diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index edcc0ba1019..702d79bbee1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: steps: - uses: actions/checkout@v5 - - uses: actions/setup-python@v5 + - uses: actions/setup-python@v6 with: python-version: "3.13" @@ -23,7 +23,7 @@ jobs: run: sudo apt-get install gettext - name: Install uv - uses: astral-sh/setup-uv@v6 + uses: astral-sh/setup-uv@v7 - name: Build HTML Docs run: VERSION=${{ github.event.repository.default_branch }} JOBS=4 MODE=html make all diff --git a/.github/workflows/deploy-gh-page.yml b/.github/workflows/deploy-gh-page.yml index 391bfc79024..c0bff8f5341 100644 --- a/.github/workflows/deploy-gh-page.yml +++ b/.github/workflows/deploy-gh-page.yml @@ -3,7 +3,7 @@ name: deploy-gh-page on: push: branches: - - "3.13" + - "3.14" jobs: cd: @@ -15,7 +15,7 @@ jobs: run: sudo apt-get install gettext - name: Install uv - uses: astral-sh/setup-uv@v6 + uses: astral-sh/setup-uv@v7 - name: Build run: JOBS=4 MODE=html make all diff --git a/.github/workflows/py313-sync-cpython.yml b/.github/workflows/py314-sync-cpython.yml similarity index 92% rename from .github/workflows/py313-sync-cpython.yml rename to .github/workflows/py314-sync-cpython.yml index ae9303b983f..9f0f5af7b1b 100644 --- a/.github/workflows/py313-sync-cpython.yml +++ b/.github/workflows/py314-sync-cpython.yml @@ -1,9 +1,9 @@ -name: python-3.13-sync-with-cpython +name: python-3.14-sync-with-cpython on: push: branches: - - "3.13" + - "3.14" schedule: - cron: "0 0 * * *" @@ -11,8 +11,8 @@ jobs: sync: runs-on: ubuntu-latest env: - VERSION: "3.13" - BRANCH: "cron/sync/3.13" + VERSION: "3.14" + BRANCH: "cron/sync/3.14" steps: - uses: actions/checkout@v5 with: @@ -31,7 +31,7 @@ jobs: run: sudo apt-get install gettext - name: Install uv - uses: astral-sh/setup-uv@v6 + uses: astral-sh/setup-uv@v7 - name: Sync with CPython run: make clone merge rm_cpython wrap diff --git a/.github/workflows/summarize_progress.yml b/.github/workflows/summarize_progress.yml index eadcf2dcf1e..700519232e3 100644 --- a/.github/workflows/summarize_progress.yml +++ b/.github/workflows/summarize_progress.yml @@ -38,7 +38,7 @@ jobs: shell: bash - name: Commit wiki code - uses: stefanzweifel/git-auto-commit-action@v6 + uses: stefanzweifel/git-auto-commit-action@v7 with: commit_message: Weekly Update -- Summarize Progress repository: markdown diff --git a/.scripts/summarize_progress/main.py b/.scripts/summarize_progress/main.py index f35f7bbd56a..b31624109c8 100644 --- a/.scripts/summarize_progress/main.py +++ b/.scripts/summarize_progress/main.py @@ -137,7 +137,7 @@ def format_line_po(filename: str, po_link: str, progress: str, num_entries: str, filedict_sorted = dict(sorted(filedict.items())) for filename, filedata in filedict_sorted.items(): file_path = f"{dirname}/{filename}" if dirname else filename - po_link = f"https://github.com/python/python-docs-zh-tw/tree/3.13/{file_path}" + po_link = f"https://github.com/python/python-docs-zh-tw/tree/3.14/{file_path}" issue_link = filedata['issue'] issue_number = f"#{issue_link.split('/')[-1]}" create_issue_link = f"https://github.com/python/python-docs-zh-tw/issues/new?title=Translate%20`{file_path}`" diff --git a/Makefile b/Makefile index c0da35f4af8..68604f26330 100644 --- a/Makefile +++ b/Makefile @@ -38,7 +38,7 @@ endef export PRINT_HELP_PYSCRIPT # End of python section CPYTHON_CLONE := ../cpython -VERSION := $(or $(VERSION), 3.13) +VERSION := $(or $(VERSION), 3.14) SPHINX_CONF := $(CPYTHON_CLONE)/Doc/conf.py LANGUAGE := zh_TW LC_MESSAGES := $(CPYTHON_CLONE)/Doc/locales/$(LANGUAGE)/LC_MESSAGES diff --git a/README.rst b/README.rst index 0fa98b4abcb..14ff6f6038e 100644 --- a/README.rst +++ b/README.rst @@ -6,7 +6,7 @@ Python 官方說明文件臺灣繁體中文翻譯計畫 :target: https://discord.gg/44XheGXhWH :alt: Join Chat on Discord -這是 Python 3.13 官方說明文件的臺灣繁體中文(zh_TW)翻譯。 +這是 Python 3.14 官方說明文件的臺灣繁體中文(zh_TW)翻譯。 翻譯之前,請務必詳讀並同意\ `授權與 License`_。參與方式請參考\ `參與翻譯`_。 @@ -133,13 +133,13 @@ the PSF for inclusion in the documentation. 接著在 terminal 裡按照以下步驟: -1. 基於最新版本的 ``upstream/3.13`` 開啟一個 branch,現在假設我們想要翻譯 library/math.po \ +1. 基於最新版本的 ``upstream/3.14`` 開啟一個 branch,現在假設我們想要翻譯 library/math.po \ 所以把這個 branch 叫做 ``library/math``: .. code-block:: bash git fetch upstream - git checkout -b library/math upstream/3.13 + git checkout -b library/math upstream/3.14 2. 接著就可以開始翻譯(翻譯時可參考\ `翻譯守則`_),你可以手動開啟 Poedit 應用程式再選 \ library/math.po 檔案打開 @@ -223,7 +223,7 @@ the PSF for inclusion in the documentation. - 從 upstream(我們的主要 GitHub repo)做 fetch 的動作 - 對 origin(你的 fork)做 push -- 永遠不對 ``3.13`` branch 進行修改,請保持讓這個 branch 唯讀,可以避免掉很多問題。 +- 永遠不對 ``3.14`` branch 進行修改,請保持讓這個 branch 唯讀,可以避免掉很多問題。 要翻譯哪些東西 -------------- diff --git a/about.po b/about.po index a95b16de88a..0ebe85514ff 100644 --- a/about.po +++ b/about.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -11,7 +11,7 @@ # hsiao yi , 2015 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2025-01-01 00:15+0000\n" "PO-Revision-Date: 2022-05-12 00:11+0800\n" diff --git a/bugs.po b/bugs.po index 2837ebfc0a4..4bd3a6eb498 100644 --- a/bugs.po +++ b/bugs.po @@ -1,5 +1,4 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -11,9 +10,9 @@ # Steven Hsu , 2021-2022 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-04-18 19:45+0000\n" +"POT-Creation-Date: 2025-10-20 00:15+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-" @@ -55,15 +54,25 @@ msgstr "說明文件的錯誤" #: ../../bugs.rst:18 msgid "" "If you find a bug in this documentation or would like to propose an " -"improvement, please submit a bug report on the :ref:`tracker `. If you have a suggestion on how to fix it, include that as well." +"improvement, please submit a bug report on the :ref:`issue tracker `. If you have a suggestion on how to fix it, include that as " +"well." msgstr "" -"如果你在這份說明文件中發現了錯誤並想要幫助我們改進,請將錯誤報告提交到\\ :" -"ref:`追蹤系統 (tracker) `。如果你有相應的修正建議,請一併" -"提交。(譯者註:如果是繁體中文說明文件翻譯相關的錯誤,請提交到 https://" -"github.com/python/python-docs-zh-tw/issues。)" +"如果你在這份說明文件中發現了錯誤並想要提出改進方案,請將錯誤報告提交到\\ :" +"ref:`錯誤追蹤系統 (issue tracker) `。如果你有相應的修正建" +"議,請一併提交。(譯者註:如果是繁體中文說明文件翻譯相關的錯誤,請提交到 " +"https://github.com/python/python-docs-zh-tw/issues。)" -#: ../../bugs.rst:22 +#: ../../bugs.rst:24 +msgid "" +"If the bug or suggested improvement concerns the translation of this " +"documentation, submit the report to the `translation’s repository " +"`_ instead." +msgstr "" +"如果錯誤或建議的改進涉及此文件的翻譯,請將報告提交到\\ `翻譯存儲庫 " +"`_。" + +#: ../../bugs.rst:28 msgid "" "You can also open a discussion item on our `Documentation Discourse forum " "`_." @@ -71,44 +80,36 @@ msgstr "" "你也可以在我們的\\ `說明文件 Discourse 討論區 `_\\ 中新增一個討論事項。" -#: ../../bugs.rst:25 +#: ../../bugs.rst:31 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 bug " +"documentation, please submit a bug report on the `python-doc-theme issue " "tracker `_." msgstr "" +"如果你發現文件主題 (HTML / CSS / JavaScript) 中存在錯誤,請在 `python-doc-" +"theme 問題追蹤系統 `_\\ 上提交錯誤報" +"告。" -#: ../../bugs.rst:29 -msgid "" -"If you're short on time, you can also email documentation bug reports to " -"docs@python.org (behavioral bugs can be sent to python-list@python.org). " -"'docs@' is a mailing list run by volunteers; your request will be noticed, " -"though it may take a while to be processed." -msgstr "" -"如果你的時間有限,也可以將說明文件的錯誤報告以電子郵件寄到 docs@python.org\\ " -"(程式碼執行的錯誤可以寄到 python-list@python.org)。「docs@」是一個由志工們" -"所運行的郵寄清單;你的請求會被注意到,但可能需要一些時間才會被處理。" - -#: ../../bugs.rst:36 +#: ../../bugs.rst:37 msgid "`Documentation bugs`_" msgstr "`說明文件錯誤`_" -#: ../../bugs.rst:37 +#: ../../bugs.rst:38 msgid "" "A list of documentation bugs that have been submitted to the Python issue " "tracker." msgstr "一系列已被提交至 Python 問題追蹤系統的有關說明文件的錯誤。" -#: ../../bugs.rst:39 +#: ../../bugs.rst:40 msgid "`Issue Tracking `_" msgstr "`問題追蹤系統 `_" -#: ../../bugs.rst:40 +#: ../../bugs.rst:41 msgid "" "Overview of the process involved in reporting an improvement on the tracker." msgstr "在追蹤系統上回報改進建議的過程簡介。" -#: ../../bugs.rst:42 +#: ../../bugs.rst:43 msgid "" "`Helping with Documentation `_" @@ -116,20 +117,20 @@ msgstr "" "`貢獻說明文件 `_" -#: ../../bugs.rst:43 +#: ../../bugs.rst:44 msgid "" "Comprehensive guide for individuals that are interested in contributing to " "Python documentation." msgstr "給有意成為 Python 說明文件貢獻者的綜合指南。" -#: ../../bugs.rst:45 +#: ../../bugs.rst:46 msgid "" "`Documentation Translations `_" msgstr "" "`說明文件翻譯 `_" -#: ../../bugs.rst:46 +#: ../../bugs.rst:47 msgid "" "A list of GitHub pages for documentation translation and their primary " "contacts." @@ -137,11 +138,11 @@ msgstr "" "一份 GitHub 網頁的清單,裡面有各個說明文件翻譯團隊的連結,以及他們的主要聯絡" "人。" -#: ../../bugs.rst:52 +#: ../../bugs.rst:53 msgid "Using the Python issue tracker" msgstr "使用 Python 問題追蹤系統" -#: ../../bugs.rst:54 +#: ../../bugs.rst:55 msgid "" "Issue reports for Python itself should be submitted via the GitHub issues " "tracker (https://github.com/python/cpython/issues). The GitHub issues " @@ -152,7 +153,7 @@ msgstr "" "python/cpython/issues) 提交。這個 GitHub 問題追蹤系統提供了一個網頁表單,可以" "輸入並提交相關資訊給開發者。" -#: ../../bugs.rst:59 +#: ../../bugs.rst:60 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 " @@ -167,7 +168,7 @@ msgstr "" "本中修正了這個問題,也有可能需要更詳細的資訊(在這種情況下,如果可以,非常歡" "迎你提供資訊!)。要確認是否重複回報,請使用頁面頂端的搜尋框來搜尋追蹤系統。" -#: ../../bugs.rst:66 +#: ../../bugs.rst:67 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 " @@ -177,7 +178,7 @@ msgstr "" "如果你想回報的問題還沒有在問題列表出現過,請登入 GitHub。如果你還沒有 GitHub " "帳戶,請點選「Sign up」連結來建立一個新的帳戶。你無法以匿名方式提交錯誤報告。" -#: ../../bugs.rst:71 +#: ../../bugs.rst:72 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." @@ -185,18 +186,18 @@ msgstr "" "如果已經登入,那你就可以提交問題了。請點選列表頂端區域的「New issue」按鈕,來" "回報一個新的問題。" -#: ../../bugs.rst:74 +#: ../../bugs.rst:75 msgid "The submission form has two fields, \"Title\" and \"Comment\"." msgstr "提交的表單中有兩個欄位,「Title」及「Comment」。" -#: ../../bugs.rst:76 +#: ../../bugs.rst:77 msgid "" "For the \"Title\" field, enter a *very* short description of the problem; " "fewer than ten words is good." msgstr "" "在「Title」欄位,輸入對該問題\\ *非常*\\ 簡短的描述;最好少於十個單字。" -#: ../../bugs.rst:79 +#: ../../bugs.rst:80 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 " @@ -207,7 +208,7 @@ msgstr "" "確定說明中包含了涉及到的任何擴充模組,以及你當時所使用的硬體和軟體平台(視情" "況而定,可以附上版本資訊)。" -#: ../../bugs.rst:84 +#: ../../bugs.rst:85 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 " @@ -216,7 +217,7 @@ msgstr "" "每一份問題報告都會被一位開發人員查核,並由他決定要做出什麼變更來修正這個問" "題。每當該問題有修正動作時,你會收到更新回報。" -#: ../../bugs.rst:91 +#: ../../bugs.rst:92 msgid "" "`How to Report Bugs Effectively `_" @@ -224,7 +225,7 @@ msgstr "" "`如何有效地回報錯誤 `_" -#: ../../bugs.rst:92 +#: ../../bugs.rst:93 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." @@ -232,14 +233,14 @@ msgstr "" "這篇文章詳細說明如何建立一份有用的錯誤報告。它描述了什麼樣的資訊是有用的,以" "及這些資訊為什麼有用。" -#: ../../bugs.rst:95 +#: ../../bugs.rst:96 msgid "" "`Bug Writing Guidelines `_" msgstr "" "`錯誤撰寫指南 `_" -#: ../../bugs.rst:96 +#: ../../bugs.rst:97 msgid "" "Information about writing a good bug report. Some of this is specific to " "the Mozilla project, but describes general good practices." @@ -247,11 +248,11 @@ msgstr "" "撰寫一份優良錯誤報告的相關資訊。部分的文章內容是針對 Mozilla 專案,但它也描述" "了通用的好習慣。" -#: ../../bugs.rst:102 +#: ../../bugs.rst:103 msgid "Getting started contributing to Python yourself" msgstr "開始讓自己貢獻 Python" -#: ../../bugs.rst:104 +#: ../../bugs.rst:105 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/c-api/abstract.po b/c-api/abstract.po index 87e9a0091e1..ef695f4ea5d 100644 --- a/c-api/abstract.po +++ b/c-api/abstract.po @@ -1,5 +1,4 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -8,7 +7,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2018-06-26 18:54+0800\n" "PO-Revision-Date: 2021-12-09 21:20+0800\n" diff --git a/c-api/allocation.po b/c-api/allocation.po index d1b75248593..616ca9afcfc 100644 --- a/c-api/allocation.po +++ b/c-api/allocation.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -7,9 +7,9 @@ # msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"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: 2025-11-09 17:02+0000\n" "PO-Revision-Date: 2022-10-16 15:35+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -29,84 +29,174 @@ msgstr "在 heap 上分配物件" msgid "" "Initialize a newly allocated object *op* with its type and initial " "reference. Returns the initialized object. Other fields of the object are " -"not affected." +"not initialized. Despite its name, this function is unrelated to the " +"object's :meth:`~object.__init__` method (:c:member:`~PyTypeObject.tp_init` " +"slot). Specifically, this function does **not** call the object's :meth:`!" +"__init__` method." msgstr "" -"用它的型別和初始參照來初始化新分配物件 *op*。已初始化的物件會被回傳。物件的其" -"他欄位不受影響。" #: ../../c-api/allocation.rst:24 msgid "" +"In general, consider this function to be a low-level routine. Use :c:member:" +"`~PyTypeObject.tp_alloc` where possible. For implementing :c:member:`!" +"tp_alloc` for your type, prefer :c:func:`PyType_GenericAlloc` or :c:func:" +"`PyObject_New`." +msgstr "" + +#: ../../c-api/allocation.rst:31 +msgid "" +"This function only initializes the object's memory corresponding to the " +"initial :c:type:`PyObject` structure. It does not zero the rest." +msgstr "" + +#: ../../c-api/allocation.rst:37 +msgid "" "This does everything :c:func:`PyObject_Init` does, and also initializes the " "length information for a variable-size object." msgstr "" "它會做到 :c:func:`PyObject_Init` 的所有功能,並且會初始化一個大小可變物件的長" "度資訊。" -#: ../../c-api/allocation.rst:30 +#: ../../c-api/allocation.rst:42 +msgid "" +"This function only initializes some of the object's memory. It does not " +"zero the rest." +msgstr "" + +#: ../../c-api/allocation.rst:48 msgid "" -"Allocate a new Python object using the C structure type *TYPE* and the " -"Python type object *typeobj* (``PyTypeObject*``). Fields not defined by the " -"Python object header are not initialized. The caller will own the only " -"reference to the object (i.e. its reference count will be one). The size of " -"the memory allocation is determined from the :c:member:`~PyTypeObject." -"tp_basicsize` field of the type object." +"Allocates a new Python object using the C structure type *TYPE* and the " +"Python type object *typeobj* (``PyTypeObject*``) by calling :c:func:" +"`PyObject_Malloc` to allocate memory and initializing it like :c:func:" +"`PyObject_Init`. The caller will own the only reference to the object (i.e. " +"its reference count will be one)." msgstr "" "使用 C 結構型別 *TYPE* 和 Python 型別物件 *typeobj* (``PyTypeObject*``) 分配" -"一個新的 Python 物件。未在該 Python 物件標頭 (header) 中定義的欄位不會被初始" -"化;呼叫者會擁有那個對於物件的唯一參照(物件的參照計數為一)。記憶體分配大小" -"由 type 物件的 :c:member:`~PyTypeObject.tp_basicsize` 欄位來指定。" +"一個新的 Python 物件。它會呼叫 :c:func:`PyObject_Malloc` 來分配記憶體,並且會" +"像 :c:func:`PyObject_Init` 一樣初始化它。呼叫者會擁有該物件的唯一參照(也就是" +"它的參照計數會是 1)。" -#: ../../c-api/allocation.rst:38 +#: ../../c-api/allocation.rst:54 ../../c-api/allocation.rst:107 msgid "" -"Note that this function is unsuitable if *typeobj* has :c:macro:" -"`Py_TPFLAGS_HAVE_GC` set. For such objects, use :c:func:`PyObject_GC_New` " -"instead." +"Avoid calling this directly to allocate memory for an object; call the " +"type's :c:member:`~PyTypeObject.tp_alloc` slot instead." msgstr "" -"注意,如果 *typeobj* 有 :c:macro:`Py_TPFLAGS_HAVE_GC` 設定,則此函式不適用。" -"對於這種物件,請改用 :c:func:`PyObject_GC_New`。" -#: ../../c-api/allocation.rst:45 +#: ../../c-api/allocation.rst:57 ../../c-api/allocation.rst:110 msgid "" -"Allocate a new Python object using the C structure type *TYPE* and the " -"Python type object *typeobj* (``PyTypeObject*``). Fields not defined by the " -"Python object header are not initialized. The allocated memory allows for " -"the *TYPE* structure plus *size* (``Py_ssize_t``) fields of the size given " -"by the :c:member:`~PyTypeObject.tp_itemsize` field of *typeobj*. This is " -"useful for implementing objects like tuples, which are able to determine " -"their size at construction time. Embedding the array of fields into the " -"same allocation decreases the number of allocations, improving the memory " -"management efficiency." +"When populating a type's :c:member:`~PyTypeObject.tp_alloc` slot, :c:func:" +"`PyType_GenericAlloc` is preferred over a custom function that simply calls " +"this macro." msgstr "" -"使用 C 的結構型別 *TYPE* 和 Python 的型別物件 *typeobj* (``PyTypeObject*``) " -"分配一個新的 Python 物件。未在該 Python 物件標頭中定義的欄位不會被初始化。記" -"憶體空間預留了 *TYPE* 結構大小再加上 *typeobj* 物件中 :c:member:" -"`~PyTypeObject.tp_itemsize` 欄位提供的 *size* (``Py_ssize_t``) 欄位的值。這對" -"於實現如 tuple 這種能夠在建立期間決定自己大小的物件是很實用的。將欄位的陣列嵌" -"入到相同的記憶體分配中可以減少記憶體分配的次數,這提高了記憶體管理的效率。" -#: ../../c-api/allocation.rst:56 +#: ../../c-api/allocation.rst:61 msgid "" -"Note that this function is unsuitable if *typeobj* has :c:macro:" -"`Py_TPFLAGS_HAVE_GC` set. For such objects, use :c:func:`PyObject_GC_NewVar` " -"instead." +"This macro does not call :c:member:`~PyTypeObject.tp_alloc`, :c:member:" +"`~PyTypeObject.tp_new` (:meth:`~object.__new__`), or :c:member:" +"`~PyTypeObject.tp_init` (:meth:`~object.__init__`)." msgstr "" -"注意,如果 *typeobj* 有 :c:macro:`Py_TPFLAGS_HAVE_GC` 設定,則此函式不適用。" -"對於這種物件,請改用 :c:func:`PyObject_GC_NewVar`。" +"這個巨集不會呼叫 :c:member:`~PyTypeObject.tp_alloc`、:c:member:" +"`~PyTypeObject.tp_new` (:meth:`~object.__new__`)、或 :c:member:" +"`~PyTypeObject.tp_init` (:meth:`~object.__init__`)。" -#: ../../c-api/allocation.rst:63 +#: ../../c-api/allocation.rst:65 msgid "" -"Releases memory allocated to an object using :c:macro:`PyObject_New` or :c:" -"macro:`PyObject_NewVar`. This is normally called from the :c:member:" -"`~PyTypeObject.tp_dealloc` handler specified in the object's type. The " -"fields of the object should not be accessed after this call as the memory is " -"no longer a valid Python object." +"This cannot be used for objects with :c:macro:`Py_TPFLAGS_HAVE_GC` set in :c:" +"member:`~PyTypeObject.tp_flags`; use :c:macro:`PyObject_GC_New` instead." msgstr "" -"釋放由 :c:macro:`PyObject_New` 或者 :c:macro:`PyObject_NewVar` 分配給物件的記" -"憶體。這通常是在物件型別所指定的 :c:member:`~PyTypeObject.tp_dealloc` " -"handler 中呼叫。呼叫這個函式以後,物件的各欄位都不可以被存取,因為原本分配的" -"記憶體已不再是一個有效的 Python 物件。" +"這不能用於有在 :c:member:`~PyTypeObject.tp_flags` 中設定 :c:macro:" +"`Py_TPFLAGS_HAVE_GC` 的物件;請改用 :c:macro:`PyObject_GC_New`。" -#: ../../c-api/allocation.rst:72 +#: ../../c-api/allocation.rst:68 +msgid "" +"Memory allocated by this macro must be freed with :c:func:`PyObject_Free` " +"(usually called via the object's :c:member:`~PyTypeObject.tp_free` slot)." +msgstr "" + +#: ../../c-api/allocation.rst:73 ../../c-api/allocation.rst:123 +msgid "" +"The returned memory is not guaranteed to have been completely zeroed before " +"it was initialized." +msgstr "" + +#: ../../c-api/allocation.rst:78 ../../c-api/allocation.rst:128 +msgid "" +"This macro does not construct a fully initialized object of the given type; " +"it merely allocates memory and prepares it for further initialization by :c:" +"member:`~PyTypeObject.tp_init`. To construct a fully initialized object, " +"call *typeobj* instead. For example::" +msgstr "" + +#: ../../c-api/allocation.rst:83 +msgid "PyObject *foo = PyObject_CallNoArgs((PyObject *)&PyFoo_Type);" +msgstr "PyObject *foo = PyObject_CallNoArgs((PyObject *)&PyFoo_Type);" + +#: ../../c-api/allocation.rst:87 ../../c-api/allocation.rst:137 +#: ../../c-api/allocation.rst:182 ../../c-api/allocation.rst:184 +#: ../../c-api/allocation.rst:186 +msgid ":c:func:`PyObject_Free`" +msgstr ":c:func:`PyObject_Free`" + +#: ../../c-api/allocation.rst:88 +msgid ":c:macro:`PyObject_GC_New`" +msgstr ":c:macro:`PyObject_GC_New`" + +#: ../../c-api/allocation.rst:89 ../../c-api/allocation.rst:139 +msgid ":c:func:`PyType_GenericAlloc`" +msgstr ":c:func:`PyType_GenericAlloc`" + +#: ../../c-api/allocation.rst:90 ../../c-api/allocation.rst:140 +msgid ":c:member:`~PyTypeObject.tp_alloc`" +msgstr ":c:member:`~PyTypeObject.tp_alloc`" + +#: ../../c-api/allocation.rst:95 +msgid "Like :c:macro:`PyObject_New` except:" +msgstr "和 :c:macro:`PyObject_New` 類似,但有以下差異:" + +#: ../../c-api/allocation.rst:97 +msgid "" +"It allocates enough memory for the *TYPE* structure plus *size* " +"(``Py_ssize_t``) fields of the size given by the :c:member:`~PyTypeObject." +"tp_itemsize` field of *typeobj*." +msgstr "" + +#: ../../c-api/allocation.rst:100 +msgid "The memory is initialized like :c:func:`PyObject_InitVar`." +msgstr "記憶體會像 :c:func:`PyObject_InitVar` 一樣被初始化。" + +#: ../../c-api/allocation.rst:102 +msgid "" +"This is useful for implementing objects like tuples, which are able to " +"determine their size at construction time. Embedding the array of fields " +"into the same allocation decreases the number of allocations, improving the " +"memory management efficiency." +msgstr "" + +#: ../../c-api/allocation.rst:114 +msgid "" +"This cannot be used for objects with :c:macro:`Py_TPFLAGS_HAVE_GC` set in :c:" +"member:`~PyTypeObject.tp_flags`; use :c:macro:`PyObject_GC_NewVar` instead." +msgstr "" +"這不能用於有在 :c:member:`~PyTypeObject.tp_flags` 中設定 :c:macro:" +"`Py_TPFLAGS_HAVE_GC` 的物件;請改用 :c:macro:`PyObject_GC_NewVar`。" + +#: ../../c-api/allocation.rst:118 +msgid "" +"Memory allocated by this function must be freed with :c:func:`PyObject_Free` " +"(usually called via the object's :c:member:`~PyTypeObject.tp_free` slot)." +msgstr "" + +#: ../../c-api/allocation.rst:133 +msgid "" +"PyObject *list_instance = PyObject_CallNoArgs((PyObject *)&PyList_Type);" +msgstr "" +"PyObject *list_instance = PyObject_CallNoArgs((PyObject *)&PyList_Type);" + +#: ../../c-api/allocation.rst:138 +msgid ":c:macro:`PyObject_GC_NewVar`" +msgstr ":c:macro:`PyObject_GC_NewVar`" + +#: ../../c-api/allocation.rst:145 msgid "" "Object which is visible in Python as ``None``. This should only be accessed " "using the :c:macro:`Py_None` macro, which evaluates to a pointer to this " @@ -115,10 +205,52 @@ msgstr "" "這個物件像是 Python 中的 ``None``。它只應該透過 :c:macro:`Py_None` 巨集來存" "取,該巨集的拿到指向該物件的指標。" -#: ../../c-api/allocation.rst:79 +#: ../../c-api/allocation.rst:152 msgid ":ref:`moduleobjects`" msgstr ":ref:`moduleobjects`" -#: ../../c-api/allocation.rst:80 +#: ../../c-api/allocation.rst:153 msgid "To allocate and create extension modules." msgstr "分配記憶體和建立擴充模組。" + +#: ../../c-api/allocation.rst:157 +msgid "Deprecated aliases" +msgstr "被棄用的別名" + +#: ../../c-api/allocation.rst:159 +msgid "" +"These are :term:`soft deprecated` aliases to existing functions and macros. " +"They exist solely for backwards compatibility." +msgstr "" + +#: ../../c-api/allocation.rst:167 +msgid "Deprecated alias" +msgstr "已棄用的別名" + +#: ../../c-api/allocation.rst:168 +msgid "Function" +msgstr "函式" + +#: ../../c-api/allocation.rst:170 +msgid ":c:macro:`PyObject_New`" +msgstr ":c:macro:`PyObject_New`" + +#: ../../c-api/allocation.rst:172 +msgid ":c:macro:`PyObject_NewVar`" +msgstr ":c:macro:`PyObject_NewVar`" + +#: ../../c-api/allocation.rst:174 +msgid ":c:func:`PyObject_Init`" +msgstr ":c:func:`PyObject_Init`" + +#: ../../c-api/allocation.rst:176 +msgid ":c:func:`PyObject_InitVar`" +msgstr ":c:func:`PyObject_InitVar`" + +#: ../../c-api/allocation.rst:178 +msgid ":c:func:`PyObject_Malloc`" +msgstr ":c:func:`PyObject_Malloc`" + +#: ../../c-api/allocation.rst:180 +msgid ":c:func:`PyObject_Realloc`" +msgstr ":c:func:`PyObject_Realloc`" diff --git a/c-api/apiabiversion.po b/c-api/apiabiversion.po index 8b589303e89..ac7a67f22c8 100644 --- a/c-api/apiabiversion.po +++ b/c-api/apiabiversion.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -6,9 +6,9 @@ # Matt Wang , 2022 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-07-29 00:03+0000\n" +"POT-Creation-Date: 2025-09-08 15:25+0800\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-" @@ -24,33 +24,37 @@ msgstr "" msgid "API and ABI Versioning" msgstr "API 和 ABI 版本管理" -#: ../../c-api/apiabiversion.rst:9 +#: ../../c-api/apiabiversion.rst:11 +msgid "Build-time version constants" +msgstr "" + +#: ../../c-api/apiabiversion.rst:13 msgid "" "CPython exposes its version number in the following macros. Note that these " -"correspond to the version code is **built** with, not necessarily the " -"version used at **run time**." +"correspond to the version code is **built** with. See :c:var:`Py_Version` " +"for the version used at **run time**." msgstr "" "CPython 透過以下巨集 (macro) 公開其版本號。請注意,對應到的是\\ **建置 " -"(built)** 所用到的版本,並不一定是\\ **執行環境 (run time)** 所使用的版本。" +"(built)** 所用到的版本。關於\\ **run time** 所使用的版本,請見 :c:var:`Py_Version`。" -#: ../../c-api/apiabiversion.rst:13 +#: ../../c-api/apiabiversion.rst:17 msgid "" "See :ref:`stable` for a discussion of API and ABI stability across versions." msgstr "關於跨版本 API 和 ABI 穩定性的討論,請見 :ref:`stable`。" -#: ../../c-api/apiabiversion.rst:17 +#: ../../c-api/apiabiversion.rst:21 msgid "The ``3`` in ``3.4.1a2``." msgstr "在 ``3.4.1a2`` 中的 ``3``。" -#: ../../c-api/apiabiversion.rst:21 +#: ../../c-api/apiabiversion.rst:25 msgid "The ``4`` in ``3.4.1a2``." msgstr "在 ``3.4.1a2`` 中的 ``4``。" -#: ../../c-api/apiabiversion.rst:25 +#: ../../c-api/apiabiversion.rst:29 msgid "The ``1`` in ``3.4.1a2``." msgstr "在 ``3.4.1a2`` 中的 ``1``。" -#: ../../c-api/apiabiversion.rst:29 +#: ../../c-api/apiabiversion.rst:33 msgid "" "The ``a`` in ``3.4.1a2``. This can be ``0xA`` for alpha, ``0xB`` for beta, " "``0xC`` for release candidate or ``0xF`` for final." @@ -58,137 +62,241 @@ msgstr "" "在 ``3.4.1a2`` 中的 ``a``。``0xA`` 代表 alpha 版本、``0xB`` 代表 beta 版本、" "``0xC`` 為發布候選版本、``0xF`` 則為最終版。" -#: ../../c-api/apiabiversion.rst:35 +#: ../../c-api/apiabiversion.rst:39 msgid "The ``2`` in ``3.4.1a2``. Zero for final releases." msgstr "在 ``3.4.1a2`` 中的 ``2``。零則為最終發布版本。" -#: ../../c-api/apiabiversion.rst:39 -msgid "The Python version number encoded in a single integer." -msgstr "被編碼為單一整數的 Python 版本號。" +#: ../../c-api/apiabiversion.rst:43 +msgid "" +"The Python version number encoded in a single integer. " +"See :c:func:`Py_PACK_FULL_VERSION` for the encoding details." +msgstr "被編碼為單一整數的 Python 版本號。詳見 :c:func:`Py_PACK_FULL_VERSION` 以了解編碼詳細資訊。" -#: ../../c-api/apiabiversion.rst:41 +#: ../../c-api/apiabiversion.rst:46 msgid "" -"The underlying version information can be found by treating it as a 32 bit " -"number in the following manner:" -msgstr "所代表的版本資訊可以用以下規則將其看做是一個 32 位元數字來獲得:" +"Use this for numeric comparisons, for example, ``#if PY_VERSION_HEX >= ...``." +msgstr "使用它進行數值比較,例如 ``#if PY_VERSION_HEX >= ...``。" -#: ../../c-api/apiabiversion.rst:45 -msgid "Bytes" -msgstr "位元組串" +#: ../../c-api/apiabiversion.rst:51 +msgid "Run-time version" +msgstr "" -#: ../../c-api/apiabiversion.rst:45 -msgid "Bits (big endian order)" -msgstr "位元(大端位元組序 (big endian order))" +#: ../../c-api/apiabiversion.rst:55 +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 Python version used at run time." +msgstr "" +"編碼為單個常數整數的 Python runtime 版本號。詳見 :c:func:`Py_PACK_FULL_VERSION` " +"以了解編碼詳細資訊。這包含在 runtime 使用的 Python 版本。" -#: ../../c-api/apiabiversion.rst:45 -msgid "Meaning" -msgstr "意義" +#: ../../c-api/apiabiversion.rst:59 +msgid "" +"Use this for numeric comparisons, for example, ``if (Py_Version >= ...)``." +msgstr "使用它進行數值比較,例如 ``if (Py_Version >= ...)``。" -#: ../../c-api/apiabiversion.rst:45 -msgid "Value for ``3.4.1a2``" -msgstr "``3.4.1a2`` 中的值" +#: ../../c-api/apiabiversion.rst:65 +msgid "Bit-packing macros" +msgstr "" -#: ../../c-api/apiabiversion.rst:47 -msgid "1" -msgstr "1" +#: ../../c-api/apiabiversion.rst:69 +msgid "" +"Return the given version, encoded as a single 32-bit integer with the " +"following structure:" +msgstr "" -#: ../../c-api/apiabiversion.rst:47 -msgid "1-8" -msgstr "1-8" +#: ../../c-api/apiabiversion.rst:75 +msgid "Argument" +msgstr "引數" + +#: ../../c-api/apiabiversion.rst:73 +msgid "No. of bits" +msgstr "" + +#: ../../c-api/apiabiversion.rst:75 +msgid "Bit mask" +msgstr "" + +#: ../../c-api/apiabiversion.rst:75 +msgid "Bit shift" +msgstr "" + +#: ../../c-api/apiabiversion.rst:73 +msgid "Example values" +msgstr "" -#: ../../c-api/apiabiversion.rst:47 -msgid "``PY_MAJOR_VERSION``" -msgstr "``PY_MAJOR_VERSION``" +#: ../../c-api/apiabiversion.rst:75 ../../c-api/apiabiversion.rst:93 +msgid "``3.4.1a2``" +msgstr "``3.4.1a2``" -#: ../../c-api/apiabiversion.rst:47 +#: ../../c-api/apiabiversion.rst:75 ../../c-api/apiabiversion.rst:95 +msgid "``3.10.0``" +msgstr "``3.10.0``" + +#: ../../c-api/apiabiversion.rst:77 +msgid "*major*" +msgstr "*major*" + +#: ../../c-api/apiabiversion.rst:77 ../../c-api/apiabiversion.rst:79 +#: ../../c-api/apiabiversion.rst:81 +msgid "8" +msgstr "8" + +#: ../../c-api/apiabiversion.rst:77 +msgid "``0xFF000000``" +msgstr "``0xFF000000``" + +#: ../../c-api/apiabiversion.rst:77 +msgid "24" +msgstr "24" + +#: ../../c-api/apiabiversion.rst:77 msgid "``0x03``" msgstr "``0x03``" -#: ../../c-api/apiabiversion.rst:49 -msgid "2" -msgstr "2" +#: ../../c-api/apiabiversion.rst:79 +msgid "*minor*" +msgstr "" -#: ../../c-api/apiabiversion.rst:49 -msgid "9-16" -msgstr "9-16" +#: ../../c-api/apiabiversion.rst:79 +msgid "``0x00FF0000``" +msgstr "``0x00FF0000``" -#: ../../c-api/apiabiversion.rst:49 -msgid "``PY_MINOR_VERSION``" -msgstr "``PY_MINOR_VERSION``" +#: ../../c-api/apiabiversion.rst:79 +msgid "16" +msgstr "16" -#: ../../c-api/apiabiversion.rst:49 +#: ../../c-api/apiabiversion.rst:79 msgid "``0x04``" msgstr "``0x04``" -#: ../../c-api/apiabiversion.rst:51 -msgid "3" -msgstr "3" +#: ../../c-api/apiabiversion.rst:79 +msgid "``0x0A``" +msgstr "``0x0A``" -#: ../../c-api/apiabiversion.rst:51 -msgid "17-24" -msgstr "17-24" +#: ../../c-api/apiabiversion.rst:81 +msgid "*micro*" +msgstr "*micro*" -#: ../../c-api/apiabiversion.rst:51 -msgid "``PY_MICRO_VERSION``" -msgstr "``PY_MICRO_VERSION``" +#: ../../c-api/apiabiversion.rst:81 +msgid "``0x0000FF00``" +msgstr "``0x0000FF00``" -#: ../../c-api/apiabiversion.rst:51 +#: ../../c-api/apiabiversion.rst:81 msgid "``0x01``" msgstr "``0x01``" -#: ../../c-api/apiabiversion.rst:53 +#: ../../c-api/apiabiversion.rst:81 +msgid "``0x00``" +msgstr "``0x00``" + +#: ../../c-api/apiabiversion.rst:83 +msgid "*release_level*" +msgstr "*release_level*" + +#: ../../c-api/apiabiversion.rst:83 ../../c-api/apiabiversion.rst:85 msgid "4" msgstr "4" -#: ../../c-api/apiabiversion.rst:53 -msgid "25-28" -msgstr "25-28" - -#: ../../c-api/apiabiversion.rst:53 -msgid "``PY_RELEASE_LEVEL``" -msgstr "``PY_RELEASE_LEVEL``" +#: ../../c-api/apiabiversion.rst:83 +msgid "``0x000000F0``" +msgstr "``0x000000F0``" -#: ../../c-api/apiabiversion.rst:53 +#: ../../c-api/apiabiversion.rst:83 msgid "``0xA``" msgstr "``0xA``" -#: ../../c-api/apiabiversion.rst:55 -msgid "29-32" -msgstr "29-32" +#: ../../c-api/apiabiversion.rst:83 +msgid "``0xF``" +msgstr "``0xF``" -#: ../../c-api/apiabiversion.rst:55 -msgid "``PY_RELEASE_SERIAL``" -msgstr "``PY_RELEASE_SERIAL``" +#: ../../c-api/apiabiversion.rst:85 +msgid "*release_serial*" +msgstr "*release_serial*" -#: ../../c-api/apiabiversion.rst:55 +#: ../../c-api/apiabiversion.rst:85 +msgid "``0x0000000F``" +msgstr "``0x0000000F``" + +#: ../../c-api/apiabiversion.rst:85 +msgid "0" +msgstr "0" + +#: ../../c-api/apiabiversion.rst:85 msgid "``0x2``" msgstr "``0x2``" -#: ../../c-api/apiabiversion.rst:58 -msgid "" -"Thus ``3.4.1a2`` is hexversion ``0x030401a2`` and ``3.10.0`` is hexversion " -"``0x030a00f0``." +#: ../../c-api/apiabiversion.rst:85 +msgid "``0x0``" +msgstr "``0x0``" + +#: ../../c-api/apiabiversion.rst:88 +msgid "For example:" +msgstr "例如:" + +#: ../../c-api/apiabiversion.rst:91 +msgid "Version" +msgstr "版本" + +#: ../../c-api/apiabiversion.rst:91 +msgid "``Py_PACK_FULL_VERSION`` arguments" +msgstr "``Py_PACK_FULL_VERSION`` 引數" + +#: ../../c-api/apiabiversion.rst:91 +msgid "Encoded version" msgstr "" -"因此 ``3.4.1a2`` 代表 hexversion ``0x030401a2``、``3.10.0`` 代表 hexversion " -"``0x030a00f0``。" -#: ../../c-api/apiabiversion.rst:61 -msgid "Use this for numeric comparisons, e.g. ``#if PY_VERSION_HEX >= ...``." -msgstr "使用它進行數值比較,例如 ``#if PY_VERSION_HEX >= ...``。" +#: ../../c-api/apiabiversion.rst:93 +msgid "``(3, 4, 1, 0xA, 2)``" +msgstr "``(3, 4, 1, 0xA, 2)``" + +#: ../../c-api/apiabiversion.rst:93 +msgid "``0x030401a2``" +msgstr "``0x030401a2``" + +#: ../../c-api/apiabiversion.rst:95 +msgid "``(3, 10, 0, 0xF, 0)``" +msgstr "``(3, 10, 0, 0xF, 0)``" -#: ../../c-api/apiabiversion.rst:63 -msgid "This version is also available via the symbol :c:var:`Py_Version`." -msgstr "該版本也可透過符號 :c:var:`Py_Version` 獲得。" +#: ../../c-api/apiabiversion.rst:95 +msgid "``0x030a00f0``" +msgstr "``0x030a00f0``" -#: ../../c-api/apiabiversion.rst:67 +#: ../../c-api/apiabiversion.rst:98 msgid "" -"The Python runtime version number encoded in a single constant integer, with " -"the same format as the :c:macro:`PY_VERSION_HEX` macro. This contains the " -"Python version used at run time." +"Out-of range bits in the arguments are ignored. That is, the macro can be " +"defined as:" msgstr "" -"編碼為單個常數整數的 Python 執行環境版本號,格式與 :c:macro:`PY_VERSION_HEX` " -"巨集相同。這包含在執行環境使用的 Python 版本。" -#: ../../c-api/apiabiversion.rst:73 -msgid "All the given macros are defined in :source:`Include/patchlevel.h`." -msgstr "所有提到的巨集都定義在 :source:`Include/patchlevel.h`。" +#: ../../c-api/apiabiversion.rst:101 +msgid "" +"#ifndef Py_PACK_FULL_VERSION\n" +"#define Py_PACK_FULL_VERSION(X, Y, Z, LEVEL, SERIAL) ( \\\n" +" (((X) & 0xff) << 24) | \\\n" +" (((Y) & 0xff) << 16) | \\\n" +" (((Z) & 0xff) << 8) | \\\n" +" (((LEVEL) & 0xf) << 4) | \\\n" +" (((SERIAL) & 0xf) << 0))\n" +"#endif" +msgstr "" +"#ifndef Py_PACK_FULL_VERSION\n" +"#define Py_PACK_FULL_VERSION(X, Y, Z, LEVEL, SERIAL) ( \\\n" +" (((X) & 0xff) << 24) | \\\n" +" (((Y) & 0xff) << 16) | \\\n" +" (((Z) & 0xff) << 8) | \\\n" +" (((LEVEL) & 0xf) << 4) | \\\n" +" (((SERIAL) & 0xf) << 0))\n" +"#endif" + +#: ../../c-api/apiabiversion.rst:112 +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:119 +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 " +"comparisons." +msgstr "" diff --git a/c-api/arg.po b/c-api/arg.po index 921b3bae7fd..faecd8282de 100644 --- a/c-api/arg.po +++ b/c-api/arg.po @@ -1,12 +1,12 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-05-06 05:40+0000\n" +"POT-Creation-Date: 2025-10-25 00:15+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-" @@ -56,7 +56,7 @@ msgstr "" #: ../../c-api/arg.rst:33 msgid "Strings and buffers" -msgstr "" +msgstr "字串與緩衝區" #: ../../c-api/arg.rst:37 msgid "" @@ -178,7 +178,7 @@ msgid "" "encoding." msgstr "" -#: ../../c-api/arg.rst:113 ../../c-api/arg.rst:593 +#: ../../c-api/arg.rst:113 ../../c-api/arg.rst:614 msgid "``z`` (:class:`str` or ``None``) [const char \\*]" msgstr "``z`` (:class:`str` 或 ``None``) [const char \\*]" @@ -298,7 +298,7 @@ msgstr "``w*`` (可讀寫 :term:`bytes-like object`) [Py_buffer]" msgid "" "This format accepts any object which implements the read-write buffer " "interface. It fills a :c:type:`Py_buffer` structure provided by the caller. " -"The buffer may contain embedded null bytes. The caller have to call :c:func:" +"The buffer may contain embedded null bytes. The caller has to call :c:func:" "`PyBuffer_Release` when it is done with the buffer." msgstr "" @@ -454,7 +454,7 @@ msgstr "" "將一個 Python 非負整數轉換成無符號 tiny integer(小整數),儲存在 C 的 :c:" "expr:`unsigned`" -#: ../../c-api/arg.rst:248 ../../c-api/arg.rst:627 +#: ../../c-api/arg.rst:248 ../../c-api/arg.rst:648 msgid "``B`` (:class:`int`) [unsigned char]" msgstr "``B`` (:class:`int`) [unsigned char]" @@ -466,7 +466,7 @@ msgstr "" "將一個 Python 整數轉換成 tiny integer,轉換過程無溢位檢查,儲存在 C 的 :c:" "expr:`unsigned char`。" -#: ../../c-api/arg.rst:252 ../../c-api/arg.rst:621 +#: ../../c-api/arg.rst:252 ../../c-api/arg.rst:642 msgid "``h`` (:class:`int`) [short int]" msgstr "``h`` (:class:`int`) [short int]" @@ -474,7 +474,7 @@ msgstr "``h`` (:class:`int`) [short int]" 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:630 +#: ../../c-api/arg.rst:255 ../../c-api/arg.rst:651 msgid "``H`` (:class:`int`) [unsigned short int]" msgstr "``H`` (:class:`int`) [unsigned short int]" @@ -486,7 +486,7 @@ msgstr "" "將一個 Python 整數轉換成 C 的 :c:expr:`unsigned short int`,轉換過程無溢位檢" "查。" -#: ../../c-api/arg.rst:259 ../../c-api/arg.rst:615 +#: ../../c-api/arg.rst:259 ../../c-api/arg.rst:636 msgid "``i`` (:class:`int`) [int]" msgstr "``i`` (:class:`int`) [int]" @@ -494,7 +494,7 @@ msgstr "``i`` (:class:`int`) [int]" 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:633 +#: ../../c-api/arg.rst:262 ../../c-api/arg.rst:654 msgid "``I`` (:class:`int`) [unsigned int]" msgstr "``I`` (:class:`int`) [unsigned int]" @@ -505,7 +505,7 @@ msgid "" msgstr "" "將一個 Python 整數轉換成 C 的 :c:expr:`unsigned int`,轉換過程無溢位檢查。" -#: ../../c-api/arg.rst:266 ../../c-api/arg.rst:624 +#: ../../c-api/arg.rst:266 ../../c-api/arg.rst:645 msgid "``l`` (:class:`int`) [long int]" msgstr "``l`` (:class:`int`) [long int]" @@ -513,7 +513,7 @@ msgstr "``l`` (:class:`int`) [long int]" 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:636 +#: ../../c-api/arg.rst:269 ../../c-api/arg.rst:657 msgid "``k`` (:class:`int`) [unsigned long]" msgstr "``k`` (:class:`int`) [unsigned long]" @@ -524,19 +524,23 @@ msgid "" msgstr "" "將一個 Python 整數轉換成 C 的 :c:expr:`unsigned long`,轉換過程無溢位檢查。" -#: ../../c-api/arg.rst:273 ../../c-api/arg.rst:639 +#: ../../c-api/arg.rst:273 ../../c-api/arg.rst:283 +msgid "Use :meth:`~object.__index__` if available." +msgstr "如有提供則使用 :meth:`~object.__index__`。" + +#: ../../c-api/arg.rst:276 ../../c-api/arg.rst:660 msgid "``L`` (:class:`int`) [long long]" msgstr "``L`` (:class:`int`) [long long]" -#: ../../c-api/arg.rst:274 +#: ../../c-api/arg.rst:277 msgid "Convert a Python integer to a C :c:expr:`long long`." msgstr "將一個 Python 整數轉換成 C 的 :c:expr:`long long`。" -#: ../../c-api/arg.rst:276 ../../c-api/arg.rst:644 +#: ../../c-api/arg.rst:279 ../../c-api/arg.rst:665 msgid "``K`` (:class:`int`) [unsigned long long]" msgstr "``K`` (:class:`int`) [unsigned long long]" -#: ../../c-api/arg.rst:277 +#: ../../c-api/arg.rst:280 msgid "" "Convert a Python integer to a C :c:expr:`unsigned long long` without " "overflow checking." @@ -544,71 +548,71 @@ msgstr "" "將一個 Python 整數轉換成 C 的 :c:expr:`unsigned long long`,轉換過程無溢位檢" "查。" -#: ../../c-api/arg.rst:280 ../../c-api/arg.rst:647 +#: ../../c-api/arg.rst:286 ../../c-api/arg.rst:668 msgid "``n`` (:class:`int`) [:c:type:`Py_ssize_t`]" msgstr "``n`` (:class:`int`) [:c:type:`Py_ssize_t`]" -#: ../../c-api/arg.rst:281 +#: ../../c-api/arg.rst:287 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:283 +#: ../../c-api/arg.rst:289 msgid "``c`` (:class:`bytes` or :class:`bytearray` of length 1) [char]" msgstr "``c`` (:class:`bytes` 或長度為 1 的 :class:`bytearray`) [char]" -#: ../../c-api/arg.rst:284 +#: ../../c-api/arg.rst:290 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:287 +#: ../../c-api/arg.rst:293 msgid "Allow :class:`bytearray` objects." msgstr "允許 :class:`bytearray` 物件。" -#: ../../c-api/arg.rst:290 ../../c-api/arg.rst:654 +#: ../../c-api/arg.rst:296 ../../c-api/arg.rst:686 msgid "``C`` (:class:`str` of length 1) [int]" msgstr "``C`` (長度為 1 的 :class:`str`) [int]" -#: ../../c-api/arg.rst:291 +#: ../../c-api/arg.rst:297 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:294 ../../c-api/arg.rst:661 +#: ../../c-api/arg.rst:300 ../../c-api/arg.rst:693 msgid "``f`` (:class:`float`) [float]" msgstr "``f`` (:class:`float`) [float]" -#: ../../c-api/arg.rst:295 +#: ../../c-api/arg.rst:301 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:297 ../../c-api/arg.rst:658 +#: ../../c-api/arg.rst:303 ../../c-api/arg.rst:690 msgid "``d`` (:class:`float`) [double]" msgstr "``d`` (:class:`float`) [double]" -#: ../../c-api/arg.rst:298 +#: ../../c-api/arg.rst:304 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:300 +#: ../../c-api/arg.rst:306 msgid "``D`` (:class:`complex`) [Py_complex]" msgstr "``D`` (:class:`complex`) [Py_complex]" -#: ../../c-api/arg.rst:301 +#: ../../c-api/arg.rst:307 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:304 +#: ../../c-api/arg.rst:310 msgid "Other objects" msgstr "其他物件" -#: ../../c-api/arg.rst:306 ../../c-api/arg.rst:667 +#: ../../c-api/arg.rst:312 ../../c-api/arg.rst:699 msgid "``O`` (object) [PyObject \\*]" msgstr "``O`` (object) [PyObject \\*]" -#: ../../c-api/arg.rst:307 +#: ../../c-api/arg.rst:313 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:" @@ -616,11 +620,11 @@ msgid "" "not increased). The pointer stored is not ``NULL``." msgstr "" -#: ../../c-api/arg.rst:313 +#: ../../c-api/arg.rst:319 msgid "``O!`` (object) [*typeobject*, PyObject \\*]" msgstr "``O!`` (object) [*typeobject*, PyObject \\*]" -#: ../../c-api/arg.rst:314 +#: ../../c-api/arg.rst:320 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 " @@ -629,11 +633,11 @@ msgid "" "required type, :exc:`TypeError` is raised." msgstr "" -#: ../../c-api/arg.rst:322 +#: ../../c-api/arg.rst:328 msgid "``O&`` (object) [*converter*, *address*]" msgstr "``O&`` (object) [*converter*, *address*]" -#: ../../c-api/arg.rst:323 +#: ../../c-api/arg.rst:329 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 " @@ -641,11 +645,11 @@ msgid "" "*converter* function in turn is called as follows::" msgstr "" -#: ../../c-api/arg.rst:328 +#: ../../c-api/arg.rst:334 msgid "status = converter(object, address);" msgstr "status = converter(object, address);" -#: ../../c-api/arg.rst:330 +#: ../../c-api/arg.rst:336 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 " @@ -655,7 +659,7 @@ msgid "" "unmodified." msgstr "" -#: ../../c-api/arg.rst:339 +#: ../../c-api/arg.rst:345 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 " @@ -664,21 +668,21 @@ msgid "" "have the same value as in the original call." msgstr "" -#: ../../c-api/arg.rst:345 +#: ../../c-api/arg.rst:351 msgid "" "Examples of converters: :c:func:`PyUnicode_FSConverter` and :c:func:" "`PyUnicode_FSDecoder`." msgstr "" -#: ../../c-api/arg.rst:348 +#: ../../c-api/arg.rst:354 msgid ":c:macro:`!Py_CLEANUP_SUPPORTED` was added." msgstr "新增 :c:macro:`!Py_CLEANUP_SUPPORTED`。" -#: ../../c-api/arg.rst:351 +#: ../../c-api/arg.rst:357 ../../c-api/arg.rst:671 msgid "``p`` (:class:`bool`) [int]" msgstr "``p`` (:class:`bool`) [int]" -#: ../../c-api/arg.rst:352 +#: ../../c-api/arg.rst:358 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 " @@ -687,28 +691,49 @@ msgid "" "how Python tests values for truth." msgstr "" -#: ../../c-api/arg.rst:360 ../../c-api/arg.rst:691 -msgid "``(items)`` (:class:`tuple`) [*matching-items*]" -msgstr "``(items)`` (:class:`tuple`) [*matching-items*]" +#: ../../c-api/arg.rst:366 +msgid "``(items)`` (sequence) [*matching-items*]" +msgstr "``(items)`` (sequence) [*matching-items*]" + +#: ../../c-api/arg.rst:367 +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 " +"*items*. The C arguments must correspond to the individual format units in " +"*items*. Format units for sequences may be nested." +msgstr "" + +#: ../../c-api/arg.rst:372 +msgid "" +"If *items* contains format units which store a :ref:`borrowed buffer ` (``s``, ``s#``, ``z``, ``z#``, ``y``, or ``y#``) or a :" +"term:`borrowed reference` (``S``, ``Y``, ``U``, ``O``, or ``O!``), the " +"object must be a Python tuple. The *converter* for the ``O&`` format unit in " +"*items* must not store a borrowed buffer or a borrowed reference." +msgstr "" -#: ../../c-api/arg.rst:361 +#: ../../c-api/arg.rst:379 msgid "" -"The object must be a Python sequence whose length is the number of format " -"units in *items*. The C arguments must correspond to the individual format " -"units in *items*. Format units for sequences may be nested." +":class:`str` and :class:`bytearray` objects no longer accepted as a sequence." msgstr "" -#: ../../c-api/arg.rst:365 +#: ../../c-api/arg.rst:382 +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 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:368 +#: ../../c-api/arg.rst:389 msgid "``|``" msgstr "``|``" -#: ../../c-api/arg.rst:369 +#: ../../c-api/arg.rst:390 msgid "" "Indicates that the remaining arguments in the Python argument list are " "optional. The C variables corresponding to optional arguments should be " @@ -717,11 +742,11 @@ msgid "" "corresponding C variable(s)." msgstr "" -#: ../../c-api/arg.rst:375 +#: ../../c-api/arg.rst:396 msgid "``$``" msgstr "``$``" -#: ../../c-api/arg.rst:376 +#: ../../c-api/arg.rst:397 msgid "" ":c:func:`PyArg_ParseTupleAndKeywords` only: Indicates that the remaining " "arguments in the Python argument list are keyword-only. Currently, all " @@ -729,36 +754,36 @@ msgid "" "be specified before ``$`` in the format string." msgstr "" -#: ../../c-api/arg.rst:384 +#: ../../c-api/arg.rst:405 msgid "``:``" msgstr "``:``" -#: ../../c-api/arg.rst:385 +#: ../../c-api/arg.rst:406 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:389 +#: ../../c-api/arg.rst:410 msgid "``;``" msgstr "``;``" -#: ../../c-api/arg.rst:390 +#: ../../c-api/arg.rst:411 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:394 +#: ../../c-api/arg.rst:415 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:398 +#: ../../c-api/arg.rst:419 msgid "" "Additional arguments passed to these functions must be addresses of " "variables whose type is determined by the format string; these are used to " @@ -768,7 +793,7 @@ msgid "" "unit in that case." msgstr "" -#: ../../c-api/arg.rst:404 +#: ../../c-api/arg.rst:425 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 " @@ -778,24 +803,24 @@ msgid "" "the following format units are left untouched." msgstr "" -#: ../../c-api/arg.rst:413 +#: ../../c-api/arg.rst:434 msgid "API Functions" msgstr "API 函式" -#: ../../c-api/arg.rst:417 +#: ../../c-api/arg.rst:438 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:424 +#: ../../c-api/arg.rst:445 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:430 +#: ../../c-api/arg.rst:451 msgid "" "Parse the parameters of a function that takes both positional and keyword " "parameters into local variables. The *keywords* argument is a ``NULL``-" @@ -805,51 +830,51 @@ msgid "" "failure, it returns false and raises the appropriate exception." msgstr "" -#: ../../c-api/arg.rst:441 +#: ../../c-api/arg.rst:462 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:445 +#: ../../c-api/arg.rst:466 msgid "" "Added support for :ref:`positional-only parameters `." msgstr "新增對\\ :ref:`僅限位置參數 `\\ 的支援。" -#: ../../c-api/arg.rst:449 +#: ../../c-api/arg.rst:470 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:458 +#: ../../c-api/arg.rst:479 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:464 +#: ../../c-api/arg.rst:485 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:473 +#: ../../c-api/arg.rst:494 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:477 +#: ../../c-api/arg.rst:498 msgid "Example::" msgstr "舉例來說: ::" -#: ../../c-api/arg.rst:479 +#: ../../c-api/arg.rst:500 msgid "" "// Function using METH_O calling convention\n" "static PyObject*\n" @@ -863,7 +888,7 @@ msgid "" "}" msgstr "" -#: ../../c-api/arg.rst:493 +#: ../../c-api/arg.rst:514 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 " @@ -881,13 +906,13 @@ msgid "" "if there was a failure." msgstr "" -#: ../../c-api/arg.rst:508 +#: ../../c-api/arg.rst:529 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:511 +#: ../../c-api/arg.rst:532 msgid "" "static PyObject *\n" "weakref_ref(PyObject *self, PyObject *args)\n" @@ -915,17 +940,17 @@ msgstr "" " return result;\n" "}" -#: ../../c-api/arg.rst:524 +#: ../../c-api/arg.rst:545 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:527 +#: ../../c-api/arg.rst:548 msgid "PyArg_ParseTuple(args, \"O|O:ref\", &object, &callback)" msgstr "PyArg_ParseTuple(args, \"O|O:ref\", &object, &callback)" -#: ../../c-api/arg.rst:531 +#: ../../c-api/arg.rst:552 msgid "" "The value to be inserted, if any, before :c:expr:`char * const *` in the " "*keywords* parameter declaration of :c:func:`PyArg_ParseTupleAndKeywords` " @@ -934,11 +959,11 @@ msgid "" "to the desired value before including :file:`Python.h`." msgstr "" -#: ../../c-api/arg.rst:545 +#: ../../c-api/arg.rst:566 msgid "Building values" msgstr "建置數值" -#: ../../c-api/arg.rst:549 +#: ../../c-api/arg.rst:570 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 " @@ -946,7 +971,7 @@ msgid "" "``NULL`` is returned." msgstr "" -#: ../../c-api/arg.rst:554 +#: ../../c-api/arg.rst:575 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 " @@ -955,7 +980,7 @@ msgid "" "it to return a tuple of size 0 or one, parenthesize the format string." msgstr "" -#: ../../c-api/arg.rst:560 +#: ../../c-api/arg.rst:581 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. " @@ -966,7 +991,7 @@ msgid "" "`Py_BuildValue` returns." msgstr "" -#: ../../c-api/arg.rst:568 +#: ../../c-api/arg.rst:589 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 " @@ -974,155 +999,167 @@ msgid "" "be passed." msgstr "" -#: ../../c-api/arg.rst:572 +#: ../../c-api/arg.rst:593 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:576 +#: ../../c-api/arg.rst:597 msgid "``s`` (:class:`str` or ``None``) [const char \\*]" msgstr "``s`` (:class:`str` 或 ``None``) [const char \\*]" -#: ../../c-api/arg.rst:577 +#: ../../c-api/arg.rst:598 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:580 +#: ../../c-api/arg.rst:601 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:581 +#: ../../c-api/arg.rst:602 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:585 +#: ../../c-api/arg.rst:606 msgid "``y`` (:class:`bytes`) [const char \\*]" msgstr "``y`` (:class:`bytes`) [const char \\*]" -#: ../../c-api/arg.rst:586 +#: ../../c-api/arg.rst:607 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:589 +#: ../../c-api/arg.rst:610 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:590 +#: ../../c-api/arg.rst:611 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:594 ../../c-api/arg.rst:610 +#: ../../c-api/arg.rst:615 ../../c-api/arg.rst:631 msgid "Same as ``s``." msgstr "和 ``s`` 相同。" -#: ../../c-api/arg.rst:596 +#: ../../c-api/arg.rst:617 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:597 ../../c-api/arg.rst:613 +#: ../../c-api/arg.rst:618 ../../c-api/arg.rst:634 msgid "Same as ``s#``." msgstr "和 ``s#`` 相同。" -#: ../../c-api/arg.rst:599 +#: ../../c-api/arg.rst:620 msgid "``u`` (:class:`str`) [const wchar_t \\*]" msgstr "``u`` (:class:`str`) [const wchar_t \\*]" -#: ../../c-api/arg.rst:600 +#: ../../c-api/arg.rst:621 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:604 +#: ../../c-api/arg.rst:625 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:605 +#: ../../c-api/arg.rst:626 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:609 +#: ../../c-api/arg.rst:630 msgid "``U`` (:class:`str` or ``None``) [const char \\*]" msgstr "``U`` (:class:`str` 或 ``None``) [const char \\*]" -#: ../../c-api/arg.rst:612 +#: ../../c-api/arg.rst:633 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:616 +#: ../../c-api/arg.rst:637 msgid "Convert a plain C :c:expr:`int` to a Python integer object." msgstr "將一個 C 的 :c:expr:`int` 轉換成 Python 整數物件。" -#: ../../c-api/arg.rst:618 +#: ../../c-api/arg.rst:639 msgid "``b`` (:class:`int`) [char]" msgstr "``b`` (:class:`int`) [char]" -#: ../../c-api/arg.rst:619 +#: ../../c-api/arg.rst:640 msgid "Convert a plain C :c:expr:`char` to a Python integer object." msgstr "將一個 C 的 :c:expr:`char` 轉換成 Python 整數物件。" -#: ../../c-api/arg.rst:622 +#: ../../c-api/arg.rst:643 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:625 +#: ../../c-api/arg.rst:646 msgid "Convert a C :c:expr:`long int` to a Python integer object." msgstr "將一個 C 的 :c:expr:`long int` 轉換成 Python 整數物件。" -#: ../../c-api/arg.rst:628 +#: ../../c-api/arg.rst:649 msgid "Convert a C :c:expr:`unsigned char` to a Python integer object." msgstr "將一個 C 的 :c:expr:`unsigned char` 轉換成 Python 整數物件。" -#: ../../c-api/arg.rst:631 +#: ../../c-api/arg.rst:652 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:634 +#: ../../c-api/arg.rst:655 msgid "Convert a C :c:expr:`unsigned int` to a Python integer object." msgstr "將一個 C 的 :c:expr:`unsigned int` 轉換成 Python 整數物件。" -#: ../../c-api/arg.rst:637 +#: ../../c-api/arg.rst:658 msgid "Convert a C :c:expr:`unsigned long` to a Python integer object." msgstr "將一個 C 的 :c:expr:`unsigned long` 轉換成 Python 整數物件。" -#: ../../c-api/arg.rst:640 +#: ../../c-api/arg.rst:661 msgid "Convert a C :c:expr:`long long` to a Python integer object." msgstr "將一個 C 的 :c:expr:`long long` 轉換成 Python 整數物件。" -#: ../../c-api/arg.rst:645 +#: ../../c-api/arg.rst:666 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:648 +#: ../../c-api/arg.rst:669 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:650 +#: ../../c-api/arg.rst:672 +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:674 +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 " +"automatically. You can convert another type (for example, a pointer or a " +"float) to a suitable ``int`` value using ``(x) ? 1 : 0`` or ``!!x``." +msgstr "" + +#: ../../c-api/arg.rst:682 msgid "``c`` (:class:`bytes` of length 1) [char]" msgstr "``c`` (長度為 1 的 :class:`bytes`) [char]" -#: ../../c-api/arg.rst:651 +#: ../../c-api/arg.rst:683 msgid "" "Convert a C :c:expr:`int` representing a byte to a Python :class:`bytes` " "object of length 1." @@ -1130,7 +1167,7 @@ msgstr "" "將一個 C 中代表一個位元組的 :c:expr:`int` 轉換成 Python 中長度為一的 :class:" "`bytes`。" -#: ../../c-api/arg.rst:655 +#: ../../c-api/arg.rst:687 msgid "" "Convert a C :c:expr:`int` representing a character to Python :class:`str` " "object of length 1." @@ -1138,23 +1175,23 @@ msgstr "" "將一個 C 中代表一個字元的 :c:expr:`int` 轉換成 Python 中長度為一的 :class:" "`str`。" -#: ../../c-api/arg.rst:659 +#: ../../c-api/arg.rst:691 msgid "Convert a C :c:expr:`double` to a Python floating-point number." msgstr "將一個 C 的 :c:expr:`double` 轉換成 Python 浮點數。" -#: ../../c-api/arg.rst:662 +#: ../../c-api/arg.rst:694 msgid "Convert a C :c:expr:`float` to a Python floating-point number." msgstr "將一個 C 的 :c:expr:`float` 轉換成 Python 浮點數。" -#: ../../c-api/arg.rst:664 +#: ../../c-api/arg.rst:696 msgid "``D`` (:class:`complex`) [Py_complex \\*]" msgstr "``D`` (:class:`complex`) [Py_complex \\*]" -#: ../../c-api/arg.rst:665 +#: ../../c-api/arg.rst:697 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:668 +#: ../../c-api/arg.rst:700 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 " @@ -1164,30 +1201,30 @@ msgid "" "no exception has been raised yet, :exc:`SystemError` is set." msgstr "" -#: ../../c-api/arg.rst:677 +#: ../../c-api/arg.rst:709 msgid "``S`` (object) [PyObject \\*]" msgstr "``S`` (object) [PyObject \\*]" -#: ../../c-api/arg.rst:678 +#: ../../c-api/arg.rst:710 msgid "Same as ``O``." msgstr "和 ``O`` 相同。" -#: ../../c-api/arg.rst:680 +#: ../../c-api/arg.rst:712 msgid "``N`` (object) [PyObject \\*]" msgstr "``N`` (object) [PyObject \\*]" -#: ../../c-api/arg.rst:681 +#: ../../c-api/arg.rst:713 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:685 +#: ../../c-api/arg.rst:717 msgid "``O&`` (object) [*converter*, *anything*]" msgstr "``O&`` (object) [*converter*, *anything*]" -#: ../../c-api/arg.rst:686 +#: ../../c-api/arg.rst:718 msgid "" "Convert *anything* to a Python object through a *converter* function. The " "function is called with *anything* (which should be compatible with :c:expr:" @@ -1195,40 +1232,44 @@ msgid "" "``NULL`` if an error occurred." msgstr "" -#: ../../c-api/arg.rst:692 +#: ../../c-api/arg.rst:723 +msgid "``(items)`` (:class:`tuple`) [*matching-items*]" +msgstr "``(items)`` (:class:`tuple`) [*matching-items*]" + +#: ../../c-api/arg.rst:724 msgid "" "Convert a sequence of C values to a Python tuple with the same number of " "items." msgstr "" -#: ../../c-api/arg.rst:694 +#: ../../c-api/arg.rst:726 msgid "``[items]`` (:class:`list`) [*matching-items*]" msgstr "``[items]`` (:class:`list`) [*matching-items*]" -#: ../../c-api/arg.rst:695 +#: ../../c-api/arg.rst:727 msgid "" "Convert a sequence of C values to a Python list with the same number of " "items." msgstr "" -#: ../../c-api/arg.rst:697 +#: ../../c-api/arg.rst:729 msgid "``{items}`` (:class:`dict`) [*matching-items*]" msgstr "``{items}`` (:class:`dict`) [*matching-items*]" -#: ../../c-api/arg.rst:698 +#: ../../c-api/arg.rst:730 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:702 +#: ../../c-api/arg.rst:734 msgid "" "If there is an error in the format string, the :exc:`SystemError` exception " "is set and ``NULL`` returned." msgstr "" -#: ../../c-api/arg.rst:707 +#: ../../c-api/arg.rst:739 msgid "" "Identical to :c:func:`Py_BuildValue`, except that it accepts a va_list " "rather than a variable number of arguments." diff --git a/c-api/bool.po b/c-api/bool.po index 5c1cf65dac8..9b11893bcc9 100644 --- a/c-api/bool.po +++ b/c-api/bool.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -7,7 +7,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-23 07:52+0800\n" "PO-Revision-Date: 2021-12-09 20:47+0800\n" diff --git a/c-api/buffer.po b/c-api/buffer.po index 52489947570..4bf453e92e2 100644 --- a/c-api/buffer.po +++ b/c-api/buffer.po @@ -1,13 +1,12 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-05-02 00:15+0000\n" +"POT-Creation-Date: 2025-11-09 00:17+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-" @@ -88,7 +87,7 @@ msgstr "" #: ../../c-api/buffer.rst:58 msgid "call :c:func:`PyObject_GetBuffer` with the right parameters;" -msgstr "" +msgstr "以適當的參數呼叫 :c:func:`PyObject_GetBuffer`;" #: ../../c-api/buffer.rst:60 msgid "" @@ -111,7 +110,7 @@ msgstr "" #: ../../c-api/buffer.rst:75 msgid "Buffer structure" -msgstr "" +msgstr "緩衝區結構" #: ../../c-api/buffer.rst:77 msgid "" @@ -229,7 +228,7 @@ msgstr "" #: ../../c-api/buffer.rst:162 msgid "This field is controlled by the :c:macro:`PyBUF_FORMAT` flag." -msgstr "" +msgstr "此欄位受 :c:macro:`PyBUF_FORMAT` 旗標控制。" #: ../../c-api/buffer.rst:166 msgid "" @@ -363,12 +362,16 @@ msgid "" msgstr "" #: ../../c-api/buffer.rst:266 +msgid "This is a :term:`soft deprecated` alias to :c:macro:`PyBUF_WRITABLE`." +msgstr "這是 :c:macro:`PyBUF_WRITABLE` 的\\ :term:`軟性棄用 `\\ 別名。" + +#: ../../c-api/buffer.rst:270 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:270 +#: ../../c-api/buffer.rst:274 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:" @@ -376,159 +379,159 @@ msgid "" "writable buffer." msgstr "" -#: ../../c-api/buffer.rst:274 +#: ../../c-api/buffer.rst:278 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:280 +#: ../../c-api/buffer.rst:284 msgid "shape, strides, suboffsets" msgstr "" -#: ../../c-api/buffer.rst:282 +#: ../../c-api/buffer.rst:286 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:289 ../../c-api/buffer.rst:313 -#: ../../c-api/buffer.rst:338 +#: ../../c-api/buffer.rst:293 ../../c-api/buffer.rst:317 +#: ../../c-api/buffer.rst:342 msgid "Request" msgstr "" -#: ../../c-api/buffer.rst:289 ../../c-api/buffer.rst:313 -#: ../../c-api/buffer.rst:338 +#: ../../c-api/buffer.rst:293 ../../c-api/buffer.rst:317 +#: ../../c-api/buffer.rst:342 msgid "shape" msgstr "" -#: ../../c-api/buffer.rst:289 ../../c-api/buffer.rst:313 -#: ../../c-api/buffer.rst:338 +#: ../../c-api/buffer.rst:293 ../../c-api/buffer.rst:317 +#: ../../c-api/buffer.rst:342 msgid "strides" msgstr "" -#: ../../c-api/buffer.rst:289 ../../c-api/buffer.rst:313 -#: ../../c-api/buffer.rst:338 +#: ../../c-api/buffer.rst:293 ../../c-api/buffer.rst:317 +#: ../../c-api/buffer.rst:342 msgid "suboffsets" msgstr "" -#: ../../c-api/buffer.rst:291 ../../c-api/buffer.rst:293 -#: ../../c-api/buffer.rst:295 ../../c-api/buffer.rst:315 -#: ../../c-api/buffer.rst:317 ../../c-api/buffer.rst:319 -#: ../../c-api/buffer.rst:321 ../../c-api/buffer.rst:340 -#: ../../c-api/buffer.rst:342 ../../c-api/buffer.rst:344 +#: ../../c-api/buffer.rst:295 ../../c-api/buffer.rst:297 +#: ../../c-api/buffer.rst:299 ../../c-api/buffer.rst:319 +#: ../../c-api/buffer.rst:321 ../../c-api/buffer.rst:323 +#: ../../c-api/buffer.rst:325 ../../c-api/buffer.rst:344 #: ../../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:354 ../../c-api/buffer.rst:356 +#: ../../c-api/buffer.rst:358 msgid "yes" msgstr "" -#: ../../c-api/buffer.rst:291 ../../c-api/buffer.rst:340 -#: ../../c-api/buffer.rst:342 +#: ../../c-api/buffer.rst:295 ../../c-api/buffer.rst:344 +#: ../../c-api/buffer.rst:346 msgid "if needed" msgstr "" -#: ../../c-api/buffer.rst:293 ../../c-api/buffer.rst:295 -#: ../../c-api/buffer.rst:297 ../../c-api/buffer.rst:315 -#: ../../c-api/buffer.rst:317 ../../c-api/buffer.rst:319 -#: ../../c-api/buffer.rst:321 ../../c-api/buffer.rst:344 -#: ../../c-api/buffer.rst:346 ../../c-api/buffer.rst:348 +#: ../../c-api/buffer.rst:297 ../../c-api/buffer.rst:299 +#: ../../c-api/buffer.rst:301 ../../c-api/buffer.rst:319 +#: ../../c-api/buffer.rst:321 ../../c-api/buffer.rst:323 +#: ../../c-api/buffer.rst:325 ../../c-api/buffer.rst:348 #: ../../c-api/buffer.rst:350 ../../c-api/buffer.rst:352 -#: ../../c-api/buffer.rst:354 +#: ../../c-api/buffer.rst:354 ../../c-api/buffer.rst:356 +#: ../../c-api/buffer.rst:358 msgid "NULL" msgstr "NULL" -#: ../../c-api/buffer.rst:304 +#: ../../c-api/buffer.rst:308 msgid "contiguity requests" msgstr "" -#: ../../c-api/buffer.rst:306 +#: ../../c-api/buffer.rst:310 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:313 ../../c-api/buffer.rst:338 +#: ../../c-api/buffer.rst:317 ../../c-api/buffer.rst:342 msgid "contig" msgstr "" -#: ../../c-api/buffer.rst:315 ../../c-api/buffer.rst:321 -#: ../../c-api/buffer.rst:352 ../../c-api/buffer.rst:354 +#: ../../c-api/buffer.rst:319 ../../c-api/buffer.rst:325 +#: ../../c-api/buffer.rst:356 ../../c-api/buffer.rst:358 msgid "C" msgstr "C" -#: ../../c-api/buffer.rst:317 +#: ../../c-api/buffer.rst:321 msgid "F" msgstr "F" -#: ../../c-api/buffer.rst:319 +#: ../../c-api/buffer.rst:323 msgid "C or F" msgstr "C 或 F" -#: ../../c-api/buffer.rst:321 +#: ../../c-api/buffer.rst:325 msgid ":c:macro:`PyBUF_ND`" msgstr ":c:macro:`PyBUF_ND`" -#: ../../c-api/buffer.rst:326 +#: ../../c-api/buffer.rst:330 msgid "compound requests" msgstr "" -#: ../../c-api/buffer.rst:328 +#: ../../c-api/buffer.rst:332 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:332 +#: ../../c-api/buffer.rst:336 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:338 +#: ../../c-api/buffer.rst:342 msgid "readonly" msgstr "" -#: ../../c-api/buffer.rst:338 +#: ../../c-api/buffer.rst:342 msgid "format" msgstr "" -#: ../../c-api/buffer.rst:340 ../../c-api/buffer.rst:342 #: ../../c-api/buffer.rst:344 ../../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 msgid "U" msgstr "U" -#: ../../c-api/buffer.rst:340 ../../c-api/buffer.rst:344 -#: ../../c-api/buffer.rst:348 ../../c-api/buffer.rst:352 +#: ../../c-api/buffer.rst:344 ../../c-api/buffer.rst:348 +#: ../../c-api/buffer.rst:352 ../../c-api/buffer.rst:356 msgid "0" msgstr "0" -#: ../../c-api/buffer.rst:342 ../../c-api/buffer.rst:346 -#: ../../c-api/buffer.rst:350 ../../c-api/buffer.rst:354 +#: ../../c-api/buffer.rst:346 ../../c-api/buffer.rst:350 +#: ../../c-api/buffer.rst:354 ../../c-api/buffer.rst:358 msgid "1 or 0" msgstr "1 或 0" -#: ../../c-api/buffer.rst:359 +#: ../../c-api/buffer.rst:363 msgid "Complex arrays" msgstr "" -#: ../../c-api/buffer.rst:362 +#: ../../c-api/buffer.rst:366 msgid "NumPy-style: shape and strides" -msgstr "" +msgstr "NumPy 風格:形狀與步幅" -#: ../../c-api/buffer.rst:364 +#: ../../c-api/buffer.rst:368 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:367 +#: ../../c-api/buffer.rst:371 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 " @@ -536,14 +539,14 @@ msgid "" "strides` are ``NULL``." msgstr "" -#: ../../c-api/buffer.rst:371 +#: ../../c-api/buffer.rst:375 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:375 +#: ../../c-api/buffer.rst:379 msgid "" "ptr = (char *)buf + indices[0] * strides[0] + ... + indices[n-1] * " "strides[n-1];\n" @@ -553,14 +556,14 @@ msgstr "" "strides[n-1];\n" "item = *((typeof(item) *)ptr);" -#: ../../c-api/buffer.rst:381 +#: ../../c-api/buffer.rst:385 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:385 +#: ../../c-api/buffer.rst:389 msgid "" "def verify_structure(memlen, itemsize, ndim, shape, strides, offset):\n" " \"\"\"Verify that the parameters represent a valid array within\n" @@ -589,11 +592,11 @@ msgid "" " return 0 <= offset+imin and offset+imax+itemsize <= memlen" msgstr "" -#: ../../c-api/buffer.rst:415 +#: ../../c-api/buffer.rst:419 msgid "PIL-style: shape, strides and suboffsets" msgstr "" -#: ../../c-api/buffer.rst:417 +#: ../../c-api/buffer.rst:421 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 " @@ -604,14 +607,14 @@ msgid "" "x[2][3]`` arrays that can be located anywhere in memory." msgstr "" -#: ../../c-api/buffer.rst:426 +#: ../../c-api/buffer.rst:430 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:430 +#: ../../c-api/buffer.rst:434 msgid "" "void *get_item_pointer(int ndim, void *buf, Py_ssize_t *strides,\n" " Py_ssize_t *suboffsets, Py_ssize_t *indices) {\n" @@ -639,25 +642,25 @@ msgstr "" " return (void*)pointer;\n" "}" -#: ../../c-api/buffer.rst:445 +#: ../../c-api/buffer.rst:449 msgid "Buffer-related functions" -msgstr "" +msgstr "與緩衝相關的函式" -#: ../../c-api/buffer.rst:449 +#: ../../c-api/buffer.rst:453 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:456 +#: ../../c-api/buffer.rst:460 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:461 +#: ../../c-api/buffer.rst:465 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 " @@ -665,7 +668,7 @@ msgid "" "instead of *exporter* (See :ref:`Buffer Object Structures `)." msgstr "" -#: ../../c-api/buffer.rst:466 +#: ../../c-api/buffer.rst:470 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:" @@ -673,7 +676,7 @@ msgid "" "`PyBuffer_Release` must be called exactly once." msgstr "" -#: ../../c-api/buffer.rst:474 +#: ../../c-api/buffer.rst:478 msgid "" "Release the buffer *view* and release the :term:`strong reference` (i.e. " "decrement the reference count) to the view's supporting object, ``view-" @@ -681,19 +684,19 @@ msgid "" "used, otherwise reference leaks may occur." msgstr "" -#: ../../c-api/buffer.rst:479 +#: ../../c-api/buffer.rst:483 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:485 +#: ../../c-api/buffer.rst:489 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:493 +#: ../../c-api/buffer.rst:497 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 " @@ -701,69 +704,69 @@ msgid "" "succeeds." msgstr "" -#: ../../c-api/buffer.rst:500 +#: ../../c-api/buffer.rst:504 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:506 +#: ../../c-api/buffer.rst:510 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." msgstr "" -#: ../../c-api/buffer.rst:513 +#: ../../c-api/buffer.rst:517 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:517 +#: ../../c-api/buffer.rst:521 msgid "This function fails if *len* != *src->len*." -msgstr "" +msgstr "此函式在 *len* != *src->len* 時失敗。" -#: ../../c-api/buffer.rst:522 +#: ../../c-api/buffer.rst:526 msgid "" "Copy data from *src* to *dest* buffer. Can convert between C-style and or " "Fortran-style buffers." msgstr "" -#: ../../c-api/buffer.rst:525 +#: ../../c-api/buffer.rst:529 msgid "``0`` is returned on success, ``-1`` on error." -msgstr "" +msgstr "成功時回傳 ``0``,錯誤時回傳 ``-1``。" -#: ../../c-api/buffer.rst:529 +#: ../../c-api/buffer.rst:533 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:536 +#: ../../c-api/buffer.rst:540 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:540 +#: ../../c-api/buffer.rst:544 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:544 +#: ../../c-api/buffer.rst:548 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:548 +#: ../../c-api/buffer.rst:552 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 " @@ -790,14 +793,14 @@ msgstr "buffer object(緩衝物件)" msgid "PyBufferProcs (C type)" msgstr "PyBufferProcs(C 型別)" -#: ../../c-api/buffer.rst:301 +#: ../../c-api/buffer.rst:305 msgid "contiguous" msgstr "contiguous(連續的)" -#: ../../c-api/buffer.rst:301 +#: ../../c-api/buffer.rst:305 msgid "C-contiguous" msgstr "C-contiguous(C 連續的)" -#: ../../c-api/buffer.rst:301 +#: ../../c-api/buffer.rst:305 msgid "Fortran contiguous" msgstr "Fortran contiguous(Fortran 連續的)" diff --git a/c-api/bytearray.po b/c-api/bytearray.po index 183f9f7fa0b..9853f9a6398 100644 --- a/c-api/bytearray.po +++ b/c-api/bytearray.po @@ -1,13 +1,12 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-08-04 00:03+0000\n" +"POT-Creation-Date: 2025-09-08 15:25+0800\n" "PO-Revision-Date: 2023-08-12 11:42+0800\n" "Last-Translator: Liang-Bo Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -62,8 +61,8 @@ msgstr "直接 API 函式" #: ../../c-api/bytearray.rst:42 msgid "" -"Return a new bytearray object from any object, *o*, that implements the :ref:" -"`buffer protocol `." +"Return a new bytearray object from any object, *o*, that implements " +"the :ref:`buffer protocol `." msgstr "" "由任意物件 *o* 回傳一個新的位元組陣列物件,並實作了\\ :ref:`緩衝協定 (buffer " "protocol) `。" @@ -95,22 +94,29 @@ msgstr "" "總是會多附加一個空位元組。" #: ../../c-api/bytearray.rst:76 -msgid "Resize the internal buffer of *bytearray* to *len*." -msgstr "將 *bytearray* 的內部緩衝區大小調整為 *len*。" +msgid "" +"Resize the internal buffer of *bytearray* to *len*. Failure is a ``-1`` " +"return with an exception set." +msgstr "將 *bytearray* 的內部緩衝區大小調整為 *len*。失敗時會回傳 ``-1`` 並設定例外。" #: ../../c-api/bytearray.rst:79 +msgid "" +"A negative *len* will now result in an exception being set and -1 returned." +msgstr "負的 *len* 現在會設定例外並回傳 -1。" + +#: ../../c-api/bytearray.rst:84 msgid "Macros" msgstr "巨集" -#: ../../c-api/bytearray.rst:81 +#: ../../c-api/bytearray.rst:86 msgid "These macros trade safety for speed and they don't check pointers." msgstr "這些巨集犧牲了安全性以換取速度,並且它們不會檢查指標。" -#: ../../c-api/bytearray.rst:85 +#: ../../c-api/bytearray.rst:90 msgid "Similar to :c:func:`PyByteArray_AsString`, but without error checking." msgstr "與 :c:func:`PyByteArray_AsString` 類似,但沒有錯誤檢查。" -#: ../../c-api/bytearray.rst:90 +#: ../../c-api/bytearray.rst:95 msgid "Similar to :c:func:`PyByteArray_Size`, but without error checking." msgstr "與 :c:func:`PyByteArray_Size` 類似,但沒有錯誤檢查。" diff --git a/c-api/bytes.po b/c-api/bytes.po index 4cb4ac85455..86da7979be3 100644 --- a/c-api/bytes.po +++ b/c-api/bytes.po @@ -1,13 +1,12 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-12-01 00:17+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-" @@ -160,8 +159,8 @@ msgid "``%zd``" msgstr "``%zd``" #: ../../c-api/bytes.rst:84 -msgid ":c:type:`\\ Py_ssize_t`" -msgstr ":c:type:`\\ Py_ssize_t`" +msgid ":c:type:` Py_ssize_t`" +msgstr ":c:type:` Py_ssize_t`" #: ../../c-api/bytes.rst:84 msgid "Equivalent to ``printf(\"%zd\")``. [1]_" @@ -252,7 +251,7 @@ msgstr "" #: ../../c-api/bytes.rst:134 msgid "Similar to :c:func:`PyBytes_Size`, but without error checking." -msgstr "" +msgstr "和 :c:func:`PyBytes_Size` 類似,但不進行錯誤檢查。" #: ../../c-api/bytes.rst:139 msgid "" @@ -267,7 +266,7 @@ msgstr "" #: ../../c-api/bytes.rst:151 msgid "Similar to :c:func:`PyBytes_AsString`, but without error checking." -msgstr "" +msgstr "和 :c:func:`PyBytes_AsString` 類似,但不進行錯誤檢查。" #: ../../c-api/bytes.rst:156 msgid "" @@ -315,6 +314,29 @@ msgid "" msgstr "" #: ../../c-api/bytes.rst:194 +msgid "Similar to ``sep.join(iterable)`` in Python." +msgstr "類似 Python 中的 ``sep.join(iterable)``。" + +#: ../../c-api/bytes.rst:196 +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:201 +msgid "" +"*iterable* must be an iterable object yielding objects that implement the :" +"ref:`buffer protocol `." +msgstr "" + +#: ../../c-api/bytes.rst:204 +msgid "" +"On success, return a new :class:`bytes` object. On error, set an exception " +"and return ``NULL``." +msgstr "" + +#: ../../c-api/bytes.rst:212 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 " @@ -326,6 +348,57 @@ msgid "" "``NULL``, :exc:`MemoryError` is set, and ``-1`` is returned." msgstr "" +#: ../../c-api/bytes.rst:226 +msgid "" +"Get the string representation of *bytes*. This function is currently used to " +"implement :meth:`!bytes.__repr__` in Python." +msgstr "" + +#: ../../c-api/bytes.rst:229 +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:232 +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*. " +"For example, the byte string ``'Python'`` would be represented as " +"``b\"'Python'\"`` when *smartquotes* is true, or ``b'\\'Python\\''`` when it " +"is false." +msgstr "" + +#: ../../c-api/bytes.rst:238 +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:245 +msgid "" +"Unescape a backslash-escaped string *s*. *s* must not be ``NULL``. *len* " +"must be the size of *s*." +msgstr "" + +#: ../../c-api/bytes.rst:248 +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:251 +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:255 +msgid "*unicode* and *recode_encoding* are now unused." +msgstr "" + #: ../../c-api/bytes.rst:11 msgid "object" msgstr "object(物件)" diff --git a/c-api/call.po b/c-api/call.po index ada203379cd..deda7d818bf 100644 --- a/c-api/call.po +++ b/c-api/call.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -6,7 +6,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-23 07:52+0800\n" "PO-Revision-Date: 2022-10-16 03:20+0800\n" diff --git a/c-api/capsule.po b/c-api/capsule.po index 8962dc66fc4..0a50a92d860 100644 --- a/c-api/capsule.po +++ b/c-api/capsule.po @@ -1,13 +1,12 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-06-29 00:17+0000\n" +"POT-Creation-Date: 2025-11-07 15:15+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-" @@ -30,7 +29,7 @@ msgstr "" #: ../../c-api/capsule.rst:17 msgid "" "This subtype of :c:type:`PyObject` represents an opaque value, useful for C " -"extension modules who need to pass an opaque value (as a :c:expr:`void*` " +"extension modules which need to pass an opaque value (as a :c:expr:`void*` " "pointer) through Python code to other C code. It is often used to make a C " "function pointer defined in one module available to other modules, so the " "regular import mechanism can be used to access C APIs defined in dynamically " @@ -38,62 +37,68 @@ msgid "" msgstr "" #: ../../c-api/capsule.rst:27 +msgid "" +"The type object corresponding to capsule objects. This is the same object " +"as :class:`types.CapsuleType` in the Python layer." +msgstr "" + +#: ../../c-api/capsule.rst:33 msgid "The type of a destructor callback for a capsule. Defined as::" msgstr "" -#: ../../c-api/capsule.rst:29 +#: ../../c-api/capsule.rst:35 msgid "typedef void (*PyCapsule_Destructor)(PyObject *);" msgstr "typedef void (*PyCapsule_Destructor)(PyObject *);" -#: ../../c-api/capsule.rst:31 +#: ../../c-api/capsule.rst:37 msgid "" "See :c:func:`PyCapsule_New` for the semantics of PyCapsule_Destructor " "callbacks." msgstr "" -#: ../../c-api/capsule.rst:37 +#: ../../c-api/capsule.rst:43 msgid "" "Return true if its argument is a :c:type:`PyCapsule`. This function always " "succeeds." msgstr "" -#: ../../c-api/capsule.rst:43 +#: ../../c-api/capsule.rst:49 msgid "" "Create a :c:type:`PyCapsule` encapsulating the *pointer*. The *pointer* " "argument may not be ``NULL``." msgstr "" -#: ../../c-api/capsule.rst:46 +#: ../../c-api/capsule.rst:52 msgid "On failure, set an exception and return ``NULL``." msgstr "" -#: ../../c-api/capsule.rst:48 +#: ../../c-api/capsule.rst:54 msgid "" "The *name* string may either be ``NULL`` or a pointer to a valid C string. " "If non-``NULL``, this string must outlive the capsule. (Though it is " "permitted to free it inside the *destructor*.)" msgstr "" -#: ../../c-api/capsule.rst:52 +#: ../../c-api/capsule.rst:58 msgid "" "If the *destructor* argument is not ``NULL``, it will be called with the " "capsule as its argument when it is destroyed." msgstr "" -#: ../../c-api/capsule.rst:55 +#: ../../c-api/capsule.rst:61 msgid "" "If this capsule will be stored as an attribute of a module, the *name* " "should be specified as ``modulename.attributename``. This will enable other " "modules to import the capsule using :c:func:`PyCapsule_Import`." msgstr "" -#: ../../c-api/capsule.rst:62 +#: ../../c-api/capsule.rst:68 msgid "" "Retrieve the *pointer* stored in the capsule. On failure, set an exception " "and return ``NULL``." msgstr "" -#: ../../c-api/capsule.rst:65 +#: ../../c-api/capsule.rst:71 msgid "" "The *name* parameter must compare exactly to the name stored in the capsule. " "If the name stored in the capsule is ``NULL``, the *name* passed in must " @@ -101,46 +106,46 @@ msgid "" "capsule names." msgstr "" -#: ../../c-api/capsule.rst:73 +#: ../../c-api/capsule.rst:79 msgid "" "Return the current destructor stored in the capsule. On failure, set an " "exception and return ``NULL``." msgstr "" -#: ../../c-api/capsule.rst:76 +#: ../../c-api/capsule.rst:82 msgid "" "It is legal for a capsule to have a ``NULL`` destructor. This makes a " "``NULL`` return code somewhat ambiguous; use :c:func:`PyCapsule_IsValid` or :" "c:func:`PyErr_Occurred` to disambiguate." msgstr "" -#: ../../c-api/capsule.rst:83 +#: ../../c-api/capsule.rst:89 msgid "" "Return the current context stored in the capsule. On failure, set an " "exception and return ``NULL``." msgstr "" -#: ../../c-api/capsule.rst:86 +#: ../../c-api/capsule.rst:92 msgid "" "It is legal for a capsule to have a ``NULL`` context. This makes a ``NULL`` " "return code somewhat ambiguous; use :c:func:`PyCapsule_IsValid` or :c:func:" "`PyErr_Occurred` to disambiguate." msgstr "" -#: ../../c-api/capsule.rst:93 +#: ../../c-api/capsule.rst:99 msgid "" "Return the current name stored in the capsule. On failure, set an exception " "and return ``NULL``." msgstr "" -#: ../../c-api/capsule.rst:96 +#: ../../c-api/capsule.rst:102 msgid "" "It is legal for a capsule to have a ``NULL`` name. This makes a ``NULL`` " "return code somewhat ambiguous; use :c:func:`PyCapsule_IsValid` or :c:func:" "`PyErr_Occurred` to disambiguate." msgstr "" -#: ../../c-api/capsule.rst:103 +#: ../../c-api/capsule.rst:109 msgid "" "Import a pointer to a C object from a capsule attribute in a module. The " "*name* parameter should specify the full name to the attribute, as in " @@ -148,19 +153,19 @@ msgid "" "string exactly." msgstr "" -#: ../../c-api/capsule.rst:108 +#: ../../c-api/capsule.rst:114 msgid "" "This function splits *name* on the ``.`` character, and imports the first " "element. It then processes further elements using attribute lookups." msgstr "" -#: ../../c-api/capsule.rst:111 +#: ../../c-api/capsule.rst:117 msgid "" "Return the capsule's internal *pointer* on success. On failure, set an " "exception and return ``NULL``." msgstr "" -#: ../../c-api/capsule.rst:116 +#: ../../c-api/capsule.rst:122 msgid "" "If *name* points to an attribute of some submodule or subpackage, this " "submodule or subpackage must be previously imported using other means (for " @@ -168,11 +173,11 @@ msgid "" "to succeed." msgstr "" -#: ../../c-api/capsule.rst:121 +#: ../../c-api/capsule.rst:127 msgid "*no_block* has no effect anymore." msgstr "" -#: ../../c-api/capsule.rst:127 +#: ../../c-api/capsule.rst:133 msgid "" "Determines whether or not *capsule* is a valid capsule. A valid capsule is " "non-``NULL``, passes :c:func:`PyCapsule_CheckExact`, has a non-``NULL`` " @@ -181,41 +186,41 @@ msgid "" "compared.)" msgstr "" -#: ../../c-api/capsule.rst:133 +#: ../../c-api/capsule.rst:139 msgid "" "In other words, if :c:func:`PyCapsule_IsValid` returns a true value, calls " "to any of the accessors (any function starting with ``PyCapsule_Get``) are " "guaranteed to succeed." msgstr "" -#: ../../c-api/capsule.rst:137 +#: ../../c-api/capsule.rst:143 msgid "" "Return a nonzero value if the object is valid and matches the name passed " "in. Return ``0`` otherwise. This function will not fail." msgstr "" -#: ../../c-api/capsule.rst:143 +#: ../../c-api/capsule.rst:149 msgid "Set the context pointer inside *capsule* to *context*." msgstr "" -#: ../../c-api/capsule.rst:145 ../../c-api/capsule.rst:152 -#: ../../c-api/capsule.rst:161 ../../c-api/capsule.rst:169 +#: ../../c-api/capsule.rst:151 ../../c-api/capsule.rst:158 +#: ../../c-api/capsule.rst:167 ../../c-api/capsule.rst:175 msgid "" "Return ``0`` on success. Return nonzero and set an exception on failure." msgstr "" -#: ../../c-api/capsule.rst:150 +#: ../../c-api/capsule.rst:156 msgid "Set the destructor inside *capsule* to *destructor*." msgstr "" -#: ../../c-api/capsule.rst:157 +#: ../../c-api/capsule.rst:163 msgid "" "Set the name inside *capsule* to *name*. If non-``NULL``, the name must " "outlive the capsule. If the previous *name* stored in the capsule was not " "``NULL``, no attempt is made to free it." msgstr "" -#: ../../c-api/capsule.rst:166 +#: ../../c-api/capsule.rst:172 msgid "" "Set the void pointer inside *capsule* to *pointer*. The pointer may not be " "``NULL``." diff --git a/c-api/cell.po b/c-api/cell.po index 1b56cd0661b..0f4a13c46c0 100644 --- a/c-api/cell.po +++ b/c-api/cell.po @@ -1,5 +1,4 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -9,9 +8,9 @@ # msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-07-10 00:04+0000\n" +"POT-Creation-Date: 2025-11-05 00:16+0000\n" "PO-Revision-Date: 2022-10-16 15:33+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -31,7 +30,7 @@ msgstr "Cell 物件" msgid "" "\"Cell\" objects are used to implement variables referenced by multiple " "scopes. For each such variable, a cell object is created to store the value; " -"the local variables of each stack frame that references the value contains a " +"the local variables of each stack frame that references the value contain a " "reference to the cells from outer scopes which also use that variable. When " "the value is accessed, the value contained in the cell is used instead of " "the cell object itself. This de-referencing of the cell object requires " diff --git a/c-api/code.po b/c-api/code.po index 89118a2635b..140c2ec5649 100644 --- a/c-api/code.po +++ b/c-api/code.po @@ -1,13 +1,12 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-08-03 00:19+0000\n" +"POT-Creation-Date: 2025-11-13 23:16+0000\n" "PO-Revision-Date: 2015-12-09 17:51+0000\n" "Last-Translator: Liang-Bo Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -252,11 +251,25 @@ msgid "" "it before returning." msgstr "" -#: ../../c-api/code.rst:217 +#: ../../c-api/code.rst:216 +msgid "This is a :term:`soft deprecated` function that does nothing." +msgstr "" + +#: ../../c-api/code.rst:218 +msgid "" +"Prior to Python 3.10, this function would perform basic optimizations to a " +"code object." +msgstr "" + +#: ../../c-api/code.rst:221 +msgid "This function now does nothing." +msgstr "" + +#: ../../c-api/code.rst:228 msgid "Code Object Flags" msgstr "程式碼物件旗標" -#: ../../c-api/code.rst:219 +#: ../../c-api/code.rst:230 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:" @@ -264,7 +277,7 @@ msgid "" "`PyUnstable_Code_New` and similar functions." msgstr "" -#: ../../c-api/code.rst:224 +#: ../../c-api/code.rst:235 msgid "" "Flags whose names start with ``CO_FUTURE_`` correspond to features normally " "selectable by :ref:`future statements `. These flags can be used in :" @@ -272,163 +285,171 @@ msgid "" "mandatory in current versions of Python, and setting them has no effect." msgstr "" -#: ../../c-api/code.rst:230 +#: ../../c-api/code.rst:241 msgid "" "The following flags are available. For their meaning, see the linked " "documentation of their Python equivalents." msgstr "" -#: ../../c-api/code.rst:238 +#: ../../c-api/code.rst:249 msgid "Flag" msgstr "旗標" -#: ../../c-api/code.rst:239 +#: ../../c-api/code.rst:250 msgid "Meaning" msgstr "意義" -#: ../../c-api/code.rst:241 +#: ../../c-api/code.rst:252 msgid ":py:data:`inspect.CO_OPTIMIZED`" msgstr ":py:data:`inspect.CO_OPTIMIZED`" -#: ../../c-api/code.rst:243 +#: ../../c-api/code.rst:254 msgid ":py:data:`inspect.CO_NEWLOCALS`" msgstr ":py:data:`inspect.CO_NEWLOCALS`" -#: ../../c-api/code.rst:245 +#: ../../c-api/code.rst:256 msgid ":py:data:`inspect.CO_VARARGS`" msgstr ":py:data:`inspect.CO_VARARGS`" -#: ../../c-api/code.rst:247 +#: ../../c-api/code.rst:258 msgid ":py:data:`inspect.CO_VARKEYWORDS`" msgstr ":py:data:`inspect.CO_VARKEYWORDS`" -#: ../../c-api/code.rst:249 +#: ../../c-api/code.rst:260 msgid ":py:data:`inspect.CO_NESTED`" msgstr ":py:data:`inspect.CO_NESTED`" -#: ../../c-api/code.rst:251 +#: ../../c-api/code.rst:262 msgid ":py:data:`inspect.CO_GENERATOR`" msgstr ":py:data:`inspect.CO_GENERATOR`" -#: ../../c-api/code.rst:253 +#: ../../c-api/code.rst:264 msgid ":py:data:`inspect.CO_COROUTINE`" msgstr ":py:data:`inspect.CO_COROUTINE`" -#: ../../c-api/code.rst:255 +#: ../../c-api/code.rst:266 msgid ":py:data:`inspect.CO_ITERABLE_COROUTINE`" msgstr ":py:data:`inspect.CO_ITERABLE_COROUTINE`" -#: ../../c-api/code.rst:257 +#: ../../c-api/code.rst:268 msgid ":py:data:`inspect.CO_ASYNC_GENERATOR`" msgstr ":py:data:`inspect.CO_ASYNC_GENERATOR`" -#: ../../c-api/code.rst:260 +#: ../../c-api/code.rst:270 +msgid ":py:data:`inspect.CO_HAS_DOCSTRING`" +msgstr ":py:data:`inspect.CO_HAS_DOCSTRING`" + +#: ../../c-api/code.rst:272 +msgid ":py:data:`inspect.CO_METHOD`" +msgstr ":py:data:`inspect.CO_METHOD`" + +#: ../../c-api/code.rst:275 msgid "no effect (:py:data:`__future__.division`)" msgstr "無效果(:py:data:`__future__.division`)" -#: ../../c-api/code.rst:262 +#: ../../c-api/code.rst:277 msgid "no effect (:py:data:`__future__.absolute_import`)" msgstr "無效果(:py:data:`__future__.absolute_import`)" -#: ../../c-api/code.rst:264 +#: ../../c-api/code.rst:279 msgid "no effect (:py:data:`__future__.with_statement`)" msgstr "無效果(:py:data:`__future__.with_statement`)" -#: ../../c-api/code.rst:266 +#: ../../c-api/code.rst:281 msgid "no effect (:py:data:`__future__.print_function`)" msgstr "無效果(:py:data:`__future__.print_function`)" -#: ../../c-api/code.rst:268 +#: ../../c-api/code.rst:283 msgid "no effect (:py:data:`__future__.unicode_literals`)" msgstr "無效果(:py:data:`__future__.unicode_literals`)" -#: ../../c-api/code.rst:270 +#: ../../c-api/code.rst:285 msgid "no effect (:py:data:`__future__.generator_stop`)" msgstr "無效果(:py:data:`__future__.generator_stop`)" -#: ../../c-api/code.rst:272 +#: ../../c-api/code.rst:287 msgid ":py:data:`__future__.annotations`" msgstr ":py:data:`__future__.annotations`" -#: ../../c-api/code.rst:276 +#: ../../c-api/code.rst:291 msgid "Extra information" msgstr "額外資訊" -#: ../../c-api/code.rst:278 +#: ../../c-api/code.rst:293 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:282 +#: ../../c-api/code.rst:297 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:288 -msgid "Return a new an opaque index value used to adding data to code objects." +#: ../../c-api/code.rst:303 +msgid "Return a new opaque index value used to adding data to code objects." msgstr "" -#: ../../c-api/code.rst:290 +#: ../../c-api/code.rst:305 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:294 +#: ../../c-api/code.rst:309 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:300 +#: ../../c-api/code.rst:315 msgid "as ``_PyEval_RequestCodeExtraIndex``" msgstr "" -#: ../../c-api/code.rst:304 +#: ../../c-api/code.rst:319 msgid "" "Renamed to ``PyUnstable_Eval_RequestCodeExtraIndex``. The old private name " "is deprecated, but will be available until the API changes." msgstr "" -#: ../../c-api/code.rst:310 +#: ../../c-api/code.rst:325 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:313 +#: ../../c-api/code.rst:328 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:318 +#: ../../c-api/code.rst:333 msgid "as ``_PyCode_GetExtra``" msgstr "" -#: ../../c-api/code.rst:322 +#: ../../c-api/code.rst:337 msgid "" "Renamed to ``PyUnstable_Code_GetExtra``. The old private name is deprecated, " "but will be available until the API changes." msgstr "" -#: ../../c-api/code.rst:328 +#: ../../c-api/code.rst:343 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:333 +#: ../../c-api/code.rst:348 msgid "as ``_PyCode_SetExtra``" msgstr "" -#: ../../c-api/code.rst:337 +#: ../../c-api/code.rst:352 msgid "" "Renamed to ``PyUnstable_Code_SetExtra``. The old private name is deprecated, " "but will be available until the API changes." @@ -454,14 +475,14 @@ msgstr "PyCode_New(C 函式)" msgid "PyCode_NewWithPosOnlyArgs (C function)" msgstr "PyCode_NewWithPosOnlyArgs(C 函式)" -#: ../../c-api/code.rst:298 +#: ../../c-api/code.rst:313 msgid "_PyEval_RequestCodeExtraIndex (C function)" msgstr "_PyEval_RequestCodeExtraIndex(C 函式)" -#: ../../c-api/code.rst:316 +#: ../../c-api/code.rst:331 msgid "_PyCode_GetExtra (C function)" msgstr "_PyCode_GetExtra(C 函式)" -#: ../../c-api/code.rst:331 +#: ../../c-api/code.rst:346 msgid "_PyCode_SetExtra (C function)" msgstr "_PyCode_SetExtra(C 函式)" diff --git a/c-api/codec.po b/c-api/codec.po index 6fd7c61a7fd..9ca1d563d06 100644 --- a/c-api/codec.po +++ b/c-api/codec.po @@ -1,13 +1,13 @@ -# Copyright (C) 2001-2023, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Matt Wang , 2023 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-07-29 00:03+0000\n" +"POT-Creation-Date: 2025-11-07 00:14+0000\n" "PO-Revision-Date: 2023-07-24 17:51+0000\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -28,8 +28,9 @@ msgstr "註冊一個新的編解碼器搜尋函式。" #: ../../c-api/codec.rst:10 msgid "" -"As side effect, this tries to load the :mod:`!encodings` package, if not yet " -"done, to make sure that it is always first in the list of search functions." +"As a side effect, this tries to load the :mod:`!encodings` package, if not " +"yet done, to make sure that it is always first in the list of search " +"functions." msgstr "" "作為副作用 (side effect),這會嘗試載入 :mod:`!encodings`\\ (如果尚未完成)," "以確保它始終位於搜尋函式列表中的第一個。" @@ -75,11 +76,11 @@ msgid "" "*object* is passed through the decoder function found for the given " "*encoding* using the error handling method defined by *errors*. *errors* " "may be ``NULL`` to use the default method defined for the codec. Raises a :" -"exc:`LookupError` if no encoder can be found." +"exc:`LookupError` if no decoder can be found." msgstr "" "*object* 被傳遞給以給定 *encoding* 所查找到的解碼器函式,並使用以 *errors* 定" "義的錯誤處理方法。*errors* 可以設為 ``NULL`` 來使用編解碼器定義的預設方法。如" -"果找不到編碼器,則引發 :exc:`LookupError`。" +"果找不到解碼器,則引發 :exc:`LookupError`。" #: ../../c-api/codec.rst:46 msgid "Codec lookup API" @@ -198,3 +199,13 @@ msgstr "將 unicode 編碼錯誤替換為反斜線跳脫(``\\x``、``\\u`` 和 #: ../../c-api/codec.rst:129 msgid "Replace the unicode encode error with ``\\N{...}`` escapes." msgstr "將 unicode 編碼錯誤替換為 ``\\N{...}`` 跳脫。" + +#: ../../c-api/codec.rst:135 +msgid "Codec utility variables" +msgstr "" + +#: ../../c-api/codec.rst:139 +msgid "" +"A string constant containing the lowercase hexadecimal digits: " +"``\"0123456789abcdef\"``." +msgstr "" diff --git a/c-api/complex.po b/c-api/complex.po index a22103f9b4e..6246d71782b 100644 --- a/c-api/complex.po +++ b/c-api/complex.po @@ -1,13 +1,13 @@ -# Copyright (C) 2001-2023, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Matt Wang , 2023 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-09-08 15:25+0800\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-" @@ -127,16 +127,20 @@ msgstr "" "如果 *num* 為 null 且 *exp* 不是正實數,則此方法會回傳零並將 :c:data:`errno` " "設定為 :c:macro:`!EDOM`。" -#: ../../c-api/complex.rst:84 +#: ../../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:89 +#: ../../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:94 +#: ../../c-api/complex.rst:96 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." @@ -144,7 +148,7 @@ msgstr "" "這個 :c:type:`PyTypeObject` 的實例代表 Python 複數型別。它與 Python 層中" "的 :class:`complex` 是同一個物件。" -#: ../../c-api/complex.rst:100 +#: ../../c-api/complex.rst:102 msgid "" "Return true if its argument is a :c:type:`PyComplexObject` or a subtype " "of :c:type:`PyComplexObject`. This function always succeeds." @@ -152,7 +156,7 @@ msgstr "" "如果其引數是一個 :c:type:`PyComplexObject` 或者是 :c:type:`PyComplexObject` " "的子型別,則會回傳 true。這個函式不會失敗。" -#: ../../c-api/complex.rst:106 +#: ../../c-api/complex.rst:108 msgid "" "Return true if its argument is a :c:type:`PyComplexObject`, but not a " "subtype of :c:type:`PyComplexObject`. This function always succeeds." @@ -160,7 +164,7 @@ msgstr "" "如果其引數是一個 :c:type:`PyComplexObject`,但不是 :c:type:`PyComplexObject` " "的子型別,則會回傳 true。這個函式不會失敗。" -#: ../../c-api/complex.rst:112 +#: ../../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." @@ -168,7 +172,7 @@ msgstr "" "從 C 的 :c:type:`Py_complex` 值建立一個新的 Python 複數物件。在錯誤時回傳 " "``NULL`` 並設定例外。" -#: ../../c-api/complex.rst:118 +#: ../../c-api/complex.rst:120 msgid "" "Return a new :c:type:`PyComplexObject` object from *real* and *imag*. Return " "``NULL`` with an exception set on error." @@ -176,11 +180,11 @@ msgstr "" "從 *real* 和 *imag* 回傳一個新的 :c:type:`PyComplexObject` 物件。在錯誤時回" "傳 ``NULL`` 並設定例外。" -#: ../../c-api/complex.rst:124 +#: ../../c-api/complex.rst:126 msgid "Return the real part of *op* as a C :c:expr:`double`." msgstr "以 C 的 :c:expr:`double` 形式回傳 *op* 的實部。" -#: ../../c-api/complex.rst:126 +#: ../../c-api/complex.rst:128 msgid "" "If *op* is not a Python complex number object but has " "a :meth:`~object.__complex__` method, this method will first be called to " @@ -190,9 +194,9 @@ msgid "" msgstr "" "如果 *op* 不是 Python 複數物件,但有一個 :meth:`~object.__complex__` 方法,則" "首先會呼叫該方法將 *op* 轉換為 Python 複數物件。如果 :meth:`!__complex__` 並" -"未定義,那麼它會回退到呼叫 :func:`PyFloat_AsDouble` 並回傳其結果。" +"未定義,那麼它會回退到呼叫 :c:func:`PyFloat_AsDouble` 並回傳其結果。" -#: ../../c-api/complex.rst:132 ../../c-api/complex.rst:148 +#: ../../c-api/complex.rst:134 ../../c-api/complex.rst:150 msgid "" "Upon failure, this method returns ``-1.0`` with an exception set, so one " "should call :c:func:`PyErr_Occurred` to check for errors." @@ -200,15 +204,15 @@ msgstr "" "失敗時,此方法回傳 ``-1.0`` 並設定例外,因此應該呼" "叫 :c:func:`PyErr_Occurred` 來檢查錯誤。" -#: ../../c-api/complex.rst:135 ../../c-api/complex.rst:151 +#: ../../c-api/complex.rst:137 ../../c-api/complex.rst:153 msgid "Use :meth:`~object.__complex__` if available." msgstr "如果可用則使用 :meth:`~object.__complex__`。" -#: ../../c-api/complex.rst:140 +#: ../../c-api/complex.rst:142 msgid "Return the imaginary part of *op* as a C :c:expr:`double`." msgstr "將 *op* 的虛部作為 C 的 :c:expr:`double` 回傳。" -#: ../../c-api/complex.rst:142 +#: ../../c-api/complex.rst:144 msgid "" "If *op* is not a Python complex number object but has " "a :meth:`~object.__complex__` method, this method will first be called to " @@ -218,13 +222,13 @@ msgid "" msgstr "" "如果 *op* 不是 Python 複數物件,但有一個 :meth:`~object.__complex__` 方法,則" "首先會呼叫該方法將 *op* 轉換為 Python 複數物件。如果 :meth:`!__complex__` 並" -"未定義,那麼它會回退到呼叫 :func:`PyFloat_AsDouble` 並於成功時回傳 ``0.0``。" +"未定義,那麼它會回退到呼叫 :c:func:`PyFloat_AsDouble` 並於成功時回傳 ``0.0``。" -#: ../../c-api/complex.rst:156 +#: ../../c-api/complex.rst:158 msgid "Return the :c:type:`Py_complex` value of the complex number *op*." msgstr "回傳複數 *op* 的 :c:type:`Py_complex` 值。" -#: ../../c-api/complex.rst:158 +#: ../../c-api/complex.rst:160 msgid "" "If *op* is not a Python complex number object but has " "a :meth:`~object.__complex__` method, this method will first be called to " @@ -237,7 +241,7 @@ msgstr "" "未定義,那麼它會回退到 :meth:`~object.__float__`。如果 :meth:`!__float__` 未" "定義,則它將繼續回退為 :meth:`~object.__index__`。" -#: ../../c-api/complex.rst:164 +#: ../../c-api/complex.rst:166 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, " @@ -246,7 +250,7 @@ msgstr "" "失敗時,此方法回傳 :c:type:`Py_complex` 並將 :c:member:`~Py_complex.real` 設" "為 ``-1.0``,並設定例外,因此應該呼叫 :c:func:`PyErr_Occurred` 來檢查錯誤。" -#: ../../c-api/complex.rst:168 +#: ../../c-api/complex.rst:170 msgid "Use :meth:`~object.__index__` if available." msgstr "如果可用則使用 :meth:`~object.__index__`。" diff --git a/c-api/concrete.po b/c-api/concrete.po index cafd42eadc1..cfa7d8a04ea 100644 --- a/c-api/concrete.po +++ b/c-api/concrete.po @@ -1,14 +1,13 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Matt Wang , 2022 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-05-09 00:15+0000\n" +"POT-Creation-Date: 2025-11-17 00:14+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-" @@ -87,6 +86,10 @@ msgstr "函式物件" msgid "Other Objects" msgstr "其他物件" +#: ../../c-api/concrete.rst:123 +msgid "C API for extension modules" +msgstr "擴充模組的 C API" + #: ../../c-api/concrete.rst:43 ../../c-api/concrete.rst:58 #: ../../c-api/concrete.rst:80 msgid "object" diff --git a/c-api/contextvars.po b/c-api/contextvars.po index 07a22f1e5f5..35ec1c9bd0e 100644 --- a/c-api/contextvars.po +++ b/c-api/contextvars.po @@ -1,11 +1,10 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"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: 2025-09-08 15:25+0800\n" "PO-Revision-Date: 2025-06-27 00:11+0800\n" "Last-Translator: \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -23,12 +22,14 @@ msgstr "情境變數物件(Context Variables Objects)" #: ../../c-api/contextvars.rst:15 msgid "" "In Python 3.7.1 the signatures of all context variables C APIs were " -"**changed** to use :c:type:`PyObject` pointers instead of :c:type:" -"`PyContext`, :c:type:`PyContextVar`, and :c:type:`PyContextToken`, e.g.::" +"**changed** to use :c:type:`PyObject` pointers instead " +"of :c:type:`PyContext`, :c:type:`PyContextVar`, " +"and :c:type:`PyContextToken`, e.g.::" msgstr "" -"在 Python 3.7.1 中所有情境變數 C API 的簽名都被\\ **改為**\\ 使用 :c:type:" -"`PyObject` 指標,而不是 :c:type:`PyContext`、:c:type:`PyContextVar` 或 :c:" -"type:`PyContextToken`,例如:" +"在 Python 3.7.1 中所有情境變數 C API 的簽名都被\\ **改為**\\ 使" +"用 :c:type:`PyObject` 指標,而不" +"是 :c:type:`PyContext`、:c:type:`PyContextVar` 或 :c:type:`PyContextToken`," +"例如:" #: ../../c-api/contextvars.rst:20 msgid "" @@ -121,7 +122,9 @@ msgstr "建立一個新的空的情境物件。 如果發生錯誤,則回傳 ` msgid "" "Create a shallow copy of the passed *ctx* context object. Returns ``NULL`` " "if an error has occurred." -msgstr "建立傳入的 *ctx* 情境物件的淺層複製 (shallow copy)。如果發生錯誤,則回傳 ``NULL``。" +msgstr "" +"建立傳入的 *ctx* 情境物件的淺層複製 (shallow copy)。如果發生錯誤,則回傳 " +"``NULL``。" #: ../../c-api/contextvars.rst:90 msgid "" @@ -145,11 +148,61 @@ msgstr "" "關閉 *ctx* 情境,並將目前執行緒的目前情境設回之前的情境。 成功時回傳 ``0``," "錯誤時回傳 ``-1``。" -#: ../../c-api/contextvars.rst:105 +#: ../../c-api/contextvars.rst:106 +msgid "" +"Register *callback* as a context object watcher for the current interpreter. " +"Return an ID which may be passed to :c:func:`PyContext_ClearWatcher`. In " +"case of error (e.g. no more watcher IDs available), return ``-1`` and set an " +"exception." +msgstr "" + +#: ../../c-api/contextvars.rst:115 +msgid "" +"Clear watcher identified by *watcher_id* previously returned " +"from :c:func:`PyContext_AddWatcher` for the current interpreter. Return " +"``0`` on success, or ``-1`` and set an exception on error (e.g. if the given " +"*watcher_id* was never registered.)" +msgstr "" + +#: ../../c-api/contextvars.rst:124 +msgid "Enumeration of possible context object watcher events:" +msgstr "" + +#: ../../c-api/contextvars.rst:126 +msgid "" +"``Py_CONTEXT_SWITCHED``: The :term:`current context` has switched to a " +"different context. The object passed to the watch callback is the now-" +"current :class:`contextvars.Context` object, or None if no context is " +"current." +msgstr "" + +#: ../../c-api/contextvars.rst:135 +msgid "" +"Context object watcher callback function. The object passed to the callback " +"is event-specific; see :c:type:`PyContextEvent` for details." +msgstr "" + +#: ../../c-api/contextvars.rst:138 +msgid "" +"If the callback returns with an exception set, it must return ``-1``; this " +"exception will be printed as an unraisable exception " +"using :c:func:`PyErr_FormatUnraisable`. Otherwise it should return ``0``." +msgstr "" + +#: ../../c-api/contextvars.rst:142 +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 " +"set. This means the callback may not call any other API that can set an " +"exception unless it saves and clears the exception state first, and restores " +"it before returning." +msgstr "" + +#: ../../c-api/contextvars.rst:151 msgid "Context variable functions:" msgstr "情境變數函式:" -#: ../../c-api/contextvars.rst:109 +#: ../../c-api/contextvars.rst:155 msgid "" "Create a new ``ContextVar`` object. The *name* parameter is used for " "introspection and debug purposes. The *def* parameter specifies a default " @@ -160,7 +213,7 @@ msgstr "" "除錯目的。*def* 參數指定情境變數的預設值,亦可用 ``NULL`` 表示沒有預設值。 如" "果發生錯誤,此函式會回傳 ``NULL``。" -#: ../../c-api/contextvars.rst:116 +#: ../../c-api/contextvars.rst:162 msgid "" "Get the value of a context variable. Returns ``-1`` if an error has " "occurred during lookup, and ``0`` if no error occurred, whether or not a " @@ -169,7 +222,7 @@ msgstr "" "取得情境變數的值。如果在查找過程中發生錯誤則回傳 ``-1``,如果沒有發生錯誤則無" "論是否找到值都會回傳 ``0``。" -#: ../../c-api/contextvars.rst:120 +#: ../../c-api/contextvars.rst:166 msgid "" "If the context variable was found, *value* will be a pointer to it. If the " "context variable was *not* found, *value* will point to:" @@ -177,23 +230,23 @@ msgstr "" "如果找到情境變數,*value* 將會是指向它的指標。如果 *沒有* 找到情境變數," "*value* 將會指到:" -#: ../../c-api/contextvars.rst:123 +#: ../../c-api/contextvars.rst:169 msgid "*default_value*, if not ``NULL``;" msgstr "*default_value* 預設值,但前提是預設值不是 ``NULL``;" -#: ../../c-api/contextvars.rst:124 +#: ../../c-api/contextvars.rst:170 msgid "the default value of *var*, if not ``NULL``;" msgstr "*var* 的預設值,但前提是預設值不是 ``NULL``;" -#: ../../c-api/contextvars.rst:125 +#: ../../c-api/contextvars.rst:171 msgid "``NULL``" msgstr "``NULL``" -#: ../../c-api/contextvars.rst:127 +#: ../../c-api/contextvars.rst:173 msgid "Except for ``NULL``, the function returns a new reference." msgstr "除了 ``NULL`` 之外,此函式會回傳一個新的參照(reference)。" -#: ../../c-api/contextvars.rst:131 +#: ../../c-api/contextvars.rst:177 msgid "" "Set the value of *var* to *value* in the current context. Returns a new " "token object for this change, or ``NULL`` if an error has occurred." @@ -201,12 +254,12 @@ msgstr "" "在目前的情境中將 *var* 的值設為 *value*。會回傳一個用來代表此變更的新 token " "物件,如果發生錯誤則回傳 ``NULL``。" -#: ../../c-api/contextvars.rst:136 +#: ../../c-api/contextvars.rst:182 msgid "" -"Reset the state of the *var* context variable to that it was in before :c:" -"func:`PyContextVar_Set` that returned the *token* was called. This function " -"returns ``0`` on success and ``-1`` on error." +"Reset the state of the *var* context variable to that it was in " +"before :c:func:`PyContextVar_Set` that returned the *token* was called. This " +"function returns ``0`` on success and ``-1`` on error." msgstr "" -"將 *var* 情境變數的狀態設回之前的狀態,亦即上一次回傳 token 的 :c:func:" -"`PyContextVar_Set` 被呼叫前的狀態。此函式在成功時回傳 ``0``,錯誤時回傳 " -"``-1``。" +"將 *var* 情境變數的狀態設回之前的狀態,亦即上一次回傳 token " +"的 :c:func:`PyContextVar_Set` 被呼叫前的狀態。此函式在成功時回傳 ``0``,錯誤" +"時回傳 ``-1``。" diff --git a/c-api/conversion.po b/c-api/conversion.po index a8c2e006996..7cd313de67b 100644 --- a/c-api/conversion.po +++ b/c-api/conversion.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -7,9 +7,9 @@ # Matt Wang , 2023 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-01-27 00:03+0000\n" +"POT-Creation-Date: 2025-11-26 00:14+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-" @@ -35,7 +35,7 @@ msgid "" "`snprintf(3)`." msgstr "" "根據格式字串 *format* 和額外引數,輸出不超過 *size* 位元組給 *str*。請參閱 " -"Unix 手冊頁面 :manpage:`snprintf(3)`。" +"Unix 使用手冊 :manpage:`snprintf(3)`。" #: ../../c-api/conversion.rst:19 msgid "" @@ -44,7 +44,7 @@ msgid "" "`vsnprintf(3)`." msgstr "" "根據格式字串 *format* 和變數引數串列 *va*,輸出不超過 *size* 位元組給 *str*。" -"Unix 手冊頁面 :manpage:`vsnprintf(3)`。" +"Unix 使用手冊 :manpage:`vsnprintf(3)`。" #: ../../c-api/conversion.rst:23 msgid "" @@ -97,12 +97,12 @@ msgstr "" #: ../../c-api/conversion.rst:44 msgid "" -"When ``rv < 0``, \"something bad happened.\" ``str[size-1]`` is ``'\\0'`` in " -"this case too, but the rest of *str* is undefined. The exact cause of the " -"error depends on the underlying platform." +"When ``rv < 0``, the output conversion failed and ``str[size-1]`` is " +"``'\\0'`` in this case too, but the rest of *str* is undefined. The exact " +"cause of the error depends on the underlying platform." msgstr "" -"當 ``rv < 0`` 時,代表「有不好的事情發生了」。在這種情況下,``str[size-1]`` " -"也是 ``'\\0'``,但 *str* 的其餘部分未定義。錯誤的確切原因取決於底層平台。" +"當 ``rv < 0`` 時,代表輸出的轉換失敗,且在這種情況下 ``str[size-1]`` 也是 " +"``'\\0'``,但 *str* 的其餘部分未定義。錯誤的確切原因取決於底層平台。" #: ../../c-api/conversion.rst:49 msgid "" @@ -116,6 +116,8 @@ msgid "" "long` value according to the given ``base``, which must be between ``2`` and " "``36`` inclusive, or be the special value ``0``." msgstr "" +"將字串 ``str`` 的初始部分根據給定的 ``base`` 轉換為 :c:expr:`unsigned long` " +"值,底 (base) 必須介於 ``2`` 到 ``36``\\ (包含)之間,或為特殊值 ``0``。" #: ../../c-api/conversion.rst:57 msgid "" @@ -125,6 +127,10 @@ msgid "" "(inclusive). If ``ptr`` is non-``NULL`` it will contain a pointer to the " "end of the scan." msgstr "" +"忽略前導空白和字元大小寫。如果 ``base`` 為零,則會尋找前導的 ``0b``、``0o`` " +"或 ``0x`` 來判斷使用哪個進位。如果這些前綴不存在,則預設為 ``10``。底必須為 " +"0 或介於 2 到 36(包含)之間。如果 ``ptr`` 為非 ``NULL``,它將包含指向掃描結" +"束處的指標。" #: ../../c-api/conversion.rst:63 msgid "" @@ -133,10 +139,13 @@ msgid "" "macro:`!ULONG_MAX` is returned. If no conversion can be performed, ``0`` is " "returned." msgstr "" +"如果轉換後的值超出對應回傳型別的範圍,則會發生範圍錯誤(:c:data:`errno` 會被" +"設定為 :c:macro:`!ERANGE`)並回傳 :c:macro:`!ULONG_MAX`。如果無法執行任何轉" +"換,則回傳 ``0``。" #: ../../c-api/conversion.rst:68 msgid "See also the Unix man page :manpage:`strtoul(3)`." -msgstr "也請見 Unix 手冊頁面 :manpage:`strtoul(3)`。" +msgstr "也請見 Unix 使用手冊 :manpage:`strtoul(3)`。" #: ../../c-api/conversion.rst:75 msgid "" @@ -144,16 +153,20 @@ msgid "" "according to the given ``base``, which must be between ``2`` and ``36`` " "inclusive, or be the special value ``0``." msgstr "" +"將字串 ``str`` 的初始部分根據給定的 ``base`` 轉換為 :c:expr:`long` 值,底 必" +"須介於 ``2`` 到 ``36`` \\ (包含)之間,或為特殊值 ``0``。" #: ../../c-api/conversion.rst:79 msgid "" "Same as :c:func:`PyOS_strtoul`, but return a :c:expr:`long` value instead " "and :c:macro:`LONG_MAX` on overflows." msgstr "" +"與 :c:func:`PyOS_strtoul` 相同,但回傳 :c:expr:`long` 值,並在溢位時回傳 :c:" +"macro:`LONG_MAX`。" #: ../../c-api/conversion.rst:82 msgid "See also the Unix man page :manpage:`strtol(3)`." -msgstr "也請見 Unix 手冊頁面 :manpage:`strtol(3)`。" +msgstr "也請見 Unix 使用手冊 :manpage:`strtol(3)`。" #: ../../c-api/conversion.rst:89 msgid "" @@ -192,7 +205,7 @@ 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_HUGE_VAL`` (with an " +"``overflow_exception`` is ``NULL`` return ``Py_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 " @@ -200,7 +213,7 @@ msgid "" msgstr "" "如果 ``s`` 表示的值太大而無法儲存在浮點數中(例如 ``\"1e500\"`` 在許多平台上" "都是這樣的字串),如果 ``overflow_exception`` 為 ``NULL`` 則回傳 " -"``Py_HUGE_VAL``\\ (會帶有適當的符號)並且不設定任何例外。否則, " +"``Py_INFINITY``\\ (會帶有適當的符號)並且不設定任何例外。否則, " "``overflow_exception`` 必須指向一個 Python 例外物件;引發該例外並回傳 " "``-1.0``。在這兩種情況下,將 ``*endptr`` 設定為指向轉換後的值之後的第一個字" "元。" @@ -232,35 +245,33 @@ msgstr "" "``'r'`` 格式碼指定標準 :func:`repr` 格式。" #: ../../c-api/conversion.rst:131 -msgid "" -"*flags* can be zero or more of the values ``Py_DTSF_SIGN``, " -"``Py_DTSF_ADD_DOT_0``, or ``Py_DTSF_ALT``, or-ed together:" -msgstr "" -"*flags* 可以是零個或多個值 ``Py_DTSF_SIGN``、``Py_DTSF_ADD_DOT_0`` 或 " -"``Py_DTSF_ALT``,會被聯集在一起:" +msgid "*flags* can be zero or more of the following values or-ed together:" +msgstr "*flags* 可以是零個或多個以下的值被聯集在一起:" -#: ../../c-api/conversion.rst:134 +#: ../../c-api/conversion.rst:135 msgid "" -"``Py_DTSF_SIGN`` means to always precede the returned string with a sign " -"character, even if *val* is non-negative." +"Always precede the returned string with a sign character, even if *val* is " +"non-negative." msgstr "" -"``Py_DTSF_SIGN`` 代表總是在回傳的字串前面加上符號字元,即使 *val* 非負數。" - -#: ../../c-api/conversion.rst:137 -msgid "" -"``Py_DTSF_ADD_DOT_0`` means to ensure that the returned string will not look " -"like an integer." -msgstr "``Py_DTSF_ADD_DOT_0`` 代表確保回傳的字串看起來不會像整數。" +"總是在回傳的字串前面加上正負號字元 (sign character),即使 *val* 非負數。" #: ../../c-api/conversion.rst:140 +msgid "Ensure that the returned string will not look like an integer." +msgstr "確保回傳的字串看起來不會像整數。" + +#: ../../c-api/conversion.rst:144 msgid "" -"``Py_DTSF_ALT`` means to apply \"alternate\" formatting rules. See the " -"documentation for the :c:func:`PyOS_snprintf` ``'#'`` specifier for details." +"Apply \"alternate\" formatting rules. See the documentation for the :c:func:" +"`PyOS_snprintf` ``'#'`` specifier for details." msgstr "" -"``Py_DTSF_ALT`` 代表要套用「備用的 (alternate)」格式化規則。有關詳細資訊,請" -"參閱 :c:func:`PyOS_snprintf` ``'#'`` 的文件。" +"套用「備用的 (alternate)」格式化規則。有關詳細資訊,請參閱 :c:func:" +"`PyOS_snprintf` ``'#'`` 的文件。" -#: ../../c-api/conversion.rst:144 +#: ../../c-api/conversion.rst:150 +msgid "Negative zero is converted to positive zero." +msgstr "負零會被轉換為正零。" + +#: ../../c-api/conversion.rst:154 msgid "" "If *ptype* is non-``NULL``, then the value it points to will be set to one " "of ``Py_DTST_FINITE``, ``Py_DTST_INFINITE``, or ``Py_DTST_NAN``, signifying " @@ -271,7 +282,7 @@ msgstr "" "``Py_DTST_INFINITE`` 或 ``Py_DTST_NAN`` 其中之一,分別代表 *val* 是有限數、無" "限數或非數。" -#: ../../c-api/conversion.rst:148 +#: ../../c-api/conversion.rst:158 msgid "" "The return value is a pointer to *buffer* with the converted string or " "``NULL`` if the conversion failed. The caller is responsible for freeing the " @@ -280,18 +291,98 @@ msgstr "" "回傳值是指向 *buffer* 的指標,其中包含轉換後的字串,如果轉換失敗則回傳 " "``NULL``。呼叫者負責透過呼叫 :c:func:`PyMem_Free` 來釋放回傳的字串。" -#: ../../c-api/conversion.rst:157 +#: ../../c-api/conversion.rst:168 +msgid "" +"Case insensitive comparison of strings. These functions work almost " +"identically to :c:func:`!strcmp` and :c:func:`!strncmp` (respectively), " +"except that they ignore the case of ASCII characters." +msgstr "" +"不區分大小寫的字串比較。函式的作用方式幾乎與 :c:func:`!strcmp` 和 :c:func:`!strncmp` " +"相同,只是它們忽略大小寫。" + +#: ../../c-api/conversion.rst:172 +msgid "" +"Return ``0`` if the strings are equal, a negative value if *str1* sorts " +"lexicographically before *str2*, or a positive value if it sorts after." +msgstr "" + +#: ../../c-api/conversion.rst:175 +msgid "" +"In the *str1* or *str2* arguments, a NUL byte marks the end of the string. " +"For :c:func:`!PyOS_mystrnicmp`, the *size* argument gives the maximum size " +"of the string, as if NUL was present at the index given by *size*." +msgstr "" + +#: ../../c-api/conversion.rst:179 +msgid "These functions do not use the locale." +msgstr "" + +#: ../../c-api/conversion.rst:185 +msgid "Case insensitive comparison of strings." +msgstr "不區分大小寫的字串比較。" + +#: ../../c-api/conversion.rst:187 +msgid "" +"On Windows, these are aliases of :c:func:`!stricmp` and :c:func:`!strnicmp`, " +"respectively." +msgstr "" + +#: ../../c-api/conversion.rst:190 msgid "" -"Case insensitive comparison of strings. The function works almost " -"identically to :c:func:`!strcmp` except that it ignores the case." +"On other platforms, they are aliases of :c:func:`PyOS_mystricmp` and :c:func:" +"`PyOS_mystrnicmp`, respectively." msgstr "" -"不區分大小寫的字串比較。函式的作用方式幾乎與 :c:func:`!strcmp` 相同,只是它忽" -"略大小寫。" -#: ../../c-api/conversion.rst:163 +#: ../../c-api/conversion.rst:195 +msgid "Character classification and conversion" +msgstr "" + +#: ../../c-api/conversion.rst:197 +msgid "" +"The following macros provide locale-independent (unlike the C standard " +"library ``ctype.h``) character classification and conversion. The argument " +"must be a signed or unsigned :c:expr:`char`." +msgstr "" + +#: ../../c-api/conversion.rst:204 +msgid "Return true if the character *c* is an alphanumeric character." +msgstr "" + +#: ../../c-api/conversion.rst:209 +msgid "" +"Return true if the character *c* is an alphabetic character (``a-z`` and ``A-" +"Z``)." +msgstr "" + +#: ../../c-api/conversion.rst:214 +msgid "Return true if the character *c* is a decimal digit (``0-9``)." +msgstr "" + +#: ../../c-api/conversion.rst:219 +msgid "Return true if the character *c* is a lowercase ASCII letter (``a-z``)." +msgstr "" + +#: ../../c-api/conversion.rst:224 +msgid "" +"Return true if the character *c* is an uppercase ASCII letter (``A-Z``)." +msgstr "" + +#: ../../c-api/conversion.rst:229 +msgid "" +"Return true if the character *c* is a whitespace character (space, tab, " +"carriage return, newline, vertical tab, or form feed)." +msgstr "" + +#: ../../c-api/conversion.rst:235 msgid "" -"Case insensitive comparison of strings. The function works almost " -"identically to :c:func:`!strncmp` except that it ignores the case." +"Return true if the character *c* is a hexadecimal digit (``0-9``, ``a-f``, " +"and ``A-F``)." +msgstr "" + +#: ../../c-api/conversion.rst:241 +msgid "Return the lowercase equivalent of the character *c*." +msgstr "" + +#: ../../c-api/conversion.rst:246 +msgid "Return the uppercase equivalent of the character *c*." msgstr "" -"不區分大小寫的字串比較。函式的作用方式幾乎與 :c:func:`!strncmp` 相同,只是它" -"忽略大小寫。" diff --git a/c-api/coro.po b/c-api/coro.po index 1a5f027a6d0..5ee67a7822a 100644 --- a/c-api/coro.po +++ b/c-api/coro.po @@ -1,5 +1,4 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -8,7 +7,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-09-13 00:11+0000\n" "PO-Revision-Date: 2021-12-09 21:15+0800\n" diff --git a/c-api/curses.po b/c-api/curses.po new file mode 100644 index 00000000000..f6f79465f3f --- /dev/null +++ b/c-api/curses.po @@ -0,0 +1,213 @@ +# 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.14\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-11-09 17:02+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/curses.rst:4 +msgid "Curses C API" +msgstr "Curses C API" + +#: ../../c-api/curses.rst:6 +msgid "" +":mod:`curses` exposes a small C interface for extension modules. Consumers " +"must include the header file :file:`py_curses.h` (which is not included by " +"default by :file:`Python.h`) and :c:func:`import_curses` must be invoked, " +"usually as part of the module initialisation function, to populate :c:var:" +"`PyCurses_API`." +msgstr "" +":mod:`curses` 為擴充模組公開了一個小型的 C 介面。使用者必須包含標頭檔 " +":file:`py_curses.h`\\ (此檔案不會由 :file:`Python.h` 預設包含),並且必須觸發 " +":c:func:`import_curses` 以填充 (populate) :c:var:`PyCurses_API`,通常是作為" +"模組初始化函式的一部分。" + +#: ../../c-api/curses.rst:14 +msgid "" +"Neither the C API nor the pure Python :mod:`curses` module are compatible " +"with subinterpreters." +msgstr "" + +#: ../../c-api/curses.rst:19 +msgid "" +"Import the curses C API. The macro does not need a semi-colon to be called." +msgstr "引入 curses C API。呼叫此巨集不需要寫分號。" + +#: ../../c-api/curses.rst:21 +msgid "On success, populate the :c:var:`PyCurses_API` pointer." +msgstr "" + +#: ../../c-api/curses.rst:23 +msgid "" +"On failure, set :c:var:`PyCurses_API` to NULL and set an exception. The " +"caller must check if an error occurred via :c:func:`PyErr_Occurred`:" +msgstr "" + +#: ../../c-api/curses.rst:26 +msgid "" +"import_curses(); // semi-colon is optional but recommended\n" +"if (PyErr_Occurred()) { /* cleanup */ }" +msgstr "" +"import_curses(); // 建議要寫分號但非必要\n" +"if (PyErr_Occurred()) { /* 清理 */ }" + +#: ../../c-api/curses.rst:34 +msgid "" +"Dynamically allocated object containing the curses C API. This variable is " +"only available once :c:macro:`import_curses` succeeds." +msgstr "" + +#: ../../c-api/curses.rst:37 +msgid "``PyCurses_API[0]`` corresponds to :c:data:`PyCursesWindow_Type`." +msgstr "" + +#: ../../c-api/curses.rst:39 +msgid "" +"``PyCurses_API[1]``, ``PyCurses_API[2]``, and ``PyCurses_API[3]`` are " +"pointers to predicate functions of type ``int (*)(void)``." +msgstr "" +"``PyCurses_API[1]``、``PyCurses_API[2]`` 和 ``PyCurses_API[3]`` 是指向 " +"型別為 ``int (*)(void)`` 的謂詞函式 (predicate functions) 的指標。" + +#: ../../c-api/curses.rst:42 +msgid "" +"When called, these predicates return whether :func:`curses.setupterm`, :func:" +"`curses.initscr`, and :func:`curses.start_color` have been called " +"respectively." +msgstr "" + +#: ../../c-api/curses.rst:46 +msgid "" +"See also the convenience macros :c:macro:`PyCursesSetupTermCalled`, :c:macro:" +"`PyCursesInitialised`, and :c:macro:`PyCursesInitialisedColor`." +msgstr "" + +#: ../../c-api/curses.rst:51 +msgid "" +"The number of entries in this structure is subject to changes. Consider " +"using :c:macro:`PyCurses_API_pointers` to check if new fields are available " +"or not." +msgstr "" + +#: ../../c-api/curses.rst:58 +msgid "" +"The number of accessible fields (``4``) in :c:var:`PyCurses_API`. This " +"number is incremented whenever new fields are added." +msgstr "" + +#: ../../c-api/curses.rst:64 +msgid "" +"The :ref:`heap type ` corresponding to :class:`curses.window`." +msgstr "" + +#: ../../c-api/curses.rst:69 +msgid "" +"Return true if *op* is a :class:`curses.window` instance, false otherwise." +msgstr "如果 *op* 是 :class:`curses.window` 實例則回傳 true,否則回傳 false。" + +#: ../../c-api/curses.rst:72 +msgid "" +"The following macros are convenience macros expanding into C statements. In " +"particular, they can only be used as ``macro;`` or ``macro``, but not " +"``macro()`` or ``macro();``." +msgstr "" + +#: ../../c-api/curses.rst:78 +msgid "Macro checking if :func:`curses.setupterm` has been called." +msgstr "如果已呼叫 :func:`curses.setupterm`,則為巨集檢查。" + +#: ../../c-api/curses.rst:80 ../../c-api/curses.rst:97 +#: ../../c-api/curses.rst:114 +msgid "The macro expansion is roughly equivalent to:" +msgstr "巨集展開大致相當於:" + +#: ../../c-api/curses.rst:82 +msgid "" +"{\n" +" typedef int (*predicate_t)(void);\n" +" predicate_t was_setupterm_called = (predicate_t)PyCurses_API[1];\n" +" if (!was_setupterm_called()) {\n" +" return NULL;\n" +" }\n" +"}" +msgstr "" +"{\n" +" typedef int (*predicate_t)(void);\n" +" predicate_t was_setupterm_called = (predicate_t)PyCurses_API[1];\n" +" if (!was_setupterm_called()) {\n" +" return NULL;\n" +" }\n" +"}" + +#: ../../c-api/curses.rst:95 +msgid "Macro checking if :func:`curses.initscr` has been called." +msgstr "如果已呼叫 :func:`curses.initscr`,則為巨集檢查。" + +#: ../../c-api/curses.rst:99 +msgid "" +"{\n" +" typedef int (*predicate_t)(void);\n" +" predicate_t was_initscr_called = (predicate_t)PyCurses_API[2];\n" +" if (!was_initscr_called()) {\n" +" return NULL;\n" +" }\n" +"}" +msgstr "" +"{\n" +" typedef int (*predicate_t)(void);\n" +" predicate_t was_initscr_called = (predicate_t)PyCurses_API[2];\n" +" if (!was_initscr_called()) {\n" +" return NULL;\n" +" }\n" +"}" + +#: ../../c-api/curses.rst:112 +msgid "Macro checking if :func:`curses.start_color` has been called." +msgstr "如果已呼叫 :func:`curses.start_color`,則為巨集檢查。" + +#: ../../c-api/curses.rst:116 +msgid "" +"{\n" +" typedef int (*predicate_t)(void);\n" +" predicate_t was_start_color_called = (predicate_t)PyCurses_API[3];\n" +" if (!was_start_color_called()) {\n" +" return NULL;\n" +" }\n" +"}" +msgstr "" +"{\n" +" typedef int (*predicate_t)(void);\n" +" predicate_t was_start_color_called = (predicate_t)PyCurses_API[3];\n" +" if (!was_start_color_called()) {\n" +" return NULL;\n" +" }\n" +"}" + +#: ../../c-api/curses.rst:128 +msgid "Internal data" +msgstr "內部資料" + +#: ../../c-api/curses.rst:130 +msgid "" +"The following objects are exposed by the C API but should be considered " +"internal-only." +msgstr "以下物件由 C API 所公開,但應視為僅供內部使用。" + +#: ../../c-api/curses.rst:135 +msgid "Name of the curses capsule to pass to :c:func:`PyCapsule_Import`." +msgstr "" + +#: ../../c-api/curses.rst:137 +msgid "Internal usage only. Use :c:macro:`import_curses` instead." +msgstr "僅供內部使用。請改用 :c:macro:`import_curses`。" diff --git a/c-api/datetime.po b/c-api/datetime.po index 60f4918fdc2..9a62a3dbf6f 100644 --- a/c-api/datetime.po +++ b/c-api/datetime.po @@ -1,18 +1,18 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Ching-Lung Chuang, 2015 # Liang-Bo Wang , 2015 # Matt Wang , 2023 +# Yorkxe , 2025 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-08-22 00:03+0000\n" -"PO-Revision-Date: 2023-07-01 04:14+0800\n" -"Last-Translator: Matt Wang \n" +"POT-Creation-Date: 2025-11-20 17:54+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-" "tw)\n" "Language: zh_TW\n" @@ -31,82 +31,139 @@ msgid "" "Various date and time objects are supplied by the :mod:`datetime` module. " "Before using any of these functions, the header file :file:`datetime.h` must " "be included in your source (note that this is not included by :file:`Python." -"h`), and the macro :c:macro:`!PyDateTime_IMPORT` must be invoked, usually as " +"h`), and the macro :c:macro:`PyDateTime_IMPORT` must be invoked, usually as " "part of the module initialisation function. The macro puts a pointer to a C " -"structure into a static variable, :c:data:`!PyDateTimeAPI`, that is used by " +"structure into a static variable, :c:data:`PyDateTimeAPI`, that is used by " "the following macros." msgstr "" ":mod:`datetime` 模組提供各種日期和時間物件。在使用任何這些函式之前,必須將標" "頭檔 :file:`datetime.h` 引入於原始碼中(請注意,:file:`Python.h` 並無引入該標" -"頭檔),且巨集 :c:macro:`!PyDateTime_IMPORT` 必須被叫用,而這通常作為模組初始" -"化函式的一部分。該巨集將指向 C 結構的指標放入靜態變數 :c:data:`!" +"頭檔),且巨集 :c:macro:`PyDateTime_IMPORT` 必須被叫用,而這通常作為模組初始" +"化函式的一部分。該巨集將指向 C 結構的指標放入靜態變數 :c:data:`" "PyDateTimeAPI` 中,該變數會被以下巨集使用。" #: ../../c-api/datetime.rst:18 -msgid "This subtype of :c:type:`PyObject` represents a Python date object." +msgid "Import the datetime C API." +msgstr "引入 datetime C API。" + +#: ../../c-api/datetime.rst:20 +msgid "" +"On success, populate the :c:var:`PyDateTimeAPI` pointer. On failure, set :c:" +"var:`PyDateTimeAPI` to ``NULL`` and set an exception. The caller must check " +"if an error occurred via :c:func:`PyErr_Occurred`:" msgstr "" +"成功時填充 (populate) :c:var:`PyDateTimeAPI` 指標。失敗時將 :c:var:`PyDateTimeAPI` 設為 " +"``NULL`` 並設定一個例外。呼叫者必須透過 :c:func:`PyErr_Occurred` 檢查是否發生錯" +"誤:" -#: ../../c-api/datetime.rst:22 -msgid "This subtype of :c:type:`PyObject` represents a Python datetime object." +#: ../../c-api/datetime.rst:24 +msgid "" +"PyDateTime_IMPORT;\n" +"if (PyErr_Occurred()) { /* cleanup */ }" msgstr "" +"PyDateTime_IMPORT;\n" +"if (PyErr_Occurred()) { /* cleanup */ }" -#: ../../c-api/datetime.rst:26 +#: ../../c-api/datetime.rst:31 +msgid "This is not compatible with subinterpreters." +msgstr "這和子直譯器 (subinterpreters) 不相容。" + +#: ../../c-api/datetime.rst:35 +msgid "Structure containing the fields for the datetime C API." +msgstr "包含 datetime C API 欄位的結構。" + +#: ../../c-api/datetime.rst:37 +msgid "The fields of this structure are private and subject to change." +msgstr "此結構的欄位為私有且可能會變動。" + +#: ../../c-api/datetime.rst:39 +msgid "Do not use this directly; prefer ``PyDateTime_*`` APIs instead." +msgstr "不要直接使用這個;請改用 ``PyDateTime_*`` API。" + +#: ../../c-api/datetime.rst:43 +msgid "Dynamically allocated object containing the datetime C API." +msgstr "動態配置的物件,包含 datetime C API。" + +#: ../../c-api/datetime.rst:45 +msgid "" +"This variable is only available once :c:macro:`PyDateTime_IMPORT` succeeds." +msgstr "此變數僅在 :c:macro:`PyDateTime_IMPORT` 成功後可用。" + +#: ../../c-api/datetime.rst:49 +msgid "This subtype of :c:type:`PyObject` represents a Python date object." +msgstr "此 :c:type:`PyObject` 子型別代表 Python date 物件" + +#: ../../c-api/datetime.rst:53 +msgid "This subtype of :c:type:`PyObject` represents a Python datetime object." +msgstr "此 :c:type:`PyObject` 子型別代表 Python datetime 物件" + +#: ../../c-api/datetime.rst:57 msgid "This subtype of :c:type:`PyObject` represents a Python time object." -msgstr "" +msgstr "此 :c:type:`PyObject` 子型別代表 Python time 物件" -#: ../../c-api/datetime.rst:30 +#: ../../c-api/datetime.rst:61 msgid "" "This subtype of :c:type:`PyObject` represents the difference between two " "datetime values." -msgstr "" +msgstr "此 :c:type:`PyObject` 子型別代表兩個 datetime 物件的差值" -#: ../../c-api/datetime.rst:34 +#: ../../c-api/datetime.rst:65 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." msgstr "" +"此 :c:type:`PyTypeObject` 實例代表 Python date 型別,與 Python layer 中的 :" +"class:`datetime.date` 是同一物件" -#: ../../c-api/datetime.rst:39 +#: ../../c-api/datetime.rst:70 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." msgstr "" +"此 :c:type:`PyTypeObject` 實例代表 Python datetime 型別,與 Python layer 中" +"的 :class:`datetime.datetime` 是同一物件" -#: ../../c-api/datetime.rst:44 +#: ../../c-api/datetime.rst:75 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." msgstr "" +"此 :c:type:`PyTypeObject` 實例代表 Python time 型別,與 Python layer 中的 :" +"class:`datetime.time` 是同一物件" -#: ../../c-api/datetime.rst:49 +#: ../../c-api/datetime.rst:80 msgid "" -"This instance of :c:type:`PyTypeObject` represents Python type for the " +"This instance of :c:type:`PyTypeObject` represents the Python type for the " "difference between two datetime values; it is the same object as :class:" "`datetime.timedelta` in the Python layer." msgstr "" +"此 :c:type:`PyTypeObject` 實例代表 Python 兩個 datetime 物件的型別,與 " +"Python layer 中的 :class:`datetime.timedelta` 是同一物件" -#: ../../c-api/datetime.rst:55 +#: ../../c-api/datetime.rst:86 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." msgstr "" +"此 :c:type:`PyTypeObject` 實例代表 Python 時區資訊型別,與 Python layer 中" +"的 :class:`datetime.tzinfo` 是同一物件" -#: ../../c-api/datetime.rst:59 +#: ../../c-api/datetime.rst:90 msgid "Macro for access to the UTC singleton:" msgstr "用於存取 UTC 單例 (singleton) 的巨集:" -#: ../../c-api/datetime.rst:63 +#: ../../c-api/datetime.rst:94 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:69 +#: ../../c-api/datetime.rst:100 msgid "Type-check macros:" msgstr "型別檢查巨集:" -#: ../../c-api/datetime.rst:73 +#: ../../c-api/datetime.rst:104 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 " @@ -116,7 +173,7 @@ msgstr "" "PyDateTime_DateType` 的子型別,則回傳 true。 *ob* 不得為 ``NULL``。這個函式一" "定會執行成功。" -#: ../../c-api/datetime.rst:80 +#: ../../c-api/datetime.rst:111 msgid "" "Return true if *ob* is of type :c:data:`PyDateTime_DateType`. *ob* must not " "be ``NULL``. This function always succeeds." @@ -124,7 +181,7 @@ msgstr "" "如果 *ob* 的型別為 :c:data:`PyDateTime_DateType`,則回傳 true。 *ob* 不得為 " "``NULL``。這個函式一定會執行成功。" -#: ../../c-api/datetime.rst:86 +#: ../../c-api/datetime.rst:117 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``. " @@ -134,7 +191,7 @@ msgstr "" "PyDateTime_DateTimeType` 的子型別,則回傳 true。*ob* 不得為 ``NULL``。這個函" "式一定會執行成功。" -#: ../../c-api/datetime.rst:93 +#: ../../c-api/datetime.rst:124 msgid "" "Return true if *ob* is of type :c:data:`PyDateTime_DateTimeType`. *ob* must " "not be ``NULL``. This function always succeeds." @@ -142,7 +199,7 @@ msgstr "" "如果 *ob* 的型別為 :c:data:`PyDateTime_DateTimeType`,則回傳 true。*ob* 不得" "為 ``NULL``。這個函式一定會執行成功。" -#: ../../c-api/datetime.rst:99 +#: ../../c-api/datetime.rst:130 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 " @@ -152,7 +209,7 @@ msgstr "" "PyDateTime_TimeType` 的子型別,則回傳 true。*ob* 不得為 ``NULL``。這個函式一" "定會執行成功。" -#: ../../c-api/datetime.rst:106 +#: ../../c-api/datetime.rst:137 msgid "" "Return true if *ob* is of type :c:data:`PyDateTime_TimeType`. *ob* must not " "be ``NULL``. This function always succeeds." @@ -160,7 +217,7 @@ msgstr "" "如果 *ob* 的型別為 :c:data:`PyDateTime_TimeType`,則回傳 true。*ob* 不得為 " "``NULL``。這個函式一定會執行成功。" -#: ../../c-api/datetime.rst:112 +#: ../../c-api/datetime.rst:143 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 " @@ -170,7 +227,7 @@ msgstr "" "PyDateTime_DeltaType` 的子型別,則回傳 true。*ob* 不得為 ``NULL``。這個函式一" "定會執行成功。" -#: ../../c-api/datetime.rst:119 +#: ../../c-api/datetime.rst:150 msgid "" "Return true if *ob* is of type :c:data:`PyDateTime_DeltaType`. *ob* must not " "be ``NULL``. This function always succeeds." @@ -178,7 +235,7 @@ msgstr "" "如果 *ob* 的型別為 :c:data:`PyDateTime_DeltaType`,則回傳 true。*ob* 不得為 " "``NULL``。這個函式一定會執行成功。" -#: ../../c-api/datetime.rst:125 +#: ../../c-api/datetime.rst:156 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 " @@ -188,7 +245,7 @@ msgstr "" "PyDateTime_TZInfoType` 的子型別,則回傳 true。*ob* 不得為 ``NULL``。這個函式" "一定會執行成功。" -#: ../../c-api/datetime.rst:132 +#: ../../c-api/datetime.rst:163 msgid "" "Return true if *ob* is of type :c:data:`PyDateTime_TZInfoType`. *ob* must " "not be ``NULL``. This function always succeeds." @@ -196,24 +253,24 @@ msgstr "" "如果 *ob* 的型別為 :c:data:`PyDateTime_TZInfoType`,則回傳 true。 *ob* 不得" "為 ``NULL``。這個函式一定會執行成功。" -#: ../../c-api/datetime.rst:136 +#: ../../c-api/datetime.rst:167 msgid "Macros to create objects:" msgstr "建立物件的巨集:" -#: ../../c-api/datetime.rst:140 +#: ../../c-api/datetime.rst:171 msgid "" "Return a :class:`datetime.date` object with the specified year, month and " "day." msgstr "回傳一個有特定年、月、日的物件 :class:`datetime.date`。" -#: ../../c-api/datetime.rst:145 +#: ../../c-api/datetime.rst:176 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:151 +#: ../../c-api/datetime.rst:182 msgid "" "Return a :class:`datetime.datetime` object with the specified year, month, " "day, hour, minute, second, microsecond and fold." @@ -221,13 +278,13 @@ msgstr "" "回傳一個有特定年、月、日、時、分、秒、微秒與 fold(時間折疊)的物件 :class:" "`datetime.datetime`。" -#: ../../c-api/datetime.rst:159 +#: ../../c-api/datetime.rst:190 msgid "" "Return a :class:`datetime.time` object with the specified hour, minute, " "second and microsecond." -msgstr "回傳一個有特定時、分、秒、微秒的物件 :class:`datetime.date`。" +msgstr "回傳一個有特定時、分、秒、微秒的物件 :class:`datetime.time`。" -#: ../../c-api/datetime.rst:165 +#: ../../c-api/datetime.rst:196 msgid "" "Return a :class:`datetime.time` object with the specified hour, minute, " "second, microsecond and fold." @@ -235,7 +292,7 @@ msgstr "" "回傳一個有特定時、分、秒、微秒與 fold(時間折疊)的物件 :class:`datetime." "time`。" -#: ../../c-api/datetime.rst:173 +#: ../../c-api/datetime.rst:204 msgid "" "Return a :class:`datetime.timedelta` object representing the given number of " "days, seconds and microseconds. Normalization is performed so that the " @@ -246,7 +303,7 @@ msgstr "" "標準化 (normalization) 以便生成的微秒數和秒數位於 :class:`datetime." "timedelta` 物件記錄的範圍內。" -#: ../../c-api/datetime.rst:181 +#: ../../c-api/datetime.rst:212 msgid "" "Return a :class:`datetime.timezone` object with an unnamed fixed offset " "represented by the *offset* argument." @@ -254,7 +311,7 @@ msgstr "" "回傳一個 :class:`datetime.timezone` 物件,其未命名的固定偏移量由 *offset* 引" "數表示。" -#: ../../c-api/datetime.rst:189 +#: ../../c-api/datetime.rst:220 msgid "" "Return a :class:`datetime.timezone` object with a fixed offset represented " "by the *offset* argument and with tzname *name*." @@ -262,7 +319,7 @@ msgstr "" "回傳一個 :class:`datetime.timezone` 物件,其固定偏移量由 *offset* 引數表示," "並帶有 tzname *name*。" -#: ../../c-api/datetime.rst:195 +#: ../../c-api/datetime.rst:226 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:" @@ -273,19 +330,19 @@ msgstr "" "包括子類別(例如 :c:type:`PyDateTime_DateTime`)。引數不得為 ``NULL``,並且不" "會檢查型別:" -#: ../../c-api/datetime.rst:202 +#: ../../c-api/datetime.rst:233 msgid "Return the year, as a positive int." msgstr "回傳年份,為正整數。" -#: ../../c-api/datetime.rst:207 +#: ../../c-api/datetime.rst:238 msgid "Return the month, as an int from 1 through 12." msgstr "回傳月份,為正整數,從 1 到 12。" -#: ../../c-api/datetime.rst:212 +#: ../../c-api/datetime.rst:243 msgid "Return the day, as an int from 1 through 31." msgstr "回傳日期,為正整數,從 1 到 31。" -#: ../../c-api/datetime.rst:215 +#: ../../c-api/datetime.rst:246 msgid "" "Macros to extract fields from datetime objects. The argument must be an " "instance of :c:type:`PyDateTime_DateTime`, including subclasses. The " @@ -294,31 +351,31 @@ msgstr "" "從 datetime 物件中提取欄位的巨集。引數必須是個 :c:type:`PyDateTime_DateTime` " "的實例,包括子類別。引數不得為 ``NULL``,並且不會檢查型別:" -#: ../../c-api/datetime.rst:221 ../../c-api/datetime.rst:259 +#: ../../c-api/datetime.rst:252 ../../c-api/datetime.rst:290 msgid "Return the hour, as an int from 0 through 23." msgstr "回傳小時,為正整數,從 0 到 23。" -#: ../../c-api/datetime.rst:226 ../../c-api/datetime.rst:264 +#: ../../c-api/datetime.rst:257 ../../c-api/datetime.rst:295 msgid "Return the minute, as an int from 0 through 59." msgstr "回傳分鐘,為正整數,從 0 到 59。" -#: ../../c-api/datetime.rst:231 ../../c-api/datetime.rst:269 +#: ../../c-api/datetime.rst:262 ../../c-api/datetime.rst:300 msgid "Return the second, as an int from 0 through 59." msgstr "回傳秒,為正整數,從0 到59。" -#: ../../c-api/datetime.rst:236 ../../c-api/datetime.rst:274 +#: ../../c-api/datetime.rst:267 ../../c-api/datetime.rst:305 msgid "Return the microsecond, as an int from 0 through 999999." msgstr "回傳微秒,為正整數,從 0 到 999999。" -#: ../../c-api/datetime.rst:241 ../../c-api/datetime.rst:279 +#: ../../c-api/datetime.rst:272 ../../c-api/datetime.rst:310 msgid "Return the fold, as an int from 0 through 1." msgstr "回傳 fold,為 0 或 1 的正整數。" -#: ../../c-api/datetime.rst:248 ../../c-api/datetime.rst:286 +#: ../../c-api/datetime.rst:279 ../../c-api/datetime.rst:317 msgid "Return the tzinfo (which may be ``None``)." msgstr "回傳 tzinfo(可能是 ``None``)。" -#: ../../c-api/datetime.rst:253 +#: ../../c-api/datetime.rst:284 msgid "" "Macros to extract fields from time objects. The argument must be an " "instance of :c:type:`PyDateTime_Time`, including subclasses. The argument " @@ -327,7 +384,7 @@ msgstr "" "從 time 物件中提取欄位的巨集。引數必須是個 :c:type:`PyDateTime_Time` 的實例," "包括子類別。引數不得為 ``NULL``,並且不會檢查型別:" -#: ../../c-api/datetime.rst:291 +#: ../../c-api/datetime.rst:322 msgid "" "Macros to extract fields from time delta objects. The argument must be an " "instance of :c:type:`PyDateTime_Delta`, including subclasses. The argument " @@ -336,23 +393,23 @@ msgstr "" "從 time delta 物件中提取欄位的巨集。引數必須是個 :c:type:`PyDateTime_Delta` " "的實例,包括子類別。引數不能為 ``NULL``,並且不會檢查型別:" -#: ../../c-api/datetime.rst:297 +#: ../../c-api/datetime.rst:328 msgid "Return the number of days, as an int from -999999999 to 999999999." msgstr "以 -999999999 到 999999999 之間的整數形式回傳天數。" -#: ../../c-api/datetime.rst:304 +#: ../../c-api/datetime.rst:335 msgid "Return the number of seconds, as an int from 0 through 86399." msgstr "以 0 到 86399 之間的整數形式回傳秒數。" -#: ../../c-api/datetime.rst:311 +#: ../../c-api/datetime.rst:342 msgid "Return the number of microseconds, as an int from 0 through 999999." msgstr "以 0 到 999999 之間的整數形式回傳微秒數。" -#: ../../c-api/datetime.rst:316 +#: ../../c-api/datetime.rst:347 msgid "Macros for the convenience of modules implementing the DB API:" msgstr "為了方便模組實作 DB API 的巨集:" -#: ../../c-api/datetime.rst:320 +#: ../../c-api/datetime.rst:351 msgid "" "Create and return a new :class:`datetime.datetime` object given an argument " "tuple suitable for passing to :meth:`datetime.datetime.fromtimestamp`." @@ -360,10 +417,28 @@ msgstr "" "給定一個適合傳遞給 :meth:`datetime.datetime.fromtimestamp` 的引數元組,建立並" "回傳一個新的 :class:`datetime.datetime` 物件。" -#: ../../c-api/datetime.rst:326 +#: ../../c-api/datetime.rst:357 msgid "" "Create and return a new :class:`datetime.date` object given an argument " "tuple suitable for passing to :meth:`datetime.date.fromtimestamp`." msgstr "" "給定一個適合傳遞給 :meth:`datetime.date.fromtimestamp` 的引數元組,建立並回傳" "一個新的 :class:`datetime.date` 物件。" + +#: ../../c-api/datetime.rst:362 +msgid "Internal data" +msgstr "內部資料" + +#: ../../c-api/datetime.rst:364 +msgid "" +"The following symbols are exposed by the C API but should be considered " +"internal-only." +msgstr "以下符號由 C API 公開,但應視為僅供內部使用。" + +#: ../../c-api/datetime.rst:369 +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 +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 314623827e9..0613dc5d61f 100644 --- a/c-api/descriptor.po +++ b/c-api/descriptor.po @@ -1,5 +1,4 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -8,9 +7,9 @@ # msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-10-26 16:47+0000\n" +"POT-Creation-Date: 2025-12-02 00:15+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-" @@ -38,11 +37,99 @@ msgstr "" msgid "The type object for the built-in descriptor types." msgstr "內建 descriptor 型別的型別物件。" +#: ../../c-api/descriptor.rst:26 +msgid "" +"The type object for member descriptor objects created from :c:type:" +"`PyMemberDef` structures. These descriptors expose fields of a C struct as " +"attributes on a type, and correspond to :class:`types.MemberDescriptorType` " +"objects in Python." +msgstr "" + #: ../../c-api/descriptor.rst:35 msgid "" -"Return non-zero if the descriptor objects *descr* describes a data " -"attribute, or ``0`` if it describes a method. *descr* must be a descriptor " -"object; there is no error checking." +"The type object for get/set descriptor objects created from :c:type:" +"`PyGetSetDef` structures. These descriptors implement attributes whose value " +"is computed by C getter and setter functions, and are used for many built-in " +"type attributes." +msgstr "" + +#: ../../c-api/descriptor.rst:46 +msgid "" +"The type object for method descriptor objects created from :c:type:" +"`PyMethodDef` structures. These descriptors expose C functions as methods on " +"a type, and correspond to :class:`types.MemberDescriptorType` objects in " +"Python." +msgstr "" + +#: ../../c-api/descriptor.rst:57 +msgid "" +"The type object for wrapper descriptor objects created by :c:func:" +"`PyDescr_NewWrapper` and :c:func:`PyWrapper_New`. Wrapper descriptors are " +"used internally to expose special methods implemented via wrapper " +"structures, and appear in Python as :class:`types.WrapperDescriptorType` " +"objects." +msgstr "" + +#: ../../c-api/descriptor.rst:69 +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; " +"there is no error checking." msgstr "" "如果 descriptor 物件 *descr* 描述的是一個資料屬性則回傳非零值,或者如果它描述" -"的是一個方法則返回 ``0``。*descr* 必須為一個 descriptor 物件;沒有錯誤檢查。" +"的是一個方法則回傳 ``0``。*descr* 必須為一個 descriptor 物件;沒有錯誤檢查。" + +#: ../../c-api/descriptor.rst:78 +msgid "Built-in descriptors" +msgstr "內建描述器" + +#: ../../c-api/descriptor.rst:82 +msgid "" +"The type object for super objects. This is the same object as :class:`super` " +"in the Python layer." +msgstr "" + +#: ../../c-api/descriptor.rst:88 +msgid "" +"The type of class method objects. This is the same object as :class:" +"`classmethod` in the Python layer." +msgstr "" + +#: ../../c-api/descriptor.rst:94 +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 " +"extension types, and is the same object as :class:`classmethod` in Python." +msgstr "" + +#: ../../c-api/descriptor.rst:102 +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:105 +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:112 +msgid "" +"The type of static method objects. This is the same object as :class:" +"`staticmethod` in the Python layer." +msgstr "" + +#: ../../c-api/descriptor.rst:118 +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:121 +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 "" diff --git a/c-api/dict.po b/c-api/dict.po index b11b75f7753..e23ff151870 100644 --- a/c-api/dict.po +++ b/c-api/dict.po @@ -1,5 +1,4 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -7,9 +6,9 @@ # Liang-Bo Wang , 2015 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-02-21 00:13+0000\n" +"POT-Creation-Date: 2025-12-02 00:15+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-" @@ -27,22 +26,22 @@ msgstr "字典物件" #: ../../c-api/dict.rst:13 msgid "" "This subtype of :c:type:`PyObject` represents a Python dictionary object." -msgstr ":c:type:`PyObject` 子型態代表一個 Python 字典物件。" +msgstr ":c:type:`PyObject` 子型別代表一個 Python 字典物件。" #: ../../c-api/dict.rst:18 msgid "" "This instance of :c:type:`PyTypeObject` represents the Python dictionary " "type. This is the same object as :class:`dict` in the Python layer." msgstr "" -":c:type:`PyTypeObject` 實例代表一個 Python 字典型態。此與 Python 層中" -"的 :class:`dict` 為同一個物件。" +":c:type:`PyTypeObject` 實例代表一個 Python 字典型別。此與 Python 層中的 :" +"class:`dict` 為同一個物件。" #: ../../c-api/dict.rst:24 msgid "" "Return true if *p* is a dict object or an instance of a subtype of the dict " "type. This function always succeeds." msgstr "" -"若 *p* 是一個字典物件或字典的子型態實例則會回傳 true。此函式每次都會執行成" +"若 *p* 是一個字典物件或字典的子型別實例則會回傳 true。此函式每次都會執行成" "功。" #: ../../c-api/dict.rst:30 @@ -50,7 +49,7 @@ msgid "" "Return true if *p* is a dict object, but not an instance of a subtype of the " "dict type. This function always succeeds." msgstr "" -"若 *p* 是一個字典物件但並不是一個字典子型態的實例,則回傳 true。此函式每次都" +"若 *p* 是一個字典物件但並不是一個字典子型別的實例,則回傳 true。此函式每次都" "會執行成功。" #: ../../c-api/dict.rst:36 @@ -65,132 +64,140 @@ msgid "" msgstr "" #: ../../c-api/dict.rst:48 +msgid "" +"The type object for mapping proxy objects created by :c:func:" +"`PyDictProxy_New` and for the read-only ``__dict__`` attribute of many built-" +"in types. A :c:type:`PyDictProxy_Type` instance provides a dynamic, read-" +"only view of an underlying dictionary: changes to the underlying dictionary " +"are reflected in the proxy, but the proxy itself does not support mutation " +"operations. This corresponds to :class:`types.MappingProxyType` in Python." +msgstr "" + +#: ../../c-api/dict.rst:59 msgid "Empty an existing dictionary of all key-value pairs." msgstr "清空現有字典中的所有鍵值對。" -#: ../../c-api/dict.rst:53 +#: ../../c-api/dict.rst:64 msgid "" -"Determine if dictionary *p* contains *key*. If an item in *p* is matches " +"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:60 +#: ../../c-api/dict.rst:71 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*`." +"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:69 +#: ../../c-api/dict.rst:80 msgid "Return a new dictionary that contains the same key-value pairs as *p*." -msgstr "" +msgstr "回傳一個新的字典,包含與 *p* 相同的鍵值對。" -#: ../../c-api/dict.rst:74 +#: ../../c-api/dict.rst:85 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`` on success or ``-1`` on failure. This function *does not* steal a " -"reference to *val*." +"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`` " +"on success or ``-1`` on failure. This function *does not* steal a reference " +"to *val*." msgstr "" -#: ../../c-api/dict.rst:82 +#: ../../c-api/dict.rst:93 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*`." +"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:89 +#: ../../c-api/dict.rst:100 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 dictionary, :exc:`KeyError` is raised. Return ``0`` on success or " -"``-1`` on failure." +"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 " +"dictionary, :exc:`KeyError` is raised. Return ``0`` on success or ``-1`` on " +"failure." msgstr "" -#: ../../c-api/dict.rst:97 +#: ../../c-api/dict.rst:108 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*`." +"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:104 +#: ../../c-api/dict.rst:115 msgid "" "Return a new :term:`strong reference` to the object from dictionary *p* " "which has a key *key*:" msgstr "" -#: ../../c-api/dict.rst:107 +#: ../../c-api/dict.rst:118 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:109 +#: ../../c-api/dict.rst:120 msgid "If the key is missing, set *\\*result* to ``NULL`` and return ``0``." -msgstr "" +msgstr "如果鍵不存在,將 *\\*result* 設為 ``NULL`` 並回傳 ``0``。" -#: ../../c-api/dict.rst:110 ../../c-api/dict.rst:207 +#: ../../c-api/dict.rst:121 ../../c-api/dict.rst:218 msgid "On error, raise an exception and return ``-1``." msgstr "錯誤發生時,引發一個例外並回傳 ``-1``。" -#: ../../c-api/dict.rst:114 +#: ../../c-api/dict.rst:125 msgid "See also the :c:func:`PyObject_GetItem` function." msgstr "另見 :c:func:`PyObject_GetItem` 函式。" -#: ../../c-api/dict.rst:119 +#: ../../c-api/dict.rst:130 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:125 +#: ../../c-api/dict.rst:136 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." +"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:129 +#: ../../c-api/dict.rst:140 msgid "" -"Calling this API without :term:`GIL` held had been allowed for historical " -"reason. It is no longer allowed." +"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:136 +#: ../../c-api/dict.rst:147 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:144 +#: ../../c-api/dict.rst:155 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*`." +"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:150 +#: ../../c-api/dict.rst:161 msgid "" -"Exceptions that occur while this calls :meth:`~object.__hash__` " -"and :meth:`~object.__eq__` methods or while creating the " -"temporary :class:`str` object are silently ignored. Prefer using " -"the :c:func:`PyDict_GetItemWithError` function with your " -"own :c:func:`PyUnicode_FromString` *key* instead." +"Exceptions that occur while this calls :meth:`~object.__hash__` and :meth:" +"`~object.__eq__` methods or while creating the temporary :class:`str` object " +"are silently ignored. Prefer using the :c:func:`PyDict_GetItemWithError` " +"function with your own :c:func:`PyUnicode_FromString` *key* instead." msgstr "" -#: ../../c-api/dict.rst:159 +#: ../../c-api/dict.rst:170 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*`." +"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:168 +#: ../../c-api/dict.rst:179 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 " @@ -200,7 +207,7 @@ msgid "" "the insertion." msgstr "" -#: ../../c-api/dict.rst:179 +#: ../../c-api/dict.rst:190 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``, " @@ -212,7 +219,7 @@ msgid "" "exception, and sets ``*result`` to ``NULL``." msgstr "" -#: ../../c-api/dict.rst:189 +#: ../../c-api/dict.rst:200 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 " @@ -220,77 +227,81 @@ msgid "" "to the same object: in that case you hold two separate references to it." msgstr "" -#: ../../c-api/dict.rst:200 +#: ../../c-api/dict.rst:211 msgid "" "Remove *key* from dictionary *p* and optionally return the removed value. Do " -"not raise :exc:`KeyError` if the key missing." +"not raise :exc:`KeyError` if the key is missing." msgstr "" -#: ../../c-api/dict.rst:203 +#: ../../c-api/dict.rst:214 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:205 +#: ../../c-api/dict.rst:216 msgid "" "If the key is missing, set *\\*result* to ``NULL`` if *result* is not " "``NULL``, and return ``0``." msgstr "" -#: ../../c-api/dict.rst:209 +#: ../../c-api/dict.rst:220 msgid "" -"Similar to :meth:`dict.pop`, but without the default value and not " -"raising :exc:`KeyError` if the key missing." +"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:217 +#: ../../c-api/dict.rst:228 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:226 +#: ../../c-api/dict.rst:237 msgid "" "Return a :c:type:`PyListObject` containing all the items from the dictionary." msgstr "回傳一個包含字典中所有項目的 :c:type:`PyListObject`。" -#: ../../c-api/dict.rst:231 +#: ../../c-api/dict.rst:242 msgid "" "Return a :c:type:`PyListObject` containing all the keys from the dictionary." msgstr "回傳一個包含字典中所有鍵的 :c:type:`PyListObject`。" -#: ../../c-api/dict.rst:236 +#: ../../c-api/dict.rst:247 msgid "" "Return a :c:type:`PyListObject` containing all the values from the " "dictionary *p*." msgstr "回傳一個包含字典 *p* 中所有值的 :c:type:`PyListObject`。" -#: ../../c-api/dict.rst:244 +#: ../../c-api/dict.rst:255 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:250 +#: ../../c-api/dict.rst:261 +msgid "Similar to :c:func:`PyDict_Size`, but without error checking." +msgstr "和 :c:func:`PyDict_Size` 類似,但沒有錯誤檢查。" + +#: ../../c-api/dict.rst:266 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 first call to this function to start the iteration; the " -"function returns true for each pair in the dictionary, and false once all " -"pairs have been reported. The parameters *pkey* and *pvalue* should either " -"point to :c:expr:`PyObject*` variables that will be filled in with each key " -"and value, respectively, or may be ``NULL``. Any references returned " -"through them are borrowed. *ppos* should not be altered during iteration. " -"Its value represents offsets within the internal dictionary structure, and " -"since the structure is sparse, the offsets are not consecutive." +"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 " +"first call to this function to start the iteration; the function returns " +"true for each pair in the dictionary, and false once all pairs have been " +"reported. The parameters *pkey* and *pvalue* should either point to :c:expr:" +"`PyObject*` variables that will be filled in with each key and value, " +"respectively, or may be ``NULL``. Any references returned through them are " +"borrowed. *ppos* should not be altered during iteration. Its value " +"represents offsets within the internal dictionary structure, and since the " +"structure is sparse, the offsets are not consecutive." msgstr "" -#: ../../c-api/dict.rst:261 +#: ../../c-api/dict.rst:277 msgid "For example::" msgstr "舉例來說: ::" -#: ../../c-api/dict.rst:263 +#: ../../c-api/dict.rst:279 msgid "" "PyObject *key, *value;\n" "Py_ssize_t pos = 0;\n" @@ -300,15 +311,22 @@ msgid "" " ...\n" "}" msgstr "" +"PyObject *key, *value;\n" +"Py_ssize_t pos = 0;\n" +"\n" +"while (PyDict_Next(self->dict, &pos, &key, &value)) {\n" +" /* 用值做一些有趣的事情... */\n" +" ...\n" +"}" -#: ../../c-api/dict.rst:271 +#: ../../c-api/dict.rst:287 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:275 +#: ../../c-api/dict.rst:291 msgid "" "PyObject *key, *value;\n" "Py_ssize_t pos = 0;\n" @@ -346,15 +364,14 @@ msgstr "" " Py_DECREF(o);\n" "}" -#: ../../c-api/dict.rst:293 +#: ../../c-api/dict.rst:309 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. You can use :c:macro:" +"`Py_BEGIN_CRITICAL_SECTION` to lock the dictionary while iterating over it::" msgstr "" -#: ../../c-api/dict.rst:298 +#: ../../c-api/dict.rst:314 msgid "" "Py_BEGIN_CRITICAL_SECTION(self->dict);\n" "while (PyDict_Next(self->dict, &pos, &key, &value)) {\n" @@ -368,7 +385,18 @@ msgstr "" "}\n" "Py_END_CRITICAL_SECTION();" -#: ../../c-api/dict.rst:307 +#: ../../c-api/dict.rst:322 +msgid "" +"On the free-threaded build, this function can be used safely inside a " +"critical section. However, the references returned for *pkey* and *pvalue* " +"are :term:`borrowed ` and are only valid while the " +"critical section is held. If you need to use these objects outside the " +"critical section or when the critical section can be suspended, create a :" +"term:`strong reference ` (for example, using :c:func:" +"`Py_NewRef`)." +msgstr "" + +#: ../../c-api/dict.rst:332 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` " @@ -378,16 +406,16 @@ msgid "" "or ``-1`` if an exception was raised." msgstr "" -#: ../../c-api/dict.rst:317 +#: ../../c-api/dict.rst:342 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 to the iterating over a sequence of key value pairs if the second " -"argument has no \"keys\" attribute. Return ``0`` on success or ``-1`` if an " +"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 " +"to the iterating over a sequence of key value pairs if the second argument " +"has no \"keys\" attribute. Return ``0`` on success or ``-1`` if an " "exception was raised." msgstr "" -#: ../../c-api/dict.rst:326 +#: ../../c-api/dict.rst:351 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, " @@ -396,7 +424,7 @@ msgid "" "if an exception was raised. Equivalent Python (except for the return value)::" msgstr "" -#: ../../c-api/dict.rst:333 +#: ../../c-api/dict.rst:358 msgid "" "def PyDict_MergeFromSeq2(a, seq2, override):\n" " for key, value in seq2:\n" @@ -408,7 +436,7 @@ msgstr "" " if override or key not in a:\n" " a[key] = value" -#: ../../c-api/dict.rst:340 +#: ../../c-api/dict.rst:365 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 " @@ -416,21 +444,21 @@ msgid "" "exception." msgstr "" -#: ../../c-api/dict.rst:349 +#: ../../c-api/dict.rst:374 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.)" +"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:357 +#: ../../c-api/dict.rst:382 msgid "" -"Mark dictionary *dict* as watched. The callback granted *watcher_id* " -"by :c:func:`PyDict_AddWatcher` will be called when *dict* is modified or " +"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:365 +#: ../../c-api/dict.rst:390 msgid "" "Mark dictionary *dict* as no longer watched. The callback granted " "*watcher_id* by :c:func:`PyDict_AddWatcher` will no longer be called when " @@ -438,7 +466,7 @@ msgid "" "watched by this watcher. Return ``0`` on success or ``-1`` on error." msgstr "" -#: ../../c-api/dict.rst:374 +#: ../../c-api/dict.rst:399 msgid "" "Enumeration of possible dictionary watcher events: ``PyDict_EVENT_ADDED``, " "``PyDict_EVENT_MODIFIED``, ``PyDict_EVENT_DELETED``, " @@ -446,11 +474,11 @@ msgid "" "``PyDict_EVENT_DEALLOCATED``." msgstr "" -#: ../../c-api/dict.rst:382 +#: ../../c-api/dict.rst:407 msgid "Type of a dict watcher callback function." msgstr "" -#: ../../c-api/dict.rst:384 +#: ../../c-api/dict.rst:409 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`` " @@ -459,7 +487,7 @@ msgid "" "dictionary and *new_value* will be ``NULL``." msgstr "" -#: ../../c-api/dict.rst:390 +#: ../../c-api/dict.rst:415 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 " @@ -467,14 +495,14 @@ msgid "" "``PyDict_EVENT_CLONED`` is issued, and *key* will be the source dictionary." msgstr "" -#: ../../c-api/dict.rst:396 +#: ../../c-api/dict.rst:421 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:400 +#: ../../c-api/dict.rst:425 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 " @@ -483,20 +511,20 @@ msgid "" "again." msgstr "" -#: ../../c-api/dict.rst:406 +#: ../../c-api/dict.rst:431 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:409 +#: ../../c-api/dict.rst:434 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``." +"will be printed as an unraisable exception using :c:func:" +"`PyErr_WriteUnraisable`. Otherwise it should return ``0``." msgstr "" -#: ../../c-api/dict.rst:413 +#: ../../c-api/dict.rst:438 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 " @@ -505,6 +533,169 @@ msgid "" "it before returning." msgstr "" +#: ../../c-api/dict.rst:448 +msgid "Dictionary View Objects" +msgstr "字典視圖物件" + +#: ../../c-api/dict.rst:452 +msgid "" +"Return true if *op* is a view of a set inside a dictionary. This is " +"currently equivalent to :c:expr:`PyDictKeys_Check(op) || " +"PyDictItems_Check(op)`. This function always succeeds." +msgstr "" +"若 *op* 是一個字典中集合的視圖則會回傳 true。這目前等同於 :c:expr:" +"`PyDictKeys_Check(op) || PyDictItems_Check(op)`。此函式每次都會執行成功。" + +#: ../../c-api/dict.rst:459 +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:465 +msgid "" +"Return true if *op* is an instance of a dictionary keys view. This function " +"always succeeds." +msgstr "若 *op* 是一個字典鍵視圖的實例則會回傳 true。此函式每次都會執行成功。" + +#: ../../c-api/dict.rst:471 +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:477 +msgid "" +"Return true if *op* is an instance of a dictionary values view. This " +"function always succeeds." +msgstr "若 *op* 是一個字典值視圖的實例則會回傳 true。此函式每次都會執行成功。" + +#: ../../c-api/dict.rst:483 +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:489 +msgid "" +"Return true if *op* is an instance of a dictionary items view. This function " +"always succeeds." +msgstr "" +"若 *op* 是一個字典項目視圖的實例則會回傳 true。此函式每次都會執行成功。" + +#: ../../c-api/dict.rst:494 +msgid "Ordered Dictionaries" +msgstr "有序字典" + +#: ../../c-api/dict.rst:496 +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:503 +msgid "" +"Type object for ordered dictionaries. This is the same object as :class:" +"`collections.OrderedDict` in the Python layer." +msgstr "" +"有序字典的型別物件。此與 Python 層中的 :class:`collections.OrderedDict` 為同" +"一個物件。" + +#: ../../c-api/dict.rst:509 +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 " +"succeeds." +msgstr "" +"若 *od* 是一個有序字典物件或 :class:`~collections.OrderedDict` 的子型別實例則" +"會回傳 true。此函式每次都會執行成功。" + +#: ../../c-api/dict.rst:516 +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 " +"always succeeds." +msgstr "" +"若 *od* 是一個有序字典物件但並不是一個 :class:`~collections.OrderedDict` 子型" +"別的實例,則回傳 true。此函式每次都會執行成功。" + +#: ../../c-api/dict.rst:523 +msgid "Analogous to :c:type:`PyDictKeys_Type` for ordered dictionaries." +msgstr "" + +#: ../../c-api/dict.rst:528 +msgid "Analogous to :c:type:`PyDictValues_Type` for ordered dictionaries." +msgstr "" + +#: ../../c-api/dict.rst:533 +msgid "Analogous to :c:type:`PyDictItems_Type` for ordered dictionaries." +msgstr "" + +#: ../../c-api/dict.rst:538 +msgid "Return a new empty ordered dictionary, or ``NULL`` on failure." +msgstr "回傳一個新的空有序字典,或在失敗時回傳 ``NULL``。" + +#: ../../c-api/dict.rst:540 +msgid "This is analogous to :c:func:`PyDict_New`." +msgstr "這和 :c:func:`PyDict_New` 類似。" + +#: ../../c-api/dict.rst:545 +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:548 +msgid "This is analogous to :c:func:`PyDict_SetItem`." +msgstr "這和 :c:func:`PyDict_SetItem` 類似。" + +#: ../../c-api/dict.rst:553 +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:556 +msgid "This is analogous to :c:func:`PyDict_DelItem`." +msgstr "這和 :c:func:`PyDict_DelItem` 類似。" + +#: ../../c-api/dict.rst:559 +msgid "These are :term:`soft deprecated` aliases to ``PyDict`` APIs:" +msgstr "" + +#: ../../c-api/dict.rst:566 +msgid "``PyODict``" +msgstr "``PyODict``" + +#: ../../c-api/dict.rst:567 +msgid "``PyDict``" +msgstr "``PyDict``" + +#: ../../c-api/dict.rst:569 +msgid ":c:func:`PyDict_GetItem`" +msgstr ":c:func:`PyDict_GetItem`" + +#: ../../c-api/dict.rst:571 +msgid ":c:func:`PyDict_GetItemWithError`" +msgstr ":c:func:`PyDict_GetItemWithError`" + +#: ../../c-api/dict.rst:573 +msgid ":c:func:`PyDict_GetItemString`" +msgstr ":c:func:`PyDict_GetItemString`" + +#: ../../c-api/dict.rst:575 +msgid ":c:func:`PyDict_Contains`" +msgstr ":c:func:`PyDict_Contains`" + +#: ../../c-api/dict.rst:577 +msgid ":c:func:`PyDict_Size`" +msgstr ":c:func:`PyDict_Size`" + +#: ../../c-api/dict.rst:579 +msgid ":c:func:`PyDict_GET_SIZE`" +msgstr ":c:func:`PyDict_GET_SIZE`" + #: ../../c-api/dict.rst:8 msgid "object" msgstr "object(物件)" @@ -513,13 +704,10 @@ msgstr "object(物件)" msgid "dictionary" msgstr "dictionary(字典)" -#: ../../c-api/dict.rst:242 +#: ../../c-api/dict.rst:253 msgid "built-in function" msgstr "built-in function(內建函式)" -#: ../../c-api/dict.rst:242 +#: ../../c-api/dict.rst:253 msgid "len" msgstr "len" - -#~ msgid "PyUnicode_FromString()" -#~ msgstr "PyUnicode_FromString()" diff --git a/c-api/exceptions.po b/c-api/exceptions.po index 4dd9f8c9151..8a03c9821f8 100644 --- a/c-api/exceptions.po +++ b/c-api/exceptions.po @@ -1,13 +1,13 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Ching-Lung Chuang, 2015 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-07-11 00:17+0000\n" +"POT-Creation-Date: 2025-11-26 00:14+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-" @@ -157,7 +157,7 @@ msgstr "" #: ../../c-api/exceptions.rst:123 msgid "Raising exceptions" -msgstr "" +msgstr "引發例外" #: ../../c-api/exceptions.rst:125 msgid "" @@ -328,17 +328,23 @@ msgstr "" #: ../../c-api/exceptions.rst:314 msgid "" +"Similar to :c:func:`PyErr_SyntaxLocationObject`, but also sets the " +"*end_lineno* and *end_col_offset* information for the current exception." +msgstr "" + +#: ../../c-api/exceptions.rst:322 +msgid "" "Like :c:func:`PyErr_SyntaxLocationObject`, but *filename* is a byte string " "decoded from the :term:`filesystem encoding and error handler`." msgstr "" -#: ../../c-api/exceptions.rst:322 +#: ../../c-api/exceptions.rst:330 msgid "" "Like :c:func:`PyErr_SyntaxLocationEx`, but the *col_offset* parameter is " "omitted." msgstr "" -#: ../../c-api/exceptions.rst:328 +#: ../../c-api/exceptions.rst:336 msgid "" "This is a shorthand for ``PyErr_SetString(PyExc_SystemError, message)``, " "where *message* indicates that an internal operation (e.g. a Python/C API " @@ -346,11 +352,30 @@ msgid "" "use." msgstr "" -#: ../../c-api/exceptions.rst:335 -msgid "Issuing warnings" +#: ../../c-api/exceptions.rst:344 +msgid "" +"Get the source line in *filename* at line *lineno*. *filename* should be a " +"Python :class:`str` object." msgstr "" -#: ../../c-api/exceptions.rst:337 +#: ../../c-api/exceptions.rst:347 +msgid "" +"On success, this function returns a Python string object with the found " +"line. On failure, this function returns ``NULL`` without an exception set." +msgstr "" + +#: ../../c-api/exceptions.rst:353 +msgid "" +"Similar to :c:func:`PyErr_ProgramTextObject`, but *filename* is a :c:expr:" +"`const char *`, which is decoded with the :term:`filesystem encoding and " +"error handler`, instead of a Python object reference." +msgstr "" + +#: ../../c-api/exceptions.rst:360 +msgid "Issuing warnings" +msgstr "發出警告" + +#: ../../c-api/exceptions.rst:362 msgid "" "Use these functions to issue warnings from C code. They mirror similar " "functions exported by the Python :mod:`warnings` module. They normally " @@ -366,7 +391,7 @@ msgid "" "return an error value)." msgstr "" -#: ../../c-api/exceptions.rst:352 +#: ../../c-api/exceptions.rst:377 msgid "" "Issue a warning message. The *category* argument is a warning category (see " "below) or ``NULL``; the *message* argument is a UTF-8 encoded string. " @@ -376,7 +401,7 @@ msgid "" "`PyErr_WarnEx`, 2 is the function above that, and so forth." msgstr "" -#: ../../c-api/exceptions.rst:359 +#: ../../c-api/exceptions.rst:384 msgid "" "Warning categories must be subclasses of :c:data:`PyExc_Warning`; :c:data:" "`PyExc_Warning` is a subclass of :c:data:`PyExc_Exception`; the default " @@ -385,14 +410,14 @@ msgid "" "enumerated at :ref:`standardwarningcategories`." msgstr "" -#: ../../c-api/exceptions.rst:365 +#: ../../c-api/exceptions.rst:390 msgid "" "For information about warning control, see the documentation for the :mod:" "`warnings` module and the :option:`-W` option in the command line " "documentation. There is no C API for warning control." msgstr "" -#: ../../c-api/exceptions.rst:372 +#: ../../c-api/exceptions.rst:397 msgid "" "Issue a warning message with explicit control over all warning attributes. " "This is a straightforward wrapper around the Python function :func:`warnings." @@ -400,32 +425,39 @@ msgid "" "arguments may be set to ``NULL`` to get the default effect described there." msgstr "" -#: ../../c-api/exceptions.rst:383 +#: ../../c-api/exceptions.rst:408 msgid "" "Similar to :c:func:`PyErr_WarnExplicitObject` except that *message* and " "*module* are UTF-8 encoded strings, and *filename* is decoded from the :term:" "`filesystem encoding and error handler`." msgstr "" -#: ../../c-api/exceptions.rst:390 +#: ../../c-api/exceptions.rst:415 msgid "" "Function similar to :c:func:`PyErr_WarnEx`, but use :c:func:" "`PyUnicode_FromFormat` to format the warning message. *format* is an ASCII-" "encoded string." msgstr "" -#: ../../c-api/exceptions.rst:399 +#: ../../c-api/exceptions.rst:424 +msgid "" +"Similar to :c:func:`PyErr_WarnExplicit`, but uses :c:func:" +"`PyUnicode_FromFormat` to format the warning message. *format* is an ASCII-" +"encoded string." +msgstr "" + +#: ../../c-api/exceptions.rst:433 msgid "" "Function similar to :c:func:`PyErr_WarnFormat`, but *category* is :exc:" "`ResourceWarning` and it passes *source* to :class:`!warnings." "WarningMessage`." msgstr "" -#: ../../c-api/exceptions.rst:406 +#: ../../c-api/exceptions.rst:440 msgid "Querying the error indicator" msgstr "" -#: ../../c-api/exceptions.rst:410 +#: ../../c-api/exceptions.rst:444 msgid "" "Test whether the error indicator is set. If set, return the exception " "*type* (the first argument to the last call to one of the ``PyErr_Set*`` " @@ -434,11 +466,11 @@ msgid "" "`Py_DECREF` it." msgstr "" -#: ../../c-api/exceptions.rst:416 -msgid "The caller must hold the GIL." -msgstr "呼叫者必須持有 GIL。" +#: ../../c-api/exceptions.rst:450 +msgid "The caller must have an :term:`attached thread state`." +msgstr "" -#: ../../c-api/exceptions.rst:420 +#: ../../c-api/exceptions.rst:454 msgid "" "Do not compare the return value to a specific exception; use :c:func:" "`PyErr_ExceptionMatches` instead, shown below. (The comparison could easily " @@ -446,14 +478,14 @@ msgid "" "of a class exception, or it may be a subclass of the expected exception.)" msgstr "" -#: ../../c-api/exceptions.rst:428 +#: ../../c-api/exceptions.rst:462 msgid "" "Equivalent to ``PyErr_GivenExceptionMatches(PyErr_Occurred(), exc)``. This " "should only be called when an exception is actually set; a memory access " "violation will occur if no exception has been raised." msgstr "" -#: ../../c-api/exceptions.rst:435 +#: ../../c-api/exceptions.rst:469 msgid "" "Return true if the *given* exception matches the exception type in *exc*. " "If *exc* is a class object, this also returns true when *given* is an " @@ -461,23 +493,23 @@ msgid "" "tuple (and recursively in subtuples) are searched for a match." msgstr "" -#: ../../c-api/exceptions.rst:443 +#: ../../c-api/exceptions.rst:477 msgid "" "Return the exception currently being raised, clearing the error indicator at " "the same time. Return ``NULL`` if the error indicator is not set." msgstr "" -#: ../../c-api/exceptions.rst:446 +#: ../../c-api/exceptions.rst:480 msgid "" "This function is used by code that needs to catch exceptions, or code that " "needs to save and restore the error indicator temporarily." msgstr "" -#: ../../c-api/exceptions.rst:449 ../../c-api/exceptions.rst:493 +#: ../../c-api/exceptions.rst:483 ../../c-api/exceptions.rst:527 msgid "For example::" msgstr "舉例來說: ::" -#: ../../c-api/exceptions.rst:451 +#: ../../c-api/exceptions.rst:485 msgid "" "{\n" " PyObject *exc = PyErr_GetRaisedException();\n" @@ -495,27 +527,27 @@ msgstr "" " PyErr_SetRaisedException(exc);\n" "}" -#: ../../c-api/exceptions.rst:459 +#: ../../c-api/exceptions.rst:493 msgid "" ":c:func:`PyErr_GetHandledException`, to save the exception currently being " "handled." msgstr "" -#: ../../c-api/exceptions.rst:467 +#: ../../c-api/exceptions.rst:501 msgid "" "Set *exc* as the exception currently being raised, clearing the existing " "exception if one is set." msgstr "" -#: ../../c-api/exceptions.rst:472 +#: ../../c-api/exceptions.rst:506 msgid "This call steals a reference to *exc*, which must be a valid exception." msgstr "" -#: ../../c-api/exceptions.rst:481 +#: ../../c-api/exceptions.rst:515 msgid "Use :c:func:`PyErr_GetRaisedException` instead." msgstr "請改用 :c:func:`PyErr_GetRaisedException`。" -#: ../../c-api/exceptions.rst:483 +#: ../../c-api/exceptions.rst:517 msgid "" "Retrieve the error indicator into three variables whose addresses are " "passed. If the error indicator is not set, set all three variables to " @@ -524,13 +556,13 @@ msgid "" "the type object is not." msgstr "" -#: ../../c-api/exceptions.rst:490 +#: ../../c-api/exceptions.rst:524 msgid "" "This function is normally only used by legacy code that needs to catch " "exceptions or save and restore the error indicator temporarily." msgstr "" -#: ../../c-api/exceptions.rst:495 +#: ../../c-api/exceptions.rst:529 msgid "" "{\n" " PyObject *type, *value, *traceback;\n" @@ -550,11 +582,11 @@ msgstr "" " PyErr_Restore(type, value, traceback);\n" "}" -#: ../../c-api/exceptions.rst:509 +#: ../../c-api/exceptions.rst:543 msgid "Use :c:func:`PyErr_SetRaisedException` instead." msgstr "請改用 :c:func:`PyErr_SetRaisedException`。" -#: ../../c-api/exceptions.rst:511 +#: ../../c-api/exceptions.rst:545 msgid "" "Set the error indicator from the three objects, *type*, *value*, and " "*traceback*, clearing the existing exception if one is set. If the objects " @@ -567,20 +599,20 @@ msgid "" "don't use this function. I warned you.)" msgstr "" -#: ../../c-api/exceptions.rst:525 +#: ../../c-api/exceptions.rst:559 msgid "" "This function is normally only used by legacy code that needs to save and " "restore the error indicator temporarily. Use :c:func:`PyErr_Fetch` to save " "the current error indicator." msgstr "" -#: ../../c-api/exceptions.rst:534 +#: ../../c-api/exceptions.rst:568 msgid "" "Use :c:func:`PyErr_GetRaisedException` instead, to avoid any possible de-" "normalization." msgstr "" -#: ../../c-api/exceptions.rst:537 +#: ../../c-api/exceptions.rst:571 msgid "" "Under certain circumstances, the values returned by :c:func:`PyErr_Fetch` " "below can be \"unnormalized\", meaning that ``*exc`` is a class object but " @@ -590,14 +622,14 @@ msgid "" "improve performance." msgstr "" -#: ../../c-api/exceptions.rst:545 +#: ../../c-api/exceptions.rst:579 msgid "" "This function *does not* implicitly set the :attr:`~BaseException." "__traceback__` attribute on the exception value. If setting the traceback " "appropriately is desired, the following additional snippet is needed::" msgstr "" -#: ../../c-api/exceptions.rst:550 +#: ../../c-api/exceptions.rst:584 msgid "" "if (tb != NULL) {\n" " PyException_SetTraceback(val, tb);\n" @@ -607,7 +639,7 @@ msgstr "" " PyException_SetTraceback(val, tb);\n" "}" -#: ../../c-api/exceptions.rst:557 +#: ../../c-api/exceptions.rst:591 msgid "" "Retrieve the active exception instance, as would be returned by :func:`sys." "exception`. This refers to an exception that was *already caught*, not to an " @@ -615,7 +647,7 @@ msgid "" "or ``NULL``. Does not modify the interpreter's exception state." msgstr "" -#: ../../c-api/exceptions.rst:564 +#: ../../c-api/exceptions.rst:598 msgid "" "This function is not normally used by code that wants to handle exceptions. " "Rather, it can be used when code needs to save and restore the exception " @@ -623,14 +655,14 @@ msgid "" "clear the exception state." msgstr "" -#: ../../c-api/exceptions.rst:573 +#: ../../c-api/exceptions.rst:607 msgid "" "Set the active exception, as known from ``sys.exception()``. This refers to " "an exception that was *already caught*, not to an exception that was freshly " "raised. To clear the exception state, pass ``NULL``." msgstr "" -#: ../../c-api/exceptions.rst:580 +#: ../../c-api/exceptions.rst:614 msgid "" "This function is not normally used by code that wants to handle exceptions. " "Rather, it can be used when code needs to save and restore the exception " @@ -638,7 +670,7 @@ msgid "" "exception state." msgstr "" -#: ../../c-api/exceptions.rst:589 +#: ../../c-api/exceptions.rst:623 msgid "" "Retrieve the old-style representation of the exception info, as known from :" "func:`sys.exc_info`. This refers to an exception that was *already caught*, " @@ -648,7 +680,7 @@ msgid "" "using :c:func:`PyErr_GetHandledException`." msgstr "" -#: ../../c-api/exceptions.rst:598 +#: ../../c-api/exceptions.rst:632 msgid "" "This function is not normally used by code that wants to handle exceptions. " "Rather, it can be used when code needs to save and restore the exception " @@ -656,7 +688,7 @@ msgid "" "exception state." msgstr "" -#: ../../c-api/exceptions.rst:608 +#: ../../c-api/exceptions.rst:642 msgid "" "Set the exception info, as known from ``sys.exc_info()``. This refers to an " "exception that was *already caught*, not to an exception that was freshly " @@ -666,7 +698,7 @@ msgid "" "`PyErr_SetHandledException`." msgstr "" -#: ../../c-api/exceptions.rst:617 +#: ../../c-api/exceptions.rst:651 msgid "" "This function is not normally used by code that wants to handle exceptions. " "Rather, it can be used when code needs to save and restore the exception " @@ -674,22 +706,22 @@ msgid "" "state." msgstr "" -#: ../../c-api/exceptions.rst:624 +#: ../../c-api/exceptions.rst:658 msgid "" "The ``type`` and ``traceback`` arguments are no longer used and can be NULL. " "The interpreter now derives them from the exception instance (the ``value`` " "argument). The function still steals references of all three arguments." msgstr "" -#: ../../c-api/exceptions.rst:632 +#: ../../c-api/exceptions.rst:666 msgid "Signal Handling" msgstr "訊號處理" -#: ../../c-api/exceptions.rst:642 +#: ../../c-api/exceptions.rst:676 msgid "This function interacts with Python's signal handling." msgstr "" -#: ../../c-api/exceptions.rst:644 +#: ../../c-api/exceptions.rst:678 msgid "" "If the function is called from the main thread and under the main Python " "interpreter, it checks whether a signal has been sent to the processes and " @@ -697,7 +729,7 @@ msgid "" "module is supported, this can invoke a signal handler written in Python." msgstr "" -#: ../../c-api/exceptions.rst:649 +#: ../../c-api/exceptions.rst:683 msgid "" "The function attempts to handle all pending signals, and then returns ``0``. " "However, if a Python signal handler raises an exception, the error indicator " @@ -706,44 +738,44 @@ msgid "" "`PyErr_CheckSignals()` invocation)." msgstr "" -#: ../../c-api/exceptions.rst:655 +#: ../../c-api/exceptions.rst:689 msgid "" "If the function is called from a non-main thread, or under a non-main Python " "interpreter, it does nothing and returns ``0``." msgstr "" -#: ../../c-api/exceptions.rst:658 +#: ../../c-api/exceptions.rst:692 msgid "" "This function can be called by long-running C code that wants to be " "interruptible by user requests (such as by pressing Ctrl-C)." msgstr "" -#: ../../c-api/exceptions.rst:662 +#: ../../c-api/exceptions.rst:696 msgid "" "The default Python signal handler for :c:macro:`!SIGINT` raises the :exc:" "`KeyboardInterrupt` exception." msgstr "" -#: ../../c-api/exceptions.rst:673 +#: ../../c-api/exceptions.rst:707 msgid "" "Simulate the effect of a :c:macro:`!SIGINT` signal arriving. This is " "equivalent to ``PyErr_SetInterruptEx(SIGINT)``." msgstr "" -#: ../../c-api/exceptions.rst:677 ../../c-api/exceptions.rst:704 +#: ../../c-api/exceptions.rst:711 ../../c-api/exceptions.rst:738 msgid "" -"This function is async-signal-safe. It can be called without the :term:" -"`GIL` and from a C signal handler." +"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:687 +#: ../../c-api/exceptions.rst:721 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:691 +#: ../../c-api/exceptions.rst:725 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 " @@ -751,27 +783,27 @@ msgid "" "interrupt an operation)." msgstr "" -#: ../../c-api/exceptions.rst:696 +#: ../../c-api/exceptions.rst:730 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:699 +#: ../../c-api/exceptions.rst:733 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:712 +#: ../../c-api/exceptions.rst:746 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:716 +#: ../../c-api/exceptions.rst:750 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 " @@ -779,15 +811,15 @@ msgid "" "be called from the main thread." msgstr "" -#: ../../c-api/exceptions.rst:721 +#: ../../c-api/exceptions.rst:755 msgid "On Windows, the function now also supports socket handles." msgstr "" -#: ../../c-api/exceptions.rst:726 +#: ../../c-api/exceptions.rst:760 msgid "Exception Classes" msgstr "例外類別" -#: ../../c-api/exceptions.rst:730 +#: ../../c-api/exceptions.rst:764 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 " @@ -796,7 +828,7 @@ msgid "" "(accessible in C as :c:data:`PyExc_Exception`)." msgstr "" -#: ../../c-api/exceptions.rst:736 +#: ../../c-api/exceptions.rst:770 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 " @@ -806,41 +838,51 @@ msgid "" "variables and methods." msgstr "" -#: ../../c-api/exceptions.rst:745 +#: ../../c-api/exceptions.rst:779 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:754 +#: ../../c-api/exceptions.rst:788 msgid "" "Return non-zero if *ob* is an exception class, zero otherwise. This function " "always succeeds." msgstr "" -#: ../../c-api/exceptions.rst:759 +#: ../../c-api/exceptions.rst:793 msgid "Return :c:member:`~PyTypeObject.tp_name` of the exception class *ob*." msgstr "回傳例外類別 *ob* 的 :c:member:`~PyTypeObject.tp_name`。" -#: ../../c-api/exceptions.rst:763 +#: ../../c-api/exceptions.rst:797 msgid "Exception Objects" msgstr "例外物件" -#: ../../c-api/exceptions.rst:767 +#: ../../c-api/exceptions.rst:801 +msgid "" +"Return true if *op* is an instance of :class:`BaseException`, false " +"otherwise. This function always succeeds." +msgstr "" + +#: ../../c-api/exceptions.rst:807 +msgid "Equivalent to :c:func:`Py_TYPE(op) `." +msgstr "" + +#: ../../c-api/exceptions.rst:812 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:775 +#: ../../c-api/exceptions.rst:820 msgid "" "Set the traceback associated with the exception to *tb*. Use ``Py_None`` to " "clear it." msgstr "" -#: ../../c-api/exceptions.rst:781 +#: ../../c-api/exceptions.rst:826 msgid "" "Return the context (another exception instance during whose handling *ex* " "was raised) associated with the exception as a new reference, as accessible " @@ -848,14 +890,14 @@ msgid "" "there is no context associated, this returns ``NULL``." msgstr "" -#: ../../c-api/exceptions.rst:789 +#: ../../c-api/exceptions.rst:834 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 steals a reference to *ctx*." msgstr "" -#: ../../c-api/exceptions.rst:796 +#: ../../c-api/exceptions.rst:841 msgid "" "Return the cause (either an exception instance, or ``None``, set by " "``raise ... from ...``) associated with the exception as a new reference, as " @@ -863,28 +905,28 @@ msgid "" "attribute." msgstr "" -#: ../../c-api/exceptions.rst:804 +#: ../../c-api/exceptions.rst:849 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 " "exception instance or ``None``. This steals a reference to *cause*." msgstr "" -#: ../../c-api/exceptions.rst:808 +#: ../../c-api/exceptions.rst:853 msgid "" "The :attr:`~BaseException.__suppress_context__` attribute is implicitly set " "to ``True`` by this function." msgstr "" -#: ../../c-api/exceptions.rst:814 +#: ../../c-api/exceptions.rst:859 msgid "Return :attr:`~BaseException.args` of exception *ex*." msgstr "回傳例外 *ex* 的 :attr:`~BaseException.args`。" -#: ../../c-api/exceptions.rst:819 +#: ../../c-api/exceptions.rst:864 msgid "Set :attr:`~BaseException.args` of exception *ex* to *args*." msgstr "設定例外 *ex* 的 :attr:`~BaseException.args` 為 *args*。" -#: ../../c-api/exceptions.rst:823 +#: ../../c-api/exceptions.rst:868 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 " @@ -896,72 +938,98 @@ msgid "" "if there is nothing to reraise." msgstr "" -#: ../../c-api/exceptions.rst:837 +#: ../../c-api/exceptions.rst:882 msgid "Unicode Exception Objects" msgstr "Unicode 例外物件" -#: ../../c-api/exceptions.rst:839 +#: ../../c-api/exceptions.rst:884 msgid "" "The following functions are used to create and modify Unicode exceptions " "from C." msgstr "" -#: ../../c-api/exceptions.rst:843 +#: ../../c-api/exceptions.rst:888 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:850 +#: ../../c-api/exceptions.rst:895 msgid "Return the *encoding* attribute of the given exception object." msgstr "" -#: ../../c-api/exceptions.rst:856 +#: ../../c-api/exceptions.rst:901 msgid "Return the *object* attribute of the given exception object." msgstr "" -#: ../../c-api/exceptions.rst:862 +#: ../../c-api/exceptions.rst:907 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:870 +#: ../../c-api/exceptions.rst:911 msgid "" -"Set the *start* attribute of the given exception object to *start*. Return " +"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:914 +msgid ":attr:`UnicodeError.start`" +msgstr ":attr:`UnicodeError.start`" + +#: ../../c-api/exceptions.rst:920 +msgid "" +"Set the *start* attribute of the given exception object to *start*. Return " "``0`` on success, ``-1`` on failure." msgstr "" -#: ../../c-api/exceptions.rst:877 +#: ../../c-api/exceptions.rst:925 +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:933 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:885 +#: ../../c-api/exceptions.rst:937 +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:944 msgid "" "Set the *end* attribute of the given exception object to *end*. Return " "``0`` on success, ``-1`` on failure." msgstr "" -#: ../../c-api/exceptions.rst:892 +#: ../../c-api/exceptions.rst:947 +msgid ":attr:`UnicodeError.end`" +msgstr ":attr:`UnicodeError.end`" + +#: ../../c-api/exceptions.rst:953 msgid "Return the *reason* attribute of the given exception object." msgstr "回傳給定例外物件的 *reason* 屬性。" -#: ../../c-api/exceptions.rst:898 +#: ../../c-api/exceptions.rst:959 msgid "" "Set the *reason* attribute of the given exception object to *reason*. " "Return ``0`` on success, ``-1`` on failure." msgstr "" -#: ../../c-api/exceptions.rst:905 +#: ../../c-api/exceptions.rst:966 msgid "Recursion Control" msgstr "遞迴控制" -#: ../../c-api/exceptions.rst:907 +#: ../../c-api/exceptions.rst:968 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 " @@ -971,44 +1039,41 @@ msgid "" "recursion handling." msgstr "" -#: ../../c-api/exceptions.rst:916 +#: ../../c-api/exceptions.rst:977 msgid "Marks a point where a recursive C-level call is about to be performed." msgstr "" -#: ../../c-api/exceptions.rst:918 -msgid "" -"If :c:macro:`!USE_STACKCHECK` is defined, this function checks if the OS " -"stack overflowed using :c:func:`PyOS_CheckStack`. If this is the case, it " -"sets a :exc:`MemoryError` and returns a nonzero value." -msgstr "" - -#: ../../c-api/exceptions.rst:922 +#: ../../c-api/exceptions.rst:979 msgid "" -"The function then checks if the recursion limit is reached. If this is the " +"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:926 +#: ../../c-api/exceptions.rst:983 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:930 ../../c-api/exceptions.rst:938 +#: ../../c-api/exceptions.rst:988 +msgid "The :c:func:`PyUnstable_ThreadState_SetStackProtection` function." +msgstr "" + +#: ../../c-api/exceptions.rst:990 ../../c-api/exceptions.rst:998 msgid "" "This function is now also available in the :ref:`limited API `." msgstr "" -#: ../../c-api/exceptions.rst:935 +#: ../../c-api/exceptions.rst:995 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:941 +#: ../../c-api/exceptions.rst:1001 msgid "" "Properly implementing :c:member:`~PyTypeObject.tp_repr` for container types " "requires special recursion handling. In addition to protecting the stack, :" @@ -1017,13 +1082,13 @@ msgid "" "Effectively, these are the C equivalent to :func:`reprlib.recursive_repr`." msgstr "" -#: ../../c-api/exceptions.rst:949 +#: ../../c-api/exceptions.rst:1009 msgid "" "Called at the beginning of the :c:member:`~PyTypeObject.tp_repr` " "implementation to detect cycles." msgstr "" -#: ../../c-api/exceptions.rst:952 +#: ../../c-api/exceptions.rst:1012 msgid "" "If the object has already been processed, the function returns a positive " "integer. In that case the :c:member:`~PyTypeObject.tp_repr` implementation " @@ -1031,276 +1096,301 @@ msgid "" "`dict` objects return ``{...}`` and :class:`list` objects return ``[...]``." msgstr "" -#: ../../c-api/exceptions.rst:958 +#: ../../c-api/exceptions.rst:1018 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:962 +#: ../../c-api/exceptions.rst:1022 msgid "" "Otherwise, the function returns zero and the :c:member:`~PyTypeObject." "tp_repr` implementation can continue normally." msgstr "" -#: ../../c-api/exceptions.rst:967 +#: ../../c-api/exceptions.rst:1027 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:974 +#: ../../c-api/exceptions.rst:1032 +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:1036 ../../c-api/exceptions.rst:1046 +msgid "" +"This function cannot fail, and the caller must hold an :term:`attached " +"thread state`." +msgstr "" + +#: ../../c-api/exceptions.rst:1040 +msgid ":py:func:`sys.getrecursionlimit`" +msgstr ":py:func:`sys.getrecursionlimit`" + +#: ../../c-api/exceptions.rst:1044 +msgid "Set the recursion limit for the current interpreter." +msgstr "" + +#: ../../c-api/exceptions.rst:1050 +msgid ":py:func:`sys.setrecursionlimit`" +msgstr ":py:func:`sys.setrecursionlimit`" + +#: ../../c-api/exceptions.rst:1055 msgid "Exception and warning types" msgstr "例外和警告型別" -#: ../../c-api/exceptions.rst:976 +#: ../../c-api/exceptions.rst:1057 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:980 +#: ../../c-api/exceptions.rst:1061 msgid "For completeness, here are all the variables:" msgstr "" -#: ../../c-api/exceptions.rst:983 +#: ../../c-api/exceptions.rst:1064 msgid "Exception types" msgstr "例外型別" -#: ../../c-api/exceptions.rst:990 ../../c-api/exceptions.rst:1136 -#: ../../c-api/exceptions.rst:1166 +#: ../../c-api/exceptions.rst:1071 ../../c-api/exceptions.rst:1217 +#: ../../c-api/exceptions.rst:1247 msgid "C name" msgstr "C 名稱" -#: ../../c-api/exceptions.rst:991 ../../c-api/exceptions.rst:1137 -#: ../../c-api/exceptions.rst:1167 +#: ../../c-api/exceptions.rst:1072 ../../c-api/exceptions.rst:1218 +#: ../../c-api/exceptions.rst:1248 msgid "Python name" msgstr "Python 名稱" -#: ../../c-api/exceptions.rst:993 +#: ../../c-api/exceptions.rst:1074 msgid ":exc:`BaseException`" msgstr ":exc:`BaseException`" -#: ../../c-api/exceptions.rst:995 +#: ../../c-api/exceptions.rst:1076 msgid ":exc:`BaseExceptionGroup`" msgstr ":exc:`BaseExceptionGroup`" -#: ../../c-api/exceptions.rst:997 +#: ../../c-api/exceptions.rst:1078 msgid ":exc:`Exception`" msgstr ":exc:`Exception`" -#: ../../c-api/exceptions.rst:999 +#: ../../c-api/exceptions.rst:1080 msgid ":exc:`ArithmeticError`" msgstr ":exc:`ArithmeticError`" -#: ../../c-api/exceptions.rst:1001 +#: ../../c-api/exceptions.rst:1082 msgid ":exc:`AssertionError`" msgstr ":exc:`AssertionError`" -#: ../../c-api/exceptions.rst:1003 +#: ../../c-api/exceptions.rst:1084 msgid ":exc:`AttributeError`" msgstr ":exc:`AttributeError`" -#: ../../c-api/exceptions.rst:1005 +#: ../../c-api/exceptions.rst:1086 msgid ":exc:`BlockingIOError`" msgstr ":exc:`BlockingIOError`" -#: ../../c-api/exceptions.rst:1007 +#: ../../c-api/exceptions.rst:1088 msgid ":exc:`BrokenPipeError`" msgstr ":exc:`BrokenPipeError`" -#: ../../c-api/exceptions.rst:1009 +#: ../../c-api/exceptions.rst:1090 msgid ":exc:`BufferError`" msgstr ":exc:`BufferError`" -#: ../../c-api/exceptions.rst:1011 +#: ../../c-api/exceptions.rst:1092 msgid ":exc:`ChildProcessError`" msgstr ":exc:`ChildProcessError`" -#: ../../c-api/exceptions.rst:1013 +#: ../../c-api/exceptions.rst:1094 msgid ":exc:`ConnectionAbortedError`" msgstr ":exc:`ConnectionAbortedError`" -#: ../../c-api/exceptions.rst:1015 +#: ../../c-api/exceptions.rst:1096 msgid ":exc:`ConnectionError`" msgstr ":exc:`ConnectionError`" -#: ../../c-api/exceptions.rst:1017 +#: ../../c-api/exceptions.rst:1098 msgid ":exc:`ConnectionRefusedError`" msgstr ":exc:`ConnectionRefusedError`" -#: ../../c-api/exceptions.rst:1019 +#: ../../c-api/exceptions.rst:1100 msgid ":exc:`ConnectionResetError`" msgstr ":exc:`ConnectionResetError`" -#: ../../c-api/exceptions.rst:1021 +#: ../../c-api/exceptions.rst:1102 msgid ":exc:`EOFError`" msgstr ":exc:`EOFError`" -#: ../../c-api/exceptions.rst:1023 +#: ../../c-api/exceptions.rst:1104 msgid ":exc:`FileExistsError`" msgstr ":exc:`FileExistsError`" -#: ../../c-api/exceptions.rst:1025 +#: ../../c-api/exceptions.rst:1106 msgid ":exc:`FileNotFoundError`" msgstr ":exc:`FileNotFoundError`" -#: ../../c-api/exceptions.rst:1027 +#: ../../c-api/exceptions.rst:1108 msgid ":exc:`FloatingPointError`" msgstr ":exc:`FloatingPointError`" -#: ../../c-api/exceptions.rst:1029 +#: ../../c-api/exceptions.rst:1110 msgid ":exc:`GeneratorExit`" msgstr ":exc:`GeneratorExit`" -#: ../../c-api/exceptions.rst:1031 +#: ../../c-api/exceptions.rst:1112 msgid ":exc:`ImportError`" msgstr ":exc:`ImportError`" -#: ../../c-api/exceptions.rst:1033 +#: ../../c-api/exceptions.rst:1114 msgid ":exc:`IndentationError`" msgstr ":exc:`IndentationError`" -#: ../../c-api/exceptions.rst:1035 +#: ../../c-api/exceptions.rst:1116 msgid ":exc:`IndexError`" msgstr ":exc:`IndexError`" -#: ../../c-api/exceptions.rst:1037 +#: ../../c-api/exceptions.rst:1118 msgid ":exc:`InterruptedError`" msgstr ":exc:`InterruptedError`" -#: ../../c-api/exceptions.rst:1039 +#: ../../c-api/exceptions.rst:1120 msgid ":exc:`IsADirectoryError`" msgstr ":exc:`IsADirectoryError`" -#: ../../c-api/exceptions.rst:1041 +#: ../../c-api/exceptions.rst:1122 msgid ":exc:`KeyError`" msgstr ":exc:`KeyError`" -#: ../../c-api/exceptions.rst:1043 +#: ../../c-api/exceptions.rst:1124 msgid ":exc:`KeyboardInterrupt`" msgstr ":exc:`KeyboardInterrupt`" -#: ../../c-api/exceptions.rst:1045 +#: ../../c-api/exceptions.rst:1126 msgid ":exc:`LookupError`" msgstr ":exc:`LookupError`" -#: ../../c-api/exceptions.rst:1047 +#: ../../c-api/exceptions.rst:1128 msgid ":exc:`MemoryError`" msgstr ":exc:`MemoryError`" -#: ../../c-api/exceptions.rst:1049 +#: ../../c-api/exceptions.rst:1130 msgid ":exc:`ModuleNotFoundError`" msgstr ":exc:`ModuleNotFoundError`" -#: ../../c-api/exceptions.rst:1051 +#: ../../c-api/exceptions.rst:1132 msgid ":exc:`NameError`" msgstr ":exc:`NameError`" -#: ../../c-api/exceptions.rst:1053 +#: ../../c-api/exceptions.rst:1134 msgid ":exc:`NotADirectoryError`" msgstr ":exc:`NotADirectoryError`" -#: ../../c-api/exceptions.rst:1055 +#: ../../c-api/exceptions.rst:1136 msgid ":exc:`NotImplementedError`" msgstr ":exc:`NotImplementedError`" -#: ../../c-api/exceptions.rst:1057 ../../c-api/exceptions.rst:1140 -#: ../../c-api/exceptions.rst:1143 ../../c-api/exceptions.rst:1146 +#: ../../c-api/exceptions.rst:1138 ../../c-api/exceptions.rst:1221 +#: ../../c-api/exceptions.rst:1224 ../../c-api/exceptions.rst:1227 msgid ":exc:`OSError`" msgstr ":exc:`OSError`" -#: ../../c-api/exceptions.rst:1059 +#: ../../c-api/exceptions.rst:1140 msgid ":exc:`OverflowError`" msgstr ":exc:`OverflowError`" -#: ../../c-api/exceptions.rst:1061 +#: ../../c-api/exceptions.rst:1142 msgid ":exc:`PermissionError`" msgstr ":exc:`PermissionError`" -#: ../../c-api/exceptions.rst:1063 +#: ../../c-api/exceptions.rst:1144 msgid ":exc:`ProcessLookupError`" msgstr ":exc:`ProcessLookupError`" -#: ../../c-api/exceptions.rst:1065 +#: ../../c-api/exceptions.rst:1146 msgid ":exc:`PythonFinalizationError`" msgstr ":exc:`PythonFinalizationError`" -#: ../../c-api/exceptions.rst:1067 +#: ../../c-api/exceptions.rst:1148 msgid ":exc:`RecursionError`" msgstr ":exc:`RecursionError`" -#: ../../c-api/exceptions.rst:1069 +#: ../../c-api/exceptions.rst:1150 msgid ":exc:`ReferenceError`" msgstr ":exc:`ReferenceError`" -#: ../../c-api/exceptions.rst:1071 +#: ../../c-api/exceptions.rst:1152 msgid ":exc:`RuntimeError`" msgstr ":exc:`RuntimeError`" -#: ../../c-api/exceptions.rst:1073 +#: ../../c-api/exceptions.rst:1154 msgid ":exc:`StopAsyncIteration`" msgstr ":exc:`StopAsyncIteration`" -#: ../../c-api/exceptions.rst:1075 +#: ../../c-api/exceptions.rst:1156 msgid ":exc:`StopIteration`" msgstr ":exc:`StopIteration`" -#: ../../c-api/exceptions.rst:1077 +#: ../../c-api/exceptions.rst:1158 msgid ":exc:`SyntaxError`" msgstr ":exc:`SyntaxError`" -#: ../../c-api/exceptions.rst:1079 +#: ../../c-api/exceptions.rst:1160 msgid ":exc:`SystemError`" msgstr ":exc:`SystemError`" -#: ../../c-api/exceptions.rst:1081 +#: ../../c-api/exceptions.rst:1162 msgid ":exc:`SystemExit`" msgstr ":exc:`SystemExit`" -#: ../../c-api/exceptions.rst:1083 +#: ../../c-api/exceptions.rst:1164 msgid ":exc:`TabError`" msgstr ":exc:`TabError`" -#: ../../c-api/exceptions.rst:1085 +#: ../../c-api/exceptions.rst:1166 msgid ":exc:`TimeoutError`" msgstr ":exc:`TimeoutError`" -#: ../../c-api/exceptions.rst:1087 +#: ../../c-api/exceptions.rst:1168 msgid ":exc:`TypeError`" msgstr ":exc:`TypeError`" -#: ../../c-api/exceptions.rst:1089 +#: ../../c-api/exceptions.rst:1170 msgid ":exc:`UnboundLocalError`" msgstr ":exc:`UnboundLocalError`" -#: ../../c-api/exceptions.rst:1091 +#: ../../c-api/exceptions.rst:1172 msgid ":exc:`UnicodeDecodeError`" msgstr ":exc:`UnicodeDecodeError`" -#: ../../c-api/exceptions.rst:1093 +#: ../../c-api/exceptions.rst:1174 msgid ":exc:`UnicodeEncodeError`" msgstr ":exc:`UnicodeEncodeError`" -#: ../../c-api/exceptions.rst:1095 +#: ../../c-api/exceptions.rst:1176 msgid ":exc:`UnicodeError`" msgstr ":exc:`UnicodeError`" -#: ../../c-api/exceptions.rst:1097 +#: ../../c-api/exceptions.rst:1178 msgid ":exc:`UnicodeTranslateError`" msgstr ":exc:`UnicodeTranslateError`" -#: ../../c-api/exceptions.rst:1099 +#: ../../c-api/exceptions.rst:1180 msgid ":exc:`ValueError`" msgstr ":exc:`ValueError`" -#: ../../c-api/exceptions.rst:1101 +#: ../../c-api/exceptions.rst:1182 msgid ":exc:`ZeroDivisionError`" msgstr ":exc:`ZeroDivisionError`" -#: ../../c-api/exceptions.rst:1103 +#: ../../c-api/exceptions.rst:1184 msgid "" ":c:data:`PyExc_BlockingIOError`, :c:data:`PyExc_BrokenPipeError`, :c:data:" "`PyExc_ChildProcessError`, :c:data:`PyExc_ConnectionError`, :c:data:" @@ -1320,127 +1410,166 @@ msgstr "" "`PyExc_PermissionError`, :c:data:`PyExc_ProcessLookupError` 和 :c:data:" "`PyExc_TimeoutError` 是在 :pep:`3151` 被引入。" -#: ../../c-api/exceptions.rst:1113 +#: ../../c-api/exceptions.rst:1194 msgid ":c:data:`PyExc_StopAsyncIteration` and :c:data:`PyExc_RecursionError`." msgstr ":c:data:`PyExc_StopAsyncIteration` 和 :c:data:`PyExc_RecursionError`。" -#: ../../c-api/exceptions.rst:1116 +#: ../../c-api/exceptions.rst:1197 msgid ":c:data:`PyExc_ModuleNotFoundError`." msgstr ":c:data:`PyExc_ModuleNotFoundError`。" -#: ../../c-api/exceptions.rst:1119 +#: ../../c-api/exceptions.rst:1200 msgid ":c:data:`PyExc_BaseExceptionGroup`." msgstr ":c:data:`PyExc_BaseExceptionGroup`" -#: ../../c-api/exceptions.rst:1124 +#: ../../c-api/exceptions.rst:1205 msgid "OSError aliases" msgstr "OSError 別名" -#: ../../c-api/exceptions.rst:1126 +#: ../../c-api/exceptions.rst:1207 msgid "The following are a compatibility aliases to :c:data:`PyExc_OSError`." msgstr "" -#: ../../c-api/exceptions.rst:1128 +#: ../../c-api/exceptions.rst:1209 msgid "These aliases used to be separate exception types." msgstr "" -#: ../../c-api/exceptions.rst:1138 +#: ../../c-api/exceptions.rst:1219 msgid "Notes" msgstr "註解" -#: ../../c-api/exceptions.rst:1147 +#: ../../c-api/exceptions.rst:1228 msgid "[win]_" msgstr "[win]_" -#: ../../c-api/exceptions.rst:1149 +#: ../../c-api/exceptions.rst:1230 msgid "Notes:" msgstr "註解:" -#: ../../c-api/exceptions.rst:1152 +#: ../../c-api/exceptions.rst:1233 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:1159 +#: ../../c-api/exceptions.rst:1240 msgid "Warning types" msgstr "警告型別" -#: ../../c-api/exceptions.rst:1169 +#: ../../c-api/exceptions.rst:1250 msgid ":exc:`Warning`" msgstr ":exc:`Warning`" -#: ../../c-api/exceptions.rst:1171 +#: ../../c-api/exceptions.rst:1252 msgid ":exc:`BytesWarning`" msgstr ":exc:`BytesWarning`" -#: ../../c-api/exceptions.rst:1173 +#: ../../c-api/exceptions.rst:1254 msgid ":exc:`DeprecationWarning`" msgstr ":exc:`DeprecationWarning`" -#: ../../c-api/exceptions.rst:1175 +#: ../../c-api/exceptions.rst:1256 msgid ":exc:`EncodingWarning`" msgstr ":exc:`EncodingWarning`" -#: ../../c-api/exceptions.rst:1177 +#: ../../c-api/exceptions.rst:1258 msgid ":exc:`FutureWarning`" msgstr ":exc:`FutureWarning`" -#: ../../c-api/exceptions.rst:1179 +#: ../../c-api/exceptions.rst:1260 msgid ":exc:`ImportWarning`" msgstr ":exc:`ImportWarning`" -#: ../../c-api/exceptions.rst:1181 +#: ../../c-api/exceptions.rst:1262 msgid ":exc:`PendingDeprecationWarning`" msgstr ":exc:`PendingDeprecationWarning`" -#: ../../c-api/exceptions.rst:1183 +#: ../../c-api/exceptions.rst:1264 msgid ":exc:`ResourceWarning`" msgstr ":exc:`ResourceWarning`" -#: ../../c-api/exceptions.rst:1185 +#: ../../c-api/exceptions.rst:1266 msgid ":exc:`RuntimeWarning`" msgstr ":exc:`RuntimeWarning`" -#: ../../c-api/exceptions.rst:1187 +#: ../../c-api/exceptions.rst:1268 msgid ":exc:`SyntaxWarning`" msgstr ":exc:`SyntaxWarning`" -#: ../../c-api/exceptions.rst:1189 +#: ../../c-api/exceptions.rst:1270 msgid ":exc:`UnicodeWarning`" msgstr ":exc:`UnicodeWarning`" -#: ../../c-api/exceptions.rst:1191 +#: ../../c-api/exceptions.rst:1272 msgid ":exc:`UserWarning`" msgstr ":exc:`UserWarning`" -#: ../../c-api/exceptions.rst:1193 +#: ../../c-api/exceptions.rst:1274 msgid ":c:data:`PyExc_ResourceWarning`." msgstr ":c:data:`PyExc_ResourceWarning`。" -#: ../../c-api/exceptions.rst:1196 +#: ../../c-api/exceptions.rst:1277 msgid ":c:data:`PyExc_EncodingWarning`." msgstr ":c:data:`PyExc_EncodingWarning`。" +#: ../../c-api/exceptions.rst:1282 +msgid "Tracebacks" +msgstr "" + +#: ../../c-api/exceptions.rst:1286 +msgid "" +"Type object for traceback objects. This is available as :class:`types." +"TracebackType` in the Python layer." +msgstr "" + +#: ../../c-api/exceptions.rst:1292 +msgid "" +"Return true if *op* is a traceback object, false otherwise. This function " +"does not account for subtypes." +msgstr "" + +#: ../../c-api/exceptions.rst:1298 +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:1301 +msgid "Calling this function without an exception set is undefined behavior." +msgstr "" + +#: ../../c-api/exceptions.rst:1303 ../../c-api/exceptions.rst:1311 +msgid "" +"This function returns ``0`` on success, and returns ``-1`` with an exception " +"set on failure." +msgstr "" + +#: ../../c-api/exceptions.rst:1309 +msgid "Write the traceback *tb* into the file *f*." +msgstr "" + #: ../../c-api/exceptions.rst:183 msgid "strerror (C function)" msgstr "strerror(C 函式)" -#: ../../c-api/exceptions.rst:637 ../../c-api/exceptions.rst:668 -#: ../../c-api/exceptions.rst:683 +#: ../../c-api/exceptions.rst:671 ../../c-api/exceptions.rst:702 +#: ../../c-api/exceptions.rst:717 msgid "module" msgstr "module(模組)" -#: ../../c-api/exceptions.rst:637 ../../c-api/exceptions.rst:668 -#: ../../c-api/exceptions.rst:683 +#: ../../c-api/exceptions.rst:671 ../../c-api/exceptions.rst:702 +#: ../../c-api/exceptions.rst:717 msgid "signal" msgstr "signal(訊號)" -#: ../../c-api/exceptions.rst:637 ../../c-api/exceptions.rst:668 +#: ../../c-api/exceptions.rst:671 ../../c-api/exceptions.rst:702 msgid "SIGINT (C macro)" msgstr "SIGINT(C 巨集)" -#: ../../c-api/exceptions.rst:637 ../../c-api/exceptions.rst:668 -#: ../../c-api/exceptions.rst:683 +#: ../../c-api/exceptions.rst:671 ../../c-api/exceptions.rst:702 +#: ../../c-api/exceptions.rst:717 msgid "KeyboardInterrupt (built-in exception)" msgstr "KeyboardInterrupt(內建例外)" + +#~ msgid "The caller must hold the GIL." +#~ msgstr "呼叫者必須持有 GIL。" diff --git a/c-api/extension-modules.po b/c-api/extension-modules.po new file mode 100644 index 00000000000..b93feceed8f --- /dev/null +++ b/c-api/extension-modules.po @@ -0,0 +1,384 @@ +# 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.14\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-09-08 15:25+0800\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/extension-modules.rst:6 +msgid "Defining extension modules" +msgstr "" + +#: ../../c-api/extension-modules.rst:8 +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 `." +msgstr "" + +#: ../../c-api/extension-modules.rst:13 +msgid "" +"To be importable by default (that is, " +"by :py:class:`importlib.machinery.ExtensionFileLoader`), the shared library " +"must be available on :py:attr:`sys.path`, and must be named after the module " +"name plus an extension listed " +"in :py:attr:`importlib.machinery.EXTENSION_SUFFIXES`." +msgstr "" + +#: ../../c-api/extension-modules.rst:21 +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 " +"is Setuptools, whose documentation can be found at https://" +"setuptools.pypa.io/en/latest/setuptools.html." +msgstr "" + +#: ../../c-api/extension-modules.rst:26 +msgid "" +"Normally, the initialization function returns a module definition " +"initialized using :c:func:`PyModuleDef_Init`. This allows splitting the " +"creation process into several phases:" +msgstr "" + +#: ../../c-api/extension-modules.rst:30 +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." +msgstr "" + +#: ../../c-api/extension-modules.rst:33 +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__`." +msgstr "" + +#: ../../c-api/extension-modules.rst:37 +msgid "" +"Afterwards, the module object is initialized using extension-specific code " +"-- the equivalent of :py:meth:`~object.__init__` on classes." +msgstr "" + +#: ../../c-api/extension-modules.rst:40 +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." +msgstr "" + +#: ../../c-api/extension-modules.rst:48 +msgid "Added support for multi-phase initialization (:pep:`489`)." +msgstr "" + +#: ../../c-api/extension-modules.rst:52 +msgid "Multiple module instances" +msgstr "" + +#: ../../c-api/extension-modules.rst:54 +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 " +"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 +msgid "" +"Additional module instances may be created in :ref:`sub-interpreters ` or after Python runtime reinitialization " +"(:c:func:`Py_Finalize` and :c:func:`Py_Initialize`). In these cases, sharing " +"Python objects between module instances would likely cause crashes or " +"undefined behavior." +msgstr "" + +#: ../../c-api/extension-modules.rst:68 +msgid "" +"To avoid such issues, each instance of an extension module should be " +"*isolated*: changes to one instance should not implicitly affect the others, " +"and all state owned by the module, including references to Python objects, " +"should be specific to a particular module instance. See :ref:`isolating-" +"extensions-howto` for more details and a practical guide." +msgstr "" + +#: ../../c-api/extension-modules.rst:74 +msgid "" +"A simpler way to avoid these issues is :ref:`raising an error on repeated " +"initialization `." +msgstr "" + +#: ../../c-api/extension-modules.rst:77 +msgid "" +"All modules are expected to support :ref:`sub-interpreters `, or otherwise explicitly signal a lack of support. This is usually " +"achieved by isolation or blocking repeated initialization, as above. A " +"module may also be limited to the main interpreter using " +"the :c:data:`Py_mod_multiple_interpreters` slot." +msgstr "" + +#: ../../c-api/extension-modules.rst:89 +msgid "Initialization function" +msgstr "" + +#: ../../c-api/extension-modules.rst:91 +msgid "" +"The initialization function defined by an extension module has the following " +"signature:" +msgstr "" + +#: ../../c-api/extension-modules.rst:96 +msgid "" +"Its name should be :samp:`PyInit_{}`, with ```` replaced by the " +"name of the module." +msgstr "" + +#: ../../c-api/extension-modules.rst:99 +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:" +msgstr "" + +#: ../../c-api/extension-modules.rst:106 +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" +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 +msgid "" +"It is recommended to define the initialization function using a helper macro:" +msgstr "" + +#: ../../c-api/extension-modules.rst:119 +msgid "Declare an extension module initialization function. This macro:" +msgstr "" + +#: ../../c-api/extension-modules.rst:122 +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" +msgstr "" + +#: ../../c-api/extension-modules.rst:124 +msgid "for C++, declares the function as ``extern \"C\"``." +msgstr "" + +#: ../../c-api/extension-modules.rst:126 +msgid "For example, a module called ``spam`` would be defined like this::" +msgstr "" + +#: ../../c-api/extension-modules.rst:128 +msgid "" +"static struct PyModuleDef spam_module = {\n" +" .m_base = PyModuleDef_HEAD_INIT,\n" +" .m_name = \"spam\",\n" +" ...\n" +"};\n" +"\n" +"PyMODINIT_FUNC\n" +"PyInit_spam(void)\n" +"{\n" +" return PyModuleDef_Init(&spam_module);\n" +"}" +msgstr "" +"static struct PyModuleDef spam_module = {\n" +" .m_base = PyModuleDef_HEAD_INIT,\n" +" .m_name = \"spam\",\n" +" ...\n" +"};\n" +"\n" +"PyMODINIT_FUNC\n" +"PyInit_spam(void)\n" +"{\n" +" 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 +msgid "Legacy single-phase initialization" +msgstr "" + +#: ../../c-api/extension-modules.rst:187 +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 +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`." +msgstr "" + +#: ../../c-api/extension-modules.rst:197 +msgid "" +"Single-phase initialization differs from the :ref:`default ` in the following ways:" +msgstr "" + +#: ../../c-api/extension-modules.rst:200 +msgid "Single-phase modules are, or rather *contain*, “singletons”." +msgstr "" + +#: ../../c-api/extension-modules.rst:202 +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 +msgid "" +"For subsequent imports, Python does not call the initialization function " +"again. Instead, it creates a new module object with a new ``__dict__``, and " +"copies the saved contents to it. For example, given a single-phase module " +"``_testsinglephase`` [#testsinglephase]_ that defines a function ``sum`` and " +"an exception class ``error``:" +msgstr "" + +#: ../../c-api/extension-modules.rst:214 +msgid "" +">>> import sys\n" +">>> import _testsinglephase as one\n" +">>> del sys.modules['_testsinglephase']\n" +">>> import _testsinglephase as two\n" +">>> one is two\n" +"False\n" +">>> one.__dict__ is two.__dict__\n" +"False\n" +">>> one.sum is two.sum\n" +"True\n" +">>> one.error is two.error\n" +"True" +msgstr "" +">>> import sys\n" +">>> import _testsinglephase as one\n" +">>> del sys.modules['_testsinglephase']\n" +">>> import _testsinglephase as two\n" +">>> one is two\n" +"False\n" +">>> one.__dict__ is two.__dict__\n" +"False\n" +">>> one.sum is two.sum\n" +"True\n" +">>> one.error is two.error\n" +"True" + +#: ../../c-api/extension-modules.rst:229 +msgid "" +"The exact behavior should be considered a CPython implementation detail." +msgstr "" + +#: ../../c-api/extension-modules.rst:231 +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 " +"first suitable module created during the ``PyInit_modulename`` call. " +"Specifically, when a sub-module is imported, this mechanism prepends the " +"parent package name to the name of the module." +msgstr "" + +#: ../../c-api/extension-modules.rst:237 +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 +msgid "Non-ASCII module names (``PyInitU_modulename``) are not supported." +msgstr "" + +#: ../../c-api/extension-modules.rst:242 +msgid "" +"Single-phase modules support module lookup functions " +"like :c:func:`PyState_FindModule`." +msgstr "" + +#: ../../c-api/extension-modules.rst:245 +msgid "" +"``_testsinglephase`` is an internal module used in CPython's self-test " +"suite; your installation may or may not include it." +msgstr "" diff --git a/c-api/file.po b/c-api/file.po index cb40f45c722..053ac91f7a3 100644 --- a/c-api/file.po +++ b/c-api/file.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2023, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -7,9 +7,9 @@ # Matt Wang , 2022 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-11-12 00:16+0000\n" "PO-Revision-Date: 2023-04-24 20:38+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -43,7 +43,6 @@ msgstr "" "錯誤報告;建議第三方程式碼改為存取 :mod:`io` API。" #: ../../c-api/file.rst:22 -#, fuzzy msgid "" "Create a Python file object from the file descriptor of an already opened " "file *fd*. The arguments *name*, *encoding*, *errors* and *newline* can be " @@ -83,7 +82,6 @@ msgstr "" "須回傳一個整數,它作為檔案描述器值回傳。設定例外並在失敗時回傳 ``-1``。" #: ../../c-api/file.rst:52 -#, fuzzy msgid "" "Equivalent to ``p.readline([n])``, this function reads one line from the " "object *p*. *p* may be a file object or any object with a :meth:`~io.IOBase." @@ -95,12 +93,12 @@ msgid "" "regardless of length, but :exc:`EOFError` is raised if the end of the file " "is reached immediately." msgstr "" -"相當於 ``p.readline([n])``,這個函式從物件 *p* 中讀取一行。 *p* 可以是檔案對" -"像或任何具有 :meth:`~io.IOBase.readline` 方法的物件。如果 *n* 為 ``0``,則只" -"讀取一行,而不管該行的長度。如果 *n* 大於 ``0``,則不會從檔案中讀取超過 *n* " -"個位元組;可以回傳部分行。在這兩種情況下,如果立即到達檔案末尾,則回傳一個空" -"字串。但是,如果 *n* 小於 ``0``,無論長度如何,都會讀取一行,但如果立即到達檔" -"案末尾,則會引發 :exc:`EOFError`。" +"相當於 ``p.readline([n])``,這個函式從物件 *p* 中讀取一行。 *p* 可以是檔案物" +"件或任何具有 :meth:`~io.IOBase.readline` 方法的物件。如果 *n* 為 ``0``,則不" +"管該行的長度都只會讀取一行。如果 *n* 大於 ``0``,則不會從檔案中讀取超過 *n* " +"個位元組;可以回傳該行的一部分。在這兩種情況下,如果立即到達檔案末尾,則回傳" +"一個空字串。但是,如果 *n* 小於 ``0``,無論長度如何,都會讀取一行,但如果立即" +"到達檔案末尾,則會引發 :exc:`EOFError`。" #: ../../c-api/file.rst:65 msgid "" @@ -112,16 +110,15 @@ msgstr "" #: ../../c-api/file.rst:68 msgid "The *handler* is a function of type:" -msgstr "" +msgstr "*handler* 是以下類型的函式:" #: ../../c-api/file.rst:73 -#, fuzzy msgid "" "Equivalent of :c:expr:`PyObject *(\\*)(PyObject *path, void *userData)`, " "where *path* is guaranteed to be :c:type:`PyUnicodeObject`." msgstr "" -"處理程式是 :c:expr:`PyObject *(\\*)(PyObject *path, void *userData)` 型別的函" -"式,其中 *path* 保證為 :c:type:`PyUnicodeObject`。" +"相當於 :c:expr:`PyObject *(\\*)(PyObject *path, void *userData)`,其中 " +"*path* 保證為 :c:type:`PyUnicodeObject`。" #: ../../c-api/file.rst:77 msgid "" @@ -142,15 +139,14 @@ msgstr "" "它們已知有被凍結或在 ``sys.modules`` 中可用。" #: ../../c-api/file.rst:85 -#, fuzzy msgid "" "Once a hook has been set, it cannot be removed or replaced, and later calls " "to :c:func:`PyFile_SetOpenCodeHook` will fail. On failure, the function " "returns -1 and sets an exception if the interpreter has been initialized." msgstr "" -"一旦設定了一個掛鉤函式,它就不能被刪除或替換,以後呼叫 :c:func:" -"`PyFile_SetOpenCodeHook` 將失敗。失敗時,函式回傳 -1 並在直譯器已初始化時設定" -"例外。" +"一旦設定了一個掛鉤函式,它就不能被刪除或替換,且後續對 :c:func:" +"`PyFile_SetOpenCodeHook` 的呼叫將會失敗。失敗時,函式回傳 -1 且若直譯器已初始" +"化便會設定例外。" #: ../../c-api/file.rst:89 msgid "This function is safe to call before :c:func:`Py_Initialize`." @@ -164,7 +160,35 @@ msgstr "" "不帶引數地引發一個\\ :ref:`稽核事件 (auditing event) ` " "``setopencodehook``。" -#: ../../c-api/file.rst:101 +#: ../../c-api/file.rst:98 +msgid "" +"Open *path* with the mode ``'rb'``. *path* must be a Python :class:`str` " +"object. The behavior of this function may be overridden by :c:func:" +"`PyFile_SetOpenCodeHook` to allow for some preprocessing of the text." +msgstr "" +"以模式 ``'rb'`` 開啟 *path*。*path* 必須是 Python :class:`str` 物件。此函式的" +"行為可能會被 :c:func:`PyFile_SetOpenCodeHook` 覆蓋,以允許對文字進行某些預處理。" + +#: ../../c-api/file.rst:103 +msgid "This is analogous to :func:`io.open_code` in Python." +msgstr "這類似於 Python 中的 :func:`io.open_code`。" + +#: ../../c-api/file.rst:105 +msgid "" +"On success, this function returns a :term:`strong reference` to a Python " +"file object. On failure, this function returns ``NULL`` with an exception " +"set." +msgstr "" +"成功時,此函式回傳對 Python 檔案物件的 :term:`strong reference`。失敗時,回傳 ``NULL`` 並設定例外。" + +#: ../../c-api/file.rst:114 +msgid "" +"Similar to :c:func:`PyFile_OpenCodeObject`, but *path* is a UTF-8 encoded :c:" +"expr:`const char*`." +msgstr "" +"類似於 :c:func:`PyFile_OpenCodeObject`,但 *path* 是 UTF-8 編碼的 :c:expr:`const char*`。" + +#: ../../c-api/file.rst:124 msgid "" "Write object *obj* to file object *p*. The only supported flag for *flags* " "is :c:macro:`Py_PRINT_RAW`; if given, the :func:`str` of the object is " @@ -175,7 +199,7 @@ msgstr "" "`Py_PRINT_RAW`;如果有給定,則寫入物件的 :func:`str` 而不是 :func:`repr`。在" "成功回傳 ``0`` 或在失敗回傳 ``-1``;將設定適當的例外。" -#: ../../c-api/file.rst:109 +#: ../../c-api/file.rst:132 msgid "" "Write string *s* to file object *p*. Return ``0`` on success or ``-1`` on " "failure; the appropriate exception will be set." @@ -195,6 +219,6 @@ msgstr "file(檔案)" msgid "EOFError (built-in exception)" msgstr "EOFError(內建例外)" -#: ../../c-api/file.rst:99 +#: ../../c-api/file.rst:122 msgid "Py_PRINT_RAW (C macro)" msgstr "Py_PRINT_RAW(C 巨集)" diff --git a/c-api/float.po b/c-api/float.po index 3c2eff7ff26..d0f41f7aeed 100644 --- a/c-api/float.po +++ b/c-api/float.po @@ -1,17 +1,17 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Ching-Lung Chuang, 2015 # Liang-Bo Wang , 2015 +# Matt Wang , 2025 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-07-20 00:03+0000\n" -"PO-Revision-Date: 2017-09-22 18:26+0000\n" -"Last-Translator: Liang-Bo Wang \n" +"POT-Creation-Date: 2025-11-19 00:14+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-" "tw)\n" "Language: zh_TW\n" @@ -27,36 +27,45 @@ msgstr "浮點數(Floating-Point)物件" #: ../../c-api/float.rst:13 msgid "" "This subtype of :c:type:`PyObject` represents a Python floating-point object." -msgstr "" +msgstr "這個 :c:type:`PyObject` 的子型別代表一個 Python 浮點數物件。" #: ../../c-api/float.rst:18 msgid "" "This instance of :c:type:`PyTypeObject` represents the Python floating-point " "type. This is the same object as :class:`float` in the Python layer." msgstr "" +"這個 :c:type:`PyTypeObject` 的實例代表 Python 浮點數型別。這與 Python 層中" +"的 :class:`float` 物件相同。" #: ../../c-api/float.rst:24 msgid "" "Return true if its argument is a :c:type:`PyFloatObject` or a subtype of :c:" "type:`PyFloatObject`. This function always succeeds." msgstr "" +"如果其引數是 :c:type:`PyFloatObject` 或 :c:type:`PyFloatObject` 的子型別,則" +"回傳 true。這個函式不會失敗。" #: ../../c-api/float.rst:30 msgid "" "Return true if its argument is a :c:type:`PyFloatObject`, but not a subtype " "of :c:type:`PyFloatObject`. This function always succeeds." msgstr "" +"如果其引數是 :c:type:`PyFloatObject`,但不是 :c:type:`PyFloatObject` 的子型" +"別,則回傳 true。這個函式不會失敗。" #: ../../c-api/float.rst:36 msgid "" "Create a :c:type:`PyFloatObject` object based on the string value in *str*, " "or ``NULL`` on failure." msgstr "" +"建立一個基於字串值 *str* 的 :c:type:`PyFloatObject` 物件,失敗時回傳 " +"``NULL``。" #: ../../c-api/float.rst:42 msgid "" "Create a :c:type:`PyFloatObject` object from *v*, or ``NULL`` on failure." msgstr "" +"建立一個來自 *v* 的 :c:type:`PyFloatObject` 物件,失敗時回傳 ``NULL``。" #: ../../c-api/float.rst:47 msgid "" @@ -67,16 +76,21 @@ msgid "" "meth:`~object.__index__`. This method returns ``-1.0`` upon failure, so one " "should call :c:func:`PyErr_Occurred` to check for errors." msgstr "" +"回傳 *pyfloat* 內容的 C :c:expr:`double` 表示形式。如果 *pyfloat* 不是 " +"Python 浮點數物件,但具有 :meth:`~object.__float__` 方法,則會先呼叫此方法將 " +"*pyfloat* 轉換為浮點數。如果未定義 :meth:`!__float__`,則會用後備方法 :meth:" +"`~object.__index__`。此方法在失敗時回傳 ``-1.0``,因此應該呼叫 :c:func:" +"`PyErr_Occurred` 來檢查錯誤。" #: ../../c-api/float.rst:54 msgid "Use :meth:`~object.__index__` if available." -msgstr "" +msgstr "請使用 :meth:`~object.__index__`\\ (如果可用)。" #: ../../c-api/float.rst:60 msgid "" "Return a C :c:expr:`double` representation of the contents of *pyfloat*, but " "without error checking." -msgstr "" +msgstr "回傳 *pyfloat* 內容的 C :c:expr:`double` 表示形式,但不進行錯誤檢查。" #: ../../c-api/float.rst:66 msgid "" @@ -84,23 +98,150 @@ msgid "" "minimum and maximum values of a float. It's a thin wrapper around the header " "file :file:`float.h`." msgstr "" +"回傳一個 structseq 實例,其中包含有關浮點數的精度、最小值和最大值的資訊。它是" +"對標頭檔 :file:`float.h` 的簡單封裝。" #: ../../c-api/float.rst:73 msgid "" "Return the maximum representable finite float *DBL_MAX* as C :c:expr:" "`double`." -msgstr "" +msgstr "將可表示的最大有限浮點數 *DBL_MAX* 作為 C :c:expr:`double` 回傳。" #: ../../c-api/float.rst:78 msgid "" "Return the minimum normalized positive float *DBL_MIN* as C :c:expr:`double`." +msgstr "將最小的正規化浮點數 *DBL_MIN* 作為 C :c:expr:`double` 回傳。" + +#: ../../c-api/float.rst:83 +msgid "" +"This macro expands a to constant expression of type :c:expr:`double`, that " +"represents the positive infinity." +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` 巨集。" -#: ../../c-api/float.rst:82 -msgid "Pack and Unpack functions" +#: ../../c-api/float.rst:92 +msgid "" +"This macro expands a to constant expression of type :c:expr:`double`, that " +"represents a quiet not-a-number (qNaN) value." +msgstr "" +"這個巨集會展開為一型別為 :c:expr:`double` 的常數運算式,表示安靜型 NaN " +"(qNaN) 值。" + +#: ../../c-api/float.rst:95 +msgid "" +"On most platforms, this is equivalent to the :c:macro:`!NAN` macro from the " +"C11 standard ```` header." msgstr "" +"在大多數平台上,這相當於 C11 標準 ```` 標頭檔中的 :c:macro:`!NAN` 巨" +"集。" -#: ../../c-api/float.rst:84 +#: ../../c-api/float.rst:101 +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 +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 +msgid "High precision (long double) definition of :data:`~math.e` constant." +msgstr "高精度(long double)定義的 :data:`~math.e` 常數。" + +#: ../../c-api/float.rst:119 +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 +msgid "High precision (long double) definition of :data:`~math.pi` constant." +msgstr "高精度(long double)定義的 :data:`~math.pi` 常數。" + +#: ../../c-api/float.rst:129 +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 +msgid "Return :data:`math.nan` from a function." +msgstr "從函式回傳 :data:`math.nan`。" + +#: ../../c-api/float.rst:138 +msgid "" +"On most platforms, this is equivalent to ``return PyFloat_FromDouble(NAN)``." +msgstr "在大多數平台上,這相當於 ``return PyFloat_FromDouble(NAN)``。" + +#: ../../c-api/float.rst:143 +msgid "" +"Return :data:`math.inf` or :data:`-math.inf ` from a function, " +"depending on the sign of *sign*." +msgstr "" +"根據 *sign* 的正負號,從函式回傳 :data:`math.inf` 或 :data:`-math.inf `。" + +#: ../../c-api/float.rst:146 +msgid "On most platforms, this is equivalent to the following::" +msgstr "在大多數平台上,這相當於以下內容: ::" + +#: ../../c-api/float.rst:148 +msgid "return PyFloat_FromDouble(copysign(INFINITY, sign));" +msgstr "return PyFloat_FromDouble(copysign(INFINITY, sign));" + +#: ../../c-api/float.rst:153 +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`` " +"otherwise." +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:163 +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:172 +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 "Pack and Unpack functions" +msgstr "打包和解包函式" + +#: ../../c-api/float.rst:182 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 " @@ -108,8 +249,11 @@ msgid "" "c:expr:`double` from such a bytes string. The suffix (2, 4 or 8) specifies " "the number of bytes in the bytes string." msgstr "" +"打包和解包函式提供了一種有效的跨平台方式,來將浮點數值儲存為位元組字串。打包" +"例程從 C :c:expr:`double` 產生位元組字串,而解包例程則從這樣的位元組字串產生 " +"C :c:expr:`double`。後綴(2、4 或 8)標示了位元組字串中的位元組數。" -#: ../../c-api/float.rst:90 +#: ../../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 " @@ -120,20 +264,36 @@ msgid "" "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:99 +#: ../../c-api/float.rst:197 +msgid "" +"Note that NaNs type may not be preserved on IEEE platforms (signaling NaN " +"become quiet NaN), for example on x86 systems in 32-bit mode." +msgstr "" +"請注意,在 IEEE 平台上可能無法保留 NaN 型別(「訊號型 NaN (signaling NaN)」會" +"變成「安靜型 NaN (quiet NaN)」),例如在 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)." msgstr "" +"在非 IEEE 平台上,如果精度更高或動態範圍比 IEEE 754 支援的更大,則無法打包所" +"有值;在非 IEEE 平台上,如果精度較低或動態範圍較小,則無法解包所有值。在這種" +"案例下發生的情況在某種程度上是偶然的(唉)。" -#: ../../c-api/float.rst:107 +#: ../../c-api/float.rst:208 msgid "Pack functions" -msgstr "" +msgstr "打包函式" -#: ../../c-api/float.rst:109 +#: ../../c-api/float.rst:210 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 " @@ -142,42 +302,49 @@ msgid "" "`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." 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-api/float.rst:116 +#: ../../c-api/float.rst:217 msgid "" "Return value: ``0`` if all is OK, ``-1`` if error (and an exception is set, " "most likely :exc:`OverflowError`)." msgstr "" +"回傳值:如果一切正常則為 ``0``,如果發生錯誤則為 ``-1``\\ (並且會設定一個例" +"外,最有可能是 :exc:`OverflowError`)。" -#: ../../c-api/float.rst:119 +#: ../../c-api/float.rst:220 msgid "There are two problems on non-IEEE platforms:" -msgstr "" +msgstr "在非 IEEE 平台上有兩個問題:" -#: ../../c-api/float.rst:121 +#: ../../c-api/float.rst:222 msgid "What this does is undefined if *x* is a NaN or infinity." -msgstr "" +msgstr "如果 *x* 是 NaN 或無窮大,則這樣做是未定義的。" -#: ../../c-api/float.rst:122 +#: ../../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:126 +#: ../../c-api/float.rst:227 msgid "Pack a C double as the IEEE 754 binary16 half-precision format." -msgstr "" +msgstr "將 C double 打包為 IEEE 754 binary16 半精度格式。" -#: ../../c-api/float.rst:130 +#: ../../c-api/float.rst:231 msgid "Pack a C double as the IEEE 754 binary32 single precision format." -msgstr "" +msgstr "將 C double 打包為 IEEE 754 binary32 單精度格式。" -#: ../../c-api/float.rst:134 +#: ../../c-api/float.rst:235 msgid "Pack a C double as the IEEE 754 binary64 double precision format." -msgstr "" +msgstr "將 C double 打包為 IEEE 754 binary64 雙精度格式。" -#: ../../c-api/float.rst:138 +#: ../../c-api/float.rst:239 msgid "Unpack functions" -msgstr "" +msgstr "解包函式" -#: ../../c-api/float.rst:140 +#: ../../c-api/float.rst:241 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 " @@ -186,31 +353,40 @@ msgid "" "be used to use the native endian: it is equal to ``1`` on big endian " "processor, or ``0`` 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-api/float.rst:147 +#: ../../c-api/float.rst:248 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:" "`OverflowError`)." msgstr "" +"回傳值:解包後的 double。發生錯誤時,這是 ``-1.0`` 且 :c:func:" +"`PyErr_Occurred` 為 true(並且會設置一個例外,最有可能是 :exc:" +"`OverflowError`)。" -#: ../../c-api/float.rst:151 +#: ../../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:156 +#: ../../c-api/float.rst:257 msgid "Unpack the IEEE 754 binary16 half-precision format as a C double." -msgstr "" +msgstr "將 IEEE 754 binary16 半精度格式解包為 C double。" -#: ../../c-api/float.rst:160 +#: ../../c-api/float.rst:261 msgid "Unpack the IEEE 754 binary32 single precision format as a C double." -msgstr "" +msgstr "將 IEEE 754 binary32 單精度格式解包為 C double。" -#: ../../c-api/float.rst:164 +#: ../../c-api/float.rst:265 msgid "Unpack the IEEE 754 binary64 double precision format as a C double." -msgstr "" +msgstr "將 IEEE 754 binary64 雙精度格式解包為 C double。" #: ../../c-api/float.rst:8 msgid "object" diff --git a/c-api/frame.po b/c-api/frame.po index 1bbe0b32c78..c0441207853 100644 --- a/c-api/frame.po +++ b/c-api/frame.po @@ -1,12 +1,11 @@ -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # -#, fuzzy msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-12-12 00:15+0000\n" +"POT-Creation-Date: 2025-11-11 00:15+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -56,95 +55,102 @@ msgid "" msgstr "" #: ../../c-api/frame.rst:34 +msgid "" +"Create a new frame object. This function returns a :term:`strong reference` " +"to the new frame object on success, and returns ``NULL`` with an exception " +"set on failure." +msgstr "" + +#: ../../c-api/frame.rst:40 msgid "Return non-zero if *obj* is a frame object." msgstr "" -#: ../../c-api/frame.rst:38 +#: ../../c-api/frame.rst:44 msgid "" "Previously, this function was only available after including ````." msgstr "" -#: ../../c-api/frame.rst:43 +#: ../../c-api/frame.rst:49 msgid "Get the *frame* next outer frame." msgstr "" -#: ../../c-api/frame.rst:45 +#: ../../c-api/frame.rst:51 msgid "" "Return a :term:`strong reference`, or ``NULL`` if *frame* has no outer frame." msgstr "" -#: ../../c-api/frame.rst:53 +#: ../../c-api/frame.rst:59 msgid "Get the *frame*'s :attr:`~frame.f_builtins` attribute." msgstr "取得 *frame* 的 :attr:`~frame.f_builtins` 屬性。" -#: ../../c-api/frame.rst:55 ../../c-api/frame.rst:86 +#: ../../c-api/frame.rst:61 ../../c-api/frame.rst:92 msgid "Return a :term:`strong reference`. The result cannot be ``NULL``." msgstr "回傳 :term:`strong reference`。結果不能為 ``NULL``。" -#: ../../c-api/frame.rst:62 +#: ../../c-api/frame.rst:68 msgid "Get the *frame* code." msgstr "" -#: ../../c-api/frame.rst:64 ../../c-api/frame.rst:130 +#: ../../c-api/frame.rst:70 ../../c-api/frame.rst:136 msgid "Return a :term:`strong reference`." msgstr "回傳 :term:`strong reference`。" -#: ../../c-api/frame.rst:66 +#: ../../c-api/frame.rst:72 msgid "The result (frame code) cannot be ``NULL``." msgstr "" -#: ../../c-api/frame.rst:73 +#: ../../c-api/frame.rst:79 msgid "" "Get the generator, coroutine, or async generator that owns this frame, or " "``NULL`` if this frame is not owned by a generator. Does not raise an " "exception, even if the return value is ``NULL``." msgstr "" -#: ../../c-api/frame.rst:77 +#: ../../c-api/frame.rst:83 msgid "Return a :term:`strong reference`, or ``NULL``." msgstr "回傳 :term:`strong reference` 或 ``NULL``。" -#: ../../c-api/frame.rst:84 +#: ../../c-api/frame.rst:90 msgid "Get the *frame*'s :attr:`~frame.f_globals` attribute." msgstr "取得 *frame* 的 :attr:`~frame.f_globals` 屬性。" -#: ../../c-api/frame.rst:93 +#: ../../c-api/frame.rst:99 msgid "Get the *frame*'s :attr:`~frame.f_lasti` attribute." msgstr "取得 *frame* 的 :attr:`~frame.f_lasti` 屬性。" -#: ../../c-api/frame.rst:95 +#: ../../c-api/frame.rst:101 msgid "Returns -1 if ``frame.f_lasti`` is ``None``." msgstr "如果 ``frame.f_lasti`` 是 ``None`` 則回傳 -1。" -#: ../../c-api/frame.rst:102 +#: ../../c-api/frame.rst:108 msgid "Get the variable *name* of *frame*." msgstr "取得 *frame* 的變數 *name*。" -#: ../../c-api/frame.rst:104 +#: ../../c-api/frame.rst:110 msgid "Return a :term:`strong reference` to the variable value on success." msgstr "在成功時回傳變數值的 :term:`strong reference`。" -#: ../../c-api/frame.rst:105 +#: ../../c-api/frame.rst:111 msgid "" "Raise :exc:`NameError` and return ``NULL`` if the variable does not exist." msgstr "如果變數不存在,則引發 :exc:`NameError` 並回傳 ``NULL``。" -#: ../../c-api/frame.rst:106 +#: ../../c-api/frame.rst:112 msgid "Raise an exception and return ``NULL`` on error." msgstr "在錯誤時引發例外並回傳 ``NULL``。" -#: ../../c-api/frame.rst:108 +#: ../../c-api/frame.rst:114 msgid "*name* type must be a :class:`str`." msgstr "*name* 的型別必須是 :class:`str`。" -#: ../../c-api/frame.rst:115 +#: ../../c-api/frame.rst:121 msgid "" "Similar to :c:func:`PyFrame_GetVar`, but the variable name is a C string " "encoded in UTF-8." msgstr "" -#: ../../c-api/frame.rst:123 +#: ../../c-api/frame.rst:129 msgid "" "Get the *frame*'s :attr:`~frame.f_locals` attribute. If the frame refers to " "an :term:`optimized scope`, this returns a write-through proxy object that " @@ -153,21 +159,21 @@ msgid "" "directly (as described for :func:`locals`)." msgstr "" -#: ../../c-api/frame.rst:134 +#: ../../c-api/frame.rst:140 msgid "" "As part of :pep:`667`, return an instance of :c:var:" "`PyFrameLocalsProxy_Type`." msgstr "" -#: ../../c-api/frame.rst:140 +#: ../../c-api/frame.rst:146 msgid "Return the line number that *frame* is currently executing." msgstr "" -#: ../../c-api/frame.rst:144 +#: ../../c-api/frame.rst:150 msgid "Frame Locals Proxies" msgstr "" -#: ../../c-api/frame.rst:148 +#: ../../c-api/frame.rst:154 msgid "" "The :attr:`~frame.f_locals` attribute on a :ref:`frame object ` is an instance of a \"frame-locals proxy\". The proxy object " @@ -176,39 +182,87 @@ msgid "" "to date with the live local variables in the frame itself." msgstr "" -#: ../../c-api/frame.rst:154 +#: ../../c-api/frame.rst:160 msgid "See :pep:`667` for more information." msgstr "" -#: ../../c-api/frame.rst:158 +#: ../../c-api/frame.rst:164 msgid "The type of frame :func:`locals` proxy objects." msgstr "" -#: ../../c-api/frame.rst:162 +#: ../../c-api/frame.rst:168 msgid "Return non-zero if *obj* is a frame :func:`locals` proxy." msgstr "" -#: ../../c-api/frame.rst:165 +#: ../../c-api/frame.rst:172 +msgid "Legacy Local Variable APIs" +msgstr "" + +#: ../../c-api/frame.rst:174 +msgid "" +"These APIs are :term:`soft deprecated`. As of Python 3.13, they do nothing. " +"They exist solely for backwards compatibility." +msgstr "" + +#: ../../c-api/frame.rst:180 ../../c-api/frame.rst:194 +#: ../../c-api/frame.rst:207 +msgid "This function is :term:`soft deprecated` and does nothing." +msgstr "" + +#: ../../c-api/frame.rst:182 +msgid "" +"Prior to Python 3.13, this function would copy the :attr:`~frame.f_locals` " +"attribute of *f* to the internal \"fast\" array of local variables, allowing " +"changes in frame objects to be visible to the interpreter. If *clear* was " +"true, this function would process variables that were unset in the locals " +"dictionary." +msgstr "" + +#: ../../c-api/frame.rst:188 ../../c-api/frame.rst:201 +#: ../../c-api/frame.rst:213 +msgid "This function now does nothing." +msgstr "" + +#: ../../c-api/frame.rst:196 +msgid "" +"Prior to Python 3.13, this function would copy the internal \"fast\" array " +"of local variables (which is used by the interpreter) to the :attr:`~frame." +"f_locals` attribute of *f*, allowing changes in local variables to be " +"visible to frame objects." +msgstr "" + +#: ../../c-api/frame.rst:209 +msgid "" +"Prior to Python 3.13, this function was similar to :c:func:" +"`PyFrame_FastToLocals`, but would return ``0`` on success, and ``-1`` with " +"an exception set on failure." +msgstr "" + +#: ../../c-api/frame.rst:218 +msgid ":pep:`667`" +msgstr "" + +#: ../../c-api/frame.rst:222 msgid "Internal Frames" msgstr "" -#: ../../c-api/frame.rst:167 +#: ../../c-api/frame.rst:224 msgid "Unless using :pep:`523`, you will not need this." msgstr "" -#: ../../c-api/frame.rst:171 +#: ../../c-api/frame.rst:228 msgid "The interpreter's internal frame representation." msgstr "" -#: ../../c-api/frame.rst:177 +#: ../../c-api/frame.rst:234 msgid "Return a :term:`strong reference` to the code object for the frame." msgstr "" -#: ../../c-api/frame.rst:184 +#: ../../c-api/frame.rst:241 msgid "Return the byte offset into the last executed instruction." msgstr "" -#: ../../c-api/frame.rst:191 +#: ../../c-api/frame.rst:248 msgid "" "Return the currently executing line number, or -1 if there is no line number." msgstr "" diff --git a/c-api/function.po b/c-api/function.po index 9328805cc2d..61b434d12ad 100644 --- a/c-api/function.po +++ b/c-api/function.po @@ -1,5 +1,4 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -8,9 +7,9 @@ # Matt Wang , 2022 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"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: 2025-11-10 00:16+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-" @@ -126,8 +125,8 @@ msgid "" msgstr "" "設定函式物件 *op* 的引數預設值。*defaults* 必須是 ``Py_None`` 或一個 tuple。" -#: ../../c-api/function.rst:86 ../../c-api/function.rst:116 -#: ../../c-api/function.rst:130 +#: ../../c-api/function.rst:86 ../../c-api/function.rst:125 +#: ../../c-api/function.rst:139 msgid "Raises :exc:`SystemError` and returns ``-1`` on failure." msgstr "引發 :exc:`SystemError` 且在失敗時回傳 ``-1``。" @@ -139,7 +138,8 @@ msgstr "為一個給定的函式物件 *func* 設定 vectorcall 欄位。" msgid "" "Warning: extensions using this API must preserve the behavior of the " "unaltered (default) vectorcall function!" -msgstr "警告:使用此 API 的擴充套件必須保留未更改(預設)vectorcall 函式的行為!" +msgstr "" +"警告:使用此 API 的擴充套件必須保留未更改(預設)vectorcall 函式的行為!" #: ../../c-api/function.rst:101 msgid "" @@ -151,13 +151,26 @@ msgstr "" #: ../../c-api/function.rst:107 msgid "" +"Set the keyword-only argument default values of the function object *op*. " +"*defaults* must be a dictionary of keyword-only arguments or ``Py_None``." +msgstr "" +"設定函式物件 *op* 的僅限關鍵字引數預設值。*defaults* 必須是僅限關鍵字引數的字典或 ``Py_None``。" + +#: ../../c-api/function.rst:110 +msgid "" +"This function returns ``0`` on success, and returns ``-1`` with an exception " +"set on failure." +msgstr "此函式在成功時回傳 ``0``,在失敗時回傳 ``-1`` 且設定一個例外。" + +#: ../../c-api/function.rst:116 +msgid "" "Return the closure associated with the function object *op*. This can be " "``NULL`` or a tuple of cell objects." msgstr "" "回傳與函式物件 *op* 相關聯的閉包,這可以是個 ``NULL`` 或是一個包含 cell 物件" "的 tuple。" -#: ../../c-api/function.rst:113 +#: ../../c-api/function.rst:122 msgid "" "Set the closure associated with the function object *op*. *closure* must be " "``Py_None`` or a tuple of cell objects." @@ -165,27 +178,27 @@ msgstr "" "設定與函式物件 *op* 相關聯的閉包,*closure* 必須是 ``Py_None`` 或是一個包含 " "cell 物件的 tuple。" -#: ../../c-api/function.rst:121 +#: ../../c-api/function.rst:130 msgid "" "Return the annotations of the function object *op*. This can be a mutable " "dictionary or ``NULL``." msgstr "" "回傳函式物件 *op* 的標註,這可以是一個可變動的 (mutable) 字典或 ``NULL``。" -#: ../../c-api/function.rst:127 +#: ../../c-api/function.rst:136 msgid "" "Set the annotations for the function object *op*. *annotations* must be a " "dictionary or ``Py_None``." msgstr "設定函式物件 *op* 的標註,*annotations* 必須是一個字典或 ``Py_None``。" -#: ../../c-api/function.rst:141 +#: ../../c-api/function.rst:150 msgid "" "These functions are similar to their ``PyFunction_Get*`` counterparts, but " "do not do type checking. Passing anything other than an instance of :c:data:" "`PyFunction_Type` is undefined behavior." msgstr "" -#: ../../c-api/function.rst:148 +#: ../../c-api/function.rst:157 msgid "" "Register *callback* as a function watcher for the current interpreter. " "Return an ID which may be passed to :c:func:`PyFunction_ClearWatcher`. In " @@ -193,7 +206,7 @@ msgid "" "exception." msgstr "" -#: ../../c-api/function.rst:158 +#: ../../c-api/function.rst:167 msgid "" "Clear watcher identified by *watcher_id* previously returned from :c:func:" "`PyFunction_AddWatcher` for the current interpreter. Return ``0`` on " @@ -201,35 +214,35 @@ msgid "" "*watcher_id* was never registered.)" msgstr "" -#: ../../c-api/function.rst:168 +#: ../../c-api/function.rst:177 msgid "Enumeration of possible function watcher events:" msgstr "" -#: ../../c-api/function.rst:170 +#: ../../c-api/function.rst:179 msgid "``PyFunction_EVENT_CREATE``" msgstr "``PyFunction_EVENT_CREATE``" -#: ../../c-api/function.rst:171 +#: ../../c-api/function.rst:180 msgid "``PyFunction_EVENT_DESTROY``" msgstr "``PyFunction_EVENT_DESTROY``" -#: ../../c-api/function.rst:172 +#: ../../c-api/function.rst:181 msgid "``PyFunction_EVENT_MODIFY_CODE``" msgstr "``PyFunction_EVENT_MODIFY_CODE``" -#: ../../c-api/function.rst:173 +#: ../../c-api/function.rst:182 msgid "``PyFunction_EVENT_MODIFY_DEFAULTS``" msgstr "``PyFunction_EVENT_MODIFY_DEFAULTS``" -#: ../../c-api/function.rst:174 +#: ../../c-api/function.rst:183 msgid "``PyFunction_EVENT_MODIFY_KWDEFAULTS``" msgstr "``PyFunction_EVENT_MODIFY_KWDEFAULTS``" -#: ../../c-api/function.rst:181 +#: ../../c-api/function.rst:190 msgid "Type of a function watcher callback function." msgstr "" -#: ../../c-api/function.rst:183 +#: ../../c-api/function.rst:192 msgid "" "If *event* is ``PyFunction_EVENT_CREATE`` or ``PyFunction_EVENT_DESTROY`` " "then *new_value* will be ``NULL``. Otherwise, *new_value* will hold a :term:" @@ -237,13 +250,13 @@ msgid "" "for the attribute that is being modified." msgstr "" -#: ../../c-api/function.rst:188 +#: ../../c-api/function.rst:197 msgid "" "The callback may inspect but must not modify *func*; doing so could have " "unpredictable effects, including infinite recursion." msgstr "" -#: ../../c-api/function.rst:191 +#: ../../c-api/function.rst:200 msgid "" "If *event* is ``PyFunction_EVENT_CREATE``, then the callback is invoked " "after *func* has been fully initialized. Otherwise, the callback is invoked " @@ -255,7 +268,7 @@ msgid "" "semantics of the Python code being executed." msgstr "" -#: ../../c-api/function.rst:200 +#: ../../c-api/function.rst:209 msgid "" "If *event* is ``PyFunction_EVENT_DESTROY``, Taking a reference in the " "callback to the about-to-be-destroyed function will resurrect it, preventing " @@ -263,14 +276,14 @@ msgid "" "later, any watcher callbacks active at that time will be called again." msgstr "" -#: ../../c-api/function.rst:205 +#: ../../c-api/function.rst:214 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:209 +#: ../../c-api/function.rst:218 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 8ad9b1c6a12..1489b716d56 100644 --- a/c-api/gcsupport.po +++ b/c-api/gcsupport.po @@ -1,13 +1,12 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"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: 2025-09-08 15:25+0800\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-" @@ -76,8 +75,8 @@ msgstr "" #: ../../c-api/gcsupport.rst:37 msgid "" -"Before fields which refer to other containers are invalidated, :c:func:" -"`PyObject_GC_UnTrack` must be called." +"Before fields which refer to other containers are " +"invalidated, :c:func:`PyObject_GC_UnTrack` must be called." msgstr "" #: ../../c-api/gcsupport.rst:40 @@ -87,35 +86,75 @@ msgstr "" #: ../../c-api/gcsupport.rst:43 msgid "" -"If a type adds the Py_TPFLAGS_HAVE_GC, then it *must* implement at least a :" -"c:member:`~PyTypeObject.tp_traverse` handler or explicitly use one from its " -"subclass or subclasses." +"If a type adds the Py_TPFLAGS_HAVE_GC, then it *must* implement at least " +"a :c:member:`~PyTypeObject.tp_traverse` handler or explicitly use one from " +"its subclass or subclasses." msgstr "" #: ../../c-api/gcsupport.rst:47 msgid "" "When calling :c:func:`PyType_Ready` or some of the APIs that indirectly call " "it like :c:func:`PyType_FromSpecWithBases` or :c:func:`PyType_FromSpec` the " -"interpreter will automatically populate the :c:member:`~PyTypeObject." -"tp_flags`, :c:member:`~PyTypeObject.tp_traverse` and :c:member:" -"`~PyTypeObject.tp_clear` fields if the type inherits from a class that " -"implements the garbage collector protocol and the child class does *not* " -"include the :c:macro:`Py_TPFLAGS_HAVE_GC` flag." +"interpreter will automatically populate " +"the :c:member:`~PyTypeObject.tp_flags`, :c:member:`~PyTypeObject.tp_traverse` " +"and :c:member:`~PyTypeObject.tp_clear` fields if the type inherits from a " +"class that implements the garbage collector protocol and the child class " +"does *not* include the :c:macro:`Py_TPFLAGS_HAVE_GC` flag." msgstr "" #: ../../c-api/gcsupport.rst:57 msgid "" -"Analogous to :c:macro:`PyObject_New` but for container objects with the :c:" -"macro:`Py_TPFLAGS_HAVE_GC` flag set." +"Analogous to :c:macro:`PyObject_New` but for container objects with " +"the :c:macro:`Py_TPFLAGS_HAVE_GC` flag set." msgstr "" -#: ../../c-api/gcsupport.rst:62 +#: ../../c-api/gcsupport.rst:60 ../../c-api/gcsupport.rst:84 msgid "" -"Analogous to :c:macro:`PyObject_NewVar` but for container objects with the :" -"c:macro:`Py_TPFLAGS_HAVE_GC` flag set." +"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/gcsupport.rst:67 +#: ../../c-api/gcsupport.rst:63 ../../c-api/gcsupport.rst:87 +msgid "" +"When populating a type's :c:member:`~PyTypeObject.tp_alloc` " +"slot, :c:func:`PyType_GenericAlloc` is preferred over a custom function that " +"simply calls this macro." +msgstr "" + +#: ../../c-api/gcsupport.rst:67 ../../c-api/gcsupport.rst:91 +msgid "" +"Memory allocated by this macro must be freed with :c:func:`PyObject_GC_Del` " +"(usually called via the object's :c:member:`~PyTypeObject.tp_free` slot)." +msgstr "" + +#: ../../c-api/gcsupport.rst:73 ../../c-api/gcsupport.rst:97 +msgid ":c:func:`PyObject_GC_Del`" +msgstr ":c:func:`PyObject_GC_Del`" + +#: ../../c-api/gcsupport.rst:74 +msgid ":c:macro:`PyObject_New`" +msgstr ":c:macro:`PyObject_New`" + +#: ../../c-api/gcsupport.rst:75 ../../c-api/gcsupport.rst:99 +#: ../../c-api/gcsupport.rst:193 +msgid ":c:func:`PyType_GenericAlloc`" +msgstr ":c:func:`PyType_GenericAlloc`" + +#: ../../c-api/gcsupport.rst:76 ../../c-api/gcsupport.rst:100 +msgid ":c:member:`~PyTypeObject.tp_alloc`" +msgstr ":c:member:`~PyTypeObject.tp_alloc`" + +#: ../../c-api/gcsupport.rst:81 +msgid "" +"Analogous to :c:macro:`PyObject_NewVar` but for container objects with " +"the :c:macro:`Py_TPFLAGS_HAVE_GC` flag set." +msgstr "" + +#: ../../c-api/gcsupport.rst:98 +msgid ":c:macro:`PyObject_NewVar`" +msgstr ":c:macro:`PyObject_NewVar`" + +#: ../../c-api/gcsupport.rst:105 msgid "" "Analogous to :c:macro:`PyObject_GC_New` but allocates *extra_size* bytes at " "the end of the object (at offset :c:member:`~PyTypeObject.tp_basicsize`). " @@ -123,34 +162,41 @@ msgid "" "object header `." msgstr "" -#: ../../c-api/gcsupport.rst:73 +#: ../../c-api/gcsupport.rst:111 msgid "" "The extra data will be deallocated with the object, but otherwise it is not " "managed by Python." msgstr "" -#: ../../c-api/gcsupport.rst:77 +#: ../../c-api/gcsupport.rst:114 +msgid "" +"Memory allocated by this function must be freed " +"with :c:func:`PyObject_GC_Del` (usually called via the " +"object's :c:member:`~PyTypeObject.tp_free` slot)." +msgstr "" + +#: ../../c-api/gcsupport.rst:119 msgid "" "The function is marked as unstable because the final mechanism for reserving " "extra data after an instance is not yet decided. For allocating a variable " -"number of fields, prefer using :c:type:`PyVarObject` and :c:member:" -"`~PyTypeObject.tp_itemsize` instead." +"number of fields, prefer using :c:type:`PyVarObject` " +"and :c:member:`~PyTypeObject.tp_itemsize` instead." msgstr "" -#: ../../c-api/gcsupport.rst:88 +#: ../../c-api/gcsupport.rst:130 msgid "" "Resize an object allocated by :c:macro:`PyObject_NewVar`. Returns the " "resized object of type ``TYPE*`` (refers to any C type) or ``NULL`` on " "failure." msgstr "" -#: ../../c-api/gcsupport.rst:92 +#: ../../c-api/gcsupport.rst:134 msgid "" "*op* must be of type :c:expr:`PyVarObject *` and must not be tracked by the " "collector yet. *newsize* must be of type :c:type:`Py_ssize_t`." msgstr "" -#: ../../c-api/gcsupport.rst:99 +#: ../../c-api/gcsupport.rst:141 msgid "" "Adds the object *op* to the set of container objects tracked by the " "collector. The collector can run at unexpected times so objects must be " @@ -159,83 +205,112 @@ msgid "" "usually near the end of the constructor." msgstr "" -#: ../../c-api/gcsupport.rst:108 +#: ../../c-api/gcsupport.rst:150 msgid "" "Returns non-zero if the object implements the garbage collector protocol, " "otherwise returns 0." msgstr "" -#: ../../c-api/gcsupport.rst:111 +#: ../../c-api/gcsupport.rst:153 msgid "" "The object cannot be tracked by the garbage collector if this function " "returns 0." msgstr "" -#: ../../c-api/gcsupport.rst:116 +#: ../../c-api/gcsupport.rst:158 msgid "" "Returns 1 if the object type of *op* implements the GC protocol and *op* is " "being currently tracked by the garbage collector and 0 otherwise." msgstr "" -#: ../../c-api/gcsupport.rst:119 +#: ../../c-api/gcsupport.rst:161 msgid "This is analogous to the Python function :func:`gc.is_tracked`." msgstr "" -#: ../../c-api/gcsupport.rst:126 +#: ../../c-api/gcsupport.rst:168 msgid "" "Returns 1 if the object type of *op* implements the GC protocol and *op* has " "been already finalized by the garbage collector and 0 otherwise." msgstr "" -#: ../../c-api/gcsupport.rst:129 +#: ../../c-api/gcsupport.rst:171 msgid "This is analogous to the Python function :func:`gc.is_finalized`." msgstr "" -#: ../../c-api/gcsupport.rst:136 +#: ../../c-api/gcsupport.rst:178 +msgid "" +"Releases memory allocated to an object using :c:macro:`PyObject_GC_New` " +"or :c:macro:`PyObject_GC_NewVar`." +msgstr "" + +#: ../../c-api/gcsupport.rst:181 msgid "" -"Releases memory allocated to an object using :c:macro:`PyObject_GC_New` or :" -"c:macro:`PyObject_GC_NewVar`." +"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/gcsupport.rst:142 +#: ../../c-api/gcsupport.rst:184 +msgid "" +"Do not use this for memory allocated " +"by :c:macro:`PyObject_New`, :c:macro:`PyObject_NewVar`, or related " +"allocation functions; use :c:func:`PyObject_Free` instead." +msgstr "" + +#: ../../c-api/gcsupport.rst:190 +msgid ":c:func:`PyObject_Free` is the non-GC equivalent of this function." +msgstr "" + +#: ../../c-api/gcsupport.rst:191 +msgid ":c:macro:`PyObject_GC_New`" +msgstr ":c:macro:`PyObject_GC_New`" + +#: ../../c-api/gcsupport.rst:192 +msgid ":c:macro:`PyObject_GC_NewVar`" +msgstr ":c:macro:`PyObject_GC_NewVar`" + +#: ../../c-api/gcsupport.rst:194 +msgid ":c:member:`~PyTypeObject.tp_free`" +msgstr ":c:member:`~PyTypeObject.tp_free`" + +#: ../../c-api/gcsupport.rst:199 msgid "" "Remove the object *op* from the set of container objects tracked by the " "collector. Note that :c:func:`PyObject_GC_Track` can be called again on " -"this object to add it back to the set of tracked objects. The deallocator (:" -"c:member:`~PyTypeObject.tp_dealloc` handler) should call this for the object " -"before any of the fields used by the :c:member:`~PyTypeObject.tp_traverse` " -"handler become invalid." +"this object to add it back to the set of tracked objects. The deallocator " +"(:c:member:`~PyTypeObject.tp_dealloc` handler) should call this for the " +"object before any of the fields used by " +"the :c:member:`~PyTypeObject.tp_traverse` handler become invalid." msgstr "" -#: ../../c-api/gcsupport.rst:151 +#: ../../c-api/gcsupport.rst:208 msgid "" "The :c:func:`!_PyObject_GC_TRACK` and :c:func:`!_PyObject_GC_UNTRACK` macros " "have been removed from the public C API." msgstr "" -#: ../../c-api/gcsupport.rst:154 +#: ../../c-api/gcsupport.rst:211 msgid "" "The :c:member:`~PyTypeObject.tp_traverse` handler accepts a function " "parameter of this type:" msgstr "" -#: ../../c-api/gcsupport.rst:159 +#: ../../c-api/gcsupport.rst:216 msgid "" -"Type of the visitor function passed to the :c:member:`~PyTypeObject." -"tp_traverse` handler. The function should be called with an object to " -"traverse as *object* and the third parameter to the :c:member:`~PyTypeObject." -"tp_traverse` handler as *arg*. The Python core uses several visitor " -"functions to implement cyclic garbage detection; it's not expected that " -"users will need to write their own visitor functions." +"Type of the visitor function passed to " +"the :c:member:`~PyTypeObject.tp_traverse` handler. The function should be " +"called with an object to traverse as *object* and the third parameter to " +"the :c:member:`~PyTypeObject.tp_traverse` handler as *arg*. The Python core " +"uses several visitor functions to implement cyclic garbage detection; it's " +"not expected that users will need to write their own visitor functions." msgstr "" -#: ../../c-api/gcsupport.rst:166 +#: ../../c-api/gcsupport.rst:223 msgid "" "The :c:member:`~PyTypeObject.tp_traverse` handler must have the following " "type:" msgstr "" -#: ../../c-api/gcsupport.rst:171 +#: ../../c-api/gcsupport.rst:228 msgid "" "Traversal function for a container object. Implementations must call the " "*visit* function for each object directly contained by *self*, with the " @@ -245,15 +320,15 @@ msgid "" "returned immediately." msgstr "" -#: ../../c-api/gcsupport.rst:178 +#: ../../c-api/gcsupport.rst:235 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*:" +"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:185 +#: ../../c-api/gcsupport.rst:242 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 " @@ -261,7 +336,7 @@ msgid "" "look like::" msgstr "" -#: ../../c-api/gcsupport.rst:190 +#: ../../c-api/gcsupport.rst:247 msgid "" "static int\n" "my_traverse(Noddy *self, visitproc visit, void *arg)\n" @@ -279,13 +354,13 @@ msgstr "" " return 0;\n" "}" -#: ../../c-api/gcsupport.rst:198 +#: ../../c-api/gcsupport.rst:255 msgid "" -"The :c:member:`~PyTypeObject.tp_clear` handler must be of the :c:type:" -"`inquiry` type, or ``NULL`` if the object is immutable." +"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:204 +#: ../../c-api/gcsupport.rst:261 msgid "" "Drop references that may have created reference cycles. Immutable objects " "do not have to define this method since they can never directly create " @@ -295,82 +370,82 @@ msgid "" "in a reference cycle." msgstr "" -#: ../../c-api/gcsupport.rst:213 +#: ../../c-api/gcsupport.rst:270 msgid "Controlling the Garbage Collector State" msgstr "" -#: ../../c-api/gcsupport.rst:215 +#: ../../c-api/gcsupport.rst:272 msgid "" "The C-API provides the following functions for controlling garbage " "collection runs." msgstr "" -#: ../../c-api/gcsupport.rst:220 +#: ../../c-api/gcsupport.rst:277 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:223 +#: ../../c-api/gcsupport.rst:280 msgid "" "Returns the number of collected + unreachable objects which cannot be " "collected. If the garbage collector is disabled or already collecting, " -"returns ``0`` immediately. Errors during garbage collection are passed to :" -"data:`sys.unraisablehook`. This function does not raise exceptions." +"returns ``0`` immediately. Errors during garbage collection are passed " +"to :data:`sys.unraisablehook`. This function does not raise exceptions." msgstr "" -#: ../../c-api/gcsupport.rst:233 +#: ../../c-api/gcsupport.rst:290 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:241 +#: ../../c-api/gcsupport.rst:298 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:249 +#: ../../c-api/gcsupport.rst:306 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:256 +#: ../../c-api/gcsupport.rst:313 msgid "Querying Garbage Collector State" msgstr "" -#: ../../c-api/gcsupport.rst:258 +#: ../../c-api/gcsupport.rst:315 msgid "" "The C-API provides the following interface for querying information about " "the garbage collector." msgstr "" -#: ../../c-api/gcsupport.rst:263 +#: ../../c-api/gcsupport.rst:320 msgid "" "Run supplied *callback* on all live GC-capable objects. *arg* is passed " "through to all invocations of *callback*." msgstr "" -#: ../../c-api/gcsupport.rst:267 +#: ../../c-api/gcsupport.rst:324 msgid "" "If new objects are (de)allocated by the callback it is undefined if they " "will be visited." msgstr "" -#: ../../c-api/gcsupport.rst:270 +#: ../../c-api/gcsupport.rst:327 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:278 +#: ../../c-api/gcsupport.rst:335 msgid "" -"Type of the visitor function to be passed to :c:func:" -"`PyUnstable_GC_VisitObjects`. *arg* is the same as the *arg* passed to " -"``PyUnstable_GC_VisitObjects``. Return ``1`` to continue iteration, return " -"``0`` to stop iteration. Other return values are reserved for now so " -"behavior on returning anything else is undefined." +"Type of the visitor function to be passed " +"to :c:func:`PyUnstable_GC_VisitObjects`. *arg* is the same as the *arg* " +"passed to ``PyUnstable_GC_VisitObjects``. Return ``1`` to continue " +"iteration, return ``0`` to stop iteration. Other return values are reserved " +"for now so behavior on returning anything else is undefined." msgstr "" diff --git a/c-api/gen.po b/c-api/gen.po index a1d498d11c9..d3c409ea04b 100644 --- a/c-api/gen.po +++ b/c-api/gen.po @@ -1,5 +1,4 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -8,9 +7,9 @@ # msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-09-13 00:11+0000\n" +"POT-Creation-Date: 2025-11-20 17:54+0000\n" "PO-Revision-Date: 2022-10-16 15:33+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -80,3 +79,52 @@ msgstr "" "基於 *frame* 物件建立並回傳一個新的產生器物件,其中 ``__name__`` 和 " "``__qualname__`` 設為 *name* 和 *qualname*。此函式會取走一個對 *frame* 的參" "照。*frame* 引數必須不為 ``NULL``。" + +#: ../../c-api/gen.rst:50 +msgid "" +"Return a new :term:`strong reference` to the code object wrapped by *gen*. " +"This function always succeeds." +msgstr "" +"回傳一個對 *gen* 所包裝的程式碼物件的新\\ :term:`強參照 `。" +"此函式總是會成功執行。" + +#: ../../c-api/gen.rst:55 +msgid "Asynchronous Generator Objects" +msgstr "非同步產生器 (Asynchronous Generator) 物件" + +#: ../../c-api/gen.rst:58 +msgid ":pep:`525`" +msgstr ":pep:`525`" + +#: ../../c-api/gen.rst:62 +msgid "" +"The type object corresponding to asynchronous generator objects. This is " +"available as :class:`types.AsyncGeneratorType` in the Python layer." +msgstr "" +"與非同步產生器物件對應的型別物件。在 Python 層中可以 :class:`types." +"AsyncGeneratorType` 使用。" + +#: ../../c-api/gen.rst:69 +msgid "" +"Create a new asynchronous generator wrapping *frame*, with ``__name__`` and " +"``__qualname__`` set to *name* and *qualname*. *frame* is stolen by this " +"function and must not be ``NULL``." +msgstr "" +"建立一個包裝 *frame* 的非同步產生器,並將 ``__name__`` 和 ``__qualname__`` 設為 " +"*name* 和 *qualname*。*frame* 會被此函式取走,且不得為 ``NULL``。" + +#: ../../c-api/gen.rst:73 +msgid "" +"On success, this function returns a :term:`strong reference` to the new " +"asynchronous generator. On failure, this function returns ``NULL`` with an " +"exception set." +msgstr "" +"成功時此函式回傳對新的非同步產生器的\\ :term:`強參照 `。失敗" +"時此函式回傳 ``NULL`` 並設定一個例外。" + +#: ../../c-api/gen.rst:81 +msgid "" +"Return true if *op* is an asynchronous generator object, false otherwise. " +"This function always succeeds." +msgstr "" +"如果 *op* 是一個非同步產生器物件則回傳 true,否則回傳 false。此函式總是會成功執行。" diff --git a/c-api/hash.po b/c-api/hash.po index bd50f539c26..7ec708bf846 100644 --- a/c-api/hash.po +++ b/c-api/hash.po @@ -1,13 +1,13 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Matt Wang , 2024 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-08-12 00:17+0000\n" +"POT-Creation-Date: 2025-11-09 00:17+0000\n" "PO-Revision-Date: 2024-04-30 00:20+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -30,11 +30,62 @@ msgstr "另請參閱 :c:member:`PyTypeObject.tp_hash` 成員和 :ref:`numeric-ha msgid "Hash value type: signed integer." msgstr "雜湊值型別:有符號整數。" -#: ../../c-api/hash.rst:16 +#: ../../c-api/hash.rst:17 msgid "Hash value type: unsigned integer." msgstr "雜湊值型別:無符號整數。" -#: ../../c-api/hash.rst:22 +#: ../../c-api/hash.rst:24 +msgid "" +"A numerical value indicating the algorithm for hashing of :class:`str`, :" +"class:`bytes`, and :class:`memoryview`." +msgstr "" + +#: ../../c-api/hash.rst:27 +msgid "The algorithm name is exposed by :data:`sys.hash_info.algorithm`." +msgstr "演算式名稱由 :data:`sys.hash_info.algorithm` 公開。" + +#: ../../c-api/hash.rst:36 +msgid "" +"Numerical values to compare to :c:macro:`Py_HASH_ALGORITHM` to determine " +"which algorithm is used for hashing. The hash algorithm can be configured " +"via the configure :option:`--with-hash-algorithm` option." +msgstr "" + +#: ../../c-api/hash.rst:40 +msgid "Add :c:macro:`!Py_HASH_FNV` and :c:macro:`!Py_HASH_SIPHASH24`." +msgstr "新增 :c:macro:`!Py_HASH_FNV` 和 :c:macro:`!Py_HASH_SIPHASH24`。" + +#: ../../c-api/hash.rst:43 +msgid "Add :c:macro:`!Py_HASH_SIPHASH13`." +msgstr "新增 :c:macro:`!Py_HASH_SIPHASH13`。" + +#: ../../c-api/hash.rst:49 +msgid "" +"Buffers of length in range ``[1, Py_HASH_CUTOFF)`` are hashed using DJBX33A " +"instead of the algorithm described by :c:macro:`Py_HASH_ALGORITHM`." +msgstr "" + +#: ../../c-api/hash.rst:52 +msgid "A :c:macro:`!Py_HASH_CUTOFF` of 0 disables the optimization." +msgstr "將 :c:macro:`!Py_HASH_CUTOFF` 設為 0 可停用此最佳化。" + +#: ../../c-api/hash.rst:53 +msgid "" +":c:macro:`!Py_HASH_CUTOFF` must be non-negative and less or equal than 7." +msgstr ":c:macro:`!Py_HASH_CUTOFF` 必須為非負且小於或等於 7。" + +#: ../../c-api/hash.rst:55 +msgid "" +"32-bit platforms should use a cutoff smaller than 64-bit platforms because " +"it is easier to create colliding strings. A cutoff of 7 on 64-bit platforms " +"and 5 on 32-bit platforms should provide a decent safety margin." +msgstr "" + +#: ../../c-api/hash.rst:59 +msgid "This corresponds to the :data:`sys.hash_info.cutoff` constant." +msgstr "這對應到 :data:`sys.hash_info.cutoff` 常數。" + +#: ../../c-api/hash.rst:66 msgid "" "The `Mersenne prime `_ ``P = " "2**n -1``, used for numeric hash scheme." @@ -42,53 +93,77 @@ msgstr "" "用於數值雜湊方案的\\ `梅森質數 (Mersenne prime) `_ ``P = 2**n -1``。" -#: ../../c-api/hash.rst:28 +#: ../../c-api/hash.rst:69 +msgid "This corresponds to the :data:`sys.hash_info.modulus` constant." +msgstr "這對應到 :data:`sys.hash_info.modulus` 常數。" + +#: ../../c-api/hash.rst:76 msgid "The exponent ``n`` of ``P`` in :c:macro:`PyHASH_MODULUS`." msgstr ":c:macro:`PyHASH_MODULUS` 中 ``P`` 的指數 ``n``。" -#: ../../c-api/hash.rst:34 +#: ../../c-api/hash.rst:83 msgid "Prime multiplier used in string and various other hashes." msgstr "用於字串和其他各種雜湊的質數乘數 (prime multiplier)。" -#: ../../c-api/hash.rst:40 +#: ../../c-api/hash.rst:90 msgid "The hash value returned for a positive infinity." msgstr "正無窮大回傳的雜湊值。" -#: ../../c-api/hash.rst:46 +#: ../../c-api/hash.rst:92 +msgid "This corresponds to the :data:`sys.hash_info.inf` constant." +msgstr "這對應到 :data:`sys.hash_info.inf` 常數。" + +#: ../../c-api/hash.rst:99 msgid "The multiplier used for the imaginary part of a complex number." msgstr "用於複數虛數部分的乘數。" -#: ../../c-api/hash.rst:52 +#: ../../c-api/hash.rst:101 +msgid "This corresponds to the :data:`sys.hash_info.imag` constant." +msgstr "這對應到 :data:`sys.hash_info.imag` 常數。" + +#: ../../c-api/hash.rst:108 msgid "Hash function definition used by :c:func:`PyHash_GetFuncDef`." msgstr ":c:func:`PyHash_GetFuncDef` 所使用的雜湊函式定義。" -#: ../../c-api/hash.rst:56 +#: ../../c-api/hash.rst:112 msgid "Hash function." msgstr "雜湊函式。" -#: ../../c-api/hash.rst:60 +#: ../../c-api/hash.rst:116 msgid "Hash function name (UTF-8 encoded string)." msgstr "雜湊函式名稱(UTF-8 編碼字串)。" -#: ../../c-api/hash.rst:64 +#: ../../c-api/hash.rst:118 +msgid "This corresponds to the :data:`sys.hash_info.algorithm` constant." +msgstr "這對應到 :data:`sys.hash_info.algorithm` 常數。" + +#: ../../c-api/hash.rst:122 msgid "Internal size of the hash value in bits." msgstr "雜湊值的內部大小(以位元為單位)。" -#: ../../c-api/hash.rst:68 +#: ../../c-api/hash.rst:124 +msgid "This corresponds to the :data:`sys.hash_info.hash_bits` constant." +msgstr "這對應到 :data:`sys.hash_info.hash_bits` 常數。" + +#: ../../c-api/hash.rst:128 msgid "Size of seed input in bits." msgstr "Seed 輸入的大小(以位元為單位)。" -#: ../../c-api/hash.rst:75 +#: ../../c-api/hash.rst:130 +msgid "This corresponds to the :data:`sys.hash_info.seed_bits` constant." +msgstr "這對應到 :data:`sys.hash_info.seed_bits` 常數。" + +#: ../../c-api/hash.rst:137 msgid "Get the hash function definition." msgstr "取得雜湊函式定義。" -#: ../../c-api/hash.rst:78 +#: ../../c-api/hash.rst:140 msgid ":pep:`456` \"Secure and interchangeable hash algorithm\"." msgstr "" ":pep:`456`\\ 「安全且可交替使用的雜湊演算法 (Secure and interchangeable hash " "algorithm)」。" -#: ../../c-api/hash.rst:85 +#: ../../c-api/hash.rst:147 msgid "" "Hash a pointer value: process the pointer value as an integer (cast it to " "``uintptr_t`` internally). The pointer is not dereferenced." @@ -96,11 +171,33 @@ msgstr "" "雜湊指標值:將指標值作為整數處理(在內部轉型為 ``uintptr_t``)。指標不會被取" "值 (dereference)。" -#: ../../c-api/hash.rst:88 +#: ../../c-api/hash.rst:150 msgid "The function cannot fail: it cannot return ``-1``." msgstr "此函式不會失敗:它不會回傳 ``-1``。" -#: ../../c-api/hash.rst:94 +#: ../../c-api/hash.rst:157 +msgid "" +"Compute and return the hash value of a buffer of *len* bytes starting at " +"address *ptr*. The hash is guaranteed to match that of :class:`bytes`, :" +"class:`memoryview`, and other built-in objects that implement the :ref:" +"`buffer protocol `." +msgstr "" + +#: ../../c-api/hash.rst:162 +msgid "" +"Use this function to implement hashing for immutable objects whose :c:member:" +"`~PyTypeObject.tp_richcompare` function compares to another object's buffer." +msgstr "" + +#: ../../c-api/hash.rst:166 +msgid "*len* must be greater than or equal to ``0``." +msgstr "*len* 必須大於或等於 ``0``。" + +#: ../../c-api/hash.rst:168 +msgid "This function always succeeds." +msgstr "此函式總是會成功執行。" + +#: ../../c-api/hash.rst:175 msgid "" "Generic hashing function that is meant to be put into a type object's " "``tp_hash`` slot. Its result only depends on the object's identity." @@ -108,6 +205,6 @@ msgstr "" "泛用雜湊函式,旨在放入型別物件的 ``tp_hash`` 插槽中。其結果僅取決於物件的識別" "性。" -#: ../../c-api/hash.rst:99 +#: ../../c-api/hash.rst:180 msgid "In CPython, it is equivalent to :c:func:`Py_HashPointer`." msgstr "在 CPython 中,它等價於 :c:func:`Py_HashPointer`。" diff --git a/c-api/import.po b/c-api/import.po index 8f830d9e96d..fa6dd95b735 100644 --- a/c-api/import.po +++ b/c-api/import.po @@ -1,16 +1,16 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Ching-Lung Chuang, 2015 +# Matt Wang , 2025 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-10-10 00:13+0000\n" -"PO-Revision-Date: 2018-05-23 14:06+0000\n" -"Last-Translator: Adrian Liaw \n" +"POT-Creation-Date: 2025-11-25 00:13+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-" "tw)\n" "Language: zh_TW\n" @@ -28,10 +28,12 @@ msgid "" "This is a wrapper around :c:func:`PyImport_Import()` which takes a :c:expr:" "`const char *` as an argument instead of a :c:expr:`PyObject *`." 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 "" +msgstr "這個函式是 :c:func:`PyImport_ImportModule` 的已棄用別名。" #: ../../c-api/import.rst:23 msgid "" @@ -40,6 +42,9 @@ msgid "" "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." @@ -50,6 +55,7 @@ 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 msgid "" @@ -58,12 +64,16 @@ msgid "" "`__import__`, the return value when a submodule of a package was requested " "is normally the top-level package, unless a non-empty *fromlist* was given." msgstr "" +"回傳值是對引入的模組或頂層套件的新參照,或者是 ``NULL``,失敗時會設定例外。就" +"像 :func:`__import__` 一樣,當要求一個套件的子模組時,回傳值通常是頂層套件," +"除非給定一個非空的 *fromlist*。" #: ../../c-api/import.rst:46 msgid "" "Failing imports remove incomplete module objects, like with :c:func:" "`PyImport_ImportModule`." msgstr "" +"失敗的引入會移除不完整的模組物件,就像 :c:func:`PyImport_ImportModule` 一樣。" #: ../../c-api/import.rst:52 msgid "" @@ -71,16 +81,20 @@ msgid "" "function :func:`__import__`, as the standard :func:`__import__` function " "calls this function directly." msgstr "" +"引入一個模組。這最好透過參考內建的 Python 函式 :func:`__import__` 來說明,因" +"為標準的 :func:`__import__` 函式會直接呼叫這個函式。" #: ../../c-api/import.rst:66 msgid "" "Similar to :c:func:`PyImport_ImportModuleLevelObject`, but the name is a " "UTF-8 encoded string instead of a Unicode object." msgstr "" +"類似於 :c:func:`PyImport_ImportModuleLevelObject`,但名稱是 UTF-8 編碼字串," +"而不是 Unicode 物件。" #: ../../c-api/import.rst:69 msgid "Negative values for *level* are no longer accepted." -msgstr "" +msgstr "不再接受負的 *level* 值。" #: ../../c-api/import.rst:74 msgid "" @@ -90,20 +104,26 @@ msgid "" "current globals. This means that the import is done using whatever import " "hooks are installed in the current environment." msgstr "" +"這是一個較高階的介面,用來呼叫目前的「引入掛勾函式 (import hook function)」" +"(明確的 *level* 為 0,表示絕對引入 (absolute import))。它從目前全域變數的 " +"``__builtins__`` 中呼叫 :func:`__import__` 函式。這表示引入是使用目前環境所安" +"裝的引入掛勾來完成的。" #: ../../c-api/import.rst:80 msgid "This function always uses absolute imports." -msgstr "" +msgstr "此函式總是使用絕對引入。" #: ../../c-api/import.rst:85 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)." msgstr "" +"重新載入一個模組。回傳重新載入模組的新參照,或在失敗時回傳 ``NULL`` 並設定例" +"外(在這種情況下模組仍然存在)。" #: ../../c-api/import.rst:91 msgid "Return the module object corresponding to a module name." -msgstr "" +msgstr "回傳與模組名稱對應的模組物件。" #: ../../c-api/import.rst:93 msgid "" @@ -111,16 +131,20 @@ msgid "" "modules dictionary if there's one there, and if not, create a new one and " "insert it in the modules dictionary." msgstr "" +"*name* 引數的形式可以是 ``package.module``。首先檢查模組字典中是否有,如果沒" +"有,則建立新的模組並插入模組字典中。" #: ../../c-api/import.rst:97 msgid "" "Return a :term:`strong reference` to the module on success. Return ``NULL`` " "with an exception set on failure." msgstr "" +"成功時回傳模組的\\ :term:`強參照 `。失敗時回傳 ``NULL`` 並" +"設定例外。" #: ../../c-api/import.rst:100 msgid "The module name *name* is decoded from UTF-8." -msgstr "" +msgstr "模組名稱 *name* 是以 UTF-8 解碼。" #: ../../c-api/import.rst:102 msgid "" @@ -130,18 +154,25 @@ msgid "" "structures implied by a dotted name for *name* are not created if not " "already present." msgstr "" +"這個函式不會載入或引入模組;如果模組尚未載入,你將會得到一個空的模組物件。使" +"用 :c:func:`PyImport_ImportModule` 或其變體來引入一個模組。如果尚未存在,則不" +"會建立由 *name* 的點名稱 (dotted name) 所隱含的套件結構。" #: ../../c-api/import.rst:113 msgid "" "Similar to :c:func:`PyImport_AddModuleRef`, but return a :term:`borrowed " "reference` and *name* is a Python :class:`str` object." msgstr "" +"類似於 :c:func:`PyImport_AddModuleRef`,但是會回傳一個\\ :term:`借用參照 " +"`\\ 且 *name* 為 Python 的 :class:`str` 物件。" #: ../../c-api/import.rst:121 msgid "" "Similar to :c:func:`PyImport_AddModuleRef`, but return a :term:`borrowed " "reference`." msgstr "" +"類似於 :c:func:`PyImport_AddModuleRef`,但是會回傳一個\\ :term:`借用參照 " +"`。" #: ../../c-api/import.rst:129 msgid "" @@ -156,6 +187,13 @@ msgid "" "know that the module object is an unknown (and probably damaged with respect " "to the module author's intents) state." msgstr "" +"給定一個模組名稱(可能為 ``package.module`` 的形式),以及一個從 Python 位元" +"組碼檔讀取或從內建函式 :func:`compile` 取得的程式碼物件,載入模組。回傳模組物" +"件的新參照,如果發生錯誤,則回傳 ``NULL`` 並設定例外。在出錯的情況下,*name* " +"會從 :data:`sys.modules` 中移除,即使 *name* 在進入 :c:func:" +"`PyImport_ExecCodeModule` 時已經在 :data:`sys.modules` 中。在 :data:`sys." +"modules` 中留下未完全初始化的模組是很危險的,因為這種模組的引入無法知道模組物" +"件處於未知狀態(且相對於模組作者的意圖,很可能已經損壞)。" #: ../../c-api/import.rst:139 msgid "" @@ -164,6 +202,10 @@ msgid "" "will be set to the module's :attr:`!__loader__` (if set) and to an instance " "of :class:`~importlib.machinery.SourceFileLoader` otherwise." msgstr "" +"如果尚未設定,模組的 :attr:`~module.__spec__` 和 :attr:`~module.__loader__` " +"將會被設定為適當的值。規格的載入器將被設定為模組的 :attr:`!__loader__`\\ (如" +"果有設定),否則將被設定為 :class:`~importlib.machinery.SourceFileLoader` 的" +"實例。" #: ../../c-api/import.rst:144 msgid "" @@ -171,40 +213,52 @@ msgid "" "object's :attr:`~codeobject.co_filename`. If applicable, :attr:`~module." "__cached__` will also be set." msgstr "" +"模組的 :attr:`~module.__file__` 屬性將會設定為程式碼物件的 :attr:" +"`~codeobject.co_filename`。如果適用,:attr:`~module.__cached__` 也會被設定。" #: ../../c-api/import.rst:148 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." msgstr "" +"如果模組已經被引入,這個函式會重新載入模組。請參閱 :c:func:" +"`PyImport_ReloadModule` 以取得重新載入模組的預期方法。" #: ../../c-api/import.rst:151 msgid "" "If *name* points to a dotted name of the form ``package.module``, any " "package structures not already created will still not be created." msgstr "" +"如果 *name* 指向形式為 ``package.module`` 的點名稱,則任何尚未建立的套件結構" +"仍不會被建立。" #: ../../c-api/import.rst:154 msgid "" "See also :c:func:`PyImport_ExecCodeModuleEx` and :c:func:" "`PyImport_ExecCodeModuleWithPathnames`." msgstr "" +"另請參閱 :c:func:`PyImport_ExecCodeModuleEx` 及 :c:func:" +"`PyImport_ExecCodeModuleWithPathnames`。" #: ../../c-api/import.rst:157 msgid "" "The setting of :attr:`~module.__cached__` and :attr:`~module.__loader__` is " "deprecated. See :class:`~importlib.machinery.ModuleSpec` for alternatives." msgstr "" +":attr:`~module.__cached__` 和 :attr:`~module.__loader__` 的設定已被棄用。請參" +"閱 :class:`~importlib.machinery.ModuleSpec` 以取得替代方案。" #: ../../c-api/import.rst:165 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``." msgstr "" +"類似於 :c:func:`PyImport_ExecCodeModule`,但是如果 *pathname* 不是 ``NULL``," +"模組物件的 :attr:`~module.__file__` 屬性會被設定為 *pathname*。" #: ../../c-api/import.rst:168 msgid "See also :c:func:`PyImport_ExecCodeModuleWithPathnames`." -msgstr "也請見 :c:func:`PyImport_ExecCodeModuleWithPathnames`。" +msgstr "另請參閱 :c:func:`PyImport_ExecCodeModuleWithPathnames`。" #: ../../c-api/import.rst:173 msgid "" @@ -212,12 +266,17 @@ msgid "" "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." msgstr "" +"類似於 :c:func:`PyImport_ExecCodeModuleEx`,但是如果 *cpathname* 不是 " +"``NULL``,模組物件的 :attr:`~module.__cached__` 屬性會被設定為 *cpathname*。" +"在這三個函式中,這是首選的函式。" #: ../../c-api/import.rst:179 msgid "" "Setting :attr:`~module.__cached__` is deprecated. See :class:`~importlib." "machinery.ModuleSpec` for alternatives." msgstr "" +"設定 :attr:`~module.__cached__` 已被棄用。請參閱 :class:`~importlib." +"machinery.ModuleSpec` 以取得替代方案。" #: ../../c-api/import.rst:186 msgid "" @@ -226,12 +285,17 @@ msgid "" "what the value for *pathname* should be from *cpathname* if the former is " "set to ``NULL``." msgstr "" +"類似於 :c:func:`PyImport_ExecCodeModuleObject`,但是 *name*、*pathname* 和 " +"*cpathname* 是 UTF-8 編碼的字串。如果 *pathname* 被設定為 ``NULL``,也會嘗試" +"從 *cpathname* 中找出 *pathname* 的值應該是什麼。" #: ../../c-api/import.rst:192 msgid "" "Uses :func:`!imp.source_from_cache` in calculating the source path if only " "the bytecode path is provided." msgstr "" +"如果只提供了位元組碼路徑,則在計算原始碼路徑時使用 :func:`!imp." +"source_from_cache`。" #: ../../c-api/import.rst:195 msgid "No longer uses the removed :mod:`!imp` module." @@ -243,6 +307,9 @@ msgid "" "file). The magic number should be present in the first four bytes of the " "bytecode file, in little-endian byte order. Returns ``-1`` on error." msgstr "" +"回傳 Python 位元組碼檔案(也稱為 :file:`.pyc` 檔案)的魔術數字(magic " +"number)。魔術數字應該出現在位元組碼檔案的前四個位元組,以小端序(little-" +"endian)位元組順序排列。錯誤時會回傳 ``-1``。" #: ../../c-api/import.rst:205 msgid "Return value of ``-1`` upon failure." @@ -254,12 +321,16 @@ msgid "" "names. Keep in mind that the value at ``sys.implementation.cache_tag`` is " "authoritative and should be used instead of this function." msgstr "" +"回傳 :pep:`3147` 格式 Python 位元組碼檔名的魔術標籤字串。請記住,``sys." +"implementation.cache_tag`` 的值是權威的,應該使用它來取代這個函式。" #: ../../c-api/import.rst:219 msgid "" "Return the dictionary used for the module administration (a.k.a. ``sys." "modules``). Note that this is a per-interpreter variable." msgstr "" +"回傳用於模組管理的字典(也稱為 ``sys.modules``)。請注意,這是一個針對每個直" +"譯器的變數 (per-interpreter variable)。" #: ../../c-api/import.rst:224 msgid "" @@ -267,6 +338,8 @@ msgid "" "not been imported yet then returns ``NULL`` but does not set an error. " "Returns ``NULL`` and sets an error if the lookup failed." msgstr "" +"回傳已以給定名稱引入的模組。如果模組尚未引入,則會回傳 ``NULL`` 但不會設定錯" +"誤。如果查找失敗,則回傳 ``NULL`` 並設定錯誤。" #: ../../c-api/import.rst:232 msgid "" @@ -278,6 +351,12 @@ msgid "" "finder for this path item. Cache the result in :data:`sys." "path_importer_cache`. Return a new reference to the finder object." msgstr "" +"回傳 :data:`sys.path`/:attr:`!pkg.__path__` 項 *path* 的查找器物件 (finder " +"object),可能的方式是從 :data:`sys.path_importer_cache` 字典取得。如果它還沒" +"有被快取,就遍歷 :data:`sys.path_hooks` 直到找到可以處理路徑項的掛勾。如果沒" +"有掛勾可以處理,則回傳 ``None``;這會告訴我們的呼叫者 :term:`path based " +"finder` 找不到這個路徑項的查找器。將結果快取到 :data:`sys." +"path_importer_cache`。回傳查找器物件的新參照。" #: ../../c-api/import.rst:243 msgid "" @@ -287,16 +366,22 @@ msgid "" "`PyImport_ImportModule`. (Note the misnomer --- this function would reload " "the module if it was already imported.)" msgstr "" +"載入一個名為 *name* 的凍結模組。成功則回傳 ``1``,找不到模組則回傳 ``0``,初" +"始化失敗則回傳 ``-1`` 並設定例外。要在成功載入時存取引入的模組,請使用 :c:" +"func:`PyImport_ImportModule`。(請注意這個名稱並不恰當 --- 如果模組已經被引" +"入,這個函式會重新載入模組)。" #: ../../c-api/import.rst:251 msgid "The ``__file__`` attribute is no longer set on the module." -msgstr "" +msgstr "不會再於模組設定 ``__file__`` 屬性。" #: ../../c-api/import.rst:257 msgid "" "Similar to :c:func:`PyImport_ImportFrozenModuleObject`, but the name is a " "UTF-8 encoded string instead of a Unicode object." msgstr "" +"類似於 :c:func:`PyImport_ImportFrozenModuleObject`,但名稱是 UTF-8 編碼字串," +"而不是 Unicode 物件。" #: ../../c-api/import.rst:265 msgid "" @@ -305,6 +390,9 @@ msgid "" "Python source distribution). Its definition, found in :file:`Include/import." "h`, is::" msgstr "" +"這是由 :program:`freeze` 工具程式產生的凍結模組描述器的結構型別定義(請參閱 " +"Python 原始碼發行版中的 :file:`Tools/freeze/`)。它的定義在 :file:`Include/" +"import.h` 中,為: ::" #: ../../c-api/import.rst:270 msgid "" @@ -327,6 +415,8 @@ 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." msgstr "" +"新的 ``is_package`` 欄位指出模組是否為套件。這取代了將 ``size`` 欄位設定為負" +"值的方式。" #: ../../c-api/import.rst:283 msgid "" @@ -336,6 +426,9 @@ msgid "" "could play tricks with this to provide a dynamically created collection of " "frozen modules." msgstr "" +"這個指標會被初始化為指向一個 :c:struct:`_frozen` 記錄的陣列,以一個其成員都" +"是 ``NULL`` 或 0 的記錄為結尾。當一個凍結的模組被引入時,它會在這個表格中被搜" +"尋。第三方程式碼可以利用這一點來提供一個動態建立的凍結模組集合。" #: ../../c-api/import.rst:291 msgid "" @@ -346,6 +439,10 @@ msgid "" "function called on the first attempted import. This should be called " "before :c:func:`Py_Initialize`." msgstr "" +"新增單一模組到現有的內建模組表格。這是 :c:func:`PyImport_ExtendInittab` 的便" +"利包裝器,如果表格無法擴充會回傳 ``-1``。新的模組可以用 *name* 的名稱引入,並" +"使用函式 *initfunc* 作為第一次嘗試引入時呼叫的初始化函式。這應該在 :c:func:" +"`Py_Initialize` 之前呼叫。" #: ../../c-api/import.rst:301 msgid "" @@ -354,14 +451,17 @@ msgid "" "conjunction with :c:func:`PyImport_ExtendInittab` to provide additional " "built-in modules. The structure consists of two members:" msgstr "" +"描述內建模組列表中單一項目的結構。嵌入 Python 的程式可以使用這些結構的陣列" +"與 :c:func:`PyImport_ExtendInittab` 結合來提供額外的內建模組。這個結構包含兩" +"個成員:" #: ../../c-api/import.rst:309 msgid "The module name, as an ASCII encoded string." -msgstr "" +msgstr "模組名稱,為 ASCII 編碼的字串。" #: ../../c-api/import.rst:313 msgid "Initialization function for a module built into the interpreter." -msgstr "" +msgstr "內建於直譯器中的模組的初始化函式。" #: ../../c-api/import.rst:318 msgid "" @@ -373,6 +473,11 @@ msgid "" "failure, no modules are added to the internal table. This must be called " "before :c:func:`Py_Initialize`." msgstr "" +"新增一個模組集合到內建模組表格。*newtab* 陣列必須以包含 ``NULL`` 的 :c:" +"member:`~_inittab.name` 欄位的哨兵項目(sentinel entry)結尾;如果沒有提供哨" +"兵值,可能會導致記憶體錯誤。成功時會回傳 ``0``,如果沒有足夠的記憶體可以分配" +"來擴充內部表格則回傳 ``-1``。在失敗的情況下,沒有模組會被加入內部表格。這個函" +"式必須在 :c:func:`Py_Initialize` 之前呼叫。" #: ../../c-api/import.rst:325 msgid "" @@ -380,6 +485,45 @@ msgid "" "or :c:func:`PyImport_ExtendInittab` must be called before each Python " "initialization." msgstr "" +"如果 Python 被多次初始化,:c:func:`PyImport_AppendInittab` 或 :c:func:" +"`PyImport_ExtendInittab` 必須在每次 Python 初始化之前被呼叫。" + +#: ../../c-api/import.rst:332 +msgid "" +"The table of built-in modules used by Python initialization. Do not use this " +"directly; use :c:func:`PyImport_AppendInittab` and :c:func:" +"`PyImport_ExtendInittab` instead." +msgstr "" +"Python 初始化所使用的內建模組表格。請勿直接使用它," +"請改用 :c:func:`PyImport_AppendInittab` 與 :c:func:" +"`PyImport_ExtendInittab`。" + +#: ../../c-api/import.rst:339 +msgid "Import the module *mod_name* and get its attribute *attr_name*." +msgstr "引入模組 *mod_name* 並取得其屬性 *attr_name*。" + +#: ../../c-api/import.rst:341 +msgid "Names must be Python :class:`str` objects." +msgstr "名稱必須是 Python :class:`str` 物件。" + +#: ../../c-api/import.rst:343 +msgid "" +"Helper function combining :c:func:`PyImport_Import` and :c:func:" +"`PyObject_GetAttr`. For example, it can raise :exc:`ImportError` if the " +"module is not found, and :exc:`AttributeError` if the attribute doesn't " +"exist." +msgstr "" +"結合 :c:func:`PyImport_Import` 和 :c:func:`PyObject_GetAttr` 的輔助函式。例" +"如,如果找不到模組,它會引發 :exc:`ImportError`,如果屬性不存在,則會引發 :" +"exc:`AttributeError`。" + +#: ../../c-api/import.rst:352 +msgid "" +"Similar to :c:func:`PyImport_ImportModuleAttr`, but names are UTF-8 encoded " +"strings instead of Python :class:`str` objects." +msgstr "" +"類似於 :c:func:`PyImport_ImportModuleAttr`,但名稱是 UTF-8 編碼字串,而不是 " +"Python :class:`str` 物件。" #: ../../c-api/import.rst:11 msgid "package variable" @@ -411,4 +555,4 @@ msgstr "compile(編譯)" #: ../../c-api/import.rst:263 msgid "freeze utility" -msgstr "freeze utility(凍結工具)" +msgstr "freeze utility(凍結工具程式)" diff --git a/c-api/index.po b/c-api/index.po index 7e0a7df3091..024b9747ea9 100644 --- a/c-api/index.po +++ b/c-api/index.po @@ -1,5 +1,4 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -8,7 +7,7 @@ # Steven Hsu , 2021 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2018-06-26 18:54+0800\n" "PO-Revision-Date: 2021-07-05 21:11+0800\n" diff --git a/c-api/init.po b/c-api/init.po index cc5d9d5c5f8..2932196ad1d 100644 --- a/c-api/init.po +++ b/c-api/init.po @@ -1,13 +1,13 @@ -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Adrian Liaw , 2018 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-08-27 00:15+0000\n" +"POT-Creation-Date: 2025-11-26 00:14+0000\n" "PO-Revision-Date: 2023-04-24 20:49+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -389,7 +389,7 @@ msgstr "" #: ../../c-api/init.rst:217 msgid "Set by the :option:`-I` option." -msgstr "由 :option:`-i` 選項設定。" +msgstr "由 :option:`-I` 選項設定。" #: ../../c-api/init.rst:225 msgid "" @@ -624,12 +624,11 @@ 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:" "`Py_NewInterpreter` below) that were created and not yet destroyed since the " -"last call to :c:func:`Py_Initialize`. Ideally, this frees all memory " -"allocated by the Python interpreter. This is a no-op when called for a " +"last call to :c:func:`Py_Initialize`. This is a no-op when called for a " "second time (without calling :c:func:`Py_Initialize` again first)." msgstr "" -#: ../../c-api/init.rst:424 +#: ../../c-api/init.rst:423 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 " @@ -637,13 +636,22 @@ msgid "" "`Py_RunMain` is running." msgstr "" -#: ../../c-api/init.rst:429 +#: ../../c-api/init.rst:428 msgid "" "Normally the return value is ``0``. If there were errors during finalization " "(flushing buffered data), ``-1`` is returned." msgstr "" -#: ../../c-api/init.rst:433 +#: ../../c-api/init.rst:432 +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 " +"correctly clean up all of the preveiously allocated PyObjects before using " +"them in subsequent calls to :c:func:`Py_Initialize`. Otherwise it could " +"introduce vulnerabilities and incorrect behavior." +msgstr "" + +#: ../../c-api/init.rst:438 msgid "" "This function is provided for a number of reasons. An embedding application " "might want to restart Python without having to restart the application " @@ -654,7 +662,7 @@ msgid "" "Python before exiting from the application." msgstr "" -#: ../../c-api/init.rst:441 +#: ../../c-api/init.rst:446 msgid "" "**Bugs and caveats:** The destruction of modules and objects in modules is " "done in random order; this may cause destructors (:meth:`~object.__del__` " @@ -662,7 +670,8 @@ msgid "" "modules. Dynamically loaded extension modules loaded by Python are not " "unloaded. Small amounts of memory allocated by the Python interpreter may " "not be freed (if you find a leak, please report it). Memory tied up in " -"circular references between objects is not freed. Some memory allocated by " +"circular references between objects is not freed. Interned strings will all " +"be deallocated regardless of their reference count. Some memory allocated by " "extension modules may not be freed. Some extensions may not work properly " "if their initialization routine is called more than once; this can happen if " "an application calls :c:func:`Py_Initialize` and :c:func:`Py_FinalizeEx` " @@ -673,7 +682,7 @@ msgid "" "stdout and stderr files." msgstr "" -#: ../../c-api/init.rst:456 +#: ../../c-api/init.rst:462 msgid "" "Raises an :ref:`auditing event ` ``cpython." "_PySys_ClearAuditHooks`` with no arguments." @@ -681,20 +690,20 @@ msgstr "" "引發一個不附帶引數的\\ :ref:`稽核事件 ` ``cpython." "_PySys_ClearAuditHooks``。" -#: ../../c-api/init.rst:463 +#: ../../c-api/init.rst:469 msgid "" "This is a backwards-compatible version of :c:func:`Py_FinalizeEx` that " "disregards the return value." msgstr "" -#: ../../c-api/init.rst:469 +#: ../../c-api/init.rst:475 msgid "" "Similar to :c:func:`Py_Main` but *argv* is an array of bytes strings, " "allowing the calling application to delegate the text decoding step to the " "CPython runtime." msgstr "" -#: ../../c-api/init.rst:478 +#: ../../c-api/init.rst:484 msgid "" "The main program for the standard interpreter, encapsulating a full " "initialization/finalization cycle, as well as additional behaviour to " @@ -703,14 +712,14 @@ msgid "" "cmdline`." msgstr "" -#: ../../c-api/init.rst:484 +#: ../../c-api/init.rst:490 msgid "" "This is made available for programs which wish to support the full CPython " "command line interface, rather than just embedding a Python runtime in a " "larger application." msgstr "" -#: ../../c-api/init.rst:488 +#: ../../c-api/init.rst:494 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 " @@ -720,20 +729,20 @@ msgid "" "pointed to by the argument list are not modified)." msgstr "" -#: ../../c-api/init.rst:495 +#: ../../c-api/init.rst:501 msgid "" "The return value is ``2`` if the argument list does not represent a valid " "Python command line, and otherwise the same as :c:func:`Py_RunMain`." msgstr "" -#: ../../c-api/init.rst:498 +#: ../../c-api/init.rst:504 msgid "" "In terms of the CPython runtime configuration APIs documented in the :ref:" "`runtime configuration ` section (and without accounting for " "error handling), ``Py_Main`` is approximately equivalent to::" msgstr "" -#: ../../c-api/init.rst:502 +#: ../../c-api/init.rst:508 msgid "" "PyConfig config;\n" "PyConfig_InitPythonConfig(&config);\n" @@ -744,7 +753,7 @@ msgid "" "Py_RunMain();" msgstr "" -#: ../../c-api/init.rst:510 +#: ../../c-api/init.rst:516 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:" @@ -757,11 +766,11 @@ msgid "" "first initialized)." msgstr "" -#: ../../c-api/init.rst:523 +#: ../../c-api/init.rst:529 msgid "Executes the main module in a fully configured CPython runtime." msgstr "" -#: ../../c-api/init.rst:525 +#: ../../c-api/init.rst:531 msgid "" "Executes the command (:c:member:`PyConfig.run_command`), the script (:c:" "member:`PyConfig.run_filename`) or the module (:c:member:`PyConfig." @@ -770,7 +779,7 @@ msgid "" "``__main__`` module's global namespace." msgstr "" -#: ../../c-api/init.rst:531 +#: ../../c-api/init.rst:537 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 " @@ -778,7 +787,7 @@ msgid "" "any other unhandled exception." msgstr "" -#: ../../c-api/init.rst:536 +#: ../../c-api/init.rst:542 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 " @@ -789,41 +798,41 @@ msgid "" "status of a :exc:`SystemExit`, as specified above." msgstr "" -#: ../../c-api/init.rst:544 +#: ../../c-api/init.rst:550 msgid "" "This function always finalizes the Python interpreter before it returns." msgstr "" -#: ../../c-api/init.rst:546 +#: ../../c-api/init.rst:552 msgid "" "See :ref:`Python Configuration ` for an example of a " "customized Python that always runs in isolated mode using :c:func:" "`Py_RunMain`." msgstr "" -#: ../../c-api/init.rst:552 +#: ../../c-api/init.rst:558 msgid "" "Register an :mod:`atexit` callback for the target interpreter *interp*. This " "is similar to :c:func:`Py_AtExit`, but takes an explicit interpreter and " "data pointer for the callback." msgstr "" -#: ../../c-api/init.rst:556 -msgid "The :term:`GIL` must be held for *interp*." +#: ../../c-api/init.rst:562 +msgid "There must be an :term:`attached thread state` for *interp*." msgstr "" -#: ../../c-api/init.rst:561 +#: ../../c-api/init.rst:567 msgid "Process-wide parameters" msgstr "" -#: ../../c-api/init.rst:571 +#: ../../c-api/init.rst:577 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "program_name` should be used instead, see :ref:`Python Initialization " "Configuration `." msgstr "" -#: ../../c-api/init.rst:575 +#: ../../c-api/init.rst:581 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 " @@ -837,37 +846,39 @@ msgid "" "this storage." msgstr "" -#: ../../c-api/init.rst:586 ../../c-api/init.rst:828 ../../c-api/init.rst:864 -#: ../../c-api/init.rst:890 +#: ../../c-api/init.rst:592 ../../c-api/init.rst:840 ../../c-api/init.rst:876 +#: ../../c-api/init.rst:902 msgid "" "Use :c:func:`Py_DecodeLocale` to decode a bytes string to get a :c:expr:" "`wchar_t*` string." msgstr "" -#: ../../c-api/init.rst:594 +#: ../../c-api/init.rst:600 msgid "" "Return the program name set with :c:member:`PyConfig.program_name`, or the " "default. The returned string points into static storage; the caller should " "not modify its value." msgstr "" -#: ../../c-api/init.rst:598 ../../c-api/init.rst:620 ../../c-api/init.rst:666 -#: ../../c-api/init.rst:688 ../../c-api/init.rst:714 ../../c-api/init.rst:902 +#: ../../c-api/init.rst:604 ../../c-api/init.rst:627 ../../c-api/init.rst:675 +#: ../../c-api/init.rst:699 ../../c-api/init.rst:726 ../../c-api/init.rst:914 msgid "" "This function should not be called before :c:func:`Py_Initialize`, otherwise " "it returns ``NULL``." msgstr "此函式不應該在 :c:func:`Py_Initialize` 之前呼叫,否則會回傳 ``NULL``。" -#: ../../c-api/init.rst:601 ../../c-api/init.rst:623 ../../c-api/init.rst:669 -#: ../../c-api/init.rst:691 ../../c-api/init.rst:719 ../../c-api/init.rst:905 +#: ../../c-api/init.rst:607 ../../c-api/init.rst:630 ../../c-api/init.rst:678 +#: ../../c-api/init.rst:702 ../../c-api/init.rst:731 ../../c-api/init.rst:917 msgid "It now returns ``NULL`` if called before :c:func:`Py_Initialize`." msgstr "如果在 :c:func:`Py_Initialize` 之前呼叫,現在會回傳 ``NULL``。" -#: ../../c-api/init.rst:604 ../../c-api/init.rst:694 -msgid "Get :data:`sys.executable` instead." +#: ../../c-api/init.rst:610 ../../c-api/init.rst:705 +msgid "" +"Use :c:func:`PyConfig_Get(\"executable\") ` (:data:`sys." +"executable`) instead." msgstr "" -#: ../../c-api/init.rst:610 +#: ../../c-api/init.rst:617 msgid "" "Return the *prefix* for installed platform-independent files. This is " "derived through a number of complicated rules from the program name set " @@ -881,13 +892,15 @@ msgid "" "See also the next function." msgstr "" -#: ../../c-api/init.rst:626 +#: ../../c-api/init.rst:633 msgid "" -"Get :data:`sys.base_prefix` instead, or :data:`sys.prefix` if :ref:`virtual " -"environments ` need to be handled." +"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-api/init.rst:633 +#: ../../c-api/init.rst:642 msgid "" "Return the *exec-prefix* for installed platform-*dependent* files. This is " "derived through a number of complicated rules from the program name set " @@ -901,7 +914,7 @@ msgid "" "useful on Unix." msgstr "" -#: ../../c-api/init.rst:644 +#: ../../c-api/init.rst:653 msgid "" "Background: The exec-prefix differs from the prefix when platform dependent " "files (such as executables and shared libraries) are installed in a " @@ -910,7 +923,7 @@ msgid "" "independent may be installed in :file:`/usr/local`." msgstr "" -#: ../../c-api/init.rst:650 +#: ../../c-api/init.rst:659 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 " @@ -924,7 +937,7 @@ msgid "" "independent from the Python version by which they were compiled!)." msgstr "" -#: ../../c-api/init.rst:661 +#: ../../c-api/init.rst:670 msgid "" "System administrators will know how to configure the :program:`mount` or :" "program:`automount` programs to share :file:`/usr/local` between platforms " @@ -932,13 +945,15 @@ msgid "" "platform." msgstr "" -#: ../../c-api/init.rst:672 +#: ../../c-api/init.rst:681 msgid "" -"Get :data:`sys.base_exec_prefix` instead, or :data:`sys.exec_prefix` if :ref:" -"`virtual environments ` need to be handled." +"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-api/init.rst:682 +#: ../../c-api/init.rst:693 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 " @@ -947,7 +962,7 @@ msgid "" "available to Python code as ``sys.executable``." msgstr "" -#: ../../c-api/init.rst:704 +#: ../../c-api/init.rst:716 msgid "" "Return the default module search path; this is computed from the program " "name (set by :c:member:`PyConfig.program_name`) and some environment " @@ -960,21 +975,23 @@ msgid "" "for loading modules." msgstr "" -#: ../../c-api/init.rst:722 -msgid "Get :data:`sys.path` instead." +#: ../../c-api/init.rst:734 +msgid "" +"Use :c:func:`PyConfig_Get(\"module_search_paths\") ` (:data:" +"`sys.path`) instead." msgstr "" -#: ../../c-api/init.rst:728 +#: ../../c-api/init.rst:740 msgid "" "Return the version of this Python interpreter. This is a string that looks " "something like ::" msgstr "" -#: ../../c-api/init.rst:731 +#: ../../c-api/init.rst:743 msgid "\"3.0a5+ (py3k:63103M, May 12 2008, 00:53:55) \\n[GCC 4.2.3]\"" msgstr "\"3.0a5+ (py3k:63103M, May 12 2008, 00:53:55) \\n[GCC 4.2.3]\"" -#: ../../c-api/init.rst:735 +#: ../../c-api/init.rst:747 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 " @@ -983,11 +1000,11 @@ msgid "" "version`." msgstr "" -#: ../../c-api/init.rst:740 +#: ../../c-api/init.rst:752 msgid "See also the :c:var:`Py_Version` constant." msgstr "另請參閱 :c:var:`Py_Version` 常數。" -#: ../../c-api/init.rst:747 +#: ../../c-api/init.rst:759 msgid "" "Return the platform identifier for the current platform. On Unix, this is " "formed from the \"official\" name of the operating system, converted to " @@ -998,50 +1015,50 @@ msgid "" "available to Python code as ``sys.platform``." msgstr "" -#: ../../c-api/init.rst:758 +#: ../../c-api/init.rst:770 msgid "" "Return the official copyright string for the current Python version, for " "example" msgstr "" -#: ../../c-api/init.rst:760 +#: ../../c-api/init.rst:772 msgid "``'Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam'``" msgstr "``'Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam'``" -#: ../../c-api/init.rst:764 +#: ../../c-api/init.rst:776 msgid "" "The returned string points into static storage; the caller should not modify " "its value. The value is available to Python code as ``sys.copyright``." msgstr "" -#: ../../c-api/init.rst:770 +#: ../../c-api/init.rst:782 msgid "" "Return an indication of the compiler used to build the current Python " "version, in square brackets, for example::" msgstr "" -#: ../../c-api/init.rst:773 +#: ../../c-api/init.rst:785 msgid "\"[GCC 2.7.2.2]\"" msgstr "\"[GCC 2.7.2.2]\"" -#: ../../c-api/init.rst:777 ../../c-api/init.rst:791 +#: ../../c-api/init.rst:789 ../../c-api/init.rst:803 msgid "" "The returned string points into static storage; the caller should not modify " "its value. The value is available to Python code as part of the variable " "``sys.version``." msgstr "" -#: ../../c-api/init.rst:784 +#: ../../c-api/init.rst:796 msgid "" "Return information about the sequence number and build date and time of the " "current Python interpreter instance, for example ::" msgstr "" -#: ../../c-api/init.rst:787 +#: ../../c-api/init.rst:799 msgid "\"#67, Aug 1 1997, 22:34:28\"" msgstr "\"#67, Aug 1 1997, 22:34:28\"" -#: ../../c-api/init.rst:803 +#: ../../c-api/init.rst:815 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "argv`, :c:member:`PyConfig.parse_argv` and :c:member:`PyConfig.safe_path` " @@ -1049,7 +1066,7 @@ msgid "" "config>`." msgstr "" -#: ../../c-api/init.rst:808 +#: ../../c-api/init.rst:820 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 " @@ -1060,84 +1077,84 @@ msgid "" "fatal condition is signalled using :c:func:`Py_FatalError`." msgstr "" -#: ../../c-api/init.rst:816 +#: ../../c-api/init.rst:828 msgid "" "If *updatepath* is zero, this is all the function does. If *updatepath* is " "non-zero, the function also modifies :data:`sys.path` according to the " "following algorithm:" msgstr "" -#: ../../c-api/init.rst:820 +#: ../../c-api/init.rst:832 msgid "" "If the name of an existing script is passed in ``argv[0]``, the absolute " "path of the directory where the script is located is prepended to :data:`sys." "path`." msgstr "" -#: ../../c-api/init.rst:823 +#: ../../c-api/init.rst:835 msgid "" "Otherwise (that is, if *argc* is ``0`` or ``argv[0]`` doesn't point to an " "existing file name), an empty string is prepended to :data:`sys.path`, which " "is the same as prepending the current working directory (``\".\"``)." msgstr "" -#: ../../c-api/init.rst:831 ../../c-api/init.rst:867 +#: ../../c-api/init.rst:843 ../../c-api/init.rst:879 msgid "" "See also :c:member:`PyConfig.orig_argv` and :c:member:`PyConfig.argv` " "members of the :ref:`Python Initialization Configuration `." msgstr "" -#: ../../c-api/init.rst:835 +#: ../../c-api/init.rst:847 msgid "" "It is recommended that applications embedding the Python interpreter for " "purposes other than executing a single script pass ``0`` as *updatepath*, " "and update :data:`sys.path` themselves if desired. See :cve:`2008-5983`." msgstr "" -#: ../../c-api/init.rst:840 +#: ../../c-api/init.rst:852 msgid "" "On versions before 3.1.3, you can achieve the same effect by manually " "popping the first :data:`sys.path` element after having called :c:func:" "`PySys_SetArgv`, for example using::" msgstr "" -#: ../../c-api/init.rst:844 +#: ../../c-api/init.rst:856 msgid "PyRun_SimpleString(\"import sys; sys.path.pop(0)\\n\");" msgstr "PyRun_SimpleString(\"import sys; sys.path.pop(0)\\n\");" -#: ../../c-api/init.rst:856 +#: ../../c-api/init.rst:868 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "argv` and :c:member:`PyConfig.parse_argv` should be used instead, see :ref:" "`Python Initialization Configuration `." msgstr "" -#: ../../c-api/init.rst:860 +#: ../../c-api/init.rst:872 msgid "" "This function works like :c:func:`PySys_SetArgvEx` with *updatepath* set to " "``1`` unless the :program:`python` interpreter was started with the :option:" "`-I`." msgstr "" -#: ../../c-api/init.rst:870 +#: ../../c-api/init.rst:882 msgid "The *updatepath* value depends on :option:`-I`." msgstr "" -#: ../../c-api/init.rst:877 +#: ../../c-api/init.rst:889 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "home` should be used instead, see :ref:`Python Initialization Configuration " "`." msgstr "" -#: ../../c-api/init.rst:881 +#: ../../c-api/init.rst:893 msgid "" "Set the default \"home\" directory, that is, the location of the standard " "Python libraries. See :envvar:`PYTHONHOME` for the meaning of the argument " "string." msgstr "" -#: ../../c-api/init.rst:885 +#: ../../c-api/init.rst:897 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 " @@ -1145,26 +1162,29 @@ msgid "" "this storage." msgstr "" -#: ../../c-api/init.rst:898 +#: ../../c-api/init.rst:910 msgid "" "Return the default \"home\", that is, the value set by :c:member:`PyConfig." "home`, or the value of the :envvar:`PYTHONHOME` environment variable if it " "is set." msgstr "" -#: ../../c-api/init.rst:908 +#: ../../c-api/init.rst:920 msgid "" -"Get :c:member:`PyConfig.home` or :envvar:`PYTHONHOME` environment variable " -"instead." -msgstr "改為取得 :c:member:`PyConfig.home` 或 :envvar:`PYTHONHOME` 環境變數。" +"Use :c:func:`PyConfig_Get(\"home\") ` or the :envvar:" +"`PYTHONHOME` environment variable instead." +msgstr "" +"改為使用 :c:func:`PyConfig_Get(\"home\") ` 或 :envvar:" +"`PYTHONHOME` 環境變數。" -#: ../../c-api/init.rst:916 +#: ../../c-api/init.rst:928 msgid "Thread State and the Global Interpreter Lock" msgstr "" -#: ../../c-api/init.rst:923 +#: ../../c-api/init.rst:935 msgid "" -"The Python interpreter is not fully thread-safe. In order to support multi-" +"Unless on a :term:`free-threaded ` build of :term:`CPython`, " +"the Python interpreter is not fully thread-safe. In order to support multi-" "threaded Python programs, there's a global lock, called the :term:`global " "interpreter lock` or :term:`GIL`, that must be held by the current thread " "before it can safely access Python objects. Without the lock, even the " @@ -1174,7 +1194,7 @@ msgid "" "once instead of twice." msgstr "" -#: ../../c-api/init.rst:933 +#: ../../c-api/init.rst:946 msgid "" "Therefore, the rule exists that only the thread that has acquired the :term:" "`GIL` may operate on Python objects or call Python/C API functions. In order " @@ -1184,56 +1204,75 @@ msgid "" "a file, so that other Python threads can run in the meantime." msgstr "" -#: ../../c-api/init.rst:943 +#: ../../c-api/init.rst:956 msgid "" "The Python interpreter keeps some thread-specific bookkeeping information " -"inside a data structure called :c:type:`PyThreadState`. There's also one " -"global variable pointing to the current :c:type:`PyThreadState`: it can be " -"retrieved using :c:func:`PyThreadState_Get`." +"inside a data structure called :c:type:`PyThreadState`, known as a :term:" +"`thread state`. Each OS thread has a thread-local pointer to a :c:type:" +"`PyThreadState`; a thread state referenced by this pointer is considered to " +"be :term:`attached `." +msgstr "" + +#: ../../c-api/init.rst:961 +msgid "" +"A thread can only have one :term:`attached thread state` at a time. An " +"attached thread state is typically analogous with holding the :term:`GIL`, " +"except on :term:`free-threaded ` builds. On builds with " +"the :term:`GIL` enabled, :term:`attaching ` a thread " +"state will block until the :term:`GIL` can be acquired. However, even on " +"builds with the :term:`GIL` disabled, it is still required to have an " +"attached thread state to call most of the C API." +msgstr "" + +#: ../../c-api/init.rst:968 +msgid "" +"In general, there will always be an :term:`attached thread state` when using " +"Python's C API. Only in some specific cases (such as in a :c:macro:" +"`Py_BEGIN_ALLOW_THREADS` block) will the thread not have an attached thread " +"state. If uncertain, check if :c:func:`PyThreadState_GetUnchecked` returns " +"``NULL``." msgstr "" -#: ../../c-api/init.rst:949 -msgid "Releasing the GIL from extension code" +#: ../../c-api/init.rst:974 +msgid "Detaching the thread state from extension code" msgstr "" -#: ../../c-api/init.rst:951 +#: ../../c-api/init.rst:976 msgid "" -"Most extension code manipulating the :term:`GIL` has the following simple " -"structure::" +"Most extension code manipulating the :term:`thread state` has the following " +"simple structure::" msgstr "" -#: ../../c-api/init.rst:954 +#: ../../c-api/init.rst:979 msgid "" "Save the thread state in a local variable.\n" -"Release the global interpreter lock.\n" "... Do some blocking I/O operation ...\n" -"Reacquire the global interpreter lock.\n" "Restore the thread state from the local variable." msgstr "" -#: ../../c-api/init.rst:960 +#: ../../c-api/init.rst:983 msgid "This is so common that a pair of macros exists to simplify it::" msgstr "" -#: ../../c-api/init.rst:962 +#: ../../c-api/init.rst:985 msgid "" "Py_BEGIN_ALLOW_THREADS\n" "... Do some blocking I/O operation ...\n" "Py_END_ALLOW_THREADS" msgstr "" -#: ../../c-api/init.rst:970 +#: ../../c-api/init.rst:993 msgid "" "The :c:macro:`Py_BEGIN_ALLOW_THREADS` macro opens a new block and declares a " "hidden local variable; the :c:macro:`Py_END_ALLOW_THREADS` macro closes the " "block." msgstr "" -#: ../../c-api/init.rst:974 +#: ../../c-api/init.rst:997 msgid "The block above expands to the following code::" msgstr "" -#: ../../c-api/init.rst:976 +#: ../../c-api/init.rst:999 msgid "" "PyThreadState *_save;\n" "\n" @@ -1242,60 +1281,78 @@ msgid "" "PyEval_RestoreThread(_save);" msgstr "" -#: ../../c-api/init.rst:986 +#: ../../c-api/init.rst:1009 +msgid "Here is how these functions work:" +msgstr "" + +#: ../../c-api/init.rst:1011 msgid "" -"Here is how these functions work: the global interpreter lock is used to " -"protect the pointer to the current thread state. When releasing the lock " -"and saving the thread state, the current thread state pointer must be " -"retrieved before the lock is released (since another thread could " -"immediately acquire the lock and store its own thread state in the global " -"variable). Conversely, when acquiring the lock and restoring the thread " -"state, the lock must be acquired before storing the thread state pointer." +"The :term:`attached thread state` holds the :term:`GIL` for the entire " +"interpreter. When detaching the :term:`attached thread state`, the :term:" +"`GIL` is released, allowing other threads to attach a thread state to their " +"own thread, thus getting the :term:`GIL` and can start executing. The " +"pointer to the prior :term:`attached thread state` is stored as a local " +"variable. Upon reaching :c:macro:`Py_END_ALLOW_THREADS`, the thread state " +"that was previously :term:`attached ` is passed to :c:" +"func:`PyEval_RestoreThread`. This function will block until another releases " +"its :term:`thread state `, thus allowing the old :" +"term:`thread state ` to get re-attached and the C API " +"can be called again." msgstr "" -#: ../../c-api/init.rst:995 +#: ../../c-api/init.rst:1021 +msgid "" +"For :term:`free-threaded ` builds, the :term:`GIL` is " +"normally out of the question, but detaching the :term:`thread state " +"` is still required for blocking I/O and long " +"operations. The difference is that threads don't have to wait for the :term:" +"`GIL` to be released to attach their thread state, allowing true multi-core " +"parallelism." +msgstr "" + +#: ../../c-api/init.rst:1027 msgid "" -"Calling system I/O functions is the most common use case for releasing the " -"GIL, but it can also be useful before calling long-running computations " -"which don't need access to Python objects, such as compression or " -"cryptographic functions operating over memory buffers. For example, the " -"standard :mod:`zlib` and :mod:`hashlib` modules release the GIL when " +"Calling system I/O functions is the most common use case for detaching the :" +"term:`thread state `, but it can also be useful " +"before calling long-running computations which don't need access to Python " +"objects, such as compression or cryptographic functions operating over " +"memory buffers. For example, the standard :mod:`zlib` and :mod:`hashlib` " +"modules detach the :term:`thread state ` when " "compressing or hashing data." msgstr "" -#: ../../c-api/init.rst:1006 +#: ../../c-api/init.rst:1038 msgid "Non-Python created threads" msgstr "" -#: ../../c-api/init.rst:1008 +#: ../../c-api/init.rst:1040 msgid "" "When threads are created using the dedicated Python APIs (such as the :mod:" "`threading` module), a thread state is automatically associated to them and " "the code showed above is therefore correct. However, when threads are " "created from C (for example by a third-party library with its own thread " -"management), they don't hold the GIL, nor is there a thread state structure " -"for them." +"management), they don't hold the :term:`GIL`, because they don't have an :" +"term:`attached thread state`." msgstr "" -#: ../../c-api/init.rst:1015 +#: ../../c-api/init.rst:1047 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 " -"must first register these threads with the interpreter by creating a thread " -"state data structure, then acquiring the GIL, and finally storing their " -"thread state pointer, before you can start using the Python/C API. When you " -"are done, you should reset the thread state pointer, release the GIL, and " -"finally free the thread state data structure." +"must first register these threads with the interpreter by creating an :term:" +"`attached thread state` before you can start using the Python/C API. When " +"you are done, you should detach the :term:`thread state `, and finally free it." msgstr "" -#: ../../c-api/init.rst:1023 +#: ../../c-api/init.rst:1054 msgid "" "The :c:func:`PyGILState_Ensure` and :c:func:`PyGILState_Release` functions " "do all of the above automatically. The typical idiom for calling into " "Python from a C thread is::" msgstr "" -#: ../../c-api/init.rst:1027 +#: ../../c-api/init.rst:1058 msgid "" "PyGILState_STATE gstate;\n" "gstate = PyGILState_Ensure();\n" @@ -1308,20 +1365,60 @@ msgid "" "PyGILState_Release(gstate);" msgstr "" -#: ../../c-api/init.rst:1037 +#: ../../c-api/init.rst:1068 msgid "" "Note that the ``PyGILState_*`` functions assume there is only one global " "interpreter (created automatically by :c:func:`Py_Initialize`). Python " "supports the creation of additional interpreters (using :c:func:" "`Py_NewInterpreter`), but mixing multiple interpreters and the " -"``PyGILState_*`` API is unsupported." +"``PyGILState_*`` API is unsupported. This is because :c:func:" +"`PyGILState_Ensure` and similar functions default to :term:`attaching " +"` a :term:`thread state` for the main interpreter, " +"meaning that the thread can't safely interact with the calling " +"subinterpreter." msgstr "" -#: ../../c-api/init.rst:1047 +#: ../../c-api/init.rst:1078 +msgid "Supporting subinterpreters in non-Python threads" +msgstr "" + +#: ../../c-api/init.rst:1080 +msgid "" +"If you would like to support subinterpreters with non-Python created " +"threads, you must use the ``PyThreadState_*`` API instead of the traditional " +"``PyGILState_*`` API." +msgstr "" + +#: ../../c-api/init.rst:1084 +msgid "" +"In particular, you must store the interpreter state from the calling " +"function and pass it to :c:func:`PyThreadState_New`, which will ensure that " +"the :term:`thread state` is targeting the correct interpreter::" +msgstr "" + +#: ../../c-api/init.rst:1088 +msgid "" +"/* The return value of PyInterpreterState_Get() from the\n" +" function that created this thread. */\n" +"PyInterpreterState *interp = ThreadData->interp;\n" +"PyThreadState *tstate = PyThreadState_New(interp);\n" +"PyThreadState_Swap(tstate);\n" +"\n" +"/* GIL of the subinterpreter is now held.\n" +" Perform Python actions here. */\n" +"result = CallSomeFunction();\n" +"/* evaluate result or handle exception */\n" +"\n" +"/* Destroy the thread state. No Python API allowed beyond this point. */\n" +"PyThreadState_Clear(tstate);\n" +"PyThreadState_DeleteCurrent();" +msgstr "" + +#: ../../c-api/init.rst:1106 msgid "Cautions about fork()" msgstr "" -#: ../../c-api/init.rst:1049 +#: ../../c-api/init.rst:1108 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 " @@ -1330,7 +1427,7 @@ msgid "" "CPython's runtime." msgstr "" -#: ../../c-api/init.rst:1055 +#: ../../c-api/init.rst:1114 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` " @@ -1347,7 +1444,7 @@ msgid "" "locks, but is not always able to." msgstr "" -#: ../../c-api/init.rst:1070 +#: ../../c-api/init.rst:1129 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 " @@ -1360,11 +1457,11 @@ msgid "" "called immediately after." msgstr "" -#: ../../c-api/init.rst:1084 +#: ../../c-api/init.rst:1143 msgid "Cautions regarding runtime finalization" msgstr "" -#: ../../c-api/init.rst:1086 +#: ../../c-api/init.rst:1145 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:" @@ -1375,41 +1472,39 @@ msgid "" "acquire the :term:`GIL`." msgstr "" -#: ../../c-api/init.rst:1094 +#: ../../c-api/init.rst:1153 msgid "" -"If any thread, other than the finalization thread, attempts to acquire the " -"GIL during finalization, either explicitly via :c:func:`PyGILState_Ensure`, :" -"c:macro:`Py_END_ALLOW_THREADS`, :c:func:`PyEval_AcquireThread`, or :c:func:" -"`PyEval_AcquireLock`, or implicitly when the interpreter attempts to " -"reacquire it after having yielded it, the thread enters **a permanently " -"blocked state** where it remains until the program exits. In most cases " -"this is harmless, but this can result in deadlock if a later stage of " -"finalization attempts to acquire a lock owned by the blocked thread, or " -"otherwise waits on the blocked thread." +"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." msgstr "" -#: ../../c-api/init.rst:1104 +#: ../../c-api/init.rst:1160 msgid "" "Gross? Yes. This prevents random crashes and/or unexpectedly skipped C++ " "finalizations further up the call stack when such threads were forcibly " -"exited here in CPython 3.13.7 and earlier. The CPython runtime GIL acquiring " -"C APIs have never had any error reporting or handling expectations at GIL " -"acquisition time that would've allowed for graceful exit from this " -"situation. Changing that would require new stable C APIs and rewriting the " -"majority of C code in the CPython ecosystem to use those with error handling." +"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." msgstr "" -#: ../../c-api/init.rst:1114 +#: ../../c-api/init.rst:1170 msgid "High-level API" msgstr "高階 API" -#: ../../c-api/init.rst:1116 +#: ../../c-api/init.rst:1172 msgid "" "These are the most commonly used types and functions when writing C " "extension code, or when embedding the Python interpreter:" msgstr "" -#: ../../c-api/init.rst:1121 +#: ../../c-api/init.rst:1177 msgid "" "This data structure represents the state shared by a number of cooperating " "threads. Threads belonging to the same interpreter share their module " @@ -1417,7 +1512,7 @@ msgid "" "in this structure." msgstr "" -#: ../../c-api/init.rst:1126 +#: ../../c-api/init.rst:1182 msgid "" "Threads belonging to different interpreters initially share nothing, except " "process state like available memory, open file descriptors and such. The " @@ -1425,58 +1520,60 @@ msgid "" "which interpreter they belong." msgstr "" -#: ../../c-api/init.rst:1134 +#: ../../c-api/init.rst:1189 +msgid "" +":pep:`684` introduced the possibility of a :ref:`per-interpreter GIL `. See :c:func:`Py_NewInterpreterFromConfig`." +msgstr "" + +#: ../../c-api/init.rst:1196 msgid "" "This data structure represents the state of a single thread. The only " "public data member is:" msgstr "" -#: ../../c-api/init.rst:1139 +#: ../../c-api/init.rst:1201 msgid "This thread's interpreter state." msgstr "" -#: ../../c-api/init.rst:1150 +#: ../../c-api/init.rst:1212 msgid "Deprecated function which does nothing." msgstr "" -#: ../../c-api/init.rst:1152 +#: ../../c-api/init.rst:1214 msgid "" "In Python 3.6 and older, this function created the GIL if it didn't exist." msgstr "" -#: ../../c-api/init.rst:1154 +#: ../../c-api/init.rst:1216 msgid "The function now does nothing." msgstr "此函式現在不會做任何事情。" -#: ../../c-api/init.rst:1157 +#: ../../c-api/init.rst:1219 msgid "" "This function is now called by :c:func:`Py_Initialize()`, so you don't have " "to call it yourself anymore." msgstr "" -#: ../../c-api/init.rst:1161 +#: ../../c-api/init.rst:1223 msgid "" "This function cannot be called before :c:func:`Py_Initialize()` anymore." msgstr "" -#: ../../c-api/init.rst:1171 +#: ../../c-api/init.rst:1233 msgid "" -"Release the global interpreter lock (if it has been created) and reset the " -"thread state to ``NULL``, returning the previous thread state (which is not " -"``NULL``). If the lock has been created, the current thread must have " -"acquired it." +"Detach the :term:`attached thread state` and return it. The thread will have " +"no :term:`thread state` upon returning." msgstr "" -#: ../../c-api/init.rst:1179 +#: ../../c-api/init.rst:1239 msgid "" -"Acquire the global interpreter lock (if it has been created) and set the " -"thread state to *tstate*, which must not be ``NULL``. If the lock has been " -"created, the current thread must not have acquired it, otherwise deadlock " -"ensues." +"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/init.rst:1185 ../../c-api/init.rst:1248 -#: ../../c-api/init.rst:1547 +#: ../../c-api/init.rst:1244 ../../c-api/init.rst:1688 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 " @@ -1484,61 +1581,86 @@ msgid "" "details." msgstr "" -#: ../../c-api/init.rst:1190 ../../c-api/init.rst:1253 -#: ../../c-api/init.rst:1557 +#: ../../c-api/init.rst:1249 ../../c-api/init.rst:1333 +#: ../../c-api/init.rst:1698 msgid "" "Hangs the current thread, rather than terminating it, if called while the " "interpreter is finalizing." msgstr "" -#: ../../c-api/init.rst:1196 +#: ../../c-api/init.rst:1255 msgid "" -"Return the current thread state. The global interpreter lock must be held. " -"When the current thread state is ``NULL``, this issues a fatal error (so " -"that the caller needn't check for ``NULL``)." +"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/init.rst:1200 +#: ../../c-api/init.rst:1260 msgid "See also :c:func:`PyThreadState_GetUnchecked`." msgstr "也請見 :c:func:`PyThreadState_GetUnchecked`。" -#: ../../c-api/init.rst:1205 +#: ../../c-api/init.rst:1264 msgid "" "Similar to :c:func:`PyThreadState_Get`, but don't kill the process with a " "fatal error if it is NULL. The caller is responsible to check if the result " "is NULL." msgstr "" -#: ../../c-api/init.rst:1209 +#: ../../c-api/init.rst:1268 msgid "" "In Python 3.5 to 3.12, the function was private and known as " "``_PyThreadState_UncheckedGet()``." msgstr "" -#: ../../c-api/init.rst:1216 +#: ../../c-api/init.rst:1275 msgid "" -"Swap the current thread state with the thread state given by the argument " -"*tstate*, which may be ``NULL``." +"Set the :term:`attached thread state` to *tstate*, and return the :term:" +"`thread state` that was attached prior to calling." msgstr "" -#: ../../c-api/init.rst:1219 +#: ../../c-api/init.rst:1278 +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/init.rst:1282 +msgid ":c:func:`PyEval_ReleaseThread`" +msgstr ":c:func:`PyEval_ReleaseThread`" + +#: ../../c-api/init.rst:1285 msgid "" -"The :term:`GIL` does not need to be held, but will be held upon returning if " -"*tstate* is non-``NULL``." +"Similar to :c:func:`PyGILState_Ensure`, this function will hang the thread " +"if the runtime is finalizing." msgstr "" -#: ../../c-api/init.rst:1222 +#: ../../c-api/init.rst:1289 msgid "" "The following functions use thread-local storage, and are not compatible " "with sub-interpreters:" msgstr "" -#: ../../c-api/init.rst:1227 +#: ../../c-api/init.rst:1294 +msgid "" +"The type of the value returned by :c:func:`PyGILState_Ensure` and passed to :" +"c:func:`PyGILState_Release`." +msgstr "" + +#: ../../c-api/init.rst:1299 +msgid "The GIL was already held when :c:func:`PyGILState_Ensure` was called." +msgstr "" + +#: ../../c-api/init.rst:1303 +msgid "The GIL was not held when :c:func:`PyGILState_Ensure` was called." +msgstr "" + +#: ../../c-api/init.rst:1307 msgid "" "Ensure that the current thread is ready to call the Python C API regardless " -"of the current state of Python, or of the global interpreter lock. This may " -"be called as many times as desired by a thread as long as each call is " -"matched with a call to :c:func:`PyGILState_Release`. In general, other " +"of the current state of Python, or of the :term:`attached thread state`. " +"This may be called as many times as desired by a thread as long as each call " +"is matched with a call to :c:func:`PyGILState_Release`. In general, other " "thread-related APIs may be used between :c:func:`PyGILState_Ensure` and :c:" "func:`PyGILState_Release` calls as long as the thread state is restored to " "its previous state before the Release(). For example, normal usage of the :" @@ -1546,23 +1668,32 @@ msgid "" "is acceptable." msgstr "" -#: ../../c-api/init.rst:1237 +#: ../../c-api/init.rst:1317 +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:" +"func:`PyGILState_Release` to ensure Python is left in the same state. Even " +"though recursive calls are allowed, these handles *cannot* be shared - each " +"unique call to :c:func:`PyGILState_Ensure` must save the handle for its call " +"to :c:func:`PyGILState_Release`." +msgstr "" + +#: ../../c-api/init.rst:1324 msgid "" -"The return value is an opaque \"handle\" to the thread state when :c:func:" -"`PyGILState_Ensure` was called, and must be passed to :c:func:" -"`PyGILState_Release` to ensure Python is left in the same state. Even though " -"recursive calls are allowed, these handles *cannot* be shared - each unique " -"call to :c:func:`PyGILState_Ensure` must save the handle for its call to :c:" -"func:`PyGILState_Release`." +"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." msgstr "" -#: ../../c-api/init.rst:1244 +#: ../../c-api/init.rst:1328 msgid "" -"When the function returns, the current thread will hold the GIL and be able " -"to call arbitrary Python code. Failure is a fatal error." +"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-" +"finalization` for more details." msgstr "" -#: ../../c-api/init.rst:1259 +#: ../../c-api/init.rst:1339 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:" @@ -1570,38 +1701,57 @@ msgid "" "caller, hence the use of the GILState API)." msgstr "" -#: ../../c-api/init.rst:1264 +#: ../../c-api/init.rst:1344 msgid "" "Every call to :c:func:`PyGILState_Ensure` must be matched by a call to :c:" "func:`PyGILState_Release` on the same thread." msgstr "" -#: ../../c-api/init.rst:1270 +#: ../../c-api/init.rst:1349 msgid "" -"Get the current thread state for this thread. May return ``NULL`` if no " -"GILState API has been used on the current thread. Note that the main thread " -"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:`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." msgstr "" -#: ../../c-api/init.rst:1278 +#: ../../c-api/init.rst:1355 msgid "" -"Return ``1`` if the current thread is holding the GIL and ``0`` otherwise. " -"This function can be called from any thread at any time. Only if it has had " -"its Python thread state initialized and currently is holding the GIL 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 GIL is locked can allow the caller to perform sensitive actions or " -"otherwise behave differently." +"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." msgstr "" -#: ../../c-api/init.rst:1290 +#: ../../c-api/init.rst:1360 +msgid ":c:func:`PyThreadState_Get`" +msgstr ":c:func:`PyThreadState_Get`" + +#: ../../c-api/init.rst:1364 +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." +msgstr "" + +#: ../../c-api/init.rst:1374 +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." +msgstr "" + +#: ../../c-api/init.rst:1381 msgid "" "The following macros are normally used without a trailing semicolon; look " "for example usage in the Python source distribution." msgstr "" -#: ../../c-api/init.rst:1296 +#: ../../c-api/init.rst:1387 msgid "" "This macro expands to ``{ PyThreadState *_save; _save = PyEval_SaveThread();" "``. Note that it contains an opening brace; it must be matched with a " @@ -1609,7 +1759,7 @@ msgid "" "discussion of this macro." msgstr "" -#: ../../c-api/init.rst:1304 +#: ../../c-api/init.rst:1395 msgid "" "This macro expands to ``PyEval_RestoreThread(_save); }``. Note that it " "contains a closing brace; it must be matched with an earlier :c:macro:" @@ -1617,40 +1767,42 @@ msgid "" "macro." msgstr "" -#: ../../c-api/init.rst:1312 +#: ../../c-api/init.rst:1403 msgid "" "This macro expands to ``PyEval_RestoreThread(_save);``: it is equivalent to :" "c:macro:`Py_END_ALLOW_THREADS` without the closing brace." msgstr "" -#: ../../c-api/init.rst:1318 +#: ../../c-api/init.rst:1409 msgid "" "This macro expands to ``_save = PyEval_SaveThread();``: it is equivalent to :" "c:macro:`Py_BEGIN_ALLOW_THREADS` without the opening brace and variable " "declaration." msgstr "" -#: ../../c-api/init.rst:1324 +#: ../../c-api/init.rst:1415 msgid "Low-level API" msgstr "低階 API" -#: ../../c-api/init.rst:1326 +#: ../../c-api/init.rst:1417 msgid "" "All of the following functions must be called after :c:func:`Py_Initialize`." msgstr "" -#: ../../c-api/init.rst:1328 -msgid ":c:func:`Py_Initialize()` now initializes the :term:`GIL`." +#: ../../c-api/init.rst:1419 +msgid "" +":c:func:`Py_Initialize()` now initializes the :term:`GIL` and sets an :term:" +"`attached thread state`." msgstr "" -#: ../../c-api/init.rst:1334 +#: ../../c-api/init.rst:1426 msgid "" -"Create a new interpreter state object. The global interpreter lock need not " -"be held, but may be held if it is necessary to serialize calls to this " -"function." +"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/init.rst:1338 +#: ../../c-api/init.rst:1430 msgid "" "Raises an :ref:`auditing event ` ``cpython." "PyInterpreterState_New`` with no arguments." @@ -1658,13 +1810,13 @@ msgstr "" "引發一個不附帶引數的\\ :ref:`稽核事件 ` ``cpython." "PyInterpreterState_New``。" -#: ../../c-api/init.rst:1343 +#: ../../c-api/init.rst:1435 msgid "" -"Reset all information in an interpreter state object. The global " -"interpreter lock must be held." +"Reset all information in an interpreter state object. There must be an :" +"term:`attached thread state` for the interpreter." msgstr "" -#: ../../c-api/init.rst:1346 +#: ../../c-api/init.rst:1438 msgid "" "Raises an :ref:`auditing event ` ``cpython." "PyInterpreterState_Clear`` with no arguments." @@ -1672,237 +1824,307 @@ msgstr "" "引發一個不附帶引數的\\ :ref:`稽核事件 ` ``cpython." "PyInterpreterState_Clear``。" -#: ../../c-api/init.rst:1351 +#: ../../c-api/init.rst:1443 msgid "" -"Destroy an interpreter state object. The global interpreter lock need not " -"be held. The interpreter state must have been reset with a previous call " -"to :c:func:`PyInterpreterState_Clear`." +"Destroy an interpreter state object. There **should not** be an :term:" +"`attached thread state` for the target interpreter. The interpreter state " +"must have been reset with a previous call to :c:func:" +"`PyInterpreterState_Clear`." msgstr "" -#: ../../c-api/init.rst:1358 +#: ../../c-api/init.rst:1450 msgid "" "Create a new thread state object belonging to the given interpreter object. " -"The global interpreter lock need not be held, but may be held if it is " -"necessary to serialize calls to this function." +"An :term:`attached thread state` is not needed." msgstr "" -#: ../../c-api/init.rst:1365 +#: ../../c-api/init.rst:1455 msgid "" -"Reset all information in a thread state object. The global interpreter lock " -"must be held." +"Reset all information in a :term:`thread state` object. *tstate* must be :" +"term:`attached `" msgstr "" -#: ../../c-api/init.rst:1368 +#: ../../c-api/init.rst:1458 msgid "" -"This function now calls the :c:member:`PyThreadState.on_delete` callback. " +"This function now calls the :c:member:`!PyThreadState.on_delete` callback. " "Previously, that happened in :c:func:`PyThreadState_Delete`." msgstr "" -#: ../../c-api/init.rst:1372 -msgid "The :c:member:`PyThreadState.on_delete` callback was removed." -msgstr ":c:member:`PyThreadState.on_delete` 回呼已被移除。" +#: ../../c-api/init.rst:1462 +msgid "The :c:member:`!PyThreadState.on_delete` callback was removed." +msgstr ":c:member:`!PyThreadState.on_delete` 回呼已被移除。" -#: ../../c-api/init.rst:1378 +#: ../../c-api/init.rst:1468 msgid "" -"Destroy a thread state object. The global interpreter lock need not be " -"held. The thread state must have been reset with a previous call to :c:func:" -"`PyThreadState_Clear`." +"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/init.rst:1385 +#: ../../c-api/init.rst:1476 msgid "" -"Destroy the current thread state and release the global interpreter lock. " -"Like :c:func:`PyThreadState_Delete`, the global interpreter lock must be " -"held. The thread state must have been reset with a previous call to :c:func:" -"`PyThreadState_Clear`." +"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/init.rst:1393 +#: ../../c-api/init.rst:1479 +msgid "" +"No :term:`thread state` will be :term:`attached ` " +"upon returning." +msgstr "" + +#: ../../c-api/init.rst:1484 msgid "Get the current frame of the Python thread state *tstate*." msgstr "" -#: ../../c-api/init.rst:1395 +#: ../../c-api/init.rst:1486 msgid "" "Return a :term:`strong reference`. Return ``NULL`` if no frame is currently " "executing." msgstr "" -#: ../../c-api/init.rst:1398 +#: ../../c-api/init.rst:1489 msgid "See also :c:func:`PyEval_GetFrame`." msgstr "也請見 :c:func:`PyEval_GetFrame`。" -#: ../../c-api/init.rst:1400 ../../c-api/init.rst:1409 -#: ../../c-api/init.rst:1418 -msgid "*tstate* must not be ``NULL``." -msgstr "*tstate* 不可為 ``NULL``。" +#: ../../c-api/init.rst:1491 ../../c-api/init.rst:1500 +#: ../../c-api/init.rst:1509 +msgid "" +"*tstate* must not be ``NULL``, and must be :term:`attached `." +msgstr "" -#: ../../c-api/init.rst:1407 +#: ../../c-api/init.rst:1498 msgid "" -"Get the unique thread state identifier of the Python thread state *tstate*." +"Get the unique :term:`thread state` identifier of the Python thread state " +"*tstate*." msgstr "" -#: ../../c-api/init.rst:1416 +#: ../../c-api/init.rst:1507 msgid "Get the interpreter of the Python thread state *tstate*." msgstr "" -#: ../../c-api/init.rst:1425 +#: ../../c-api/init.rst:1516 msgid "Suspend tracing and profiling in the Python thread state *tstate*." msgstr "" -#: ../../c-api/init.rst:1427 +#: ../../c-api/init.rst:1518 msgid "Resume them using the :c:func:`PyThreadState_LeaveTracing` function." msgstr "" -#: ../../c-api/init.rst:1434 +#: ../../c-api/init.rst:1525 msgid "" "Resume tracing and profiling in the Python thread state *tstate* suspended " "by the :c:func:`PyThreadState_EnterTracing` function." msgstr "" -#: ../../c-api/init.rst:1437 +#: ../../c-api/init.rst:1528 msgid "" "See also :c:func:`PyEval_SetTrace` and :c:func:`PyEval_SetProfile` functions." msgstr "" -#: ../../c-api/init.rst:1445 -msgid "Get the current interpreter." +#: ../../c-api/init.rst:1536 +msgid "" +"Set the stack protection start address and stack protection size of a Python " +"thread state." +msgstr "" + +#: ../../c-api/init.rst:1539 +msgid "" +"On success, return ``0``. On failure, set an exception and return ``-1``." +msgstr "" + +#: ../../c-api/init.rst:1542 +msgid "" +"CPython implements :ref:`recursion control ` for C code by " +"raising :py:exc:`RecursionError` when it notices that the machine execution " +"stack is close to overflow. See for example the :c:func:" +"`Py_EnterRecursiveCall` function. For this, it needs to know the location of " +"the current thread's stack, which it normally gets from the operating " +"system. When the stack is changed, for example using context switching " +"techniques like the Boost library's ``boost::context``, you must call :c:" +"func:`~PyUnstable_ThreadState_SetStackProtection` to inform CPython of the " +"change." +msgstr "" + +#: ../../c-api/init.rst:1551 +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/init.rst:1556 +msgid "" +"See :c:func:`PyUnstable_ThreadState_ResetStackProtection` for undoing this " +"operation." +msgstr "" + +#: ../../c-api/init.rst:1562 ../../c-api/init.rst:1582 +msgid "" +"This function was added in a bugfix release, and extensions that use it will " +"be incompatible with Python 3.14.0. Most packaging tools for Python are not " +"able to handle this incompatibility automatically, and will need explicit " +"configuration. When using PyPA standards (wheels and source distributions), " +"specify ``Requires-Python: != 3.14.0.*`` in `core metadata `_." msgstr "" -#: ../../c-api/init.rst:1447 +#: ../../c-api/init.rst:1573 +msgid "" +"Reset the stack protection start address and stack protection size of a " +"Python thread state to the operating system defaults." +msgstr "" + +#: ../../c-api/init.rst:1576 msgid "" -"Issue a fatal error if there no current Python thread state or no current " -"interpreter. It cannot return NULL." +"See :c:func:`PyUnstable_ThreadState_SetStackProtection` for an explanation." +msgstr "" + +#: ../../c-api/init.rst:1593 +msgid "Get the current interpreter." msgstr "" -#: ../../c-api/init.rst:1450 ../../c-api/init.rst:1460 -#: ../../c-api/init.rst:1482 -msgid "The caller must hold the GIL." +#: ../../c-api/init.rst:1595 +msgid "" +"Issue a fatal error if there no :term:`attached thread state`. It cannot " +"return NULL." msgstr "" -#: ../../c-api/init.rst:1457 +#: ../../c-api/init.rst:1603 msgid "" "Return the interpreter's unique ID. If there was any error in doing so then " "``-1`` is returned and an error is set." msgstr "" -#: ../../c-api/init.rst:1467 +#: ../../c-api/init.rst:1606 ../../c-api/init.rst:2221 +#: ../../c-api/init.rst:2228 ../../c-api/init.rst:2247 +#: ../../c-api/init.rst:2254 +msgid "The caller must have an :term:`attached thread state`." +msgstr "呼叫者必須擁有一個 :term:`attached thread state`。" + +#: ../../c-api/init.rst:1613 msgid "" "Return a dictionary in which interpreter-specific data may be stored. If " "this function returns ``NULL`` then no exception has been raised and the " "caller should assume no interpreter-specific dict is available." msgstr "" -#: ../../c-api/init.rst:1471 +#: ../../c-api/init.rst:1617 msgid "" "This is not a replacement for :c:func:`PyModule_GetState()`, which " "extensions should use to store interpreter-specific state information." msgstr "" -#: ../../c-api/init.rst:1479 +#: ../../c-api/init.rst:1620 msgid "" -"Return a :term:`strong reference` to the ``__main__`` :ref:`module object " -"` for the given interpreter." +"The returned dictionary is borrowed from the interpreter and is valid until " +"interpreter shutdown." msgstr "" -#: ../../c-api/init.rst:1489 +#: ../../c-api/init.rst:1628 msgid "Type of a frame evaluation function." msgstr "" -#: ../../c-api/init.rst:1491 +#: ../../c-api/init.rst:1630 msgid "" "The *throwflag* parameter is used by the ``throw()`` method of generators: " "if non-zero, handle the current exception." msgstr "" -#: ../../c-api/init.rst:1494 +#: ../../c-api/init.rst:1633 msgid "The function now takes a *tstate* parameter." msgstr "" -#: ../../c-api/init.rst:1497 +#: ../../c-api/init.rst:1636 msgid "" "The *frame* parameter changed from ``PyFrameObject*`` to " "``_PyInterpreterFrame*``." msgstr "" -#: ../../c-api/init.rst:1502 +#: ../../c-api/init.rst:1641 msgid "Get the frame evaluation function." msgstr "" -#: ../../c-api/init.rst:1504 ../../c-api/init.rst:1512 +#: ../../c-api/init.rst:1643 ../../c-api/init.rst:1651 msgid "See the :pep:`523` \"Adding a frame evaluation API to CPython\"." msgstr "" -#: ../../c-api/init.rst:1510 +#: ../../c-api/init.rst:1649 msgid "Set the frame evaluation function." msgstr "" -#: ../../c-api/init.rst:1519 +#: ../../c-api/init.rst:1658 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 " -"in the dictionary. It is okay to call this function when no current thread " -"state is available. If this function returns ``NULL``, no exception has been " -"raised and the caller should assume no current thread state is available." +"in the dictionary. It is okay to call this function when no :term:`thread " +"state` is :term:`attached `. If this function returns " +"``NULL``, no exception has been raised and the caller should assume no " +"thread state is attached." msgstr "" -#: ../../c-api/init.rst:1528 +#: ../../c-api/init.rst:1668 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 steal any references to *exc*. To prevent naive " "misuse, you must write your own C extension to call this. Must be called " -"with the GIL held. 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." +"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." msgstr "" -#: ../../c-api/init.rst:1536 +#: ../../c-api/init.rst:1676 msgid "" "The type of the *id* parameter changed from :c:expr:`long` to :c:expr:" "`unsigned long`." msgstr "" -#: ../../c-api/init.rst:1542 +#: ../../c-api/init.rst:1682 msgid "" -"Acquire the global interpreter lock and set the current thread state to " -"*tstate*, which must not be ``NULL``. The lock must have been created " -"earlier. If this thread already has the lock, deadlock ensues." +":term:`Attach ` *tstate* to the current thread, which " +"must not be ``NULL`` or already :term:`attached `." msgstr "" -#: ../../c-api/init.rst:1552 +#: ../../c-api/init.rst:1685 +msgid "" +"The calling thread must not already have an :term:`attached thread state`." +msgstr "" + +#: ../../c-api/init.rst:1693 msgid "" "Updated to be consistent with :c:func:`PyEval_RestoreThread`, :c:func:" "`Py_END_ALLOW_THREADS`, and :c:func:`PyGILState_Ensure`, and terminate the " "current thread if called while the interpreter is finalizing." msgstr "" -#: ../../c-api/init.rst:1561 +#: ../../c-api/init.rst:1702 msgid "" ":c:func:`PyEval_RestoreThread` is a higher-level function which is always " "available (even when threads have not been initialized)." msgstr "" -#: ../../c-api/init.rst:1567 +#: ../../c-api/init.rst:1708 msgid "" -"Reset the current thread state to ``NULL`` and release the global " -"interpreter lock. The lock must have been created earlier and must be held " -"by the current thread. The *tstate* argument, which must not be ``NULL``, " -"is only used to check that it represents the current thread state --- if it " -"isn't, a fatal error is reported." +"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/init.rst:1573 +#: ../../c-api/init.rst:1713 msgid "" ":c:func:`PyEval_SaveThread` is a higher-level function which is always " "available (even when threads have not been initialized)." msgstr "" -#: ../../c-api/init.rst:1580 +#: ../../c-api/init.rst:1720 msgid "Sub-interpreter support" msgstr "" -#: ../../c-api/init.rst:1582 +#: ../../c-api/init.rst:1722 msgid "" "While in most uses, you will only embed a single Python interpreter, there " "are cases where you need to create several independent interpreters in the " @@ -1910,7 +2132,7 @@ msgid "" "to do that." msgstr "" -#: ../../c-api/init.rst:1587 +#: ../../c-api/init.rst:1727 msgid "" "The \"main\" interpreter is the first one created when the runtime " "initializes. It is usually the only Python interpreter in a process. Unlike " @@ -1921,31 +2143,31 @@ msgid "" "returns a pointer to its state." msgstr "" -#: ../../c-api/init.rst:1594 +#: ../../c-api/init.rst:1734 msgid "" "You can switch between sub-interpreters using the :c:func:" "`PyThreadState_Swap` function. You can create and destroy them using the " "following functions:" msgstr "" -#: ../../c-api/init.rst:1600 +#: ../../c-api/init.rst:1740 msgid "" "Structure containing most parameters to configure a sub-interpreter. Its " "values are used only in :c:func:`Py_NewInterpreterFromConfig` and never " "modified by the runtime." msgstr "" -#: ../../c-api/init.rst:1606 +#: ../../c-api/init.rst:1746 msgid "Structure fields:" msgstr "" -#: ../../c-api/init.rst:1610 +#: ../../c-api/init.rst:1750 msgid "" "If this is ``0`` then the sub-interpreter will use its own \"object\" " "allocator state. Otherwise it will use (share) the main interpreter's." msgstr "" -#: ../../c-api/init.rst:1614 +#: ../../c-api/init.rst:1754 msgid "" "If this is ``0`` then :c:member:`~PyInterpreterConfig." "check_multi_interp_extensions` must be ``1`` (non-zero). If this is ``1`` " @@ -1953,44 +2175,44 @@ msgid "" "`PyInterpreterConfig_OWN_GIL`." msgstr "" -#: ../../c-api/init.rst:1622 +#: ../../c-api/init.rst:1762 msgid "" "If this is ``0`` then the runtime will not support forking the process in " "any thread where the sub-interpreter is currently active. Otherwise fork is " "unrestricted." msgstr "" -#: ../../c-api/init.rst:1626 +#: ../../c-api/init.rst:1766 msgid "" "Note that the :mod:`subprocess` module still works when fork is disallowed." msgstr "" -#: ../../c-api/init.rst:1631 +#: ../../c-api/init.rst:1771 msgid "" "If this is ``0`` then the runtime will not support replacing the current " "process via exec (e.g. :func:`os.execv`) in any thread where the sub-" "interpreter is currently active. Otherwise exec is unrestricted." msgstr "" -#: ../../c-api/init.rst:1636 +#: ../../c-api/init.rst:1776 msgid "" "Note that the :mod:`subprocess` module still works when exec is disallowed." msgstr "" -#: ../../c-api/init.rst:1641 +#: ../../c-api/init.rst:1781 msgid "" "If this is ``0`` then the sub-interpreter's :mod:`threading` module won't " "create threads. Otherwise threads are allowed." msgstr "" -#: ../../c-api/init.rst:1647 +#: ../../c-api/init.rst:1787 msgid "" "If this is ``0`` then the sub-interpreter's :mod:`threading` module won't " "create daemon threads. Otherwise daemon threads are allowed (as long as :c:" "member:`~PyInterpreterConfig.allow_threads` is non-zero)." msgstr "" -#: ../../c-api/init.rst:1654 +#: ../../c-api/init.rst:1794 msgid "" "If this is ``0`` then all extension modules may be imported, including " "legacy (single-phase init) modules, in any thread where the sub-interpreter " @@ -1999,37 +2221,37 @@ msgid "" "`Py_mod_multiple_interpreters`.)" msgstr "" -#: ../../c-api/init.rst:1661 +#: ../../c-api/init.rst:1801 msgid "" "This must be ``1`` (non-zero) if :c:member:`~PyInterpreterConfig." "use_main_obmalloc` is ``0``." msgstr "" -#: ../../c-api/init.rst:1666 +#: ../../c-api/init.rst:1806 msgid "" "This determines the operation of the GIL for the sub-interpreter. It may be " "one of the following:" msgstr "" -#: ../../c-api/init.rst:1673 +#: ../../c-api/init.rst:1813 msgid "Use the default selection (:c:macro:`PyInterpreterConfig_SHARED_GIL`)." msgstr "" -#: ../../c-api/init.rst:1677 +#: ../../c-api/init.rst:1817 msgid "Use (share) the main interpreter's GIL." msgstr "" -#: ../../c-api/init.rst:1681 +#: ../../c-api/init.rst:1821 msgid "Use the sub-interpreter's own GIL." msgstr "" -#: ../../c-api/init.rst:1683 +#: ../../c-api/init.rst:1823 msgid "" "If this is :c:macro:`PyInterpreterConfig_OWN_GIL` then :c:member:" "`PyInterpreterConfig.use_main_obmalloc` must be ``0``." msgstr "" -#: ../../c-api/init.rst:1697 +#: ../../c-api/init.rst:1837 msgid "" "Create a new sub-interpreter. This is an (almost) totally separate " "environment for the execution of Python code. In particular, the new " @@ -2042,42 +2264,43 @@ msgid "" "underlying file descriptors)." msgstr "" -#: ../../c-api/init.rst:1707 +#: ../../c-api/init.rst:1847 msgid "" "The given *config* controls the options with which the interpreter is " "initialized." msgstr "" -#: ../../c-api/init.rst:1710 +#: ../../c-api/init.rst:1850 msgid "" -"Upon success, *tstate_p* will be set to the first thread state created in " -"the new sub-interpreter. This thread state is made in the current thread " -"state. Note that no actual thread is created; see the discussion of thread " -"states below. If creation of the new interpreter is unsuccessful, " -"*tstate_p* is set to ``NULL``; no exception is set since the exception state " -"is stored in the current thread state and there may not be a current thread " -"state." +"Upon success, *tstate_p* will be set to the first :term:`thread state` " +"created in the new sub-interpreter. This thread state is :term:`attached " +"`. Note that no actual thread is created; see the " +"discussion of thread states below. If creation of the new interpreter is " +"unsuccessful, *tstate_p* is set to ``NULL``; no exception is set since the " +"exception state is stored in the :term:`attached thread state`, which might " +"not exist." msgstr "" -#: ../../c-api/init.rst:1719 +#: ../../c-api/init.rst:1859 msgid "" -"Like all other Python/C API functions, the global interpreter lock must be " -"held before calling this function and is still held when it returns. " -"Likewise a current thread state must be set on entry. On success, the " -"returned thread state will be set as current. If the sub-interpreter is " -"created with its own GIL then the GIL of the calling interpreter will be " -"released. When the function returns, the new interpreter's GIL will be held " -"by the current thread and the previously interpreter's GIL will remain " -"released here." +"Like all other Python/C API functions, an :term:`attached thread state` must " +"be present before calling this function, but it might be detached upon " +"returning. On success, the returned thread state will be :term:`attached " +"`. If the sub-interpreter is created with its own :" +"term:`GIL` then the :term:`attached thread state` of the calling interpreter " +"will be detached. When the function returns, the new interpreter's :term:" +"`thread state` will be :term:`attached ` to the " +"current thread and the previous interpreter's :term:`attached thread state` " +"will remain detached." msgstr "" -#: ../../c-api/init.rst:1730 +#: ../../c-api/init.rst:1870 msgid "" "Sub-interpreters are most effective when isolated from each other, with " "certain functionality restricted::" msgstr "" -#: ../../c-api/init.rst:1733 +#: ../../c-api/init.rst:1873 msgid "" "PyInterpreterConfig config = {\n" " .use_main_obmalloc = 0,\n" @@ -2109,7 +2332,7 @@ msgstr "" " Py_ExitStatusException(status);\n" "}" -#: ../../c-api/init.rst:1748 +#: ../../c-api/init.rst:1888 msgid "" "Note that the config is used only briefly and does not get modified. During " "initialization the config's values are converted into various :c:type:" @@ -2117,11 +2340,11 @@ msgid "" "internally on the :c:type:`PyInterpreterState`." msgstr "" -#: ../../c-api/init.rst:1757 +#: ../../c-api/init.rst:1897 msgid "Extension modules are shared between (sub-)interpreters as follows:" msgstr "" -#: ../../c-api/init.rst:1759 +#: ../../c-api/init.rst:1899 msgid "" "For modules using multi-phase initialization, e.g. :c:func:" "`PyModule_FromDefAndSpec`, a separate module object is created and " @@ -2129,7 +2352,7 @@ msgid "" "are shared between these module objects." msgstr "" -#: ../../c-api/init.rst:1765 +#: ../../c-api/init.rst:1905 msgid "" "For modules using single-phase initialization, e.g. :c:func:" "`PyModule_Create`, the first time a particular extension is imported, it is " @@ -2141,7 +2364,7 @@ msgid "" "might cause unwanted behavior (see `Bugs and caveats`_ below)." msgstr "" -#: ../../c-api/init.rst:1776 +#: ../../c-api/init.rst:1916 msgid "" "Note that this is different from what happens when an extension is imported " "after the interpreter has been completely re-initialized by calling :c:func:" @@ -2151,7 +2374,7 @@ msgid "" "shared between these modules." msgstr "" -#: ../../c-api/init.rst:1796 +#: ../../c-api/init.rst:1936 msgid "" "Create a new sub-interpreter. This is essentially just a wrapper around :c:" "func:`Py_NewInterpreterFromConfig` with a config that preserves the existing " @@ -2160,27 +2383,25 @@ msgid "" "single-phase init modules." msgstr "" -#: ../../c-api/init.rst:1808 +#: ../../c-api/init.rst:1948 msgid "" -"Destroy the (sub-)interpreter represented by the given thread state. The " -"given thread state must be the current thread state. See the discussion of " -"thread states below. When the call returns, the current thread state is " -"``NULL``. All thread states associated with this interpreter are " -"destroyed. The global interpreter lock used by the target interpreter must " -"be held before calling this function. No GIL is held when it returns." +"Destroy the (sub-)interpreter represented by the given :term:`thread state`. " +"The given thread state must be :term:`attached `. " +"When the call returns, there will be no :term:`attached thread state`. All " +"thread states associated with this interpreter are destroyed." msgstr "" -#: ../../c-api/init.rst:1816 +#: ../../c-api/init.rst:1953 msgid "" ":c:func:`Py_FinalizeEx` will destroy all sub-interpreters that haven't been " "explicitly destroyed at that point." msgstr "" -#: ../../c-api/init.rst:1821 +#: ../../c-api/init.rst:1960 msgid "A Per-Interpreter GIL" msgstr "直譯器各別持有的 GIL" -#: ../../c-api/init.rst:1823 +#: ../../c-api/init.rst:1962 msgid "" "Using :c:func:`Py_NewInterpreterFromConfig` you can create a sub-interpreter " "that is completely isolated from other interpreters, including having its " @@ -2189,10 +2410,10 @@ msgid "" "interpreters or blocking any others. Thus a single Python process can truly " "take advantage of multiple CPU cores when running Python code. The " "isolation also encourages a different approach to concurrency than that of " -"just using threads. (See :pep:`554`.)" +"just using threads. (See :pep:`554` and :pep:`684`.)" msgstr "" -#: ../../c-api/init.rst:1833 +#: ../../c-api/init.rst:1972 msgid "" "Using an isolated interpreter requires vigilance in preserving that " "isolation. That especially means not sharing any objects or mutable state " @@ -2206,7 +2427,7 @@ msgid "" "builtin objects." msgstr "" -#: ../../c-api/init.rst:1844 +#: ../../c-api/init.rst:1983 msgid "" "If you preserve isolation then you will have access to proper multi-core " "computing without the complications that come with free-threading. Failure " @@ -2214,7 +2435,7 @@ msgid "" "threading, including races and hard-to-debug crashes." msgstr "" -#: ../../c-api/init.rst:1849 +#: ../../c-api/init.rst:1988 msgid "" "Aside from that, one of the main challenges of using multiple isolated " "interpreters is how to communicate between them safely (not break isolation) " @@ -2224,11 +2445,11 @@ msgid "" "sharing) data between interpreters." msgstr "" -#: ../../c-api/init.rst:1860 +#: ../../c-api/init.rst:1999 msgid "Bugs and caveats" msgstr "" -#: ../../c-api/init.rst:1862 +#: ../../c-api/init.rst:2001 msgid "" "Because sub-interpreters (and the main interpreter) are part of the same " "process, the insulation between them isn't perfect --- for example, using " @@ -2241,7 +2462,7 @@ msgid "" "should be avoided if possible." msgstr "" -#: ../../c-api/init.rst:1872 +#: ../../c-api/init.rst:2011 msgid "" "Special care should be taken to avoid sharing user-defined functions, " "methods, instances or classes between sub-interpreters, since import " @@ -2250,7 +2471,7 @@ msgid "" "objects from which the above are reachable." msgstr "" -#: ../../c-api/init.rst:1878 +#: ../../c-api/init.rst:2017 msgid "" "Also note that combining this functionality with ``PyGILState_*`` APIs is " "delicate, because these APIs assume a bijection between Python thread states " @@ -2262,25 +2483,25 @@ msgid "" "created threads will probably be broken when using sub-interpreters." msgstr "" -#: ../../c-api/init.rst:1889 +#: ../../c-api/init.rst:2028 msgid "Asynchronous Notifications" msgstr "" -#: ../../c-api/init.rst:1891 +#: ../../c-api/init.rst:2030 msgid "" "A mechanism is provided to make asynchronous notifications to the main " "interpreter thread. These notifications take the form of a function pointer " "and a void pointer argument." msgstr "" -#: ../../c-api/init.rst:1898 +#: ../../c-api/init.rst:2037 msgid "" "Schedule a function to be called from the main interpreter thread. On " "success, ``0`` is returned and *func* is queued for being called in the main " "thread. On failure, ``-1`` is returned without setting any exception." msgstr "" -#: ../../c-api/init.rst:1902 +#: ../../c-api/init.rst:2041 msgid "" "When successfully queued, *func* will be *eventually* called from the main " "interpreter thread with the argument *arg*. It will be called " @@ -2288,38 +2509,33 @@ msgid "" "these conditions met:" msgstr "" -#: ../../c-api/init.rst:1907 +#: ../../c-api/init.rst:2046 msgid "on a :term:`bytecode` boundary;" msgstr "" -#: ../../c-api/init.rst:1908 +#: ../../c-api/init.rst:2047 msgid "" -"with the main thread holding the :term:`global interpreter lock` (*func* can " +"with the main thread holding an :term:`attached thread state` (*func* can " "therefore use the full C API)." msgstr "" -#: ../../c-api/init.rst:1911 +#: ../../c-api/init.rst:2050 msgid "" "*func* must return ``0`` on success, or ``-1`` on failure with an exception " "set. *func* won't be interrupted to perform another asynchronous " "notification recursively, but it can still be interrupted to switch threads " -"if the global interpreter lock is released." -msgstr "" - -#: ../../c-api/init.rst:1916 -msgid "" -"This function doesn't need a current thread state to run, and it doesn't " -"need the global interpreter lock." +"if the :term:`thread state ` is detached." msgstr "" -#: ../../c-api/init.rst:1919 +#: ../../c-api/init.rst:2055 msgid "" -"To call this function in a subinterpreter, the caller must hold the GIL. " -"Otherwise, the function *func* can be scheduled to be called from the wrong " -"interpreter." +"This function doesn't need an :term:`attached thread state`. However, to " +"call this function in a subinterpreter, the caller must have an :term:" +"`attached thread state`. Otherwise, the function *func* can be scheduled to " +"be called from the wrong interpreter." msgstr "" -#: ../../c-api/init.rst:1924 +#: ../../c-api/init.rst:2060 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 " @@ -2329,7 +2545,7 @@ msgid "" "`PyGILState API`." msgstr "" -#: ../../c-api/init.rst:1933 +#: ../../c-api/init.rst:2069 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 " @@ -2337,18 +2553,46 @@ msgid "" "scheduled calls." msgstr "" -#: ../../c-api/init.rst:1942 +#: ../../c-api/init.rst:2075 +msgid "" +"This function now always schedules *func* to be run in the main interpreter." +msgstr "" + +#: ../../c-api/init.rst:2082 +msgid "" +"Execute all pending calls. This is usually executed automatically by the " +"interpreter." +msgstr "" + +#: ../../c-api/init.rst:2085 +msgid "" +"This function returns ``0`` on success, and returns ``-1`` with an exception " +"set on failure." +msgstr "" + +#: ../../c-api/init.rst:2088 +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/init.rst:2094 +msgid "This function only runs pending calls in the main interpreter." +msgstr "" + +#: ../../c-api/init.rst:2101 msgid "Profiling and Tracing" msgstr "" -#: ../../c-api/init.rst:1947 +#: ../../c-api/init.rst:2106 msgid "" "The Python interpreter provides some low-level support for attaching " "profiling and execution tracing facilities. These are used for profiling, " "debugging, and coverage analysis tools." msgstr "" -#: ../../c-api/init.rst:1951 +#: ../../c-api/init.rst:2110 msgid "" "This C interface allows the profiling or tracing code to avoid the overhead " "of calling through Python-level callable objects, making a direct C function " @@ -2358,7 +2602,7 @@ msgid "" "reported to the Python-level trace functions in previous versions." msgstr "" -#: ../../c-api/init.rst:1961 +#: ../../c-api/init.rst:2120 msgid "" "The type of the trace function registered using :c:func:`PyEval_SetProfile` " "and :c:func:`PyEval_SetTrace`. The first parameter is the object passed to " @@ -2370,66 +2614,66 @@ msgid "" "value of *what*:" msgstr "" -#: ../../c-api/init.rst:1970 +#: ../../c-api/init.rst:2129 msgid "Value of *what*" msgstr "*what* 的值" -#: ../../c-api/init.rst:1970 +#: ../../c-api/init.rst:2129 msgid "Meaning of *arg*" msgstr "*arg* 的含義" -#: ../../c-api/init.rst:1972 +#: ../../c-api/init.rst:2131 msgid ":c:data:`PyTrace_CALL`" msgstr ":c:data:`PyTrace_CALL`" -#: ../../c-api/init.rst:1972 ../../c-api/init.rst:1977 -#: ../../c-api/init.rst:1988 +#: ../../c-api/init.rst:2131 ../../c-api/init.rst:2136 +#: ../../c-api/init.rst:2147 msgid "Always :c:data:`Py_None`." msgstr "" -#: ../../c-api/init.rst:1974 +#: ../../c-api/init.rst:2133 msgid ":c:data:`PyTrace_EXCEPTION`" msgstr ":c:data:`PyTrace_EXCEPTION`" -#: ../../c-api/init.rst:1974 +#: ../../c-api/init.rst:2133 msgid "Exception information as returned by :func:`sys.exc_info`." msgstr "" -#: ../../c-api/init.rst:1977 +#: ../../c-api/init.rst:2136 msgid ":c:data:`PyTrace_LINE`" msgstr ":c:data:`PyTrace_LINE`" -#: ../../c-api/init.rst:1979 +#: ../../c-api/init.rst:2138 msgid ":c:data:`PyTrace_RETURN`" msgstr ":c:data:`PyTrace_RETURN`" -#: ../../c-api/init.rst:1979 +#: ../../c-api/init.rst:2138 msgid "" "Value being returned to the caller, or ``NULL`` if caused by an exception." msgstr "" -#: ../../c-api/init.rst:1982 +#: ../../c-api/init.rst:2141 msgid ":c:data:`PyTrace_C_CALL`" msgstr ":c:data:`PyTrace_C_CALL`" -#: ../../c-api/init.rst:1982 ../../c-api/init.rst:1984 -#: ../../c-api/init.rst:1986 +#: ../../c-api/init.rst:2141 ../../c-api/init.rst:2143 +#: ../../c-api/init.rst:2145 msgid "Function object being called." msgstr "被呼叫的函式物件。" -#: ../../c-api/init.rst:1984 +#: ../../c-api/init.rst:2143 msgid ":c:data:`PyTrace_C_EXCEPTION`" msgstr ":c:data:`PyTrace_C_EXCEPTION`" -#: ../../c-api/init.rst:1986 +#: ../../c-api/init.rst:2145 msgid ":c:data:`PyTrace_C_RETURN`" msgstr ":c:data:`PyTrace_C_RETURN`" -#: ../../c-api/init.rst:1988 +#: ../../c-api/init.rst:2147 msgid ":c:data:`PyTrace_OPCODE`" msgstr ":c:data:`PyTrace_OPCODE`" -#: ../../c-api/init.rst:1993 +#: ../../c-api/init.rst:2152 msgid "" "The value of the *what* parameter to a :c:type:`Py_tracefunc` function when " "a new call to a function or method is being reported, or a new entry into a " @@ -2438,7 +2682,7 @@ msgid "" "the corresponding frame." msgstr "" -#: ../../c-api/init.rst:2002 +#: ../../c-api/init.rst:2161 msgid "" "The value of the *what* parameter to a :c:type:`Py_tracefunc` function when " "an exception has been raised. The callback function is called with this " @@ -2450,7 +2694,7 @@ msgid "" "profiler." msgstr "" -#: ../../c-api/init.rst:2013 +#: ../../c-api/init.rst:2172 msgid "" "The value passed as the *what* parameter to a :c:type:`Py_tracefunc` " "function (but not a profiling function) when a line-number event is being " @@ -2458,31 +2702,31 @@ msgid "" "f_trace_lines` to *0* on that frame." msgstr "" -#: ../../c-api/init.rst:2021 +#: ../../c-api/init.rst:2180 msgid "" "The value for the *what* parameter to :c:type:`Py_tracefunc` functions when " "a call is about to return." msgstr "" -#: ../../c-api/init.rst:2027 +#: ../../c-api/init.rst:2186 msgid "" "The value for the *what* parameter to :c:type:`Py_tracefunc` functions when " "a C function is about to be called." msgstr "" -#: ../../c-api/init.rst:2033 +#: ../../c-api/init.rst:2192 msgid "" "The value for the *what* parameter to :c:type:`Py_tracefunc` functions when " "a C function has raised an exception." msgstr "" -#: ../../c-api/init.rst:2039 +#: ../../c-api/init.rst:2198 msgid "" "The value for the *what* parameter to :c:type:`Py_tracefunc` functions when " "a C function has returned." msgstr "" -#: ../../c-api/init.rst:2045 +#: ../../c-api/init.rst:2204 msgid "" "The value for the *what* parameter to :c:type:`Py_tracefunc` functions (but " "not profiling functions) when a new opcode is about to be executed. This " @@ -2490,7 +2734,7 @@ msgid "" "attr:`~frame.f_trace_opcodes` to *1* on the frame." msgstr "" -#: ../../c-api/init.rst:2053 +#: ../../c-api/init.rst:2212 msgid "" "Set the profiler function to *func*. The *obj* parameter is passed to the " "function as its first parameter, and may be any Python object, or ``NULL``. " @@ -2500,29 +2744,24 @@ msgid "" "`PyTrace_LINE` :c:data:`PyTrace_OPCODE` and :c:data:`PyTrace_EXCEPTION`." msgstr "" -#: ../../c-api/init.rst:2060 +#: ../../c-api/init.rst:2219 msgid "See also the :func:`sys.setprofile` function." msgstr "另請參閱 :func:`sys.setprofile` 函式。" -#: ../../c-api/init.rst:2062 ../../c-api/init.rst:2069 -#: ../../c-api/init.rst:2088 ../../c-api/init.rst:2095 -msgid "The caller must hold the :term:`GIL`." -msgstr "呼叫者必須持有 :term:`GIL`。" - -#: ../../c-api/init.rst:2066 +#: ../../c-api/init.rst:2225 msgid "" "Like :c:func:`PyEval_SetProfile` but sets the profile function in all " "running threads belonging to the current interpreter instead of the setting " "it only on the current thread." msgstr "" -#: ../../c-api/init.rst:2071 +#: ../../c-api/init.rst:2230 msgid "" "As :c:func:`PyEval_SetProfile`, this function ignores any exceptions raised " "while setting the profile functions in all threads." msgstr "" -#: ../../c-api/init.rst:2079 +#: ../../c-api/init.rst:2238 msgid "" "Set the tracing function to *func*. This is similar to :c:func:" "`PyEval_SetProfile`, except the tracing function does receive line-number " @@ -2533,28 +2772,28 @@ msgid "" "*what* parameter." msgstr "" -#: ../../c-api/init.rst:2086 +#: ../../c-api/init.rst:2245 msgid "See also the :func:`sys.settrace` function." msgstr "也請見 :func:`sys.settrace` 函式。" -#: ../../c-api/init.rst:2092 +#: ../../c-api/init.rst:2251 msgid "" "Like :c:func:`PyEval_SetTrace` but sets the tracing function in all running " "threads belonging to the current interpreter instead of the setting it only " "on the current thread." msgstr "" -#: ../../c-api/init.rst:2097 +#: ../../c-api/init.rst:2256 msgid "" "As :c:func:`PyEval_SetTrace`, this function ignores any exceptions raised " "while setting the trace functions in all threads." msgstr "" -#: ../../c-api/init.rst:2103 +#: ../../c-api/init.rst:2262 msgid "Reference tracing" msgstr "" -#: ../../c-api/init.rst:2109 +#: ../../c-api/init.rst:2268 msgid "" "The type of the trace function registered using :c:func:" "`PyRefTracer_SetTracer`. The first parameter is a Python object that has " @@ -2564,19 +2803,19 @@ msgid "" "provided when :c:func:`PyRefTracer_SetTracer` was called." msgstr "" -#: ../../c-api/init.rst:2119 +#: ../../c-api/init.rst:2278 msgid "" "The value for the *event* parameter to :c:type:`PyRefTracer` functions when " "a Python object has been created." msgstr "" -#: ../../c-api/init.rst:2124 +#: ../../c-api/init.rst:2283 msgid "" "The value for the *event* parameter to :c:type:`PyRefTracer` functions when " "a Python object has been destroyed." msgstr "" -#: ../../c-api/init.rst:2129 +#: ../../c-api/init.rst:2288 msgid "" "Register a reference tracer function. The function will be called when a new " "Python has been created or when an object is going to be destroyed. If " @@ -2585,19 +2824,20 @@ msgid "" "return ``-1`` on error." msgstr "" -#: ../../c-api/init.rst:2135 +#: ../../c-api/init.rst:2294 msgid "" "Not that tracer functions **must not** create Python objects inside or " "otherwise the call will be re-entrant. The tracer also **must not** clear " -"any existing exception or set an exception. The GIL will be held every time " -"the tracer function is called." +"any existing exception or set an exception. A :term:`thread state` will be " +"active every time the tracer function is called." msgstr "" -#: ../../c-api/init.rst:2140 ../../c-api/init.rst:2151 -msgid "The GIL must be held when calling this function." +#: ../../c-api/init.rst:2299 ../../c-api/init.rst:2310 +msgid "" +"There must be an :term:`attached thread state` when calling this function." msgstr "" -#: ../../c-api/init.rst:2146 +#: ../../c-api/init.rst:2305 msgid "" "Get the registered reference tracer function and the value of the opaque " "data pointer that was registered when :c:func:`PyRefTracer_SetTracer` was " @@ -2605,48 +2845,48 @@ msgid "" "set the **data** pointer to NULL." msgstr "" -#: ../../c-api/init.rst:2158 +#: ../../c-api/init.rst:2317 msgid "Advanced Debugger Support" msgstr "" -#: ../../c-api/init.rst:2163 +#: ../../c-api/init.rst:2322 msgid "" "These functions are only intended to be used by advanced debugging tools." msgstr "" -#: ../../c-api/init.rst:2168 +#: ../../c-api/init.rst:2327 msgid "" "Return the interpreter state object at the head of the list of all such " "objects." msgstr "" -#: ../../c-api/init.rst:2173 +#: ../../c-api/init.rst:2332 msgid "Return the main interpreter state object." msgstr "" -#: ../../c-api/init.rst:2178 +#: ../../c-api/init.rst:2337 msgid "" "Return the next interpreter state object after *interp* from the list of all " "such objects." msgstr "" -#: ../../c-api/init.rst:2184 +#: ../../c-api/init.rst:2343 msgid "" "Return the pointer to the first :c:type:`PyThreadState` object in the list " "of threads associated with the interpreter *interp*." msgstr "" -#: ../../c-api/init.rst:2190 +#: ../../c-api/init.rst:2349 msgid "" "Return the next thread state object after *tstate* from the list of all such " "objects belonging to the same :c:type:`PyInterpreterState` object." msgstr "" -#: ../../c-api/init.rst:2197 +#: ../../c-api/init.rst:2356 msgid "Thread Local Storage Support" msgstr "" -#: ../../c-api/init.rst:2201 +#: ../../c-api/init.rst:2360 msgid "" "The Python interpreter provides low-level support for thread-local storage " "(TLS) which wraps the underlying native TLS implementation to support the " @@ -2656,19 +2896,19 @@ msgid "" "thread." msgstr "" -#: ../../c-api/init.rst:2208 +#: ../../c-api/init.rst:2367 msgid "" -"The GIL does *not* need to be held when calling these functions; they supply " -"their own locking." +"A :term:`thread state` does *not* need to be :term:`attached ` when calling these functions; they suppl their own locking." msgstr "" -#: ../../c-api/init.rst:2211 +#: ../../c-api/init.rst:2370 msgid "" "Note that :file:`Python.h` does not include the declaration of the TLS APIs, " "you need to include :file:`pythread.h` to use thread-local storage." msgstr "" -#: ../../c-api/init.rst:2215 +#: ../../c-api/init.rst:2374 msgid "" "None of these API functions handle memory management on behalf of the :c:" "expr:`void*` values. You need to allocate and deallocate them yourself. If " @@ -2676,22 +2916,22 @@ msgid "" "don't do refcount operations on them either." msgstr "" -#: ../../c-api/init.rst:2223 +#: ../../c-api/init.rst:2382 msgid "Thread Specific Storage (TSS) API" msgstr "" -#: ../../c-api/init.rst:2225 +#: ../../c-api/init.rst:2384 msgid "" "TSS API is introduced to supersede the use of the existing TLS API within " "the CPython interpreter. This API uses a new type :c:type:`Py_tss_t` " "instead of :c:expr:`int` to represent thread keys." msgstr "" -#: ../../c-api/init.rst:2231 +#: ../../c-api/init.rst:2390 msgid "\"A New C-API for Thread-Local Storage in CPython\" (:pep:`539`)" msgstr "" -#: ../../c-api/init.rst:2236 +#: ../../c-api/init.rst:2395 msgid "" "This data structure represents the state of a thread key, the definition of " "which may depend on the underlying TLS implementation, and it has an " @@ -2699,52 +2939,52 @@ msgid "" "public members in this structure." msgstr "" -#: ../../c-api/init.rst:2241 +#: ../../c-api/init.rst:2400 msgid "" "When :ref:`Py_LIMITED_API ` is not defined, static allocation of " "this type by :c:macro:`Py_tss_NEEDS_INIT` is allowed." msgstr "" -#: ../../c-api/init.rst:2247 +#: ../../c-api/init.rst:2406 msgid "" "This macro expands to the initializer for :c:type:`Py_tss_t` variables. Note " "that this macro won't be defined with :ref:`Py_LIMITED_API `." msgstr "" -#: ../../c-api/init.rst:2252 +#: ../../c-api/init.rst:2411 msgid "Dynamic Allocation" msgstr "" -#: ../../c-api/init.rst:2254 +#: ../../c-api/init.rst:2413 msgid "" "Dynamic allocation of the :c:type:`Py_tss_t`, required in extension modules " "built with :ref:`Py_LIMITED_API `, where static allocation of this " "type is not possible due to its implementation being opaque at build time." msgstr "" -#: ../../c-api/init.rst:2261 +#: ../../c-api/init.rst:2420 msgid "" "Return a value which is the same state as a value initialized with :c:macro:" "`Py_tss_NEEDS_INIT`, or ``NULL`` in the case of dynamic allocation failure." msgstr "" -#: ../../c-api/init.rst:2268 +#: ../../c-api/init.rst:2427 msgid "" "Free the given *key* allocated by :c:func:`PyThread_tss_alloc`, after first " "calling :c:func:`PyThread_tss_delete` to ensure any associated thread locals " "have been unassigned. This is a no-op if the *key* argument is ``NULL``." msgstr "" -#: ../../c-api/init.rst:2274 +#: ../../c-api/init.rst:2433 msgid "" "A freed key becomes a dangling pointer. You should reset the key to ``NULL``." msgstr "" -#: ../../c-api/init.rst:2279 +#: ../../c-api/init.rst:2438 msgid "Methods" msgstr "方法" -#: ../../c-api/init.rst:2281 +#: ../../c-api/init.rst:2440 msgid "" "The parameter *key* of these functions must not be ``NULL``. Moreover, the " "behaviors of :c:func:`PyThread_tss_set` and :c:func:`PyThread_tss_get` are " @@ -2752,13 +2992,13 @@ msgid "" "func:`PyThread_tss_create`." msgstr "" -#: ../../c-api/init.rst:2289 +#: ../../c-api/init.rst:2448 msgid "" "Return a non-zero value if the given :c:type:`Py_tss_t` has been initialized " "by :c:func:`PyThread_tss_create`." msgstr "" -#: ../../c-api/init.rst:2295 +#: ../../c-api/init.rst:2454 msgid "" "Return a zero value on successful initialization of a TSS key. The behavior " "is undefined if the value pointed to by the *key* argument is not " @@ -2767,7 +3007,7 @@ msgid "" "no-op and immediately returns success." msgstr "" -#: ../../c-api/init.rst:2304 +#: ../../c-api/init.rst:2463 msgid "" "Destroy a TSS key to forget the values associated with the key across all " "threads, and change the key's initialization state to uninitialized. A " @@ -2776,31 +3016,31 @@ msgid "" "key -- calling it on an already destroyed key is a no-op." msgstr "" -#: ../../c-api/init.rst:2313 +#: ../../c-api/init.rst:2472 msgid "" "Return a zero value to indicate successfully associating a :c:expr:`void*` " "value with a TSS key in the current thread. Each thread has a distinct " "mapping of the key to a :c:expr:`void*` value." msgstr "" -#: ../../c-api/init.rst:2320 +#: ../../c-api/init.rst:2479 msgid "" "Return the :c:expr:`void*` value associated with a TSS key in the current " "thread. This returns ``NULL`` if no value is associated with the key in the " "current thread." msgstr "" -#: ../../c-api/init.rst:2328 +#: ../../c-api/init.rst:2487 msgid "Thread Local Storage (TLS) API" msgstr "執行緒局部儲存 (Thread Local Storage, TLS) API:" -#: ../../c-api/init.rst:2330 +#: ../../c-api/init.rst:2489 msgid "" "This API is superseded by :ref:`Thread Specific Storage (TSS) API `." msgstr "" -#: ../../c-api/init.rst:2335 +#: ../../c-api/init.rst:2494 msgid "" "This version of the API does not support platforms where the native TLS key " "is defined in a way that cannot be safely cast to ``int``. On such " @@ -2809,62 +3049,74 @@ msgid "" "platforms." msgstr "" -#: ../../c-api/init.rst:2340 +#: ../../c-api/init.rst:2499 msgid "" "Due to the compatibility problem noted above, this version of the API should " "not be used in new code." msgstr "" -#: ../../c-api/init.rst:2351 +#: ../../c-api/init.rst:2510 msgid "Synchronization Primitives" msgstr "" -#: ../../c-api/init.rst:2353 +#: ../../c-api/init.rst:2512 msgid "The C-API provides a basic mutual exclusion lock." msgstr "" -#: ../../c-api/init.rst:2357 +#: ../../c-api/init.rst:2516 msgid "" "A mutual exclusion lock. The :c:type:`!PyMutex` should be initialized to " "zero to represent the unlocked state. For example::" msgstr "" -#: ../../c-api/init.rst:2360 +#: ../../c-api/init.rst:2519 msgid "PyMutex mutex = {0};" msgstr "PyMutex mutex = {0};" -#: ../../c-api/init.rst:2362 +#: ../../c-api/init.rst:2521 msgid "" "Instances of :c:type:`!PyMutex` should not be copied or moved. Both the " "contents and address of a :c:type:`!PyMutex` are meaningful, and it must " "remain at a fixed, writable location in memory." msgstr "" -#: ../../c-api/init.rst:2368 +#: ../../c-api/init.rst:2527 msgid "" "A :c:type:`!PyMutex` currently occupies one byte, but the size should be " "considered unstable. The size may change in future Python releases without " "a deprecation period." msgstr "" -#: ../../c-api/init.rst:2376 +#: ../../c-api/init.rst:2535 msgid "" "Lock mutex *m*. If another thread has already locked it, the calling thread " "will block until the mutex is unlocked. While blocked, the thread will " -"temporarily release the :term:`GIL` if it is held." +"temporarily detach the :term:`thread state ` if one " +"exists." msgstr "" -#: ../../c-api/init.rst:2384 +#: ../../c-api/init.rst:2543 msgid "" "Unlock mutex *m*. The mutex must be locked --- otherwise, the function will " "issue a fatal error." msgstr "" -#: ../../c-api/init.rst:2392 +#: ../../c-api/init.rst:2550 +msgid "Returns non-zero if the mutex *m* is currently locked, zero otherwise." +msgstr "" + +#: ../../c-api/init.rst:2554 +msgid "" +"This function is intended for use in assertions and debugging only and " +"should not be used to make concurrency control decisions, as the lock state " +"may change immediately after the check." +msgstr "" + +#: ../../c-api/init.rst:2563 msgid "Python Critical Section API" msgstr "" -#: ../../c-api/init.rst:2394 +#: ../../c-api/init.rst:2565 msgid "" "The critical section API provides a deadlock avoidance layer on top of per-" "object locks for :term:`free-threaded ` CPython. They are " @@ -2872,7 +3124,7 @@ msgid "" "no-ops in versions of Python with the global interpreter lock." msgstr "" -#: ../../c-api/init.rst:2399 +#: ../../c-api/init.rst:2570 msgid "" "Critical sections are intended to be used for custom types implemented in C-" "API extensions. They should generally not be used with built-in types like :" @@ -2881,7 +3133,7 @@ msgid "" "`PyDict_Next`, which requires critical section to be acquired externally." msgstr "" -#: ../../c-api/init.rst:2406 +#: ../../c-api/init.rst:2577 msgid "" "Critical sections avoid deadlocks by implicitly suspending active critical " "sections, hence, they do not provide exclusive access such as provided by " @@ -2892,7 +3144,16 @@ msgid "" "threads can acquire the per-object lock for the same object." msgstr "" -#: ../../c-api/init.rst:2414 +#: ../../c-api/init.rst:2585 +msgid "" +"Variants that accept :c:type:`PyMutex` pointers rather than Python objects " +"are also available. Use these variants to start a critical section in a " +"situation where there is no :c:type:`PyObject` -- for example, when working " +"with a C type that does not extend or wrap :c:type:`PyObject` but still " +"needs to call into the C API in a manner that might lead to deadlocks." +msgstr "" + +#: ../../c-api/init.rst:2591 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 " @@ -2900,7 +3161,7 @@ msgid "" "future Python versions." msgstr "" -#: ../../c-api/init.rst:2421 +#: ../../c-api/init.rst:2598 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 " @@ -2909,11 +3170,11 @@ msgid "" "lock more than two objects at once." msgstr "" -#: ../../c-api/init.rst:2427 +#: ../../c-api/init.rst:2604 msgid "Example usage::" msgstr "範例用法: ::" -#: ../../c-api/init.rst:2429 +#: ../../c-api/init.rst:2606 msgid "" "static PyObject *\n" "set_field(MyObject *self, PyObject *value)\n" @@ -2933,7 +3194,7 @@ msgstr "" " Py_RETURN_NONE;\n" "}" -#: ../../c-api/init.rst:2438 +#: ../../c-api/init.rst:2615 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 " @@ -2943,18 +3204,19 @@ msgid "" "`PyEval_SaveThread`." msgstr "" -#: ../../c-api/init.rst:2446 +#: ../../c-api/init.rst:2623 msgid "" "Acquires the per-object lock for the object *op* and begins a critical " "section." msgstr "" -#: ../../c-api/init.rst:2449 ../../c-api/init.rst:2463 -#: ../../c-api/init.rst:2478 ../../c-api/init.rst:2492 +#: ../../c-api/init.rst:2626 ../../c-api/init.rst:2640 +#: ../../c-api/init.rst:2657 ../../c-api/init.rst:2672 +#: ../../c-api/init.rst:2686 ../../c-api/init.rst:2703 msgid "In the free-threaded build, this macro expands to::" msgstr "" -#: ../../c-api/init.rst:2451 +#: ../../c-api/init.rst:2628 msgid "" "{\n" " PyCriticalSection _py_cs;\n" @@ -2964,15 +3226,39 @@ msgstr "" " PyCriticalSection _py_cs;\n" " PyCriticalSection_Begin(&_py_cs, (PyObject*)(op))" -#: ../../c-api/init.rst:2455 ../../c-api/init.rst:2484 +#: ../../c-api/init.rst:2632 ../../c-api/init.rst:2678 msgid "In the default build, this macro expands to ``{``." msgstr "" -#: ../../c-api/init.rst:2461 +#: ../../c-api/init.rst:2638 +msgid "Locks the mutex *m* and begins a critical section." +msgstr "" + +#: ../../c-api/init.rst:2642 +msgid "" +"{\n" +" PyCriticalSection _py_cs;\n" +" PyCriticalSection_BeginMutex(&_py_cs, m)" +msgstr "" +"{\n" +" PyCriticalSection _py_cs;\n" +" PyCriticalSection_BeginMutex(&_py_cs, m)" + +#: ../../c-api/init.rst:2646 +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/init.rst:2649 ../../c-api/init.rst:2695 +msgid "On the default build, this macro expands to ``{``." +msgstr "" + +#: ../../c-api/init.rst:2655 msgid "Ends the critical section and releases the per-object lock." msgstr "" -#: ../../c-api/init.rst:2465 +#: ../../c-api/init.rst:2659 msgid "" " PyCriticalSection_End(&_py_cs);\n" "}" @@ -2980,18 +3266,18 @@ msgstr "" " PyCriticalSection_End(&_py_cs);\n" "}" -#: ../../c-api/init.rst:2468 ../../c-api/init.rst:2497 +#: ../../c-api/init.rst:2662 ../../c-api/init.rst:2708 msgid "In the default build, this macro expands to ``}``." msgstr "" -#: ../../c-api/init.rst:2474 +#: ../../c-api/init.rst:2668 msgid "" "Acquires the per-objects locks for the objects *a* and *b* and begins a " "critical section. The locks are acquired in a consistent order (lowest " "address first) to avoid lock ordering deadlocks." msgstr "" -#: ../../c-api/init.rst:2480 +#: ../../c-api/init.rst:2674 msgid "" "{\n" " PyCriticalSection2 _py_cs2;\n" @@ -3001,11 +3287,31 @@ msgstr "" " PyCriticalSection2 _py_cs2;\n" " PyCriticalSection2_Begin(&_py_cs2, (PyObject*)(a), (PyObject*)(b))" -#: ../../c-api/init.rst:2490 +#: ../../c-api/init.rst:2684 +msgid "Locks the mutexes *m1* and *m2* and begins a critical section." +msgstr "" + +#: ../../c-api/init.rst:2688 +msgid "" +"{\n" +" PyCriticalSection2 _py_cs2;\n" +" PyCriticalSection2_BeginMutex(&_py_cs2, m1, m2)" +msgstr "" +"{\n" +" PyCriticalSection2 _py_cs2;\n" +" PyCriticalSection2_BeginMutex(&_py_cs2, m1, m2)" + +#: ../../c-api/init.rst:2692 +msgid "" +"Note that unlike :c:macro:`Py_BEGIN_CRITICAL_SECTION2`, there is no cast for " +"the arguments of the macro - they must be :c:type:`PyMutex` pointers." +msgstr "" + +#: ../../c-api/init.rst:2701 msgid "Ends the critical section and releases the per-object locks." msgstr "" -#: ../../c-api/init.rst:2494 +#: ../../c-api/init.rst:2705 msgid "" " PyCriticalSection2_End(&_py_cs2);\n" "}" @@ -3013,6 +3319,257 @@ msgstr "" " PyCriticalSection2_End(&_py_cs2);\n" "}" +#: ../../c-api/init.rst:2714 +msgid "Legacy Locking APIs" +msgstr "" + +#: ../../c-api/init.rst:2716 +msgid "" +"These APIs are obsolete since Python 3.13 with the introduction of :c:type:" +"`PyMutex`." +msgstr "" + +#: ../../c-api/init.rst:2719 +msgid "These APIs are now a simple wrapper around ``PyMutex``." +msgstr "" + +#: ../../c-api/init.rst:2725 +msgid "A pointer to a mutual exclusion lock." +msgstr "" + +#: ../../c-api/init.rst:2730 +msgid "The result of acquiring a lock with a timeout." +msgstr "" + +#: ../../c-api/init.rst:2736 +msgid "Failed to acquire the lock." +msgstr "" + +#: ../../c-api/init.rst:2740 +msgid "The lock was successfully acquired." +msgstr "" + +#: ../../c-api/init.rst:2744 +msgid "The lock was interrupted by a signal." +msgstr "" + +#: ../../c-api/init.rst:2749 +msgid "Allocate a new lock." +msgstr "" + +#: ../../c-api/init.rst:2751 +msgid "" +"On success, this function returns a lock; on failure, this function returns " +"``0`` without an exception set." +msgstr "" + +#: ../../c-api/init.rst:2754 ../../c-api/init.rst:2766 +#: ../../c-api/init.rst:2786 ../../c-api/init.rst:2804 +#: ../../c-api/init.rst:2812 ../../c-api/init.rst:2835 +#: ../../c-api/init.rst:2919 ../../c-api/init.rst:2927 +msgid "The caller does not need to hold an :term:`attached thread state`." +msgstr "呼叫者不需擁有一個 :term:`attached thread state`。" + +#: ../../c-api/init.rst:2756 +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/init.rst:2763 +msgid "" +"Destroy *lock*. The lock should not be held by any thread when calling this." +msgstr "" + +#: ../../c-api/init.rst:2771 +msgid "Acquire *lock* with a timeout." +msgstr "" + +#: ../../c-api/init.rst:2773 +msgid "" +"This will wait for *microseconds* microseconds to acquire the lock. If the " +"timeout expires, this function returns :c:enumerator:`PY_LOCK_FAILURE`. If " +"*microseconds* is ``-1``, this will wait indefinitely until the lock has " +"been released." +msgstr "" + +#: ../../c-api/init.rst:2778 +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 " +"interruption, it's generally expected that the caller makes a call to :c:" +"func:`Py_MakePendingCalls` to propagate an exception to Python code." +msgstr "" + +#: ../../c-api/init.rst:2783 +msgid "" +"If the lock is successfully acquired, this function returns :c:enumerator:" +"`PY_LOCK_ACQUIRED`." +msgstr "" + +#: ../../c-api/init.rst:2791 +msgid "Acquire *lock*." +msgstr "" + +#: ../../c-api/init.rst:2793 +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/init.rst:2797 +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/init.rst:2801 +msgid "" +"Unlike :c:func:`PyThread_acquire_lock_timed`, acquiring the lock cannot be " +"interrupted by a signal." +msgstr "" + +#: ../../c-api/init.rst:2809 +msgid "" +"Release *lock*. If *lock* is not held, then this function issues a fatal " +"error." +msgstr "" + +#: ../../c-api/init.rst:2816 +msgid "Operating System Thread APIs" +msgstr "" + +#: ../../c-api/init.rst:2820 +msgid "Sentinel value for an invalid thread ID." +msgstr "" + +#: ../../c-api/init.rst:2822 +msgid "This is currently equivalent to ``(unsigned long)-1``." +msgstr "" + +#: ../../c-api/init.rst:2827 +msgid "" +"Start function *func* in a new thread with argument *arg*. The resulting " +"thread is not intended to be joined." +msgstr "" + +#: ../../c-api/init.rst:2830 +msgid "*func* must not be ``NULL``, but *arg* may be ``NULL``." +msgstr "" + +#: ../../c-api/init.rst:2832 +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/init.rst:2840 +msgid "Return the identifier of the current thread, which will never be zero." +msgstr "" + +#: ../../c-api/init.rst:2842 ../../c-api/init.rst:2874 +msgid "" +"This function cannot fail, and the caller does not need to hold an :term:" +"`attached thread state`." +msgstr "" + +#: ../../c-api/init.rst:2846 +msgid ":py:func:`threading.get_ident`" +msgstr ":py:func:`threading.get_ident`" + +#: ../../c-api/init.rst:2851 +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/init.rst:2855 +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/init.rst:2858 +msgid "The caller must hold an :term:`attached thread state`." +msgstr "呼叫者必須擁有一個 :term:`attached thread state`。" + +#: ../../c-api/init.rst:2863 +msgid "This macro is defined when the system supports native thread IDs." +msgstr "" + +#: ../../c-api/init.rst:2868 +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/init.rst:2871 +msgid "" +"This function is only available when :c:macro:`PY_HAVE_THREAD_NATIVE_ID` is " +"defined." +msgstr "" + +#: ../../c-api/init.rst:2878 +msgid ":py:func:`threading.get_native_id`" +msgstr ":py:func:`threading.get_native_id`" + +#: ../../c-api/init.rst:2883 +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/init.rst:2886 +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/init.rst:2891 +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 " +"call C++ destructors on some libc implementations. However, if a " +"``noexcept`` function is reached, it may terminate the process. Other " +"systems, such as macOS, do unwinding." +msgstr "" + +#: ../../c-api/init.rst:2897 +msgid "" +"On Windows, this function calls ``_endthreadex()``, which kills the thread " +"without calling C++ destructors." +msgstr "" + +#: ../../c-api/init.rst:2900 +msgid "In any case, there is a risk of corruption on the thread's stack." +msgstr "" + +#: ../../c-api/init.rst:2907 +msgid "" +"Initialize ``PyThread*`` APIs. Python executes this function automatically, " +"so there's little need to call it from an extension module." +msgstr "" + +#: ../../c-api/init.rst:2913 +msgid "Set the stack size of the current thread to *size* bytes." +msgstr "" + +#: ../../c-api/init.rst:2915 +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/init.rst:2924 +msgid "" +"Return the stack size of the current thread in bytes, or ``0`` if the " +"system's default stack size is in use." +msgstr "" + #: ../../c-api/init.rst:350 msgid "PyEval_InitThreads()" msgstr "PyEval_InitThreads()" @@ -3021,147 +3578,150 @@ msgstr "PyEval_InitThreads()" msgid "modules (in module sys)" msgstr "modules(sys 模組中)" -#: ../../c-api/init.rst:350 ../../c-api/init.rst:700 +#: ../../c-api/init.rst:350 ../../c-api/init.rst:712 msgid "path (in module sys)" msgstr "path(sys 模組中)" -#: ../../c-api/init.rst:350 ../../c-api/init.rst:700 ../../c-api/init.rst:1166 -#: ../../c-api/init.rst:1689 ../../c-api/init.rst:1788 +#: ../../c-api/init.rst:350 ../../c-api/init.rst:712 ../../c-api/init.rst:1228 +#: ../../c-api/init.rst:1829 ../../c-api/init.rst:1928 msgid "module" msgstr "模組" -#: ../../c-api/init.rst:350 ../../c-api/init.rst:1689 ../../c-api/init.rst:1788 +#: ../../c-api/init.rst:350 ../../c-api/init.rst:1829 ../../c-api/init.rst:1928 msgid "builtins" msgstr "builtins(內建)" -#: ../../c-api/init.rst:350 ../../c-api/init.rst:1689 ../../c-api/init.rst:1788 +#: ../../c-api/init.rst:350 ../../c-api/init.rst:1829 ../../c-api/init.rst:1928 msgid "__main__" msgstr "__main__" -#: ../../c-api/init.rst:350 ../../c-api/init.rst:1689 ../../c-api/init.rst:1788 +#: ../../c-api/init.rst:350 ../../c-api/init.rst:1829 ../../c-api/init.rst:1928 msgid "sys" msgstr "sys" -#: ../../c-api/init.rst:350 ../../c-api/init.rst:700 +#: ../../c-api/init.rst:350 ../../c-api/init.rst:712 msgid "search" msgstr "search(搜尋)" -#: ../../c-api/init.rst:350 ../../c-api/init.rst:700 +#: ../../c-api/init.rst:350 ../../c-api/init.rst:712 msgid "path" msgstr "path(路徑)" -#: ../../c-api/init.rst:350 ../../c-api/init.rst:1753 ../../c-api/init.rst:1806 +#: ../../c-api/init.rst:350 ../../c-api/init.rst:1893 ../../c-api/init.rst:1946 msgid "Py_FinalizeEx (C function)" msgstr "Py_FinalizeEx(C 函式)" -#: ../../c-api/init.rst:566 +#: ../../c-api/init.rst:572 msgid "Py_Initialize()" msgstr "Py_Initialize()" -#: ../../c-api/init.rst:566 ../../c-api/init.rst:798 +#: ../../c-api/init.rst:572 ../../c-api/init.rst:810 msgid "main()" msgstr "main()" -#: ../../c-api/init.rst:566 +#: ../../c-api/init.rst:572 msgid "Py_GetPath()" msgstr "Py_GetPath()" -#: ../../c-api/init.rst:679 +#: ../../c-api/init.rst:690 msgid "executable (in module sys)" msgstr "executable(sys 模組中)" -#: ../../c-api/init.rst:733 ../../c-api/init.rst:775 ../../c-api/init.rst:789 +#: ../../c-api/init.rst:745 ../../c-api/init.rst:787 ../../c-api/init.rst:801 msgid "version (in module sys)" msgstr "version(sys 模組中)" -#: ../../c-api/init.rst:745 +#: ../../c-api/init.rst:757 msgid "platform (in module sys)" msgstr "platform(sys 模組中)" -#: ../../c-api/init.rst:762 +#: ../../c-api/init.rst:774 msgid "copyright (in module sys)" msgstr "copyright(sys 模組中)" -#: ../../c-api/init.rst:798 +#: ../../c-api/init.rst:810 msgid "Py_FatalError()" msgstr "Py_FatalError()" -#: ../../c-api/init.rst:798 +#: ../../c-api/init.rst:810 msgid "argv (in module sys)" msgstr "argv(sys 模組中)" -#: ../../c-api/init.rst:918 +#: ../../c-api/init.rst:930 msgid "global interpreter lock" msgstr "global interpreter lock(全域直譯器鎖)" -#: ../../c-api/init.rst:918 +#: ../../c-api/init.rst:930 msgid "interpreter lock" msgstr "interpreter lock(直譯器鎖)" -#: ../../c-api/init.rst:918 +#: ../../c-api/init.rst:930 msgid "lock, interpreter" msgstr "lock, interpreter(鎖、直譯器)" -#: ../../c-api/init.rst:931 +#: ../../c-api/init.rst:944 msgid "setswitchinterval (in module sys)" msgstr "setswitchinterval (sys 模組中)" -#: ../../c-api/init.rst:940 +#: ../../c-api/init.rst:953 msgid "PyThreadState (C type)" msgstr "PyThreadState(C 型別)" -#: ../../c-api/init.rst:966 +#: ../../c-api/init.rst:989 msgid "Py_BEGIN_ALLOW_THREADS (C macro)" msgstr "Py_BEGIN_ALLOW_THREADS(C 巨集)" -#: ../../c-api/init.rst:966 +#: ../../c-api/init.rst:989 msgid "Py_END_ALLOW_THREADS (C macro)" msgstr "Py_END_ALLOW_THREADS(C 巨集)" -#: ../../c-api/init.rst:982 +#: ../../c-api/init.rst:1005 msgid "PyEval_RestoreThread (C function)" msgstr "PyEval_RestoreThread(C 函式)" -#: ../../c-api/init.rst:982 +#: ../../c-api/init.rst:1005 msgid "PyEval_SaveThread (C function)" msgstr "PyEval_SaveThread(C 函式)" -#: ../../c-api/init.rst:1144 +#: ../../c-api/init.rst:1206 msgid "PyEval_AcquireThread()" msgstr "PyEval_AcquireThread()" -#: ../../c-api/init.rst:1144 +#: ../../c-api/init.rst:1206 msgid "PyEval_ReleaseThread()" msgstr "PyEval_ReleaseThread()" -#: ../../c-api/init.rst:1144 +#: ../../c-api/init.rst:1206 msgid "PyEval_SaveThread()" msgstr "PyEval_SaveThread()" -#: ../../c-api/init.rst:1144 +#: ../../c-api/init.rst:1206 msgid "PyEval_RestoreThread()" msgstr "PyEval_RestoreThread()" -#: ../../c-api/init.rst:1166 +#: ../../c-api/init.rst:1228 msgid "_thread" msgstr "_thread" -#: ../../c-api/init.rst:1689 ../../c-api/init.rst:1788 +#: ../../c-api/init.rst:1829 ../../c-api/init.rst:1928 msgid "stdout (in module sys)" msgstr "stdout(sys 模組中)" -#: ../../c-api/init.rst:1689 ../../c-api/init.rst:1788 +#: ../../c-api/init.rst:1829 ../../c-api/init.rst:1928 msgid "stderr (in module sys)" msgstr "stderr(sys 模組中)" -#: ../../c-api/init.rst:1689 ../../c-api/init.rst:1788 +#: ../../c-api/init.rst:1829 ../../c-api/init.rst:1928 msgid "stdin (in module sys)" msgstr "stdin(sys 模組中)" -#: ../../c-api/init.rst:1753 +#: ../../c-api/init.rst:1893 msgid "Py_Initialize (C function)" msgstr "Py_Initialize(C 函式)" -#: ../../c-api/init.rst:1783 +#: ../../c-api/init.rst:1923 msgid "close (in module os)" msgstr "close(os 模組中)" + +#~ msgid "*tstate* must not be ``NULL``." +#~ msgstr "*tstate* 不可為 ``NULL``。" diff --git a/c-api/init_config.po b/c-api/init_config.po index 434dd0394e1..e6e285c2c5e 100644 --- a/c-api/init_config.po +++ b/c-api/init_config.po @@ -1,14 +1,13 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# 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.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-03-14 00:14+0000\n" +"POT-Creation-Date: 2025-11-05 00:16+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -22,18 +21,1087 @@ msgstr "" msgid "Python Initialization Configuration" msgstr "Python 初始化設定" -#: ../../c-api/init_config.rst:11 +#: ../../c-api/init_config.rst:13 +msgid "PyInitConfig C API" +msgstr "PyInitConfig C API" + +#: ../../c-api/init_config.rst:17 +msgid "Python can be initialized with :c:func:`Py_InitializeFromInitConfig`." +msgstr "Python 可以使用 :c:func:`Py_InitializeFromInitConfig` 來初始化。" + +#: ../../c-api/init_config.rst:19 ../../c-api/init_config.rst:650 +msgid "" +"The :c:func:`Py_RunMain` function can be used to write a customized Python " +"program." +msgstr "" + +#: ../../c-api/init_config.rst:22 ../../c-api/init_config.rst:653 +msgid "" +"See also :ref:`Initialization, Finalization, and Threads `." +msgstr "" + +#: ../../c-api/init_config.rst:25 +msgid ":pep:`741` \"Python Configuration C API\"." +msgstr "" + +#: ../../c-api/init_config.rst:29 ../../c-api/init_config.rst:660 +msgid "Example" +msgstr "範例" + +#: ../../c-api/init_config.rst:31 +msgid "" +"Example of customized Python always running with the :ref:`Python " +"Development Mode ` enabled; return ``-1`` on error:" +msgstr "" + +#: ../../c-api/init_config.rst:34 +msgid "" +"int init_python(void)\n" +"{\n" +" PyInitConfig *config = PyInitConfig_Create();\n" +" if (config == NULL) {\n" +" printf(\"PYTHON INIT ERROR: memory allocation failed\\n\");\n" +" return -1;\n" +" }\n" +"\n" +" // Enable the Python Development Mode\n" +" if (PyInitConfig_SetInt(config, \"dev_mode\", 1) < 0) {\n" +" goto error;\n" +" }\n" +"\n" +" // Initialize Python with the configuration\n" +" if (Py_InitializeFromInitConfig(config) < 0) {\n" +" goto error;\n" +" }\n" +" PyInitConfig_Free(config);\n" +" return 0;\n" +"\n" +"error:\n" +" {\n" +" // Display the error message.\n" +" //\n" +" // This uncommon braces style is used, because you cannot make\n" +" // goto targets point to variable declarations.\n" +" const char *err_msg;\n" +" (void)PyInitConfig_GetError(config, &err_msg);\n" +" printf(\"PYTHON INIT ERROR: %s\\n\", err_msg);\n" +" PyInitConfig_Free(config);\n" +" return -1;\n" +" }\n" +"}" +msgstr "" + +#: ../../c-api/init_config.rst:71 +msgid "Create Config" +msgstr "建立設定" + +#: ../../c-api/init_config.rst:75 +msgid "Opaque structure to configure the Python initialization." +msgstr "" + +#: ../../c-api/init_config.rst:80 +msgid "" +"Create a new initialization configuration using :ref:`Isolated Configuration " +"` default values." +msgstr "" + +#: ../../c-api/init_config.rst:83 +msgid "It must be freed by :c:func:`PyInitConfig_Free`." +msgstr "必須由 :c:func:`PyInitConfig_Free` 來釋放。" + +#: ../../c-api/init_config.rst:85 +msgid "Return ``NULL`` on memory allocation failure." +msgstr "在記憶體配置失敗時回傳 ``NULL``。" + +#: ../../c-api/init_config.rst:90 +msgid "Free memory of the initialization configuration *config*." +msgstr "釋放初始化配置 *config* 的記憶體。" + +#: ../../c-api/init_config.rst:92 +msgid "If *config* is ``NULL``, no operation is performed." +msgstr "如果 *config* 是 ``NULL``,則不執行任何操作。" + +#: ../../c-api/init_config.rst:96 +msgid "Error Handling" +msgstr "錯誤處理" + +#: ../../c-api/init_config.rst:100 +msgid "Get the *config* error message." +msgstr "取得 *config* 錯誤訊息。" + +#: ../../c-api/init_config.rst:102 +msgid "Set *\\*err_msg* and return ``1`` if an error is set." +msgstr "如果設定了錯誤,則設置 *\\*err_msg* 並回傳 ``1``。" + +#: ../../c-api/init_config.rst:103 +msgid "Set *\\*err_msg* to ``NULL`` and return ``0`` otherwise." +msgstr "如果沒有設定錯誤,則設定 *\\*err_msg* 為 ``NULL`` 並回傳 ``0``。" + +#: ../../c-api/init_config.rst:105 +msgid "An error message is a UTF-8 encoded string." +msgstr "錯誤訊息是 UTF-8 編碼的字串。" + +#: ../../c-api/init_config.rst:107 +msgid "If *config* has an exit code, format the exit code as an error message." +msgstr "" + +#: ../../c-api/init_config.rst:110 +msgid "" +"The error message remains valid until another ``PyInitConfig`` function is " +"called with *config*. The caller doesn't have to free the error message." +msgstr "" + +#: ../../c-api/init_config.rst:117 +msgid "Get the *config* exit code." +msgstr "" + +#: ../../c-api/init_config.rst:119 +msgid "Set *\\*exitcode* and return ``1`` if *config* has an exit code set." +msgstr "" + +#: ../../c-api/init_config.rst:120 +msgid "Return ``0`` if *config* has no exit code set." +msgstr "" + +#: ../../c-api/init_config.rst:122 +msgid "" +"Only the ``Py_InitializeFromInitConfig()`` function can set an exit code if " +"the ``parse_argv`` option is non-zero." +msgstr "" + +#: ../../c-api/init_config.rst:125 +msgid "" +"An exit code can be set when parsing the command line failed (exit code " +"``2``) or when a command line option asks to display the command line help " +"(exit code ``0``)." +msgstr "" + +#: ../../c-api/init_config.rst:131 +msgid "Get Options" +msgstr "" + +#: ../../c-api/init_config.rst:133 ../../c-api/init_config.rst:187 +#: ../../c-api/init_config.rst:559 +msgid "" +"The configuration option *name* parameter must be a non-NULL null-terminated " +"UTF-8 encoded string. See :ref:`Configuration Options `." +msgstr "" + +#: ../../c-api/init_config.rst:138 +msgid "Test if the configuration has an option called *name*." +msgstr "測試配置是否有名為 *name* 的選項。" + +#: ../../c-api/init_config.rst:140 +msgid "Return ``1`` if the option exists, or return ``0`` otherwise." +msgstr "如果選項存在則回傳 ``1``,否則回傳 ``0``。" + +#: ../../c-api/init_config.rst:145 +msgid "Get an integer configuration option." +msgstr "" + +#: ../../c-api/init_config.rst:147 ../../c-api/init_config.rst:156 +msgid "Set *\\*value*, and return ``0`` on success." +msgstr "" + +#: ../../c-api/init_config.rst:148 ../../c-api/init_config.rst:157 +#: ../../c-api/init_config.rst:172 ../../c-api/init_config.rst:200 +#: ../../c-api/init_config.rst:209 ../../c-api/init_config.rst:218 +#: ../../c-api/init_config.rst:233 ../../c-api/init_config.rst:249 +msgid "Set an error in *config* and return ``-1`` on error." +msgstr "" + +#: ../../c-api/init_config.rst:153 +msgid "" +"Get a string configuration option as a null-terminated UTF-8 encoded string." +msgstr "" + +#: ../../c-api/init_config.rst:159 +msgid "" +"*\\*value* can be set to ``NULL`` if the option is an optional string and " +"the option is unset." +msgstr "" + +#: ../../c-api/init_config.rst:162 +msgid "" +"On success, the string must be released with ``free(value)`` if it's not " +"``NULL``." +msgstr "" + +#: ../../c-api/init_config.rst:168 +msgid "" +"Get a string list configuration option as an array of null-terminated UTF-8 " +"encoded strings." +msgstr "" + +#: ../../c-api/init_config.rst:171 +msgid "Set *\\*length* and *\\*value*, and return ``0`` on success." +msgstr "" + +#: ../../c-api/init_config.rst:174 +msgid "" +"On success, the string list must be released with " +"``PyInitConfig_FreeStrList(length, items)``." +msgstr "" + +#: ../../c-api/init_config.rst:180 +msgid "Free memory of a string list created by ``PyInitConfig_GetStrList()``." +msgstr "" + +#: ../../c-api/init_config.rst:185 +msgid "Set Options" +msgstr "" + +#: ../../c-api/init_config.rst:190 +msgid "" +"Some configuration options have side effects on other options. This logic is " +"only implemented when ``Py_InitializeFromInitConfig()`` is called, not by " +"the \"Set\" functions below. For example, setting ``dev_mode`` to ``1`` does " +"not set ``faulthandler`` to ``1``." +msgstr "" + +#: ../../c-api/init_config.rst:197 +msgid "Set an integer configuration option." +msgstr "" + +#: ../../c-api/init_config.rst:199 ../../c-api/init_config.rst:208 +#: ../../c-api/init_config.rst:217 ../../c-api/init_config.rst:232 +#: ../../c-api/init_config.rst:248 ../../c-api/init_config.rst:591 +msgid "Return ``0`` on success." +msgstr "成功時回傳 ``0``。" + +#: ../../c-api/init_config.rst:205 +msgid "" +"Set a string configuration option from a null-terminated UTF-8 encoded " +"string. The string is copied." +msgstr "" + +#: ../../c-api/init_config.rst:214 +msgid "" +"Set a string list configuration option from an array of null-terminated " +"UTF-8 encoded strings. The string list is copied." +msgstr "" + +#: ../../c-api/init_config.rst:222 +msgid "Module" +msgstr "模組" + +#: ../../c-api/init_config.rst:226 +msgid "Add a built-in extension module to the table of built-in modules." +msgstr "" + +#: ../../c-api/init_config.rst:228 +msgid "" +"The new module can be imported by the name *name*, and uses the function " +"*initfunc* as the initialization function called on the first attempted " +"import." +msgstr "" + +#: ../../c-api/init_config.rst:235 +msgid "" +"If Python is initialized multiple times, ``PyInitConfig_AddModule()`` must " +"be called at each Python initialization." +msgstr "" + +#: ../../c-api/init_config.rst:238 +msgid "Similar to the :c:func:`PyImport_AppendInittab` function." +msgstr "和 :c:func:`PyImport_AppendInittab` 函式類似。" + +#: ../../c-api/init_config.rst:242 +msgid "Initialize Python" +msgstr "初始化 Python" + +#: ../../c-api/init_config.rst:246 +msgid "Initialize Python from the initialization configuration." +msgstr "" + +#: ../../c-api/init_config.rst:250 +msgid "Set an exit code in *config* and return ``-1`` if Python wants to exit." +msgstr "" + +#: ../../c-api/init_config.rst:253 +msgid "See ``PyInitConfig_GetExitcode()`` for the exit code case." +msgstr "" + +#: ../../c-api/init_config.rst:259 +msgid "Configuration Options" +msgstr "" + +#: ../../c-api/init_config.rst:264 +msgid "Option" +msgstr "選項" + +#: ../../c-api/init_config.rst:265 +msgid "PyConfig/PyPreConfig member" +msgstr "PyConfig/PyPreConfig 成員" + +#: ../../c-api/init_config.rst:266 +msgid "Type" +msgstr "" + +#: ../../c-api/init_config.rst:267 +msgid "Visibility" +msgstr "" + +#: ../../c-api/init_config.rst:268 +msgid "``\"allocator\"``" +msgstr "``\"allocator\"``" + +#: ../../c-api/init_config.rst:269 +msgid ":c:member:`allocator `" +msgstr ":c:member:`allocator `" + +#: ../../c-api/init_config.rst:270 ../../c-api/init_config.rst:294 +#: ../../c-api/init_config.rst:322 ../../c-api/init_config.rst:358 +#: ../../c-api/init_config.rst:366 ../../c-api/init_config.rst:378 +#: ../../c-api/init_config.rst:406 ../../c-api/init_config.rst:494 +#: ../../c-api/init_config.rst:522 ../../c-api/init_config.rst:576 +msgid "``int``" +msgstr "``int``" + +#: ../../c-api/init_config.rst:271 ../../c-api/init_config.rst:291 +#: ../../c-api/init_config.rst:299 ../../c-api/init_config.rst:303 +#: ../../c-api/init_config.rst:307 ../../c-api/init_config.rst:311 +#: ../../c-api/init_config.rst:315 ../../c-api/init_config.rst:319 +#: ../../c-api/init_config.rst:327 ../../c-api/init_config.rst:331 +#: ../../c-api/init_config.rst:335 ../../c-api/init_config.rst:347 +#: ../../c-api/init_config.rst:351 ../../c-api/init_config.rst:355 +#: ../../c-api/init_config.rst:359 ../../c-api/init_config.rst:363 +#: ../../c-api/init_config.rst:367 ../../c-api/init_config.rst:375 +#: ../../c-api/init_config.rst:387 ../../c-api/init_config.rst:391 +#: ../../c-api/init_config.rst:395 ../../c-api/init_config.rst:399 +#: ../../c-api/init_config.rst:411 ../../c-api/init_config.rst:415 +#: ../../c-api/init_config.rst:423 ../../c-api/init_config.rst:427 +#: ../../c-api/init_config.rst:439 ../../c-api/init_config.rst:451 +#: ../../c-api/init_config.rst:455 ../../c-api/init_config.rst:459 +#: ../../c-api/init_config.rst:463 ../../c-api/init_config.rst:467 +#: ../../c-api/init_config.rst:471 ../../c-api/init_config.rst:475 +#: ../../c-api/init_config.rst:479 ../../c-api/init_config.rst:483 +#: ../../c-api/init_config.rst:487 ../../c-api/init_config.rst:495 +#: ../../c-api/init_config.rst:503 ../../c-api/init_config.rst:507 +#: ../../c-api/init_config.rst:511 ../../c-api/init_config.rst:515 +#: ../../c-api/init_config.rst:519 ../../c-api/init_config.rst:527 +#: ../../c-api/init_config.rst:543 +msgid "Read-only" +msgstr "唯讀" + +#: ../../c-api/init_config.rst:272 +msgid "``\"argv\"``" +msgstr "``\"argv\"``" + +#: ../../c-api/init_config.rst:273 +msgid ":c:member:`argv `" +msgstr ":c:member:`argv `" + +#: ../../c-api/init_config.rst:274 ../../c-api/init_config.rst:402 +#: ../../c-api/init_config.rst:410 ../../c-api/init_config.rst:530 +#: ../../c-api/init_config.rst:578 +msgid "``list[str]``" +msgstr "``list[str]``" + +#: ../../c-api/init_config.rst:275 ../../c-api/init_config.rst:279 +#: ../../c-api/init_config.rst:283 ../../c-api/init_config.rst:287 +#: ../../c-api/init_config.rst:295 ../../c-api/init_config.rst:323 +#: ../../c-api/init_config.rst:339 ../../c-api/init_config.rst:343 +#: ../../c-api/init_config.rst:371 ../../c-api/init_config.rst:379 +#: ../../c-api/init_config.rst:383 ../../c-api/init_config.rst:403 +#: ../../c-api/init_config.rst:407 ../../c-api/init_config.rst:419 +#: ../../c-api/init_config.rst:431 ../../c-api/init_config.rst:435 +#: ../../c-api/init_config.rst:443 ../../c-api/init_config.rst:447 +#: ../../c-api/init_config.rst:491 ../../c-api/init_config.rst:499 +#: ../../c-api/init_config.rst:523 ../../c-api/init_config.rst:531 +#: ../../c-api/init_config.rst:535 ../../c-api/init_config.rst:539 +msgid "Public" +msgstr "公開" + +#: ../../c-api/init_config.rst:276 +msgid "``\"base_exec_prefix\"``" +msgstr "``\"base_exec_prefix\"``" + +#: ../../c-api/init_config.rst:277 +msgid ":c:member:`base_exec_prefix `" +msgstr ":c:member:`base_exec_prefix `" + +#: ../../c-api/init_config.rst:278 ../../c-api/init_config.rst:282 +#: ../../c-api/init_config.rst:286 ../../c-api/init_config.rst:298 +#: ../../c-api/init_config.rst:334 ../../c-api/init_config.rst:338 +#: ../../c-api/init_config.rst:342 ../../c-api/init_config.rst:350 +#: ../../c-api/init_config.rst:354 ../../c-api/init_config.rst:362 +#: ../../c-api/init_config.rst:430 ../../c-api/init_config.rst:434 +#: ../../c-api/init_config.rst:438 ../../c-api/init_config.rst:442 +#: ../../c-api/init_config.rst:450 ../../c-api/init_config.rst:454 +#: ../../c-api/init_config.rst:458 ../../c-api/init_config.rst:462 +#: ../../c-api/init_config.rst:482 ../../c-api/init_config.rst:486 +#: ../../c-api/init_config.rst:490 ../../c-api/init_config.rst:577 +msgid "``str``" +msgstr "``str``" + +#: ../../c-api/init_config.rst:280 +msgid "``\"base_executable\"``" +msgstr "``\"base_executable\"``" + +#: ../../c-api/init_config.rst:281 +msgid ":c:member:`base_executable `" +msgstr ":c:member:`base_executable `" + +#: ../../c-api/init_config.rst:284 +msgid "``\"base_prefix\"``" +msgstr "``\"base_prefix\"``" + +#: ../../c-api/init_config.rst:285 +msgid ":c:member:`base_prefix `" +msgstr ":c:member:`base_prefix `" + +#: ../../c-api/init_config.rst:288 +msgid "``\"buffered_stdio\"``" +msgstr "``\"buffered_stdio\"``" + +#: ../../c-api/init_config.rst:289 +msgid ":c:member:`buffered_stdio `" +msgstr ":c:member:`buffered_stdio `" + +#: ../../c-api/init_config.rst:290 ../../c-api/init_config.rst:302 +#: ../../c-api/init_config.rst:306 ../../c-api/init_config.rst:310 +#: ../../c-api/init_config.rst:314 ../../c-api/init_config.rst:318 +#: ../../c-api/init_config.rst:326 ../../c-api/init_config.rst:330 +#: ../../c-api/init_config.rst:346 ../../c-api/init_config.rst:370 +#: ../../c-api/init_config.rst:374 ../../c-api/init_config.rst:382 +#: ../../c-api/init_config.rst:386 ../../c-api/init_config.rst:390 +#: ../../c-api/init_config.rst:394 ../../c-api/init_config.rst:398 +#: ../../c-api/init_config.rst:414 ../../c-api/init_config.rst:418 +#: ../../c-api/init_config.rst:422 ../../c-api/init_config.rst:426 +#: ../../c-api/init_config.rst:446 ../../c-api/init_config.rst:466 +#: ../../c-api/init_config.rst:470 ../../c-api/init_config.rst:474 +#: ../../c-api/init_config.rst:478 ../../c-api/init_config.rst:498 +#: ../../c-api/init_config.rst:502 ../../c-api/init_config.rst:506 +#: ../../c-api/init_config.rst:510 ../../c-api/init_config.rst:514 +#: ../../c-api/init_config.rst:518 ../../c-api/init_config.rst:526 +#: ../../c-api/init_config.rst:534 ../../c-api/init_config.rst:542 +#: ../../c-api/init_config.rst:575 +msgid "``bool``" +msgstr "``bool``" + +#: ../../c-api/init_config.rst:292 +msgid "``\"bytes_warning\"``" +msgstr "``\"bytes_warning\"``" + +#: ../../c-api/init_config.rst:293 +msgid ":c:member:`bytes_warning `" +msgstr ":c:member:`bytes_warning `" + +#: ../../c-api/init_config.rst:296 +msgid "``\"check_hash_pycs_mode\"``" +msgstr "``\"check_hash_pycs_mode\"``" + +#: ../../c-api/init_config.rst:297 +msgid ":c:member:`check_hash_pycs_mode `" +msgstr ":c:member:`check_hash_pycs_mode `" + +#: ../../c-api/init_config.rst:300 +msgid "``\"code_debug_ranges\"``" +msgstr "``\"code_debug_ranges\"``" + +#: ../../c-api/init_config.rst:301 +msgid ":c:member:`code_debug_ranges `" +msgstr ":c:member:`code_debug_ranges `" + +#: ../../c-api/init_config.rst:304 +msgid "``\"coerce_c_locale\"``" +msgstr "``\"coerce_c_locale\"``" + +#: ../../c-api/init_config.rst:305 +msgid ":c:member:`coerce_c_locale `" +msgstr ":c:member:`coerce_c_locale `" + +#: ../../c-api/init_config.rst:308 +msgid "``\"coerce_c_locale_warn\"``" +msgstr "``\"coerce_c_locale_warn\"``" + +#: ../../c-api/init_config.rst:309 +msgid ":c:member:`coerce_c_locale_warn `" +msgstr ":c:member:`coerce_c_locale_warn `" + +#: ../../c-api/init_config.rst:312 +msgid "``\"configure_c_stdio\"``" +msgstr "``\"configure_c_stdio\"``" + +#: ../../c-api/init_config.rst:313 +msgid ":c:member:`configure_c_stdio `" +msgstr ":c:member:`configure_c_stdio `" + +#: ../../c-api/init_config.rst:316 +msgid "``\"configure_locale\"``" +msgstr "``\"configure_locale\"``" + +#: ../../c-api/init_config.rst:317 +msgid ":c:member:`configure_locale `" +msgstr ":c:member:`configure_locale `" + +#: ../../c-api/init_config.rst:320 +msgid "``\"cpu_count\"``" +msgstr "``\"cpu_count\"``" + +#: ../../c-api/init_config.rst:321 +msgid ":c:member:`cpu_count `" +msgstr ":c:member:`cpu_count `" + +#: ../../c-api/init_config.rst:324 +msgid "``\"dev_mode\"``" +msgstr "``\"dev_mode\"``" + +#: ../../c-api/init_config.rst:325 +msgid ":c:member:`dev_mode `" +msgstr ":c:member:`dev_mode `" + +#: ../../c-api/init_config.rst:328 +msgid "``\"dump_refs\"``" +msgstr "``\"dump_refs\"``" + +#: ../../c-api/init_config.rst:329 +msgid ":c:member:`dump_refs `" +msgstr ":c:member:`dump_refs `" + +#: ../../c-api/init_config.rst:332 +msgid "``\"dump_refs_file\"``" +msgstr "``\"dump_refs_file\"``" + +#: ../../c-api/init_config.rst:333 +msgid ":c:member:`dump_refs_file `" +msgstr ":c:member:`dump_refs_file `" + +#: ../../c-api/init_config.rst:336 +msgid "``\"exec_prefix\"``" +msgstr "``\"exec_prefix\"``" + +#: ../../c-api/init_config.rst:337 +msgid ":c:member:`exec_prefix `" +msgstr ":c:member:`exec_prefix `" + +#: ../../c-api/init_config.rst:340 +msgid "``\"executable\"``" +msgstr "``\"executable\"``" + +#: ../../c-api/init_config.rst:341 +msgid ":c:member:`executable `" +msgstr ":c:member:`executable `" + +#: ../../c-api/init_config.rst:344 +msgid "``\"faulthandler\"``" +msgstr "``\"faulthandler\"``" + +#: ../../c-api/init_config.rst:345 +msgid ":c:member:`faulthandler `" +msgstr ":c:member:`faulthandler `" + +#: ../../c-api/init_config.rst:348 +msgid "``\"filesystem_encoding\"``" +msgstr "``\"filesystem_encoding\"``" + +#: ../../c-api/init_config.rst:349 +msgid ":c:member:`filesystem_encoding `" +msgstr ":c:member:`filesystem_encoding `" + +#: ../../c-api/init_config.rst:352 +msgid "``\"filesystem_errors\"``" +msgstr "``\"filesystem_errors\"``" + +#: ../../c-api/init_config.rst:353 +msgid ":c:member:`filesystem_errors `" +msgstr ":c:member:`filesystem_errors `" + +#: ../../c-api/init_config.rst:356 +msgid "``\"hash_seed\"``" +msgstr "``\"hash_seed\"``" + +#: ../../c-api/init_config.rst:357 +msgid ":c:member:`hash_seed `" +msgstr ":c:member:`hash_seed `" + +#: ../../c-api/init_config.rst:360 +msgid "``\"home\"``" +msgstr "``\"home\"``" + +#: ../../c-api/init_config.rst:361 +msgid ":c:member:`home `" +msgstr ":c:member:`home `" + +#: ../../c-api/init_config.rst:364 +msgid "``\"import_time\"``" +msgstr "``\"import_time\"``" + +#: ../../c-api/init_config.rst:365 +msgid ":c:member:`import_time `" +msgstr ":c:member:`import_time `" + +#: ../../c-api/init_config.rst:368 +msgid "``\"inspect\"``" +msgstr "``\"inspect\"``" + +#: ../../c-api/init_config.rst:369 +msgid ":c:member:`inspect `" +msgstr ":c:member:`inspect `" + +#: ../../c-api/init_config.rst:372 +msgid "``\"install_signal_handlers\"``" +msgstr "``\"install_signal_handlers\"``" + +#: ../../c-api/init_config.rst:373 +msgid ":c:member:`install_signal_handlers `" +msgstr ":c:member:`install_signal_handlers `" + +#: ../../c-api/init_config.rst:376 +msgid "``\"int_max_str_digits\"``" +msgstr "``\"int_max_str_digits\"``" + +#: ../../c-api/init_config.rst:377 +msgid ":c:member:`int_max_str_digits `" +msgstr ":c:member:`int_max_str_digits `" + +#: ../../c-api/init_config.rst:380 +msgid "``\"interactive\"``" +msgstr "``\"interactive\"``" + +#: ../../c-api/init_config.rst:381 +msgid ":c:member:`interactive `" +msgstr ":c:member:`interactive `" + +#: ../../c-api/init_config.rst:384 +msgid "``\"isolated\"``" +msgstr "``\"isolated\"``" + +#: ../../c-api/init_config.rst:385 +msgid ":c:member:`isolated `" +msgstr ":c:member:`isolated `" + +#: ../../c-api/init_config.rst:388 +msgid "``\"legacy_windows_fs_encoding\"``" +msgstr "``\"legacy_windows_fs_encoding\"``" + +#: ../../c-api/init_config.rst:389 +msgid "" +":c:member:`legacy_windows_fs_encoding `" +msgstr "" +":c:member:`legacy_windows_fs_encoding `" + +#: ../../c-api/init_config.rst:392 +msgid "``\"legacy_windows_stdio\"``" +msgstr "``\"legacy_windows_stdio\"``" + +#: ../../c-api/init_config.rst:393 +msgid ":c:member:`legacy_windows_stdio `" +msgstr ":c:member:`legacy_windows_stdio `" + +#: ../../c-api/init_config.rst:396 +msgid "``\"malloc_stats\"``" +msgstr "``\"malloc_stats\"``" + +#: ../../c-api/init_config.rst:397 +msgid ":c:member:`malloc_stats `" +msgstr ":c:member:`malloc_stats `" + +#: ../../c-api/init_config.rst:400 +msgid "``\"module_search_paths\"``" +msgstr "``\"module_search_paths\"``" + +#: ../../c-api/init_config.rst:401 +msgid ":c:member:`module_search_paths `" +msgstr ":c:member:`module_search_paths `" + +#: ../../c-api/init_config.rst:404 +msgid "``\"optimization_level\"``" +msgstr "``\"optimization_level\"``" + +#: ../../c-api/init_config.rst:405 +msgid ":c:member:`optimization_level `" +msgstr ":c:member:`optimization_level `" + +#: ../../c-api/init_config.rst:408 +msgid "``\"orig_argv\"``" +msgstr "``\"orig_argv\"``" + +#: ../../c-api/init_config.rst:409 +msgid ":c:member:`orig_argv `" +msgstr ":c:member:`orig_argv `" + +#: ../../c-api/init_config.rst:412 +msgid "``\"parse_argv\"``" +msgstr "``\"parse_argv\"``" + +#: ../../c-api/init_config.rst:413 +msgid ":c:member:`parse_argv `" +msgstr ":c:member:`parse_argv `" + +#: ../../c-api/init_config.rst:416 +msgid "``\"parser_debug\"``" +msgstr "``\"parser_debug\"``" + +#: ../../c-api/init_config.rst:417 +msgid ":c:member:`parser_debug `" +msgstr ":c:member:`parser_debug `" + +#: ../../c-api/init_config.rst:420 +msgid "``\"pathconfig_warnings\"``" +msgstr "``\"pathconfig_warnings\"``" + +#: ../../c-api/init_config.rst:421 +msgid ":c:member:`pathconfig_warnings `" +msgstr ":c:member:`pathconfig_warnings `" + +#: ../../c-api/init_config.rst:424 +msgid "``\"perf_profiling\"``" +msgstr "``\"perf_profiling\"``" + +#: ../../c-api/init_config.rst:425 +msgid ":c:member:`perf_profiling `" +msgstr ":c:member:`perf_profiling `" + +#: ../../c-api/init_config.rst:428 +msgid "``\"platlibdir\"``" +msgstr "``\"platlibdir\"``" + +#: ../../c-api/init_config.rst:429 +msgid ":c:member:`platlibdir `" +msgstr ":c:member:`platlibdir `" + +#: ../../c-api/init_config.rst:432 +msgid "``\"prefix\"``" +msgstr "``\"prefix\"``" + +#: ../../c-api/init_config.rst:433 +msgid ":c:member:`prefix `" +msgstr ":c:member:`prefix `" + +#: ../../c-api/init_config.rst:436 +msgid "``\"program_name\"``" +msgstr "``\"surrogateescape\"``" + +#: ../../c-api/init_config.rst:437 +msgid ":c:member:`program_name `" +msgstr ":c:member:`program_name `" + +#: ../../c-api/init_config.rst:440 +msgid "``\"pycache_prefix\"``" +msgstr "``\"pycache_prefix\"``" + +#: ../../c-api/init_config.rst:441 +msgid ":c:member:`pycache_prefix `" +msgstr ":c:member:`pycache_prefix `" + +#: ../../c-api/init_config.rst:444 +msgid "``\"quiet\"``" +msgstr "``\"quiet\"``" + +#: ../../c-api/init_config.rst:445 +msgid ":c:member:`quiet `" +msgstr ":c:member:`quiet `" + +#: ../../c-api/init_config.rst:448 +msgid "``\"run_command\"``" +msgstr "``\"run_command\"``" + +#: ../../c-api/init_config.rst:449 +msgid ":c:member:`run_command `" +msgstr ":c:member:`run_command `" + +#: ../../c-api/init_config.rst:452 +msgid "``\"run_filename\"``" +msgstr "``\"run_filename\"``" + +#: ../../c-api/init_config.rst:453 +msgid ":c:member:`run_filename `" +msgstr ":c:member:`run_filename `" + +#: ../../c-api/init_config.rst:456 +msgid "``\"run_module\"``" +msgstr "``\"run_module\"``" + +#: ../../c-api/init_config.rst:457 +msgid ":c:member:`run_module `" +msgstr ":c:member:`run_module `" + +#: ../../c-api/init_config.rst:460 +msgid "``\"run_presite\"``" +msgstr "``\"run_presite\"``" + +#: ../../c-api/init_config.rst:461 +msgid ":c:member:`run_presite `" +msgstr ":c:member:`run_presite `" + +#: ../../c-api/init_config.rst:464 +msgid "``\"safe_path\"``" +msgstr "``\"safe_path\"``" + +#: ../../c-api/init_config.rst:465 +msgid ":c:member:`safe_path `" +msgstr ":c:member:`safe_path `" + +#: ../../c-api/init_config.rst:468 +msgid "``\"show_ref_count\"``" +msgstr "``\"show_ref_count\"``" + +#: ../../c-api/init_config.rst:469 +msgid ":c:member:`show_ref_count `" +msgstr ":c:member:`show_ref_count `" + +#: ../../c-api/init_config.rst:472 +msgid "``\"site_import\"``" +msgstr "``\"site_import\"``" + +#: ../../c-api/init_config.rst:473 +msgid ":c:member:`site_import `" +msgstr ":c:member:`site_import `" + +#: ../../c-api/init_config.rst:476 +msgid "``\"skip_source_first_line\"``" +msgstr "``\"skip_source_first_line\"``" + +#: ../../c-api/init_config.rst:477 +msgid ":c:member:`skip_source_first_line `" +msgstr ":c:member:`skip_source_first_line `" + +#: ../../c-api/init_config.rst:480 +msgid "``\"stdio_encoding\"``" +msgstr "``\"stdio_encoding\"``" + +#: ../../c-api/init_config.rst:481 +msgid ":c:member:`stdio_encoding `" +msgstr ":c:member:`stdio_encoding `" + +#: ../../c-api/init_config.rst:484 +msgid "``\"stdio_errors\"``" +msgstr "``\"stdio_errors\"``" + +#: ../../c-api/init_config.rst:485 +msgid ":c:member:`stdio_errors `" +msgstr ":c:member:`stdio_errors `" + +#: ../../c-api/init_config.rst:488 +msgid "``\"stdlib_dir\"``" +msgstr "``\"stdlib_dir\"``" + +#: ../../c-api/init_config.rst:489 +msgid ":c:member:`stdlib_dir `" +msgstr ":c:member:`stdlib_dir `" + +#: ../../c-api/init_config.rst:492 +msgid "``\"tracemalloc\"``" +msgstr "``\"tracemalloc\"``" + +#: ../../c-api/init_config.rst:493 +msgid ":c:member:`tracemalloc `" +msgstr ":c:member:`tracemalloc `" + +#: ../../c-api/init_config.rst:496 +msgid "``\"use_environment\"``" +msgstr "``\"use_environment\"``" + +#: ../../c-api/init_config.rst:497 +msgid ":c:member:`use_environment `" +msgstr ":c:member:`use_environment `" + +#: ../../c-api/init_config.rst:500 +msgid "``\"use_frozen_modules\"``" +msgstr "``\"use_frozen_modules\"``" + +#: ../../c-api/init_config.rst:501 +msgid ":c:member:`use_frozen_modules `" +msgstr ":c:member:`use_frozen_modules `" + +#: ../../c-api/init_config.rst:504 +msgid "``\"use_hash_seed\"``" +msgstr "``\"use_hash_seed\"``" + +#: ../../c-api/init_config.rst:505 +msgid ":c:member:`use_hash_seed `" +msgstr ":c:member:`use_hash_seed `" + +#: ../../c-api/init_config.rst:508 +msgid "``\"use_system_logger\"``" +msgstr "``\"use_system_logger\"``" + +#: ../../c-api/init_config.rst:509 +msgid ":c:member:`use_system_logger `" +msgstr ":c:member:`use_system_logger `" + +#: ../../c-api/init_config.rst:512 +msgid "``\"user_site_directory\"``" +msgstr "``\"user_site_directory\"``" + +#: ../../c-api/init_config.rst:513 +msgid ":c:member:`user_site_directory `" +msgstr ":c:member:`user_site_directory `" + +#: ../../c-api/init_config.rst:516 +msgid "``\"utf8_mode\"``" +msgstr "``\"utf8_mode\"``" + +#: ../../c-api/init_config.rst:517 +msgid ":c:member:`utf8_mode `" +msgstr ":c:member:`utf8_mode `" + +#: ../../c-api/init_config.rst:520 +msgid "``\"verbose\"``" +msgstr "``\"verbose\"``" + +#: ../../c-api/init_config.rst:521 +msgid ":c:member:`verbose `" +msgstr ":c:member:`verbose `" + +#: ../../c-api/init_config.rst:524 +msgid "``\"warn_default_encoding\"``" +msgstr "``\"warn_default_encoding\"``" + +#: ../../c-api/init_config.rst:525 +msgid ":c:member:`warn_default_encoding `" +msgstr ":c:member:`warn_default_encoding `" + +#: ../../c-api/init_config.rst:528 +msgid "``\"warnoptions\"``" +msgstr "``\"warnoptions\"``" + +#: ../../c-api/init_config.rst:529 +msgid ":c:member:`warnoptions `" +msgstr ":c:member:`warnoptions `" + +#: ../../c-api/init_config.rst:532 +msgid "``\"write_bytecode\"``" +msgstr "``\"write_bytecode\"``" + +#: ../../c-api/init_config.rst:533 +msgid ":c:member:`write_bytecode `" +msgstr ":c:member:`write_bytecode `" + +#: ../../c-api/init_config.rst:536 +msgid "``\"xoptions\"``" +msgstr "``\"xoptions\"``" + +#: ../../c-api/init_config.rst:537 +msgid ":c:member:`xoptions `" +msgstr ":c:member:`xoptions `" + +#: ../../c-api/init_config.rst:538 ../../c-api/init_config.rst:579 +msgid "``dict[str, str]``" +msgstr "``dict[str, str]``" + +#: ../../c-api/init_config.rst:540 +msgid "``\"_pystats\"``" +msgstr "``\"_pystats\"``" + +#: ../../c-api/init_config.rst:541 +msgid ":c:member:`_pystats `" +msgstr ":c:member:`_pystats `" + +#: ../../c-api/init_config.rst:545 +msgid "Visibility:" +msgstr "" + +#: ../../c-api/init_config.rst:547 +msgid "" +"Public: Can by get by :c:func:`PyConfig_Get` and set by :c:func:" +"`PyConfig_Set`." +msgstr "" + +#: ../../c-api/init_config.rst:549 +msgid "" +"Read-only: Can by get by :c:func:`PyConfig_Get`, but cannot be set by :c:" +"func:`PyConfig_Set`." +msgstr "" + +#: ../../c-api/init_config.rst:554 +msgid "Runtime Python configuration API" +msgstr "" + +#: ../../c-api/init_config.rst:556 +msgid "" +"At runtime, it's possible to get and set configuration options using :c:func:" +"`PyConfig_Get` and :c:func:`PyConfig_Set` functions." +msgstr "" + +#: ../../c-api/init_config.rst:562 +msgid "" +"Some options are read from the :mod:`sys` attributes. For example, the " +"option ``\"argv\"`` is read from :data:`sys.argv`." +msgstr "" + +#: ../../c-api/init_config.rst:568 +msgid "" +"Get the current runtime value of a configuration option as a Python object." +msgstr "" + +#: ../../c-api/init_config.rst:570 ../../c-api/init_config.rst:601 +msgid "Return a new reference on success." +msgstr "" + +#: ../../c-api/init_config.rst:571 ../../c-api/init_config.rst:602 +msgid "Set an exception and return ``NULL`` on error." +msgstr "" + +#: ../../c-api/init_config.rst:573 +msgid "The object type depends on the configuration option. It can be:" +msgstr "" + +#: ../../c-api/init_config.rst:581 ../../c-api/init_config.rst:604 +#: ../../c-api/init_config.rst:619 +msgid "" +"The caller must have an :term:`attached thread state`. The function cannot " +"be called before Python initialization nor after Python finalization." +msgstr "" + +#: ../../c-api/init_config.rst:589 +msgid "Similar to :c:func:`PyConfig_Get`, but get the value as a C int." +msgstr "" + +#: ../../c-api/init_config.rst:592 +msgid "Set an exception and return ``-1`` on error." +msgstr "" + +#: ../../c-api/init_config.rst:599 +msgid "Get all configuration option names as a ``frozenset``." +msgstr "" + +#: ../../c-api/init_config.rst:612 +msgid "Set the current runtime value of a configuration option." +msgstr "" + +#: ../../c-api/init_config.rst:614 +msgid "Raise a :exc:`ValueError` if there is no option *name*." +msgstr "如果沒有選項 *name*,則引發 :exc:`ValueError`。" + +#: ../../c-api/init_config.rst:615 +msgid "Raise a :exc:`ValueError` if *value* is an invalid value." +msgstr "如果 *value* 是無效值,則引發 :exc:`ValueError`。" + +#: ../../c-api/init_config.rst:616 +msgid "Raise a :exc:`ValueError` if the option is read-only (cannot be set)." +msgstr "如果選項是唯讀的(無法設定),則引發 :exc:`ValueError`。" + +#: ../../c-api/init_config.rst:617 +msgid "Raise a :exc:`TypeError` if *value* has not the proper type." +msgstr "" + +#: ../../c-api/init_config.rst:622 +msgid "" +"Raises an :ref:`auditing event ` ``cpython.PyConfig_Set`` with " +"arguments ``name``, ``value``." +msgstr "" + +#: ../../c-api/init_config.rst:630 +msgid "PyConfig C API" +msgstr "PyConfig C API" + +#: ../../c-api/init_config.rst:634 msgid "" "Python can be initialized with :c:func:`Py_InitializeFromConfig` and the :c:" "type:`PyConfig` structure. It can be preinitialized with :c:func:" "`Py_PreInitialize` and the :c:type:`PyPreConfig` structure." msgstr "" -#: ../../c-api/init_config.rst:15 +#: ../../c-api/init_config.rst:638 msgid "There are two kinds of configuration:" msgstr "" -#: ../../c-api/init_config.rst:17 +#: ../../c-api/init_config.rst:640 msgid "" "The :ref:`Python Configuration ` can be used to build a " "customized Python which behaves as the regular Python. For example, " @@ -41,7 +1109,7 @@ msgid "" "Python." msgstr "" -#: ../../c-api/init_config.rst:22 +#: ../../c-api/init_config.rst:645 msgid "" "The :ref:`Isolated Configuration ` can be used to embed " "Python into an application. It isolates Python from the system. For example, " @@ -49,30 +1117,15 @@ msgid "" "no signal handler is registered." msgstr "" -#: ../../c-api/init_config.rst:27 -msgid "" -"The :c:func:`Py_RunMain` function can be used to write a customized Python " -"program." -msgstr "" - -#: ../../c-api/init_config.rst:30 -msgid "" -"See also :ref:`Initialization, Finalization, and Threads `." -msgstr "" - -#: ../../c-api/init_config.rst:33 +#: ../../c-api/init_config.rst:656 msgid ":pep:`587` \"Python Initialization Configuration\"." msgstr "" -#: ../../c-api/init_config.rst:37 -msgid "Example" -msgstr "範例" - -#: ../../c-api/init_config.rst:39 +#: ../../c-api/init_config.rst:662 msgid "Example of customized Python always running in isolated mode::" msgstr "" -#: ../../c-api/init_config.rst:41 +#: ../../c-api/init_config.rst:664 msgid "" "int main(int argc, char **argv)\n" "{\n" @@ -108,144 +1161,144 @@ msgid "" "}" msgstr "" -#: ../../c-api/init_config.rst:76 +#: ../../c-api/init_config.rst:699 msgid "PyWideStringList" msgstr "PyWideStringList" -#: ../../c-api/init_config.rst:80 +#: ../../c-api/init_config.rst:703 msgid "List of ``wchar_t*`` strings." msgstr "``wchar_t*`` 字串串列。" -#: ../../c-api/init_config.rst:82 +#: ../../c-api/init_config.rst:705 msgid "" "If *length* is non-zero, *items* must be non-``NULL`` and all strings must " "be non-``NULL``." msgstr "" -#: ../../c-api/init_config.rst:87 +#: ../../c-api/init_config.rst:710 msgid "Methods:" msgstr "方法:" -#: ../../c-api/init_config.rst:91 +#: ../../c-api/init_config.rst:714 msgid "Append *item* to *list*." msgstr "" -#: ../../c-api/init_config.rst:93 ../../c-api/init_config.rst:104 +#: ../../c-api/init_config.rst:716 ../../c-api/init_config.rst:727 msgid "Python must be preinitialized to call this function." msgstr "" -#: ../../c-api/init_config.rst:97 +#: ../../c-api/init_config.rst:720 msgid "Insert *item* into *list* at *index*." msgstr "" -#: ../../c-api/init_config.rst:99 +#: ../../c-api/init_config.rst:722 msgid "" "If *index* is greater than or equal to *list* length, append *item* to " "*list*." msgstr "" -#: ../../c-api/init_config.rst:102 +#: ../../c-api/init_config.rst:725 msgid "*index* must be greater than or equal to ``0``." msgstr "" -#: ../../c-api/init_config.rst:108 ../../c-api/init_config.rst:128 -#: ../../c-api/init_config.rst:235 ../../c-api/init_config.rst:554 +#: ../../c-api/init_config.rst:731 ../../c-api/init_config.rst:751 +#: ../../c-api/init_config.rst:858 ../../c-api/init_config.rst:1177 msgid "Structure fields:" msgstr "" -#: ../../c-api/init_config.rst:112 +#: ../../c-api/init_config.rst:735 msgid "List length." msgstr "串列長度。" -#: ../../c-api/init_config.rst:116 +#: ../../c-api/init_config.rst:739 msgid "List items." msgstr "" -#: ../../c-api/init_config.rst:119 +#: ../../c-api/init_config.rst:742 msgid "PyStatus" msgstr "PyStatus" -#: ../../c-api/init_config.rst:123 +#: ../../c-api/init_config.rst:746 msgid "" "Structure to store an initialization function status: success, error or exit." msgstr "" -#: ../../c-api/init_config.rst:126 +#: ../../c-api/init_config.rst:749 msgid "For an error, it can store the C function name which created the error." msgstr "" -#: ../../c-api/init_config.rst:132 +#: ../../c-api/init_config.rst:755 msgid "Exit code. Argument passed to ``exit()``." msgstr "" -#: ../../c-api/init_config.rst:136 +#: ../../c-api/init_config.rst:759 msgid "Error message." msgstr "錯誤訊息。" -#: ../../c-api/init_config.rst:140 +#: ../../c-api/init_config.rst:763 msgid "Name of the function which created an error, can be ``NULL``." msgstr "" -#: ../../c-api/init_config.rst:144 +#: ../../c-api/init_config.rst:767 msgid "Functions to create a status:" -msgstr "" +msgstr "建立狀態的函式:" -#: ../../c-api/init_config.rst:148 +#: ../../c-api/init_config.rst:771 msgid "Success." -msgstr "" +msgstr "成功。" -#: ../../c-api/init_config.rst:152 +#: ../../c-api/init_config.rst:775 msgid "Initialization error with a message." -msgstr "" +msgstr "附帶訊息的初始化錯誤。" -#: ../../c-api/init_config.rst:154 +#: ../../c-api/init_config.rst:777 msgid "*err_msg* must not be ``NULL``." msgstr "*err_msg* 不可為 ``NULL``。" -#: ../../c-api/init_config.rst:158 +#: ../../c-api/init_config.rst:781 msgid "Memory allocation failure (out of memory)." msgstr "" -#: ../../c-api/init_config.rst:162 +#: ../../c-api/init_config.rst:785 msgid "Exit Python with the specified exit code." -msgstr "" +msgstr "以指定的退出代號退出 Python。" -#: ../../c-api/init_config.rst:164 +#: ../../c-api/init_config.rst:787 msgid "Functions to handle a status:" -msgstr "" +msgstr "處理狀態的函式:" -#: ../../c-api/init_config.rst:168 +#: ../../c-api/init_config.rst:791 msgid "" "Is the status an error or an exit? If true, the exception must be handled; " "by calling :c:func:`Py_ExitStatusException` for example." msgstr "" -#: ../../c-api/init_config.rst:173 +#: ../../c-api/init_config.rst:796 msgid "Is the result an error?" msgstr "" -#: ../../c-api/init_config.rst:177 +#: ../../c-api/init_config.rst:800 msgid "Is the result an exit?" msgstr "" -#: ../../c-api/init_config.rst:181 +#: ../../c-api/init_config.rst:804 msgid "" "Call ``exit(exitcode)`` if *status* is an exit. Print the error message and " "exit with a non-zero exit code if *status* is an error. Must only be called " "if ``PyStatus_Exception(status)`` is non-zero." msgstr "" -#: ../../c-api/init_config.rst:186 +#: ../../c-api/init_config.rst:809 msgid "" "Internally, Python uses macros which set ``PyStatus.func``, whereas " "functions to create a status set ``func`` to ``NULL``." msgstr "" -#: ../../c-api/init_config.rst:189 +#: ../../c-api/init_config.rst:812 msgid "Example::" msgstr "範例: ::" -#: ../../c-api/init_config.rst:191 +#: ../../c-api/init_config.rst:814 msgid "" "PyStatus alloc(void **ptr, size_t size)\n" "{\n" @@ -287,203 +1340,203 @@ msgstr "" " return 0;\n" "}" -#: ../../c-api/init_config.rst:213 +#: ../../c-api/init_config.rst:836 msgid "PyPreConfig" msgstr "PyPreConfig" -#: ../../c-api/init_config.rst:217 +#: ../../c-api/init_config.rst:840 msgid "Structure used to preinitialize Python." msgstr "" -#: ../../c-api/init_config.rst:221 +#: ../../c-api/init_config.rst:844 msgid "Function to initialize a preconfiguration:" msgstr "" -#: ../../c-api/init_config.rst:225 +#: ../../c-api/init_config.rst:848 msgid "" "Initialize the preconfiguration with :ref:`Python Configuration `." msgstr "" -#: ../../c-api/init_config.rst:230 +#: ../../c-api/init_config.rst:853 msgid "" "Initialize the preconfiguration with :ref:`Isolated Configuration `." msgstr "" -#: ../../c-api/init_config.rst:239 +#: ../../c-api/init_config.rst:862 msgid "Name of the Python memory allocators:" msgstr "" -#: ../../c-api/init_config.rst:241 +#: ../../c-api/init_config.rst:864 msgid "" "``PYMEM_ALLOCATOR_NOT_SET`` (``0``): don't change memory allocators (use " "defaults)." msgstr "" -#: ../../c-api/init_config.rst:243 +#: ../../c-api/init_config.rst:866 msgid "" "``PYMEM_ALLOCATOR_DEFAULT`` (``1``): :ref:`default memory allocators " "`." msgstr "" -#: ../../c-api/init_config.rst:245 +#: ../../c-api/init_config.rst:868 msgid "" "``PYMEM_ALLOCATOR_DEBUG`` (``2``): :ref:`default memory allocators ` with :ref:`debug hooks `." msgstr "" -#: ../../c-api/init_config.rst:248 +#: ../../c-api/init_config.rst:871 msgid "``PYMEM_ALLOCATOR_MALLOC`` (``3``): use ``malloc()`` of the C library." msgstr "" -#: ../../c-api/init_config.rst:249 +#: ../../c-api/init_config.rst:872 msgid "" "``PYMEM_ALLOCATOR_MALLOC_DEBUG`` (``4``): force usage of ``malloc()`` with :" "ref:`debug hooks `." msgstr "" -#: ../../c-api/init_config.rst:251 +#: ../../c-api/init_config.rst:874 msgid "" "``PYMEM_ALLOCATOR_PYMALLOC`` (``5``): :ref:`Python pymalloc memory allocator " "`." msgstr "" -#: ../../c-api/init_config.rst:253 +#: ../../c-api/init_config.rst:876 msgid "" "``PYMEM_ALLOCATOR_PYMALLOC_DEBUG`` (``6``): :ref:`Python pymalloc memory " "allocator ` with :ref:`debug hooks `." msgstr "" -#: ../../c-api/init_config.rst:256 +#: ../../c-api/init_config.rst:879 msgid "" "``PYMEM_ALLOCATOR_MIMALLOC`` (``6``): use ``mimalloc``, a fast malloc " "replacement." msgstr "" -#: ../../c-api/init_config.rst:258 +#: ../../c-api/init_config.rst:881 msgid "" "``PYMEM_ALLOCATOR_MIMALLOC_DEBUG`` (``7``): use ``mimalloc``, a fast malloc " "replacement with :ref:`debug hooks `." msgstr "" -#: ../../c-api/init_config.rst:262 +#: ../../c-api/init_config.rst:885 msgid "" "``PYMEM_ALLOCATOR_PYMALLOC`` and ``PYMEM_ALLOCATOR_PYMALLOC_DEBUG`` are not " "supported if Python is :option:`configured using --without-pymalloc <--" "without-pymalloc>`." msgstr "" -#: ../../c-api/init_config.rst:266 +#: ../../c-api/init_config.rst:889 msgid "" "``PYMEM_ALLOCATOR_MIMALLOC`` and ``PYMEM_ALLOCATOR_MIMALLOC_DEBUG`` are not " "supported if Python is :option:`configured using --without-mimalloc <--" "without-mimalloc>` or if the underlying atomic support isn't available." msgstr "" -#: ../../c-api/init_config.rst:271 +#: ../../c-api/init_config.rst:894 msgid "See :ref:`Memory Management `." msgstr "請見\\ :ref:`記憶體管理 `。" -#: ../../c-api/init_config.rst:273 +#: ../../c-api/init_config.rst:896 msgid "Default: ``PYMEM_ALLOCATOR_NOT_SET``." msgstr "預設:``PYMEM_ALLOCATOR_NOT_SET``。" -#: ../../c-api/init_config.rst:277 +#: ../../c-api/init_config.rst:900 msgid "Set the LC_CTYPE locale to the user preferred locale." msgstr "" -#: ../../c-api/init_config.rst:279 +#: ../../c-api/init_config.rst:902 msgid "" "If equals to ``0``, set :c:member:`~PyPreConfig.coerce_c_locale` and :c:" "member:`~PyPreConfig.coerce_c_locale_warn` members to ``0``." msgstr "" -#: ../../c-api/init_config.rst:282 ../../c-api/init_config.rst:293 +#: ../../c-api/init_config.rst:905 ../../c-api/init_config.rst:916 msgid "See the :term:`locale encoding`." msgstr "請見 :term:`locale encoding`。" -#: ../../c-api/init_config.rst:284 ../../c-api/init_config.rst:339 -#: ../../c-api/init_config.rst:710 +#: ../../c-api/init_config.rst:907 ../../c-api/init_config.rst:962 +#: ../../c-api/init_config.rst:1333 msgid "Default: ``1`` in Python config, ``0`` in isolated config." msgstr "" -#: ../../c-api/init_config.rst:288 +#: ../../c-api/init_config.rst:911 msgid "If equals to ``2``, coerce the C locale." msgstr "" -#: ../../c-api/init_config.rst:290 +#: ../../c-api/init_config.rst:913 msgid "" "If equals to ``1``, read the LC_CTYPE locale to decide if it should be " "coerced." msgstr "" -#: ../../c-api/init_config.rst:295 ../../c-api/init_config.rst:301 +#: ../../c-api/init_config.rst:918 ../../c-api/init_config.rst:924 msgid "Default: ``-1`` in Python config, ``0`` in isolated config." msgstr "" -#: ../../c-api/init_config.rst:299 +#: ../../c-api/init_config.rst:922 msgid "If non-zero, emit a warning if the C locale is coerced." msgstr "" -#: ../../c-api/init_config.rst:305 +#: ../../c-api/init_config.rst:928 msgid "" ":ref:`Python Development Mode `: see :c:member:`PyConfig.dev_mode`." msgstr "" -#: ../../c-api/init_config.rst:308 ../../c-api/init_config.rst:719 -#: ../../c-api/init_config.rst:765 ../../c-api/init_config.rst:1244 +#: ../../c-api/init_config.rst:931 ../../c-api/init_config.rst:1342 +#: ../../c-api/init_config.rst:1398 ../../c-api/init_config.rst:1892 msgid "Default: ``-1`` in Python mode, ``0`` in isolated mode." msgstr "" -#: ../../c-api/init_config.rst:312 +#: ../../c-api/init_config.rst:935 msgid "Isolated mode: see :c:member:`PyConfig.isolated`." msgstr "" -#: ../../c-api/init_config.rst:314 ../../c-api/init_config.rst:921 +#: ../../c-api/init_config.rst:937 ../../c-api/init_config.rst:1569 msgid "Default: ``0`` in Python mode, ``1`` in isolated mode." msgstr "" -#: ../../c-api/init_config.rst:318 +#: ../../c-api/init_config.rst:941 msgid "If non-zero:" msgstr "如果不為 0:" -#: ../../c-api/init_config.rst:320 +#: ../../c-api/init_config.rst:943 msgid "Set :c:member:`PyPreConfig.utf8_mode` to ``0``," msgstr "將 :c:member:`PyPreConfig.utf8_mode` 設為 ``0``、" -#: ../../c-api/init_config.rst:321 +#: ../../c-api/init_config.rst:944 msgid "Set :c:member:`PyConfig.filesystem_encoding` to ``\"mbcs\"``," msgstr "將 :c:member:`PyConfig.filesystem_encoding` 設為 ``\"mbcs\"``、" -#: ../../c-api/init_config.rst:322 +#: ../../c-api/init_config.rst:945 msgid "Set :c:member:`PyConfig.filesystem_errors` to ``\"replace\"``." msgstr "將 :c:member:`PyConfig.filesystem_errors` 設為 ``\"replace\"``。" -#: ../../c-api/init_config.rst:324 +#: ../../c-api/init_config.rst:947 msgid "" "Initialized from the :envvar:`PYTHONLEGACYWINDOWSFSENCODING` environment " "variable value." msgstr "" -#: ../../c-api/init_config.rst:327 ../../c-api/init_config.rst:935 +#: ../../c-api/init_config.rst:950 ../../c-api/init_config.rst:1583 msgid "" "Only available on Windows. ``#ifdef MS_WINDOWS`` macro can be used for " "Windows specific code." msgstr "" -#: ../../c-api/init_config.rst:330 ../../c-api/init_config.rst:658 -#: ../../c-api/init_config.rst:665 ../../c-api/init_config.rst:732 -#: ../../c-api/init_config.rst:843 ../../c-api/init_config.rst:857 -#: ../../c-api/init_config.rst:871 ../../c-api/init_config.rst:938 -#: ../../c-api/init_config.rst:952 ../../c-api/init_config.rst:1012 -#: ../../c-api/init_config.rst:1064 ../../c-api/init_config.rst:1126 -#: ../../c-api/init_config.rst:1180 ../../c-api/init_config.rst:1209 -#: ../../c-api/init_config.rst:1298 +#: ../../c-api/init_config.rst:953 ../../c-api/init_config.rst:1281 +#: ../../c-api/init_config.rst:1288 ../../c-api/init_config.rst:1355 +#: ../../c-api/init_config.rst:1487 ../../c-api/init_config.rst:1505 +#: ../../c-api/init_config.rst:1519 ../../c-api/init_config.rst:1586 +#: ../../c-api/init_config.rst:1600 ../../c-api/init_config.rst:1660 +#: ../../c-api/init_config.rst:1712 ../../c-api/init_config.rst:1774 +#: ../../c-api/init_config.rst:1828 ../../c-api/init_config.rst:1857 +#: ../../c-api/init_config.rst:1971 ../../c-api/init_config.rst:2018 msgid "Default: ``0``." msgstr "預設:``0``。" -#: ../../c-api/init_config.rst:334 +#: ../../c-api/init_config.rst:957 msgid "" "If non-zero, :c:func:`Py_PreInitializeFromArgs` and :c:func:" "`Py_PreInitializeFromBytesArgs` parse their ``argv`` argument the same way " @@ -491,95 +1544,95 @@ msgid "" "Arguments `." msgstr "" -#: ../../c-api/init_config.rst:343 +#: ../../c-api/init_config.rst:966 msgid "" "Use :ref:`environment variables `? See :c:member:`PyConfig." "use_environment`." msgstr "" -#: ../../c-api/init_config.rst:346 ../../c-api/init_config.rst:1272 +#: ../../c-api/init_config.rst:969 ../../c-api/init_config.rst:1933 msgid "Default: ``1`` in Python config and ``0`` in isolated config." msgstr "" -#: ../../c-api/init_config.rst:350 +#: ../../c-api/init_config.rst:973 msgid "If non-zero, enable the :ref:`Python UTF-8 Mode `." msgstr "" -#: ../../c-api/init_config.rst:352 +#: ../../c-api/init_config.rst:975 msgid "" "Set to ``0`` or ``1`` by the :option:`-X utf8 <-X>` command line option and " "the :envvar:`PYTHONUTF8` environment variable." msgstr "" -#: ../../c-api/init_config.rst:355 +#: ../../c-api/init_config.rst:978 msgid "Also set to ``1`` if the ``LC_CTYPE`` locale is ``C`` or ``POSIX``." msgstr "" -#: ../../c-api/init_config.rst:357 +#: ../../c-api/init_config.rst:980 msgid "Default: ``-1`` in Python config and ``0`` in isolated config." msgstr "" -#: ../../c-api/init_config.rst:363 +#: ../../c-api/init_config.rst:986 msgid "Preinitialize Python with PyPreConfig" msgstr "" -#: ../../c-api/init_config.rst:365 +#: ../../c-api/init_config.rst:988 msgid "The preinitialization of Python:" msgstr "" -#: ../../c-api/init_config.rst:367 +#: ../../c-api/init_config.rst:990 msgid "Set the Python memory allocators (:c:member:`PyPreConfig.allocator`)" msgstr "" -#: ../../c-api/init_config.rst:368 +#: ../../c-api/init_config.rst:991 msgid "Configure the LC_CTYPE locale (:term:`locale encoding`)" msgstr "" -#: ../../c-api/init_config.rst:369 +#: ../../c-api/init_config.rst:992 msgid "" "Set the :ref:`Python UTF-8 Mode ` (:c:member:`PyPreConfig." "utf8_mode`)" msgstr "" -#: ../../c-api/init_config.rst:372 +#: ../../c-api/init_config.rst:995 msgid "" "The current preconfiguration (``PyPreConfig`` type) is stored in " "``_PyRuntime.preconfig``." msgstr "" -#: ../../c-api/init_config.rst:375 +#: ../../c-api/init_config.rst:998 msgid "Functions to preinitialize Python:" msgstr "" -#: ../../c-api/init_config.rst:379 ../../c-api/init_config.rst:385 -#: ../../c-api/init_config.rst:394 +#: ../../c-api/init_config.rst:1002 ../../c-api/init_config.rst:1008 +#: ../../c-api/init_config.rst:1017 msgid "Preinitialize Python from *preconfig* preconfiguration." msgstr "" -#: ../../c-api/init_config.rst:381 ../../c-api/init_config.rst:390 -#: ../../c-api/init_config.rst:399 +#: ../../c-api/init_config.rst:1004 ../../c-api/init_config.rst:1013 +#: ../../c-api/init_config.rst:1022 msgid "*preconfig* must not be ``NULL``." msgstr "*preconfig* 不可為 ``NULL``。" -#: ../../c-api/init_config.rst:387 +#: ../../c-api/init_config.rst:1010 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:396 +#: ../../c-api/init_config.rst:1019 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:401 ../../c-api/init_config.rst:1359 +#: ../../c-api/init_config.rst:1024 ../../c-api/init_config.rst:2041 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:404 +#: ../../c-api/init_config.rst:1027 msgid "" "For :ref:`Python Configuration ` (:c:func:" "`PyPreConfig_InitPythonConfig`), if Python is initialized with command line " @@ -589,7 +1642,7 @@ msgid "" "`Python UTF-8 Mode `." msgstr "" -#: ../../c-api/init_config.rst:411 +#: ../../c-api/init_config.rst:1034 msgid "" "``PyMem_SetAllocator()`` can be called after :c:func:`Py_PreInitialize` and " "before :c:func:`Py_InitializeFromConfig` to install a custom memory " @@ -597,7 +1650,7 @@ msgid "" "`PyPreConfig.allocator` is set to ``PYMEM_ALLOCATOR_NOT_SET``." msgstr "" -#: ../../c-api/init_config.rst:416 +#: ../../c-api/init_config.rst:1039 msgid "" "Python memory allocation functions like :c:func:`PyMem_RawMalloc` must not " "be used before the Python preinitialization, whereas calling directly " @@ -605,13 +1658,13 @@ msgid "" "not be called before the Python preinitialization." msgstr "" -#: ../../c-api/init_config.rst:421 +#: ../../c-api/init_config.rst:1044 msgid "" "Example using the preinitialization to enable the :ref:`Python UTF-8 Mode " "`::" msgstr "" -#: ../../c-api/init_config.rst:424 +#: ../../c-api/init_config.rst:1047 msgid "" "PyStatus status;\n" "PyPreConfig preconfig;\n" @@ -631,84 +1684,84 @@ msgid "" "Py_Finalize();" msgstr "" -#: ../../c-api/init_config.rst:443 +#: ../../c-api/init_config.rst:1066 msgid "PyConfig" msgstr "PyConfig" -#: ../../c-api/init_config.rst:447 +#: ../../c-api/init_config.rst:1070 msgid "Structure containing most parameters to configure Python." msgstr "" -#: ../../c-api/init_config.rst:449 +#: ../../c-api/init_config.rst:1072 msgid "" "When done, the :c:func:`PyConfig_Clear` function must be used to release the " "configuration memory." msgstr "" -#: ../../c-api/init_config.rst:454 +#: ../../c-api/init_config.rst:1077 msgid "Structure methods:" msgstr "" -#: ../../c-api/init_config.rst:458 +#: ../../c-api/init_config.rst:1081 msgid "" "Initialize configuration with the :ref:`Python Configuration `." msgstr "" -#: ../../c-api/init_config.rst:463 +#: ../../c-api/init_config.rst:1086 msgid "" "Initialize configuration with the :ref:`Isolated Configuration `." msgstr "" -#: ../../c-api/init_config.rst:468 +#: ../../c-api/init_config.rst:1091 msgid "Copy the wide character string *str* into ``*config_str``." msgstr "" -#: ../../c-api/init_config.rst:470 ../../c-api/init_config.rst:477 -#: ../../c-api/init_config.rst:484 ../../c-api/init_config.rst:492 -#: ../../c-api/init_config.rst:498 ../../c-api/init_config.rst:515 +#: ../../c-api/init_config.rst:1093 ../../c-api/init_config.rst:1100 +#: ../../c-api/init_config.rst:1107 ../../c-api/init_config.rst:1115 +#: ../../c-api/init_config.rst:1121 ../../c-api/init_config.rst:1138 msgid ":ref:`Preinitialize Python ` if needed." msgstr "" -#: ../../c-api/init_config.rst:474 +#: ../../c-api/init_config.rst:1097 msgid "" "Decode *str* using :c:func:`Py_DecodeLocale` and set the result into " "``*config_str``." msgstr "" -#: ../../c-api/init_config.rst:481 +#: ../../c-api/init_config.rst:1104 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:488 +#: ../../c-api/init_config.rst:1111 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:496 +#: ../../c-api/init_config.rst:1119 msgid "Set the list of wide strings *list* to *length* and *items*." msgstr "" -#: ../../c-api/init_config.rst:502 +#: ../../c-api/init_config.rst:1125 msgid "Read all Python configuration." -msgstr "" +msgstr "讀取所有 Python 配置。" -#: ../../c-api/init_config.rst:504 +#: ../../c-api/init_config.rst:1127 msgid "Fields which are already initialized are left unchanged." -msgstr "" +msgstr "已經初始化的欄位將保持不變。" -#: ../../c-api/init_config.rst:506 +#: ../../c-api/init_config.rst:1129 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:509 ../../c-api/init_config.rst:1041 +#: ../../c-api/init_config.rst:1132 ../../c-api/init_config.rst:1689 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 " @@ -717,25 +1770,25 @@ msgid "" "as Python options." msgstr "" -#: ../../c-api/init_config.rst:517 +#: ../../c-api/init_config.rst:1140 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:523 +#: ../../c-api/init_config.rst:1146 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:531 +#: ../../c-api/init_config.rst:1154 msgid "Release configuration memory." msgstr "" -#: ../../c-api/init_config.rst:533 +#: ../../c-api/init_config.rst:1156 msgid "" "Most ``PyConfig`` methods :ref:`preinitialize Python ` if needed. " "In that case, the Python preinitialization configuration (:c:type:" @@ -744,23 +1797,23 @@ msgid "" "before calling a :c:type:`PyConfig` method:" msgstr "" -#: ../../c-api/init_config.rst:539 +#: ../../c-api/init_config.rst:1162 msgid ":c:member:`PyConfig.dev_mode`" msgstr ":c:member:`PyConfig.dev_mode`" -#: ../../c-api/init_config.rst:540 +#: ../../c-api/init_config.rst:1163 msgid ":c:member:`PyConfig.isolated`" msgstr ":c:member:`PyConfig.isolated`" -#: ../../c-api/init_config.rst:541 +#: ../../c-api/init_config.rst:1164 msgid ":c:member:`PyConfig.parse_argv`" msgstr ":c:member:`PyConfig.parse_argv`" -#: ../../c-api/init_config.rst:542 +#: ../../c-api/init_config.rst:1165 msgid ":c:member:`PyConfig.use_environment`" msgstr ":c:member:`PyConfig.use_environment`" -#: ../../c-api/init_config.rst:544 +#: ../../c-api/init_config.rst:1167 msgid "" "Moreover, if :c:func:`PyConfig_SetArgv` or :c:func:`PyConfig_SetBytesArgv` " "is used, this method must be called before other methods, since the " @@ -768,13 +1821,13 @@ msgid "" "member:`~PyConfig.parse_argv` is non-zero)." msgstr "" -#: ../../c-api/init_config.rst:549 +#: ../../c-api/init_config.rst:1172 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:562 +#: ../../c-api/init_config.rst:1185 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:" @@ -784,419 +1837,450 @@ msgid "" "entry in :c:member:`~PyConfig.argv` can be an empty string." msgstr "" -#: ../../c-api/init_config.rst:570 +#: ../../c-api/init_config.rst:1193 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:575 +#: ../../c-api/init_config.rst:1198 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:578 ../../c-api/init_config.rst:605 -#: ../../c-api/init_config.rst:619 ../../c-api/init_config.rst:629 -#: ../../c-api/init_config.rst:739 ../../c-api/init_config.rst:750 -#: ../../c-api/init_config.rst:832 ../../c-api/init_config.rst:982 -#: ../../c-api/init_config.rst:1083 ../../c-api/init_config.rst:1102 -#: ../../c-api/init_config.rst:1117 ../../c-api/init_config.rst:1134 -#: ../../c-api/init_config.rst:1147 ../../c-api/init_config.rst:1155 -#: ../../c-api/init_config.rst:1169 +#: ../../c-api/init_config.rst:1201 ../../c-api/init_config.rst:1228 +#: ../../c-api/init_config.rst:1242 ../../c-api/init_config.rst:1252 +#: ../../c-api/init_config.rst:1363 ../../c-api/init_config.rst:1372 +#: ../../c-api/init_config.rst:1383 ../../c-api/init_config.rst:1474 +#: ../../c-api/init_config.rst:1630 ../../c-api/init_config.rst:1731 +#: ../../c-api/init_config.rst:1750 ../../c-api/init_config.rst:1765 +#: ../../c-api/init_config.rst:1782 ../../c-api/init_config.rst:1795 +#: ../../c-api/init_config.rst:1803 ../../c-api/init_config.rst:1817 +#: ../../c-api/init_config.rst:1920 msgid "Default: ``NULL``." msgstr "預設值:``NULL``。" -#: ../../c-api/init_config.rst:580 +#: ../../c-api/init_config.rst:1203 msgid "See also the :c:member:`~PyConfig.orig_argv` member." msgstr "另請參閱 :c:member:`~PyConfig.orig_argv` 成員。" -#: ../../c-api/init_config.rst:584 +#: ../../c-api/init_config.rst:1207 msgid "" "If equals to zero, ``Py_RunMain()`` prepends a potentially unsafe path to :" "data:`sys.path` at startup:" msgstr "" -#: ../../c-api/init_config.rst:587 +#: ../../c-api/init_config.rst:1210 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:589 +#: ../../c-api/init_config.rst:1212 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:591 +#: ../../c-api/init_config.rst:1214 msgid "" "Otherwise (``python -c code`` and ``python``), prepend an empty string, " "which means the current working directory." msgstr "" -#: ../../c-api/init_config.rst:594 +#: ../../c-api/init_config.rst:1217 msgid "" "Set to ``1`` by the :option:`-P` command line option and the :envvar:" "`PYTHONSAFEPATH` environment variable." msgstr "" -#: ../../c-api/init_config.rst:597 +#: ../../c-api/init_config.rst:1220 msgid "Default: ``0`` in Python config, ``1`` in isolated config." msgstr "" -#: ../../c-api/init_config.rst:603 +#: ../../c-api/init_config.rst:1226 msgid ":data:`sys.base_exec_prefix`." msgstr ":data:`sys.base_exec_prefix`。" -#: ../../c-api/init_config.rst:607 ../../c-api/init_config.rst:621 -#: ../../c-api/init_config.rst:631 ../../c-api/init_config.rst:741 -#: ../../c-api/init_config.rst:752 ../../c-api/init_config.rst:999 -#: ../../c-api/init_config.rst:1085 +#: ../../c-api/init_config.rst:1230 ../../c-api/init_config.rst:1244 +#: ../../c-api/init_config.rst:1254 ../../c-api/init_config.rst:1374 +#: ../../c-api/init_config.rst:1385 ../../c-api/init_config.rst:1647 +#: ../../c-api/init_config.rst:1733 msgid "Part of the :ref:`Python Path Configuration ` output." msgstr "" -#: ../../c-api/init_config.rst:609 +#: ../../c-api/init_config.rst:1232 msgid "See also :c:member:`PyConfig.exec_prefix`." msgstr "也請見 :c:member:`PyConfig.exec_prefix`" -#: ../../c-api/init_config.rst:613 +#: ../../c-api/init_config.rst:1236 msgid "Python base executable: :data:`sys._base_executable`." msgstr "" -#: ../../c-api/init_config.rst:615 +#: ../../c-api/init_config.rst:1238 msgid "Set by the :envvar:`__PYVENV_LAUNCHER__` environment variable." -msgstr "" +msgstr "由 :envvar:`__PYVENV_LAUNCHER__` 環境變數設定。" -#: ../../c-api/init_config.rst:617 +#: ../../c-api/init_config.rst:1240 msgid "Set from :c:member:`PyConfig.executable` if ``NULL``." -msgstr "" +msgstr "如果為 ``NULL``,則從 :c:member:`PyConfig.executable` 設定。" -#: ../../c-api/init_config.rst:623 +#: ../../c-api/init_config.rst:1246 msgid "See also :c:member:`PyConfig.executable`." msgstr "也請見 :c:member:`PyConfig.executable`" -#: ../../c-api/init_config.rst:627 +#: ../../c-api/init_config.rst:1250 msgid ":data:`sys.base_prefix`." msgstr ":data:`sys.base_prefix`。" -#: ../../c-api/init_config.rst:633 +#: ../../c-api/init_config.rst:1256 msgid "See also :c:member:`PyConfig.prefix`." msgstr "也請見 :c:member:`PyConfig.prefix`" -#: ../../c-api/init_config.rst:637 +#: ../../c-api/init_config.rst:1260 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:640 +#: ../../c-api/init_config.rst:1263 msgid "" "Set to ``0`` by the :option:`-u` command line option and the :envvar:" "`PYTHONUNBUFFERED` environment variable." msgstr "" -#: ../../c-api/init_config.rst:643 +#: ../../c-api/init_config.rst:1266 msgid "stdin is always opened in buffered mode." msgstr "" -#: ../../c-api/init_config.rst:645 ../../c-api/init_config.rst:678 -#: ../../c-api/init_config.rst:1197 ../../c-api/init_config.rst:1330 +#: ../../c-api/init_config.rst:1268 ../../c-api/init_config.rst:1301 +#: ../../c-api/init_config.rst:1845 ../../c-api/init_config.rst:2003 msgid "Default: ``1``." msgstr "預設值:``1``。" -#: ../../c-api/init_config.rst:649 +#: ../../c-api/init_config.rst:1272 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:653 +#: ../../c-api/init_config.rst:1276 msgid "" "If equal or greater to ``2``, raise a :exc:`BytesWarning` exception in these " "cases." msgstr "" -#: ../../c-api/init_config.rst:656 +#: ../../c-api/init_config.rst:1279 msgid "Incremented by the :option:`-b` command line option." msgstr "" -#: ../../c-api/init_config.rst:662 +#: ../../c-api/init_config.rst:1285 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:671 +#: ../../c-api/init_config.rst:1294 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:675 +#: ../../c-api/init_config.rst:1298 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:684 +#: ../../c-api/init_config.rst:1307 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:687 +#: ../../c-api/init_config.rst:1310 msgid "Valid values:" -msgstr "" +msgstr "有效值:" -#: ../../c-api/init_config.rst:689 +#: ../../c-api/init_config.rst:1312 msgid "" "``L\"always\"``: Hash the source file for invalidation regardless of value " "of the 'check_source' flag." msgstr "" -#: ../../c-api/init_config.rst:691 +#: ../../c-api/init_config.rst:1314 msgid "``L\"never\"``: Assume that hash-based pycs always are valid." msgstr "" -#: ../../c-api/init_config.rst:692 +#: ../../c-api/init_config.rst:1315 msgid "" "``L\"default\"``: The 'check_source' flag in hash-based pycs determines " "invalidation." msgstr "" -#: ../../c-api/init_config.rst:695 +#: ../../c-api/init_config.rst:1318 msgid "Default: ``L\"default\"``." msgstr "預設:``L\"default\"``。" -#: ../../c-api/init_config.rst:697 +#: ../../c-api/init_config.rst:1320 msgid "See also :pep:`552` \"Deterministic pycs\"." msgstr "" -#: ../../c-api/init_config.rst:701 +#: ../../c-api/init_config.rst:1324 msgid "If non-zero, configure C standard streams:" msgstr "" -#: ../../c-api/init_config.rst:703 +#: ../../c-api/init_config.rst:1326 msgid "" "On Windows, set the binary mode (``O_BINARY``) on stdin, stdout and stderr." msgstr "" -#: ../../c-api/init_config.rst:705 +#: ../../c-api/init_config.rst:1328 msgid "" "If :c:member:`~PyConfig.buffered_stdio` equals zero, disable buffering of " "stdin, stdout and stderr streams." msgstr "" -#: ../../c-api/init_config.rst:707 +#: ../../c-api/init_config.rst:1330 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:714 +#: ../../c-api/init_config.rst:1337 msgid "If non-zero, enable the :ref:`Python Development Mode `." msgstr "" -#: ../../c-api/init_config.rst:716 +#: ../../c-api/init_config.rst:1339 msgid "" "Set to ``1`` by the :option:`-X dev <-X>` option and the :envvar:" "`PYTHONDEVMODE` environment variable." msgstr "" -#: ../../c-api/init_config.rst:723 +#: ../../c-api/init_config.rst:1346 msgid "Dump Python references?" msgstr "" -#: ../../c-api/init_config.rst:725 +#: ../../c-api/init_config.rst:1348 msgid "If non-zero, dump all objects which are still alive at exit." msgstr "" -#: ../../c-api/init_config.rst:727 +#: ../../c-api/init_config.rst:1350 msgid "Set to ``1`` by the :envvar:`PYTHONDUMPREFS` environment variable." msgstr "" -#: ../../c-api/init_config.rst:729 +#: ../../c-api/init_config.rst:1352 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:736 +#: ../../c-api/init_config.rst:1359 +msgid "Filename where to dump Python references." +msgstr "" + +#: ../../c-api/init_config.rst:1361 +msgid "Set by the :envvar:`PYTHONDUMPREFSFILE` environment variable." +msgstr "由 :envvar:`PYTHONDUMPREFSFILE` 環境變數設定。" + +#: ../../c-api/init_config.rst:1369 msgid "" "The site-specific directory prefix where the platform-dependent Python files " "are installed: :data:`sys.exec_prefix`." msgstr "" -#: ../../c-api/init_config.rst:743 +#: ../../c-api/init_config.rst:1376 msgid "See also :c:member:`PyConfig.base_exec_prefix`." msgstr "也請見 :c:member:`PyConfig.base_exec_prefix`" -#: ../../c-api/init_config.rst:747 +#: ../../c-api/init_config.rst:1380 msgid "" "The absolute path of the executable binary for the Python interpreter: :data:" "`sys.executable`." msgstr "" -#: ../../c-api/init_config.rst:754 +#: ../../c-api/init_config.rst:1387 msgid "See also :c:member:`PyConfig.base_executable`." msgstr "也請見 :c:member:`PyConfig.base_executable`" -#: ../../c-api/init_config.rst:758 +#: ../../c-api/init_config.rst:1391 msgid "Enable faulthandler?" -msgstr "" +msgstr "啟用 faulthandler?" -#: ../../c-api/init_config.rst:760 +#: ../../c-api/init_config.rst:1393 msgid "If non-zero, call :func:`faulthandler.enable` at startup." -msgstr "" +msgstr "如果非零,則在啟動時呼叫 :func:`faulthandler.enable`。" -#: ../../c-api/init_config.rst:762 +#: ../../c-api/init_config.rst:1395 msgid "" "Set to ``1`` by :option:`-X faulthandler <-X>` and the :envvar:" "`PYTHONFAULTHANDLER` environment variable." msgstr "" -#: ../../c-api/init_config.rst:769 +#: ../../c-api/init_config.rst:1402 msgid "" ":term:`Filesystem encoding `: :func:" "`sys.getfilesystemencoding`." msgstr "" -#: ../../c-api/init_config.rst:772 +#: ../../c-api/init_config.rst:1405 msgid "On macOS, Android and VxWorks: use ``\"utf-8\"`` by default." msgstr "" -#: ../../c-api/init_config.rst:774 +#: ../../c-api/init_config.rst:1407 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:778 +#: ../../c-api/init_config.rst:1411 msgid "Default encoding on other platforms:" -msgstr "" +msgstr "其他平台的預設編碼:" -#: ../../c-api/init_config.rst:780 +#: ../../c-api/init_config.rst:1413 msgid "``\"utf-8\"`` if :c:member:`PyPreConfig.utf8_mode` is non-zero." -msgstr "" +msgstr "如果 :c:member:`PyPreConfig.utf8_mode` 非零,則為 ``\"utf-8\"``。" -#: ../../c-api/init_config.rst:781 +#: ../../c-api/init_config.rst:1414 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:784 +#: ../../c-api/init_config.rst:1417 msgid "``\"utf-8\"`` if ``nl_langinfo(CODESET)`` returns an empty string." msgstr "" -#: ../../c-api/init_config.rst:785 +#: ../../c-api/init_config.rst:1418 msgid "" "Otherwise, use the :term:`locale encoding`: ``nl_langinfo(CODESET)`` result." msgstr "" -#: ../../c-api/init_config.rst:788 +#: ../../c-api/init_config.rst:1421 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:791 +#: ../../c-api/init_config.rst:1424 msgid "See also the :c:member:`~PyConfig.filesystem_errors` member." msgstr "另請參閱 :c:member:`~PyConfig.filesystem_errors` 成員。" -#: ../../c-api/init_config.rst:795 +#: ../../c-api/init_config.rst:1428 msgid "" ":term:`Filesystem error handler `: :" "func:`sys.getfilesystemencodeerrors`." msgstr "" -#: ../../c-api/init_config.rst:798 +#: ../../c-api/init_config.rst:1431 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:802 +#: ../../c-api/init_config.rst:1435 msgid "On other platforms: use ``\"surrogateescape\"`` by default." -msgstr "" +msgstr "其他平台:預設使用 ``\"surrogateescape\"``。" -#: ../../c-api/init_config.rst:804 +#: ../../c-api/init_config.rst:1437 msgid "Supported error handlers:" -msgstr "" +msgstr "支援的錯誤處理器:" -#: ../../c-api/init_config.rst:806 +#: ../../c-api/init_config.rst:1439 msgid "``\"strict\"``" msgstr "``\"strict\"``" -#: ../../c-api/init_config.rst:807 +#: ../../c-api/init_config.rst:1440 msgid "``\"surrogateescape\"``" msgstr "``\"surrogateescape\"``" -#: ../../c-api/init_config.rst:808 +#: ../../c-api/init_config.rst:1441 msgid "``\"surrogatepass\"`` (only supported with the UTF-8 encoding)" msgstr "``\"surrogatepass\"``\\ (僅支援 UTF-8 編碼)" -#: ../../c-api/init_config.rst:810 +#: ../../c-api/init_config.rst:1443 msgid "See also the :c:member:`~PyConfig.filesystem_encoding` member." msgstr "另請參閱 :c:member:`~PyConfig.filesystem_encoding` 成員。" -#: ../../c-api/init_config.rst:815 +#: ../../c-api/init_config.rst:1447 +msgid "If non-zero, use frozen modules." +msgstr "如果非零,則使用凍結模組。" + +#: ../../c-api/init_config.rst:1449 +msgid "Set by the :envvar:`PYTHON_FROZEN_MODULES` environment variable." +msgstr "由 :envvar:`PYTHON_FROZEN_MODULES` 環境變數設定。" + +#: ../../c-api/init_config.rst:1451 +msgid "" +"Default: ``1`` in a release build, or ``0`` in a :ref:`debug build `." +msgstr "" + +#: ../../c-api/init_config.rst:1457 msgid "Randomized hash function seed." msgstr "" -#: ../../c-api/init_config.rst:817 +#: ../../c-api/init_config.rst:1459 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:820 +#: ../../c-api/init_config.rst:1462 msgid "Set by the :envvar:`PYTHONHASHSEED` environment variable." msgstr "由 :envvar:`PYTHONHASHSEED` 環境變數設定。" -#: ../../c-api/init_config.rst:822 +#: ../../c-api/init_config.rst:1464 msgid "" "Default *use_hash_seed* value: ``-1`` in Python mode, ``0`` in isolated mode." msgstr "" -#: ../../c-api/init_config.rst:827 +#: ../../c-api/init_config.rst:1469 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:830 +#: ../../c-api/init_config.rst:1472 msgid "Set by the :envvar:`PYTHONHOME` environment variable." msgstr "由 :envvar:`PYTHONHOME` 環境變數設定。" -#: ../../c-api/init_config.rst:834 ../../c-api/init_config.rst:964 -#: ../../c-api/init_config.rst:984 ../../c-api/init_config.rst:1073 -#: ../../c-api/init_config.rst:1104 +#: ../../c-api/init_config.rst:1476 ../../c-api/init_config.rst:1612 +#: ../../c-api/init_config.rst:1632 ../../c-api/init_config.rst:1721 +#: ../../c-api/init_config.rst:1752 msgid "Part of the :ref:`Python Path Configuration ` input." msgstr "" -#: ../../c-api/init_config.rst:838 -msgid "If non-zero, profile import time." +#: ../../c-api/init_config.rst:1480 +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:840 +#: ../../c-api/init_config.rst:1484 msgid "" -"Set the ``1`` by the :option:`-X importtime <-X>` option and the :envvar:" +"Set by the :option:`-X importtime <-X>` option and the :envvar:" "`PYTHONPROFILEIMPORTTIME` environment variable." msgstr "" +"由 :option:`-X importtime <-X>` 選項與 :envvar:`PYTHONPROFILEIMPORTTIME` 環境" +"變數設定。" -#: ../../c-api/init_config.rst:847 +#: ../../c-api/init_config.rst:1491 +msgid "Added support for ``import_time = 2``" +msgstr "新增對 ``import_time = 2`` 的支援" + +#: ../../c-api/init_config.rst:1495 msgid "Enter interactive mode after executing a script or a command." -msgstr "" +msgstr "在執行腳本或命令後進入互動模式。" -#: ../../c-api/init_config.rst:849 +#: ../../c-api/init_config.rst:1497 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 " @@ -1204,30 +2288,30 @@ msgid "" "a terminal." msgstr "" -#: ../../c-api/init_config.rst:854 +#: ../../c-api/init_config.rst:1502 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:861 +#: ../../c-api/init_config.rst:1509 msgid "Install Python signal handlers?" msgstr "" -#: ../../c-api/init_config.rst:863 ../../c-api/init_config.rst:1047 -#: ../../c-api/init_config.rst:1071 ../../c-api/init_config.rst:1282 +#: ../../c-api/init_config.rst:1511 ../../c-api/init_config.rst:1695 +#: ../../c-api/init_config.rst:1719 ../../c-api/init_config.rst:1955 msgid "Default: ``1`` in Python mode, ``0`` in isolated mode." msgstr "" -#: ../../c-api/init_config.rst:867 +#: ../../c-api/init_config.rst:1515 msgid "If greater than ``0``, enable the interactive mode (REPL)." msgstr "" -#: ../../c-api/init_config.rst:869 +#: ../../c-api/init_config.rst:1517 msgid "Incremented by the :option:`-i` command line option." msgstr "" -#: ../../c-api/init_config.rst:875 +#: ../../c-api/init_config.rst:1523 msgid "" "Configures the :ref:`integer string conversion length limitation " "`. An initial value of ``-1`` means the value will be " @@ -1237,47 +2321,47 @@ msgid "" "str_digits_check_threshold`) are unsupported and will produce an error." msgstr "" -#: ../../c-api/init_config.rst:883 +#: ../../c-api/init_config.rst:1531 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:886 +#: ../../c-api/init_config.rst:1534 msgid "" "Default: ``-1`` in Python mode. 4300 (:data:`sys.int_info." "default_max_str_digits`) in isolated mode." msgstr "" -#: ../../c-api/init_config.rst:893 +#: ../../c-api/init_config.rst:1541 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:897 +#: ../../c-api/init_config.rst:1545 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:900 ../../c-api/init_config.rst:1259 +#: ../../c-api/init_config.rst:1548 ../../c-api/init_config.rst:1909 msgid "Default: ``-1``." msgstr "預設值:``1``。" -#: ../../c-api/init_config.rst:906 +#: ../../c-api/init_config.rst:1554 msgid "If greater than ``0``, enable isolated mode:" msgstr "" -#: ../../c-api/init_config.rst:908 +#: ../../c-api/init_config.rst:1556 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:912 +#: ../../c-api/init_config.rst:1560 msgid "" "Set :c:member:`~PyConfig.use_environment` to ``0``: ignore ``PYTHON`` " "environment variables." @@ -1285,77 +2369,77 @@ msgstr "" "將 :c:member:`~PyConfig.use_environment` 設定為 ``0``:忽略 ``PYTHON`` 環境變" "數。" -#: ../../c-api/init_config.rst:914 +#: ../../c-api/init_config.rst:1562 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:916 +#: ../../c-api/init_config.rst:1564 msgid "" "Python REPL doesn't import :mod:`readline` nor enable default readline " "configuration on interactive prompts." msgstr "" -#: ../../c-api/init_config.rst:919 +#: ../../c-api/init_config.rst:1567 msgid "Set to ``1`` by the :option:`-I` command line option." msgstr "" -#: ../../c-api/init_config.rst:923 +#: ../../c-api/init_config.rst:1571 msgid "" "See also the :ref:`Isolated Configuration ` and :c:" "member:`PyPreConfig.isolated`." msgstr "" -#: ../../c-api/init_config.rst:928 +#: ../../c-api/init_config.rst:1576 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:932 +#: ../../c-api/init_config.rst:1580 msgid "" "Set to ``1`` if the :envvar:`PYTHONLEGACYWINDOWSSTDIO` environment variable " "is set to a non-empty string." msgstr "" -#: ../../c-api/init_config.rst:940 +#: ../../c-api/init_config.rst:1588 msgid "See also the :pep:`528` (Change Windows console encoding to UTF-8)." msgstr "" -#: ../../c-api/init_config.rst:944 +#: ../../c-api/init_config.rst:1592 msgid "" "If non-zero, dump statistics on :ref:`Python pymalloc memory allocator " "` at exit." msgstr "" -#: ../../c-api/init_config.rst:947 +#: ../../c-api/init_config.rst:1595 msgid "Set to ``1`` by the :envvar:`PYTHONMALLOCSTATS` environment variable." msgstr "" -#: ../../c-api/init_config.rst:949 +#: ../../c-api/init_config.rst:1597 msgid "" "The option is ignored if Python is :option:`configured using the --without-" "pymalloc option <--without-pymalloc>`." msgstr "" -#: ../../c-api/init_config.rst:956 +#: ../../c-api/init_config.rst:1604 msgid "Platform library directory name: :data:`sys.platlibdir`." msgstr "" -#: ../../c-api/init_config.rst:958 +#: ../../c-api/init_config.rst:1606 msgid "Set by the :envvar:`PYTHONPLATLIBDIR` environment variable." msgstr "" -#: ../../c-api/init_config.rst:960 +#: ../../c-api/init_config.rst:1608 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:968 +#: ../../c-api/init_config.rst:1616 msgid "" "This macro is now used on Windows to locate the standard library extension " "modules, typically under ``DLLs``. However, for compatibility, note that " @@ -1363,21 +2447,21 @@ msgid "" "and virtual environments." msgstr "" -#: ../../c-api/init_config.rst:977 +#: ../../c-api/init_config.rst:1625 msgid "" "Module search paths (:data:`sys.path`) as a string separated by ``DELIM`` (:" "data:`os.pathsep`)." msgstr "" -#: ../../c-api/init_config.rst:980 +#: ../../c-api/init_config.rst:1628 msgid "Set by the :envvar:`PYTHONPATH` environment variable." msgstr "" -#: ../../c-api/init_config.rst:989 +#: ../../c-api/init_config.rst:1637 msgid "Module search paths: :data:`sys.path`." msgstr "" -#: ../../c-api/init_config.rst:991 +#: ../../c-api/init_config.rst:1639 msgid "" "If :c:member:`~PyConfig.module_search_paths_set` is equal to ``0``, :c:func:" "`Py_InitializeFromConfig` will replace :c:member:`~PyConfig." @@ -1385,41 +2469,41 @@ msgid "" "to ``1``." msgstr "" -#: ../../c-api/init_config.rst:996 +#: ../../c-api/init_config.rst:1644 msgid "" "Default: empty list (``module_search_paths``) and ``0`` " "(``module_search_paths_set``)." msgstr "" -#: ../../c-api/init_config.rst:1003 +#: ../../c-api/init_config.rst:1651 msgid "Compilation optimization level:" msgstr "" -#: ../../c-api/init_config.rst:1005 +#: ../../c-api/init_config.rst:1653 msgid "``0``: Peephole optimizer, set ``__debug__`` to ``True``." msgstr "" -#: ../../c-api/init_config.rst:1006 +#: ../../c-api/init_config.rst:1654 msgid "``1``: Level 0, remove assertions, set ``__debug__`` to ``False``." msgstr "" -#: ../../c-api/init_config.rst:1007 +#: ../../c-api/init_config.rst:1655 msgid "``2``: Level 1, strip docstrings." msgstr "" -#: ../../c-api/init_config.rst:1009 +#: ../../c-api/init_config.rst:1657 msgid "" "Incremented by the :option:`-O` command line option. Set to the :envvar:" "`PYTHONOPTIMIZE` environment variable value." msgstr "" -#: ../../c-api/init_config.rst:1016 +#: ../../c-api/init_config.rst:1664 msgid "" "The list of the original command line arguments passed to the Python " "executable: :data:`sys.orig_argv`." msgstr "" -#: ../../c-api/init_config.rst:1019 +#: ../../c-api/init_config.rst:1667 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` " @@ -1428,400 +2512,441 @@ msgid "" "parse_argv` is non-zero)." msgstr "" -#: ../../c-api/init_config.rst:1026 +#: ../../c-api/init_config.rst:1674 msgid "" "See also the :c:member:`~PyConfig.argv` member and the :c:func:" "`Py_GetArgcArgv` function." msgstr "" -#: ../../c-api/init_config.rst:1029 ../../c-api/init_config.rst:1317 -#: ../../c-api/init_config.rst:1336 +#: ../../c-api/init_config.rst:1677 ../../c-api/init_config.rst:1990 +#: ../../c-api/init_config.rst:2009 msgid "Default: empty list." msgstr "" -#: ../../c-api/init_config.rst:1035 +#: ../../c-api/init_config.rst:1683 msgid "Parse command line arguments?" msgstr "" -#: ../../c-api/init_config.rst:1037 +#: ../../c-api/init_config.rst:1685 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:1049 +#: ../../c-api/init_config.rst:1697 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:1055 +#: ../../c-api/init_config.rst:1703 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:1058 +#: ../../c-api/init_config.rst:1706 msgid "" "Incremented by the :option:`-d` command line option. Set to the :envvar:" "`PYTHONDEBUG` environment variable value." msgstr "" -#: ../../c-api/init_config.rst:1061 ../../c-api/init_config.rst:1166 +#: ../../c-api/init_config.rst:1709 ../../c-api/init_config.rst:1814 msgid "" "Needs a :ref:`debug build of Python ` (the ``Py_DEBUG`` macro " "must be defined)." msgstr "" -#: ../../c-api/init_config.rst:1068 +#: ../../c-api/init_config.rst:1716 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:1075 +#: ../../c-api/init_config.rst:1723 msgid "Now also applies on Windows." -msgstr "" +msgstr "現在也適用於 Windows。" -#: ../../c-api/init_config.rst:1080 +#: ../../c-api/init_config.rst:1728 msgid "" "The site-specific directory prefix where the platform independent Python " "files are installed: :data:`sys.prefix`." msgstr "" -#: ../../c-api/init_config.rst:1087 +#: ../../c-api/init_config.rst:1735 msgid "See also :c:member:`PyConfig.base_prefix`." msgstr "也請見 :c:member:`PyConfig.base_prefix`" -#: ../../c-api/init_config.rst:1091 +#: ../../c-api/init_config.rst:1739 msgid "" "Program name used to initialize :c:member:`~PyConfig.executable` and in " "early error messages during Python initialization." msgstr "" -#: ../../c-api/init_config.rst:1094 +#: ../../c-api/init_config.rst:1742 msgid "On macOS, use :envvar:`PYTHONEXECUTABLE` environment variable if set." msgstr "" -#: ../../c-api/init_config.rst:1095 +#: ../../c-api/init_config.rst:1743 msgid "" "If the ``WITH_NEXT_FRAMEWORK`` macro is defined, use :envvar:" "`__PYVENV_LAUNCHER__` environment variable if set." msgstr "" -#: ../../c-api/init_config.rst:1097 +#: ../../c-api/init_config.rst:1745 msgid "" "Use ``argv[0]`` of :c:member:`~PyConfig.argv` if available and non-empty." msgstr "" -#: ../../c-api/init_config.rst:1099 +#: ../../c-api/init_config.rst:1747 msgid "" "Otherwise, use ``L\"python\"`` on Windows, or ``L\"python3\"`` on other " "platforms." msgstr "" -#: ../../c-api/init_config.rst:1108 +#: ../../c-api/init_config.rst:1756 msgid "" "Directory where cached ``.pyc`` files are written: :data:`sys." "pycache_prefix`." msgstr "" -#: ../../c-api/init_config.rst:1111 +#: ../../c-api/init_config.rst:1759 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:1115 +#: ../../c-api/init_config.rst:1763 msgid "If ``NULL``, :data:`sys.pycache_prefix` is set to ``None``." msgstr "" -#: ../../c-api/init_config.rst:1121 +#: ../../c-api/init_config.rst:1769 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:1124 +#: ../../c-api/init_config.rst:1772 msgid "Incremented by the :option:`-q` command line option." msgstr "" -#: ../../c-api/init_config.rst:1130 +#: ../../c-api/init_config.rst:1778 msgid "Value of the :option:`-c` command line option." msgstr "" -#: ../../c-api/init_config.rst:1132 ../../c-api/init_config.rst:1153 +#: ../../c-api/init_config.rst:1780 ../../c-api/init_config.rst:1801 msgid "Used by :c:func:`Py_RunMain`." -msgstr "" +msgstr "被 :c:func:`Py_RunMain` 使用。" -#: ../../c-api/init_config.rst:1138 +#: ../../c-api/init_config.rst:1786 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:1142 +#: ../../c-api/init_config.rst:1790 msgid "" "For example, it is set to ``script.py`` by the ``python3 script.py arg`` " "command line." msgstr "" -#: ../../c-api/init_config.rst:1145 +#: ../../c-api/init_config.rst:1793 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:1151 +#: ../../c-api/init_config.rst:1799 msgid "Value of the :option:`-m` command line option." msgstr "" -#: ../../c-api/init_config.rst:1159 +#: ../../c-api/init_config.rst:1807 msgid "" "``package.module`` path to module that should be imported before ``site.py`` " "is run." msgstr "" -#: ../../c-api/init_config.rst:1162 +#: ../../c-api/init_config.rst:1810 msgid "" "Set by the :option:`-X presite=package.module <-X>` command-line option and " "the :envvar:`PYTHON_PRESITE` environment variable. The command-line option " "takes precedence." msgstr "" -#: ../../c-api/init_config.rst:1173 +#: ../../c-api/init_config.rst:1821 msgid "" "Show total reference count at exit (excluding :term:`immortal` objects)?" msgstr "" -#: ../../c-api/init_config.rst:1175 +#: ../../c-api/init_config.rst:1823 msgid "Set to ``1`` by :option:`-X showrefcount <-X>` command line option." msgstr "" -#: ../../c-api/init_config.rst:1177 +#: ../../c-api/init_config.rst:1825 msgid "" "Needs a :ref:`debug build of Python ` (the ``Py_REF_DEBUG`` " "macro must be defined)." msgstr "" -#: ../../c-api/init_config.rst:1184 +#: ../../c-api/init_config.rst:1832 msgid "Import the :mod:`site` module at startup?" msgstr "" -#: ../../c-api/init_config.rst:1186 +#: ../../c-api/init_config.rst:1834 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:1189 +#: ../../c-api/init_config.rst:1837 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:1192 +#: ../../c-api/init_config.rst:1840 msgid "Set to ``0`` by the :option:`-S` command line option." msgstr "" -#: ../../c-api/init_config.rst:1194 +#: ../../c-api/init_config.rst:1842 msgid "" ":data:`sys.flags.no_site ` is set to the inverted value of :c:" "member:`~PyConfig.site_import`." msgstr "" -#: ../../c-api/init_config.rst:1201 +#: ../../c-api/init_config.rst:1849 msgid "" "If non-zero, skip the first line of the :c:member:`PyConfig.run_filename` " "source." msgstr "" -#: ../../c-api/init_config.rst:1204 +#: ../../c-api/init_config.rst:1852 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:1207 +#: ../../c-api/init_config.rst:1855 msgid "Set to ``1`` by the :option:`-x` command line option." msgstr "" -#: ../../c-api/init_config.rst:1214 +#: ../../c-api/init_config.rst:1862 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:1218 +#: ../../c-api/init_config.rst:1866 msgid "" "Use the :envvar:`PYTHONIOENCODING` environment variable if it is non-empty." msgstr "" -#: ../../c-api/init_config.rst:1221 +#: ../../c-api/init_config.rst:1869 msgid "Default encoding:" -msgstr "" +msgstr "預設編碼:" -#: ../../c-api/init_config.rst:1223 +#: ../../c-api/init_config.rst:1871 msgid "``\"UTF-8\"`` if :c:member:`PyPreConfig.utf8_mode` is non-zero." -msgstr "" +msgstr "如果 :c:member:`PyPreConfig.utf8_mode` 非零,則為 ``\"UTF-8\"``。" -#: ../../c-api/init_config.rst:1224 +#: ../../c-api/init_config.rst:1872 msgid "Otherwise, use the :term:`locale encoding`." -msgstr "" +msgstr "否則使用 :term:`locale encoding`。" -#: ../../c-api/init_config.rst:1226 +#: ../../c-api/init_config.rst:1874 msgid "Default error handler:" msgstr "" -#: ../../c-api/init_config.rst:1228 +#: ../../c-api/init_config.rst:1876 msgid "On Windows: use ``\"surrogateescape\"``." -msgstr "" +msgstr "在 Windows 上:使用 ``\"surrogateescape\"``。" -#: ../../c-api/init_config.rst:1229 +#: ../../c-api/init_config.rst:1877 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:1231 +#: ../../c-api/init_config.rst:1879 msgid "``\"strict\"`` otherwise." msgstr "" -#: ../../c-api/init_config.rst:1233 +#: ../../c-api/init_config.rst:1881 msgid "See also :c:member:`PyConfig.legacy_windows_stdio`." msgstr "也請見 :c:member:`PyConfig.legacy_windows_stdio`。" -#: ../../c-api/init_config.rst:1237 +#: ../../c-api/init_config.rst:1885 msgid "Enable tracemalloc?" msgstr "" -#: ../../c-api/init_config.rst:1239 +#: ../../c-api/init_config.rst:1887 msgid "If non-zero, call :func:`tracemalloc.start` at startup." msgstr "" -#: ../../c-api/init_config.rst:1241 +#: ../../c-api/init_config.rst:1889 msgid "" "Set by :option:`-X tracemalloc=N <-X>` command line option and by the :" "envvar:`PYTHONTRACEMALLOC` environment variable." msgstr "" -#: ../../c-api/init_config.rst:1248 -msgid "Enable compatibility mode with the perf profiler?" +#: ../../c-api/init_config.rst:1896 +msgid "Enable the Linux ``perf`` profiler support?" +msgstr "要啟用 Linux ``perf`` 分析器支援嗎?" + +#: ../../c-api/init_config.rst:1898 +msgid "If equals to ``1``, enable support for the Linux ``perf`` profiler." +msgstr "如果等於 ``1``,則啟用對 Linux ``perf`` 分析器的支援。" + +#: ../../c-api/init_config.rst:1900 +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:1250 +#: ../../c-api/init_config.rst:1903 msgid "" -"If non-zero, initialize the perf trampoline. See :ref:`perf_profiling` for " -"more information." +"Set to ``1`` by :option:`-X perf <-X>` command-line option and the :envvar:" +"`PYTHONPERFSUPPORT` environment variable." msgstr "" -#: ../../c-api/init_config.rst:1253 +#: ../../c-api/init_config.rst:1906 msgid "" -"Set by :option:`-X perf <-X>` command-line option and by the :envvar:" -"`PYTHON_PERF_JIT_SUPPORT` environment variable for perf support with stack " -"pointers and :option:`-X perf_jit <-X>` command-line option and by the :" -"envvar:`PYTHON_PERF_JIT_SUPPORT` environment variable for perf support with " -"DWARF JIT information." +"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:1912 +msgid "See :ref:`perf_profiling` for more information." +msgstr "" + +#: ../../c-api/init_config.rst:1918 +msgid "Directory of the Python standard library." msgstr "" -#: ../../c-api/init_config.rst:1265 +#: ../../c-api/init_config.rst:1926 msgid "Use :ref:`environment variables `?" msgstr "" -#: ../../c-api/init_config.rst:1267 +#: ../../c-api/init_config.rst:1928 msgid "" "If equals to zero, ignore the :ref:`environment variables `." msgstr "" -#: ../../c-api/init_config.rst:1270 +#: ../../c-api/init_config.rst:1931 msgid "Set to ``0`` by the :option:`-E` environment variable." msgstr "" -#: ../../c-api/init_config.rst:1276 +#: ../../c-api/init_config.rst:1937 +msgid "" +"If non-zero, ``stdout`` and ``stderr`` will be redirected to the system log." +msgstr "" + +#: ../../c-api/init_config.rst:1940 +msgid "Only available on macOS 10.12 and later, and on iOS." +msgstr "" + +#: ../../c-api/init_config.rst:1942 +msgid "" +"Default: ``0`` (don't use the system log) on macOS; ``1`` on iOS (use the " +"system log)." +msgstr "" + +#: ../../c-api/init_config.rst:1949 msgid "If non-zero, add the user site directory to :data:`sys.path`." msgstr "" -#: ../../c-api/init_config.rst:1278 +#: ../../c-api/init_config.rst:1951 msgid "Set to ``0`` by the :option:`-s` and :option:`-I` command line options." msgstr "" -#: ../../c-api/init_config.rst:1280 +#: ../../c-api/init_config.rst:1953 msgid "Set to ``0`` by the :envvar:`PYTHONNOUSERSITE` environment variable." msgstr "" -#: ../../c-api/init_config.rst:1286 +#: ../../c-api/init_config.rst:1959 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:1290 +#: ../../c-api/init_config.rst:1963 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:1294 +#: ../../c-api/init_config.rst:1967 msgid "Incremented by the :option:`-v` command line option." msgstr "" -#: ../../c-api/init_config.rst:1296 +#: ../../c-api/init_config.rst:1969 msgid "Set by the :envvar:`PYTHONVERBOSE` environment variable value." msgstr "" -#: ../../c-api/init_config.rst:1302 +#: ../../c-api/init_config.rst:1975 msgid "" "Options of the :mod:`warnings` module to build warnings filters, lowest to " "highest priority: :data:`sys.warnoptions`." msgstr "" -#: ../../c-api/init_config.rst:1305 +#: ../../c-api/init_config.rst:1978 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 :data:`warnings.filters` which is checked first (highest priority)." msgstr "" -#: ../../c-api/init_config.rst:1310 +#: ../../c-api/init_config.rst:1983 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:1313 +#: ../../c-api/init_config.rst:1986 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:1321 +#: ../../c-api/init_config.rst:1994 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:1324 +#: ../../c-api/init_config.rst:1997 msgid "" "Set to ``0`` by the :option:`-B` command line option and the :envvar:" "`PYTHONDONTWRITEBYTECODE` environment variable." msgstr "" -#: ../../c-api/init_config.rst:1327 +#: ../../c-api/init_config.rst:2000 msgid "" ":data:`sys.dont_write_bytecode` is initialized to the inverted value of :c:" "member:`~PyConfig.write_bytecode`." msgstr "" -#: ../../c-api/init_config.rst:1334 +#: ../../c-api/init_config.rst:2007 msgid "Values of the :option:`-X` command line options: :data:`sys._xoptions`." msgstr "" -#: ../../c-api/init_config.rst:1338 +#: ../../c-api/init_config.rst:2013 +msgid "If non-zero, write performance statistics at Python exit." +msgstr "" + +#: ../../c-api/init_config.rst:2015 +msgid "" +"Need a special build with the ``Py_STATS`` macro: see :option:`--enable-" +"pystats`." +msgstr "" + +#: ../../c-api/init_config.rst:2020 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 " @@ -1829,27 +2954,27 @@ msgid "" "c:member:`~PyConfig.argv`." msgstr "" -#: ../../c-api/init_config.rst:1343 +#: ../../c-api/init_config.rst:2025 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:1348 +#: ../../c-api/init_config.rst:2030 msgid "The ``show_alloc_count`` field has been removed." msgstr "" -#: ../../c-api/init_config.rst:1354 +#: ../../c-api/init_config.rst:2036 msgid "Initialization with PyConfig" msgstr "" -#: ../../c-api/init_config.rst:1356 +#: ../../c-api/init_config.rst:2038 msgid "" "Initializing the interpreter from a populated configuration struct is " "handled by calling :c:func:`Py_InitializeFromConfig`." msgstr "" -#: ../../c-api/init_config.rst:1362 +#: ../../c-api/init_config.rst:2044 msgid "" "If :c:func:`PyImport_FrozenModules`, :c:func:`PyImport_AppendInittab` or :c:" "func:`PyImport_ExtendInittab` are used, they must be set or called after " @@ -1858,17 +2983,17 @@ msgid "" "`PyImport_ExtendInittab` must be called before each Python initialization." msgstr "" -#: ../../c-api/init_config.rst:1369 +#: ../../c-api/init_config.rst:2051 msgid "" "The current configuration (``PyConfig`` type) is stored in " "``PyInterpreterState.config``." msgstr "" -#: ../../c-api/init_config.rst:1372 +#: ../../c-api/init_config.rst:2054 msgid "Example setting the program name::" msgstr "" -#: ../../c-api/init_config.rst:1374 +#: ../../c-api/init_config.rst:2056 msgid "" "void init_python(void)\n" "{\n" @@ -1922,7 +3047,7 @@ msgstr "" " Py_ExitStatusException(status);\n" "}" -#: ../../c-api/init_config.rst:1400 +#: ../../c-api/init_config.rst:2082 msgid "" "More complete example modifying the default configuration, read the " "configuration, and then override some parameters. Note that since 3.11, many " @@ -1931,7 +3056,7 @@ msgid "" "called will be left unchanged by initialization::" msgstr "" -#: ../../c-api/init_config.rst:1407 +#: ../../c-api/init_config.rst:2089 msgid "" "PyStatus init_python(const char *program_name)\n" "{\n" @@ -1986,18 +3111,18 @@ msgid "" "}" msgstr "" -#: ../../c-api/init_config.rst:1463 +#: ../../c-api/init_config.rst:2145 msgid "Isolated Configuration" msgstr "" -#: ../../c-api/init_config.rst:1465 +#: ../../c-api/init_config.rst:2147 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:1470 +#: ../../c-api/init_config.rst:2152 msgid "" "This configuration ignores global configuration variables, environment " "variables, command line arguments (:c:member:`PyConfig.argv` is not parsed) " @@ -2005,115 +3130,115 @@ msgid "" "LC_CTYPE locale are left unchanged. Signal handlers are not installed." msgstr "" -#: ../../c-api/init_config.rst:1475 +#: ../../c-api/init_config.rst:2157 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:1483 +#: ../../c-api/init_config.rst:2165 msgid "Python Configuration" msgstr "" -#: ../../c-api/init_config.rst:1485 +#: ../../c-api/init_config.rst:2167 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:1489 +#: ../../c-api/init_config.rst:2171 msgid "" "Environments variables and command line arguments are used to configure " "Python, whereas global configuration variables are ignored." msgstr "" -#: ../../c-api/init_config.rst:1492 +#: ../../c-api/init_config.rst:2174 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:1501 +#: ../../c-api/init_config.rst:2183 msgid "Python Path Configuration" -msgstr "" +msgstr "Python 路徑配置" -#: ../../c-api/init_config.rst:1503 +#: ../../c-api/init_config.rst:2185 msgid ":c:type:`PyConfig` contains multiple fields for the path configuration:" msgstr "" -#: ../../c-api/init_config.rst:1505 +#: ../../c-api/init_config.rst:2187 msgid "Path configuration inputs:" msgstr "" -#: ../../c-api/init_config.rst:1507 +#: ../../c-api/init_config.rst:2189 msgid ":c:member:`PyConfig.home`" msgstr ":c:member:`PyConfig.home`" -#: ../../c-api/init_config.rst:1508 +#: ../../c-api/init_config.rst:2190 msgid ":c:member:`PyConfig.platlibdir`" msgstr ":c:member:`PyConfig.platlibdir`" -#: ../../c-api/init_config.rst:1509 +#: ../../c-api/init_config.rst:2191 msgid ":c:member:`PyConfig.pathconfig_warnings`" msgstr ":c:member:`PyConfig.pathconfig_warnings`" -#: ../../c-api/init_config.rst:1510 +#: ../../c-api/init_config.rst:2192 msgid ":c:member:`PyConfig.program_name`" msgstr ":c:member:`PyConfig.program_name`" -#: ../../c-api/init_config.rst:1511 +#: ../../c-api/init_config.rst:2193 msgid ":c:member:`PyConfig.pythonpath_env`" msgstr ":c:member:`PyConfig.pythonpath_env`" -#: ../../c-api/init_config.rst:1512 +#: ../../c-api/init_config.rst:2194 msgid "current working directory: to get absolute paths" msgstr "" -#: ../../c-api/init_config.rst:1513 +#: ../../c-api/init_config.rst:2195 msgid "" "``PATH`` environment variable to get the program full path (from :c:member:" "`PyConfig.program_name`)" msgstr "" -#: ../../c-api/init_config.rst:1515 +#: ../../c-api/init_config.rst:2197 msgid "``__PYVENV_LAUNCHER__`` environment variable" msgstr "``__PYVENV_LAUNCHER__`` 環境變數" -#: ../../c-api/init_config.rst:1516 +#: ../../c-api/init_config.rst:2198 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:1520 +#: ../../c-api/init_config.rst:2202 msgid "Path configuration output fields:" msgstr "" -#: ../../c-api/init_config.rst:1522 +#: ../../c-api/init_config.rst:2204 msgid ":c:member:`PyConfig.base_exec_prefix`" msgstr ":c:member:`PyConfig.base_exec_prefix`" -#: ../../c-api/init_config.rst:1523 +#: ../../c-api/init_config.rst:2205 msgid ":c:member:`PyConfig.base_executable`" msgstr ":c:member:`PyConfig.base_executable`" -#: ../../c-api/init_config.rst:1524 +#: ../../c-api/init_config.rst:2206 msgid ":c:member:`PyConfig.base_prefix`" msgstr ":c:member:`PyConfig.base_prefix`" -#: ../../c-api/init_config.rst:1525 +#: ../../c-api/init_config.rst:2207 msgid ":c:member:`PyConfig.exec_prefix`" msgstr ":c:member:`PyConfig.exec_prefix`" -#: ../../c-api/init_config.rst:1526 +#: ../../c-api/init_config.rst:2208 msgid ":c:member:`PyConfig.executable`" msgstr ":c:member:`PyConfig.executable`" -#: ../../c-api/init_config.rst:1527 +#: ../../c-api/init_config.rst:2209 msgid "" ":c:member:`PyConfig.module_search_paths_set`, :c:member:`PyConfig." "module_search_paths`" @@ -2121,11 +3246,11 @@ msgstr "" ":c:member:`PyConfig.module_search_paths_set`, :c:member:`PyConfig." "module_search_paths`" -#: ../../c-api/init_config.rst:1529 +#: ../../c-api/init_config.rst:2211 msgid ":c:member:`PyConfig.prefix`" msgstr ":c:member:`PyConfig.prefix`" -#: ../../c-api/init_config.rst:1531 +#: ../../c-api/init_config.rst:2213 msgid "" "If at least one \"output field\" is not set, Python calculates the path " "configuration to fill unset fields. If :c:member:`~PyConfig." @@ -2134,7 +3259,7 @@ msgid "" "module_search_paths_set` is set to ``1``." msgstr "" -#: ../../c-api/init_config.rst:1537 +#: ../../c-api/init_config.rst:2219 msgid "" "It is possible to completely ignore the function calculating the default " "path configuration by setting explicitly all path configuration output " @@ -2144,52 +3269,52 @@ msgid "" "modification." msgstr "" -#: ../../c-api/init_config.rst:1544 +#: ../../c-api/init_config.rst:2226 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:1547 +#: ../../c-api/init_config.rst:2229 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:1551 +#: ../../c-api/init_config.rst:2233 msgid ":c:func:`Py_RunMain` and :c:func:`Py_Main` modify :data:`sys.path`:" -msgstr "" +msgstr ":c:func:`Py_RunMain` 和 :c:func:`Py_Main` 會修改 :data:`sys.path`:" -#: ../../c-api/init_config.rst:1553 +#: ../../c-api/init_config.rst:2235 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:1556 +#: ../../c-api/init_config.rst:2238 msgid "If :c:member:`~PyConfig.isolated` is zero:" msgstr "如果 :c:member:`~PyConfig.isolated` 為零:" -#: ../../c-api/init_config.rst:1558 +#: ../../c-api/init_config.rst:2240 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:1560 +#: ../../c-api/init_config.rst:2242 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:1562 +#: ../../c-api/init_config.rst:2244 msgid "Otherwise, prepend an empty string to :data:`sys.path`." msgstr "" -#: ../../c-api/init_config.rst:1564 +#: ../../c-api/init_config.rst:2246 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." @@ -2198,213 +3323,100 @@ msgid "" "data:`sys.path`." msgstr "" -#: ../../c-api/init_config.rst:1570 +#: ../../c-api/init_config.rst:2252 msgid "The following configuration files are used by the path configuration:" msgstr "" -#: ../../c-api/init_config.rst:1572 +#: ../../c-api/init_config.rst:2254 msgid "``pyvenv.cfg``" msgstr "``pyvenv.cfg``" -#: ../../c-api/init_config.rst:1573 +#: ../../c-api/init_config.rst:2255 msgid "``._pth`` file (ex: ``python._pth``)" msgstr "" -#: ../../c-api/init_config.rst:1574 +#: ../../c-api/init_config.rst:2256 msgid "``pybuilddir.txt`` (Unix only)" msgstr "``pybuilddir.txt``\\ (僅限 Unix)" -#: ../../c-api/init_config.rst:1576 +#: ../../c-api/init_config.rst:2258 msgid "If a ``._pth`` file is present:" msgstr "" -#: ../../c-api/init_config.rst:1578 +#: ../../c-api/init_config.rst:2260 msgid "Set :c:member:`~PyConfig.isolated` to ``1``." msgstr "將 :c:member:`~PyConfig.isolated` 設定為 ``1``。" -#: ../../c-api/init_config.rst:1579 +#: ../../c-api/init_config.rst:2261 msgid "Set :c:member:`~PyConfig.use_environment` to ``0``." msgstr "將 :c:member:`~PyConfig.use_environment` 設定為 ``0``。" -#: ../../c-api/init_config.rst:1580 +#: ../../c-api/init_config.rst:2262 msgid "Set :c:member:`~PyConfig.site_import` to ``0``." msgstr "將 :c:member:`~PyConfig.site_import` 設定為 ``0``。" -#: ../../c-api/init_config.rst:1581 +#: ../../c-api/init_config.rst:2263 msgid "Set :c:member:`~PyConfig.safe_path` to ``1``." msgstr "將 :c:member:`~PyConfig.safe_path` 設定為 ``1``。" -#: ../../c-api/init_config.rst:1583 +#: ../../c-api/init_config.rst:2265 +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 " +"parent, :c:member:`~PyConfig.prefix` and :c:member:`~PyConfig.exec_prefix` " +"are set that location. When this happens, :c:member:`~PyConfig.base_prefix` " +"and :c:member:`~PyConfig.base_exec_prefix` still keep their value, pointing " +"to the base installation. See :ref:`sys-path-init-virtual-environments` for " +"more information." +msgstr "" + +#: ../../c-api/init_config.rst:2273 msgid "" "The ``__PYVENV_LAUNCHER__`` environment variable is used to set :c:member:" "`PyConfig.base_executable`." msgstr "" -#: ../../c-api/init_config.rst:1588 +#: ../../c-api/init_config.rst:2278 +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:2284 msgid "Py_GetArgcArgv()" msgstr "Py_GetArgcArgv()" -#: ../../c-api/init_config.rst:1592 +#: ../../c-api/init_config.rst:2288 msgid "Get the original command line arguments, before Python modified them." msgstr "" -#: ../../c-api/init_config.rst:1594 +#: ../../c-api/init_config.rst:2290 msgid "See also :c:member:`PyConfig.orig_argv` member." msgstr "也請參與 :c:member:`PyConfig.orig_argv` 成員。" -#: ../../c-api/init_config.rst:1598 -msgid "Multi-Phase Initialization Private Provisional API" -msgstr "" - -#: ../../c-api/init_config.rst:1600 -msgid "" -"This section is a private provisional API introducing multi-phase " -"initialization, the core feature of :pep:`432`:" -msgstr "" - -#: ../../c-api/init_config.rst:1603 -msgid "\"Core\" initialization phase, \"bare minimum Python\":" -msgstr "" - -#: ../../c-api/init_config.rst:1605 -msgid "Builtin types;" -msgstr "內建型別;" - -#: ../../c-api/init_config.rst:1606 -msgid "Builtin exceptions;" -msgstr "內建例外;" - -#: ../../c-api/init_config.rst:1607 -msgid "Builtin and frozen modules;" -msgstr "" - -#: ../../c-api/init_config.rst:1608 -msgid "" -"The :mod:`sys` module is only partially initialized (ex: :data:`sys.path` " -"doesn't exist yet)." -msgstr "" - -#: ../../c-api/init_config.rst:1611 -msgid "\"Main\" initialization phase, Python is fully initialized:" -msgstr "" - -#: ../../c-api/init_config.rst:1613 -msgid "Install and configure :mod:`importlib`;" -msgstr "" - -#: ../../c-api/init_config.rst:1614 -msgid "Apply the :ref:`Path Configuration `;" -msgstr "" - -#: ../../c-api/init_config.rst:1615 -msgid "Install signal handlers;" -msgstr "" - -#: ../../c-api/init_config.rst:1616 -msgid "" -"Finish :mod:`sys` module initialization (ex: create :data:`sys.stdout` and :" -"data:`sys.path`);" -msgstr "" - -#: ../../c-api/init_config.rst:1618 -msgid "" -"Enable optional features like :mod:`faulthandler` and :mod:`tracemalloc`;" -msgstr "" - -#: ../../c-api/init_config.rst:1619 -msgid "Import the :mod:`site` module;" -msgstr "引入 :mod:`site` 模組;" - -#: ../../c-api/init_config.rst:1620 -msgid "etc." -msgstr "" - -#: ../../c-api/init_config.rst:1622 -msgid "Private provisional API:" -msgstr "" - -#: ../../c-api/init_config.rst:1624 -msgid "" -":c:member:`PyConfig._init_main`: if set to ``0``, :c:func:" -"`Py_InitializeFromConfig` stops at the \"Core\" initialization phase." -msgstr "" - -#: ../../c-api/init_config.rst:1629 -msgid "" -"Move to the \"Main\" initialization phase, finish the Python initialization." -msgstr "" - -#: ../../c-api/init_config.rst:1631 -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:1637 -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." +#: ../../c-api/init_config.rst:2293 +msgid "Delaying main module execution" msgstr "" -#: ../../c-api/init_config.rst:1641 +#: ../../c-api/init_config.rst:2295 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." +"In some embedding use cases, it may be desirable to separate interpreter " +"initialization from the execution of the main module." msgstr "" -#: ../../c-api/init_config.rst:1646 +#: ../../c-api/init_config.rst:2298 msgid "" -"Example running Python code between \"Core\" and \"Main\" initialization " -"phases::" -msgstr "" - -#: ../../c-api/init_config.rst:1649 -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" -"}" +"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." msgstr "" -#: ../../c-api/init_config.rst:558 +#: ../../c-api/init_config.rst:1181 msgid "main()" msgstr "main()" -#: ../../c-api/init_config.rst:558 +#: ../../c-api/init_config.rst:1181 msgid "argv (in module sys)" msgstr "" diff --git a/c-api/intro.po b/c-api/intro.po index 4c39517d629..6ac502b87ce 100644 --- a/c-api/intro.po +++ b/c-api/intro.po @@ -1,13 +1,13 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Matt Wang , 2023 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"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: 2025-11-25 00:13+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-" @@ -67,10 +67,24 @@ msgstr "" "式之前熟悉編寫擴充可能是個好主意。" #: ../../c-api/intro.rst:34 +msgid "Language version compatibility" +msgstr "語言版本相容性" + +#: ../../c-api/intro.rst:36 +msgid "Python's C API is compatible with C11 and C++11 versions of C and C++." +msgstr "Python 的 C API 與 C11 和 C++11 版本的 C 和 C++ 相容。" + +#: ../../c-api/intro.rst:38 +msgid "" +"This is a lower limit: the C API does not require features from later C/C++ " +"versions. You do *not* need to enable your compiler's \"c11 mode\"." +msgstr "" + +#: ../../c-api/intro.rst:44 msgid "Coding standards" msgstr "編寫標準" -#: ../../c-api/intro.rst:36 +#: ../../c-api/intro.rst:46 msgid "" "If you're writing C code for inclusion in CPython, you **must** follow the " "guidelines and standards defined in :PEP:`7`. These guidelines apply " @@ -82,11 +96,11 @@ msgstr "" "中定義的指南和標準。無論你貢獻的 Python 版本如何,這些指南都適用。對於你自己" "的第三方擴充模組,則不必遵循這些約定,除非你希望最終將它們貢獻給 Python。" -#: ../../c-api/intro.rst:46 +#: ../../c-api/intro.rst:56 msgid "Include Files" msgstr "引入檔案 (include files)" -#: ../../c-api/intro.rst:48 +#: ../../c-api/intro.rst:58 msgid "" "All function, type and macro definitions needed to use the Python/C API are " "included in your code by the following line::" @@ -94,7 +108,7 @@ msgstr "" "使用 Python/C API 所需的所有函式、型別和巨集的定義都透過以下這幾行來在你的程" "式碼中引入:" -#: ../../c-api/intro.rst:51 +#: ../../c-api/intro.rst:61 msgid "" "#define PY_SSIZE_T_CLEAN\n" "#include " @@ -102,7 +116,7 @@ msgstr "" "#define PY_SSIZE_T_CLEAN\n" "#include " -#: ../../c-api/intro.rst:54 +#: ../../c-api/intro.rst:64 msgid "" "This implies inclusion of the following standard headers: ````, " "````, ````, ````, ```` and ````、````、````、" "````、```` 和 ````\\ (如果可用)。" -#: ../../c-api/intro.rst:60 +#: ../../c-api/intro.rst:70 msgid "" "Since Python may define some pre-processor definitions which affect the " "standard headers on some systems, you *must* include :file:`Python.h` before " @@ -120,7 +134,7 @@ msgstr "" "由於 Python 可能會定義一些會影響某些系統上標準標頭檔的預處理器 (pre-" "processor),因此你\\ *必須*\\ 在引入任何標準標頭檔之前引入 :file:`Python.h`。" -#: ../../c-api/intro.rst:64 +#: ../../c-api/intro.rst:74 msgid "" "It is recommended to always define ``PY_SSIZE_T_CLEAN`` before including " "``Python.h``. See :ref:`arg-parsing` for a description of this macro." @@ -128,7 +142,7 @@ msgstr "" "建議在引入 ``Python.h`` 之前都要定義 ``PY_SSIZE_T_CLEAN``。有關此巨集的說明," "請參閱\\ :ref:`arg-parsing`。" -#: ../../c-api/intro.rst:67 +#: ../../c-api/intro.rst:77 msgid "" "All user visible names defined by Python.h (except those defined by the " "included standard headers) have one of the prefixes ``Py`` or ``_Py``. " @@ -140,7 +154,7 @@ msgstr "" "有 ``Py`` 或 ``_Py`` 前綴。以 ``_Py`` 開頭的名稱供 Python 實作內部使用,擴充" "編寫者不應使用。結構成員名稱沒有保留前綴。" -#: ../../c-api/intro.rst:74 +#: ../../c-api/intro.rst:84 msgid "" "User code should never define names that begin with ``Py`` or ``_Py``. This " "confuses the reader, and jeopardizes the portability of the user code to " @@ -151,7 +165,7 @@ msgstr "" "並危及使用者程式碼在未來 Python 版本上的可移植性,這些版本可能會定義以這些前" "綴之一開頭的其他名稱。" -#: ../../c-api/intro.rst:79 +#: ../../c-api/intro.rst:89 msgid "" "The header files are typically installed with Python. On Unix, these are " "located in the directories :file:`{prefix}/include/pythonversion/` and :file:" @@ -169,7 +183,7 @@ msgstr "" "sys.version_info[:2]``。在 Windows 上,標頭安裝在 :file:`{prefix}/include` " "中,其中 ``prefix`` 是指定給安裝程式 (installer) 用的安裝目錄。" -#: ../../c-api/intro.rst:88 +#: ../../c-api/intro.rst:98 msgid "" "To include the headers, place both directories (if different) on your " "compiler's search path for includes. Do *not* place the parent directories " @@ -183,7 +197,7 @@ msgstr "" "h>``;這會在多平台建置上壞掉,因為 :option:`prefix <--prefix>` 下獨立於平台的" "標頭包括來自 :option:`exec_prefix <--exec-prefix>` 的平台特定標頭。" -#: ../../c-api/intro.rst:95 +#: ../../c-api/intro.rst:105 msgid "" "C++ users should note that although the API is defined entirely using C, the " "header files properly declare the entry points to be ``extern \"C\"``. As a " @@ -192,66 +206,32 @@ msgstr "" "C++ 使用者應注意,儘管 API 完全使用 C 來定義,但標頭檔適當地將入口點聲明為 " "``extern \"C\"``。因此,無需執行任何特殊操作即可使用 C++ 中的 API。" -#: ../../c-api/intro.rst:101 +#: ../../c-api/intro.rst:111 msgid "Useful macros" msgstr "有用的巨集" -#: ../../c-api/intro.rst:103 +#: ../../c-api/intro.rst:113 msgid "" "Several useful macros are defined in the Python header files. Many are " -"defined closer to where they are useful (e.g. :c:macro:`Py_RETURN_NONE`). " -"Others of a more general utility are defined here. This is not necessarily " -"a complete listing." +"defined closer to where they are useful (for example, :c:macro:" +"`Py_RETURN_NONE`, :c:macro:`PyMODINIT_FUNC`). Others of a more general " +"utility are defined here. This is not necessarily a complete listing." msgstr "" "Python 標頭檔中定義了幾個有用的巨集,大多被定義在它們有用的地方附近(例如 :c:" -"macro:`Py_RETURN_NONE`),其他是更通用的工具程式。以下並不一定是完整的列表。" +"macro:`Py_RETURN_NONE`、:c:macro:`PyMODINIT_FUNC`),其他是更通用的工具程式。" +"以下並不一定是完整的列表。" -#: ../../c-api/intro.rst:110 -msgid "" -"Declare an extension module ``PyInit`` initialization function. The function " -"return type is :c:expr:`PyObject*`. The macro declares any special linkage " -"declarations required by the platform, and for C++ declares the function as " -"``extern \"C\"``." -msgstr "" +#: ../../c-api/intro.rst:122 +msgid "Return the absolute value of ``x``." +msgstr "回傳 ``x`` 的絕對值。" -#: ../../c-api/intro.rst:115 +#: ../../c-api/intro.rst:124 msgid "" -"The initialization function must be named :samp:`PyInit_{name}`, where " -"*name* is the name of the module, and should be the only non-\\ ``static`` " -"item defined in the module file. Example::" +"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:119 -msgid "" -"static struct PyModuleDef spam_module = {\n" -" .m_base = PyModuleDef_HEAD_INIT,\n" -" .m_name = \"spam\",\n" -" ...\n" -"};\n" -"\n" -"PyMODINIT_FUNC\n" -"PyInit_spam(void)\n" -"{\n" -" return PyModuleDef_Init(&spam_module);\n" -"}" -msgstr "" -"static struct PyModuleDef spam_module = {\n" -" .m_base = PyModuleDef_HEAD_INIT,\n" -" .m_name = \"spam\",\n" -" ...\n" -"};\n" -"\n" -"PyMODINIT_FUNC\n" -"PyInit_spam(void)\n" -"{\n" -" return PyModuleDef_Init(&spam_module);\n" -"}" - -#: ../../c-api/intro.rst:134 -msgid "Return the absolute value of ``x``." -msgstr "回傳 ``x`` 的絕對值。" - -#: ../../c-api/intro.rst:140 +#: ../../c-api/intro.rst:132 msgid "" "Ask the compiler to always inline a static inline function. The compiler can " "ignore it and decide to not inline the function." @@ -259,7 +239,7 @@ msgstr "" "要求編譯器總是嵌入靜態行內函式 (static inline function),編譯器可以忽略它並決" "定不嵌入該函式。" -#: ../../c-api/intro.rst:143 +#: ../../c-api/intro.rst:135 msgid "" "It can be used to inline performance critical static inline functions when " "building Python in debug mode with function inlining disabled. For example, " @@ -268,7 +248,7 @@ msgstr "" "在禁用函式嵌入的除錯模式下建置 Python 時,它可用於嵌入有性能要求的靜態行內函" "式。例如,MSC 在除錯模式下建置時禁用函式嵌入。" -#: ../../c-api/intro.rst:147 +#: ../../c-api/intro.rst:139 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 " @@ -277,7 +257,7 @@ msgstr "" "盲目地使用 Py_ALWAYS_INLINE 標記靜態行內函式可能會導致更差的性能(例如程式碼" "大小增加)。在成本/收益分析方面,編譯器通常比開發人員更聰明。" -#: ../../c-api/intro.rst:151 +#: ../../c-api/intro.rst:143 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 " @@ -286,15 +266,15 @@ msgstr "" "如果 Python 是\\ :ref:`在除錯模式下建置 `\\ (如果 :c:macro:" "`Py_DEBUG` 巨集有被定義),:c:macro:`Py_ALWAYS_INLINE` 巨集就什麼都不會做。" -#: ../../c-api/intro.rst:154 +#: ../../c-api/intro.rst:146 msgid "It must be specified before the function return type. Usage::" msgstr "它必須在函式回傳型別之前被指定。用法: ::" -#: ../../c-api/intro.rst:156 +#: ../../c-api/intro.rst:148 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:162 +#: ../../c-api/intro.rst:154 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``." @@ -302,26 +282,26 @@ msgstr "" "引數必須是 [-128, 127] 或 [0, 255] 範圍內的字元或整數。這個巨集會將 ``c`` 轉" "換為 ``unsigned char`` 並回傳。" -#: ../../c-api/intro.rst:167 +#: ../../c-api/intro.rst:159 msgid "" "Use this for deprecated declarations. The macro must be placed before the " "symbol name." msgstr "將其用於已棄用的聲明。巨集必須放在符號名稱之前。" -#: ../../c-api/intro.rst:170 ../../c-api/intro.rst:256 -#: ../../c-api/intro.rst:274 +#: ../../c-api/intro.rst:162 ../../c-api/intro.rst:290 +#: ../../c-api/intro.rst:308 msgid "Example::" msgstr "範例: ::" -#: ../../c-api/intro.rst:172 +#: ../../c-api/intro.rst:164 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:174 +#: ../../c-api/intro.rst:166 msgid "MSVC support was added." msgstr "新增了 MSVC 支援。" -#: ../../c-api/intro.rst:179 +#: ../../c-api/intro.rst:171 msgid "" "Like ``getenv(s)``, but returns ``NULL`` if :option:`-E` was passed on the " "command line (see :c:member:`PyConfig.use_environment`)." @@ -329,19 +309,44 @@ msgstr "" "類似於 ``getenv(s)``,但如果在命令列上傳遞了 :option:`-E` 則回傳 ``NULL`` " "(請見 :c:member:`PyConfig.use_environment`)。" -#: ../../c-api/intro.rst:184 +#: ../../c-api/intro.rst:176 +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 ``static type``." +msgstr "" + +#: ../../c-api/intro.rst:182 +msgid "" +"Equivalent to :c:macro:`Py_LOCAL` but additionally requests the function be " +"inlined." +msgstr "" + +#: ../../c-api/intro.rst:187 msgid "Return the maximum value between ``x`` and ``y``." msgstr "回傳 ``x`` 和 ``y`` 之間的最大值。" -#: ../../c-api/intro.rst:190 +#: ../../c-api/intro.rst:193 msgid "Return the size of a structure (``type``) ``member`` in bytes." msgstr "以位元組為單位回傳結構 (``type``) ``member`` 的大小。" -#: ../../c-api/intro.rst:196 +#: ../../c-api/intro.rst:199 +msgid "" +"This is a :term:`soft deprecated` alias to :c:func:`!memcpy`. Use :c:func:`!" +"memcpy` directly instead." +msgstr "" +"這是 :c:func:`!memcpy` 的已\\ :term:`軟性棄用 `\\ 別名。請直" +"接使用 :c:func:`!memcpy`。" + +#: ../../c-api/intro.rst:202 +msgid "The macro is :term:`soft deprecated`." +msgstr "這個巨集已被\\ :term:`軟性棄用 `。" + +#: ../../c-api/intro.rst:207 msgid "Return the minimum value between ``x`` and ``y``." msgstr "回傳 ``x`` 和 ``y`` 之間的最小值。" -#: ../../c-api/intro.rst:202 +#: ../../c-api/intro.rst:213 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:" @@ -350,21 +355,21 @@ msgstr "" "禁用函式的嵌入。例如,它減少了 C 堆疊的消耗:對大量嵌入程式碼的 LTO+PGO 建置" "很有用(請參閱 :issue:`33720`)。" -#: ../../c-api/intro.rst:206 +#: ../../c-api/intro.rst:217 msgid "Usage::" msgstr "用法: ::" -#: ../../c-api/intro.rst:208 +#: ../../c-api/intro.rst:219 msgid "Py_NO_INLINE static int random(void) { return 4; }" msgstr "Py_NO_INLINE static int random(void) { return 4; }" -#: ../../c-api/intro.rst:214 +#: ../../c-api/intro.rst:225 msgid "" "Convert ``x`` to a C string. E.g. ``Py_STRINGIFY(123)`` returns ``\"123\"``." msgstr "" "將 ``x`` 轉換為 C 字串。例如 ``Py_STRINGIFY(123)`` 會回傳 ``\"123\"``。" -#: ../../c-api/intro.rst:221 +#: ../../c-api/intro.rst:232 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 " @@ -375,7 +380,7 @@ msgstr "" "蓋了所有可能值的 ``switch`` 陳述式中的 ``default:`` 子句。在你可能想要呼叫 " "``assert(0)`` 或 ``abort()`` 的地方使用它。" -#: ../../c-api/intro.rst:226 +#: ../../c-api/intro.rst:237 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 " @@ -385,7 +390,7 @@ msgstr "" "程式碼的警告。例如該巨集是在發布模式下於 GCC 使用 " "``__builtin_unreachable()`` 來實作。" -#: ../../c-api/intro.rst:230 +#: ../../c-api/intro.rst:241 msgid "" "A use for ``Py_UNREACHABLE()`` is following a call a function that never " "returns but that is not declared :c:macro:`_Py_NO_RETURN`." @@ -393,7 +398,7 @@ msgstr "" "``Py_UNREACHABLE()`` 的一個用途是,在對一個永不回傳但並未聲明為 :c:macro:" "`_Py_NO_RETURN` 的函式之呼叫後使用。" -#: ../../c-api/intro.rst:233 +#: ../../c-api/intro.rst:244 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 " @@ -405,7 +410,7 @@ msgstr "" "憶體條件下或系統呼叫回傳了超出預期範圍的值。在這種情況下,最好將錯誤回報給呼" "叫者。如果無法回報錯誤則可以使用 :c:func:`Py_FatalError`。" -#: ../../c-api/intro.rst:243 +#: ../../c-api/intro.rst:254 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; }``." @@ -413,15 +418,45 @@ msgstr "" "將此用於函式定義中未使用的參數以消除編譯器警告。例如:``int func(int a, int " "Py_UNUSED(b)) { return a; }``。" -#: ../../c-api/intro.rst:250 +#: ../../c-api/intro.rst:261 +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:264 ../../c-api/intro.rst:275 +#: ../../c-api/intro.rst:320 +msgid "For example::" +msgstr "範例: ::" + +#: ../../c-api/intro.rst:266 +msgid "Py_BUILD_ASSERT(sizeof(PyTime_t) == sizeof(int64_t));" +msgstr "Py_BUILD_ASSERT(sizeof(PyTime_t) == sizeof(int64_t));" + +#: ../../c-api/intro.rst:272 +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:277 msgid "" -"Creates a variable with name ``name`` that can be used in docstrings. If " +"#define foo_to_char(foo) \\\n" +" ((char *)(foo) + Py_BUILD_ASSERT_EXPR(offsetof(struct foo, string) == 0))" +msgstr "" +"#define foo_to_char(foo) \\\n" +" ((char *)(foo) + Py_BUILD_ASSERT_EXPR(offsetof(struct foo, string) == 0))" + +#: ../../c-api/intro.rst:284 +msgid "" +"Creates a variable with name *name* that can be used in docstrings. If " "Python is built without docstrings, the value will be empty." msgstr "" -"建立一個名為 ``name`` 的變數,可以在文件字串中使用。如果 Python 是在沒有文件" -"字串的情況下建置,則該值將為空。" +"建立一個名為 *name* 的變數,可以在文件字串中使用。如果 Python 是在沒有文件字" +"串的情況下建置,則該值將為空。" -#: ../../c-api/intro.rst:253 +#: ../../c-api/intro.rst:287 msgid "" "Use :c:macro:`PyDoc_STRVAR` for docstrings to support building Python " "without docstrings, as specified in :pep:`7`." @@ -429,7 +464,7 @@ msgstr "" "如 :pep:`7` 中所指明,使用 :c:macro:`PyDoc_STRVAR` 作為文件字串可以支援在沒有" "文件字串的情況下建置 Python。" -#: ../../c-api/intro.rst:258 +#: ../../c-api/intro.rst:292 msgid "" "PyDoc_STRVAR(pop_doc, \"Remove and return the rightmost element.\");\n" "\n" @@ -439,14 +474,21 @@ msgid "" " // ...\n" "}" msgstr "" +"PyDoc_STRVAR(pop_doc, \"Remove and return the rightmost element.\");\n" +"\n" +"static PyMethodDef deque_methods[] = {\n" +" // ...\n" +" {\"pop\", (PyCFunction)deque_pop, METH_NOARGS, pop_doc},\n" +" // ...\n" +"}" -#: ../../c-api/intro.rst:268 +#: ../../c-api/intro.rst:302 msgid "" "Creates a docstring for the given input string or an empty string if " "docstrings are disabled." msgstr "為給定的輸入字串建立一個文件字串,如果文件字串被禁用則建立空字串。" -#: ../../c-api/intro.rst:271 +#: ../../c-api/intro.rst:305 msgid "" "Use :c:macro:`PyDoc_STR` in specifying docstrings to support building Python " "without docstrings, as specified in :pep:`7`." @@ -454,7 +496,7 @@ msgstr "" "如 :pep:`7` 中所指明,使用 :c:macro:`PyDoc_STR` 指定文件字串以支援在沒有文件" "字串下建置 Python。" -#: ../../c-api/intro.rst:276 +#: ../../c-api/intro.rst:310 msgid "" "static PyMethodDef pysqlite_row_methods[] = {\n" " {\"keys\", (PyCFunction)pysqlite_row_keys, METH_NOARGS,\n" @@ -462,12 +504,53 @@ msgid "" " {NULL, NULL}\n" "};" msgstr "" +"static PyMethodDef pysqlite_row_methods[] = {\n" +" {\"keys\", (PyCFunction)pysqlite_row_keys, METH_NOARGS,\n" +" PyDoc_STR(\"Returns the keys of the row.\")},\n" +" {NULL, NULL}\n" +"};" -#: ../../c-api/intro.rst:286 +#: ../../c-api/intro.rst:318 +msgid "Declares a static character array variable with the given name *name*." +msgstr "" + +#: ../../c-api/intro.rst:322 +msgid "" +"PyDoc_VAR(python_doc) = PyDoc_STR(\"A genus of constricting snakes in the " +"Pythonidae family native \"\n" +" \"to the tropics and subtropics of the " +"Eastern Hemisphere.\");" +msgstr "" +"PyDoc_VAR(python_doc) = PyDoc_STR(\"A genus of constricting snakes in the " +"Pythonidae family native \"\n" +" \"to the tropics and subtropics of the " +"Eastern Hemisphere.\");" + +#: ../../c-api/intro.rst:327 +msgid "Compute the length of a statically allocated C array at compile time." +msgstr "" + +#: ../../c-api/intro.rst:329 +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 " +"result in a compilation error on some compilers, or otherwise produce " +"incorrect results." +msgstr "" + +#: ../../c-api/intro.rst:334 +msgid "This is roughly equivalent to::" +msgstr "" + +#: ../../c-api/intro.rst:336 +msgid "sizeof(array) / sizeof((array)[0])" +msgstr "" + +#: ../../c-api/intro.rst:342 msgid "Objects, Types and Reference Counts" msgstr "物件、型別和參照計數" -#: ../../c-api/intro.rst:290 +#: ../../c-api/intro.rst:346 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 " @@ -490,7 +573,7 @@ msgstr "" "別物件;由於它們絕不能被釋放,因此它們通常是靜態 :c:type:`PyTypeObject` 物" "件。" -#: ../../c-api/intro.rst:301 +#: ../../c-api/intro.rst:357 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." @@ -506,11 +589,11 @@ msgstr "" "`types`\\ )。對於每個眾所周知的型別,都有一個巨集來檢查物件是否屬於該型別;" "例如,若(且唯若)*a* 指向的物件是 Python list 時,``PyList_Check(a)`` 為真。" -#: ../../c-api/intro.rst:312 +#: ../../c-api/intro.rst:368 msgid "Reference Counts" msgstr "參照計數" -#: ../../c-api/intro.rst:314 +#: ../../c-api/intro.rst:370 msgid "" "The reference count is important because today's computers have a finite " "(and often severely limited) memory size; it counts how many different " @@ -533,7 +616,7 @@ msgstr "" "則可以依次為那些其他物件解除配置,依此類推。(此處相互參照物件的存在是個明顯" "的問題;目前,解決方案是「就不要那樣做」。)" -#: ../../c-api/intro.rst:331 +#: ../../c-api/intro.rst:387 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. " @@ -561,7 +644,7 @@ msgstr "" "元會被使用(假設 ``sizeof(Py_ssize_t) >= sizeof(void*)``)。因此參照計數增加" "是一個簡單的操作。" -#: ../../c-api/intro.rst:347 +#: ../../c-api/intro.rst:403 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 " @@ -587,7 +670,7 @@ msgstr "" "種情況的一個重要情況是在從 Python 呼叫的擴充模組中作為引數傳遞給 C 函式的物" "件;呼叫機制保證在呼叫期間保持對每個參數的參照。" -#: ../../c-api/intro.rst:363 +#: ../../c-api/intro.rst:419 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 " @@ -603,7 +686,7 @@ msgstr "" "程式碼路徑允許控制權從 :c:func:`Py_DECREF` 回歸使用者,因此幾乎任何操作都有潛" "在危險。" -#: ../../c-api/intro.rst:371 +#: ../../c-api/intro.rst:427 msgid "" "A safe approach is to always use the generic operations (functions whose " "name begins with ``PyObject_``, ``PyNumber_``, ``PySequence_`` or " @@ -618,11 +701,11 @@ msgstr "" "計數)。這讓呼叫者有責任在處理完結果後呼叫 :c:func:`Py_DECREF`;這就成為第二" "本質。" -#: ../../c-api/intro.rst:382 +#: ../../c-api/intro.rst:438 msgid "Reference Count Details" msgstr "參照計數詳細資訊" -#: ../../c-api/intro.rst:384 +#: ../../c-api/intro.rst:440 msgid "" "The reference count behavior of functions in the Python/C API is best " "explained in terms of *ownership of references*. Ownership pertains to " @@ -647,7 +730,7 @@ msgstr "" "照。當沒有所有權轉移時,呼叫者被稱為\\ *借用*\\ 參照。如果是\\ :term:`借用參" "照 `\\ 就不需要做任何事情。" -#: ../../c-api/intro.rst:397 +#: ../../c-api/intro.rst:453 msgid "" "Conversely, when a calling function passes in a reference to an object, " "there are two possibilities: the function *steals* a reference to the " @@ -659,7 +742,7 @@ msgstr "" "物件的參照,或者沒有。 *竊取參照*\\ 意味著當你將參照傳遞給函式時,該函式假定" "它現在擁有該參照,並且你不再對它負責。" -#: ../../c-api/intro.rst:407 +#: ../../c-api/intro.rst:463 msgid "" "Few functions steal references; the two notable exceptions are :c:func:" "`PyList_SetItem` and :c:func:`PyTuple_SetItem`, which steal a reference to " @@ -676,7 +759,7 @@ msgstr "" "慣,這些函式旨在竊取參照;例如,建立 tuple ``(1, 2, \"three\")`` 的程式碼可以" "如下所示(先暫時忘記錯誤處理;更好的編寫方式如下所示):" -#: ../../c-api/intro.rst:415 +#: ../../c-api/intro.rst:471 msgid "" "PyObject *t;\n" "\n" @@ -692,7 +775,7 @@ msgstr "" "PyTuple_SetItem(t, 1, PyLong_FromLong(2L));\n" "PyTuple_SetItem(t, 2, PyUnicode_FromString(\"three\"));" -#: ../../c-api/intro.rst:422 +#: ../../c-api/intro.rst:478 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 " @@ -703,7 +786,7 @@ msgstr "" "`PyTuple_SetItem` 竊取。如果你想繼續使用一個物件,儘管對它的參照將被竊取,請" "在呼叫參照竊取函式之前使用 :c:func:`Py_INCREF` 來取得另一個參照。" -#: ../../c-api/intro.rst:427 +#: ../../c-api/intro.rst:483 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 " @@ -715,7 +798,7 @@ msgstr "" "tuple 是一種不可變 (immutable) 的資料型別。你應該只對你自己建立的 tuple 使" "用 :c:func:`PyTuple_SetItem`。" -#: ../../c-api/intro.rst:432 +#: ../../c-api/intro.rst:488 msgid "" "Equivalent code for populating a list can be written using :c:func:" "`PyList_New` and :c:func:`PyList_SetItem`." @@ -723,7 +806,7 @@ msgstr "" "可以使用 :c:func:`PyList_New` 和 :c:func:`PyList_SetItem` 編寫用於填充列表的" "等效程式碼。" -#: ../../c-api/intro.rst:435 +#: ../../c-api/intro.rst:491 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:" @@ -736,7 +819,7 @@ msgstr "" "string` 引導。例如上面的兩個程式碼可以用以下程式碼替換(它還負責了錯誤檢" "查): ::" -#: ../../c-api/intro.rst:441 +#: ../../c-api/intro.rst:497 msgid "" "PyObject *tuple, *list;\n" "\n" @@ -748,7 +831,7 @@ msgstr "" "tuple = Py_BuildValue(\"(iis)\", 1, 2, \"three\");\n" "list = Py_BuildValue(\"[iis]\", 1, 2, \"three\");" -#: ../../c-api/intro.rst:446 +#: ../../c-api/intro.rst:502 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 " @@ -763,7 +846,7 @@ msgstr "" "穩健,因為你不取得新的一個參照就可以放棄參照(「讓它被竊取」)。例如,此函式" "將 list(實際上是任何可變序列)的所有項目設定於給定項目:" -#: ../../c-api/intro.rst:453 +#: ../../c-api/intro.rst:509 msgid "" "int\n" "set_all(PyObject *target, PyObject *item)\n" @@ -807,7 +890,7 @@ msgstr "" " return 0;\n" "}" -#: ../../c-api/intro.rst:476 +#: ../../c-api/intro.rst:532 msgid "" "The situation is slightly different for function return values. While " "passing a reference to most functions does not change your ownership " @@ -825,7 +908,7 @@ msgstr "" "照的通用函式,如 :c:func:`PyObject_GetItem` 和 :c:func:`PySequence_GetItem`," "總是回傳一個新的參照(呼叫者成為參照的所有者)。" -#: ../../c-api/intro.rst:485 +#: ../../c-api/intro.rst:541 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 " @@ -836,12 +919,12 @@ msgid "" "the same arguments), you do own a reference to the returned object." msgstr "" "重要的是要意識到你是否擁有一個函式回傳的參照只取決於你呼叫哪個函式 --- *羽毛 " -"(plumage)*(作為引數傳遞給函式的物件之型別)\\ *不會進入它!*\\ 因此,如果你" -"使用 :c:func:`PyList_GetItem` 從 list 中提取一個項目,你不會擁有其參照 --- 但" -"如果你使用 :c:func:`PySequence_GetItem` 從同一 list 中取得相同的項目(且恰好" -"使用完全相同的引數),你確實會擁有對回傳物件的參照。" +"(plumage)*\\ (作為引數傳遞給函式的物件之型別)\\ *不會進入它!*\\ 因此,如果" +"你使用 :c:func:`PyList_GetItem` 從 list 中提取一個項目,你不會擁有其參照 --- " +"但如果你使用 :c:func:`PySequence_GetItem` 從同一 list 中取得相同的項目(且恰" +"好使用完全相同的引數),你確實會擁有對回傳物件的參照。" -#: ../../c-api/intro.rst:497 +#: ../../c-api/intro.rst:553 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`, " @@ -850,7 +933,7 @@ msgstr "" "以下是一個範例,說明如何編寫函式來計算一個整數 list 中項目的總和;一次使用 :" "c:func:`PyList_GetItem`,一次使用 :c:func:`PySequence_GetItem`: ::" -#: ../../c-api/intro.rst:501 +#: ../../c-api/intro.rst:557 msgid "" "long\n" "sum_list(PyObject *list)\n" @@ -874,8 +957,29 @@ msgid "" " return total;\n" "}" msgstr "" +"long\n" +"sum_list(PyObject *list)\n" +"{\n" +" Py_ssize_t i, n;\n" +" long total = 0, value;\n" +" PyObject *item;\n" +"\n" +" n = PyList_Size(list);\n" +" if (n < 0)\n" +" return -1; /* 不是 list */\n" +" for (i = 0; i < n; i++) {\n" +" item = PyList_GetItem(list, i); /* 不會失敗 */\n" +" if (!PyLong_Check(item)) continue; /* 跳過非整數 */\n" +" value = PyLong_AsLong(item);\n" +" if (value == -1 && PyErr_Occurred())\n" +" /* 整數太大,無法放入 C long,退出 */\n" +" return -1;\n" +" total += value;\n" +" }\n" +" return total;\n" +"}" -#: ../../c-api/intro.rst:527 +#: ../../c-api/intro.rst:583 msgid "" "long\n" "sum_sequence(PyObject *sequence)\n" @@ -905,12 +1009,39 @@ msgid "" " return total;\n" "}" msgstr "" +"long\n" +"sum_sequence(PyObject *sequence)\n" +"{\n" +" Py_ssize_t i, n;\n" +" long total = 0, value;\n" +" PyObject *item;\n" +" n = PySequence_Length(sequence);\n" +" if (n < 0)\n" +" return -1; /* 沒有長度 */\n" +" for (i = 0; i < n; i++) {\n" +" item = PySequence_GetItem(sequence, i);\n" +" if (item == NULL)\n" +" return -1; /* 不是序列或其他錯誤 */\n" +" if (PyLong_Check(item)) {\n" +" value = PyLong_AsLong(item);\n" +" Py_DECREF(item);\n" +" if (value == -1 && PyErr_Occurred())\n" +" /* 整數太大,無法放入 C long,退出 */\n" +" return -1;\n" +" total += value;\n" +" }\n" +" else {\n" +" Py_DECREF(item); /* 丟棄參照所有權 */\n" +" }\n" +" }\n" +" return total;\n" +"}" -#: ../../c-api/intro.rst:561 +#: ../../c-api/intro.rst:617 msgid "Types" msgstr "型別" -#: ../../c-api/intro.rst:563 +#: ../../c-api/intro.rst:619 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:" @@ -925,7 +1056,7 @@ msgstr "" "一些結構型別被用於描述用於列出模組所匯出的函式或新物件型別的資料屬性的靜態" "表,其他則用於描述複數的值。這些將與使用它們的函式一起討論。" -#: ../../c-api/intro.rst:573 +#: ../../c-api/intro.rst:629 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 " @@ -936,11 +1067,11 @@ msgstr "" "有直接定義這樣的東西(size_t 是無符號整數型別)。有關詳細資訊,請參閱 :pep:" "`353`。 ``PY_SSIZE_T_MAX`` 是 :c:type:`Py_ssize_t` 型別的最大正值。" -#: ../../c-api/intro.rst:582 +#: ../../c-api/intro.rst:638 msgid "Exceptions" msgstr "例外" -#: ../../c-api/intro.rst:584 +#: ../../c-api/intro.rst:640 msgid "" "The Python programmer only needs to deal with exceptions if specific error " "handling is required; unhandled exceptions are automatically propagated to " @@ -952,7 +1083,7 @@ msgstr "" "給呼叫者,然後傳遞給呼叫者的呼叫者,依此類推,直到它們到達頂層直譯器,在那裡" "它們透過堆疊回溯 (stack trace) 回報給使用者。" -#: ../../c-api/intro.rst:592 +#: ../../c-api/intro.rst:648 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 " @@ -974,7 +1105,7 @@ msgstr "" "確的錯誤指示器或者有不明確的回傳值,而需要使用 :c:func:`PyErr_Occurred` 明確" "測試錯誤。這些例外都會被明確地記錄於文件。" -#: ../../c-api/intro.rst:607 +#: ../../c-api/intro.rst:663 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 " @@ -993,7 +1124,7 @@ msgstr "" "func:`PyErr_SetString` 是最常見的(儘管不是最通用的)設定例外狀態的函式,而 :" "c:func:`PyErr_Clear` 是用來清除例外狀態。" -#: ../../c-api/intro.rst:617 +#: ../../c-api/intro.rst:673 msgid "" "The full exception state consists of three objects (all of which can be " "``NULL``): the exception type, the corresponding exception value, and the " @@ -1012,7 +1143,7 @@ msgstr "" "達 Python 位元組碼直譯器的主迴圈,該迴圈負責將它傳遞給 ``sys.exc_info()`` 和" "其系列函式。" -#: ../../c-api/intro.rst:629 +#: ../../c-api/intro.rst:685 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." @@ -1030,9 +1161,9 @@ msgstr "" "外狀態。此外,兩種存取例外狀態方法的語義都發生了變化,因此捕獲例外的函式將保" "存和恢復其執行緒的例外狀態,從而保留其呼叫者的例外狀態。這可以防止例外處理程" "式碼中的常見錯誤,這些錯誤是由看似無辜的函式覆蓋了正在處理的例外而引起的;它" -"還替回溯中被堆疊幀 (stack frame) 參照的物件減少了通常不需要的生命週期延長。" +"還替回溯中被堆疊框 (stack frame) 參照的物件減少了通常不需要的生命週期延長。" -#: ../../c-api/intro.rst:640 +#: ../../c-api/intro.rst:696 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 " @@ -1047,7 +1178,7 @@ msgstr "" "並回傳一個錯誤指示符,但它\\ *不應該*\\ 設定另一個例外 --- 這將覆蓋剛剛引發的" "例外,並丟失關於錯誤確切原因的重要資訊。" -#: ../../c-api/intro.rst:649 +#: ../../c-api/intro.rst:705 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 " @@ -1059,7 +1190,7 @@ msgstr "" "巧這個例子在檢測到錯誤時不需要清理任何擁有的參照。以下範例函式展示了一些錯誤" "清理。首先,為了提醒你為什麼喜歡 Python,我們展示了等效的 Python 程式碼: ::" -#: ../../c-api/intro.rst:655 +#: ../../c-api/intro.rst:711 msgid "" "def incr_item(dict, key):\n" " try:\n" @@ -1068,12 +1199,18 @@ msgid "" " item = 0\n" " dict[key] = item + 1" msgstr "" +"def incr_item(dict, key):\n" +" try:\n" +" item = dict[key]\n" +" except KeyError:\n" +" item = 0\n" +" dict[key] = item + 1" -#: ../../c-api/intro.rst:664 +#: ../../c-api/intro.rst:720 msgid "Here is the corresponding C code, in all its glory::" msgstr "這是相應的 C 程式碼:" -#: ../../c-api/intro.rst:666 +#: ../../c-api/intro.rst:722 msgid "" "int\n" "incr_item(PyObject *dict, PyObject *key)\n" @@ -1119,7 +1256,7 @@ msgid "" "}" msgstr "" -#: ../../c-api/intro.rst:716 +#: ../../c-api/intro.rst:772 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:" @@ -1138,11 +1275,11 @@ msgstr "" "於保存擁有的參照的變數被初始化為 ``NULL`` 以使其能夠順利作用;同樣地,回傳值" "被初始化為 ``-1``\\ (失敗),並且僅在最後一次呼叫成功後才設定為成功。" -#: ../../c-api/intro.rst:730 +#: ../../c-api/intro.rst:786 msgid "Embedding Python" msgstr "嵌入式Python" -#: ../../c-api/intro.rst:732 +#: ../../c-api/intro.rst:788 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 " @@ -1152,7 +1289,7 @@ msgstr "" "只有 Python 直譯器的嵌入者(而不是擴充編寫者)需要擔心的一項重要任務是 " "Python 直譯器的初始化與完成階段。直譯器的大部分功能只能在直譯器初始化後使用。" -#: ../../c-api/intro.rst:745 +#: ../../c-api/intro.rst:801 msgid "" "The basic initialization function is :c:func:`Py_Initialize`. This " "initializes the table of loaded modules, and creates the fundamental " @@ -1163,7 +1300,7 @@ msgstr "" "立基礎模組 :mod:`builtins`、:mod:`__main__` 和 :mod:`sys`。它還會初始化模組搜" "索路徑 (``sys.path``)。" -#: ../../c-api/intro.rst:750 +#: ../../c-api/intro.rst:806 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 " @@ -1175,7 +1312,7 @@ msgstr "" "`PyConfig.argv` 和 :c:member:`PyConfig.parse_argv`,請見 :ref:`Python 初始化" "配置 `。" -#: ../../c-api/intro.rst:755 +#: ../../c-api/intro.rst:811 msgid "" "On most systems (in particular, on Unix and Windows, although the details " "are slightly different), :c:func:`Py_Initialize` calculates the module " @@ -1193,7 +1330,7 @@ msgstr "" "file:`python` 的可執行檔案,並在其父目錄中查找一個名為 :file:`lib/python{X.Y}" "` 的目錄的相對位置。" -#: ../../c-api/intro.rst:764 +#: ../../c-api/intro.rst:820 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/" @@ -1210,7 +1347,7 @@ msgstr "" "`PYTHONHOME`,或者透過設定 :envvar:`PYTHONPATH` 在標準路徑前面插入額外的目" "錄。" -#: ../../c-api/intro.rst:778 +#: ../../c-api/intro.rst:834 msgid "" "The embedding application can steer the search by setting :c:member:" "`PyConfig.program_name` *before* calling :c:func:`Py_InitializeFromConfig`. " @@ -1220,14 +1357,14 @@ msgid "" "`Py_GetPath`, :c:func:`Py_GetPrefix`, :c:func:`Py_GetExecPrefix`, and :c:" "func:`Py_GetProgramFullPath` (all defined in :file:`Modules/getpath.c`)." 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`)。" +"嵌入的應用程式可以透過在呼叫 :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`)。" -#: ../../c-api/intro.rst:789 +#: ../../c-api/intro.rst:845 msgid "" "Sometimes, it is desirable to \"uninitialize\" Python. For instance, the " "application may want to start over (make another call to :c:func:" @@ -1248,11 +1385,11 @@ msgstr "" "`Py_FinalizeEx` *不會*\\ 釋放由 Python 直譯器分配的所有記憶體,例如目前無法釋" "放被擴充模組所分配的記憶體。" -#: ../../c-api/intro.rst:803 +#: ../../c-api/intro.rst:859 msgid "Debugging Builds" msgstr "除錯建置" -#: ../../c-api/intro.rst:805 +#: ../../c-api/intro.rst:861 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 " @@ -1261,7 +1398,7 @@ msgstr "" "Python 可以在建置時使用多個巨集來啟用對直譯器和擴充模組的額外檢查,這些檢查往" "往會在執行環境 (runtime) 增加大量開銷 (overhead),因此預設情況下不啟用它們。" -#: ../../c-api/intro.rst:809 +#: ../../c-api/intro.rst:865 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 " @@ -1274,7 +1411,7 @@ msgstr "" "錯構置的完整列表,為支援追蹤參照計數、為記憶體分配器除錯或對主直譯器迴圈進行" "低階分析的建置。本節的其餘部分將僅描述最常用的建置。" -#: ../../c-api/intro.rst:817 +#: ../../c-api/intro.rst:873 msgid "" "Compiling the interpreter with the :c:macro:`!Py_DEBUG` macro defined " "produces what is generally meant by :ref:`a debug build of Python `." @@ -1298,7 +1435,7 @@ msgstr "" "除了下面描述的參照計數除錯之外,還會執行額外的檢查,請參閱 :ref:`Python 除錯" "建置 `。" -#: ../../c-api/intro.rst:828 +#: ../../c-api/intro.rst:884 msgid "" "Defining :c:macro:`Py_TRACE_REFS` enables reference tracing (see the :option:" "`configure --with-trace-refs option <--with-trace-refs>`). When defined, a " @@ -1313,7 +1450,7 @@ msgstr "" "linked list)。全體分配也有被追蹤。退出時將印出所有現行參照。(在交互模式下," "這發生在直譯器運行的每個陳述句之後。)" -#: ../../c-api/intro.rst:835 +#: ../../c-api/intro.rst:891 msgid "" "Please refer to :file:`Misc/SpecialBuilds.txt` in the Python source " "distribution for more detailed information." @@ -1321,49 +1458,51 @@ msgstr "" "有關更多詳細資訊,請參閱 Python 原始碼發布版中的 :file:`Misc/SpecialBuilds." "txt`。" -#: ../../c-api/intro.rst:842 +#: ../../c-api/intro.rst:898 msgid "Recommended third party tools" -msgstr "" +msgstr "建議的第三方工具" -#: ../../c-api/intro.rst:844 +#: ../../c-api/intro.rst:900 msgid "" "The following third party tools offer both simpler and more sophisticated " "approaches to creating C, C++ and Rust extensions for Python:" msgstr "" +"以下第三方工具提供了更簡單且更細緻的方法來為 Python 建立 C、C++ 和 Rust 擴充" +"模組:" -#: ../../c-api/intro.rst:847 +#: ../../c-api/intro.rst:903 msgid "`Cython `_" -msgstr "" +msgstr "`Cython `_" -#: ../../c-api/intro.rst:848 +#: ../../c-api/intro.rst:904 msgid "`cffi `_" -msgstr "" +msgstr "`cffi `_" -#: ../../c-api/intro.rst:849 +#: ../../c-api/intro.rst:905 msgid "`HPy `_" -msgstr "" +msgstr "`HPy `_" -#: ../../c-api/intro.rst:850 +#: ../../c-api/intro.rst:906 msgid "`nanobind `_ (C++)" -msgstr "" +msgstr "`nanobind `_ (C++)" -#: ../../c-api/intro.rst:851 +#: ../../c-api/intro.rst:907 msgid "`Numba `_" -msgstr "" +msgstr "`Numba `_" -#: ../../c-api/intro.rst:852 +#: ../../c-api/intro.rst:908 msgid "`pybind11 `_ (C++)" -msgstr "" +msgstr "`pybind11 `_ (C++)" -#: ../../c-api/intro.rst:853 +#: ../../c-api/intro.rst:909 msgid "`PyO3 `_ (Rust)" -msgstr "" +msgstr "`PyO3 `_ (Rust)" -#: ../../c-api/intro.rst:854 +#: ../../c-api/intro.rst:910 msgid "`SWIG `_" -msgstr "" +msgstr "`SWIG `_" -#: ../../c-api/intro.rst:856 +#: ../../c-api/intro.rst:912 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 " @@ -1374,7 +1513,7 @@ msgid "" "sources." msgstr "" -#: ../../c-api/intro.rst:863 +#: ../../c-api/intro.rst:919 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 " @@ -1382,142 +1521,139 @@ msgid "" "outdated." msgstr "" -#: ../../c-api/intro.rst:870 +#: ../../c-api/intro.rst:926 msgid "" "`Python Packaging User Guide: Binary Extensions `_" msgstr "" -#: ../../c-api/intro.rst:871 +#: ../../c-api/intro.rst:927 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:288 +#: ../../c-api/intro.rst:344 msgid "object" msgstr "object(物件)" -#: ../../c-api/intro.rst:288 +#: ../../c-api/intro.rst:344 msgid "type" msgstr "type(型別)" -#: ../../c-api/intro.rst:327 +#: ../../c-api/intro.rst:383 msgid "Py_INCREF (C function)" msgstr "Py_INCREF(C 函式)" -#: ../../c-api/intro.rst:327 +#: ../../c-api/intro.rst:383 msgid "Py_DECREF (C function)" msgstr "Py_DECREF(C 函式)" -#: ../../c-api/intro.rst:403 +#: ../../c-api/intro.rst:459 msgid "PyList_SetItem (C function)" msgstr "PyList_SetItem(C 函式)" -#: ../../c-api/intro.rst:403 +#: ../../c-api/intro.rst:459 msgid "PyTuple_SetItem (C function)" msgstr "PyTuple_SetItem(C 函式)" -#: ../../c-api/intro.rst:474 +#: ../../c-api/intro.rst:530 msgid "set_all()" msgstr "set_all()" -#: ../../c-api/intro.rst:493 +#: ../../c-api/intro.rst:549 msgid "PyList_GetItem (C function)" msgstr "PyList_GetItem(C 函式)" -#: ../../c-api/intro.rst:493 +#: ../../c-api/intro.rst:549 msgid "PySequence_GetItem (C function)" msgstr "PySequence_GetItem(C 函式)" -#: ../../c-api/intro.rst:523 +#: ../../c-api/intro.rst:579 msgid "sum_list()" msgstr "sum_list()" -#: ../../c-api/intro.rst:555 ../../c-api/intro.rst:647 +#: ../../c-api/intro.rst:611 ../../c-api/intro.rst:703 msgid "sum_sequence()" msgstr "sum_sequence()" -#: ../../c-api/intro.rst:590 +#: ../../c-api/intro.rst:646 msgid "PyErr_Occurred (C function)" msgstr "PyErr_Occurred(C 函式)" -#: ../../c-api/intro.rst:603 +#: ../../c-api/intro.rst:659 msgid "PyErr_SetString (C function)" msgstr "PyErr_SetString(C 函式)" -#: ../../c-api/intro.rst:603 ../../c-api/intro.rst:711 +#: ../../c-api/intro.rst:659 ../../c-api/intro.rst:767 msgid "PyErr_Clear (C function)" msgstr "PyErr_Clear(C 函式)" -#: ../../c-api/intro.rst:627 +#: ../../c-api/intro.rst:683 msgid "exc_info (in module sys)" msgstr "exc_info (sys 模組中)" -#: ../../c-api/intro.rst:662 ../../c-api/intro.rst:709 +#: ../../c-api/intro.rst:718 ../../c-api/intro.rst:765 msgid "incr_item()" msgstr "incr_item()" -#: ../../c-api/intro.rst:711 +#: ../../c-api/intro.rst:767 msgid "PyErr_ExceptionMatches (C function)" msgstr "PyErr_ExceptionMatches(C 函式)" -#: ../../c-api/intro.rst:711 +#: ../../c-api/intro.rst:767 msgid "Py_XDECREF (C function)" msgstr "Py_XDECREF(C 函式)" -#: ../../c-api/intro.rst:737 +#: ../../c-api/intro.rst:793 msgid "Py_Initialize (C function)" msgstr "Py_Initialize(C 函式)" -#: ../../c-api/intro.rst:737 +#: ../../c-api/intro.rst:793 msgid "module" msgstr "module(模組)" -#: ../../c-api/intro.rst:737 +#: ../../c-api/intro.rst:793 msgid "builtins" msgstr "builtins(內建)" -#: ../../c-api/intro.rst:737 +#: ../../c-api/intro.rst:793 msgid "__main__" msgstr "__main__" -#: ../../c-api/intro.rst:737 +#: ../../c-api/intro.rst:793 msgid "sys" msgstr "sys" -#: ../../c-api/intro.rst:737 +#: ../../c-api/intro.rst:793 msgid "search" msgstr "search(搜尋)" -#: ../../c-api/intro.rst:737 +#: ../../c-api/intro.rst:793 msgid "path" msgstr "path(路徑)" -#: ../../c-api/intro.rst:737 +#: ../../c-api/intro.rst:793 msgid "path (in module sys)" msgstr "path(sys 模組中)" -#: ../../c-api/intro.rst:772 +#: ../../c-api/intro.rst:828 msgid "Py_GetPath (C function)" msgstr "Py_GetPath(C 函式)" -#: ../../c-api/intro.rst:772 +#: ../../c-api/intro.rst:828 msgid "Py_GetPrefix (C function)" msgstr "Py_GetPrefix(C 函式)" -#: ../../c-api/intro.rst:772 +#: ../../c-api/intro.rst:828 msgid "Py_GetExecPrefix (C function)" msgstr "Py_GetExecPrefix(C 函式)" -#: ../../c-api/intro.rst:772 +#: ../../c-api/intro.rst:828 msgid "Py_GetProgramFullPath (C function)" msgstr "Py_GetProgramFullPath(C 函式)" -#: ../../c-api/intro.rst:787 +#: ../../c-api/intro.rst:843 msgid "Py_IsInitialized (C function)" msgstr "Py_IsInitialized(C 函式)" - -#~ msgid "Py_SetProgramName (C function)" -#~ msgstr "Py_SetProgramName(C 函式)" diff --git a/c-api/iter.po b/c-api/iter.po index 71d9e97f69d..37c2a713c78 100644 --- a/c-api/iter.po +++ b/c-api/iter.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -6,9 +6,9 @@ # Matt Wang , 2023 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"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: 2025-09-08 15:25+0800\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-" @@ -30,13 +30,14 @@ msgstr "有兩個專門用於疊代器的函式。" #: ../../c-api/iter.rst:12 msgid "" -"Return non-zero if the object *o* can be safely passed to :c:func:" -"`PyIter_Next`, and ``0`` otherwise. This function always succeeds." +"Return non-zero if the object *o* can be safely passed " +"to :c:func:`PyIter_NextItem` and ``0`` otherwise. This function always " +"succeeds." msgstr "" -"如果物件 *o* 可以安全地傳遞給 :c:func:`PyIter_Next` 則回傳非零 (non-zero),否" +"如果物件 *o* 可以安全地傳遞給 :c:func:`PyIter_NextItem` 則回傳非零 (non-zero),否" "則回傳 0。這個函式一定會執行成功。" -#: ../../c-api/iter.rst:17 +#: ../../c-api/iter.rst:18 msgid "" "Return non-zero if the object *o* provides the :class:`AsyncIterator` " "protocol, and ``0`` otherwise. This function always succeeds." @@ -44,7 +45,22 @@ msgstr "" "如果物件 *o* 有提供 :class:`AsyncIterator` 協定,則回傳非零,否則回傳 0。這個" "函式一定會執行成功。" -#: ../../c-api/iter.rst:24 +#: ../../c-api/iter.rst:25 +msgid "" +"Return ``1`` and set *item* to a :term:`strong reference` of the next value " +"of the iterator *iter* on success. Return ``0`` and set *item* to ``NULL`` " +"if there are no remaining values. Return ``-1``, set *item* to ``NULL`` and " +"set an exception on error." +msgstr "" + +#: ../../c-api/iter.rst:34 +msgid "" +"This is an older version of :c:func:`!PyIter_NextItem`, which is retained " +"for backwards compatibility. Prefer :c:func:`PyIter_NextItem`." +msgstr "" +"這是 :c:func:`!PyIter_NextItem` 的舊版本,為了向後相容而保留。請優先使用 :c:func:`PyIter_NextItem`。" + +#: ../../c-api/iter.rst:38 msgid "" "Return the next value from the iterator *o*. The object must be an iterator " "according to :c:func:`PyIter_Check` (it is up to the caller to check this). " @@ -56,81 +72,27 @@ msgstr "" "器(由呼叫者檢查)。如果沒有剩餘值,則回傳 ``NULL`` 且不設定例外。如果檢索項" "目時發生錯誤,則回傳 ``NULL`` 並傳遞例外。" -#: ../../c-api/iter.rst:30 -msgid "" -"To write a loop which iterates over an iterator, the C code should look " -"something like this::" -msgstr "要編寫一個疊代於疊代器的迴圈,C 程式碼應該會像這樣:" - -#: ../../c-api/iter.rst:33 -msgid "" -"PyObject *iterator = PyObject_GetIter(obj);\n" -"PyObject *item;\n" -"\n" -"if (iterator == NULL) {\n" -" /* propagate error */\n" -"}\n" -"\n" -"while ((item = PyIter_Next(iterator))) {\n" -" /* do something with item */\n" -" ...\n" -" /* release reference when done */\n" -" Py_DECREF(item);\n" -"}\n" -"\n" -"Py_DECREF(iterator);\n" -"\n" -"if (PyErr_Occurred()) {\n" -" /* propagate error */\n" -"}\n" -"else {\n" -" /* continue doing useful work */\n" -"}" -msgstr "" -"PyObject *iterator = PyObject_GetIter(obj);\n" -"PyObject *item;\n" -"\n" -"if (iterator == NULL) {\n" -" /* 傳播錯誤 */\n" -"}\n" -"\n" -"while ((item = PyIter_Next(iterator))) {\n" -" /* 對 item 做些事情 */\n" -" ...\n" -" /* 完成後釋放參照 */\n" -" Py_DECREF(item);\n" -"}\n" -"\n" -"Py_DECREF(iterator);\n" -"\n" -"if (PyErr_Occurred()) {\n" -" /* 傳播錯誤 */\n" -"}\n" -"else {\n" -" /* 繼續做一些有用的任務 */\n" -"}" - -#: ../../c-api/iter.rst:59 +#: ../../c-api/iter.rst:46 msgid "" "The enum value used to represent different results of :c:func:`PyIter_Send`." msgstr "用於表示 :c:func:`PyIter_Send` 不同結果的列舉 (enum) 值。" -#: ../../c-api/iter.rst:66 +#: ../../c-api/iter.rst:53 msgid "Sends the *arg* value into the iterator *iter*. Returns:" msgstr "將 *arg* 值發送到疊代器 *iter* 中。回傳:" -#: ../../c-api/iter.rst:68 +#: ../../c-api/iter.rst:55 msgid "" "``PYGEN_RETURN`` if iterator returns. Return value is returned via *presult*." msgstr "如果疊代器有回傳則為 ``PYGEN_RETURN``。回傳值透過 *presult* 回傳。" -#: ../../c-api/iter.rst:69 +#: ../../c-api/iter.rst:56 msgid "" "``PYGEN_NEXT`` if iterator yields. Yielded value is returned via *presult*." msgstr "" "如果疊代器有產生 (yield) 則為 ``PYGEN_NEXT``。產生值透過 *presult* 回傳。" -#: ../../c-api/iter.rst:70 +#: ../../c-api/iter.rst:57 msgid "" "``PYGEN_ERROR`` if iterator has raised and exception. *presult* is set to " "``NULL``." diff --git a/c-api/iterator.po b/c-api/iterator.po index 3675b02e9a7..6ada4984c03 100644 --- a/c-api/iterator.po +++ b/c-api/iterator.po @@ -1,14 +1,13 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Leon H., 2017 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-07-24 00:03+0000\n" +"POT-Creation-Date: 2025-11-18 00:15+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-" @@ -77,3 +76,77 @@ msgid "" "should return the next item in the iteration. When *callable* returns a " "value equal to *sentinel*, the iteration will be terminated." msgstr "" + +#: ../../c-api/iterator.rst:56 +msgid "Range Objects" +msgstr "Range 物件" + +#: ../../c-api/iterator.rst:60 +msgid "The type object for :class:`range` objects." +msgstr ":class:`range` 物件的型別物件。" + +#: ../../c-api/iterator.rst:65 +msgid "" +"Return true if the object *o* is an instance of a :class:`range` object. " +"This function always succeeds." +msgstr "" + +#: ../../c-api/iterator.rst:70 +msgid "Builtin Iterator Types" +msgstr "內建疊代器型別" + +#: ../../c-api/iterator.rst:72 +msgid "" +"These are built-in iteration types that are included in Python's C API, but " +"provide no additional functions. They are here for completeness." +msgstr "" + +#: ../../c-api/iterator.rst:80 +msgid "C type" +msgstr "C 型別" + +#: ../../c-api/iterator.rst:81 +msgid "Python type" +msgstr "Python 型別" + +#: ../../c-api/iterator.rst:83 +msgid ":py:class:`enumerate`" +msgstr ":py:class:`enumerate`" + +#: ../../c-api/iterator.rst:85 +msgid ":py:class:`filter`" +msgstr ":py:class:`filter`" + +#: ../../c-api/iterator.rst:87 +msgid ":py:class:`map`" +msgstr ":py:class:`map`" + +#: ../../c-api/iterator.rst:89 +msgid ":py:class:`reversed`" +msgstr ":py:class:`reversed`" + +#: ../../c-api/iterator.rst:91 +msgid ":py:class:`zip`" +msgstr ":py:class:`zip`" + +#: ../../c-api/iterator.rst:95 +msgid "Other Iterator Objects" +msgstr "其他疊代器物件" + +#: ../../c-api/iterator.rst:113 +msgid "Type objects for iterators of various built-in objects." +msgstr "各種內建物件的疊代器型別物件。" + +#: ../../c-api/iterator.rst:115 +msgid "" +"Do not create instances of these directly; prefer calling :c:func:" +"`PyObject_GetIter` instead." +msgstr "" + +#: ../../c-api/iterator.rst:118 +msgid "" +"Note that there is no guarantee that a given built-in type uses a given " +"iterator type. For example, iterating over :class:`range` will use one of " +"two iterator types depending on the size of the range. Other types may start " +"using a similar scheme in the future, without warning." +msgstr "" diff --git a/c-api/lifecycle.po b/c-api/lifecycle.po new file mode 100644 index 00000000000..1a3bb772c47 --- /dev/null +++ b/c-api/lifecycle.po @@ -0,0 +1,364 @@ +# 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.14\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-09-08 15:25+0800\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/lifecycle.rst:6 +msgid "Object Life Cycle" +msgstr "物件生命週期" + +#: ../../c-api/lifecycle.rst:8 +msgid "" +"This section explains how a type's slots relate to each other throughout the " +"life of an object. It is not intended to be a complete canonical reference " +"for the slots; instead, refer to the slot-specific documentation " +"in :ref:`type-structs` for details about a particular slot." +msgstr "" + +#: ../../c-api/lifecycle.rst:15 +msgid "Life Events" +msgstr "生命事件" + +#: ../../c-api/lifecycle.rst:17 +msgid "" +"The figure below illustrates the order of events that can occur throughout " +"an object's life. An arrow from *A* to *B* indicates that event *B* can " +"occur after event *A* has occurred, with the arrow's label indicating the " +"condition that must be true for *B* to occur after *A*." +msgstr "" + +#: ../../c-api/lifecycle.rst:55 ../../c-api/lifecycle.rst:62 +msgid "Diagram showing events in an object's life. Explained in detail below." +msgstr "" + +#: ../../c-api/lifecycle.rst:70 +msgid "Explanation:" +msgstr "說明:" + +#: ../../c-api/lifecycle.rst:72 +msgid "When a new object is constructed by calling its type:" +msgstr "當一個新物件透過其型別來建構時:" + +#: ../../c-api/lifecycle.rst:74 +msgid ":c:member:`~PyTypeObject.tp_new` is called to create a new object." +msgstr ":c:member:`~PyTypeObject.tp_new` 會被呼叫來建立一個新物件。" + +#: ../../c-api/lifecycle.rst:75 +msgid "" +":c:member:`~PyTypeObject.tp_alloc` is directly called " +"by :c:member:`~PyTypeObject.tp_new` to allocate the memory for the new " +"object." +msgstr "" + +#: ../../c-api/lifecycle.rst:78 +msgid "" +":c:member:`~PyTypeObject.tp_init` initializes the newly created " +"object. :c:member:`!tp_init` can be called again to re-initialize an object, " +"if desired. The :c:member:`!tp_init` call can also be skipped entirely, for " +"example by Python code calling :py:meth:`~object.__new__`." +msgstr "" + +#: ../../c-api/lifecycle.rst:83 +msgid "After :c:member:`!tp_init` completes, the object is ready to use." +msgstr "在 :c:member:`!tp_init` 完成後,該物件即可使用。" + +#: ../../c-api/lifecycle.rst:84 +msgid "Some time after the last reference to an object is removed:" +msgstr "在最後一個對物件的參照被移除一段時間後:" + +#: ../../c-api/lifecycle.rst:86 +msgid "" +"If an object is not marked as *finalized*, it might be finalized by marking " +"it as *finalized* and calling its :c:member:`~PyTypeObject.tp_finalize` " +"function. Python does *not* finalize an object when the last reference to " +"it is deleted; use :c:func:`PyObject_CallFinalizerFromDealloc` to ensure " +"that :c:member:`~PyTypeObject.tp_finalize` is always called." +msgstr "" + +#: ../../c-api/lifecycle.rst:92 +msgid "" +"If the object is marked as finalized, :c:member:`~PyTypeObject.tp_clear` " +"might be called by the garbage collector to clear references held by the " +"object. It is *not* called when the object's reference count reaches zero." +msgstr "" + +#: ../../c-api/lifecycle.rst:96 +msgid "" +":c:member:`~PyTypeObject.tp_dealloc` is called to destroy the object. To " +"avoid code duplication, :c:member:`~PyTypeObject.tp_dealloc` typically calls " +"into :c:member:`~PyTypeObject.tp_clear` to free up the object's references." +msgstr "" + +#: ../../c-api/lifecycle.rst:100 +msgid "" +"When :c:member:`~PyTypeObject.tp_dealloc` finishes object destruction, it " +"directly calls :c:member:`~PyTypeObject.tp_free` (usually set " +"to :c:func:`PyObject_Free` or :c:func:`PyObject_GC_Del` automatically as " +"appropriate for the type) to deallocate the memory." +msgstr "" + +#: ../../c-api/lifecycle.rst:105 +msgid "" +"The :c:member:`~PyTypeObject.tp_finalize` function is permitted to add a " +"reference to the object if desired. If it does, the object is " +"*resurrected*, preventing its pending destruction. (Only :c:member:`!" +"tp_finalize` is allowed to resurrect an " +"object; :c:member:`~PyTypeObject.tp_clear` " +"and :c:member:`~PyTypeObject.tp_dealloc` cannot without calling " +"into :c:member:`!tp_finalize`.) Resurrecting an object may or may not cause " +"the object's *finalized* mark to be removed. Currently, Python does not " +"remove the *finalized* mark from a resurrected object if it supports garbage " +"collection (i.e., the :c:macro:`Py_TPFLAGS_HAVE_GC` flag is set) but does " +"remove the mark if the object does not support garbage collection; either or " +"both of these behaviors may change in the future." +msgstr "" + +#: ../../c-api/lifecycle.rst:118 +msgid "" +":c:member:`~PyTypeObject.tp_dealloc` can optionally " +"call :c:member:`~PyTypeObject.tp_finalize` " +"via :c:func:`PyObject_CallFinalizerFromDealloc` if it wishes to reuse that " +"code to help with object destruction. This is recommended because it " +"guarantees that :c:member:`!tp_finalize` is always called before " +"destruction. See the :c:member:`~PyTypeObject.tp_dealloc` documentation for " +"example code." +msgstr "" + +#: ../../c-api/lifecycle.rst:125 +msgid "" +"If the object is a member of a :term:`cyclic isolate` and " +"either :c:member:`~PyTypeObject.tp_clear` fails to break the reference cycle " +"or the cyclic isolate is not detected (perhaps :func:`gc.disable` was " +"called, or the :c:macro:`Py_TPFLAGS_HAVE_GC` flag was erroneously omitted in " +"one of the involved types), the objects remain indefinitely uncollectable " +"(they \"leak\"). See :data:`gc.garbage`." +msgstr "" + +#: ../../c-api/lifecycle.rst:132 +msgid "" +"If the object is marked as supporting garbage collection " +"(the :c:macro:`Py_TPFLAGS_HAVE_GC` flag is set " +"in :c:member:`~PyTypeObject.tp_flags`), the following events are also " +"possible:" +msgstr "" + +#: ../../c-api/lifecycle.rst:136 +msgid "" +"The garbage collector occasionally " +"calls :c:member:`~PyTypeObject.tp_traverse` to identify :term:`cyclic " +"isolates `." +msgstr "" + +#: ../../c-api/lifecycle.rst:139 +msgid "" +"When the garbage collector discovers a :term:`cyclic isolate`, it finalizes " +"one of the objects in the group by marking it as *finalized* and calling " +"its :c:member:`~PyTypeObject.tp_finalize` function, if it has one. This " +"repeats until the cyclic isolate doesn't exist or all of the objects have " +"been finalized." +msgstr "" + +#: ../../c-api/lifecycle.rst:144 +msgid "" +":c:member:`~PyTypeObject.tp_finalize` is permitted to resurrect the object " +"by adding a reference from outside the :term:`cyclic isolate`. The new " +"reference causes the group of objects to no longer form a cyclic isolate " +"(the reference cycle may still exist, but if it does the objects are no " +"longer isolated)." +msgstr "" + +#: ../../c-api/lifecycle.rst:149 +msgid "" +"When the garbage collector discovers a :term:`cyclic isolate` and all of the " +"objects in the group have already been marked as *finalized*, the garbage " +"collector clears one or more of the uncleared objects in the group (possibly " +"concurrently) by calling each's :c:member:`~PyTypeObject.tp_clear` " +"function. This repeats as long as the cyclic isolate still exists and not " +"all of the objects have been cleared." +msgstr "" + +#: ../../c-api/lifecycle.rst:158 +msgid "Cyclic Isolate Destruction" +msgstr "" + +#: ../../c-api/lifecycle.rst:160 +msgid "" +"Listed below are the stages of life of a hypothetical :term:`cyclic isolate` " +"that continues to exist after each member object is finalized or cleared. " +"It is a memory leak if a cyclic isolate progresses through all of these " +"stages; it should vanish once all objects are cleared, if not sooner. A " +"cyclic isolate can vanish either because the reference cycle is broken or " +"because the objects are no longer isolated due to finalizer resurrection " +"(see :c:member:`~PyTypeObject.tp_finalize`)." +msgstr "" + +#: ../../c-api/lifecycle.rst:168 +msgid "" +"**Reachable** (not yet a cyclic isolate): All objects are in their normal, " +"reachable state. A reference cycle could exist, but an external reference " +"means the objects are not yet isolated." +msgstr "" + +#: ../../c-api/lifecycle.rst:171 +msgid "" +"**Unreachable but consistent:** The final reference from outside the cyclic " +"group of objects has been removed, causing the objects to become isolated " +"(thus a cyclic isolate is born). None of the group's objects have been " +"finalized or cleared yet. The cyclic isolate remains at this stage until " +"some future run of the garbage collector (not necessarily the next run " +"because the next run might not scan every object)." +msgstr "" + +#: ../../c-api/lifecycle.rst:177 +msgid "" +"**Mix of finalized and not finalized:** Objects in a cyclic isolate are " +"finalized one at a time, which means that there is a period of time when the " +"cyclic isolate is composed of a mix of finalized and non-finalized objects. " +"Finalization order is unspecified, so it can appear random. A finalized " +"object must behave in a sane manner when non-finalized objects interact with " +"it, and a non-finalized object must be able to tolerate the finalization of " +"an arbitrary subset of its referents." +msgstr "" + +#: ../../c-api/lifecycle.rst:184 +msgid "" +"**All finalized:** All objects in a cyclic isolate are finalized before any " +"of them are cleared." +msgstr "" + +#: ../../c-api/lifecycle.rst:186 +msgid "" +"**Mix of finalized and cleared:** The objects can be cleared serially or " +"concurrently (but with the :term:`GIL` held); either way, some will finish " +"before others. A finalized object must be able to tolerate the clearing of " +"a subset of its referents. :pep:`442` calls this stage \"cyclic trash\"." +msgstr "" + +#: ../../c-api/lifecycle.rst:190 +msgid "" +"**Leaked:** If a cyclic isolate still exists after all objects in the group " +"have been finalized and cleared, then the objects remain indefinitely " +"uncollectable (see :data:`gc.garbage`). It is a bug if a cyclic isolate " +"reaches this stage---it means the :c:member:`~PyTypeObject.tp_clear` methods " +"of the participating objects have failed to break the reference cycle as " +"required." +msgstr "" + +#: ../../c-api/lifecycle.rst:197 +msgid "" +"If :c:member:`~PyTypeObject.tp_clear` did not exist, then Python would have " +"no way to safely break a reference cycle. Simply destroying an object in a " +"cyclic isolate would result in a dangling pointer, triggering undefined " +"behavior when an object referencing the destroyed object is itself " +"destroyed. The clearing step makes object destruction a two-phase process: " +"first :c:member:`~PyTypeObject.tp_clear` is called to partially destroy the " +"objects enough to detangle them from each other, " +"then :c:member:`~PyTypeObject.tp_dealloc` is called to complete the " +"destruction." +msgstr "" + +#: ../../c-api/lifecycle.rst:206 +msgid "" +"Unlike clearing, finalization is not a phase of destruction. A finalized " +"object must still behave properly by continuing to fulfill its design " +"contracts. An object's finalizer is allowed to execute arbitrary Python " +"code, and is even allowed to prevent the impending destruction by adding a " +"reference. The finalizer is only related to destruction by call order---if " +"it runs, it runs before destruction, which starts " +"with :c:member:`~PyTypeObject.tp_clear` (if called) and concludes " +"with :c:member:`~PyTypeObject.tp_dealloc`." +msgstr "" + +#: ../../c-api/lifecycle.rst:214 +msgid "" +"The finalization step is not necessary to safely reclaim the objects in a " +"cyclic isolate, but its existence makes it easier to design types that " +"behave in a sane manner when objects are cleared. Clearing an object might " +"necessarily leave it in a broken, partially destroyed state---it might be " +"unsafe to call any of the cleared object's methods or access any of its " +"attributes. With finalization, only finalized objects can possibly interact " +"with cleared objects; non-finalized objects are guaranteed to interact with " +"only non-cleared (but potentially finalized) objects." +msgstr "" + +#: ../../c-api/lifecycle.rst:223 +msgid "To summarize the possible interactions:" +msgstr "" + +#: ../../c-api/lifecycle.rst:225 +msgid "" +"A non-finalized object might have references to or from non-finalized and " +"finalized objects, but not to or from cleared objects." +msgstr "" + +#: ../../c-api/lifecycle.rst:227 +msgid "" +"A finalized object might have references to or from non-finalized, " +"finalized, and cleared objects." +msgstr "" + +#: ../../c-api/lifecycle.rst:229 +msgid "" +"A cleared object might have references to or from finalized and cleared " +"objects, but not to or from non-finalized objects." +msgstr "" + +#: ../../c-api/lifecycle.rst:232 +msgid "" +"Without any reference cycles, an object can be simply destroyed once its " +"last reference is deleted; the finalization and clearing steps are not " +"necessary to safely reclaim unused objects. However, it can be useful to " +"automatically call :c:member:`~PyTypeObject.tp_finalize` " +"and :c:member:`~PyTypeObject.tp_clear` before destruction anyway because " +"type design is simplified when all objects always experience the same series " +"of events regardless of whether they participated in a cyclic isolate. " +"Python currently only calls :c:member:`~PyTypeObject.tp_finalize` " +"and :c:member:`~PyTypeObject.tp_clear` as needed to destroy a cyclic " +"isolate; this may change in a future version." +msgstr "" + +#: ../../c-api/lifecycle.rst:244 +msgid "Functions" +msgstr "函式" + +#: ../../c-api/lifecycle.rst:246 +msgid "To allocate and free memory, see :ref:`allocating-objects`." +msgstr "要分配和釋放記憶體,請參見 :ref:`allocating-objects`。" + +#: ../../c-api/lifecycle.rst:251 +msgid "" +"Finalizes the object as described in :c:member:`~PyTypeObject.tp_finalize`. " +"Call this function (or :c:func:`PyObject_CallFinalizerFromDealloc`) instead " +"of calling :c:member:`~PyTypeObject.tp_finalize` directly because this " +"function may deduplicate multiple calls to :c:member:`!tp_finalize`. " +"Currently, calls are only deduplicated if the type supports garbage " +"collection (i.e., the :c:macro:`Py_TPFLAGS_HAVE_GC` flag is set); this may " +"change in the future." +msgstr "" + +#: ../../c-api/lifecycle.rst:262 +msgid "" +"Same as :c:func:`PyObject_CallFinalizer` but meant to be called at the " +"beginning of the object's destructor (:c:member:`~PyTypeObject.tp_dealloc`). " +"There must not be any references to the object. If the object's finalizer " +"resurrects the object, this function returns -1; no further destruction " +"should happen. Otherwise, this function returns 0 and destruction can " +"continue normally." +msgstr "" + +#: ../../c-api/lifecycle.rst:271 +msgid ":c:member:`~PyTypeObject.tp_dealloc` for example code." +msgstr "" diff --git a/c-api/list.po b/c-api/list.po index 5b7fb4a6e10..71c0d61e56a 100644 --- a/c-api/list.po +++ b/c-api/list.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2023, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -6,7 +6,7 @@ # Matt Wang , 2023 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-23 07:52+0800\n" "PO-Revision-Date: 2023-08-24 00:55+0800\n" diff --git a/c-api/long.po b/c-api/long.po index a32b953e3ec..ccf87256ab5 100644 --- a/c-api/long.po +++ b/c-api/long.po @@ -1,13 +1,13 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Leon H., 2017 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"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: 2025-11-07 00:14+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-" @@ -61,50 +61,63 @@ msgid "" "Return a new :c:type:`PyLongObject` object from *v*, or ``NULL`` on failure." msgstr "" -#: ../../c-api/long.rst:43 +#: ../../c-api/long.rst:45 msgid "" -"The current implementation 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 back a reference to the existing object." +"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 " +"back a reference to the existing object." msgstr "" -#: ../../c-api/long.rst:50 +#: ../../c-api/long.rst:52 msgid "" "Return a new :c:type:`PyLongObject` object from a C :c:expr:`unsigned long`, " "or ``NULL`` on failure." msgstr "" -#: ../../c-api/long.rst:56 +#: ../../c-api/long.rst:58 msgid "" "Return a new :c:type:`PyLongObject` object from a C :c:type:`Py_ssize_t`, or " "``NULL`` on failure." msgstr "" -#: ../../c-api/long.rst:62 +#: ../../c-api/long.rst:64 msgid "" "Return a new :c:type:`PyLongObject` object from a C :c:type:`size_t`, or " "``NULL`` on failure." msgstr "" -#: ../../c-api/long.rst:68 +#: ../../c-api/long.rst:70 msgid "" "Return a new :c:type:`PyLongObject` object from a C :c:expr:`long long`, or " "``NULL`` on failure." msgstr "" -#: ../../c-api/long.rst:74 +#: ../../c-api/long.rst:77 +msgid "" +"Return a new :c:type:`PyLongObject` object from a signed C :c:expr:`int32_t` " +"or :c:expr:`int64_t`, or ``NULL`` with an exception set on failure." +msgstr "" + +#: ../../c-api/long.rst:86 msgid "" "Return a new :c:type:`PyLongObject` object from a C :c:expr:`unsigned long " "long`, or ``NULL`` on failure." msgstr "" -#: ../../c-api/long.rst:80 +#: ../../c-api/long.rst:93 +msgid "" +"Return a new :c:type:`PyLongObject` object from an unsigned C :c:expr:" +"`uint32_t` or :c:expr:`uint64_t`, or ``NULL`` with an exception set on " +"failure." +msgstr "" + +#: ../../c-api/long.rst:102 msgid "" "Return a new :c:type:`PyLongObject` object from the integer part of *v*, or " "``NULL`` on failure." msgstr "" -#: ../../c-api/long.rst:86 +#: ../../c-api/long.rst:108 msgid "" "Return a new :c:type:`PyLongObject` based on the string value in *str*, " "which is interpreted according to the radix in *base*, or ``NULL`` on " @@ -119,32 +132,32 @@ msgid "" "whitespace, :exc:`ValueError` will be raised." msgstr "" -#: ../../c-api/long.rst:97 +#: ../../c-api/long.rst:119 msgid "" -"Python methods :meth:`int.to_bytes` and :meth:`int.from_bytes` to convert a :" -"c:type:`PyLongObject` to/from an array of bytes in base ``256``. You can " -"call those from C using :c:func:`PyObject_CallMethod`." +":c:func:`PyLong_AsNativeBytes()` and :c:func:`PyLong_FromNativeBytes()` " +"functions can be used to convert a :c:type:`PyLongObject` to/from an array " +"of bytes in base ``256``." msgstr "" -#: ../../c-api/long.rst:104 +#: ../../c-api/long.rst:126 msgid "" "Convert a sequence of Unicode digits in the string *u* to a Python integer " "value." msgstr "" -#: ../../c-api/long.rst:112 +#: ../../c-api/long.rst:134 msgid "" "Create a Python integer from the pointer *p*. The pointer value can be " "retrieved from the resulting value using :c:func:`PyLong_AsVoidPtr`." msgstr "" -#: ../../c-api/long.rst:118 +#: ../../c-api/long.rst:140 msgid "" "Create a Python integer from the value contained in the first *n_bytes* of " "*buffer*, interpreted as a two's-complement signed number." msgstr "" -#: ../../c-api/long.rst:121 +#: ../../c-api/long.rst:143 msgid "" "*flags* are as for :c:func:`PyLong_AsNativeBytes`. Passing ``-1`` will " "select the native endian that CPython was compiled with and assume that the " @@ -153,65 +166,75 @@ msgid "" "calling :c:func:`PyLong_FromUnsignedNativeBytes`. Other flags are ignored." msgstr "" -#: ../../c-api/long.rst:132 +#: ../../c-api/long.rst:154 msgid "" "Create a Python integer from the value contained in the first *n_bytes* of " "*buffer*, interpreted as an unsigned number." msgstr "" -#: ../../c-api/long.rst:135 +#: ../../c-api/long.rst:157 msgid "" "*flags* are as for :c:func:`PyLong_AsNativeBytes`. Passing ``-1`` will " "select the native endian that CPython was compiled with and assume that the " "most-significant bit is not a sign bit. Flags other than endian are ignored." msgstr "" -#: ../../c-api/long.rst:148 ../../c-api/long.rst:184 +#: ../../c-api/long.rst:166 +msgid "Macro for creating a Python integer from a process identifier." +msgstr "" + +#: ../../c-api/long.rst:168 +msgid "" +"This can be defined as an alias to :c:func:`PyLong_FromLong` or :c:func:" +"`PyLong_FromLongLong`, depending on the size of the system's PID type." +msgstr "" + +#: ../../c-api/long.rst:181 ../../c-api/long.rst:217 msgid "" "Return a C :c:expr:`long` representation of *obj*. If *obj* is not an " "instance of :c:type:`PyLongObject`, first call its :meth:`~object.__index__` " "method (if present) to convert it to a :c:type:`PyLongObject`." msgstr "" -#: ../../c-api/long.rst:152 +#: ../../c-api/long.rst:185 msgid "" "Raise :exc:`OverflowError` if the value of *obj* is out of range for a :c:" "expr:`long`." msgstr "" -#: ../../c-api/long.rst:155 ../../c-api/long.rst:193 ../../c-api/long.rst:214 -#: ../../c-api/long.rst:234 ../../c-api/long.rst:257 +#: ../../c-api/long.rst:188 ../../c-api/long.rst:226 ../../c-api/long.rst:247 +#: ../../c-api/long.rst:267 ../../c-api/long.rst:290 msgid "Returns ``-1`` on error. Use :c:func:`PyErr_Occurred` to disambiguate." msgstr "" -#: ../../c-api/long.rst:157 ../../c-api/long.rst:195 ../../c-api/long.rst:216 -#: ../../c-api/long.rst:238 ../../c-api/long.rst:322 ../../c-api/long.rst:342 +#: ../../c-api/long.rst:190 ../../c-api/long.rst:228 ../../c-api/long.rst:249 +#: ../../c-api/long.rst:271 ../../c-api/long.rst:355 ../../c-api/long.rst:375 msgid "Use :meth:`~object.__index__` if available." msgstr "" -#: ../../c-api/long.rst:160 ../../c-api/long.rst:198 ../../c-api/long.rst:219 -#: ../../c-api/long.rst:241 ../../c-api/long.rst:325 ../../c-api/long.rst:345 +#: ../../c-api/long.rst:193 ../../c-api/long.rst:231 ../../c-api/long.rst:252 +#: ../../c-api/long.rst:274 ../../c-api/long.rst:358 ../../c-api/long.rst:378 msgid "This function will no longer use :meth:`~object.__int__`." msgstr "" -#: ../../c-api/long.rst:167 +#: ../../c-api/long.rst:200 msgid "" "A :term:`soft deprecated` alias. Exactly equivalent to the preferred " "``PyLong_AsLong``. In particular, it can fail with :exc:`OverflowError` or " "another exception." msgstr "" -#: ../../c-api/long.rst:171 +#: ../../c-api/long.rst:204 msgid "The function is soft deprecated." msgstr "" -#: ../../c-api/long.rst:176 +#: ../../c-api/long.rst:209 msgid "" "Similar to :c:func:`PyLong_AsLong`, but store the result in a C :c:expr:" "`int` instead of a C :c:expr:`long`." msgstr "" -#: ../../c-api/long.rst:188 +#: ../../c-api/long.rst:221 msgid "" "If the value of *obj* is greater than :c:macro:`LONG_MAX` or less than :c:" "macro:`LONG_MIN`, set *\\*overflow* to ``1`` or ``-1``, respectively, and " @@ -219,20 +242,20 @@ msgid "" "exception occurs set *\\*overflow* to ``0`` and return ``-1`` as usual." msgstr "" -#: ../../c-api/long.rst:207 ../../c-api/long.rst:225 +#: ../../c-api/long.rst:240 ../../c-api/long.rst:258 msgid "" "Return a C :c:expr:`long long` representation of *obj*. If *obj* is not an " "instance of :c:type:`PyLongObject`, first call its :meth:`~object.__index__` " "method (if present) to convert it to a :c:type:`PyLongObject`." msgstr "" -#: ../../c-api/long.rst:211 +#: ../../c-api/long.rst:244 msgid "" "Raise :exc:`OverflowError` if the value of *obj* is out of range for a :c:" "expr:`long long`." msgstr "" -#: ../../c-api/long.rst:229 +#: ../../c-api/long.rst:262 msgid "" "If the value of *obj* is greater than :c:macro:`LLONG_MAX` or less than :c:" "macro:`LLONG_MIN`, set *\\*overflow* to ``1`` or ``-1``, respectively, and " @@ -240,133 +263,170 @@ msgid "" "exception occurs set *\\*overflow* to ``0`` and return ``-1`` as usual." msgstr "" -#: ../../c-api/long.rst:251 +#: ../../c-api/long.rst:284 msgid "" "Return a C :c:type:`Py_ssize_t` representation of *pylong*. *pylong* must " "be an instance of :c:type:`PyLongObject`." msgstr "" -#: ../../c-api/long.rst:254 +#: ../../c-api/long.rst:287 msgid "" "Raise :exc:`OverflowError` if the value of *pylong* is out of range for a :c:" "type:`Py_ssize_t`." msgstr "" -#: ../../c-api/long.rst:266 +#: ../../c-api/long.rst:299 msgid "" "Return a C :c:expr:`unsigned long` representation of *pylong*. *pylong* " "must be an instance of :c:type:`PyLongObject`." msgstr "" -#: ../../c-api/long.rst:269 +#: ../../c-api/long.rst:302 msgid "" "Raise :exc:`OverflowError` if the value of *pylong* is out of range for a :c:" "expr:`unsigned long`." msgstr "" -#: ../../c-api/long.rst:272 +#: ../../c-api/long.rst:305 msgid "" "Returns ``(unsigned long)-1`` on error. Use :c:func:`PyErr_Occurred` to " "disambiguate." msgstr "" -#: ../../c-api/long.rst:282 +#: ../../c-api/long.rst:315 msgid "" "Return a C :c:type:`size_t` representation of *pylong*. *pylong* must be an " "instance of :c:type:`PyLongObject`." msgstr "" -#: ../../c-api/long.rst:285 +#: ../../c-api/long.rst:318 msgid "" "Raise :exc:`OverflowError` if the value of *pylong* is out of range for a :c:" "type:`size_t`." msgstr "" -#: ../../c-api/long.rst:288 +#: ../../c-api/long.rst:321 msgid "" "Returns ``(size_t)-1`` on error. Use :c:func:`PyErr_Occurred` to " "disambiguate." msgstr "" -#: ../../c-api/long.rst:297 +#: ../../c-api/long.rst:330 msgid "" "Return a C :c:expr:`unsigned long long` representation of *pylong*. " "*pylong* must be an instance of :c:type:`PyLongObject`." msgstr "" -#: ../../c-api/long.rst:300 +#: ../../c-api/long.rst:333 msgid "" "Raise :exc:`OverflowError` if the value of *pylong* is out of range for an :" "c:expr:`unsigned long long`." msgstr "" -#: ../../c-api/long.rst:303 +#: ../../c-api/long.rst:336 msgid "" "Returns ``(unsigned long long)-1`` on error. Use :c:func:`PyErr_Occurred` to " "disambiguate." msgstr "" -#: ../../c-api/long.rst:306 +#: ../../c-api/long.rst:339 msgid "" "A negative *pylong* now raises :exc:`OverflowError`, not :exc:`TypeError`." msgstr "" -#: ../../c-api/long.rst:312 +#: ../../c-api/long.rst:345 msgid "" "Return a C :c:expr:`unsigned long` representation of *obj*. If *obj* is not " "an instance of :c:type:`PyLongObject`, first call its :meth:`~object." "__index__` method (if present) to convert it to a :c:type:`PyLongObject`." msgstr "" -#: ../../c-api/long.rst:316 +#: ../../c-api/long.rst:349 msgid "" "If the value of *obj* is out of range for an :c:expr:`unsigned long`, return " "the reduction of that value modulo ``ULONG_MAX + 1``." msgstr "" -#: ../../c-api/long.rst:319 +#: ../../c-api/long.rst:352 msgid "" "Returns ``(unsigned long)-1`` on error. Use :c:func:`PyErr_Occurred` to " "disambiguate." msgstr "" -#: ../../c-api/long.rst:331 +#: ../../c-api/long.rst:364 msgid "" "Return a C :c:expr:`unsigned long long` representation of *obj*. If *obj* " "is not an instance of :c:type:`PyLongObject`, first call its :meth:`~object." "__index__` method (if present) to convert it to a :c:type:`PyLongObject`." msgstr "" -#: ../../c-api/long.rst:336 +#: ../../c-api/long.rst:369 msgid "" "If the value of *obj* is out of range for an :c:expr:`unsigned long long`, " "return the reduction of that value modulo ``ULLONG_MAX + 1``." msgstr "" -#: ../../c-api/long.rst:339 +#: ../../c-api/long.rst:372 msgid "" "Returns ``(unsigned long long)-1`` on error. Use :c:func:`PyErr_Occurred` " "to disambiguate." msgstr "" -#: ../../c-api/long.rst:351 +#: ../../c-api/long.rst:385 +msgid "" +"Set *\\*value* to a signed C :c:expr:`int32_t` or :c:expr:`int64_t` " +"representation of *obj*." +msgstr "" + +#: ../../c-api/long.rst:388 ../../c-api/long.rst:408 +msgid "" +"If *obj* is not an instance of :c:type:`PyLongObject`, first call its :meth:" +"`~object.__index__` method (if present) to convert it to a :c:type:" +"`PyLongObject`." +msgstr "" + +#: ../../c-api/long.rst:392 ../../c-api/long.rst:413 +msgid "If the *obj* value is out of range, raise an :exc:`OverflowError`." +msgstr "" + +#: ../../c-api/long.rst:394 ../../c-api/long.rst:415 +msgid "" +"Set *\\*value* and return ``0`` on success. Set an exception and return " +"``-1`` on error." +msgstr "" + +#: ../../c-api/long.rst:397 ../../c-api/long.rst:418 +msgid "*value* must not be ``NULL``." +msgstr "" + +#: ../../c-api/long.rst:405 +msgid "" +"Set *\\*value* to an unsigned C :c:expr:`uint32_t` or :c:expr:`uint64_t` " +"representation of *obj*." +msgstr "" + +#: ../../c-api/long.rst:412 +msgid "If *obj* is negative, raise a :exc:`ValueError`." +msgstr "" + +#: ../../c-api/long.rst:425 msgid "" "Return a C :c:expr:`double` representation of *pylong*. *pylong* must be an " "instance of :c:type:`PyLongObject`." msgstr "" -#: ../../c-api/long.rst:354 +#: ../../c-api/long.rst:428 msgid "" "Raise :exc:`OverflowError` if the value of *pylong* is out of range for a :c:" "expr:`double`." msgstr "" -#: ../../c-api/long.rst:357 +#: ../../c-api/long.rst:431 msgid "" "Returns ``-1.0`` on error. Use :c:func:`PyErr_Occurred` to disambiguate." msgstr "" -#: ../../c-api/long.rst:362 +#: ../../c-api/long.rst:436 msgid "" "Convert a Python integer *pylong* to a C :c:expr:`void` pointer. If *pylong* " "cannot be converted, an :exc:`OverflowError` will be raised. This is only " @@ -374,33 +434,33 @@ msgid "" "c:func:`PyLong_FromVoidPtr`." msgstr "" -#: ../../c-api/long.rst:367 +#: ../../c-api/long.rst:441 msgid "" "Returns ``NULL`` on error. Use :c:func:`PyErr_Occurred` to disambiguate." msgstr "" -#: ../../c-api/long.rst:372 +#: ../../c-api/long.rst:446 msgid "" "Copy the Python integer value *pylong* to a native *buffer* of size " "*n_bytes*. The *flags* can be set to ``-1`` to behave similarly to a C cast, " "or to values documented below to control the behavior." msgstr "" -#: ../../c-api/long.rst:376 +#: ../../c-api/long.rst:450 msgid "" "Returns ``-1`` with an exception raised on error. This may happen if " "*pylong* cannot be interpreted as an integer, or if *pylong* was negative " "and the ``Py_ASNATIVEBYTES_REJECT_NEGATIVE`` flag was set." msgstr "" -#: ../../c-api/long.rst:380 +#: ../../c-api/long.rst:454 msgid "" "Otherwise, returns the number of bytes required to store the value. If this " "is equal to or less than *n_bytes*, the entire value was copied. All " "*n_bytes* of the buffer are written: large buffers are padded with zeroes." msgstr "" -#: ../../c-api/long.rst:385 +#: ../../c-api/long.rst:459 msgid "" "If the returned value is greater than *n_bytes*, the value was truncated: as " "many of the lowest bits of the value as could fit are written, and the " @@ -408,25 +468,25 @@ msgid "" "downcast." msgstr "" -#: ../../c-api/long.rst:392 +#: ../../c-api/long.rst:466 msgid "" "Overflow is not considered an error. If the returned value is larger than " "*n_bytes*, most significant bits were discarded." msgstr "" -#: ../../c-api/long.rst:395 +#: ../../c-api/long.rst:469 msgid "``0`` will never be returned." msgstr "``0`` 將永不被回傳。" -#: ../../c-api/long.rst:397 +#: ../../c-api/long.rst:471 msgid "Values are always copied as two's-complement." msgstr "" -#: ../../c-api/long.rst:399 +#: ../../c-api/long.rst:473 msgid "Usage example::" msgstr "使用範例: ::" -#: ../../c-api/long.rst:401 +#: ../../c-api/long.rst:475 msgid "" "int32_t value;\n" "Py_ssize_t bytes = PyLong_AsNativeBytes(pylong, &value, sizeof(value), -1);\n" @@ -443,26 +503,26 @@ msgid "" "}" msgstr "" -#: ../../c-api/long.rst:415 +#: ../../c-api/long.rst:489 msgid "" "Passing zero to *n_bytes* will return the size of a buffer that would be " "large enough to hold the value. This may be larger than technically " "necessary, but not unreasonably so. If *n_bytes=0*, *buffer* may be ``NULL``." msgstr "" -#: ../../c-api/long.rst:422 +#: ../../c-api/long.rst:496 msgid "" "Passing *n_bytes=0* to this function is not an accurate way to determine the " "bit length of the value." msgstr "" -#: ../../c-api/long.rst:425 +#: ../../c-api/long.rst:499 msgid "" "To get at the entire Python value of an unknown size, the function can be " "called twice: first to determine the buffer size, then to fill it::" msgstr "" -#: ../../c-api/long.rst:428 +#: ../../c-api/long.rst:502 msgid "" "// Ask how much space we need.\n" "Py_ssize_t expected = PyLong_AsNativeBytes(pylong, NULL, 0, -1);\n" @@ -493,69 +553,69 @@ msgid "" "free(bignum);" msgstr "" -#: ../../c-api/long.rst:456 +#: ../../c-api/long.rst:530 msgid "" "*flags* is either ``-1`` (``Py_ASNATIVEBYTES_DEFAULTS``) to select defaults " "that behave most like a C cast, or a combination of the other flags in the " "table below. Note that ``-1`` cannot be combined with other flags." msgstr "" -#: ../../c-api/long.rst:461 +#: ../../c-api/long.rst:535 msgid "" "Currently, ``-1`` corresponds to ``Py_ASNATIVEBYTES_NATIVE_ENDIAN | " "Py_ASNATIVEBYTES_UNSIGNED_BUFFER``." msgstr "" -#: ../../c-api/long.rst:467 +#: ../../c-api/long.rst:541 msgid "Flag" msgstr "旗標" -#: ../../c-api/long.rst:467 +#: ../../c-api/long.rst:541 msgid "Value" msgstr "數值" -#: ../../c-api/long.rst:469 +#: ../../c-api/long.rst:543 msgid "``-1``" msgstr "``-1``" -#: ../../c-api/long.rst:470 +#: ../../c-api/long.rst:544 msgid "``0``" msgstr "``0``" -#: ../../c-api/long.rst:471 +#: ../../c-api/long.rst:545 msgid "``1``" msgstr "``1``" -#: ../../c-api/long.rst:472 +#: ../../c-api/long.rst:546 msgid "``3``" msgstr "``3``" -#: ../../c-api/long.rst:473 +#: ../../c-api/long.rst:547 msgid "``4``" msgstr "``4``" -#: ../../c-api/long.rst:474 +#: ../../c-api/long.rst:548 msgid "``8``" msgstr "``8``" -#: ../../c-api/long.rst:475 +#: ../../c-api/long.rst:549 msgid "``16``" msgstr "``16``" -#: ../../c-api/long.rst:478 +#: ../../c-api/long.rst:552 msgid "" "Specifying ``Py_ASNATIVEBYTES_NATIVE_ENDIAN`` will override any other endian " "flags. Passing ``2`` is reserved." msgstr "" -#: ../../c-api/long.rst:481 +#: ../../c-api/long.rst:555 msgid "" "By default, sufficient buffer will be requested to include a sign bit. For " "example, when converting 128 with *n_bytes=1*, the function will return 2 " "(or more) in order to store a zero sign bit." msgstr "" -#: ../../c-api/long.rst:485 +#: ../../c-api/long.rst:559 msgid "" "If ``Py_ASNATIVEBYTES_UNSIGNED_BUFFER`` is specified, a zero sign bit will " "be omitted from size calculations. This allows, for example, 128 to fit in a " @@ -565,7 +625,7 @@ msgid "" "requested." msgstr "" -#: ../../c-api/long.rst:492 +#: ../../c-api/long.rst:566 msgid "" "Specifying ``Py_ASNATIVEBYTES_REJECT_NEGATIVE`` causes an exception to be " "set if *pylong* is negative. Without this flag, negative values will be " @@ -573,7 +633,7 @@ msgid "" "of whether ``Py_ASNATIVEBYTES_UNSIGNED_BUFFER`` was specified." msgstr "" -#: ../../c-api/long.rst:497 +#: ../../c-api/long.rst:571 msgid "" "If ``Py_ASNATIVEBYTES_ALLOW_INDEX`` is specified and a non-integer value is " "passed, its :meth:`~object.__index__` method will be called first. This may " @@ -583,7 +643,7 @@ msgid "" "`TypeError`." msgstr "" -#: ../../c-api/long.rst:506 +#: ../../c-api/long.rst:580 msgid "" "With the default *flags* (``-1``, or *UNSIGNED_BUFFER* without " "*REJECT_NEGATIVE*), multiple Python integers can map to a single value " @@ -591,22 +651,82 @@ msgid "" "buffer and set all its bits. This matches typical C cast behavior." msgstr "" -#: ../../c-api/long.rst:517 +#: ../../c-api/long.rst:591 +msgid "Macro for converting a Python integer into a process identifier." +msgstr "" + +#: ../../c-api/long.rst:593 +msgid "" +"This can be defined as an alias to :c:func:`PyLong_AsLong`, :c:func:" +"`PyLong_FromLongLong`, or :c:func:`PyLong_AsInt`, depending on the size of " +"the system's PID type." +msgstr "" + +#: ../../c-api/long.rst:602 +msgid "Get the sign of the integer object *obj*." +msgstr "" + +#: ../../c-api/long.rst:604 +msgid "" +"On success, set *\\*sign* to the integer sign (0, -1 or +1 for zero, " +"negative or positive integer, respectively) and return 0." +msgstr "" + +#: ../../c-api/long.rst:607 +msgid "" +"On failure, return -1 with an exception set. This function always succeeds " +"if *obj* is a :c:type:`PyLongObject` or its subtype." +msgstr "" + +#: ../../c-api/long.rst:615 +msgid "Check if the integer object *obj* is positive (``obj > 0``)." +msgstr "" + +#: ../../c-api/long.rst:617 +msgid "" +"If *obj* is an instance of :c:type:`PyLongObject` or its subtype, return " +"``1`` when it's positive and ``0`` otherwise. Else set an exception and " +"return ``-1``." +msgstr "" + +#: ../../c-api/long.rst:626 +msgid "Check if the integer object *obj* is negative (``obj < 0``)." +msgstr "" + +#: ../../c-api/long.rst:628 +msgid "" +"If *obj* is an instance of :c:type:`PyLongObject` or its subtype, return " +"``1`` when it's negative and ``0`` otherwise. Else set an exception and " +"return ``-1``." +msgstr "" + +#: ../../c-api/long.rst:637 +msgid "Check if the integer object *obj* is zero." +msgstr "" + +#: ../../c-api/long.rst:639 +msgid "" +"If *obj* is an instance of :c:type:`PyLongObject` or its subtype, return " +"``1`` when it's zero and ``0`` otherwise. Else set an exception and return " +"``-1``." +msgstr "" + +#: ../../c-api/long.rst:648 msgid "" "On success, return a read only :term:`named tuple`, that holds information " "about Python's internal representation of integers. See :data:`sys.int_info` " "for description of individual fields." msgstr "" -#: ../../c-api/long.rst:521 +#: ../../c-api/long.rst:652 msgid "On failure, return ``NULL`` with an exception set." msgstr "在失敗時,會回傳 ``NULL`` 並設定例外。" -#: ../../c-api/long.rst:528 +#: ../../c-api/long.rst:659 msgid "Return 1 if *op* is compact, 0 otherwise." msgstr "" -#: ../../c-api/long.rst:530 +#: ../../c-api/long.rst:661 msgid "" "This function makes it possible for performance-critical code to implement a " "“fast path” for small integers. For compact values use :c:func:" @@ -614,26 +734,272 @@ msgid "" "`PyLong_As* ` function or :c:func:`PyLong_AsNativeBytes`." msgstr "" -#: ../../c-api/long.rst:536 +#: ../../c-api/long.rst:667 msgid "The speedup is expected to be negligible for most users." msgstr "" -#: ../../c-api/long.rst:538 +#: ../../c-api/long.rst:669 msgid "" "Exactly what values are considered compact is an implementation detail and " "is subject to change." msgstr "" -#: ../../c-api/long.rst:546 +#: ../../c-api/long.rst:677 msgid "" "If *op* is compact, as determined by :c:func:`PyUnstable_Long_IsCompact`, " "return its value." msgstr "" -#: ../../c-api/long.rst:549 +#: ../../c-api/long.rst:680 msgid "Otherwise, the return value is undefined." msgstr "" +#: ../../c-api/long.rst:686 +msgid "Export API" +msgstr "" + +#: ../../c-api/long.rst:692 +msgid "" +"Layout of an array of \"digits\" (\"limbs\" in the GMP terminology), used to " +"represent absolute value for arbitrary precision integers." +msgstr "" + +#: ../../c-api/long.rst:695 +msgid "" +"Use :c:func:`PyLong_GetNativeLayout` to get the native layout of Python :" +"class:`int` objects, used internally for integers with \"big enough\" " +"absolute value." +msgstr "" + +#: ../../c-api/long.rst:699 +msgid "" +"See also :data:`sys.int_info` which exposes similar information in Python." +msgstr "" + +#: ../../c-api/long.rst:703 +msgid "" +"Bits per digit. For example, a 15 bit digit means that bits 0-14 contain " +"meaningful information." +msgstr "" + +#: ../../c-api/long.rst:708 +msgid "" +"Digit size in bytes. For example, a 15 bit digit will require at least 2 " +"bytes." +msgstr "" + +#: ../../c-api/long.rst:713 +msgid "Digits order:" +msgstr "" + +#: ../../c-api/long.rst:715 +msgid "``1`` for most significant digit first" +msgstr "" + +#: ../../c-api/long.rst:716 +msgid "``-1`` for least significant digit first" +msgstr "" + +#: ../../c-api/long.rst:720 +msgid "Digit endianness:" +msgstr "" + +#: ../../c-api/long.rst:722 +msgid "``1`` for most significant byte first (big endian)" +msgstr "" + +#: ../../c-api/long.rst:723 +msgid "``-1`` for least significant byte first (little endian)" +msgstr "" + +#: ../../c-api/long.rst:728 +msgid "Get the native layout of Python :class:`int` objects." +msgstr "" + +#: ../../c-api/long.rst:730 +msgid "See the :c:struct:`PyLongLayout` structure." +msgstr "" + +#: ../../c-api/long.rst:732 +msgid "" +"The function must not be called before Python initialization nor after " +"Python finalization. The returned layout is valid until Python is finalized. " +"The layout is the same for all Python sub-interpreters in a process, and so " +"it can be cached." +msgstr "" + +#: ../../c-api/long.rst:740 +msgid "Export of a Python :class:`int` object." +msgstr "" + +#: ../../c-api/long.rst:742 +msgid "There are two cases:" +msgstr "" + +#: ../../c-api/long.rst:744 +msgid "" +"If :c:member:`digits` is ``NULL``, only use the :c:member:`value` member." +msgstr "" + +#: ../../c-api/long.rst:745 +msgid "" +"If :c:member:`digits` is not ``NULL``, use :c:member:`negative`, :c:member:" +"`ndigits` and :c:member:`digits` members." +msgstr "" + +#: ../../c-api/long.rst:750 +msgid "" +"The native integer value of the exported :class:`int` object. Only valid if :" +"c:member:`digits` is ``NULL``." +msgstr "" + +#: ../../c-api/long.rst:755 +msgid "" +"``1`` if the number is negative, ``0`` otherwise. Only valid if :c:member:" +"`digits` is not ``NULL``." +msgstr "" + +#: ../../c-api/long.rst:760 +msgid "" +"Number of digits in :c:member:`digits` array. Only valid if :c:member:" +"`digits` is not ``NULL``." +msgstr "" + +#: ../../c-api/long.rst:765 +msgid "Read-only array of unsigned digits. Can be ``NULL``." +msgstr "" + +#: ../../c-api/long.rst:770 +msgid "Export a Python :class:`int` object." +msgstr "" + +#: ../../c-api/long.rst:772 +msgid "" +"*export_long* must point to a :c:struct:`PyLongExport` structure allocated " +"by the caller. It must not be ``NULL``." +msgstr "" + +#: ../../c-api/long.rst:775 +msgid "" +"On success, fill in *\\*export_long* and return ``0``. On error, set an " +"exception and return ``-1``." +msgstr "" + +#: ../../c-api/long.rst:778 +msgid "" +":c:func:`PyLong_FreeExport` must be called when the export is no longer " +"needed." +msgstr "" + +#: ../../c-api/long.rst:782 +msgid "" +"This function always succeeds if *obj* is a Python :class:`int` object or a " +"subclass." +msgstr "" + +#: ../../c-api/long.rst:788 +msgid "Release the export *export_long* created by :c:func:`PyLong_Export`." +msgstr "" + +#: ../../c-api/long.rst:791 +msgid "" +"Calling :c:func:`PyLong_FreeExport` is optional if *export_long->digits* is " +"``NULL``." +msgstr "" + +#: ../../c-api/long.rst:796 +msgid "PyLongWriter API" +msgstr "" + +#: ../../c-api/long.rst:798 +msgid "The :c:type:`PyLongWriter` API can be used to import an integer." +msgstr "" + +#: ../../c-api/long.rst:804 +msgid "A Python :class:`int` writer instance." +msgstr "" + +#: ../../c-api/long.rst:806 +msgid "" +"The instance must be destroyed by :c:func:`PyLongWriter_Finish` or :c:func:" +"`PyLongWriter_Discard`." +msgstr "" + +#: ../../c-api/long.rst:812 +msgid "Create a :c:type:`PyLongWriter`." +msgstr "" + +#: ../../c-api/long.rst:814 +msgid "" +"On success, allocate *\\*digits* and return a writer. On error, set an " +"exception and return ``NULL``." +msgstr "" + +#: ../../c-api/long.rst:817 +msgid "*negative* is ``1`` if the number is negative, or ``0`` otherwise." +msgstr "" + +#: ../../c-api/long.rst:819 +msgid "" +"*ndigits* is the number of digits in the *digits* array. It must be greater " +"than 0." +msgstr "" + +#: ../../c-api/long.rst:822 +msgid "*digits* must not be NULL." +msgstr "" + +#: ../../c-api/long.rst:824 +msgid "" +"After a successful call to this function, the caller should fill in the " +"array of digits *digits* and then call :c:func:`PyLongWriter_Finish` to get " +"a Python :class:`int`. The layout of *digits* is described by :c:func:" +"`PyLong_GetNativeLayout`." +msgstr "" + +#: ../../c-api/long.rst:829 +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``." +msgstr "" + +#: ../../c-api/long.rst:834 +msgid "" +"Alternately, call :c:func:`PyLongWriter_Discard` to destroy the writer " +"instance without creating an :class:`~int` object." +msgstr "" + +#: ../../c-api/long.rst:840 +msgid "" +"Finish a :c:type:`PyLongWriter` created by :c:func:`PyLongWriter_Create`." +msgstr "" + +#: ../../c-api/long.rst:842 +msgid "" +"On success, return a Python :class:`int` object. On error, set an exception " +"and return ``NULL``." +msgstr "" + +#: ../../c-api/long.rst:845 +msgid "" +"The function takes care of normalizing the digits and converts the object to " +"a compact integer if needed." +msgstr "" + +#: ../../c-api/long.rst:848 ../../c-api/long.rst:857 +msgid "The writer instance and the *digits* array are invalid after the call." +msgstr "" + +#: ../../c-api/long.rst:853 +msgid "" +"Discard a :c:type:`PyLongWriter` created by :c:func:`PyLongWriter_Create`." +msgstr "" + +#: ../../c-api/long.rst:855 +msgid "If *writer* is ``NULL``, no operation is performed." +msgstr "" + #: ../../c-api/long.rst:8 msgid "object" msgstr "object(物件)" @@ -646,23 +1012,23 @@ msgstr "long integer(長整數)" msgid "integer" msgstr "integer(整數)" -#: ../../c-api/long.rst:144 +#: ../../c-api/long.rst:177 msgid "LONG_MAX (C macro)" msgstr "LONG_MAX(C 巨集)" -#: ../../c-api/long.rst:144 ../../c-api/long.rst:204 ../../c-api/long.rst:247 -#: ../../c-api/long.rst:262 ../../c-api/long.rst:278 ../../c-api/long.rst:294 +#: ../../c-api/long.rst:177 ../../c-api/long.rst:237 ../../c-api/long.rst:280 +#: ../../c-api/long.rst:295 ../../c-api/long.rst:311 ../../c-api/long.rst:327 msgid "OverflowError (built-in exception)" msgstr "OverflowError(內建例外)" -#: ../../c-api/long.rst:247 +#: ../../c-api/long.rst:280 msgid "PY_SSIZE_T_MAX (C macro)" msgstr "PY_SSIZE_T_MAX(C 巨集)" -#: ../../c-api/long.rst:262 +#: ../../c-api/long.rst:295 msgid "ULONG_MAX (C macro)" msgstr "ULONG_MAX(C 巨集)" -#: ../../c-api/long.rst:278 +#: ../../c-api/long.rst:311 msgid "SIZE_MAX (C macro)" msgstr "SIZE_MAX(C 巨集)" diff --git a/c-api/mapping.po b/c-api/mapping.po index 49e8987a803..1be66dc2c01 100644 --- a/c-api/mapping.po +++ b/c-api/mapping.po @@ -1,13 +1,13 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Matt Wang , 2024 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-11-05 00:16+0000\n" "PO-Revision-Date: 2024-05-11 14:32+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -75,14 +75,13 @@ msgid "" msgstr "" #: ../../c-api/mapping.rst:53 -#, fuzzy msgid "" "This is the same as :c:func:`PyMapping_GetOptionalItem`, but *key* is " "specified as a :c:expr:`const char*` UTF-8 encoded bytes string, rather than " "a :c:expr:`PyObject*`." msgstr "" -"這與 :c:func:`PyMapping_HasKey` 相同,但 *key* 被指定為 :c:expr:`const " -"char*` UTF-8 編碼位元組字串,而不是 :c:expr:`PyObject*`。" +"這與 :c:func:`PyMapping_GetOptionalItem` 相同,但 *key* 被指定為 :c:expr:" +"`const char*` UTF-8 編碼位元組字串,而不是 :c:expr:`PyObject*`。" #: ../../c-api/mapping.rst:62 msgid "" @@ -107,24 +106,22 @@ msgstr "" "char*` UTF-8 編碼位元組字串,而不是 :c:expr:`PyObject*`。" #: ../../c-api/mapping.rst:81 -#, fuzzy msgid "" "Return ``1`` if the mapping object has the key *key* and ``0`` otherwise. " "This is equivalent to the Python expression ``key in o``. On failure, return " "``-1``." msgstr "" "如果對映物件具有鍵 *key* 則回傳 ``1``,否則回傳 ``0``。這相當於 Python 運算" -"式 ``key in o``。這個函式總會是成功的。" +"式 ``key in o``。失敗時回傳 ``-1``。" #: ../../c-api/mapping.rst:90 -#, fuzzy msgid "" "This is the same as :c:func:`PyMapping_HasKeyWithError`, but *key* is " "specified as a :c:expr:`const char*` UTF-8 encoded bytes string, rather than " "a :c:expr:`PyObject*`." msgstr "" -"這與 :c:func:`PyMapping_HasKey` 相同,但 *key* 被指定為 :c:expr:`const " -"char*` UTF-8 編碼位元組字串,而不是 :c:expr:`PyObject*`。" +"這與 :c:func:`PyMapping_HasKeyWithError` 相同,但 *key* 被指定為 :c:expr:" +"`const char*` UTF-8 編碼位元組字串,而不是 :c:expr:`PyObject*`。" #: ../../c-api/mapping.rst:99 msgid "" @@ -136,15 +133,15 @@ msgstr "" "式 ``key in o``。這個函式總會是成功的。" #: ../../c-api/mapping.rst:105 -#, fuzzy msgid "" -"Exceptions which occur when this calls :meth:`~object.__getitem__` method " -"are silently ignored. For proper error handling, use :c:func:" +"Exceptions which occur when this calls the :meth:`~object.__getitem__` " +"method are silently ignored. For proper error handling, use :c:func:" "`PyMapping_HasKeyWithError`, :c:func:`PyMapping_GetOptionalItem` or :c:func:" "`PyObject_GetItem()` instead." msgstr "" "當它呼叫 :meth:`~object.__getitem__` 方法時發生的例外將被默默忽略。為了適當地" -"處理錯誤,請改用 :c:func:`PyObject_GetItem()`。" +"處理錯誤,請改用 :c:func:`PyMapping_HasKeyWithError`、:c:func:" +"`PyMapping_GetOptionalItem` 或 :c:func:`PyObject_GetItem()`。" #: ../../c-api/mapping.rst:113 msgid "" @@ -156,17 +153,17 @@ msgstr "" "char*` UTF-8 編碼位元組字串,而不是 :c:expr:`PyObject*`。" #: ../../c-api/mapping.rst:119 -#, fuzzy msgid "" -"Exceptions that occur when this calls :meth:`~object.__getitem__` method or " -"while creating the temporary :class:`str` object are silently ignored. For " -"proper error handling, use :c:func:`PyMapping_HasKeyStringWithError`, :c:" +"Exceptions that occur when this calls the :meth:`~object.__getitem__` method " +"or while creating the temporary :class:`str` object are silently ignored. " +"For proper error handling, use :c:func:`PyMapping_HasKeyStringWithError`, :c:" "func:`PyMapping_GetOptionalItemString` or :c:func:`PyMapping_GetItemString` " "instead." msgstr "" "當它呼叫 :meth:`~object.__getitem__` 方法或建立臨時 :class:`str` 物件時發生的" "例外將被默默忽略。為了適當地處理錯誤,請改用 :c:func:" -"`PyMapping_GetItemString`。" +"`PyMapping_HasKeyStringWithError`、:c:func:`PyMapping_GetOptionalItemString` " +"或 :c:func:`PyMapping_GetItemString`。" #: ../../c-api/mapping.rst:129 msgid "" diff --git a/c-api/marshal.po b/c-api/marshal.po index 88d77fe2c1d..41698940f03 100644 --- a/c-api/marshal.po +++ b/c-api/marshal.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -6,9 +6,9 @@ # Matt Wang , 2025 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-07-20 00:03+0000\n" +"POT-Creation-Date: 2025-11-05 00:16+0000\n" "PO-Revision-Date: 2025-06-28 02:44+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -42,52 +42,51 @@ msgstr "數值會以最低有效位元組 (the least significant byte) 優先的 #: ../../c-api/marshal.rst:16 msgid "" -"The module supports two versions of the data format: version 0 is the " -"historical version, version 1 shares interned strings in the file, and upon " -"unmarshalling. Version 2 uses a binary format for floating-point numbers. " -"``Py_MARSHAL_VERSION`` indicates the current file format (currently 2)." +"The module supports several versions of the data format; see the :py:mod:" +"`Python module documentation ` for details." msgstr "" -"這個模組支援兩個版本的資料格式:版本 0 是歷史版本,版本 1 在檔案中共享駐留字" -"串 (interned strings),並在 unmarshal 時使用。版本 2 使用二進位格式來儲存浮點" -"數。``Py_MARSHAL_VERSION`` 表示目前的檔案格式(目前為 2)。" -#: ../../c-api/marshal.rst:24 +#: ../../c-api/marshal.rst:21 +msgid "The current format version. See :py:data:`marshal.version`." +msgstr "" + +#: ../../c-api/marshal.rst:25 msgid "" "Marshal a :c:expr:`long` integer, *value*, to *file*. This will only write " "the least-significant 32 bits of *value*; regardless of the size of the " "native :c:expr:`long` type. *version* indicates the file format." msgstr "" "將一個 :c:expr:`long` 整數 *value* marshal 為 *file*。這只會寫入 *value* 的最" -"低有效 32 位元;無論原生 :c:expr:`long` 型別的大小如何。*version* 表示檔案的格" -"式。" +"低有效 32 位元;無論原生 :c:expr:`long` 型別的大小如何。*version* 表示檔案的" +"格式。" -#: ../../c-api/marshal.rst:28 ../../c-api/marshal.rst:36 +#: ../../c-api/marshal.rst:29 ../../c-api/marshal.rst:37 msgid "" -"This function can fail, in which case it sets the error indicator. " -"Use :c:func:`PyErr_Occurred` to check for that." +"This function can fail, in which case it sets the error indicator. Use :c:" +"func:`PyErr_Occurred` to check for that." msgstr "" "這個函式可能會失敗,這時會設定錯誤指示器。使用 :c:func:`PyErr_Occurred` 來檢" "查是否發生錯誤。" -#: ../../c-api/marshal.rst:33 +#: ../../c-api/marshal.rst:34 msgid "" "Marshal a Python object, *value*, to *file*. *version* indicates the file " "format." msgstr "" "將一個 Python 物件 *value* marshal 為 *file*。*version* 表示檔案的格式。" -#: ../../c-api/marshal.rst:41 +#: ../../c-api/marshal.rst:42 msgid "" "Return a bytes object containing the marshalled representation of *value*. " "*version* indicates the file format." msgstr "" "回傳一個位元組物件,包含 *value* 的 marshal 表示。*version* 為檔案的格式。" -#: ../../c-api/marshal.rst:45 +#: ../../c-api/marshal.rst:46 msgid "The following functions allow marshalled values to be read back in." msgstr "以下函式允許將 marshal 過後的值讀取回來。" -#: ../../c-api/marshal.rst:50 +#: ../../c-api/marshal.rst:51 msgid "" "Return a C :c:expr:`long` from the data stream in a :c:expr:`FILE*` opened " "for reading. Only a 32-bit value can be read in using this function, " @@ -96,13 +95,13 @@ msgstr "" "從一個為讀取而開啟的 :c:expr:`FILE*` 中的資料串流回傳一個 C :c:expr:`long`。" "無論 :c:expr:`long` 的原生大小如何,這個函式只能讀取 32 位元的值。" -#: ../../c-api/marshal.rst:54 ../../c-api/marshal.rst:64 +#: ../../c-api/marshal.rst:55 ../../c-api/marshal.rst:65 msgid "" "On error, sets the appropriate exception (:exc:`EOFError`) and returns " "``-1``." msgstr "在錯誤發生時,會設定合適的例外(:exc:`EOFError`)並回傳 ``-1``。" -#: ../../c-api/marshal.rst:60 +#: ../../c-api/marshal.rst:61 msgid "" "Return a C :c:expr:`short` from the data stream in a :c:expr:`FILE*` opened " "for reading. Only a 16-bit value can be read in using this function, " @@ -111,42 +110,53 @@ msgstr "" "從一個為讀取而開啟的 :c:expr:`FILE*` 中的資料串流回傳一個 C :c:expr:`short`。" "無論 :c:expr:`short` 的原生大小如何,這個函式只能讀取 16 位元的值。" -#: ../../c-api/marshal.rst:70 +#: ../../c-api/marshal.rst:71 msgid "" "Return a Python object from the data stream in a :c:expr:`FILE*` opened for " "reading." msgstr "" "從一個為讀取而開啟的 :c:expr:`FILE*` 中的資料串流回傳一個 Python 物件。" -#: ../../c-api/marshal.rst:73 ../../c-api/marshal.rst:87 -#: ../../c-api/marshal.rst:96 +#: ../../c-api/marshal.rst:74 ../../c-api/marshal.rst:88 +#: ../../c-api/marshal.rst:97 msgid "" "On error, sets the appropriate exception (:exc:`EOFError`, :exc:`ValueError` " "or :exc:`TypeError`) and returns ``NULL``." msgstr "" -"在錯誤發生時,會設定合適的例外(:exc:`EOFError`、:exc:`ValueError` " -"或 :exc:`TypeError`)並回傳 ``NULL``。" +"在錯誤發生時,會設定合適的例外(:exc:`EOFError`、:exc:`ValueError` 或 :exc:" +"`TypeError`)並回傳 ``NULL``。" -#: ../../c-api/marshal.rst:79 +#: ../../c-api/marshal.rst:80 msgid "" "Return a Python object from the data stream in a :c:expr:`FILE*` opened for " "reading. Unlike :c:func:`PyMarshal_ReadObjectFromFile`, this function " "assumes that no further objects will be read from the file, allowing it to " "aggressively load file data into memory so that the de-serialization can " "operate from data in memory rather than reading a byte at a time from the " -"file. Only use these variant if you are certain that you won't be reading " +"file. Only use this variant if you are certain that you won't be reading " "anything else from the file." msgstr "" -"從一個為讀取而開啟的 :c:expr:`FILE*` 中的資料串流回傳一個 Python 物件。" -"與 :c:func:`PyMarshal_ReadObjectFromFile` 不同,這個函式假設不會從檔案中讀取" -"其他物件,允許它積極地將檔案資料載入記憶體,以便反序列化可以從記憶體中的資料" -"操作,而不是從檔案中逐位元組讀取。只有在確定不會從檔案中讀取其他內容時,才使" -"用這個變體。" +"從一個為讀取而開啟的 :c:expr:`FILE*` 中的資料串流回傳一個 Python 物件。與 :c:" +"func:`PyMarshal_ReadObjectFromFile` 不同,這個函式假設不會從檔案中讀取其他物" +"件,允許它積極地將檔案資料載入記憶體,以便反序列化可以從記憶體中的資料操作," +"而不是從檔案中逐位元組讀取。只有在確定不會從檔案中讀取其他內容時,才使用這個" +"變體。" -#: ../../c-api/marshal.rst:93 +#: ../../c-api/marshal.rst:94 msgid "" "Return a Python object from the data stream in a byte buffer containing " "*len* bytes pointed to by *data*." msgstr "" "從一個包含 *len* 位元組、被 *data* 指向的位元組緩衝區中的資料串流回傳一個 " "Python 物件。" + +#~ msgid "" +#~ "The module supports two versions of the data format: version 0 is the " +#~ "historical version, version 1 shares interned strings in the file, and " +#~ "upon unmarshalling. Version 2 uses a binary format for floating-point " +#~ "numbers. ``Py_MARSHAL_VERSION`` indicates the current file format " +#~ "(currently 2)." +#~ msgstr "" +#~ "這個模組支援兩個版本的資料格式:版本 0 是歷史版本,版本 1 在檔案中共享駐留" +#~ "字串 (interned strings),並在 unmarshal 時使用。版本 2 使用二進位格式來儲" +#~ "存浮點數。``Py_MARSHAL_VERSION`` 表示目前的檔案格式(目前為 2)。" diff --git a/c-api/memory.po b/c-api/memory.po index 0b7ee268d03..a5631a2f0ce 100644 --- a/c-api/memory.po +++ b/c-api/memory.po @@ -1,14 +1,13 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Ching-Lung Chuang, 2015 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-07-21 00:18+0000\n" +"POT-Creation-Date: 2025-11-05 00:16+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-" @@ -134,8 +133,8 @@ msgid "" "allocation strategies and are optimized for different purposes. The specific " "details on how every domain allocates memory or what internal functions each " "domain calls is considered an implementation detail, but for debugging " -"purposes a simplified table can be found at :ref:`here `. The APIs used to allocate and free a block of memory must be " +"purposes a simplified table can be found at :ref:`default-memory-" +"allocators`. The APIs used to allocate and free a block of memory must be " "from the same domain. For example, :c:func:`PyMem_Free` must be used to free " "memory allocated using :c:func:`PyMem_Malloc`." msgstr "" @@ -148,8 +147,8 @@ msgstr "" msgid "" "Raw domain: intended for allocating memory for general-purpose memory " "buffers where the allocation *must* go to the system allocator or where the " -"allocator can operate without the :term:`GIL`. The memory is requested " -"directly from the system. See :ref:`Raw Memory Interface `." msgstr "" @@ -157,8 +156,8 @@ msgstr "" msgid "" "\"Mem\" domain: intended for allocating memory for Python buffers and " "general-purpose memory buffers where the allocation must be performed with " -"the :term:`GIL` held. The memory is taken from the Python private heap. See :" -"ref:`Memory Interface `." +"an :term:`attached thread state`. The memory is taken from the Python " +"private heap. See :ref:`Memory Interface `." msgstr "" #: ../../c-api/memory.rst:121 @@ -194,8 +193,8 @@ msgstr "" #: ../../c-api/memory.rst:141 msgid "" "The following function sets are wrappers to the system allocator. These " -"functions are thread-safe, the :term:`GIL ` does " -"not need to be held." +"functions are thread-safe, so a :term:`thread state` does not need to be :" +"term:`attached `." msgstr "" #: ../../c-api/memory.rst:145 @@ -206,8 +205,8 @@ msgid "" "requesting zero bytes." msgstr "" -#: ../../c-api/memory.rst:154 ../../c-api/memory.rst:225 -#: ../../c-api/memory.rst:335 +#: ../../c-api/memory.rst:154 ../../c-api/memory.rst:224 +#: ../../c-api/memory.rst:333 msgid "" "Allocates *n* bytes and returns a pointer of type :c:expr:`void*` to the " "allocated memory, or ``NULL`` if the request fails." @@ -220,8 +219,8 @@ msgid "" "have been initialized in any way." msgstr "" -#: ../../c-api/memory.rst:164 ../../c-api/memory.rst:235 -#: ../../c-api/memory.rst:345 +#: ../../c-api/memory.rst:164 ../../c-api/memory.rst:234 +#: ../../c-api/memory.rst:343 msgid "" "Allocates *nelem* elements each whose size in bytes is *elsize* and returns " "a pointer of type :c:expr:`void*` to the allocated memory, or ``NULL`` if " @@ -235,8 +234,8 @@ msgid "" "called instead." msgstr "" -#: ../../c-api/memory.rst:177 ../../c-api/memory.rst:248 -#: ../../c-api/memory.rst:358 +#: ../../c-api/memory.rst:177 ../../c-api/memory.rst:247 +#: ../../c-api/memory.rst:356 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." @@ -270,8 +269,8 @@ msgid "" "called before, undefined behavior occurs." msgstr "" -#: ../../c-api/memory.rst:199 ../../c-api/memory.rst:269 -#: ../../c-api/memory.rst:379 +#: ../../c-api/memory.rst:199 ../../c-api/memory.rst:268 +#: ../../c-api/memory.rst:377 msgid "If *p* is ``NULL``, no operation is performed." msgstr "" @@ -279,7 +278,7 @@ msgstr "" msgid "Memory Interface" msgstr "記憶體介面" -#: ../../c-api/memory.rst:207 ../../c-api/memory.rst:315 +#: ../../c-api/memory.rst:207 ../../c-api/memory.rst:314 msgid "" "The following function sets, modeled after the ANSI C standard, but " "specifying behavior when requesting zero bytes, are available for allocating " @@ -292,51 +291,50 @@ msgid "" "ref:`pymalloc memory allocator `." msgstr "" -#: ../../c-api/memory.rst:216 ../../c-api/memory.rst:330 +#: ../../c-api/memory.rst:216 ../../c-api/memory.rst:329 msgid "" -"The :term:`GIL ` must be held when using these " -"functions." +"There must be an :term:`attached thread state` when using these functions." msgstr "" -#: ../../c-api/memory.rst:221 +#: ../../c-api/memory.rst:220 msgid "" "The default allocator is now pymalloc instead of system :c:func:`malloc`." msgstr "" -#: ../../c-api/memory.rst:228 +#: ../../c-api/memory.rst:227 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:239 +#: ../../c-api/memory.rst:238 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:251 +#: ../../c-api/memory.rst:250 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:255 +#: ../../c-api/memory.rst:254 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:258 +#: ../../c-api/memory.rst:257 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:264 +#: ../../c-api/memory.rst:263 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:" @@ -344,20 +342,20 @@ msgid "" "undefined behavior occurs." msgstr "" -#: ../../c-api/memory.rst:271 +#: ../../c-api/memory.rst:270 msgid "" "The following type-oriented macros are provided for convenience. Note that " "*TYPE* refers to any C type." msgstr "" -#: ../../c-api/memory.rst:277 +#: ../../c-api/memory.rst:276 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:284 +#: ../../c-api/memory.rst:283 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* " @@ -365,17 +363,17 @@ msgid "" "failure." msgstr "" -#: ../../c-api/memory.rst:289 +#: ../../c-api/memory.rst:288 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:295 +#: ../../c-api/memory.rst:294 msgid "Same as :c:func:`PyMem_Free`." msgstr "和 :c:func:`PyMem_Free` 相同。" -#: ../../c-api/memory.rst:297 +#: ../../c-api/memory.rst:296 msgid "" "In addition, the following macro sets are provided for calling the Python " "memory allocator directly, without involving the C API functions listed " @@ -383,35 +381,35 @@ msgid "" "across Python versions and is therefore deprecated in extension modules." msgstr "" -#: ../../c-api/memory.rst:302 +#: ../../c-api/memory.rst:301 msgid "``PyMem_MALLOC(size)``" msgstr "``PyMem_MALLOC(size)``" -#: ../../c-api/memory.rst:303 +#: ../../c-api/memory.rst:302 msgid "``PyMem_NEW(type, size)``" msgstr "``PyMem_NEW(type, size)``" -#: ../../c-api/memory.rst:304 +#: ../../c-api/memory.rst:303 msgid "``PyMem_REALLOC(ptr, size)``" msgstr "``PyMem_REALLOC(ptr, size)``" -#: ../../c-api/memory.rst:305 +#: ../../c-api/memory.rst:304 msgid "``PyMem_RESIZE(ptr, type, size)``" msgstr "``PyMem_RESIZE(ptr, type, size)``" -#: ../../c-api/memory.rst:306 +#: ../../c-api/memory.rst:305 msgid "``PyMem_FREE(ptr)``" msgstr "``PyMem_FREE(ptr)``" -#: ../../c-api/memory.rst:307 +#: ../../c-api/memory.rst:306 msgid "``PyMem_DEL(ptr)``" msgstr "``PyMem_DEL(ptr)``" -#: ../../c-api/memory.rst:313 +#: ../../c-api/memory.rst:312 msgid "Object allocators" msgstr "" -#: ../../c-api/memory.rst:320 +#: ../../c-api/memory.rst:319 msgid "" "There is no guarantee that the memory returned by these allocators can be " "successfully cast to a Python object when intercepting the allocating " @@ -419,47 +417,47 @@ msgid "" "Memory Allocators ` section." msgstr "" -#: ../../c-api/memory.rst:325 +#: ../../c-api/memory.rst:324 msgid "" "The :ref:`default object allocator ` uses the :" "ref:`pymalloc memory allocator `." msgstr "" -#: ../../c-api/memory.rst:338 +#: ../../c-api/memory.rst:336 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:349 +#: ../../c-api/memory.rst:347 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:361 +#: ../../c-api/memory.rst:359 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:365 +#: ../../c-api/memory.rst:363 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:368 +#: ../../c-api/memory.rst:366 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:374 +#: ../../c-api/memory.rst:372 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:" @@ -467,293 +465,327 @@ msgid "" "called before, undefined behavior occurs." msgstr "" -#: ../../c-api/memory.rst:385 -msgid "Default Memory Allocators" +#: ../../c-api/memory.rst:379 +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:382 +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:387 +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:389 ../../c-api/memory.rst:486 +msgid ":c:func:`PyObject_Malloc`" +msgstr ":c:func:`PyObject_Malloc`" + +#: ../../c-api/memory.rst:390 ../../c-api/memory.rst:487 +msgid ":c:func:`PyObject_Realloc`" +msgstr ":c:func:`PyObject_Realloc`" + +#: ../../c-api/memory.rst:391 ../../c-api/memory.rst:488 +msgid ":c:func:`PyObject_Calloc`" +msgstr ":c:func:`PyObject_Calloc`" + +#: ../../c-api/memory.rst:392 +msgid ":c:macro:`PyObject_New`" +msgstr ":c:macro:`PyObject_New`" + +#: ../../c-api/memory.rst:393 +msgid ":c:macro:`PyObject_NewVar`" +msgstr ":c:macro:`PyObject_NewVar`" + +#: ../../c-api/memory.rst:394 +msgid ":c:func:`PyType_GenericAlloc`" +msgstr ":c:func:`PyType_GenericAlloc`" + +#: ../../c-api/memory.rst:395 +msgid ":c:member:`~PyTypeObject.tp_free`" +msgstr ":c:member:`~PyTypeObject.tp_free`" + +#: ../../c-api/memory.rst:401 +msgid "Default Memory Allocators" +msgstr "" + +#: ../../c-api/memory.rst:403 msgid "Default memory allocators:" msgstr "" -#: ../../c-api/memory.rst:390 +#: ../../c-api/memory.rst:406 msgid "Configuration" msgstr "配置" -#: ../../c-api/memory.rst:390 +#: ../../c-api/memory.rst:406 msgid "Name" msgstr "名稱" -#: ../../c-api/memory.rst:390 +#: ../../c-api/memory.rst:406 msgid "PyMem_RawMalloc" msgstr "PyMem_RawMalloc" -#: ../../c-api/memory.rst:390 +#: ../../c-api/memory.rst:406 msgid "PyMem_Malloc" msgstr "PyMem_Malloc" -#: ../../c-api/memory.rst:390 +#: ../../c-api/memory.rst:406 msgid "PyObject_Malloc" msgstr "PyObject_Malloc" -#: ../../c-api/memory.rst:392 +#: ../../c-api/memory.rst:408 msgid "Release build" msgstr "" -#: ../../c-api/memory.rst:392 +#: ../../c-api/memory.rst:408 msgid "``\"pymalloc\"``" msgstr "``\"pymalloc\"``" -#: ../../c-api/memory.rst:392 ../../c-api/memory.rst:394 +#: ../../c-api/memory.rst:408 ../../c-api/memory.rst:410 msgid "``malloc``" msgstr "``malloc``" -#: ../../c-api/memory.rst:392 +#: ../../c-api/memory.rst:408 msgid "``pymalloc``" msgstr "``pymalloc``" -#: ../../c-api/memory.rst:393 +#: ../../c-api/memory.rst:409 msgid "Debug build" msgstr "" -#: ../../c-api/memory.rst:393 +#: ../../c-api/memory.rst:409 msgid "``\"pymalloc_debug\"``" msgstr "``\"pymalloc_debug\"``" -#: ../../c-api/memory.rst:393 ../../c-api/memory.rst:395 +#: ../../c-api/memory.rst:409 ../../c-api/memory.rst:411 msgid "``malloc`` + debug" msgstr "" -#: ../../c-api/memory.rst:393 +#: ../../c-api/memory.rst:409 msgid "``pymalloc`` + debug" msgstr "" -#: ../../c-api/memory.rst:394 +#: ../../c-api/memory.rst:410 msgid "Release build, without pymalloc" msgstr "" -#: ../../c-api/memory.rst:394 +#: ../../c-api/memory.rst:410 msgid "``\"malloc\"``" msgstr "``\"malloc\"``" -#: ../../c-api/memory.rst:395 +#: ../../c-api/memory.rst:411 msgid "Debug build, without pymalloc" msgstr "" -#: ../../c-api/memory.rst:395 +#: ../../c-api/memory.rst:411 msgid "``\"malloc_debug\"``" msgstr "``\"malloc_debug\"``" -#: ../../c-api/memory.rst:398 +#: ../../c-api/memory.rst:414 msgid "Legend:" msgstr "" -#: ../../c-api/memory.rst:400 +#: ../../c-api/memory.rst:416 msgid "Name: value for :envvar:`PYTHONMALLOC` environment variable." msgstr "" -#: ../../c-api/memory.rst:401 +#: ../../c-api/memory.rst:417 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:403 +#: ../../c-api/memory.rst:419 msgid "``pymalloc``: :ref:`pymalloc memory allocator `." msgstr "" -#: ../../c-api/memory.rst:404 +#: ../../c-api/memory.rst:420 msgid "" "``mimalloc``: :ref:`mimalloc memory allocator `. The pymalloc " "allocator will be used if mimalloc support isn't available." msgstr "" -#: ../../c-api/memory.rst:406 +#: ../../c-api/memory.rst:422 msgid "" "\"+ debug\": with :ref:`debug hooks on the Python memory allocators `." msgstr "" -#: ../../c-api/memory.rst:408 +#: ../../c-api/memory.rst:424 msgid "\"Debug build\": :ref:`Python build in debug mode `." msgstr "" -#: ../../c-api/memory.rst:413 +#: ../../c-api/memory.rst:429 msgid "Customize Memory Allocators" msgstr "" -#: ../../c-api/memory.rst:419 +#: ../../c-api/memory.rst:435 msgid "" "Structure used to describe a memory block allocator. The structure has the " "following fields:" msgstr "" -#: ../../c-api/memory.rst:423 ../../c-api/memory.rst:674 +#: ../../c-api/memory.rst:439 ../../c-api/memory.rst:690 msgid "Field" msgstr "欄位" -#: ../../c-api/memory.rst:423 ../../c-api/memory.rst:674 +#: ../../c-api/memory.rst:439 ../../c-api/memory.rst:690 msgid "Meaning" msgstr "意義" -#: ../../c-api/memory.rst:425 ../../c-api/memory.rst:676 +#: ../../c-api/memory.rst:441 ../../c-api/memory.rst:692 msgid "``void *ctx``" msgstr "``void *ctx``" -#: ../../c-api/memory.rst:425 ../../c-api/memory.rst:676 +#: ../../c-api/memory.rst:441 ../../c-api/memory.rst:692 msgid "user context passed as first argument" msgstr "" -#: ../../c-api/memory.rst:427 +#: ../../c-api/memory.rst:443 msgid "``void* malloc(void *ctx, size_t size)``" msgstr "``void* malloc(void *ctx, size_t size)``" -#: ../../c-api/memory.rst:427 +#: ../../c-api/memory.rst:443 msgid "allocate a memory block" msgstr "" -#: ../../c-api/memory.rst:429 +#: ../../c-api/memory.rst:445 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:429 +#: ../../c-api/memory.rst:445 msgid "allocate a memory block initialized with zeros" msgstr "" -#: ../../c-api/memory.rst:432 +#: ../../c-api/memory.rst:448 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:432 +#: ../../c-api/memory.rst:448 msgid "allocate or resize a memory block" msgstr "" -#: ../../c-api/memory.rst:434 +#: ../../c-api/memory.rst:450 msgid "``void free(void *ctx, void *ptr)``" msgstr "``void free(void *ctx, void *ptr)``" -#: ../../c-api/memory.rst:434 +#: ../../c-api/memory.rst:450 msgid "free a memory block" msgstr "" -#: ../../c-api/memory.rst:437 +#: ../../c-api/memory.rst:453 msgid "" "The :c:type:`!PyMemAllocator` structure was renamed to :c:type:" "`PyMemAllocatorEx` and a new ``calloc`` field was added." msgstr "" -#: ../../c-api/memory.rst:444 +#: ../../c-api/memory.rst:460 msgid "Enum used to identify an allocator domain. Domains:" msgstr "" -#: ../../c-api/memory.rst:450 ../../c-api/memory.rst:459 -#: ../../c-api/memory.rst:468 +#: ../../c-api/memory.rst:466 ../../c-api/memory.rst:475 +#: ../../c-api/memory.rst:484 msgid "Functions:" msgstr "函式:" -#: ../../c-api/memory.rst:452 +#: ../../c-api/memory.rst:468 msgid ":c:func:`PyMem_RawMalloc`" msgstr ":c:func:`PyMem_RawMalloc`" -#: ../../c-api/memory.rst:453 +#: ../../c-api/memory.rst:469 msgid ":c:func:`PyMem_RawRealloc`" msgstr ":c:func:`PyMem_RawRealloc`" -#: ../../c-api/memory.rst:454 +#: ../../c-api/memory.rst:470 msgid ":c:func:`PyMem_RawCalloc`" msgstr ":c:func:`PyMem_RawCalloc`" -#: ../../c-api/memory.rst:455 +#: ../../c-api/memory.rst:471 msgid ":c:func:`PyMem_RawFree`" msgstr ":c:func:`PyMem_RawFree`" -#: ../../c-api/memory.rst:461 +#: ../../c-api/memory.rst:477 msgid ":c:func:`PyMem_Malloc`," msgstr ":c:func:`PyMem_Malloc`," -#: ../../c-api/memory.rst:462 +#: ../../c-api/memory.rst:478 msgid ":c:func:`PyMem_Realloc`" msgstr ":c:func:`PyMem_Realloc`" -#: ../../c-api/memory.rst:463 +#: ../../c-api/memory.rst:479 msgid ":c:func:`PyMem_Calloc`" msgstr ":c:func:`PyMem_Calloc`" -#: ../../c-api/memory.rst:464 +#: ../../c-api/memory.rst:480 msgid ":c:func:`PyMem_Free`" msgstr ":c:func:`PyMem_Free`" -#: ../../c-api/memory.rst:470 -msgid ":c:func:`PyObject_Malloc`" -msgstr ":c:func:`PyObject_Malloc`" - -#: ../../c-api/memory.rst:471 -msgid ":c:func:`PyObject_Realloc`" -msgstr ":c:func:`PyObject_Realloc`" - -#: ../../c-api/memory.rst:472 -msgid ":c:func:`PyObject_Calloc`" -msgstr ":c:func:`PyObject_Calloc`" - -#: ../../c-api/memory.rst:473 +#: ../../c-api/memory.rst:489 msgid ":c:func:`PyObject_Free`" msgstr ":c:func:`PyObject_Free`" -#: ../../c-api/memory.rst:477 +#: ../../c-api/memory.rst:493 msgid "Get the memory block allocator of the specified domain." msgstr "" -#: ../../c-api/memory.rst:482 +#: ../../c-api/memory.rst:498 msgid "Set the memory block allocator of the specified domain." msgstr "" -#: ../../c-api/memory.rst:484 +#: ../../c-api/memory.rst:500 msgid "" "The new allocator must return a distinct non-``NULL`` pointer when " "requesting zero bytes." msgstr "" -#: ../../c-api/memory.rst:487 +#: ../../c-api/memory.rst:503 msgid "" "For the :c:macro:`PYMEM_DOMAIN_RAW` domain, the allocator must be thread-" -"safe: the :term:`GIL ` is not held when the " -"allocator is called." +"safe: a :term:`thread state` is not :term:`attached ` " +"when the allocator is called." msgstr "" -#: ../../c-api/memory.rst:491 +#: ../../c-api/memory.rst:507 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 " -"``GIL``." +"allocator may be called in different interpreters that do not share a :term:" +"`GIL`." msgstr "" -#: ../../c-api/memory.rst:495 +#: ../../c-api/memory.rst:511 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:499 +#: ../../c-api/memory.rst:515 msgid "" "See also :c:member:`PyPreConfig.allocator` and :ref:`Preinitialize Python " "with PyPreConfig `." msgstr "" -#: ../../c-api/memory.rst:504 +#: ../../c-api/memory.rst:520 msgid ":c:func:`PyMem_SetAllocator` does have the following contract:" msgstr "" -#: ../../c-api/memory.rst:506 +#: ../../c-api/memory.rst:522 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 " "restrictions over the installed allocator other than the ones imposed by the " "domain (for instance, the Raw Domain allows the allocator to be called " -"without the GIL held). See :ref:`the section on allocator domains ` for more information." +"without an :term:`attached thread state`). See :ref:`the section on " +"allocator domains ` for more information." msgstr "" -#: ../../c-api/memory.rst:514 +#: ../../c-api/memory.rst:530 msgid "" "If called after Python has finish initializing (after :c:func:" "`Py_InitializeFromConfig` has been called) the allocator **must** wrap the " @@ -761,21 +793,21 @@ msgid "" "arbitrary one is **not supported**." msgstr "" -#: ../../c-api/memory.rst:519 +#: ../../c-api/memory.rst:535 msgid "All allocators must be thread-safe." msgstr "" -#: ../../c-api/memory.rst:525 +#: ../../c-api/memory.rst:541 msgid "" "Setup :ref:`debug hooks in the Python memory allocators ` " "to detect memory errors." msgstr "" -#: ../../c-api/memory.rst:532 +#: ../../c-api/memory.rst:548 msgid "Debug hooks on the Python memory allocators" msgstr "" -#: ../../c-api/memory.rst:534 +#: ../../c-api/memory.rst:550 msgid "" "When :ref:`Python is built in debug mode `, the :c:func:" "`PyMem_SetupDebugHooks` function is called at the :ref:`Python " @@ -783,19 +815,19 @@ msgid "" "allocators to detect memory errors." msgstr "" -#: ../../c-api/memory.rst:539 +#: ../../c-api/memory.rst:555 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:542 +#: ../../c-api/memory.rst:558 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:545 +#: ../../c-api/memory.rst:561 msgid "" "These debug hooks fill dynamically allocated memory blocks with special, " "recognizable bit patterns. Newly allocated memory is filled with the byte " @@ -805,33 +837,33 @@ msgid "" "these bytes are unlikely to be valid addresses, floats, or ASCII strings." msgstr "" -#: ../../c-api/memory.rst:552 +#: ../../c-api/memory.rst:568 msgid "Runtime checks:" msgstr "Runtime 檢查:" -#: ../../c-api/memory.rst:554 +#: ../../c-api/memory.rst:570 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:556 +#: ../../c-api/memory.rst:572 msgid "Detect write before the start of the buffer (buffer underflow)." msgstr "" -#: ../../c-api/memory.rst:557 +#: ../../c-api/memory.rst:573 msgid "Detect write after the end of the buffer (buffer overflow)." msgstr "" -#: ../../c-api/memory.rst:558 +#: ../../c-api/memory.rst:574 msgid "" -"Check that the :term:`GIL ` is held when allocator " +"Check that there is an :term:`attached thread state` when allocator " "functions of :c:macro:`PYMEM_DOMAIN_OBJ` (ex: :c:func:`PyObject_Malloc`) " "and :c:macro:`PYMEM_DOMAIN_MEM` (ex: :c:func:`PyMem_Malloc`) domains are " "called." msgstr "" -#: ../../c-api/memory.rst:563 +#: ../../c-api/memory.rst:579 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 " @@ -839,7 +871,7 @@ msgid "" "memory block was traced." msgstr "" -#: ../../c-api/memory.rst:568 +#: ../../c-api/memory.rst:584 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 " @@ -849,49 +881,49 @@ msgid "" "from a Python slice):" msgstr "" -#: ../../c-api/memory.rst:574 +#: ../../c-api/memory.rst:590 msgid "``p[-2*S:-S]``" msgstr "``p[-2*S:-S]``" -#: ../../c-api/memory.rst:575 +#: ../../c-api/memory.rst:591 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:577 +#: ../../c-api/memory.rst:593 msgid "``p[-S]``" msgstr "``p[-S]``" -#: ../../c-api/memory.rst:578 +#: ../../c-api/memory.rst:594 msgid "API identifier (ASCII character):" msgstr "" -#: ../../c-api/memory.rst:580 +#: ../../c-api/memory.rst:596 msgid "``'r'`` for :c:macro:`PYMEM_DOMAIN_RAW`." msgstr "" -#: ../../c-api/memory.rst:581 +#: ../../c-api/memory.rst:597 msgid "``'m'`` for :c:macro:`PYMEM_DOMAIN_MEM`." msgstr "" -#: ../../c-api/memory.rst:582 +#: ../../c-api/memory.rst:598 msgid "``'o'`` for :c:macro:`PYMEM_DOMAIN_OBJ`." msgstr "" -#: ../../c-api/memory.rst:584 +#: ../../c-api/memory.rst:600 msgid "``p[-S+1:0]``" msgstr "``p[-S+1:0]``" -#: ../../c-api/memory.rst:585 +#: ../../c-api/memory.rst:601 msgid "Copies of PYMEM_FORBIDDENBYTE. Used to catch under- writes and reads." msgstr "" -#: ../../c-api/memory.rst:587 +#: ../../c-api/memory.rst:603 msgid "``p[0:N]``" msgstr "``p[0:N]``" -#: ../../c-api/memory.rst:588 +#: ../../c-api/memory.rst:604 msgid "" "The requested memory, filled with copies of PYMEM_CLEANBYTE, used to catch " "reference to uninitialized memory. When a realloc-like function is called " @@ -902,25 +934,25 @@ msgid "" "bytes are also filled with PYMEM_DEADBYTE." msgstr "" -#: ../../c-api/memory.rst:596 +#: ../../c-api/memory.rst:612 msgid "``p[N:N+S]``" msgstr "``p[N:N+S]``" -#: ../../c-api/memory.rst:597 +#: ../../c-api/memory.rst:613 msgid "Copies of PYMEM_FORBIDDENBYTE. Used to catch over- writes and reads." msgstr "" -#: ../../c-api/memory.rst:599 +#: ../../c-api/memory.rst:615 msgid "``p[N+S:N+2*S]``" msgstr "``p[N+S:N+2*S]``" -#: ../../c-api/memory.rst:600 +#: ../../c-api/memory.rst:616 msgid "" "Only used if the ``PYMEM_DEBUG_SERIALNO`` macro is defined (not defined by " "default)." msgstr "" -#: ../../c-api/memory.rst:603 +#: ../../c-api/memory.rst:619 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 " @@ -930,7 +962,7 @@ msgid "" "number is incremented, and exists so you can set such a breakpoint easily." msgstr "" -#: ../../c-api/memory.rst:610 +#: ../../c-api/memory.rst:626 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, " @@ -943,16 +975,17 @@ msgid "" "getting used)." msgstr "" -#: ../../c-api/memory.rst:619 +#: ../../c-api/memory.rst:635 msgid "" "The :c:func:`PyMem_SetupDebugHooks` function now also works on Python " "compiled in release mode. On error, the debug hooks now use :mod:" "`tracemalloc` to get the traceback where a memory block was allocated. The " -"debug hooks now also check if the GIL is held when functions of :c:macro:" -"`PYMEM_DOMAIN_OBJ` and :c:macro:`PYMEM_DOMAIN_MEM` domains are called." +"debug hooks now also check if there is an :term:`attached thread state` when " +"functions of :c:macro:`PYMEM_DOMAIN_OBJ` and :c:macro:`PYMEM_DOMAIN_MEM` " +"domains are called." msgstr "" -#: ../../c-api/memory.rst:627 +#: ../../c-api/memory.rst:643 msgid "" "Byte patterns ``0xCB`` (``PYMEM_CLEANBYTE``), ``0xDB`` (``PYMEM_DEADBYTE``) " "and ``0xFB`` (``PYMEM_FORBIDDENBYTE``) have been replaced with ``0xCD``, " @@ -960,11 +993,11 @@ msgid "" "``malloc()`` and ``free()``." msgstr "" -#: ../../c-api/memory.rst:637 +#: ../../c-api/memory.rst:653 msgid "The pymalloc allocator" msgstr "" -#: ../../c-api/memory.rst:639 +#: ../../c-api/memory.rst:655 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 " @@ -973,82 +1006,82 @@ msgid "" "`PyMem_RawRealloc` for allocations larger than 512 bytes." msgstr "" -#: ../../c-api/memory.rst:645 +#: ../../c-api/memory.rst:661 msgid "" "*pymalloc* is the :ref:`default allocator ` of " "the :c:macro:`PYMEM_DOMAIN_MEM` (ex: :c:func:`PyMem_Malloc`) and :c:macro:" "`PYMEM_DOMAIN_OBJ` (ex: :c:func:`PyObject_Malloc`) domains." msgstr "" -#: ../../c-api/memory.rst:649 +#: ../../c-api/memory.rst:665 msgid "The arena allocator uses the following functions:" msgstr "" -#: ../../c-api/memory.rst:651 +#: ../../c-api/memory.rst:667 msgid ":c:func:`!VirtualAlloc` and :c:func:`!VirtualFree` on Windows," -msgstr "" +msgstr "Windows 上的 :c:func:`!VirtualAlloc` 和 :c:func:`!VirtualFree`," -#: ../../c-api/memory.rst:652 +#: ../../c-api/memory.rst:668 msgid ":c:func:`!mmap` and :c:func:`!munmap` if available," -msgstr "" +msgstr "如果可用,則使用 :c:func:`!mmap` 和 :c:func:`!munmap`," -#: ../../c-api/memory.rst:653 +#: ../../c-api/memory.rst:669 msgid ":c:func:`malloc` and :c:func:`free` otherwise." -msgstr "" +msgstr "否則使用 :c:func:`malloc` 和 :c:func:`free`。" -#: ../../c-api/memory.rst:655 +#: ../../c-api/memory.rst:671 msgid "" "This allocator is disabled if Python is configured with the :option:`--" "without-pymalloc` option. It can also be disabled at runtime using the :" "envvar:`PYTHONMALLOC` environment variable (ex: ``PYTHONMALLOC=malloc``)." msgstr "" -#: ../../c-api/memory.rst:659 +#: ../../c-api/memory.rst:675 msgid "" "Typically, it makes sense to disable the pymalloc allocator when building " "Python with AddressSanitizer (:option:`--with-address-sanitizer`) which " "helps uncover low level bugs within the C code." msgstr "" -#: ../../c-api/memory.rst:664 +#: ../../c-api/memory.rst:680 msgid "Customize pymalloc Arena Allocator" msgstr "" -#: ../../c-api/memory.rst:670 +#: ../../c-api/memory.rst:686 msgid "" "Structure used to describe an arena allocator. The structure has three " "fields:" msgstr "" -#: ../../c-api/memory.rst:678 +#: ../../c-api/memory.rst:694 msgid "``void* alloc(void *ctx, size_t size)``" msgstr "``void* alloc(void *ctx, size_t size)``" -#: ../../c-api/memory.rst:678 +#: ../../c-api/memory.rst:694 msgid "allocate an arena of size bytes" msgstr "" -#: ../../c-api/memory.rst:680 +#: ../../c-api/memory.rst:696 msgid "``void free(void *ctx, void *ptr, size_t size)``" msgstr "``void free(void *ctx, void *ptr, size_t size)``" -#: ../../c-api/memory.rst:680 +#: ../../c-api/memory.rst:696 msgid "free an arena" msgstr "" -#: ../../c-api/memory.rst:685 +#: ../../c-api/memory.rst:701 msgid "Get the arena allocator." msgstr "" -#: ../../c-api/memory.rst:689 +#: ../../c-api/memory.rst:705 msgid "Set the arena allocator." msgstr "" -#: ../../c-api/memory.rst:694 +#: ../../c-api/memory.rst:710 msgid "The mimalloc allocator" msgstr "" -#: ../../c-api/memory.rst:698 +#: ../../c-api/memory.rst:714 msgid "" "Python supports the mimalloc allocator when the underlying platform support " "is available. mimalloc \"is a general purpose allocator with excellent " @@ -1056,46 +1089,46 @@ msgid "" "runtime systems of the Koka and Lean languages.\"" msgstr "" -#: ../../c-api/memory.rst:703 +#: ../../c-api/memory.rst:719 msgid "tracemalloc C API" msgstr "" -#: ../../c-api/memory.rst:709 +#: ../../c-api/memory.rst:725 msgid "Track an allocated memory block in the :mod:`tracemalloc` module." msgstr "" -#: ../../c-api/memory.rst:711 +#: ../../c-api/memory.rst:727 msgid "" "Return ``0`` on success, return ``-1`` on error (failed to allocate memory " "to store the trace). Return ``-2`` if tracemalloc is disabled." msgstr "" -#: ../../c-api/memory.rst:714 +#: ../../c-api/memory.rst:730 msgid "If memory block is already tracked, update the existing trace." msgstr "" -#: ../../c-api/memory.rst:718 +#: ../../c-api/memory.rst:734 msgid "" "Untrack an allocated memory block in the :mod:`tracemalloc` module. Do " "nothing if the block was not tracked." msgstr "" -#: ../../c-api/memory.rst:721 +#: ../../c-api/memory.rst:737 msgid "Return ``-2`` if tracemalloc is disabled, otherwise return ``0``." msgstr "" -#: ../../c-api/memory.rst:727 +#: ../../c-api/memory.rst:743 msgid "Examples" msgstr "範例" -#: ../../c-api/memory.rst:729 +#: ../../c-api/memory.rst:745 msgid "" "Here is the example from section :ref:`memoryoverview`, rewritten so that " "the I/O buffer is allocated from the Python heap by using the first function " "set::" msgstr "" -#: ../../c-api/memory.rst:732 +#: ../../c-api/memory.rst:748 msgid "" "PyObject *res;\n" "char *buf = (char *) PyMem_Malloc(BUFSIZ); /* for I/O */\n" @@ -1108,11 +1141,11 @@ msgid "" "return res;" msgstr "" -#: ../../c-api/memory.rst:742 +#: ../../c-api/memory.rst:758 msgid "The same code using the type-oriented function set::" msgstr "" -#: ../../c-api/memory.rst:744 +#: ../../c-api/memory.rst:760 msgid "" "PyObject *res;\n" "char *buf = PyMem_New(char, BUFSIZ); /* for I/O */\n" @@ -1121,11 +1154,11 @@ msgid "" " return PyErr_NoMemory();\n" "/* ...Do some I/O operation involving buf... */\n" "res = PyBytes_FromString(buf);\n" -"PyMem_Del(buf); /* allocated with PyMem_New */\n" +"PyMem_Free(buf); /* allocated with PyMem_New */\n" "return res;" msgstr "" -#: ../../c-api/memory.rst:754 +#: ../../c-api/memory.rst:770 msgid "" "Note that in the two examples above, the buffer is always manipulated via " "functions belonging to the same set. Indeed, it is required to use the same " @@ -1135,7 +1168,7 @@ msgid "" "different allocators operating on different heaps. ::" msgstr "" -#: ../../c-api/memory.rst:761 +#: ../../c-api/memory.rst:777 msgid "" "char *buf1 = PyMem_New(char, BUFSIZ);\n" "char *buf2 = (char *) malloc(BUFSIZ);\n" @@ -1143,17 +1176,17 @@ msgid "" "...\n" "PyMem_Del(buf3); /* Wrong -- should be PyMem_Free() */\n" "free(buf2); /* Right -- allocated via malloc() */\n" -"free(buf1); /* Fatal -- should be PyMem_Del() */" +"free(buf1); /* Fatal -- should be PyMem_Free() */" msgstr "" -#: ../../c-api/memory.rst:769 +#: ../../c-api/memory.rst:785 msgid "" "In addition to the functions aimed at handling raw memory blocks from the " "Python heap, objects in Python are allocated and released with :c:macro:" -"`PyObject_New`, :c:macro:`PyObject_NewVar` and :c:func:`PyObject_Del`." +"`PyObject_New`, :c:macro:`PyObject_NewVar` and :c:func:`PyObject_Free`." msgstr "" -#: ../../c-api/memory.rst:773 +#: ../../c-api/memory.rst:789 msgid "" "These will be explained in the next chapter on defining and implementing new " "object types in C." diff --git a/c-api/memoryview.po b/c-api/memoryview.po index 0221f2b2b81..fd622b22e9f 100644 --- a/c-api/memoryview.po +++ b/c-api/memoryview.po @@ -1,13 +1,12 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-01-30 00:03+0000\n" +"POT-Creation-Date: 2025-11-06 00:14+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-" @@ -31,34 +30,40 @@ msgstr "" #: ../../c-api/memoryview.rst:18 msgid "" +"This instance of :c:type:`PyTypeObject` represents the Python memoryview " +"type. This is the same object as :class:`memoryview` in the Python layer." +msgstr "" + +#: ../../c-api/memoryview.rst:24 +msgid "" "Create a memoryview object from an object that provides the buffer " "interface. If *obj* supports writable buffer exports, the memoryview object " "will be read/write, otherwise it may be either read-only or read/write at " "the discretion of the exporter." msgstr "" -#: ../../c-api/memoryview.rst:26 +#: ../../c-api/memoryview.rst:32 msgid "Flag to request a readonly buffer." msgstr "" -#: ../../c-api/memoryview.rst:31 +#: ../../c-api/memoryview.rst:37 msgid "Flag to request a writable buffer." msgstr "" -#: ../../c-api/memoryview.rst:36 +#: ../../c-api/memoryview.rst:42 msgid "" "Create a memoryview object using *mem* as the underlying buffer. *flags* can " "be one of :c:macro:`PyBUF_READ` or :c:macro:`PyBUF_WRITE`." msgstr "" -#: ../../c-api/memoryview.rst:43 +#: ../../c-api/memoryview.rst:49 msgid "" "Create a memoryview object wrapping the given buffer structure *view*. For " "simple byte buffers, :c:func:`PyMemoryView_FromMemory` is the preferred " "function." msgstr "" -#: ../../c-api/memoryview.rst:49 +#: ../../c-api/memoryview.rst:55 msgid "" "Create a memoryview object to a :term:`contiguous` chunk of memory (in " "either 'C' or 'F'ortran *order*) from an object that defines the buffer " @@ -67,26 +72,26 @@ msgid "" "new bytes object." msgstr "" -#: ../../c-api/memoryview.rst:55 +#: ../../c-api/memoryview.rst:61 msgid "" "*buffertype* can be one of :c:macro:`PyBUF_READ` or :c:macro:`PyBUF_WRITE`." msgstr "" -#: ../../c-api/memoryview.rst:60 +#: ../../c-api/memoryview.rst:66 msgid "" "Return true if the object *obj* is a memoryview object. It is not currently " "allowed to create subclasses of :class:`memoryview`. This function always " "succeeds." msgstr "" -#: ../../c-api/memoryview.rst:67 +#: ../../c-api/memoryview.rst:73 msgid "" "Return a pointer to the memoryview's private copy of the exporter's buffer. " "*mview* **must** be a memoryview instance; this macro doesn't check its " "type, you must do it yourself or you will risk crashes." msgstr "" -#: ../../c-api/memoryview.rst:73 +#: ../../c-api/memoryview.rst:79 msgid "" "Return either a pointer to the exporting object that the memoryview is based " "on or ``NULL`` if the memoryview has been created by one of the functions :c:" diff --git a/c-api/method.po b/c-api/method.po index 15837238166..8a650771d5d 100644 --- a/c-api/method.po +++ b/c-api/method.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -6,7 +6,7 @@ # Matt Wang , 2022 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2023-07-24 00:03+0000\n" "PO-Revision-Date: 2022-01-24 22:22+0800\n" diff --git a/c-api/module.po b/c-api/module.po index 16304cac163..71f6d4b1554 100644 --- a/c-api/module.po +++ b/c-api/module.po @@ -1,13 +1,13 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Leon H., 2017 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"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: 2025-11-27 00:14+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-" @@ -25,7 +25,7 @@ msgstr "模組物件" #: ../../c-api/module.rst:15 msgid "" "This instance of :c:type:`PyTypeObject` represents the Python module type. " -"This is exposed to Python programs as ``types.ModuleType``." +"This is exposed to Python programs as :py:class:`types.ModuleType`." msgstr "" #: ../../c-api/module.rst:21 @@ -49,8 +49,8 @@ msgid "" "setting a :attr:`~module.__file__` attribute." msgstr "" -#: ../../c-api/module.rst:46 ../../c-api/module.rst:272 -#: ../../c-api/module.rst:492 +#: ../../c-api/module.rst:46 ../../c-api/module.rst:434 +#: ../../c-api/module.rst:461 msgid "Return ``NULL`` with an exception set on error." msgstr "在失敗時回傳 ``NULL`` 並設定例外。" @@ -67,6 +67,8 @@ msgid "" "Similar to :c:func:`PyModule_NewObject`, but the name is a UTF-8 encoded " "string instead of a Unicode object." msgstr "" +"類似於 :c:func:`PyModule_NewObject`,但名稱是以 UTF-8 編碼的字串,而非 " +"Unicode 物件。" #: ../../c-api/module.rst:65 msgid "" @@ -83,27 +85,41 @@ msgid "" "__dict__`." msgstr "" -#: ../../c-api/module.rst:81 +#: ../../c-api/module.rst:74 +msgid "" +"The returned reference is borrowed from the module; it is valid until the " +"module is destroyed." +msgstr "" + +#: ../../c-api/module.rst:84 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:90 +#: ../../c-api/module.rst:93 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 +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:95 +#: ../../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:102 +#: ../../c-api/module.rst:109 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." @@ -111,123 +127,154 @@ msgstr "" #: ../../c-api/module.rst:112 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 +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 " "a string, raise :exc:`SystemError` and return ``NULL``; otherwise return a " "reference to a Unicode object." msgstr "" -#: ../../c-api/module.rst:122 +#: ../../c-api/module.rst:133 msgid "" "Similar to :c:func:`PyModule_GetFilenameObject` but return the filename " "encoded to 'utf-8'." msgstr "" +"類似於 :c:func:`PyModule_GetFilenameObject`,但回傳以 'utf-8' 編碼的檔案名" +"稱。" -#: ../../c-api/module.rst:125 +#: ../../c-api/module.rst:136 +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 msgid "" ":c:func:`PyModule_GetFilename` raises :exc:`UnicodeEncodeError` on " "unencodable filenames, use :c:func:`PyModule_GetFilenameObject` instead." msgstr "" -#: ../../c-api/module.rst:133 -msgid "Initializing C modules" -msgstr "初始化 C 模組" +#: ../../c-api/module.rst:147 +msgid "Module definitions" +msgstr "模組定義" + +#: ../../c-api/module.rst:149 +msgid "" +"The functions in the previous section work on any module object, including " +"modules imported from Python code." +msgstr "" + +#: ../../c-api/module.rst:152 +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." +msgstr "" -#: ../../c-api/module.rst:135 +#: ../../c-api/module.rst:156 msgid "" -"Modules objects are usually created from extension modules (shared libraries " -"which export an initialization function), or compiled-in modules (where the " -"initialization function is added using :c:func:`PyImport_AppendInittab`). " -"See :ref:`building` or :ref:`extending-with-embedding` for details." +"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 `." msgstr "" -#: ../../c-api/module.rst:140 +#: ../../c-api/module.rst:161 msgid "" -"The initialization function can either pass a module definition instance to :" -"c:func:`PyModule_Create`, and return the resulting module object, or request " -"\"multi-phase initialization\" by returning the definition struct itself." +"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." msgstr "" -#: ../../c-api/module.rst:146 +#: ../../c-api/module.rst:169 msgid "" "The module definition struct, which holds all information needed to create a " -"module object. There is usually only one statically initialized variable of " -"this type for each module." +"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." msgstr "" -#: ../../c-api/module.rst:152 +#: ../../c-api/module.rst:177 msgid "Always initialize this member to :c:macro:`PyModuleDef_HEAD_INIT`." msgstr "" -#: ../../c-api/module.rst:156 +#: ../../c-api/module.rst:181 msgid "Name for the new module." msgstr "" -#: ../../c-api/module.rst:160 +#: ../../c-api/module.rst:185 msgid "" "Docstring for the module; usually a docstring variable created with :c:macro:" "`PyDoc_STRVAR` is used." msgstr "" -#: ../../c-api/module.rst:165 +#: ../../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." msgstr "" -#: ../../c-api/module.rst:169 +#: ../../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 "" -#: ../../c-api/module.rst:173 +#: ../../c-api/module.rst:198 msgid "" -"Setting ``m_size`` to ``-1`` means that the module does not support sub-" -"interpreters, because it has global state." +"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." msgstr "" -#: ../../c-api/module.rst:176 +#: ../../c-api/module.rst:202 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. Non-negative ``m_size`` is required for multi-phase " -"initialization." +"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 `." msgstr "" -#: ../../c-api/module.rst:181 +#: ../../c-api/module.rst:208 msgid "See :PEP:`3121` for more details." msgstr "更多詳情請見 :pep:`3121`。" -#: ../../c-api/module.rst:185 +#: ../../c-api/module.rst:212 msgid "" "A pointer to a table of module-level functions, described by :c:type:" "`PyMethodDef` values. Can be ``NULL`` if no functions are present." msgstr "" -#: ../../c-api/module.rst:190 +#: ../../c-api/module.rst:217 msgid "" "An array of slot definitions for multi-phase initialization, terminated by a " -"``{0, NULL}`` entry. When using single-phase initialization, *m_slots* must " -"be ``NULL``." +"``{0, NULL}`` entry. When using legacy single-phase initialization, " +"*m_slots* must be ``NULL``." msgstr "" -#: ../../c-api/module.rst:196 +#: ../../c-api/module.rst:223 msgid "" "Prior to version 3.5, this member was always set to ``NULL``, and was " "defined as:" -msgstr "" +msgstr "在 3.5 版本之前,這個成員總是被設為 ``NULL``,並被定義為:" -#: ../../c-api/module.rst:203 +#: ../../c-api/module.rst:230 msgid "" "A traversal function to call during GC traversal of the module object, or " "``NULL`` if not needed." msgstr "" -#: ../../c-api/module.rst:206 ../../c-api/module.rst:221 -#: ../../c-api/module.rst:242 +#: ../../c-api/module.rst:233 ../../c-api/module.rst:248 +#: ../../c-api/module.rst:269 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 " @@ -237,18 +284,18 @@ msgid "" "`PyModule_GetState`) is ``NULL``." msgstr "" -#: ../../c-api/module.rst:213 ../../c-api/module.rst:234 -#: ../../c-api/module.rst:249 +#: ../../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." msgstr "" -#: ../../c-api/module.rst:218 +#: ../../c-api/module.rst:245 msgid "" "A clear function to call during GC clearing of the module object, or " "``NULL`` if not needed." msgstr "" -#: ../../c-api/module.rst:228 +#: ../../c-api/module.rst:255 msgid "" "Like :c:member:`PyTypeObject.tp_clear`, this function is not *always* called " "before a module is deallocated. For example, when reference counting is " @@ -257,174 +304,55 @@ msgid "" "directly." msgstr "" -#: ../../c-api/module.rst:239 +#: ../../c-api/module.rst:266 msgid "" "A function to call during deallocation of the module object, or ``NULL`` if " "not needed." msgstr "" -#: ../../c-api/module.rst:253 -msgid "Single-phase initialization" -msgstr "" - -#: ../../c-api/module.rst:255 -msgid "" -"The module initialization function may create and return the module object " -"directly. This is referred to as \"single-phase initialization\", and uses " -"one of the following two module creation functions:" -msgstr "" - -#: ../../c-api/module.rst:261 -msgid "" -"Create a new module object, given the definition in *def*. This behaves " -"like :c:func:`PyModule_Create2` with *module_api_version* set to :c:macro:" -"`PYTHON_API_VERSION`." -msgstr "" - -#: ../../c-api/module.rst:268 -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:276 -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:279 -msgid "" -"Before it is returned from in the initialization function, the resulting " -"module object is typically populated using functions like :c:func:" -"`PyModule_AddObjectRef`." -msgstr "" - -#: ../../c-api/module.rst:285 -msgid "Multi-phase initialization" -msgstr "" +#: ../../c-api/module.rst:281 +msgid "Module slots" +msgstr "模組槽 (Module slots)" #: ../../c-api/module.rst:287 -msgid "" -"An alternate way to specify extensions is to request \"multi-phase " -"initialization\". Extension modules created this way behave more like Python " -"modules: the initialization is split between the *creation phase*, when the " -"module object is created, and the *execution phase*, when it is populated. " -"The distinction is similar to the :py:meth:`~object.__new__` and :py:meth:" -"`~object.__init__` methods of classes." -msgstr "" - -#: ../../c-api/module.rst:294 -msgid "" -"Unlike modules created using single-phase initialization, these 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/module.rst:302 -msgid "" -"Additional module instances may be created in :ref:`sub-interpreters ` or after after Python runtime reinitialization (:c:" -"func:`Py_Finalize` and :c:func:`Py_Initialize`). In these cases, sharing " -"Python objects between module instances would likely cause crashes or " -"undefined behavior." -msgstr "" - -#: ../../c-api/module.rst:309 -msgid "" -"To avoid such issues, each instance of an extension module should be " -"*isolated*: changes to one instance should not implicitly affect the others, " -"and all state, including references to Python objects, should be specific to " -"a particular module instance. See :ref:`isolating-extensions-howto` for more " -"details and a practical guide." -msgstr "" - -#: ../../c-api/module.rst:315 -msgid "" -"A simpler way to avoid these issues is :ref:`raising an error on repeated " -"initialization `." -msgstr "" - -#: ../../c-api/module.rst:318 -msgid "" -"All modules created using multi-phase initialization are expected to " -"support :ref:`sub-interpreters `, or otherwise " -"explicitly signal a lack of support. This is usually achieved by isolation " -"or blocking repeated initialization, as above. A module may also be limited " -"to the main interpreter using the :c:data:`Py_mod_multiple_interpreters` " -"slot." -msgstr "" - -#: ../../c-api/module.rst:326 -msgid "" -"To request multi-phase initialization, the initialization function " -"(PyInit_modulename) returns a :c:type:`PyModuleDef` instance with non-empty :" -"c:member:`~PyModuleDef.m_slots`. Before it is returned, the ``PyModuleDef`` " -"instance must be initialized with the following function:" -msgstr "" - -#: ../../c-api/module.rst:333 -msgid "" -"Ensures a module definition is a properly initialized Python object that " -"correctly reports its type and reference count." -msgstr "" - -#: ../../c-api/module.rst:336 -msgid "Returns *def* cast to ``PyObject*``, or ``NULL`` if an error occurred." -msgstr "" - -#: ../../c-api/module.rst:340 -msgid "" -"The *m_slots* member of the module definition must point to an array of " -"``PyModuleDef_Slot`` structures:" -msgstr "" - -#: ../../c-api/module.rst:347 msgid "A slot ID, chosen from the available values explained below." msgstr "" -#: ../../c-api/module.rst:351 +#: ../../c-api/module.rst:291 msgid "Value of the slot, whose meaning depends on the slot ID." msgstr "" -#: ../../c-api/module.rst:355 -msgid "The *m_slots* array must be terminated by a slot with id 0." -msgstr "" - -#: ../../c-api/module.rst:357 +#: ../../c-api/module.rst:295 msgid "The available slot types are:" msgstr "" -#: ../../c-api/module.rst:361 +#: ../../c-api/module.rst:299 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:" msgstr "" -#: ../../c-api/module.rst:368 +#: ../../c-api/module.rst:306 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``." msgstr "" -#: ../../c-api/module.rst:373 +#: ../../c-api/module.rst:311 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." msgstr "" -#: ../../c-api/module.rst:377 +#: ../../c-api/module.rst:315 msgid "" "Multiple ``Py_mod_create`` slots may not be specified in one module " "definition." msgstr "" -#: ../../c-api/module.rst:380 +#: ../../c-api/module.rst:318 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 " @@ -433,7 +361,7 @@ msgid "" "through symlinks, all while sharing a single module definition." msgstr "" -#: ../../c-api/module.rst:386 +#: ../../c-api/module.rst:324 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 " @@ -443,7 +371,7 @@ msgid "" "``Py_mod_create``." msgstr "" -#: ../../c-api/module.rst:395 +#: ../../c-api/module.rst:335 msgid "" "Specifies a function that is called to *execute* the module. This is " "equivalent to executing the code of a Python module: typically, this " @@ -451,61 +379,61 @@ msgid "" "function is:" msgstr "" -#: ../../c-api/module.rst:404 +#: ../../c-api/module.rst:344 msgid "" "If multiple ``Py_mod_exec`` slots are specified, they are processed in the " "order they appear in the *m_slots* array." msgstr "" -#: ../../c-api/module.rst:409 ../../c-api/module.rst:442 +#: ../../c-api/module.rst:351 ../../c-api/module.rst:384 msgid "Specifies one of the following values:" msgstr "" -#: ../../c-api/module.rst:415 +#: ../../c-api/module.rst:357 msgid "The module does not support being imported in subinterpreters." msgstr "" -#: ../../c-api/module.rst:419 +#: ../../c-api/module.rst:361 msgid "" "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:425 +#: ../../c-api/module.rst:367 msgid "" "The module supports being imported in subinterpreters, even when they have " "their own GIL. (See :ref:`isolating-extensions-howto`.)" msgstr "" -#: ../../c-api/module.rst:429 +#: ../../c-api/module.rst:371 msgid "" "This slot determines whether or not importing this module in a " "subinterpreter will fail." msgstr "" -#: ../../c-api/module.rst:432 +#: ../../c-api/module.rst:374 msgid "" "Multiple ``Py_mod_multiple_interpreters`` slots may not be specified in one " "module definition." msgstr "" -#: ../../c-api/module.rst:435 +#: ../../c-api/module.rst:377 msgid "" "If ``Py_mod_multiple_interpreters`` is not specified, the import machinery " "defaults to ``Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED``." msgstr "" -#: ../../c-api/module.rst:448 +#: ../../c-api/module.rst:390 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:453 +#: ../../c-api/module.rst:395 msgid "The module is safe to run without an active GIL." msgstr "" -#: ../../c-api/module.rst:455 +#: ../../c-api/module.rst:397 msgid "" "This slot is ignored by Python builds not configured with :option:`--disable-" "gil`. Otherwise, it determines whether or not importing this module will " @@ -513,41 +441,64 @@ msgid "" "threaded-cpython` for more detail." msgstr "" -#: ../../c-api/module.rst:460 +#: ../../c-api/module.rst:402 msgid "" "Multiple ``Py_mod_gil`` slots may not be specified in one module definition." msgstr "" -#: ../../c-api/module.rst:462 +#: ../../c-api/module.rst:404 msgid "" "If ``Py_mod_gil`` is not specified, the import machinery defaults to " "``Py_MOD_GIL_USED``." msgstr "" -#: ../../c-api/module.rst:467 -msgid "See :PEP:`489` for more details on multi-phase initialization." -msgstr "更多關於多階段初始化的詳細資訊,請參閱 :pep:`489`。" +#: ../../c-api/module.rst:413 +msgid "Creating extension modules dynamically" +msgstr "" + +#: ../../c-api/module.rst:415 +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 `." +msgstr "" -#: ../../c-api/module.rst:470 -msgid "Low-level module creation functions" +#: ../../c-api/module.rst:422 +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:" +"macro:`PYTHON_API_VERSION`, or to :c:macro:`PYTHON_ABI_VERSION` if using " +"the :ref:`limited API `." msgstr "" -#: ../../c-api/module.rst:472 +#: ../../c-api/module.rst:430 msgid "" -"The following functions are called under the hood when using multi-phase " -"initialization. They can be used directly, for example when creating module " -"objects dynamically. Note that both ``PyModule_FromDefAndSpec`` and " -"``PyModule_ExecDef`` must be called to fully initialize a module." +"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:479 +#: ../../c-api/module.rst:436 msgid "" -"Create a new module object, given the definition in *def* and the ModuleSpec " -"*spec*. This behaves like :c:func:`PyModule_FromDefAndSpec2` with " -"*module_api_version* set to :c:macro:`PYTHON_API_VERSION`." +"This function does not support slots. The :c:member:`~PyModuleDef.m_slots` " +"member of *def* must be ``NULL``." msgstr "" -#: ../../c-api/module.rst:487 +#: ../../c-api/module.rst:442 +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:447 +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:456 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 " @@ -555,64 +506,66 @@ msgid "" "emitted." msgstr "" -#: ../../c-api/module.rst:496 +#: ../../c-api/module.rst:463 +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:469 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:503 +#: ../../c-api/module.rst:476 msgid "Process any execution slots (:c:data:`Py_mod_exec`) given in *def*." msgstr "" -#: ../../c-api/module.rst:509 -msgid "" -"Set the docstring for *module* to *docstring*. This function is called " -"automatically when creating a module from ``PyModuleDef``, using either " -"``PyModule_Create`` or ``PyModule_FromDefAndSpec``." +#: ../../c-api/module.rst:482 +msgid "The C API version. Defined for backwards compatibility." msgstr "" -#: ../../c-api/module.rst:518 +#: ../../c-api/module.rst:484 ../../c-api/module.rst:491 msgid "" -"Add the functions from the ``NULL`` terminated *functions* array to " -"*module*. Refer to the :c:type:`PyMethodDef` documentation for details on " -"individual entries (due to the lack of a shared module namespace, module " -"level \"functions\" implemented in C typically receive the module as their " -"first parameter, making them similar to instance methods on Python classes). " -"This function is called automatically when creating a module from " -"``PyModuleDef``, using either ``PyModule_Create`` or " -"``PyModule_FromDefAndSpec``." +"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:530 +#: ../../c-api/module.rst:489 +msgid "Defined as ``3`` for backwards compatibility." +msgstr "" + +#: ../../c-api/module.rst:496 msgid "Support functions" msgstr "支援的函式" -#: ../../c-api/module.rst:532 +#: ../../c-api/module.rst:498 msgid "" -"The module initialization function (if using single phase initialization) or " -"a function called from a module execution slot (if using multi-phase " -"initialization), can use the following functions to help initialize the " -"module state:" +"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 " +"initialization function for legacy :ref:`single-phase initialization `, or code that creates modules dynamically." msgstr "" -#: ../../c-api/module.rst:539 +#: ../../c-api/module.rst:506 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:542 +#: ../../c-api/module.rst:509 msgid "" "On success, return ``0``. On error, raise an exception and return ``-1``." msgstr "" -#: ../../c-api/module.rst:544 ../../c-api/module.rst:595 -#: ../../c-api/module.rst:622 +#: ../../c-api/module.rst:511 ../../c-api/module.rst:562 +#: ../../c-api/module.rst:589 msgid "Example usage::" msgstr "用法範例: ::" -#: ../../c-api/module.rst:546 +#: ../../c-api/module.rst:513 msgid "" "static int\n" "add_spam(PyObject *module, int value)\n" @@ -638,20 +591,20 @@ msgstr "" " return res;\n" " }" -#: ../../c-api/module.rst:558 +#: ../../c-api/module.rst:525 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:562 +#: ../../c-api/module.rst:529 msgid "" "The example can also be written without checking explicitly if *obj* is " "``NULL``::" msgstr "" -#: ../../c-api/module.rst:565 +#: ../../c-api/module.rst:532 msgid "" "static int\n" "add_spam(PyObject *module, int value)\n" @@ -671,13 +624,13 @@ msgstr "" " return res;\n" " }" -#: ../../c-api/module.rst:574 +#: ../../c-api/module.rst:541 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:577 +#: ../../c-api/module.rst:544 msgid "" "The number of different *name* strings passed to this function should be " "kept small, usually by only using statically allocated strings as *name*. " @@ -687,7 +640,7 @@ msgid "" "internally to create a key object." msgstr "" -#: ../../c-api/module.rst:590 +#: ../../c-api/module.rst:557 msgid "" "Similar to :c:func:`PyModule_AddObjectRef`, but \"steals\" a reference to " "*value*. It can be called with a result of function that returns a new " @@ -695,39 +648,44 @@ msgid "" "variable." msgstr "" -#: ../../c-api/module.rst:597 +#: ../../c-api/module.rst:564 msgid "" "if (PyModule_Add(module, \"spam\", PyBytes_FromString(value)) < 0) {\n" " goto error;\n" "}" msgstr "" +"if (PyModule_Add(module, \"spam\", PyBytes_FromString(value)) < 0) {\n" +" goto error;\n" +"}" -#: ../../c-api/module.rst:606 +#: ../../c-api/module.rst:573 msgid "" "Similar to :c:func:`PyModule_AddObjectRef`, but steals a reference to " "*value* on success (if it returns ``0``)." msgstr "" +"類似於 :c:func:`PyModule_AddObjectRef`,但在成功時(如果回傳 ``0``)會偷走對 " +"*value* 的參照。" -#: ../../c-api/module.rst:609 +#: ../../c-api/module.rst:576 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:616 +#: ../../c-api/module.rst:583 msgid "" "Unlike other functions that steal references, ``PyModule_AddObject()`` only " "releases the reference to *value* **on success**." msgstr "" -#: ../../c-api/module.rst:619 +#: ../../c-api/module.rst:586 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:624 +#: ../../c-api/module.rst:591 msgid "" "PyObject *obj = PyBytes_FromString(value);\n" "if (PyModule_AddObject(module, \"spam\", obj) < 0) {\n" @@ -741,24 +699,25 @@ msgid "" "// Py_XDECREF(obj) is not needed here." msgstr "" -#: ../../c-api/module.rst:637 +#: ../../c-api/module.rst:604 msgid ":c:func:`PyModule_AddObject` is :term:`soft deprecated`." msgstr "" +":c:func:`PyModule_AddObject` 已被\\ :term:`軟性棄用 `。" -#: ../../c-api/module.rst:642 +#: ../../c-api/module.rst:609 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:646 +#: ../../c-api/module.rst:613 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:652 +#: ../../c-api/module.rst:619 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 " @@ -766,14 +725,14 @@ msgid "" "on success." msgstr "" -#: ../../c-api/module.rst:657 +#: ../../c-api/module.rst:624 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:664 +#: ../../c-api/module.rst:631 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 " @@ -781,11 +740,11 @@ msgid "" "with an exception set on error, ``0`` on success." msgstr "" -#: ../../c-api/module.rst:672 +#: ../../c-api/module.rst:639 msgid "Add a string constant to *module*." msgstr "將字串常數加入到 *module* 中。" -#: ../../c-api/module.rst:676 +#: ../../c-api/module.rst:643 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 " @@ -793,36 +752,70 @@ msgid "" "``-1`` with an exception set on error, ``0`` on success." msgstr "" -#: ../../c-api/module.rst:686 +#: ../../c-api/module.rst:653 +msgid "" +"Add the functions from the ``NULL`` terminated *functions* array to " +"*module*. Refer to the :c:type:`PyMethodDef` documentation for details on " +"individual entries (due to the lack of a shared module namespace, module " +"level \"functions\" implemented in C typically receive the module as their " +"first parameter, making them similar to instance methods on Python classes)." +msgstr "" + +#: ../../c-api/module.rst:659 +msgid "" +"This function is called automatically when creating a module from " +"``PyModuleDef`` (such as when using :ref:`multi-phase-initialization`, " +"``PyModule_Create``, or ``PyModule_FromDefAndSpec``). Some module authors " +"may prefer defining functions in multiple :c:type:`PyMethodDef` arrays; in " +"that case they should call this function directly." +msgstr "" + +#: ../../c-api/module.rst:666 +msgid "" +"The *functions* array must be statically allocated (or otherwise guaranteed " +"to outlive the module object)." +msgstr "" + +#: ../../c-api/module.rst:673 +msgid "" +"Set the docstring for *module* to *docstring*. This function is called " +"automatically when creating a module from ``PyModuleDef`` (such as when " +"using :ref:`multi-phase-initialization`, ``PyModule_Create``, or " +"``PyModule_FromDefAndSpec``)." +msgstr "" + +#: ../../c-api/module.rst:682 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`. " -"It must be called during *module*'s initialization function. If this " -"function is not called during module initialization, the import machinery " -"assumes the module does not support running without the GIL. This function " -"is only available in Python builds configured with :option:`--disable-gil`. " -"Return ``-1`` with an exception set on error, ``0`` on success." +"It must be called during *module*'s initialization function when using :ref:" +"`single-phase-initialization`. If this function is not called during module " +"initialization, the import machinery assumes the module does not support " +"running without the GIL. This function is only available in Python builds " +"configured with :option:`--disable-gil`. Return ``-1`` with an exception set " +"on error, ``0`` on success." msgstr "" -#: ../../c-api/module.rst:699 -msgid "Module lookup" -msgstr "模組查找" +#: ../../c-api/module.rst:696 +msgid "Module lookup (single-phase initialization)" +msgstr "" -#: ../../c-api/module.rst:701 +#: ../../c-api/module.rst:698 msgid "" -"Single-phase initialization creates singleton modules that can be looked up " -"in the context of the current interpreter. This allows the module object to " -"be retrieved later with only a reference to the module definition." +"The legacy :ref:`single-phase initialization ` " +"initialization scheme creates singleton modules that can be looked up in the " +"context of the current interpreter. This allows the module object to be " +"retrieved later with only a reference to the module definition." msgstr "" -#: ../../c-api/module.rst:705 +#: ../../c-api/module.rst:703 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:710 +#: ../../c-api/module.rst:708 msgid "" "Returns the module object that was created from *def* for the current " "interpreter. This method requires that the module object has been attached " @@ -831,20 +824,21 @@ msgid "" "to the interpreter state yet, it returns ``NULL``." msgstr "" -#: ../../c-api/module.rst:717 +#: ../../c-api/module.rst:715 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:720 +#: ../../c-api/module.rst:718 msgid "Only effective on modules created using single-phase initialization." msgstr "" -#: ../../c-api/module.rst:722 +#: ../../c-api/module.rst:720 msgid "" -"Python calls ``PyState_AddModule`` automatically after importing a module, " +"Python calls ``PyState_AddModule`` automatically after importing a module " +"that uses :ref:`single-phase initialization `, " "so it is unnecessary (but harmless) to call it from module initialization " "code. An explicit call is needed only if the module's own init code " "subsequently calls ``PyState_FindModule``. The function is mainly intended " @@ -853,15 +847,21 @@ msgid "" "state updates)." msgstr "" -#: ../../c-api/module.rst:730 ../../c-api/module.rst:741 -msgid "The caller must hold the GIL." +#: ../../c-api/module.rst:729 +msgid "" +"If a module was attached previously using the same *def*, it is replaced by " +"the new *module*." +msgstr "" + +#: ../../c-api/module.rst:732 ../../c-api/module.rst:743 +msgid "The caller must have an :term:`attached thread state`." msgstr "" -#: ../../c-api/module.rst:732 +#: ../../c-api/module.rst:734 msgid "Return ``-1`` with an exception set on error, ``0`` on success." msgstr "成功時回傳 ``0``,在失敗時回傳 ``-1`` 並設定例外。" -#: ../../c-api/module.rst:738 +#: ../../c-api/module.rst:740 msgid "" "Removes the module object created from *def* from the interpreter state. " "Return ``-1`` with an exception set on error, ``0`` on success." @@ -879,7 +879,7 @@ msgstr "module(模組)" msgid "ModuleType (in module types)" msgstr "MethodType(types 模組中)" -#: ../../c-api/module.rst:33 ../../c-api/module.rst:77 +#: ../../c-api/module.rst:33 ../../c-api/module.rst:80 msgid "__name__ (module attribute)" msgstr "__name__(模組屬性)" @@ -887,7 +887,7 @@ msgstr "__name__(模組屬性)" msgid "__doc__ (module attribute)" msgstr "__doc__(模組屬性)" -#: ../../c-api/module.rst:33 ../../c-api/module.rst:108 +#: ../../c-api/module.rst:33 ../../c-api/module.rst:119 msgid "__file__ (module attribute)" msgstr "__file__(模組屬性)" @@ -903,6 +903,6 @@ msgstr "__loader__(模組屬性)" msgid "__dict__ (module attribute)" msgstr "__dict__(模組屬性)" -#: ../../c-api/module.rst:77 ../../c-api/module.rst:108 +#: ../../c-api/module.rst:80 ../../c-api/module.rst:119 msgid "SystemError (built-in exception)" msgstr "SystemError(內建例外)" diff --git a/c-api/monitoring.po b/c-api/monitoring.po index ac7e58b853e..8c2bc0c80c4 100644 --- a/c-api/monitoring.po +++ b/c-api/monitoring.po @@ -1,12 +1,12 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # #, fuzzy msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-03-20 00:14+0000\n" +"POT-Creation-Date: 2025-11-05 00:16+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -106,67 +106,71 @@ msgid "Fire a ``JUMP`` event." msgstr "發出一個 ``JUMP`` 事件。" #: ../../c-api/monitoring.rst:80 -msgid "Fire a ``BRANCH`` event." -msgstr "發出一個 ``BRANCH`` 事件。" +msgid "Fire a ``BRANCH_LEFT`` event." +msgstr "發出一個 ``BRANCH_LEFT`` 事件。" #: ../../c-api/monitoring.rst:85 +msgid "Fire a ``BRANCH_RIGHT`` event." +msgstr "發出一個 ``BRANCH_RIGHT`` 事件。" + +#: ../../c-api/monitoring.rst:90 msgid "Fire a ``C_RETURN`` event." msgstr "發出一個 ``C_RETURN`` 事件。" -#: ../../c-api/monitoring.rst:90 +#: ../../c-api/monitoring.rst:95 msgid "" "Fire a ``PY_THROW`` event with the current exception (as returned by :c:func:" "`PyErr_GetRaisedException`)." msgstr "" -#: ../../c-api/monitoring.rst:96 +#: ../../c-api/monitoring.rst:101 msgid "" "Fire a ``RAISE`` event with the current exception (as returned by :c:func:" "`PyErr_GetRaisedException`)." msgstr "" -#: ../../c-api/monitoring.rst:102 +#: ../../c-api/monitoring.rst:107 msgid "" "Fire a ``C_RAISE`` event with the current exception (as returned by :c:func:" "`PyErr_GetRaisedException`)." msgstr "" -#: ../../c-api/monitoring.rst:108 +#: ../../c-api/monitoring.rst:113 msgid "" "Fire a ``RERAISE`` event with the current exception (as returned by :c:func:" "`PyErr_GetRaisedException`)." msgstr "" -#: ../../c-api/monitoring.rst:114 +#: ../../c-api/monitoring.rst:119 msgid "" "Fire an ``EXCEPTION_HANDLED`` event with the current exception (as returned " "by :c:func:`PyErr_GetRaisedException`)." msgstr "" -#: ../../c-api/monitoring.rst:120 +#: ../../c-api/monitoring.rst:125 msgid "" "Fire a ``PY_UNWIND`` event with the current exception (as returned by :c:" "func:`PyErr_GetRaisedException`)." msgstr "" -#: ../../c-api/monitoring.rst:126 +#: ../../c-api/monitoring.rst:131 msgid "" "Fire a ``STOP_ITERATION`` event. If ``value`` is an instance of :exc:" "`StopIteration`, it is used. Otherwise, a new :exc:`StopIteration` instance " "is created with ``value`` as its argument." msgstr "" -#: ../../c-api/monitoring.rst:131 +#: ../../c-api/monitoring.rst:136 msgid "Managing the Monitoring State" msgstr "" -#: ../../c-api/monitoring.rst:133 +#: ../../c-api/monitoring.rst:138 msgid "" "Monitoring states can be managed with the help of monitoring scopes. A scope " -"would typically correspond to a python function." +"would typically correspond to a Python function." msgstr "" -#: ../../c-api/monitoring.rst:138 +#: ../../c-api/monitoring.rst:143 msgid "" "Enter a monitored scope. ``event_types`` is an array of the event IDs for " "events that may be fired from the scope. For example, the ID of a " @@ -179,7 +183,7 @@ msgid "" "``state_array``) is given in ``length``." msgstr "" -#: ../../c-api/monitoring.rst:148 +#: ../../c-api/monitoring.rst:153 msgid "" "The ``version`` argument is a pointer to a value which should be allocated " "by the user together with ``state_array`` and initialized to 0, and then set " @@ -188,7 +192,7 @@ msgid "" "to return quickly if they have not." msgstr "" -#: ../../c-api/monitoring.rst:154 +#: ../../c-api/monitoring.rst:159 msgid "" "The scopes referred to here are lexical scopes: a function, class or " "method. :c:func:`!PyMonitoring_EnterScope` should be called whenever the " @@ -198,97 +202,101 @@ msgid "" "emulating a generator, the scope needs to be exited and re-entered." msgstr "" -#: ../../c-api/monitoring.rst:161 +#: ../../c-api/monitoring.rst:166 msgid "The macros for *event_types* are:" msgstr "*event_types* 的巨集有:" -#: ../../c-api/monitoring.rst:169 +#: ../../c-api/monitoring.rst:174 msgid "Macro" msgstr "巨集" -#: ../../c-api/monitoring.rst:169 +#: ../../c-api/monitoring.rst:174 msgid "Event" msgstr "事件" -#: ../../c-api/monitoring.rst:171 -msgid ":monitoring-event:`BRANCH`" -msgstr ":monitoring-event:`BRANCH`" +#: ../../c-api/monitoring.rst:176 +msgid ":monitoring-event:`BRANCH_LEFT`" +msgstr ":monitoring-event:`BRANCH_LEFT`" -#: ../../c-api/monitoring.rst:172 +#: ../../c-api/monitoring.rst:177 +msgid ":monitoring-event:`BRANCH_RIGHT`" +msgstr ":monitoring-event:`BRANCH_RIGHT`" + +#: ../../c-api/monitoring.rst:178 msgid ":monitoring-event:`CALL`" msgstr ":monitoring-event:`CALL`" -#: ../../c-api/monitoring.rst:173 +#: ../../c-api/monitoring.rst:179 msgid ":monitoring-event:`C_RAISE`" msgstr ":monitoring-event:`C_RAISE`" -#: ../../c-api/monitoring.rst:174 +#: ../../c-api/monitoring.rst:180 msgid ":monitoring-event:`C_RETURN`" msgstr ":monitoring-event:`C_RETURN`" -#: ../../c-api/monitoring.rst:175 +#: ../../c-api/monitoring.rst:181 msgid ":monitoring-event:`EXCEPTION_HANDLED`" msgstr ":monitoring-event:`EXCEPTION_HANDLED`" -#: ../../c-api/monitoring.rst:176 +#: ../../c-api/monitoring.rst:182 msgid ":monitoring-event:`INSTRUCTION`" msgstr ":monitoring-event:`INSTRUCTION`" -#: ../../c-api/monitoring.rst:177 +#: ../../c-api/monitoring.rst:183 msgid ":monitoring-event:`JUMP`" msgstr ":monitoring-event:`JUMP`" -#: ../../c-api/monitoring.rst:178 +#: ../../c-api/monitoring.rst:184 msgid ":monitoring-event:`LINE`" msgstr ":monitoring-event:`LINE`" -#: ../../c-api/monitoring.rst:179 +#: ../../c-api/monitoring.rst:185 msgid ":monitoring-event:`PY_RESUME`" msgstr ":monitoring-event:`PY_RESUME`" -#: ../../c-api/monitoring.rst:180 +#: ../../c-api/monitoring.rst:186 msgid ":monitoring-event:`PY_RETURN`" msgstr ":monitoring-event:`PY_RETURN`" -#: ../../c-api/monitoring.rst:181 +#: ../../c-api/monitoring.rst:187 msgid ":monitoring-event:`PY_START`" msgstr ":monitoring-event:`PY_START`" -#: ../../c-api/monitoring.rst:182 +#: ../../c-api/monitoring.rst:188 msgid ":monitoring-event:`PY_THROW`" msgstr ":monitoring-event:`PY_THROW`" -#: ../../c-api/monitoring.rst:183 +#: ../../c-api/monitoring.rst:189 msgid ":monitoring-event:`PY_UNWIND`" msgstr ":monitoring-event:`PY_UNWIND`" -#: ../../c-api/monitoring.rst:184 +#: ../../c-api/monitoring.rst:190 msgid ":monitoring-event:`PY_YIELD`" msgstr ":monitoring-event:`PY_YIELD`" -#: ../../c-api/monitoring.rst:185 +#: ../../c-api/monitoring.rst:191 msgid ":monitoring-event:`RAISE`" msgstr ":monitoring-event:`RAISE`" -#: ../../c-api/monitoring.rst:186 +#: ../../c-api/monitoring.rst:192 msgid ":monitoring-event:`RERAISE`" msgstr ":monitoring-event:`RERAISE`" -#: ../../c-api/monitoring.rst:187 +#: ../../c-api/monitoring.rst:193 msgid ":monitoring-event:`STOP_ITERATION`" msgstr ":monitoring-event:`STOP_ITERATION`" -#: ../../c-api/monitoring.rst:192 +#: ../../c-api/monitoring.rst:198 msgid "" "Exit the last scope that was entered with :c:func:`!PyMonitoring_EnterScope`." msgstr "" -#: ../../c-api/monitoring.rst:197 +#: ../../c-api/monitoring.rst:203 msgid "" "Return true if the event corresponding to the event ID *ev* is a :ref:`local " "event `." msgstr "" -#: ../../c-api/monitoring.rst:204 +#: ../../c-api/monitoring.rst:210 msgid "This function is :term:`soft deprecated`." msgstr "" diff --git a/c-api/none.po b/c-api/none.po index 2a360b0167b..675650b0201 100644 --- a/c-api/none.po +++ b/c-api/none.po @@ -1,12 +1,11 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Leon H., 2017 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-23 07:52+0800\n" "PO-Revision-Date: 2018-05-23 14:07+0000\n" diff --git a/c-api/number.po b/c-api/number.po index 83e14a4b313..66d782afb55 100644 --- a/c-api/number.po +++ b/c-api/number.po @@ -1,11 +1,10 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-07-20 00:03+0000\n" "PO-Revision-Date: 2018-05-23 14:07+0000\n" diff --git a/c-api/object.po b/c-api/object.po index 85e8adfd099..5cdde8ebd56 100644 --- a/c-api/object.po +++ b/c-api/object.po @@ -1,13 +1,12 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-01-05 00:15+0000\n" +"POT-Creation-Date: 2025-11-05 00:16+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-" @@ -135,8 +134,8 @@ msgstr "" #: ../../c-api/object.rst:50 msgid "" -"This function is primarily intended for backwards compatibility: " -"using :c:func:`Py_GetConstant` is recommended for new code." +"This function is primarily intended for backwards compatibility: using :c:" +"func:`Py_GetConstant` is recommended for new code." msgstr "" #: ../../c-api/object.rst:53 @@ -154,16 +153,15 @@ msgstr "" #: ../../c-api/object.rst:67 msgid "" "Properly handle returning :c:data:`Py_NotImplemented` from within a C " -"function (that is, create a new :term:`strong reference` " -"to :const:`NotImplemented` and return it)." +"function (that is, create a new :term:`strong reference` to :const:" +"`NotImplemented` and return it)." msgstr "" #: ../../c-api/object.rst:74 msgid "" -"Flag to be used with multiple functions that print the object " -"(like :c:func:`PyObject_Print` and :c:func:`PyFile_WriteObject`). If passed, " -"these function would use the :func:`str` of the object instead of " -"the :func:`repr`." +"Flag to be used with multiple functions that print the object (like :c:func:" +"`PyObject_Print` and :c:func:`PyFile_WriteObject`). If passed, these " +"functions use the :func:`str` of the object instead of the :func:`repr`." msgstr "" #: ../../c-api/object.rst:82 @@ -196,27 +194,26 @@ msgstr "" #: ../../c-api/object.rst:113 msgid "" -"Exceptions that occur when this calls :meth:`~object.__getattr__` " -"and :meth:`~object.__getattribute__` methods aren't propagated, but instead " -"given to :func:`sys.unraisablehook`. For proper error handling, " -"use :c:func:`PyObject_HasAttrWithError`, :c:func:`PyObject_GetOptionalAttr` " -"or :c:func:`PyObject_GetAttr` instead." +"Exceptions that occur when this calls :meth:`~object.__getattr__` and :meth:" +"`~object.__getattribute__` methods aren't propagated, but instead given to :" +"func:`sys.unraisablehook`. For proper error handling, use :c:func:" +"`PyObject_HasAttrWithError`, :c:func:`PyObject_GetOptionalAttr` or :c:func:" +"`PyObject_GetAttr` instead." msgstr "" #: ../../c-api/object.rst:122 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*`." +"as a :c:expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" +"`PyObject*`." msgstr "" #: ../../c-api/object.rst:128 msgid "" -"Exceptions that occur when this calls :meth:`~object.__getattr__` " -"and :meth:`~object.__getattribute__` methods or while creating the " -"temporary :class:`str` object are silently ignored. For proper error " -"handling, " -"use :c:func:`PyObject_HasAttrStringWithError`, :c:func:`PyObject_GetOptionalAttrString` " +"Exceptions that occur when this calls :meth:`~object.__getattr__` and :meth:" +"`~object.__getattribute__` methods or while creating the temporary :class:" +"`str` object are silently ignored. For proper error handling, use :c:func:" +"`PyObject_HasAttrStringWithError`, :c:func:`PyObject_GetOptionalAttrString` " "or :c:func:`PyObject_GetAttrString` instead." msgstr "" @@ -229,37 +226,36 @@ msgstr "" #: ../../c-api/object.rst:142 msgid "" -"If the missing attribute should not be treated as a failure, you can " -"use :c:func:`PyObject_GetOptionalAttr` instead." +"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 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*`." +"as a :c:expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" +"`PyObject*`." msgstr "" #: ../../c-api/object.rst:152 msgid "" -"If the missing attribute should not be treated as a failure, you can " -"use :c:func:`PyObject_GetOptionalAttrString` instead." +"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 msgid "" -"Variant of :c:func:`PyObject_GetAttr` which doesn't " -"raise :exc:`AttributeError` if the attribute is not found." +"Variant of :c:func:`PyObject_GetAttr` which doesn't raise :exc:" +"`AttributeError` if the attribute is not found." msgstr "" #: ../../c-api/object.rst:161 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 ``0`` and set *\\*result* to ``NULL``; " -"the :exc:`AttributeError` is silenced. If an error other " -"than :exc:`AttributeError` is raised, return ``-1`` and set *\\*result* to " -"``NULL``." +"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 " +"``0`` and set *\\*result* to ``NULL``; the :exc:`AttributeError` is " +"silenced. If an error other than :exc:`AttributeError` is raised, return " +"``-1`` and set *\\*result* to ``NULL``." msgstr "" #: ../../c-api/object.rst:173 @@ -273,11 +269,10 @@ msgstr "" 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 " -"of classes in the object's MRO as well as an attribute in the " -"object's :attr:`~object.__dict__` (if present). As outlined " -"in :ref:`descriptors`, data descriptors take preference over instance " -"attributes, while non-data descriptors don't. Otherwise, " -"an :exc:`AttributeError` is raised." +"of classes in the object's MRO as well as an attribute in the object's :attr:" +"`~object.__dict__` (if present). As outlined in :ref:`descriptors`, data " +"descriptors take preference over instance attributes, while non-data " +"descriptors don't. Otherwise, an :exc:`AttributeError` is raised." msgstr "" #: ../../c-api/object.rst:191 @@ -297,8 +292,8 @@ msgstr "" #: ../../c-api/object.rst:203 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*`." +"as a :c:expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" +"`PyObject*`." msgstr "" #: ../../c-api/object.rst:207 @@ -311,10 +306,10 @@ msgstr "" 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*. " -"For attribute names that aren't known at compile time, prefer " -"calling :c:func:`PyUnicode_FromString` and :c:func:`PyObject_SetAttr` " -"directly. For more details, see :c:func:`PyUnicode_InternFromString`, which " -"may be used internally to create a key object." +"For attribute names that aren't known at compile time, prefer calling :c:" +"func:`PyUnicode_FromString` and :c:func:`PyObject_SetAttr` directly. For " +"more details, see :c:func:`PyUnicode_InternFromString`, which may be used " +"internally to create a key object." msgstr "" #: ../../c-api/object.rst:220 @@ -338,18 +333,18 @@ msgstr "" #: ../../c-api/object.rst:238 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*`." +"as a :c:expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" +"`PyObject*`." msgstr "" #: ../../c-api/object.rst:242 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*. " -"For attribute names that aren't known at compile time, prefer " -"calling :c:func:`PyUnicode_FromString` and :c:func:`PyObject_DelAttr` " -"directly. For more details, see :c:func:`PyUnicode_InternFromString`, which " -"may be used internally to create a key object for lookup." +"For attribute names that aren't known at compile time, prefer calling :c:" +"func:`PyUnicode_FromString` and :c:func:`PyObject_DelAttr` directly. For " +"more details, see :c:func:`PyUnicode_InternFromString`, which may be used " +"internally to create a key object for lookup." msgstr "" #: ../../c-api/object.rst:253 @@ -393,12 +388,12 @@ msgstr "" #: ../../c-api/object.rst:287 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`, :c:macro:`Py_NE`, :c:macro:`Py_GT`, " -"or :c:macro:`Py_GE`, corresponding to ``<``, ``<=``, ``==``, ``!=``, ``>``, " -"or ``>=`` respectively. This is the equivalent of the Python expression ``o1 " -"op o2``, where ``op`` is the operator corresponding to *opid*. Returns the " -"value of the comparison on success, or ``NULL`` on failure." +"which must be one of :c:macro:`Py_LT`, :c:macro:`Py_LE`, :c:macro:`Py_EQ`, :" +"c:macro:`Py_NE`, :c:macro:`Py_GT`, or :c:macro:`Py_GE`, corresponding to " +"``<``, ``<=``, ``==``, ``!=``, ``>``, or ``>=`` respectively. This is the " +"equivalent of the Python expression ``o1 op o2``, where ``op`` is the " +"operator corresponding to *opid*. Returns the value of the comparison on " +"success, or ``NULL`` on failure." msgstr "" #: ../../c-api/object.rst:297 @@ -444,10 +439,10 @@ msgstr "" #: ../../c-api/object.rst:330 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:`PyObject_Repr` with ``\\x``, ``\\u`` or ``\\U`` escapes. This " -"generates a string similar to that returned by :c:func:`PyObject_Repr` in " -"Python 2. Called by the :func:`ascii` built-in function." +"but escape the non-ASCII characters in the string returned by :c:func:" +"`PyObject_Repr` with ``\\x``, ``\\u`` or ``\\U`` escapes. This generates a " +"string similar to that returned by :c:func:`PyObject_Repr` in Python 2. " +"Called by the :func:`ascii` built-in function." msgstr "" #: ../../c-api/object.rst:341 @@ -484,8 +479,8 @@ msgstr "" msgid "" "If *cls* has a :meth:`~type.__subclasscheck__` method, it will be called to " "determine the subclass status as described in :pep:`3119`. Otherwise, " -"*derived* is a subclass of *cls* if it is a direct or indirect subclass, " -"i.e. contained in :attr:`cls.__mro__ `." +"*derived* is a subclass of *cls* if it is a direct or indirect subclass, i." +"e. contained in :attr:`cls.__mro__ `." msgstr "" #: ../../c-api/object.rst:376 @@ -510,8 +505,8 @@ msgstr "" #: ../../c-api/object.rst:394 msgid "" -"An instance *inst* can override what is considered its class by having " -"a :attr:`~object.__class__` attribute." +"An instance *inst* can override what is considered its class by having a :" +"attr:`~object.__class__` attribute." msgstr "" #: ../../c-api/object.rst:397 @@ -610,9 +605,9 @@ msgstr "" #: ../../c-api/object.rst:498 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*`." +"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:505 @@ -621,8 +616,8 @@ msgid "" "(possibly empty) list of strings appropriate for the object argument, or " "``NULL`` if there was an error. If the argument is ``NULL``, this is like " "the Python ``dir()``, returning the names of the current locals; in this " -"case, if no execution frame is active then ``NULL`` is returned " -"but :c:func:`PyErr_Occurred` will return false." +"case, if no execution frame is active then ``NULL`` is returned but :c:func:" +"`PyErr_Occurred` will return false." msgstr "" #: ../../c-api/object.rst:514 @@ -636,17 +631,17 @@ msgstr "" #: ../../c-api/object.rst:522 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." +"is intended for :term:`iterator` types, to be used in the :c:member:" +"`PyTypeObject.tp_iter` slot." msgstr "" #: ../../c-api/object.rst:528 msgid "" -"This is the equivalent to the Python expression ``aiter(o)``. Takes " -"an :class:`AsyncIterable` object and returns an :class:`AsyncIterator` for " -"it. This is typically a new iterator but if the argument is " -"an :class:`AsyncIterator`, this returns itself. Raises :exc:`TypeError` and " -"returns ``NULL`` if the object cannot be iterated." +"This is the equivalent to the Python expression ``aiter(o)``. Takes an :" +"class:`AsyncIterable` object and returns an :class:`AsyncIterator` for it. " +"This is typically a new iterator but if the argument is an :class:" +"`AsyncIterator`, this returns itself. Raises :exc:`TypeError` and returns " +"``NULL`` if the object cannot be iterated." msgstr "" #: ../../c-api/object.rst:538 @@ -673,14 +668,14 @@ msgstr "" #: ../../c-api/object.rst:553 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`)." +"`; it is safe to use this larger size (e.g. with :c:" +"func:`!memset`)." msgstr "" #: ../../c-api/object.rst:556 msgid "" -"The type *cls* **must** have been created using " -"negative :c:member:`PyType_Spec.basicsize`. Python does not check this." +"The type *cls* **must** have been created using negative :c:member:" +"`PyType_Spec.basicsize`. Python does not check this." msgstr "" #: ../../c-api/object.rst:560 @@ -689,8 +684,8 @@ msgstr "錯誤時設定一個例外並回傳一個負值。" #: ../../c-api/object.rst:566 msgid "" -"Get a pointer to per-item data for a class " -"with :c:macro:`Py_TPFLAGS_ITEMS_AT_END`." +"Get a pointer to per-item data for a class with :c:macro:" +"`Py_TPFLAGS_ITEMS_AT_END`." msgstr "" #: ../../c-api/object.rst:569 @@ -698,14 +693,14 @@ 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." msgstr "" -"錯誤時設定一個例外並回傳 ``NULL``。如果 *o* 沒有設" -"定 :c:macro:`Py_TPFLAGS_ITEMS_AT_END`,則會引發 :py:exc:`TypeError`。" +"錯誤時設定一個例外並回傳 ``NULL``。如果 *o* 沒有設定 :c:macro:" +"`Py_TPFLAGS_ITEMS_AT_END`,則會引發 :py:exc:`TypeError`。" #: ../../c-api/object.rst:577 msgid "Visit the managed dictionary of *obj*." msgstr "" -#: ../../c-api/object.rst:579 ../../c-api/object.rst:588 +#: ../../c-api/object.rst:579 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." @@ -715,6 +710,231 @@ msgstr "" msgid "Clear the managed dictionary of *obj*." msgstr "" +#: ../../c-api/object.rst:588 +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:595 +msgid "" +"Enable `deferred reference counting `_ on *obj*, if supported by the runtime. In " +"the :term:`free-threaded ` build, this allows the " +"interpreter to avoid reference count adjustments to *obj*, which may improve " +"multi-threaded performance. The tradeoff is that *obj* will only be " +"deallocated by the tracing garbage collector, and not when the interpreter " +"no longer has any references to it." +msgstr "" + +#: ../../c-api/object.rst:602 +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 " +"hint was ignored by the interpreter, such as when deferred reference " +"counting is already enabled on *obj*. This function is thread-safe, and " +"cannot fail." +msgstr "" + +#: ../../c-api/object.rst:607 +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 " +"not an object tracked by the garbage collector (see :func:`gc.is_tracked` " +"and :c:func:`PyObject_GC_IsTracked`)." +msgstr "" + +#: ../../c-api/object.rst:612 +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:620 +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 " +"fail, but the check is conservative, and may return ``0`` in some cases even " +"if *obj* is a unique temporary object." +msgstr "" + +#: ../../c-api/object.rst:626 +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 " +"should be used instead of checking if the reference count is ``1``. Starting " +"with Python 3.14, the interpreter internally avoids some reference count " +"modifications when loading objects onto the operands stack by :term:" +"`borrowing ` references when possible, which means that " +"a reference count of ``1`` by itself does not guarantee that a function " +"argument uniquely referenced." +msgstr "" + +#: ../../c-api/object.rst:635 +msgid "" +"In the example below, ``my_func`` is called with a unique temporary object " +"as its argument::" +msgstr "" + +#: ../../c-api/object.rst:638 +msgid "my_func([1, 2, 3])" +msgstr "my_func([1, 2, 3])" + +#: ../../c-api/object.rst:640 +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:643 +msgid "" +"my_list = [1, 2, 3]\n" +"my_func(my_list)" +msgstr "" +"my_list = [1, 2, 3]\n" +"my_func(my_list)" + +#: ../../c-api/object.rst:646 +msgid "See also the function :c:func:`Py_REFCNT`." +msgstr "另請參閱 :c:func:`Py_REFCNT` 函式。" + +#: ../../c-api/object.rst:652 +msgid "" +"This function returns non-zero if *obj* is :term:`immortal`, and zero " +"otherwise. This function cannot fail." +msgstr "" + +#: ../../c-api/object.rst:657 +msgid "" +"Objects that are immortal in one CPython version are not guaranteed to be " +"immortal in another." +msgstr "" + +#: ../../c-api/object.rst:664 +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:668 +msgid "" +":c:func:`PyUnstable_EnableTryIncRef` must have been called earlier on *obj* " +"or this function may spuriously return ``0`` in the :term:`free threading` " +"build." +msgstr "" + +#: ../../c-api/object.rst:672 +msgid "" +"This function is logically equivalent to the following C code, except that " +"it behaves atomically in the :term:`free threading` build::" +msgstr "" + +#: ../../c-api/object.rst:675 +msgid "" +"if (Py_REFCNT(op) > 0) {\n" +" Py_INCREF(op);\n" +" return 1;\n" +"}\n" +"return 0;" +msgstr "" +"if (Py_REFCNT(op) > 0) {\n" +" Py_INCREF(op);\n" +" return 1;\n" +"}\n" +"return 0;" + +#: ../../c-api/object.rst:681 +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:684 +msgid "" +"Typically, correct use of this function requires support from *obj*'s " +"deallocator (:c:member:`~PyTypeObject.tp_dealloc`). For example, the " +"following sketch could be adapted to implement a \"weakmap\" that works like " +"a :py:class:`~weakref.WeakValueDictionary` for a specific type:" +msgstr "" + +#: ../../c-api/object.rst:690 +msgid "" +"PyMutex mutex;\n" +"\n" +"PyObject *\n" +"add_entry(weakmap_key_type *key, PyObject *value)\n" +"{\n" +" PyUnstable_EnableTryIncRef(value);\n" +" weakmap_type weakmap = ...;\n" +" PyMutex_Lock(&mutex);\n" +" weakmap_add_entry(weakmap, key, value);\n" +" PyMutex_Unlock(&mutex);\n" +" Py_RETURN_NONE;\n" +"}\n" +"\n" +"PyObject *\n" +"get_value(weakmap_key_type *key)\n" +"{\n" +" weakmap_type weakmap = ...;\n" +" PyMutex_Lock(&mutex);\n" +" PyObject *result = weakmap_find(weakmap, key);\n" +" if (PyUnstable_TryIncRef(result)) {\n" +" // `result` is safe to use\n" +" PyMutex_Unlock(&mutex);\n" +" return result;\n" +" }\n" +" // if we get here, `result` is starting to be garbage-collected,\n" +" // but has not been removed from the weakmap yet\n" +" PyMutex_Unlock(&mutex);\n" +" return NULL;\n" +"}\n" +"\n" +"// tp_dealloc function for weakmap values\n" +"void\n" +"value_dealloc(PyObject *value)\n" +"{\n" +" weakmap_type weakmap = ...;\n" +" PyMutex_Lock(&mutex);\n" +" weakmap_remove_value(weakmap, value);\n" +"\n" +" ...\n" +" PyMutex_Unlock(&mutex);\n" +"}" +msgstr "" + +#: ../../c-api/object.rst:738 +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:745 +msgid "Determine if *op* only has one reference." +msgstr "" + +#: ../../c-api/object.rst:747 +msgid "" +"On GIL-enabled builds, this function is equivalent to :c:expr:`Py_REFCNT(op) " +"== 1`." +msgstr "" + +#: ../../c-api/object.rst:750 +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 thread. :c:expr:`Py_REFCNT(op) == 1` is **not** thread-" +"safe on free threaded builds; prefer this function." +msgstr "" + +#: ../../c-api/object.rst:755 +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:328 #: ../../c-api/object.rst:353 ../../c-api/object.rst:404 #: ../../c-api/object.rst:438 ../../c-api/object.rst:459 diff --git a/c-api/objimpl.po b/c-api/objimpl.po index b468c229482..e01909fd1f9 100644 --- a/c-api/objimpl.po +++ b/c-api/objimpl.po @@ -1,11 +1,10 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2018-06-26 18:54+0800\n" "PO-Revision-Date: 2025-07-14 02:51+0000\n" diff --git a/c-api/perfmaps.po b/c-api/perfmaps.po index ee98fd31d11..026a9131c84 100644 --- a/c-api/perfmaps.po +++ b/c-api/perfmaps.po @@ -1,13 +1,13 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Matt Wang , 2024 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-07-17 17:39+0800\n" +"POT-Creation-Date: 2025-09-08 15:25+0800\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-" @@ -25,12 +25,12 @@ msgstr "對 Perf Map 的支援" 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`` " +"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 `_." +"Perf tool `_." msgstr "" "在支援的平台上(截至撰寫本文時,僅限 Linux),runtime 可以利用 *perf map 檔案" "*\\ 使得外部分析工具(例如 `perf , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Python 3.14\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-11-17 00:14+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/picklebuffer.rst:9 +msgid "Pickle buffer objects" +msgstr "" + +#: ../../c-api/picklebuffer.rst:13 +msgid "" +"A :class:`pickle.PickleBuffer` object wraps a :ref:`buffer-providing object " +"` for out-of-band data transfer with the :mod:`pickle` module." +msgstr "" + +#: ../../c-api/picklebuffer.rst:19 +msgid "" +"This instance of :c:type:`PyTypeObject` represents the Python pickle buffer " +"type. This is the same object as :class:`pickle.PickleBuffer` in the Python " +"layer." +msgstr "" + +#: ../../c-api/picklebuffer.rst:25 +msgid "" +"Return true if *op* is a pickle buffer instance. This function always " +"succeeds." +msgstr "" + +#: ../../c-api/picklebuffer.rst:31 +msgid "Create a pickle buffer from the object *obj*." +msgstr "" + +#: ../../c-api/picklebuffer.rst:33 +msgid "" +"This function will fail if *obj* doesn't support the :ref:`buffer protocol " +"`." +msgstr "" + +#: ../../c-api/picklebuffer.rst:35 +msgid "" +"On success, return a new pickle buffer instance. On failure, set an " +"exception and return ``NULL``." +msgstr "" + +#: ../../c-api/picklebuffer.rst:38 +msgid "Analogous to calling :class:`pickle.PickleBuffer` with *obj* in Python." +msgstr "" + +#: ../../c-api/picklebuffer.rst:43 +msgid "" +"Get a pointer to the underlying :c:type:`Py_buffer` that the pickle buffer " +"wraps." +msgstr "" + +#: ../../c-api/picklebuffer.rst:45 +msgid "" +"The returned pointer is valid as long as *picklebuf* is alive and has not " +"been released. The caller must not modify or free the returned :c:type:" +"`Py_buffer`. If the pickle buffer has been released, raise :exc:`ValueError`." +msgstr "" + +#: ../../c-api/picklebuffer.rst:49 +msgid "" +"On success, return a pointer to the buffer view. On failure, set an " +"exception and return ``NULL``." +msgstr "" + +#: ../../c-api/picklebuffer.rst:55 +msgid "Release the underlying buffer held by the pickle buffer." +msgstr "" + +#: ../../c-api/picklebuffer.rst:57 +msgid "" +"Return ``0`` on success. On failure, set an exception and return ``-1``." +msgstr "" + +#: ../../c-api/picklebuffer.rst:59 +msgid "Analogous to calling :meth:`pickle.PickleBuffer.release` in Python." +msgstr "" + +#: ../../c-api/picklebuffer.rst:5 +msgid "object" +msgstr "" + +#: ../../c-api/picklebuffer.rst:5 +msgid "PickleBuffer" +msgstr "" diff --git a/c-api/refcounting.po b/c-api/refcounting.po index ddee8b5b89a..3ad5095d4d8 100644 --- a/c-api/refcounting.po +++ b/c-api/refcounting.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -6,9 +6,9 @@ # Matt Wang , 2023 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"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: 2025-09-08 15:25+0800\n" "PO-Revision-Date: 2023-08-06 14:19+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -37,51 +37,66 @@ msgstr "取得物件 *o* 的參照計數。" #: ../../c-api/refcounting.rst:18 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:" -"`immortal` and have a very high refcount that does not reflect the actual " -"number of references. Consequently, do not rely on the returned value to be " -"accurate, other than a value of 0 or 1." +"the object are actually held. For example, some objects " +"are :term:`immortal` and have a very high refcount that does not reflect the " +"actual number of references. Consequently, do not rely on the returned " +"value to be accurate, other than a value of 0 or 1." msgstr "" "請注意,回傳的值可能實際上並不反映實際保存了多少對該物件的參照。例如,某些物" -"件是「:term:`不滅的 (immortal) `」,並且具有非常高的參照計" -"數,不能反映實際的參照數量。因此,除了 0 或 1 以外,不要依賴回傳值的準確性。" +"件是「:term:`不滅的 (immortal) `」,並且具有非常高的參照計數,不能" +"反映實際的參照數量。因此,除了 0 或 1 以外,不要依賴回傳值的準確性。" #: ../../c-api/refcounting.rst:24 msgid "" "Use the :c:func:`Py_SET_REFCNT()` function to set an object reference count." msgstr "使用 :c:func:`Py_SET_REFCNT()` 函式設定物件參照計數。" -#: ../../c-api/refcounting.rst:26 +#: ../../c-api/refcounting.rst:28 +msgid "" +"On :term:`free threaded ` builds of Python, returning 1 " +"isn't sufficient to determine if it's safe to treat *o* as having no access " +"by other threads. Use :c:func:`PyUnstable_Object_IsUniquelyReferenced` for " +"that instead." +msgstr "" + +#: ../../c-api/refcounting.rst:33 +msgid "" +"See also the " +"function :c:func:`PyUnstable_Object_IsUniqueReferencedTemporary()`." +msgstr "" + +#: ../../c-api/refcounting.rst:35 msgid ":c:func:`Py_REFCNT()` is changed to the inline static function." msgstr ":c:func:`Py_REFCNT()` 更改為行內靜態函式 (inline static function)。" -#: ../../c-api/refcounting.rst:29 +#: ../../c-api/refcounting.rst:38 msgid "The parameter type is no longer :c:expr:`const PyObject*`." msgstr "參數型別不再是 :c:expr:`const PyObject*`。" -#: ../../c-api/refcounting.rst:35 +#: ../../c-api/refcounting.rst:44 msgid "Set the object *o* reference counter to *refcnt*." msgstr "設定物件 *o* 的參照計數。" -#: ../../c-api/refcounting.rst:37 +#: ../../c-api/refcounting.rst:46 msgid "" "On :ref:`Python build with Free Threading `, if " "*refcnt* is larger than ``UINT32_MAX``, the object is made :term:`immortal`." msgstr "" "在\\ :ref:`啟用自由執行緒的 Python 建置 `\\ 中,如果 " -"*refcnt* 大於 ``UINT32_MAX``,則該物件會被設為\\ :term:`不滅的 (immortal) `。" +"*refcnt* 大於 ``UINT32_MAX``,則該物件會被設為\\ :term:`不滅的 (immortal) " +"`。" -#: ../../c-api/refcounting.rst:40 ../../c-api/refcounting.rst:53 -#: ../../c-api/refcounting.rst:119 +#: ../../c-api/refcounting.rst:49 ../../c-api/refcounting.rst:62 +#: ../../c-api/refcounting.rst:128 msgid "This function has no effect on :term:`immortal` objects." msgstr "請注意,此函式對\\ :term:`不滅的 `\\ 物件沒有影響。" -#: ../../c-api/refcounting.rst:44 ../../c-api/refcounting.rst:68 -#: ../../c-api/refcounting.rst:147 +#: ../../c-api/refcounting.rst:53 ../../c-api/refcounting.rst:77 +#: ../../c-api/refcounting.rst:156 msgid "Immortal objects are not modified." msgstr "不滅的物件不會被修改。" -#: ../../c-api/refcounting.rst:50 +#: ../../c-api/refcounting.rst:59 msgid "" "Indicate taking a new :term:`strong reference` to object *o*, indicating it " "is in use and should not be destroyed." @@ -89,37 +104,37 @@ msgstr "" "代表取得對於物件 *o* 的新\\ :term:`強參照 `,即它正在使用且" "不應被銷毀。" -#: ../../c-api/refcounting.rst:55 +#: ../../c-api/refcounting.rst:64 msgid "" -"This function is usually used to convert a :term:`borrowed reference` to a :" -"term:`strong reference` in-place. The :c:func:`Py_NewRef` function can be " +"This function is usually used to convert a :term:`borrowed reference` to " +"a :term:`strong reference` in-place. The :c:func:`Py_NewRef` function can be " "used to create a new :term:`strong reference`." msgstr "" "此函式通常用於將\\ :term:`借用參照 `\\ 原地 (in-place) 轉" "換為\\ :term:`強參照 `。:c:func:`Py_NewRef` 函式可用於建立" "新的\\ :term:`強參照 `。" -#: ../../c-api/refcounting.rst:59 +#: ../../c-api/refcounting.rst:68 msgid "When done using the object, release is by calling :c:func:`Py_DECREF`." msgstr "使用完該物件後,透過呼叫 :c:func:`Py_DECREF` 來釋放它。" -#: ../../c-api/refcounting.rst:61 +#: ../../c-api/refcounting.rst:70 msgid "" "The object must not be ``NULL``; if you aren't sure that it isn't ``NULL``, " "use :c:func:`Py_XINCREF`." msgstr "" -"該物件不能為 ``NULL``;如果你不確定它不是 ``NULL``,請使用 :c:func:" -"`Py_XINCREF`。" +"該物件不能為 ``NULL``;如果你不確定它不是 ``NULL``,請使" +"用 :c:func:`Py_XINCREF`。" -#: ../../c-api/refcounting.rst:64 +#: ../../c-api/refcounting.rst:73 msgid "" -"Do not expect this function to actually modify *o* in any way. For at least :" -"pep:`some objects <0683>`, this function has no effect." +"Do not expect this function to actually modify *o* in any way. For at " +"least :pep:`some objects <0683>`, this function has no effect." msgstr "" "不要期望此函式會以任何方式實際修改 *o*,至少對於\\ :pep:`某些物件 <0683>`\\ " "來說,此函式沒有任何效果。" -#: ../../c-api/refcounting.rst:74 +#: ../../c-api/refcounting.rst:83 msgid "" "Similar to :c:func:`Py_INCREF`, but the object *o* can be ``NULL``, in which " "case this has no effect." @@ -127,39 +142,39 @@ msgstr "" "與 :c:func:`Py_INCREF` 類似,但物件 *o* 可以為 ``NULL``,在這種情況下這就不會" "有任何效果。" -#: ../../c-api/refcounting.rst:77 +#: ../../c-api/refcounting.rst:86 msgid "See also :c:func:`Py_XNewRef`." msgstr "另請見 :c:func:`Py_XNewRef`。" -#: ../../c-api/refcounting.rst:82 +#: ../../c-api/refcounting.rst:91 msgid "" "Create a new :term:`strong reference` to an object: call :c:func:`Py_INCREF` " "on *o* and return the object *o*." msgstr "" -"建立對物件的新\\ :term:`強參照 `:於 *o* 呼叫 :c:func:" -"`Py_INCREF` 並回傳物件 *o*。" +"建立對物件的新\\ :term:`強參照 `:於 *o* 呼" +"叫 :c:func:`Py_INCREF` 並回傳物件 *o*。" -#: ../../c-api/refcounting.rst:85 +#: ../../c-api/refcounting.rst:94 msgid "" "When the :term:`strong reference` is no longer needed, :c:func:`Py_DECREF` " "should be called on it to release the reference." msgstr "" -"當不再需要\\ :term:`強參照 `\\ 時,應對其呼叫 :c:func:" -"`Py_DECREF` 以釋放該參照。" +"當不再需要\\ :term:`強參照 `\\ 時,應對其呼" +"叫 :c:func:`Py_DECREF` 以釋放該參照。" -#: ../../c-api/refcounting.rst:88 +#: ../../c-api/refcounting.rst:97 msgid "" "The object *o* must not be ``NULL``; use :c:func:`Py_XNewRef` if *o* can be " "``NULL``." msgstr "" -"物件 *o* 不能為 ``NULL``;如果 *o* 可以為 ``NULL``,則使用 :c:func:" -"`Py_XNewRef`。" +"物件 *o* 不能為 ``NULL``;如果 *o* 可以為 ``NULL``,則使" +"用 :c:func:`Py_XNewRef`。" -#: ../../c-api/refcounting.rst:91 +#: ../../c-api/refcounting.rst:100 msgid "For example::" msgstr "舉例來說: ::" -#: ../../c-api/refcounting.rst:93 +#: ../../c-api/refcounting.rst:102 msgid "" "Py_INCREF(obj);\n" "self->attr = obj;" @@ -167,27 +182,27 @@ msgstr "" "Py_INCREF(obj);\n" "self->attr = obj;" -#: ../../c-api/refcounting.rst:96 +#: ../../c-api/refcounting.rst:105 msgid "can be written as::" msgstr "可以寫成: ::" -#: ../../c-api/refcounting.rst:98 +#: ../../c-api/refcounting.rst:107 msgid "self->attr = Py_NewRef(obj);" msgstr "self->attr = Py_NewRef(obj);" -#: ../../c-api/refcounting.rst:100 +#: ../../c-api/refcounting.rst:109 msgid "See also :c:func:`Py_INCREF`." msgstr "另請參閱 :c:func:`Py_INCREF`。" -#: ../../c-api/refcounting.rst:107 +#: ../../c-api/refcounting.rst:116 msgid "Similar to :c:func:`Py_NewRef`, but the object *o* can be NULL." msgstr "與 :c:func:`Py_NewRef` 類似,但物件 *o* 可以為 NULL。" -#: ../../c-api/refcounting.rst:109 +#: ../../c-api/refcounting.rst:118 msgid "If the object *o* is ``NULL``, the function just returns ``NULL``." msgstr "如果物件 *o* 為 ``NULL``,則該函式僅回傳 ``NULL``。" -#: ../../c-api/refcounting.rst:116 +#: ../../c-api/refcounting.rst:125 msgid "" "Release a :term:`strong reference` to object *o*, indicating the reference " "is no longer used." @@ -195,7 +210,7 @@ msgstr "" "釋放一個對物件 *o* 的\\ :term:`強參照 `,代表該參照不會再被" "使用。" -#: ../../c-api/refcounting.rst:121 +#: ../../c-api/refcounting.rst:130 msgid "" "Once the last :term:`strong reference` is released (i.e. the object's " "reference count reaches 0), the object's type's deallocation function (which " @@ -205,33 +220,33 @@ msgstr "" "到零),則觸發物件之型別的釋放函式 (deallocation function)(不得為 " "``NULL``\\ )。" -#: ../../c-api/refcounting.rst:126 +#: ../../c-api/refcounting.rst:135 msgid "" "This function is usually used to delete a :term:`strong reference` before " "exiting its scope." msgstr "" "此函式通常用於在退出作用域之前刪除\\ :term:`強參照 `。" -#: ../../c-api/refcounting.rst:129 +#: ../../c-api/refcounting.rst:138 msgid "" "The object must not be ``NULL``; if you aren't sure that it isn't ``NULL``, " "use :c:func:`Py_XDECREF`." msgstr "" -"該物件不能為 ``NULL``;如果你不確定它不是 ``NULL``,請改用 :c:func:" -"`Py_XDECREF`。" +"該物件不能為 ``NULL``;如果你不確定它不是 ``NULL``,請改" +"用 :c:func:`Py_XDECREF`。" -#: ../../c-api/refcounting.rst:132 +#: ../../c-api/refcounting.rst:141 msgid "" -"Do not expect this function to actually modify *o* in any way. For at least :" -"pep:`some objects <683>`, this function has no effect." +"Do not expect this function to actually modify *o* in any way. For at " +"least :pep:`some objects <683>`, this function has no effect." msgstr "" "不要期望此函式會以任何方式實際修改 *o*,至少對於\\ :pep:`某些物件 <683>`\\ 來" "說,此函式沒有任何效果。" -#: ../../c-api/refcounting.rst:138 +#: ../../c-api/refcounting.rst:147 msgid "" -"The deallocation function can cause arbitrary Python code to be invoked (e." -"g. when a class instance with a :meth:`~object.__del__` method is " +"The deallocation function can cause arbitrary Python code to be invoked " +"(e.g. when a class instance with a :meth:`~object.__del__` method is " "deallocated). While exceptions in such code are not propagated, the " "executed code has free access to all Python global variables. This means " "that any object that is reachable from a global variable should be in a " @@ -240,14 +255,14 @@ msgid "" "object in a temporary variable, update the list data structure, and then " "call :c:func:`Py_DECREF` for the temporary variable." msgstr "" -"釋放函式可以導致任意 Python 程式碼被叫用(例如,當釋放具有 :meth:`~object." -"__del__` 方法的類別實例時)。雖然此類程式碼中的例外不會被傳遞出來,但​​執行的程" -"式碼可以自由存取所有 Python 全域變數。這意味著在叫用 :c:func:`Py_DECREF` 之" -"前,可從全域變數存取的任何物件都應處於一致狀態。例如,從 list 中刪除物件的程" -"式碼應將已刪除物件的參照複製到臨時變數中,更新 list 資料結構,然後為臨時變數" -"呼叫 :c:func:`Py_DECREF`。" - -#: ../../c-api/refcounting.rst:153 +"釋放函式可以導致任意 Python 程式碼被叫用(例如,當釋放具" +"有 :meth:`~object.__del__` 方法的類別實例時)。雖然此類程式碼中的例外不會被傳" +"遞出來,但​​執行的程式碼可以自由存取所有 Python 全域變數。這意味著在叫" +"用 :c:func:`Py_DECREF` 之前,可從全域變數存取的任何物件都應處於一致狀態。例" +"如,從 list 中刪除物件的程式碼應將已刪除物件的參照複製到臨時變數中,更新 " +"list 資料結構,然後為臨時變數呼叫 :c:func:`Py_DECREF`。" + +#: ../../c-api/refcounting.rst:162 msgid "" "Similar to :c:func:`Py_DECREF`, but the object *o* can be ``NULL``, in which " "case this has no effect. The same warning from :c:func:`Py_DECREF` applies " @@ -256,7 +271,7 @@ msgstr "" "和 :c:func:`Py_DECREF` 類似,但該物件可以是 ``NULL``,在這種情況下巨集不起作" "用。在這裡也會出現與 :c:func:`Py_DECREF` 相同的警告。" -#: ../../c-api/refcounting.rst:160 +#: ../../c-api/refcounting.rst:169 msgid "" "Release a :term:`strong reference` for object *o*. The object may be " "``NULL``, in which case the macro has no effect; otherwise the effect is the " @@ -270,7 +285,7 @@ msgstr "" "非引數也設定為 ``NULL``。:c:func:`Py_DECREF` 的警告不適用於傳遞的物件,因為巨" "集在釋放其參照之前小心地使用臨時變數並將引數設定為 ``NULL``。" -#: ../../c-api/refcounting.rst:168 +#: ../../c-api/refcounting.rst:177 msgid "" "It is a good idea to use this macro whenever releasing a reference to an " "object that might be traversed during garbage collection." @@ -278,7 +293,7 @@ msgstr "" "每當要釋放垃圾回收 (garbage collection) 期間可能被遍歷到之對於物件的參照時," "使用此巨集是個好主意。" -#: ../../c-api/refcounting.rst:171 +#: ../../c-api/refcounting.rst:180 msgid "" "The macro argument is now only evaluated once. If the argument has side " "effects, these are no longer duplicated." @@ -286,24 +301,26 @@ msgstr "" "巨集引數現在僅會被求值 (evaluate) 一次。如果引數有其他副作用,則不再重複作" "用。" -#: ../../c-api/refcounting.rst:178 +#: ../../c-api/refcounting.rst:187 msgid "" "Indicate taking a new :term:`strong reference` to object *o*. A function " "version of :c:func:`Py_XINCREF`. It can be used for runtime dynamic " "embedding of Python." msgstr "" -"代表取得對於物件 *o* 的\\ :term:`強參照 `。:c:func:" -"`Py_XINCREF` 的函式版本。它可用於 Python 的 runtime 動態嵌入。" +"代表取得對於物件 *o* 的\\ :term:`強參照 `。:c:func:`Py_XINCREF` 的函式版本。它可用於 Python 的 runtime 動態" +"嵌入。" -#: ../../c-api/refcounting.rst:185 +#: ../../c-api/refcounting.rst:194 msgid "" -"Release a :term:`strong reference` to object *o*. A function version of :c:" -"func:`Py_XDECREF`. It can be used for runtime dynamic embedding of Python." +"Release a :term:`strong reference` to object *o*. A function version " +"of :c:func:`Py_XDECREF`. It can be used for runtime dynamic embedding of " +"Python." msgstr "" "釋放對物件 *o* 的\\ :term:`強參照 `。:c:func:`Py_XDECREF` " "的函式版本。它可用於 Python 的 runtime 動態嵌入。" -#: ../../c-api/refcounting.rst:192 +#: ../../c-api/refcounting.rst:201 msgid "" "Macro safely releasing a :term:`strong reference` to object *dst* and " "setting *dst* to *src*." @@ -311,11 +328,11 @@ msgstr "" "巨集安全地釋放對於物件 *dst* 的\\ :term:`強參照 `\\ 並將 " "*dst* 設定為 *src*。" -#: ../../c-api/refcounting.rst:195 +#: ../../c-api/refcounting.rst:204 msgid "As in case of :c:func:`Py_CLEAR`, \"the obvious\" code can be deadly::" msgstr "與 :c:func:`Py_CLEAR` 的情況一樣,「明顯的」程式碼可能是致命的: ::" -#: ../../c-api/refcounting.rst:197 +#: ../../c-api/refcounting.rst:206 msgid "" "Py_DECREF(dst);\n" "dst = src;" @@ -323,15 +340,15 @@ msgstr "" "Py_DECREF(dst);\n" "dst = src;" -#: ../../c-api/refcounting.rst:200 +#: ../../c-api/refcounting.rst:209 msgid "The safe way is::" msgstr "安全的方法是: ::" -#: ../../c-api/refcounting.rst:202 +#: ../../c-api/refcounting.rst:211 msgid "Py_SETREF(dst, src);" msgstr "Py_SETREF(dst, src);" -#: ../../c-api/refcounting.rst:204 +#: ../../c-api/refcounting.rst:213 msgid "" "That arranges to set *dst* to *src* *before* releasing the reference to the " "old value of *dst*, so that any code triggered as a side-effect of *dst* " @@ -341,16 +358,16 @@ msgstr "" "被拆除而觸發的任何副作用 (side-effect) 之程式碼不會相信 *dst* 是指向一個有效" "物件。" -#: ../../c-api/refcounting.rst:211 ../../c-api/refcounting.rst:223 +#: ../../c-api/refcounting.rst:220 ../../c-api/refcounting.rst:232 msgid "" "The macro arguments are now only evaluated once. If an argument has side " "effects, these are no longer duplicated." msgstr "巨集引數現在僅會被求值一次。如果引數有其他副作用,則不再重複作用。" -#: ../../c-api/refcounting.rst:218 +#: ../../c-api/refcounting.rst:227 msgid "" "Variant of :c:macro:`Py_SETREF` macro that uses :c:func:`Py_XDECREF` instead " "of :c:func:`Py_DECREF`." msgstr "" -":c:macro:`Py_SETREF` 巨集的變體,請改用 :c:func:`Py_XDECREF` 而非 :c:func:" -"`Py_DECREF`。" +":c:macro:`Py_SETREF` 巨集的變體,請改用 :c:func:`Py_XDECREF` 而" +"非 :c:func:`Py_DECREF`。" diff --git a/c-api/reflection.po b/c-api/reflection.po index 6854e16e934..ceb70a288b7 100644 --- a/c-api/reflection.po +++ b/c-api/reflection.po @@ -1,13 +1,12 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-09-08 15:25+0800\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-" @@ -35,9 +34,10 @@ msgstr "" #: ../../c-api/reflection.rst:22 msgid "" "Use either :c:func:`PyEval_GetFrameLocals` to obtain the same behaviour as " -"calling :func:`locals` in Python code, or else call :c:func:" -"`PyFrame_GetLocals` on the result of :c:func:`PyEval_GetFrame` to access " -"the :attr:`~frame.f_locals` attribute of the currently executing frame." +"calling :func:`locals` in Python code, or else " +"call :c:func:`PyFrame_GetLocals` on the result of :c:func:`PyEval_GetFrame` " +"to access the :attr:`~frame.f_locals` attribute of the currently executing " +"frame." msgstr "" #: ../../c-api/reflection.rst:27 @@ -56,19 +56,19 @@ msgstr "" msgid "" "As this function returns a :term:`borrowed reference`, the dictionary " "returned for :term:`optimized scopes ` is cached on the " -"frame object and will remain alive as long as the frame object does. Unlike :" -"c:func:`PyEval_GetFrameLocals` and :func:`locals`, subsequent calls to this " -"function in the same frame will update the contents of the cached dictionary " -"to reflect changes in the state of the local variables rather than returning " -"a new snapshot." +"frame object and will remain alive as long as the frame object does. " +"Unlike :c:func:`PyEval_GetFrameLocals` and :func:`locals`, subsequent calls " +"to this function in the same frame will update the contents of the cached " +"dictionary to reflect changes in the state of the local variables rather " +"than returning a new snapshot." msgstr "" #: ../../c-api/reflection.rst:39 msgid "" -"As part of :pep:`667`, :c:func:`PyFrame_GetLocals`, :func:`locals`, and :" -"attr:`FrameType.f_locals ` no longer make use of the shared " -"cache dictionary. Refer to the :ref:`What's New entry ` for additional details." +"As part of :pep:`667`, :c:func:`PyFrame_GetLocals`, :func:`locals`, " +"and :attr:`FrameType.f_locals ` no longer make use of the " +"shared cache dictionary. Refer to the :ref:`What's New entry ` for additional details." msgstr "" #: ../../c-api/reflection.rst:50 @@ -83,8 +83,8 @@ msgstr "" #: ../../c-api/reflection.rst:58 msgid "" -"Return the current thread state's frame, which is ``NULL`` if no frame is " -"currently executing." +"Return the :term:`attached thread state`'s frame, which is ``NULL`` if no " +"frame is currently executing." msgstr "" #: ../../c-api/reflection.rst:61 @@ -94,22 +94,22 @@ msgstr "另請見 :c:func:`PyThreadState_GetFrame`。" #: ../../c-api/reflection.rst:74 msgid "" "Return a dictionary of the local variables in the current execution frame, " -"or ``NULL`` if no frame is currently executing. Equivalent to calling :func:" -"`locals` in Python code." +"or ``NULL`` if no frame is currently executing. Equivalent to " +"calling :func:`locals` in Python code." msgstr "" #: ../../c-api/reflection.rst:78 msgid "" "To access :attr:`~frame.f_locals` on the current frame without making an " -"independent snapshot in :term:`optimized scopes `, call :c:" -"func:`PyFrame_GetLocals` on the result of :c:func:`PyEval_GetFrame`." +"independent snapshot in :term:`optimized scopes `, " +"call :c:func:`PyFrame_GetLocals` on the result of :c:func:`PyEval_GetFrame`." msgstr "" #: ../../c-api/reflection.rst:87 msgid "" "Return a dictionary of the global variables in the current execution frame, " -"or ``NULL`` if no frame is currently executing. Equivalent to calling :func:" -"`globals` in Python code." +"or ``NULL`` if no frame is currently executing. Equivalent to " +"calling :func:`globals` in Python code." msgstr "" #: ../../c-api/reflection.rst:96 @@ -122,8 +122,8 @@ msgstr "" msgid "" "Return a description string, depending on the type of *func*. Return values " "include \"()\" for functions and methods, \" constructor\", \" instance\", " -"and \" object\". Concatenated with the result of :c:func:" -"`PyEval_GetFuncName`, the result will be a description of *func*." +"and \" object\". Concatenated with the result " +"of :c:func:`PyEval_GetFuncName`, the result will be a description of *func*." msgstr "" #~ msgid "*frame* must not be ``NULL``." diff --git a/c-api/sequence.po b/c-api/sequence.po index 88d5a0d4fa4..912fea56bfa 100644 --- a/c-api/sequence.po +++ b/c-api/sequence.po @@ -1,13 +1,12 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-07-24 00:03+0000\n" +"POT-Creation-Date: 2025-09-08 15:25+0800\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-" @@ -25,10 +24,10 @@ msgstr "序列協定" #: ../../c-api/sequence.rst:11 msgid "" "Return ``1`` if the object provides the sequence protocol, and ``0`` " -"otherwise. Note that it returns ``1`` for Python classes with a :meth:" -"`~object.__getitem__` method, unless they are :class:`dict` subclasses, " -"since in general it is impossible to determine what type of keys the class " -"supports. This function always succeeds." +"otherwise. Note that it returns ``1`` for Python classes with " +"a :meth:`~object.__getitem__` method, unless they are :class:`dict` " +"subclasses, since in general it is impossible to determine what type of keys " +"the class supports. This function always succeeds." msgstr "" #: ../../c-api/sequence.rst:23 @@ -123,19 +122,29 @@ msgid "" msgstr "" #: ../../c-api/sequence.rst:110 +msgid "Alias for :c:func:`PySequence_Contains`." +msgstr ":c:func:`PySequence_Contains` 的別名。" + +#: ../../c-api/sequence.rst:112 +msgid "" +"The function is :term:`soft deprecated` and should no longer be used to " +"write new code." +msgstr "" + +#: ../../c-api/sequence.rst:119 msgid "" "Return the first index *i* for which ``o[i] == value``. On error, return " "``-1``. This is equivalent to the Python expression ``o.index(value)``." msgstr "" -#: ../../c-api/sequence.rst:116 +#: ../../c-api/sequence.rst:125 msgid "" "Return a list object with the same contents as the sequence or iterable *o*, " "or ``NULL`` on failure. The returned list is guaranteed to be new. This is " "equivalent to the Python expression ``list(o)``." msgstr "" -#: ../../c-api/sequence.rst:125 +#: ../../c-api/sequence.rst:134 msgid "" "Return a tuple object with the same contents as the sequence or iterable " "*o*, or ``NULL`` on failure. If *o* is a tuple, a new reference will be " @@ -143,7 +152,7 @@ msgid "" "contents. This is equivalent to the Python expression ``tuple(o)``." msgstr "" -#: ../../c-api/sequence.rst:133 +#: ../../c-api/sequence.rst:142 msgid "" "Return the sequence or iterable *o* as an object usable by the other " "``PySequence_Fast*`` family of functions. If the object is not a sequence or " @@ -151,56 +160,57 @@ msgid "" "``NULL`` on failure." msgstr "" -#: ../../c-api/sequence.rst:138 +#: ../../c-api/sequence.rst:147 msgid "" "The ``PySequence_Fast*`` functions are thus named because they assume *o* is " "a :c:type:`PyTupleObject` or a :c:type:`PyListObject` and access the data " "fields of *o* directly." msgstr "" -#: ../../c-api/sequence.rst:142 +#: ../../c-api/sequence.rst:151 msgid "" "As a CPython implementation detail, if *o* is already a sequence or list, it " "will be returned." msgstr "" -#: ../../c-api/sequence.rst:148 +#: ../../c-api/sequence.rst:157 msgid "" -"Returns the length of *o*, assuming that *o* was returned by :c:func:" -"`PySequence_Fast` and that *o* is not ``NULL``. The size can also be " -"retrieved by calling :c:func:`PySequence_Size` on *o*, but :c:func:" -"`PySequence_Fast_GET_SIZE` is faster because it can assume *o* is a list or " -"tuple." +"Returns the length of *o*, assuming that *o* was returned " +"by :c:func:`PySequence_Fast` and that *o* is not ``NULL``. The size can " +"also be retrieved by calling :c:func:`PySequence_Size` on *o*, " +"but :c:func:`PySequence_Fast_GET_SIZE` is faster because it can assume *o* " +"is a list or tuple." msgstr "" -#: ../../c-api/sequence.rst:157 +#: ../../c-api/sequence.rst:166 msgid "" -"Return the *i*\\ th element of *o*, assuming that *o* was returned by :c:" -"func:`PySequence_Fast`, *o* is not ``NULL``, and that *i* is within bounds." +"Return the *i*\\ th element of *o*, assuming that *o* was returned " +"by :c:func:`PySequence_Fast`, *o* is not ``NULL``, and that *i* is within " +"bounds." msgstr "" -#: ../../c-api/sequence.rst:163 +#: ../../c-api/sequence.rst:172 msgid "" "Return the underlying array of PyObject pointers. Assumes that *o* was " "returned by :c:func:`PySequence_Fast` and *o* is not ``NULL``." msgstr "" -#: ../../c-api/sequence.rst:166 +#: ../../c-api/sequence.rst:175 msgid "" "Note, if a list gets resized, the reallocation may relocate the items array. " "So, only use the underlying array pointer in contexts where the sequence " "cannot change." msgstr "" -#: ../../c-api/sequence.rst:173 +#: ../../c-api/sequence.rst:182 msgid "" -"Return the *i*\\ th element of *o* or ``NULL`` on failure. Faster form of :c:" -"func:`PySequence_GetItem` but without checking that :c:func:" -"`PySequence_Check` on *o* is true and without adjustment for negative " -"indices." +"Return the *i*\\ th element of *o* or ``NULL`` on failure. Faster form " +"of :c:func:`PySequence_GetItem` but without checking " +"that :c:func:`PySequence_Check` on *o* is true and without adjustment for " +"negative indices." msgstr "" -#: ../../c-api/sequence.rst:21 ../../c-api/sequence.rst:123 +#: ../../c-api/sequence.rst:21 ../../c-api/sequence.rst:132 msgid "built-in function" msgstr "built-in function(內建函式)" @@ -208,6 +218,6 @@ msgstr "built-in function(內建函式)" msgid "len" msgstr "len" -#: ../../c-api/sequence.rst:123 +#: ../../c-api/sequence.rst:132 msgid "tuple" msgstr "tuple(元組)" diff --git a/c-api/set.po b/c-api/set.po index e094b1ee324..2bdbc213493 100644 --- a/c-api/set.po +++ b/c-api/set.po @@ -1,11 +1,10 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2023-11-27 00:03+0000\n" "PO-Revision-Date: 2018-05-23 14:07+0000\n" diff --git a/c-api/slice.po b/c-api/slice.po index fbac58a43a4..7cbae1a4eef 100644 --- a/c-api/slice.po +++ b/c-api/slice.po @@ -1,16 +1,16 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Leon H., 2017 +# Weilin Du, 2025 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2025-02-18 00:13+0000\n" -"PO-Revision-Date: 2018-05-23 14:07+0000\n" -"Last-Translator: Adrian Liaw \n" +"PO-Revision-Date: 2025-10-08 21:36+0800\n" +"Last-Translator: Weilin Du <1372449351@qq.com>\n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" "Language: zh_TW\n" @@ -18,6 +18,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" +"X-Generator: Poedit 3.6\n" #: ../../c-api/slice.rst:6 msgid "Slice Objects" @@ -27,13 +28,14 @@ msgstr "切片物件" msgid "" "The type object for slice objects. This is the same as :class:`slice` in " "the Python layer." -msgstr "" +msgstr "slice 物件的型別物件。這與 Python 層中的 :class:`slice` 相同。" #: ../../c-api/slice.rst:17 msgid "" "Return true if *ob* is a slice object; *ob* must not be ``NULL``. This " "function always succeeds." msgstr "" +"如果 *ob* 是 slice 物件,則回傳 true;*ob* 不能是 ``NULL`` 。此函式永遠成功。" #: ../../c-api/slice.rst:23 msgid "" @@ -42,12 +44,15 @@ msgid "" "the same names. Any of the values may be ``NULL``, in which case the " "``None`` will be used for the corresponding attribute." msgstr "" +"以指定的值回傳一個新的切片物件。*start*、*stop* 及 *step* 參數會被用為同名的 " +"slice 物件屬性值。任何值都可能是 ``NULL``,在這種情況下,``None`` 將用於相對" +"應的屬性。" #: ../../c-api/slice.rst:28 msgid "" "Return ``NULL`` with an exception set if the new object could not be " "allocated." -msgstr "" +msgstr "如果無法分配新物件,則回傳 ``NULL`` 並設定例外。" #: ../../c-api/slice.rst:34 msgid "" @@ -55,6 +60,8 @@ msgid "" "assuming a sequence of length *length*. Treats indices greater than *length* " "as errors." msgstr "" +"從 slice 物件 *slice* 讀取開始、停止和步進索引,假設序列長度為 *length*。將大" +"於 *length* 的索引視為錯誤。" #: ../../c-api/slice.rst:38 msgid "" @@ -62,15 +69,17 @@ msgid "" "one of the indices was not ``None`` and failed to be converted to an " "integer, in which case ``-1`` is returned with an exception set)." msgstr "" +"成功時回傳 ``0``,錯誤時回傳 ``-1``,並無例外設定(除非其中一個索引不是 " +"``None`` 並且未能轉換成整數,在這種情況下會回傳 ``-1`` ,並有設定例外)。" #: ../../c-api/slice.rst:42 msgid "You probably do not want to use this function." -msgstr "" +msgstr "你可能不想使用此功能。" #: ../../c-api/slice.rst:44 ../../c-api/slice.rst:75 msgid "" "The parameter type for the *slice* parameter was ``PySliceObject*`` before." -msgstr "" +msgstr "之前 *slice* 的參數型別是 ``PySliceObject*`` 。" #: ../../c-api/slice.rst:51 msgid "" @@ -80,6 +89,9 @@ msgid "" "bounds indices are clipped in a manner consistent with the handling of " "normal slices." msgstr "" +"可用來取代 :c:func:`PySlice_GetIndices`。從假設序列長度為 *length* 的 slice " +"物件 *slice* 擷取開始、停止和步長索引,並將 slice 的長度存入 *slicelength*。" +"超出範圍的索引會被剪切,剪切方式與一般切片的處理方式一致。" #: ../../c-api/slice.rst:57 msgid "Return ``0`` on success and ``-1`` on error with an exception set." @@ -91,6 +103,9 @@ msgid "" "should be replaced by a combination of :c:func:`PySlice_Unpack` " "and :c:func:`PySlice_AdjustIndices` where ::" msgstr "" +"這個函式對於可調整大小的序列並不安全。它的呼叫應該" +"被 :c:func:`PySlice_Unpack` 和 :c:func:`PySlice_AdjustIndices` 的組合取代,其" +"中: ::" #: ../../c-api/slice.rst:64 msgid "" @@ -99,10 +114,14 @@ msgid "" " // return error\n" "}" msgstr "" +"if (PySlice_GetIndicesEx(slice, length, &start, &stop, &step, &slicelength) " +"< 0) {\n" +" // return error\n" +"}" #: ../../c-api/slice.rst:68 msgid "is replaced by ::" -msgstr "" +msgstr "被更換為: ::" #: ../../c-api/slice.rst:70 msgid "" @@ -111,6 +130,10 @@ msgid "" "}\n" "slicelength = PySlice_AdjustIndices(length, &start, &stop, step);" msgstr "" +"if (PySlice_Unpack(slice, &start, &stop, &step) < 0) {\n" +" // return error\n" +"}\n" +"slicelength = PySlice_AdjustIndices(length, &start, &stop, step);" #: ../../c-api/slice.rst:79 msgid "" @@ -120,6 +143,10 @@ msgid "" "PySlice_Unpack` and :c:func:`!PySlice_AdjustIndices`. Arguments *start*, " "*stop* and *step* are evaluated more than once." msgstr "" +"如果 ``Py_LIMITED_API`` 沒有設定或設定為 ``0x03050400`` 和 ``0x03060000`` (不" +"包括) 或 ``0x03060100`` 或更高的值 :c:func:`!PySlice_GetIndicesEx` 是使" +"用 :c:func:`!PySlice_Unpack` 和 :c:func:`!PySlice_AdjustIndices` 來實作一個巨集" +"。引數 *start*、*stop* 和 *step* 會被計算多次。" #: ../../c-api/slice.rst:86 msgid "" @@ -127,6 +154,9 @@ msgid "" "between ``0x03060000`` and ``0x03060100`` (not including) :c:func:`!" "PySlice_GetIndicesEx` is a deprecated function." msgstr "" +"如果 ``Py_LIMITED_API`` 設定為小於 ``0x03050400`` 或介於 ``0x03060000`` 和 " +"``0x03060100`` 之間 (不包括邊界值) :c:func:`!PySlice_GetIndicesEx` 是一個" +"已廢棄的函式。" #: ../../c-api/slice.rst:94 msgid "" @@ -136,6 +166,10 @@ msgid "" "``PY_SSIZE_T_MIN`` to ``PY_SSIZE_T_MIN``, and silently boost the step values " "less than ``-PY_SSIZE_T_MAX`` to ``-PY_SSIZE_T_MAX``." msgstr "" +"以 C 整數的形式從 slice 物件中抽取 start、stop 及 step 資料成員。將大於 " +"``PY_SSIZE_T_MAX`` 的值靜默減少為 ``PY_SSIZE_T_MAX``,將小於 ``PY_SSIZE_T_MIN`` " +"的 start 和 stop 值靜默提升為 ``PY_SSIZE_T_MIN``,將小於 ``-PY_SSIZE_T_MAX`` " +"的 step 值靜默提升為 ``-PY_SSIZE_T_MAX``。" #: ../../c-api/slice.rst:100 msgid "Return ``-1`` with an exception set on error, ``0`` on success." @@ -147,12 +181,14 @@ msgid "" "Out of bounds indices are clipped in a manner consistent with the handling " "of normal slices." msgstr "" +"假設序列長度為指定長度,調整開始/結束切片索引。超出範圍的索引會以與處理正常切" +"片一致的方式切除。" #: ../../c-api/slice.rst:111 msgid "" "Return the length of the slice. Always successful. Doesn't call Python " "code." -msgstr "" +msgstr "回傳切片的長度。永遠成功。不呼叫 Python 程式碼。" #: ../../c-api/slice.rst:118 msgid "Ellipsis Object" @@ -163,12 +199,16 @@ msgid "" "The type of Python :const:`Ellipsis` object. Same " "as :class:`types.EllipsisType` in the Python layer." msgstr "" +"Python :const:`Ellipsis` 物件的型別。與 Python 層中" +"的 :class:`types.EllipsisType` 相同。" #: ../../c-api/slice.rst:129 msgid "" "The Python ``Ellipsis`` object. This object has no methods. " "Like :c:data:`Py_None`, it is an :term:`immortal` singleton object." msgstr "" +"Python ``Ellipsis`` 物件。這個物件沒有方法。就像 :c:data:`Py_None` 一樣,它是" +"一個 :term:`immortal` 單一物件。" #: ../../c-api/slice.rst:132 msgid ":c:data:`Py_Ellipsis` is immortal." diff --git a/c-api/stable.po b/c-api/stable.po index 54ff032f045..5e4a3dc643c 100644 --- a/c-api/stable.po +++ b/c-api/stable.po @@ -1,13 +1,13 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Matt Wang , 2023 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-12-04 00:14+0000\n" +"POT-Creation-Date: 2025-09-08 15:25+0800\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-" @@ -113,11 +113,11 @@ msgstr "" "使用此 API 的專案應該要遵循 CPython 開發細節,並花費額外的力氣來針對這些變動" "來做調整。" -#: ../../c-api/stable.rst:56 +#: ../../c-api/stable.rst:57 msgid "Stable Application Binary Interface" msgstr "穩定的應用程式二進位介面" -#: ../../c-api/stable.rst:58 +#: ../../c-api/stable.rst:59 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, " @@ -127,11 +127,11 @@ msgstr "" "API 使用方式中都以相同的方式運作 -- 例如在嵌入式 Python (embedding Python) " "中。" -#: ../../c-api/stable.rst:65 +#: ../../c-api/stable.rst:66 msgid "Limited C API" msgstr "受限 C API" -#: ../../c-api/stable.rst:67 +#: ../../c-api/stable.rst:68 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 " @@ -142,14 +142,14 @@ msgstr "" "僅使用受限 API 的擴充可以只編譯一次就被載入於多個版本的 Python。受限 API 的內" "容\\ :ref:`列在下方 `。" -#: ../../c-api/stable.rst:74 +#: ../../c-api/stable.rst:75 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 版本。" -#: ../../c-api/stable.rst:77 +#: ../../c-api/stable.rst:78 msgid "" "Define ``Py_LIMITED_API`` to the value of :c:macro:`PY_VERSION_HEX` " "corresponding to the lowest Python version your extension supports. The " @@ -160,7 +160,7 @@ msgstr "" "的 :c:macro:`PY_VERSION_HEX` 值。該擴充與從指定版本開始的所有 Python 3 版本" "之 ABI 相容,並且可以使用過去版本有引入的受限 API。" -#: ../../c-api/stable.rst:83 +#: ../../c-api/stable.rst:84 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 " @@ -170,7 +170,7 @@ msgstr "" "代表 Python 3.10 的 ``0x030A0000``\\ ),以便在使用未來的 Python 版本進行編譯" "時仍保持穩定性。" -#: ../../c-api/stable.rst:87 +#: ../../c-api/stable.rst:88 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)." @@ -178,11 +178,11 @@ msgstr "" "你還可以將 ``Py_LIMITED_API`` 定義為 ``3``,這與 ``0x03020000``\\ (Python " "3.2,引入了受限 API 的版本)相同。" -#: ../../c-api/stable.rst:94 +#: ../../c-api/stable.rst:95 msgid "Stable ABI" msgstr "穩定 ABI" -#: ../../c-api/stable.rst:96 +#: ../../c-api/stable.rst:97 msgid "" "To enable this, Python provides a *Stable ABI*: a set of symbols that will " "remain ABI-compatible across Python 3.x versions." @@ -190,7 +190,7 @@ msgstr "" "為了實現它,Python 提供了一個\\ *穩定 ABI (Stable ABI)*:一組將在各個 Python " "3.x 版本之間保持 ABI 相容的符號。" -#: ../../c-api/stable.rst:101 +#: ../../c-api/stable.rst:102 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 " @@ -198,10 +198,11 @@ msgid "" "extensions. See Python's Backwards Compatibility Policy (:pep:`387`) for " "details." msgstr "" -"穩定 ABI 可以防止 ABI 問題,例如由於結構布局或函式簽名變化導致缺少符號或數據損壞的鏈接器 (linker) 錯誤。" -"然而,Python 的其他變化可能會改變 *行為* 的擴充。有關詳細信息,請參閱 Python 的向後相容性政策 (:pep:`387`)。" +"穩定 ABI 可以防止 ABI 問題,例如由於結構布局或函式簽名變化導致缺少符號或數據" +"損壞的鏈接器 (linker) 錯誤。然而,Python 的其他變化可能會改變 *行為* 的擴充。" +"有關詳細信息,請參閱 Python 的向後相容性政策 (:pep:`387`)。" -#: ../../c-api/stable.rst:107 +#: ../../c-api/stable.rst:108 msgid "" "The Stable ABI contains symbols exposed in the :ref:`Limited API `, but also other ones – for example, functions necessary to support " @@ -210,7 +211,7 @@ msgstr "" "穩定 ABI 被包含在\\ :ref:`受限 API ` 中開放的符號,但也包含其" "他符號 - 例如,支援舊版受限 API 所必需的函式。" -#: ../../c-api/stable.rst:111 +#: ../../c-api/stable.rst:112 msgid "" "On Windows, extensions that use the Stable ABI should be linked against " "``python3.dll`` rather than a version-specific library such as " @@ -219,7 +220,7 @@ msgstr "" "在 Windows 上,使用穩定 ABI 的擴充應該連接到 ``python3.dll`` 而不是特定版本的" "函式庫,例如 ``python39.dll``。" -#: ../../c-api/stable.rst:115 +#: ../../c-api/stable.rst:116 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 " @@ -232,7 +233,7 @@ msgstr "" "用者(或者打包工具)身上,例如使用 3.10+ 受限 API 建置的擴充不會為較低版本的 " "Python 所安裝。" -#: ../../c-api/stable.rst:122 +#: ../../c-api/stable.rst:123 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 " @@ -241,18 +242,18 @@ msgstr "" "穩定 ABI 中的所有函式都作為函式存在於 Python 的共享函式庫中,而不僅是作為巨" "集。這使得它們可被用於不使用 C 預處理器 (preprocessor) 的語言。" -#: ../../c-api/stable.rst:128 +#: ../../c-api/stable.rst:129 msgid "Limited API Scope and Performance" msgstr "受限 API 範圍和性能" -#: ../../c-api/stable.rst:130 +#: ../../c-api/stable.rst:131 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." msgstr "" "受限 API 的目標是允許使用完整的 C API 進行所有可能的操作,但可能會降低性能。" -#: ../../c-api/stable.rst:133 +#: ../../c-api/stable.rst:134 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 " @@ -262,7 +263,7 @@ msgstr "" "體 :c:func:`PyList_GET_ITEM` 為不可用。巨集運行可以更快,因為它可以依賴 list " "物件的特定版本實作細節。" -#: ../../c-api/stable.rst:138 +#: ../../c-api/stable.rst:139 msgid "" "Without ``Py_LIMITED_API`` defined, some C API functions are inlined or " "replaced by macros. Defining ``Py_LIMITED_API`` disables this inlining, " @@ -273,7 +274,7 @@ msgstr "" "``Py_LIMITED_API`` 會禁用嵌入,從而隨著 Python 資料結構的改進而提高穩定性,但" "可能會降低性能。" -#: ../../c-api/stable.rst:143 +#: ../../c-api/stable.rst:144 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 " @@ -287,11 +288,11 @@ msgstr "" "將產生一個擴充,可以在特定版本的擴充不可用的地方發布 — 例如,用於即將發布的 " "Python 版本的預發布版本 (prerelease)。" -#: ../../c-api/stable.rst:152 +#: ../../c-api/stable.rst:153 msgid "Limited API Caveats" msgstr "受限 API 注意事項" -#: ../../c-api/stable.rst:154 +#: ../../c-api/stable.rst:155 msgid "" "Note that compiling with ``Py_LIMITED_API`` is *not* a complete guarantee " "that code conforms to the :ref:`Limited API ` or " @@ -304,7 +305,7 @@ msgstr "" "``Py_LIMITED_API`` 僅涵蓋定義,但 API 還包括其他議題,例如預期的語義 " "(semantic)。" -#: ../../c-api/stable.rst:159 +#: ../../c-api/stable.rst:160 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 " @@ -318,7 +319,7 @@ msgstr "" "現在代表選擇預設行為,但在 Python 3.8 中,引數將被直接使用,導致 ``NULL`` 取" "消參照 (dereference) 且崩潰 (crash)。類似的引數適用於結構 (struct) 的欄位。" -#: ../../c-api/stable.rst:166 +#: ../../c-api/stable.rst:167 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." @@ -326,7 +327,7 @@ msgstr "" "另一個問題是,當有定義 ``Py_LIMITED_API`` 時,一些結構欄位目前不會被隱藏,即" "使它們是受限 API 的一部分。" -#: ../../c-api/stable.rst:169 +#: ../../c-api/stable.rst:170 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." @@ -334,7 +335,7 @@ msgstr "" "出於這些原因,我們建議要以它支援的\\ *所有*\\ 次要 Python 版本來測試擴充,並" "且最好使用\\ *最低*\\ 版本進行建置。" -#: ../../c-api/stable.rst:172 +#: ../../c-api/stable.rst:173 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 " @@ -345,7 +346,7 @@ msgstr "" "義 ``Py_LIMITED_API``,一些私有聲明也會因為技術原因(或者甚至是無意地,例如臭" "蟲)而被公開出來。" -#: ../../c-api/stable.rst:177 +#: ../../c-api/stable.rst:178 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 " @@ -357,11 +358,11 @@ msgstr "" "行編譯意味著擴充將能以 Python 3.12 運行,但不一定能以 Python 3.12 *編譯*。特" "別是如果穩定 ABI 保持穩定,部分受限 API 可能會被棄用和刪除。" -#: ../../c-api/stable.rst:187 +#: ../../c-api/stable.rst:188 msgid "Platform Considerations" msgstr "平台注意事項" -#: ../../c-api/stable.rst:189 +#: ../../c-api/stable.rst:190 msgid "" "ABI stability depends not only on Python, but also on the compiler used, " "lower-level libraries and compiler options. For the purposes of " @@ -372,7 +373,7 @@ msgstr "" "於\\ :ref:`穩定 ABI ` 的目的,這些細節定義了一個「平台」。它們通" "常取決於作業系統種類和處理器架構" -#: ../../c-api/stable.rst:194 +#: ../../c-api/stable.rst:195 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 " @@ -383,11 +384,11 @@ msgstr "" "定 ABI 的方式建置。``python.org`` 和許多第三方發布者發布的 Windows 和 macOS " "版本就是這種情況。" -#: ../../c-api/stable.rst:204 +#: ../../c-api/stable.rst:205 msgid "Contents of Limited API" msgstr "受限 API 的內容" -#: ../../c-api/stable.rst:207 +#: ../../c-api/stable.rst:208 msgid "" "Currently, the :ref:`Limited API ` includes the following " "items:" diff --git a/c-api/structures.po b/c-api/structures.po index eacbf76707f..6993217234c 100644 --- a/c-api/structures.po +++ b/c-api/structures.po @@ -1,13 +1,13 @@ -# Copyright (C) 2001-2023, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Leon H., 2017 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-03-11 00:14+0000\n" +"POT-Creation-Date: 2025-11-20 00:14+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-" @@ -51,129 +51,197 @@ msgid "" "In a normal \"release\" build, it contains only the object's reference count " "and a pointer to the corresponding type object. Nothing is actually declared " "to be a :c:type:`PyObject`, but every pointer to a Python object can be cast " -"to a :c:expr:`PyObject*`. Access to the members must be done by using the " -"macros :c:macro:`Py_REFCNT` and :c:macro:`Py_TYPE`." +"to a :c:expr:`PyObject*`." +msgstr "" + +#: ../../c-api/structures.rst:33 +msgid "" +"The members must not be accessed directly; instead use macros such as :c:" +"macro:`Py_REFCNT` and :c:macro:`Py_TYPE`." msgstr "" #: ../../c-api/structures.rst:38 msgid "" -"This is an extension of :c:type:`PyObject` that adds " -"the :c:member:`~PyVarObject.ob_size` field. This is only used for objects " -"that have some notion of *length*. This type does not often appear in the " -"Python/C API. Access to the members must be done by using the " -"macros :c:macro:`Py_REFCNT`, :c:macro:`Py_TYPE`, and :c:macro:`Py_SIZE`." +"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 +msgid "" +"The field type may be different from ``Py_ssize_t``, depending on build " +"configuration and platform." msgstr "" #: ../../c-api/structures.rst:47 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 +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 +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 +msgid "" +"A size field, whose contents should be considered an object's internal " +"implementation detail." +msgstr "" + +#: ../../c-api/structures.rst:67 +msgid "Do not use this field directly; use :c:macro:`Py_SIZE` instead." +msgstr "" + +#: ../../c-api/structures.rst:69 +msgid "" +"Object creation functions such as :c:func:`PyObject_NewVar` will generally " +"set this field to the requested size (number of items). After creation, " +"arbitrary values can be stored in :c:member:`!ob_size` using :c:macro:" +"`Py_SET_SIZE`." +msgstr "" + +#: ../../c-api/structures.rst:74 +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 +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:50 +#: ../../c-api/structures.rst:84 msgid "PyObject ob_base;" msgstr "PyObject ob_base;" -#: ../../c-api/structures.rst:52 +#: ../../c-api/structures.rst:86 msgid "See documentation of :c:type:`PyObject` above." msgstr "" -#: ../../c-api/structures.rst:57 +#: ../../c-api/structures.rst:91 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:61 +#: ../../c-api/structures.rst:95 msgid "PyVarObject ob_base;" msgstr "PyVarObject ob_base;" -#: ../../c-api/structures.rst:63 +#: ../../c-api/structures.rst:97 msgid "See documentation of :c:type:`PyVarObject` above." msgstr "請見上面 :c:type:`PyVarObject` 的文件。" -#: ../../c-api/structures.rst:68 +#: ../../c-api/structures.rst:102 msgid "" "The base class of all other objects, the same as :class:`object` in Python." msgstr "" -#: ../../c-api/structures.rst:73 +#: ../../c-api/structures.rst:107 msgid "" "Test if the *x* object is the *y* object, the same as ``x is y`` in Python." msgstr "" -#: ../../c-api/structures.rst:80 +#: ../../c-api/structures.rst:114 msgid "" "Test if an object is the ``None`` singleton, the same as ``x is None`` in " "Python." msgstr "" -#: ../../c-api/structures.rst:88 +#: ../../c-api/structures.rst:122 msgid "" "Test if an object is the ``True`` singleton, the same as ``x is True`` in " "Python." msgstr "" -#: ../../c-api/structures.rst:96 +#: ../../c-api/structures.rst:130 msgid "" "Test if an object is the ``False`` singleton, the same as ``x is False`` in " "Python." msgstr "" -#: ../../c-api/structures.rst:104 +#: ../../c-api/structures.rst:138 msgid "Get the type of the Python object *o*." msgstr "" -#: ../../c-api/structures.rst:106 -msgid "Return a :term:`borrowed reference`." -msgstr "" - -#: ../../c-api/structures.rst:108 -msgid "Use the :c:func:`Py_SET_TYPE` function to set an object type." +#: ../../c-api/structures.rst:140 +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:110 +#: ../../c-api/structures.rst:143 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:117 +#: ../../c-api/structures.rst:150 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:125 -msgid "Set the object *o* type to *type*." -msgstr "將物件 *o* 的型別設為 *type*。" +#: ../../c-api/structures.rst:158 +msgid "" +"Set the type of object *o* to *type*, without any checking or reference " +"counting." +msgstr "" + +#: ../../c-api/structures.rst:161 +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 +msgid "" +"Note that assigning an incompatible type can lead to undefined behavior." +msgstr "" -#: ../../c-api/structures.rst:132 -msgid "Get the size of the Python object *o*." -msgstr "取得 Python 物件 *o* 的大小。" +#: ../../c-api/structures.rst:167 +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:134 -msgid "Use the :c:func:`Py_SET_SIZE` function to set an object size." +#: ../../c-api/structures.rst:177 +msgid "Get the :c:member:`~PyVarObject.ob_size` field of *o*." msgstr "" -#: ../../c-api/structures.rst:136 +#: ../../c-api/structures.rst:179 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:143 -msgid "Set the object *o* size to *size*." -msgstr "將物件 *o* 的大小設為 *size*。" +#: ../../c-api/structures.rst:186 +msgid "Set the :c:member:`~PyVarObject.ob_size` field of *o* to *size*." +msgstr "" -#: ../../c-api/structures.rst:150 +#: ../../c-api/structures.rst:193 msgid "" -"This is a macro which expands to initialization values for a " -"new :c:type:`PyObject` type. This macro expands to::" +"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:153 +#: ../../c-api/structures.rst:196 msgid "" "_PyObject_EXTRA_INIT\n" "1, type," @@ -181,14 +249,14 @@ msgstr "" "_PyObject_EXTRA_INIT\n" "1, type," -#: ../../c-api/structures.rst:159 +#: ../../c-api/structures.rst:202 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::" +"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:163 +#: ../../c-api/structures.rst:206 msgid "" "_PyObject_EXTRA_INIT\n" "1, type, size," @@ -196,11 +264,11 @@ msgstr "" "_PyObject_EXTRA_INIT\n" "1, type, size," -#: ../../c-api/structures.rst:168 +#: ../../c-api/structures.rst:211 msgid "Implementing functions and methods" msgstr "實作函式與方法" -#: ../../c-api/structures.rst:172 +#: ../../c-api/structures.rst:215 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 " @@ -210,11 +278,11 @@ msgid "" "reference." msgstr "" -#: ../../c-api/structures.rst:179 +#: ../../c-api/structures.rst:222 msgid "The function signature is::" msgstr "" -#: ../../c-api/structures.rst:181 +#: ../../c-api/structures.rst:224 msgid "" "PyObject *PyCFunction(PyObject *self,\n" " PyObject *args);" @@ -222,14 +290,14 @@ msgstr "" "PyObject *PyCFunction(PyObject *self,\n" " PyObject *args);" -#: ../../c-api/structures.rst:186 +#: ../../c-api/structures.rst:229 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:190 +#: ../../c-api/structures.rst:233 msgid "" "PyObject *PyCFunctionWithKeywords(PyObject *self,\n" " PyObject *args,\n" @@ -239,13 +307,13 @@ msgstr "" " PyObject *args,\n" " PyObject *kwargs);" -#: ../../c-api/structures.rst:197 +#: ../../c-api/structures.rst:240 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:201 +#: ../../c-api/structures.rst:244 msgid "" "PyObject *PyCFunctionFast(PyObject *self,\n" " PyObject *const *args,\n" @@ -255,14 +323,14 @@ msgstr "" " PyObject *const *args,\n" " Py_ssize_t nargs);" -#: ../../c-api/structures.rst:207 +#: ../../c-api/structures.rst:250 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:211 +#: ../../c-api/structures.rst:254 msgid "" "PyObject *PyCFunctionFastWithKeywords(PyObject *self,\n" " PyObject *const *args,\n" @@ -274,14 +342,14 @@ msgstr "" " Py_ssize_t nargs,\n" " PyObject *kwnames);" -#: ../../c-api/structures.rst:218 +#: ../../c-api/structures.rst:261 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:222 +#: ../../c-api/structures.rst:265 msgid "" "PyObject *PyCMethod(PyObject *self,\n" " PyTypeObject *defining_class,\n" @@ -295,29 +363,29 @@ msgstr "" " Py_ssize_t nargs,\n" " PyObject *kwnames)" -#: ../../c-api/structures.rst:233 +#: ../../c-api/structures.rst:276 msgid "" "Structure used to describe a method of an extension type. This structure " "has four fields:" msgstr "" -#: ../../c-api/structures.rst:238 +#: ../../c-api/structures.rst:281 msgid "Name of the method." msgstr "" -#: ../../c-api/structures.rst:242 +#: ../../c-api/structures.rst:285 msgid "Pointer to the C implementation." msgstr "" -#: ../../c-api/structures.rst:246 +#: ../../c-api/structures.rst:289 msgid "Flags bits indicating how the call should be constructed." msgstr "" -#: ../../c-api/structures.rst:250 +#: ../../c-api/structures.rst:293 msgid "Points to the contents of the docstring." msgstr "" -#: ../../c-api/structures.rst:252 +#: ../../c-api/structures.rst:295 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 " @@ -327,42 +395,41 @@ msgid "" "implementation uses the specific C type of the *self* object." msgstr "" -#: ../../c-api/structures.rst:260 +#: ../../c-api/structures.rst:303 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:265 +#: ../../c-api/structures.rst:308 msgid "There are these calling conventions:" msgstr "" -#: ../../c-api/structures.rst:269 +#: ../../c-api/structures.rst:312 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 first one is the *self* object for methods; for module " -"functions, it is the module object. The second parameter (often called " -"*args*) is a tuple object representing all arguments. This parameter is " -"typically processed using :c:func:`PyArg_ParseTuple` " -"or :c:func:`PyArg_UnpackTuple`." +"This is the typical calling convention, where the methods have the type :c:" +"type:`PyCFunction`. The function expects two :c:expr:`PyObject*` values. The " +"first one is the *self* object for methods; for module functions, it is the " +"module object. The second parameter (often called *args*) is a tuple object " +"representing all arguments. This parameter is typically processed using :c:" +"func:`PyArg_ParseTuple` or :c:func:`PyArg_UnpackTuple`." msgstr "" -#: ../../c-api/structures.rst:279 +#: ../../c-api/structures.rst:322 msgid "" -"Can only be used in certain combinations with other " -"flags: :ref:`METH_VARARGS | METH_KEYWORDS `, :ref:`METH_FASTCALL | METH_KEYWORDS ` and :ref:`METH_METHOD | METH_FASTCALL | METH_KEYWORDS " -"`." +"Can only be used in certain combinations with other flags: :ref:" +"`METH_VARARGS | METH_KEYWORDS `, :ref:" +"`METH_FASTCALL | METH_KEYWORDS ` and :ref:" +"`METH_METHOD | METH_FASTCALL | METH_KEYWORDS `." msgstr "" -#: ../../c-api/structures.rst:287 +#: ../../c-api/structures.rst:330 msgid ":c:expr:`METH_VARARGS | METH_KEYWORDS`" msgstr ":c:expr:`METH_VARARGS | METH_KEYWORDS`" -#: ../../c-api/structures.rst:288 +#: ../../c-api/structures.rst:331 msgid "" "Methods with these flags must be of type :c:type:`PyCFunctionWithKeywords`. " "The function expects three parameters: *self*, *args*, *kwargs* where " @@ -371,7 +438,7 @@ msgid "" "using :c:func:`PyArg_ParseTupleAndKeywords`." msgstr "" -#: ../../c-api/structures.rst:297 +#: ../../c-api/structures.rst:340 msgid "" "Fast calling convention supporting only positional arguments. The methods " "have the type :c:type:`PyCFunctionFast`. The first parameter is *self*, the " @@ -380,15 +447,15 @@ msgid "" "the array)." msgstr "" -#: ../../c-api/structures.rst:307 +#: ../../c-api/structures.rst:350 msgid "``METH_FASTCALL`` is now part of the :ref:`stable ABI `." msgstr "" -#: ../../c-api/structures.rst:312 +#: ../../c-api/structures.rst:355 msgid ":c:expr:`METH_FASTCALL | METH_KEYWORDS`" msgstr ":c:expr:`METH_FASTCALL | METH_KEYWORDS`" -#: ../../c-api/structures.rst:313 +#: ../../c-api/structures.rst:356 msgid "" "Extension of :c:macro:`METH_FASTCALL` supporting also keyword arguments, " "with methods of type :c:type:`PyCFunctionFastWithKeywords`. Keyword " @@ -400,17 +467,17 @@ msgid "" "the positional arguments." msgstr "" -#: ../../c-api/structures.rst:328 +#: ../../c-api/structures.rst:371 msgid "" "Can only be used in the combination with other flags: :ref:`METH_METHOD | " "METH_FASTCALL | METH_KEYWORDS `." msgstr "" -#: ../../c-api/structures.rst:334 +#: ../../c-api/structures.rst:377 msgid ":c:expr:`METH_METHOD | METH_FASTCALL | METH_KEYWORDS`" msgstr ":c:expr:`METH_METHOD | METH_FASTCALL | METH_KEYWORDS`" -#: ../../c-api/structures.rst:335 +#: ../../c-api/structures.rst:378 msgid "" "Extension of :ref:`METH_FASTCALL | METH_KEYWORDS ` supporting the *defining class*, that is, the class that " @@ -418,14 +485,14 @@ msgid "" "``Py_TYPE(self)``." msgstr "" -#: ../../c-api/structures.rst:340 +#: ../../c-api/structures.rst:383 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:349 +#: ../../c-api/structures.rst:392 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 " @@ -434,22 +501,22 @@ msgid "" "the second parameter will be ``NULL``." msgstr "" -#: ../../c-api/structures.rst:355 +#: ../../c-api/structures.rst:398 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." +"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:361 +#: ../../c-api/structures.rst:404 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 ``\"O\"`` argument. They have the type :c:type:`PyCFunction`, with " -"the *self* parameter, and a :c:expr:`PyObject*` parameter representing the " +"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 " +"``\"O\"`` argument. They have the type :c:type:`PyCFunction`, with the " +"*self* parameter, and a :c:expr:`PyObject*` parameter representing the " "single argument." msgstr "" -#: ../../c-api/structures.rst:367 +#: ../../c-api/structures.rst:410 msgid "" "These two constants are not used to indicate the calling convention but the " "binding when use with methods of classes. These may not be used for " @@ -457,53 +524,71 @@ msgid "" "any given method." msgstr "" -#: ../../c-api/structures.rst:377 +#: ../../c-api/structures.rst:420 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 :func:`classmethod` built-in function." msgstr "" -#: ../../c-api/structures.rst:387 +#: ../../c-api/structures.rst:430 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 :func:`staticmethod` built-in function." msgstr "" -#: ../../c-api/structures.rst:391 +#: ../../c-api/structures.rst:434 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:397 +#: ../../c-api/structures.rst:440 msgid "" "The method will be loaded in place of existing definitions. Without " "*METH_COEXIST*, the default is to skip repeated definitions. Since slot " "wrappers are loaded before the method table, the existence of a " -"*sq_contains* slot, for example, would generate a wrapped method " -"named :meth:`~object.__contains__` and preclude the loading of a " -"corresponding PyCFunction with the same name. With the flag defined, the " -"PyCFunction will be loaded in place of the wrapper object and will co-exist " -"with the slot. This is helpful because calls to PyCFunctions are optimized " -"more than wrapper object calls." +"*sq_contains* slot, for example, would generate a wrapped method named :meth:" +"`~object.__contains__` and preclude the loading of a corresponding " +"PyCFunction with the same name. With the flag defined, the PyCFunction will " +"be loaded in place of the wrapper object and will co-exist with the slot. " +"This is helpful because calls to PyCFunctions are optimized more than " +"wrapper object calls." msgstr "" -#: ../../c-api/structures.rst:409 +#: ../../c-api/structures.rst:453 +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 +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 +msgid "" +"This is the same as :c:func:`PyCMethod_Check`, but does not account for " +"subtypes." +msgstr "" + +#: ../../c-api/structures.rst:471 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:413 +#: ../../c-api/structures.rst:475 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:417 +#: ../../c-api/structures.rst:479 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 " @@ -511,89 +596,171 @@ msgid "" "can be set to :const:`None` or ``NULL``." msgstr "" -#: ../../c-api/structures.rst:423 +#: ../../c-api/structures.rst:485 msgid ":attr:`function.__module__`" msgstr ":attr:`function.__module__`" -#: ../../c-api/structures.rst:425 +#: ../../c-api/structures.rst:487 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:434 +#: ../../c-api/structures.rst:496 +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 +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 +msgid "" +"This is the same as :c:func:`PyCFunction_Check`, but does not account for " +"subtypes." +msgstr "" + +#: ../../c-api/structures.rst:514 msgid "Equivalent to ``PyCMethod_New(ml, self, module, NULL)``." msgstr "等價於 ``PyCMethod_New(ml, self, module, NULL)``。" -#: ../../c-api/structures.rst:439 +#: ../../c-api/structures.rst:519 msgid "Equivalent to ``PyCMethod_New(ml, self, NULL, NULL)``." msgstr "等價於 ``PyCMethod_New(ml, self, NULL, NULL)``。" -#: ../../c-api/structures.rst:443 +#: ../../c-api/structures.rst:524 +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 +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 +msgid "" +"This function returns the function's flags on success, and ``-1`` with an " +"exception set on failure." +msgstr "" + +#: ../../c-api/structures.rst:536 +msgid "" +"This is the same as :c:func:`PyCFunction_GetFlags`, but without error or " +"type checking." +msgstr "" + +#: ../../c-api/structures.rst:542 +msgid "" +"Get the function pointer on *func* as it was passed to :c:member:" +"`~PyMethodDef.ml_meth`." +msgstr "" + +#: ../../c-api/structures.rst:548 +msgid "" +"This function returns the function pointer on success, and ``NULL`` with an " +"exception set on failure." +msgstr "" + +#: ../../c-api/structures.rst:554 +msgid "" +"This is the same as :c:func:`PyCFunction_GetFunction`, but without error or " +"type checking." +msgstr "" + +#: ../../c-api/structures.rst:560 +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 " +"created through a :c:type:`PyMethodDef` on a :c:type:`PyModuleDef`, this is " +"the resulting module object." +msgstr "" + +#: ../../c-api/structures.rst:568 +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 +msgid "" +"This is the same as :c:func:`PyCFunction_GetSelf`, but without error or type " +"checking." +msgstr "" + +#: ../../c-api/structures.rst:579 msgid "Accessing attributes of extension types" msgstr "" -#: ../../c-api/structures.rst:447 +#: ../../c-api/structures.rst:583 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:452 +#: ../../c-api/structures.rst:588 msgid "Its fields are, in order:" msgstr "" -#: ../../c-api/structures.rst:456 +#: ../../c-api/structures.rst:592 msgid "" "Name of the member. A NULL value marks the end of a ``PyMemberDef[]`` array." msgstr "" -#: ../../c-api/structures.rst:459 +#: ../../c-api/structures.rst:595 msgid "The string should be static, no copy is made of it." msgstr "" -#: ../../c-api/structures.rst:463 +#: ../../c-api/structures.rst:599 msgid "" "The type of the member in the C struct. See :ref:`PyMemberDef-types` for the " "possible values." msgstr "" -#: ../../c-api/structures.rst:468 +#: ../../c-api/structures.rst:604 msgid "" "The offset in bytes that the member is located on the type’s object struct." msgstr "" -#: ../../c-api/structures.rst:472 +#: ../../c-api/structures.rst:608 msgid "" "Zero or more of the :ref:`PyMemberDef-flags`, combined using bitwise OR." msgstr "" -#: ../../c-api/structures.rst:476 +#: ../../c-api/structures.rst:612 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:480 +#: ../../c-api/structures.rst:616 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-" -"only access. Certain types, like :c:macro:`Py_T_STRING`, " -"imply :c:macro:`Py_READONLY`. Only :c:macro:`Py_T_OBJECT_EX` (and " -"legacy :c:macro:`T_OBJECT`) members can be deleted." +"only access. Certain types, like :c:macro:`Py_T_STRING`, imply :c:macro:" +"`Py_READONLY`. Only :c:macro:`Py_T_OBJECT_EX` (and legacy :c:macro:" +"`T_OBJECT`) members can be deleted." msgstr "" -#: ../../c-api/structures.rst:489 +#: ../../c-api/structures.rst:625 msgid "" "For heap-allocated types (created using :c:func:`PyType_FromSpec` or " "similar), ``PyMemberDef`` may contain a definition for the special member " -"``\"__vectorcalloffset__\"``, corresponding " -"to :c:member:`~PyTypeObject.tp_vectorcall_offset` in type objects. These " -"must be defined with ``Py_T_PYSSIZET`` and ``Py_READONLY``, for example::" +"``\"__vectorcalloffset__\"``, corresponding to :c:member:`~PyTypeObject." +"tp_vectorcall_offset` in type objects. This member must be defined with " +"``Py_T_PYSSIZET``, and either ``Py_READONLY`` or ``Py_READONLY | " +"Py_RELATIVE_OFFSET``. For example::" msgstr "" -#: ../../c-api/structures.rst:495 +#: ../../c-api/structures.rst:632 msgid "" "static PyMemberDef spam_type_members[] = {\n" " {\"__vectorcalloffset__\", Py_T_PYSSIZET,\n" @@ -607,92 +774,93 @@ msgstr "" " {NULL} /* Sentinel */\n" "};" -#: ../../c-api/structures.rst:501 +#: ../../c-api/structures.rst:638 msgid "(You may need to ``#include `` for :c:func:`!offsetof`.)" msgstr "" -#: ../../c-api/structures.rst:503 +#: ../../c-api/structures.rst:640 msgid "" -"The legacy offsets :c:member:`~PyTypeObject.tp_dictoffset` " -"and :c:member:`~PyTypeObject.tp_weaklistoffset` can be defined similarly " -"using ``\"__dictoffset__\"`` and ``\"__weaklistoffset__\"`` members, but " +"The legacy offsets :c:member:`~PyTypeObject.tp_dictoffset` and :c:member:" +"`~PyTypeObject.tp_weaklistoffset` can be defined similarly using " +"``\"__dictoffset__\"`` and ``\"__weaklistoffset__\"`` members, but " "extensions are strongly encouraged to use :c:macro:`Py_TPFLAGS_MANAGED_DICT` " "and :c:macro:`Py_TPFLAGS_MANAGED_WEAKREF` instead." msgstr "" -#: ../../c-api/structures.rst:511 +#: ../../c-api/structures.rst:648 msgid "" "``PyMemberDef`` is always available. Previously, it required including " "``\"structmember.h\"``." msgstr "" -#: ../../c-api/structures.rst:516 +#: ../../c-api/structures.rst:653 +msgid "" +":c:macro:`Py_RELATIVE_OFFSET` is now allowed for " +"``\"__vectorcalloffset__\"``, ``\"__dictoffset__\"`` and " +"``\"__weaklistoffset__\"``." +msgstr "" + +#: ../../c-api/structures.rst:659 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:522 +#: ../../c-api/structures.rst:665 msgid "" "``PyMember_GetOne`` is always available. Previously, it required including " "``\"structmember.h\"``." msgstr "" -#: ../../c-api/structures.rst:527 +#: ../../c-api/structures.rst:670 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:533 +#: ../../c-api/structures.rst:676 msgid "" "``PyMember_SetOne`` is always available. Previously, it required including " "``\"structmember.h\"``." msgstr "" -#: ../../c-api/structures.rst:539 +#: ../../c-api/structures.rst:682 msgid "Member flags" msgstr "" -#: ../../c-api/structures.rst:541 +#: ../../c-api/structures.rst:684 msgid "The following flags can be used with :c:member:`PyMemberDef.flags`:" msgstr "" -#: ../../c-api/structures.rst:545 +#: ../../c-api/structures.rst:688 msgid "Not writable." msgstr "不可寫入。" -#: ../../c-api/structures.rst:549 +#: ../../c-api/structures.rst:692 msgid "" "Emit an ``object.__getattr__`` :ref:`audit event ` before " "reading." msgstr "" -#: ../../c-api/structures.rst:554 +#: ../../c-api/structures.rst:697 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:558 -msgid "" -"Can only be used as part of :c:member:`Py_tp_members " -"` :c:type:`slot ` when creating a " -"class using negative :c:member:`~PyType_Spec.basicsize`. It is mandatory in " -"that case." -msgstr "" - -#: ../../c-api/structures.rst:563 +#: ../../c-api/structures.rst:701 msgid "" -"This flag is only used in :c:type:`PyType_Slot`. When " -"setting :c:member:`~PyTypeObject.tp_members` during class creation, Python " -"clears it and sets :c:member:`PyMemberDef.offset` to the offset from the " -"``PyObject`` struct." +"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." +"basicsize`. It is mandatory in that case. When setting :c:member:" +"`~PyTypeObject.tp_members` from the slot during class creation, Python " +"clears the flag and sets :c:member:`PyMemberDef.offset` to the offset from " +"the ``PyObject`` struct." msgstr "" -#: ../../c-api/structures.rst:575 +#: ../../c-api/structures.rst:716 msgid "" "The :c:macro:`!RESTRICTED`, :c:macro:`!READ_RESTRICTED` and :c:macro:`!" "WRITE_RESTRICTED` macros available with ``#include \"structmember.h\"`` are " @@ -701,20 +869,20 @@ msgid "" "nothing." msgstr "" -#: ../../c-api/structures.rst:586 +#: ../../c-api/structures.rst:727 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 names are now always available. Previously, these required ``#include " +"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 " +"names are now always available. Previously, these required ``#include " "\"structmember.h\"``. The header is still available and it provides the old " "names." msgstr "" -#: ../../c-api/structures.rst:595 +#: ../../c-api/structures.rst:736 msgid "Member types" msgstr "" -#: ../../c-api/structures.rst:597 +#: ../../c-api/structures.rst:738 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 " @@ -723,147 +891,147 @@ msgid "" "exception such as :exc:`TypeError` or :exc:`ValueError` is raised." msgstr "" -#: ../../c-api/structures.rst:605 +#: ../../c-api/structures.rst:746 msgid "" -"Unless marked (D), attributes defined this way cannot be deleted using " -"e.g. :keyword:`del` or :py:func:`delattr`." +"Unless marked (D), attributes defined this way cannot be deleted using e.g. :" +"keyword:`del` or :py:func:`delattr`." msgstr "" -#: ../../c-api/structures.rst:609 +#: ../../c-api/structures.rst:750 msgid "Macro name" msgstr "巨集名稱" -#: ../../c-api/structures.rst:609 +#: ../../c-api/structures.rst:750 msgid "C type" msgstr "" -#: ../../c-api/structures.rst:609 +#: ../../c-api/structures.rst:750 msgid "Python type" msgstr "" -#: ../../c-api/structures.rst:611 +#: ../../c-api/structures.rst:752 msgid ":c:expr:`char`" msgstr ":c:expr:`char`" -#: ../../c-api/structures.rst:611 ../../c-api/structures.rst:612 -#: ../../c-api/structures.rst:613 ../../c-api/structures.rst:614 -#: ../../c-api/structures.rst:615 ../../c-api/structures.rst:616 -#: ../../c-api/structures.rst:617 ../../c-api/structures.rst:618 -#: ../../c-api/structures.rst:619 ../../c-api/structures.rst:620 -#: ../../c-api/structures.rst:621 +#: ../../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 msgid ":py:class:`int`" msgstr ":py:class:`int`" -#: ../../c-api/structures.rst:612 +#: ../../c-api/structures.rst:753 msgid ":c:expr:`short`" msgstr ":c:expr:`short`" -#: ../../c-api/structures.rst:613 +#: ../../c-api/structures.rst:754 msgid ":c:expr:`int`" msgstr ":c:expr:`int`" -#: ../../c-api/structures.rst:614 +#: ../../c-api/structures.rst:755 msgid ":c:expr:`long`" msgstr ":c:expr:`long`" -#: ../../c-api/structures.rst:615 +#: ../../c-api/structures.rst:756 msgid ":c:expr:`long long`" msgstr ":c:expr:`long long`" -#: ../../c-api/structures.rst:616 +#: ../../c-api/structures.rst:757 msgid ":c:expr:`unsigned char`" msgstr ":c:expr:`unsigned char`" -#: ../../c-api/structures.rst:617 +#: ../../c-api/structures.rst:758 msgid ":c:expr:`unsigned int`" msgstr ":c:expr:`unsigned int`" -#: ../../c-api/structures.rst:618 +#: ../../c-api/structures.rst:759 msgid ":c:expr:`unsigned short`" msgstr ":c:expr:`unsigned short`" -#: ../../c-api/structures.rst:619 +#: ../../c-api/structures.rst:760 msgid ":c:expr:`unsigned long`" msgstr ":c:expr:`unsigned long`" -#: ../../c-api/structures.rst:620 +#: ../../c-api/structures.rst:761 msgid ":c:expr:`unsigned long long`" msgstr ":c:expr:`unsigned long long`" -#: ../../c-api/structures.rst:621 +#: ../../c-api/structures.rst:762 msgid ":c:expr:`Py_ssize_t`" msgstr ":c:expr:`Py_ssize_t`" -#: ../../c-api/structures.rst:622 +#: ../../c-api/structures.rst:763 msgid ":c:expr:`float`" msgstr ":c:expr:`float`" -#: ../../c-api/structures.rst:622 ../../c-api/structures.rst:623 +#: ../../c-api/structures.rst:763 ../../c-api/structures.rst:764 msgid ":py:class:`float`" msgstr ":py:class:`float`" -#: ../../c-api/structures.rst:623 +#: ../../c-api/structures.rst:764 msgid ":c:expr:`double`" msgstr ":c:expr:`double`" -#: ../../c-api/structures.rst:624 +#: ../../c-api/structures.rst:765 msgid ":c:expr:`char` (written as 0 or 1)" msgstr ":c:expr:`char` (寫成 0 或 1)" -#: ../../c-api/structures.rst:624 +#: ../../c-api/structures.rst:765 msgid ":py:class:`bool`" msgstr ":py:class:`bool`" -#: ../../c-api/structures.rst:626 +#: ../../c-api/structures.rst:767 msgid ":c:expr:`const char *` (*)" msgstr ":c:expr:`const char *` (*)" -#: ../../c-api/structures.rst:626 ../../c-api/structures.rst:627 +#: ../../c-api/structures.rst:767 ../../c-api/structures.rst:768 msgid ":py:class:`str` (RO)" msgstr ":py:class:`str` (RO)" -#: ../../c-api/structures.rst:627 +#: ../../c-api/structures.rst:768 msgid ":c:expr:`const char[]` (*)" msgstr ":c:expr:`const char[]` (*)" -#: ../../c-api/structures.rst:628 +#: ../../c-api/structures.rst:769 msgid ":c:expr:`char` (0-127)" msgstr ":c:expr:`char` (0-127)" -#: ../../c-api/structures.rst:628 +#: ../../c-api/structures.rst:769 msgid ":py:class:`str` (**)" msgstr ":py:class:`str` (**)" -#: ../../c-api/structures.rst:629 +#: ../../c-api/structures.rst:770 msgid ":c:expr:`PyObject *`" msgstr ":c:expr:`PyObject *`" -#: ../../c-api/structures.rst:629 +#: ../../c-api/structures.rst:770 msgid ":py:class:`object` (D)" msgstr ":py:class:`object` (D)" -#: ../../c-api/structures.rst:632 +#: ../../c-api/structures.rst:773 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:637 +#: ../../c-api/structures.rst:778 msgid "(**): String of length 1. Only ASCII is accepted." msgstr "" -#: ../../c-api/structures.rst:639 +#: ../../c-api/structures.rst:780 msgid "(RO): Implies :c:macro:`Py_READONLY`." msgstr "" -#: ../../c-api/structures.rst:641 +#: ../../c-api/structures.rst:782 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:667 +#: ../../c-api/structures.rst:808 msgid "" "In previous versions, the macros were only available with ``#include " "\"structmember.h\"`` and were named without the ``Py_`` prefix (e.g. as " @@ -871,174 +1039,183 @@ msgid "" "with the following deprecated types:" msgstr "" -#: ../../c-api/structures.rst:675 +#: ../../c-api/structures.rst:816 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:681 +#: ../../c-api/structures.rst:822 msgid "Always ``None``. Must be used with :c:macro:`Py_READONLY`." msgstr "" -#: ../../c-api/structures.rst:684 +#: ../../c-api/structures.rst:825 msgid "Defining Getters and Setters" msgstr "" -#: ../../c-api/structures.rst:688 +#: ../../c-api/structures.rst:829 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:693 +#: ../../c-api/structures.rst:834 msgid "attribute name" msgstr "屬性名稱" -#: ../../c-api/structures.rst:697 +#: ../../c-api/structures.rst:838 msgid "C function to get the attribute." msgstr "" -#: ../../c-api/structures.rst:701 +#: ../../c-api/structures.rst:842 msgid "" "Optional C function to set or delete the attribute. If ``NULL``, the " "attribute is read-only." msgstr "" -#: ../../c-api/structures.rst:706 +#: ../../c-api/structures.rst:847 msgid "optional docstring" msgstr "可選的文件字串" -#: ../../c-api/structures.rst:710 +#: ../../c-api/structures.rst:851 msgid "" "Optional user data pointer, providing additional data for getter and setter." msgstr "" -#: ../../c-api/structures.rst:714 +#: ../../c-api/structures.rst:855 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:717 +#: ../../c-api/structures.rst:858 msgid "" "It should return a new reference on success or ``NULL`` with a set exception " "on failure." msgstr "" -#: ../../c-api/structures.rst:722 +#: ../../c-api/structures.rst:863 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:725 +#: ../../c-api/structures.rst:866 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:375 ../../c-api/structures.rst:385 +#: ../../c-api/structures.rst:418 ../../c-api/structures.rst:428 msgid "built-in function" msgstr "built-in function(內建函式)" -#: ../../c-api/structures.rst:375 +#: ../../c-api/structures.rst:418 msgid "classmethod" msgstr "classmethod" -#: ../../c-api/structures.rst:385 +#: ../../c-api/structures.rst:428 msgid "staticmethod" msgstr "staticmethod" -#: ../../c-api/structures.rst:568 +#: ../../c-api/structures.rst:709 msgid "READ_RESTRICTED (C macro)" msgstr "READ_RESTRICTED(C 巨集)" -#: ../../c-api/structures.rst:568 +#: ../../c-api/structures.rst:709 msgid "WRITE_RESTRICTED (C macro)" msgstr "WRITE_RESTRICTED(C 巨集)" -#: ../../c-api/structures.rst:568 +#: ../../c-api/structures.rst:709 msgid "RESTRICTED (C macro)" msgstr "RESTRICTED(C 巨集)" -#: ../../c-api/structures.rst:581 +#: ../../c-api/structures.rst:722 msgid "READONLY (C macro)" msgstr "READONLY(C 巨集)" -#: ../../c-api/structures.rst:644 +#: ../../c-api/structures.rst:785 msgid "T_BYTE (C macro)" msgstr "T_BYTE(C 巨集)" -#: ../../c-api/structures.rst:644 +#: ../../c-api/structures.rst:785 msgid "T_SHORT (C macro)" msgstr "T_SHORT(C 巨集)" -#: ../../c-api/structures.rst:644 +#: ../../c-api/structures.rst:785 msgid "T_INT (C macro)" msgstr "T_INT(C 巨集)" -#: ../../c-api/structures.rst:644 +#: ../../c-api/structures.rst:785 msgid "T_LONG (C macro)" msgstr "T_LONG(C 巨集)" -#: ../../c-api/structures.rst:644 +#: ../../c-api/structures.rst:785 msgid "T_LONGLONG (C macro)" msgstr "T_LONGLONG(C 巨集)" -#: ../../c-api/structures.rst:644 +#: ../../c-api/structures.rst:785 msgid "T_UBYTE (C macro)" msgstr "T_UBYTE(C 巨集)" -#: ../../c-api/structures.rst:644 +#: ../../c-api/structures.rst:785 msgid "T_USHORT (C macro)" msgstr "T_USHORT(C 巨集)" -#: ../../c-api/structures.rst:644 +#: ../../c-api/structures.rst:785 msgid "T_UINT (C macro)" msgstr "T_UINT(C 巨集)" -#: ../../c-api/structures.rst:644 +#: ../../c-api/structures.rst:785 msgid "T_ULONG (C macro)" msgstr "T_ULONG(C 巨集)" -#: ../../c-api/structures.rst:644 +#: ../../c-api/structures.rst:785 msgid "T_ULONGULONG (C macro)" msgstr "T_ULONGULONG(C 巨集)" -#: ../../c-api/structures.rst:644 +#: ../../c-api/structures.rst:785 msgid "T_PYSSIZET (C macro)" msgstr "T_PYSSIZET(C 巨集)" -#: ../../c-api/structures.rst:644 +#: ../../c-api/structures.rst:785 msgid "T_FLOAT (C macro)" msgstr "T_FLOAT(C 巨集)" -#: ../../c-api/structures.rst:644 +#: ../../c-api/structures.rst:785 msgid "T_DOUBLE (C macro)" msgstr "T_DOUBLE(C 巨集)" -#: ../../c-api/structures.rst:644 +#: ../../c-api/structures.rst:785 msgid "T_BOOL (C macro)" msgstr "T_BOOL(C 巨集)" -#: ../../c-api/structures.rst:644 +#: ../../c-api/structures.rst:785 msgid "T_CHAR (C macro)" msgstr "T_CHAR(C 巨集)" -#: ../../c-api/structures.rst:644 +#: ../../c-api/structures.rst:785 msgid "T_STRING (C macro)" msgstr "T_STRING(C 巨集)" -#: ../../c-api/structures.rst:644 +#: ../../c-api/structures.rst:785 msgid "T_STRING_INPLACE (C macro)" msgstr "T_STRING_INPLACE(C 巨集)" -#: ../../c-api/structures.rst:644 +#: ../../c-api/structures.rst:785 msgid "T_OBJECT_EX (C macro)" msgstr "T_OBJECT_EX(C 巨集)" -#: ../../c-api/structures.rst:644 +#: ../../c-api/structures.rst:785 msgid "structmember.h" msgstr "structmember.h" + +#~ msgid "Set the object *o* type to *type*." +#~ msgstr "將物件 *o* 的型別設為 *type*。" + +#~ msgid "Get the size of the Python object *o*." +#~ msgstr "取得 Python 物件 *o* 的大小。" + +#~ msgid "Set the object *o* size to *size*." +#~ msgstr "將物件 *o* 的大小設為 *size*。" diff --git a/c-api/sys.po b/c-api/sys.po index 79a6fb3f3f5..40e4b155f5a 100644 --- a/c-api/sys.po +++ b/c-api/sys.po @@ -1,5 +1,4 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -8,9 +7,9 @@ # Liang-Bo Wang , 2015 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-12-12 00:15+0000\n" +"POT-Creation-Date: 2025-11-14 19:37+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-" @@ -139,20 +138,45 @@ msgid "" msgstr "" #: ../../c-api/sys.rst:129 +msgid "Check if a :c:macro:`!SIGINT` signal has been received." +msgstr "" + +#: ../../c-api/sys.rst:131 +msgid "" +"Returns ``1`` if a :c:macro:`!SIGINT` has occurred and clears the signal " +"flag, or ``0`` otherwise." +msgstr "" + +#: ../../c-api/sys.rst:134 +msgid "" +"In most cases, you should prefer :c:func:`PyErr_CheckSignals` over this " +"function. :c:func:`!PyErr_CheckSignals` invokes the appropriate signal " +"handlers for all pending signals, allowing Python code to handle the signal " +"properly. This function only detects :c:macro:`!SIGINT` and does not invoke " +"any Python signal handlers." +msgstr "" + +#: ../../c-api/sys.rst:140 +msgid "" +"This function is async-signal-safe and this function cannot fail. The caller " +"must hold an :term:`attached thread state`." +msgstr "" + +#: ../../c-api/sys.rst:147 msgid "" "This function should not be called directly: use the :c:type:`PyConfig` API " "with the :c:func:`PyConfig_SetBytesString` function which ensures that :ref:" "`Python is preinitialized `." msgstr "" -#: ../../c-api/sys.rst:133 ../../c-api/sys.rst:200 +#: ../../c-api/sys.rst:151 ../../c-api/sys.rst:218 msgid "" "This function must not be called before :ref:`Python is preinitialized ` and so that the LC_CTYPE locale is properly configured: see the :c:" "func:`Py_PreInitialize` function." msgstr "" -#: ../../c-api/sys.rst:137 +#: ../../c-api/sys.rst:155 msgid "" "Decode a byte string from the :term:`filesystem encoding and error handler`. " "If the error handler is :ref:`surrogateescape error handler " @@ -162,57 +186,57 @@ msgid "" "instead of decoding them." msgstr "" -#: ../../c-api/sys.rst:144 +#: ../../c-api/sys.rst:162 msgid "" "Return a pointer to a newly allocated wide character string, use :c:func:" "`PyMem_RawFree` to free the memory. If size is not ``NULL``, write the " "number of wide characters excluding the null character into ``*size``" msgstr "" -#: ../../c-api/sys.rst:148 +#: ../../c-api/sys.rst:166 msgid "" "Return ``NULL`` on decoding error or memory allocation error. If *size* is " "not ``NULL``, ``*size`` is set to ``(size_t)-1`` on memory error or set to " "``(size_t)-2`` on decoding error." msgstr "" -#: ../../c-api/sys.rst:152 ../../c-api/sys.rst:192 +#: ../../c-api/sys.rst:170 ../../c-api/sys.rst:210 msgid "" "The :term:`filesystem encoding and error handler` are selected by :c:func:" "`PyConfig_Read`: see :c:member:`~PyConfig.filesystem_encoding` and :c:member:" "`~PyConfig.filesystem_errors` members of :c:type:`PyConfig`." msgstr "" -#: ../../c-api/sys.rst:156 +#: ../../c-api/sys.rst:174 msgid "" "Decoding errors should never happen, unless there is a bug in the C library." msgstr "" -#: ../../c-api/sys.rst:159 +#: ../../c-api/sys.rst:177 msgid "" "Use the :c:func:`Py_EncodeLocale` function to encode the character string " "back to a byte string." msgstr "" -#: ../../c-api/sys.rst:164 +#: ../../c-api/sys.rst:182 msgid "" "The :c:func:`PyUnicode_DecodeFSDefaultAndSize` and :c:func:" "`PyUnicode_DecodeLocaleAndSize` functions." msgstr "" -#: ../../c-api/sys.rst:169 ../../c-api/sys.rst:211 +#: ../../c-api/sys.rst:187 ../../c-api/sys.rst:229 msgid "" "The function now uses the UTF-8 encoding in the :ref:`Python UTF-8 Mode " "`." msgstr "" -#: ../../c-api/sys.rst:173 +#: ../../c-api/sys.rst:191 msgid "" "The function now uses the UTF-8 encoding on Windows if :c:member:" "`PyPreConfig.legacy_windows_fs_encoding` is zero;" msgstr "" -#: ../../c-api/sys.rst:180 +#: ../../c-api/sys.rst:198 msgid "" "Encode a wide character string to the :term:`filesystem encoding and error " "handler`. If the error handler is :ref:`surrogateescape error handler " @@ -220,42 +244,85 @@ msgid "" "converted to bytes 0x80..0xFF." msgstr "" -#: ../../c-api/sys.rst:185 +#: ../../c-api/sys.rst:203 msgid "" "Return a pointer to a newly allocated byte string, use :c:func:`PyMem_Free` " "to free the memory. Return ``NULL`` on encoding error or memory allocation " "error." msgstr "" -#: ../../c-api/sys.rst:189 +#: ../../c-api/sys.rst:207 msgid "" "If error_pos is not ``NULL``, ``*error_pos`` is set to ``(size_t)-1`` on " "success, or set to the index of the invalid character on encoding error." msgstr "" -#: ../../c-api/sys.rst:196 +#: ../../c-api/sys.rst:214 msgid "" "Use the :c:func:`Py_DecodeLocale` function to decode the bytes string back " "to a wide character string." msgstr "" -#: ../../c-api/sys.rst:206 +#: ../../c-api/sys.rst:224 msgid "" "The :c:func:`PyUnicode_EncodeFSDefault` and :c:func:`PyUnicode_EncodeLocale` " "functions." msgstr "" -#: ../../c-api/sys.rst:215 +#: ../../c-api/sys.rst:233 msgid "" "The function now uses the UTF-8 encoding on Windows if :c:member:" "`PyPreConfig.legacy_windows_fs_encoding` is zero." msgstr "" -#: ../../c-api/sys.rst:223 +#: ../../c-api/sys.rst:239 +msgid "" +"Similar to :c:func:`!fopen`, but *path* is a Python object and an exception " +"is set on error." +msgstr "" + +#: ../../c-api/sys.rst:242 +msgid "" +"*path* must be a :class:`str` object, a :class:`bytes` object, or a :term:" +"`path-like object`." +msgstr "" + +#: ../../c-api/sys.rst:245 +msgid "" +"On success, return the new file pointer. On error, set an exception and " +"return ``NULL``." +msgstr "" + +#: ../../c-api/sys.rst:248 +msgid "" +"The file must be closed by :c:func:`Py_fclose` rather than calling directly :" +"c:func:`!fclose`." +msgstr "" + +#: ../../c-api/sys.rst:251 +msgid "The file descriptor is created non-inheritable (:pep:`446`)." +msgstr "" + +#: ../../c-api/sys.rst:253 +msgid "The caller must have an :term:`attached thread state`." +msgstr "" + +#: ../../c-api/sys.rst:260 +msgid "Close a file that was opened by :c:func:`Py_fopen`." +msgstr "" + +#: ../../c-api/sys.rst:262 +msgid "" +"On success, return ``0``. On error, return ``EOF`` and ``errno`` is set to " +"indicate the error. In either case, any further access (including another " +"call to :c:func:`Py_fclose`) to the stream results in undefined behavior." +msgstr "" + +#: ../../c-api/sys.rst:273 msgid "System Functions" msgstr "系統函式" -#: ../../c-api/sys.rst:225 +#: ../../c-api/sys.rst:275 msgid "" "These are utility functions that make functionality from the :mod:`sys` " "module accessible to C code. They all work with the current interpreter " @@ -263,36 +330,36 @@ msgid "" "state structure." msgstr "" -#: ../../c-api/sys.rst:231 +#: ../../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." msgstr "" -#: ../../c-api/sys.rst:236 +#: ../../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." msgstr "" -#: ../../c-api/sys.rst:242 +#: ../../c-api/sys.rst:292 msgid "" "Reset :data:`sys.warnoptions` to an empty list. This function may be called " "prior to :c:func:`Py_Initialize`." msgstr "" -#: ../../c-api/sys.rst:245 +#: ../../c-api/sys.rst:295 msgid "Clear :data:`sys.warnoptions` and :data:`!warnings.filters` instead." msgstr "" -#: ../../c-api/sys.rst:250 +#: ../../c-api/sys.rst:300 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:253 +#: ../../c-api/sys.rst:303 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 " @@ -303,48 +370,48 @@ msgid "" "of digits for very large numbers." msgstr "" -#: ../../c-api/sys.rst:261 +#: ../../c-api/sys.rst:311 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:266 +#: ../../c-api/sys.rst:316 msgid "" "As :c:func:`PySys_WriteStdout`, but write to :data:`sys.stderr` or *stderr* " "instead." msgstr "" -#: ../../c-api/sys.rst:271 +#: ../../c-api/sys.rst:321 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:279 +#: ../../c-api/sys.rst:329 msgid "" "As :c:func:`PySys_FormatStdout`, but write to :data:`sys.stderr` or *stderr* " "instead." msgstr "" -#: ../../c-api/sys.rst:286 +#: ../../c-api/sys.rst:336 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:295 +#: ../../c-api/sys.rst:345 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:298 +#: ../../c-api/sys.rst:348 msgid "The *event* string argument must not be *NULL*." msgstr "" -#: ../../c-api/sys.rst:300 +#: ../../c-api/sys.rst:350 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 " @@ -352,40 +419,40 @@ msgid "" "tuple, it will be added into a single-element tuple." msgstr "" -#: ../../c-api/sys.rst:305 +#: ../../c-api/sys.rst:355 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:309 +#: ../../c-api/sys.rst:359 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:312 +#: ../../c-api/sys.rst:362 msgid ":func:`sys.audit` performs the same function from Python code." msgstr "" -#: ../../c-api/sys.rst:314 +#: ../../c-api/sys.rst:364 msgid "See also :c:func:`PySys_AuditTuple`." msgstr "請參閱 :c:func:`PySys_AuditTuple`。" -#: ../../c-api/sys.rst:320 +#: ../../c-api/sys.rst:370 msgid "" "Require :c:type:`Py_ssize_t` for ``#`` format characters. Previously, an " "unavoidable deprecation warning was raised." msgstr "" -#: ../../c-api/sys.rst:326 +#: ../../c-api/sys.rst:376 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:334 +#: ../../c-api/sys.rst:384 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, " @@ -393,14 +460,14 @@ msgid "" "all interpreters created by the runtime." msgstr "" -#: ../../c-api/sys.rst:340 +#: ../../c-api/sys.rst:390 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:344 +#: ../../c-api/sys.rst:394 msgid "" "This function is safe to call before :c:func:`Py_Initialize`. When called " "after runtime initialization, existing audit hooks are notified and may " @@ -408,20 +475,20 @@ msgid "" "`Exception` (other errors will not be silenced)." msgstr "" -#: ../../c-api/sys.rst:349 +#: ../../c-api/sys.rst:399 msgid "" -"The hook function is always called with the GIL held by the Python " -"interpreter that raised the event." +"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:352 +#: ../../c-api/sys.rst:402 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:357 ../../c-api/sys.rst:359 +#: ../../c-api/sys.rst:407 ../../c-api/sys.rst:409 msgid "" "If the interpreter is initialized, this function raises an auditing event " "``sys.addaudithook`` with no arguments. If any existing hooks raise an " @@ -430,7 +497,7 @@ msgid "" "hook has been added unless they control all existing hooks." msgstr "" -#: ../../c-api/sys.rst:368 +#: ../../c-api/sys.rst:418 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 " @@ -438,11 +505,11 @@ msgid "" "PySys_AddAuditHook()." msgstr "" -#: ../../c-api/sys.rst:380 +#: ../../c-api/sys.rst:430 msgid "Process Control" msgstr "行程控制" -#: ../../c-api/sys.rst:387 +#: ../../c-api/sys.rst:437 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 " @@ -452,29 +519,29 @@ msgid "" "file:`core` file." msgstr "" -#: ../../c-api/sys.rst:394 +#: ../../c-api/sys.rst:444 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:398 +#: ../../c-api/sys.rst:448 msgid "Log the function name automatically." msgstr "" -#: ../../c-api/sys.rst:408 +#: ../../c-api/sys.rst:458 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:412 +#: ../../c-api/sys.rst:462 msgid "Errors from finalization no longer ignored." msgstr "" -#: ../../c-api/sys.rst:422 +#: ../../c-api/sys.rst:472 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 " @@ -486,7 +553,7 @@ msgid "" "should be called by *func*." msgstr "" -#: ../../c-api/sys.rst:432 +#: ../../c-api/sys.rst:482 msgid ":c:func:`PyUnstable_AtExit` for passing a ``void *data`` argument." msgstr "" @@ -494,18 +561,18 @@ msgstr "" msgid "USE_STACKCHECK (C macro)" msgstr "USE_STACKCHECK(C 巨集)" -#: ../../c-api/sys.rst:385 +#: ../../c-api/sys.rst:435 msgid "abort (C function)" msgstr "abort(C 函式)" -#: ../../c-api/sys.rst:404 ../../c-api/sys.rst:418 +#: ../../c-api/sys.rst:454 ../../c-api/sys.rst:468 msgid "Py_FinalizeEx (C function)" msgstr "Py_FinalizeEx(C 函式)" -#: ../../c-api/sys.rst:404 +#: ../../c-api/sys.rst:454 msgid "exit (C function)" msgstr "exit(C 函式)" -#: ../../c-api/sys.rst:418 +#: ../../c-api/sys.rst:468 msgid "cleanup functions" msgstr "cleanup functions(清理函式)" diff --git a/c-api/time.po b/c-api/time.po index 401edfe3890..4ec17128643 100644 --- a/c-api/time.po +++ b/c-api/time.po @@ -1,13 +1,13 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Matt Wang , 2025 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-24 07:20+0000\n" +"POT-Creation-Date: 2025-09-08 15:25+0800\n" "PO-Revision-Date: 2025-05-25 04:26+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -102,9 +102,9 @@ msgstr "" #: ../../c-api/time.rst:58 msgid "" "As any other C API (unless otherwise specified), the functions must be " -"called with the :term:`GIL` held." +"called with an :term:`attached thread state`." msgstr "" -"如同任何其他 C API(除非另有指定),必須在持有 :term:`GIL` 的情況下呼叫函式。" +"如同任何其他 C API(除非另有指定),必須在具有 :term:`attached thread state` 的情況下呼叫函式。" #: ../../c-api/time.rst:63 msgid "" @@ -134,8 +134,8 @@ msgstr "原始時鐘函式" #: ../../c-api/time.rst:80 msgid "" "Similar to clock functions, but don't set an exception on error and don't " -"require the caller to hold the GIL." -msgstr "類似於時鐘函式,但不會在出錯時設定例外,也不需要讓呼叫者持有 GIL。" +"require the caller to have an :term:`attached thread state`." +msgstr "類似於時鐘函式,但不會在出錯時設定例外,也不需要呼叫者擁有 :term:`attached thread state`。" #: ../../c-api/time.rst:83 msgid "On success, the functions return ``0``." @@ -144,35 +144,35 @@ msgstr "成功時函式會回傳 ``0``。" #: ../../c-api/time.rst:85 msgid "" "On failure, they set ``*result`` to ``0`` and return ``-1``, *without* " -"setting an exception. To get the cause of the error, acquire the GIL and " -"call the regular (non-``Raw``) function. Note that the regular function may " -"succeed after the ``Raw`` one failed." +"setting an exception. To get the cause of the error, :term:`attach ` a :term:`thread state`, and call the regular (non-``Raw``) " +"function. Note that the regular function may succeed after the ``Raw`` one " +"failed." msgstr "" "失敗時,它們會將 ``*result`` 設為 ``0`` 並回傳 ``-1``, 而\\ *不*\\ 設定例外。" -"要取得錯誤原因,請取得 GIL 並呼叫常規(非 ``Raw``)函式。請注意,常規函式可能" -"會在 ``Raw`` 的函式失敗後成功。" +"要取得錯誤原因,請\\ :term:`附加 `\\ 一個 :term:`thread state`," +"並呼叫常規(非 ``Raw``)函式。請注意,常規函式可能會在 ``Raw`` 的函式失敗後成功。" #: ../../c-api/time.rst:92 msgid "" "Similar to :c:func:`PyTime_Monotonic`, but don't set an exception on error " -"and don't require holding the GIL." +"and don't require an :term:`attached thread state`." msgstr "" -"類似於 :c:func:`PyTime_Monotonic`,但不會在出錯時設定例外,也不需要持有 GIL。" +"類似於 :c:func:`PyTime_Monotonic`,但不會在錯誤時設定例外,也不需要擁有 :term:`attached thread state`。" #: ../../c-api/time.rst:97 msgid "" "Similar to :c:func:`PyTime_PerfCounter`, but don't set an exception on error " -"and don't require holding the GIL." +"and don't require an :term:`attached thread state`." msgstr "" -"類似於 :c:func:`PyTime_PerfCounter`,但不會在出錯時設定例外,也不需要持有 " -"GIL。" +"類似於 :c:func:`PyTime_PerfCounter`,但不會在錯誤時設定例外,也不需要擁有 :term:`attached thread state`。" #: ../../c-api/time.rst:102 msgid "" "Similar to :c:func:`PyTime_Time`, but don't set an exception on error and " -"don't require holding the GIL." +"don't require an :term:`attached thread state`." msgstr "" -"類似於 :c:func:`PyTime_Time`,但不會在出錯時設定例外,也不需要持有 GIL。" +"類似於 :c:func:`PyTime_Time`,但不會在錯誤時設定例外,也不需要擁有 :term:`attached thread state`。" #: ../../c-api/time.rst:107 msgid "Conversion functions" diff --git a/c-api/tuple.po b/c-api/tuple.po index d70d49e9677..3116a764a7c 100644 --- a/c-api/tuple.po +++ b/c-api/tuple.po @@ -1,16 +1,16 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Leon H., 2017 +# Yorkxe , 2025 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-10-08 00:13+0000\n" -"PO-Revision-Date: 2017-09-22 18:26+0000\n" -"Last-Translator: Leon H.\n" +"POT-Creation-Date: 2025-11-05 00:16+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-" "tw)\n" "Language: zh_TW\n" @@ -25,31 +25,36 @@ msgstr "Tuple(元組)物件" #: ../../c-api/tuple.rst:13 msgid "This subtype of :c:type:`PyObject` represents a Python tuple object." -msgstr "" +msgstr "此 :c:type:`PyObject` 子型別代表 Python 元組物件" #: ../../c-api/tuple.rst:18 msgid "" "This instance of :c:type:`PyTypeObject` represents the Python tuple type; it " "is the same object as :class:`tuple` in the Python layer." msgstr "" +"此 :c:type:`PyTypeObject` 實例代表 Python 元組型別,與 Python 層中的 :class:" +"`tuple` 是同一物件" #: ../../c-api/tuple.rst:24 msgid "" "Return true if *p* is a tuple object or an instance of a subtype of the " "tuple type. This function always succeeds." msgstr "" +"如果 *p* 為一元組物件或是元組型別的子型別實例時回傳 true。此函式總會執行成功" #: ../../c-api/tuple.rst:30 msgid "" "Return true if *p* is a tuple object, but not an instance of a subtype of " "the tuple type. This function always succeeds." msgstr "" +"如果 *p* 為一元組物件但不是元組型別的子型別實例時回傳 true。此函式總會執行成" +"功" #: ../../c-api/tuple.rst:36 msgid "" "Return a new tuple object of size *len*, or ``NULL`` with an exception set " "on failure." -msgstr "" +msgstr "回傳一個長度為 *len* 的新元組物件,失敗會時回傳 ``NULL`` 並設定例外。" #: ../../c-api/tuple.rst:42 msgid "" @@ -58,47 +63,60 @@ msgid "" "pointing to Python objects. ``PyTuple_Pack(2, a, b)`` is equivalent to " "``Py_BuildValue(\"(OO)\", a, b)``." msgstr "" +"回傳一個長度為 *n* 的新元組物件,失敗時會回傳 ``NULL`` 並設定例外。元組值被初" +"始化為指向 Python 物件的接續 *n* 個 C 引數。``PyTuple_Pack(2, a, b)`` 等價於 " +"``Py_BuildValue(\"(OO)\", a, b)``。" #: ../../c-api/tuple.rst:50 msgid "" "Take a pointer to a tuple object, and return the size of that tuple. On " -"error, return ``-1`` and with an exception set." +"error, return ``-1`` with an exception set." msgstr "" +"拿取一個元組物件的指標,然後回傳此元組的大小。錯誤發生時,回傳 ``-1`` 並設定" +"例外。" #: ../../c-api/tuple.rst:56 msgid "Like :c:func:`PyTuple_Size`, but without error checking." -msgstr "" +msgstr "就像 :c:func:`PyTuple_Size` 但沒有錯誤檢查。" #: ../../c-api/tuple.rst:61 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:`IndexError` exception." +"*pos* is negative or out of bounds, return ``NULL`` and set an :exc:" +"`IndexError` exception." msgstr "" +"回傳 *p* 指向的元組中位置 *pos* 處的物件。如果 *pos* 為負數或超出範圍,回傳 " +"``NULL`` 並設定 :exc:`IndexError` 例外。" #: ../../c-api/tuple.rst:64 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 " -"reference`, use :c:func:`Py_NewRef(PyTuple_GetItem(...)) ` " -"or :c:func:`PySequence_GetItem`." +"reference`, use :c:func:`Py_NewRef(PyTuple_GetItem(...)) ` or :c:" +"func:`PySequence_GetItem`." msgstr "" +"回傳的參照借自元組 *p*\\ (也就是說:它僅在你持有 *p* 的參照時有效)。若要取" +"得一個 :term:`strong reference`,請使用 :c:func:" +"`Py_NewRef(PyTuple_GetItem(...)) ` 或 :c:func:" +"`PySequence_GetItem`。" #: ../../c-api/tuple.rst:73 msgid "Like :c:func:`PyTuple_GetItem`, but does no checking of its arguments." -msgstr "" +msgstr "與 :c:func:`PyTuple_GetItem` 相似,但不檢查其引數。" #: ../../c-api/tuple.rst:78 msgid "" "Return the slice of the tuple pointed to by *p* between *low* and *high*, or " "``NULL`` with an exception set on failure." msgstr "" +"回傳由 *p* 指向的元組中介於 *low* 和 *high* 之間的切片或在錯誤時回傳 " +"``NULL`` 並設定例外。" #: ../../c-api/tuple.rst:81 msgid "" "This is the equivalent of the Python expression ``p[low:high]``. Indexing " "from the end of the tuple is not supported." -msgstr "" +msgstr "這與 Python ``p[low:high]`` 運算式等價。但不支援從元組末端開始索引。" #: ../../c-api/tuple.rst:87 msgid "" @@ -106,36 +124,51 @@ msgid "" "by *p*. Return ``0`` on success. If *pos* is out of bounds, return ``-1`` " "and set an :exc:`IndexError` exception." msgstr "" +"於 *p* 指向的元組 *pos* 位置處插入對物件 *o* 的參照。成功時回傳 ``0``,如果 " +"*pos* 超出邊界則回傳 ``-1``,並設定 :exc:`IndexError` 例外。" #: ../../c-api/tuple.rst:93 msgid "" "This function \"steals\" a reference to *o* and discards a reference to an " "item already in the tuple at the affected position." -msgstr "" +msgstr "此函式 \"竊取\" 對 *o* 的參照,並丟棄對元組中受影響位置的項目的參照。" #: ../../c-api/tuple.rst:99 msgid "" "Like :c:func:`PyTuple_SetItem`, but does no error checking, and should " "*only* be used to fill in brand new tuples." msgstr "" +"與 :c:func:`PyTuple_SetItem` 相似,但不進行錯誤檢查,且應 *只* 用於填充全新的" +"元組。" -#: ../../c-api/tuple.rst:102 ../../c-api/tuple.rst:218 -#: ../../c-api/tuple.rst:236 +#: ../../c-api/tuple.rst:102 ../../c-api/tuple.rst:224 +#: ../../c-api/tuple.rst:242 msgid "" -"Bounds checking is performed as an assertion if Python is built " -"in :ref:`debug mode ` or :option:`with assertions <--with-" -"assertions>`." +"Bounds checking is performed as an assertion if Python is built in :ref:" +"`debug mode ` or :option:`with assertions <--with-assertions>`." msgstr "" +"若 Python 以 :ref:`debug mode ` 或 :option:`with assertions <--" +"with-assertions>` 建置,則會進行作為斷言(asserting)的邊界檢查。" #: ../../c-api/tuple.rst:107 msgid "" -"This function \"steals\" a reference to *o*, and, " -"unlike :c:func:`PyTuple_SetItem`, does *not* discard a reference to any item " -"that is being replaced; any reference in the tuple at position *pos* will be " -"leaked." +"This function \"steals\" a reference to *o*, and, unlike :c:func:" +"`PyTuple_SetItem`, does *not* discard a reference to any item that is being " +"replaced; any reference in the tuple at position *pos* will be leaked." +msgstr "" +"此函式 \"竊取\" 對 *o* 的參照,且與 :c:func:`PyTuple_SetItem` 不同的是,此函" +"式並 *不* 丟棄任何被替代項目的參照;元組中 *pos* 位置的所有參照皆會被洩漏。" + +#: ../../c-api/tuple.rst:114 +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 " +"refcount > 1) could lead to undefined behavior." msgstr "" +"此巨集應 *僅* 用於新建立的元組。在正被使用中的元組(或換句話說,參照計數大於 " +"1 的元組)上使用此巨集可能會導致未定義行為。" -#: ../../c-api/tuple.rst:115 +#: ../../c-api/tuple.rst:121 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 " @@ -146,129 +179,153 @@ msgid "" "Client code should never assume that the resulting value of ``*p`` will be " "the same as before calling this function. If the object referenced by ``*p`` " "is replaced, the original ``*p`` is destroyed. On failure, returns ``-1`` " -"and sets ``*p`` to ``NULL``, and raises :exc:`MemoryError` " -"or :exc:`SystemError`." -msgstr "" - -#: ../../c-api/tuple.rst:130 +"and sets ``*p`` to ``NULL``, and raises :exc:`MemoryError` or :exc:" +"`SystemError`." +msgstr "" +"可用於調整元組的大小。*newsize* 將是元組的新長度。由於元組 *應該* 是不可變" +"的,因此僅當物件只有一個參照時才應使用此方法。如果程式碼的其他部分已經知道該" +"元組,則 *不要* 使用此方法。最終元組總會變大或縮小。可以將其理解為銷毀舊元組" +"並建立一個新元組,只是有著更高的效率。成功時回傳 ``0``。用戶端程式碼絕不應假" +"設 ``*p`` 的結果值與呼叫此函式之前的值相同。如果 ``*p`` 參照的物件被替換,則" +"原始的 ``*p`` 將被銷毀。失敗時,回傳 ``-1``,並將 ``*p`` 設定為 ``NULL``,並" +"引發 :exc:`MemoryError` 或 :exc:`SystemError` 例外。" + +#: ../../c-api/tuple.rst:136 msgid "Struct Sequence Objects" -msgstr "" +msgstr "結構序列物件" -#: ../../c-api/tuple.rst:132 +#: ../../c-api/tuple.rst:138 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." +"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." msgstr "" +"結構序列物件是 :func:`~collections.namedtuple` 物件在 C 語言中的等價,換言" +"之,一個序列的元素也可以透過屬性存取。要建立結構序列,首先需要建立特定的結構" +"序列型別。" -#: ../../c-api/tuple.rst:139 +#: ../../c-api/tuple.rst:145 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:`PyStructSequence_New`." +"Instances of the resulting type can be created with :c:func:" +"`PyStructSequence_New`." msgstr "" +"從 *desc* 中的資料建立一個新的結構序列型別,如下所述。可以使用 :c:func:" +"`PyStructSequence_New` 以建立產生結構序列型別的實例。" -#: ../../c-api/tuple.rst:142 ../../c-api/tuple.rst:211 +#: ../../c-api/tuple.rst:148 ../../c-api/tuple.rst:217 msgid "Return ``NULL`` with an exception set on failure." msgstr "失敗時回傳 ``NULL`` 並設定例外。" -#: ../../c-api/tuple.rst:147 +#: ../../c-api/tuple.rst:153 msgid "Initializes a struct sequence type *type* from *desc* in place." -msgstr "" +msgstr "從 *desc* 原地(in place)初始化結構序列型別 *type*。" -#: ../../c-api/tuple.rst:152 +#: ../../c-api/tuple.rst:158 msgid "" "Like :c:func:`PyStructSequence_InitType`, but returns ``0`` on success and " "``-1`` with an exception set on failure." msgstr "" +"與 :c:func:`PyStructSequence_InitType` 相似,但運行成功時回傳 ``0``,運行失敗" +"時回傳 ``-1`` 並設定例外。" -#: ../../c-api/tuple.rst:160 +#: ../../c-api/tuple.rst:166 msgid "Contains the meta information of a struct sequence type to create." -msgstr "" +msgstr "包含要建立的結構序列化型別的中介資訊(meta information)。" -#: ../../c-api/tuple.rst:164 +#: ../../c-api/tuple.rst:170 msgid "" "Fully qualified name of the type; null-terminated UTF-8 encoded. The name " "must contain the module name." msgstr "" +"型別的完整限定名稱(Fully qualified name);以 UTF-8 編碼並以空字元結尾。名稱" +"必須包含完整的模組名稱。" -#: ../../c-api/tuple.rst:169 +#: ../../c-api/tuple.rst:175 msgid "Pointer to docstring for the type or ``NULL`` to omit." -msgstr "" +msgstr "指向型別說明文件(docstring)的指標或使用 ``NULL`` 表示忽略。" -#: ../../c-api/tuple.rst:173 +#: ../../c-api/tuple.rst:179 msgid "Pointer to ``NULL``-terminated array with field names of the new type." -msgstr "" +msgstr "指向一個以 ``NULL`` 結尾的陣列指標,其包含新型別的欄位名稱。" -#: ../../c-api/tuple.rst:177 +#: ../../c-api/tuple.rst:183 msgid "Number of fields visible to the Python side (if used as tuple)." -msgstr "" +msgstr "Python 端可以看到欄位的數目(如果作為元組使用)。" -#: ../../c-api/tuple.rst:182 +#: ../../c-api/tuple.rst:188 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:member:`~PyStructSequence_Desc.fields` array of " -"the :c:type:`PyStructSequence_Desc` determines which field of the struct " -"sequence is described." +"tuple, all fields are typed as :c:expr:`PyObject*`. The index in the :c:" +"member:`~PyStructSequence_Desc.fields` array of the :c:type:" +"`PyStructSequence_Desc` determines which field of the struct sequence is " +"described." msgstr "" +"描述結構序列的一個欄位。由於結構序列以元組作為原型,所有欄位的型別均為 :c:" +"expr:`PyObject*`。:c:type:`PyStructSequence_Desc` 在 :c:member:" +"`~PyStructSequence_Desc.fields` 陣列中的索引決定了描述的是結構序列的哪個欄" +"位。" -#: ../../c-api/tuple.rst:190 +#: ../../c-api/tuple.rst:196 msgid "" -"Name for the field or ``NULL`` to end the list of named fields, set " -"to :c:data:`PyStructSequence_UnnamedField` to leave unnamed." +"Name for the field or ``NULL`` to end the list of named fields, set to :c:" +"data:`PyStructSequence_UnnamedField` to leave unnamed." msgstr "" +"欄位名稱,或 ``NULL`` 表示命名欄位串列結束,設定為 :c:data:" +"`PyStructSequence_UnnamedField` 表示該欄位不命名。" -#: ../../c-api/tuple.rst:195 +#: ../../c-api/tuple.rst:201 msgid "Field docstring or ``NULL`` to omit." -msgstr "" +msgstr "欄位說明字串或為 ``NULL`` 表示忽略。" -#: ../../c-api/tuple.rst:200 +#: ../../c-api/tuple.rst:206 msgid "Special value for a field name to leave it unnamed." -msgstr "" +msgstr "給定欄位名稱一個特別值,表示該欄位不命名。" -#: ../../c-api/tuple.rst:202 +#: ../../c-api/tuple.rst:208 msgid "The type was changed from ``char *``." -msgstr "" +msgstr "型別原本是 ``char *``,現已被修改。" -#: ../../c-api/tuple.rst:208 +#: ../../c-api/tuple.rst:214 msgid "" -"Creates an instance of *type*, which must have been created " -"with :c:func:`PyStructSequence_NewType`." -msgstr "" +"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:216 +#: ../../c-api/tuple.rst:222 msgid "" "Return the object at position *pos* in the struct sequence pointed to by *p*." -msgstr "" +msgstr "回傳結構序列中由 *p* 指向 *pos* 處的物件。" -#: ../../c-api/tuple.rst:224 +#: ../../c-api/tuple.rst:230 msgid "Alias to :c:func:`PyStructSequence_GetItem`." -msgstr "" +msgstr ":c:func:`PyStructSequence_GetItem` 的別名。" -#: ../../c-api/tuple.rst:226 +#: ../../c-api/tuple.rst:232 msgid "Now implemented as an alias to :c:func:`PyStructSequence_GetItem`." -msgstr "" +msgstr "現在是被實作為 :c:func:`PyStructSequence_GetItem` 的一個別名。" -#: ../../c-api/tuple.rst:232 +#: ../../c-api/tuple.rst:238 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 " "new instances." msgstr "" +"將結構序列 *p* 中索引 *pos* 處的欄位值設為 *o*。與 :c:func:" +"`PyTuple_SET_ITEM` 類似,此函式僅套用於填充全新實例。" -#: ../../c-api/tuple.rst:241 +#: ../../c-api/tuple.rst:247 msgid "This function \"steals\" a reference to *o*." -msgstr "" +msgstr "此函式 \"竊取\" *o* 的參照。" -#: ../../c-api/tuple.rst:246 +#: ../../c-api/tuple.rst:252 msgid "Alias to :c:func:`PyStructSequence_SetItem`." -msgstr "" +msgstr ":c:func:`PyStructSequence_SetItem` 的別名。" -#: ../../c-api/tuple.rst:248 +#: ../../c-api/tuple.rst:254 msgid "Now implemented as an alias to :c:func:`PyStructSequence_SetItem`." -msgstr "" +msgstr "現在是被實作為 :c:func:`PyStructSequence_SetItem` 的一個別名。" #: ../../c-api/tuple.rst:8 msgid "object" diff --git a/c-api/type.po b/c-api/type.po index 3ddebe9e5cf..f5ecca59361 100644 --- a/c-api/type.po +++ b/c-api/type.po @@ -1,12 +1,12 @@ -# Copyright (C) 2001-2023, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"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: 2025-11-22 00:14+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-" @@ -135,54 +135,105 @@ msgid "" msgstr "" #: ../../c-api/type.rst:121 +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 +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 +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 msgid "Type of a type-watcher callback function." msgstr "" -#: ../../c-api/type.rst:123 +#: ../../c-api/type.rst:137 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 " "infinite recursion." msgstr "" -#: ../../c-api/type.rst:132 +#: ../../c-api/type.rst:146 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:138 +#: ../../c-api/type.rst:152 +msgid "" +"Return non-zero if the type object *type* sets the subclass flag *flag*. " +"Subclass flags are denoted by :c:macro:`Py_TPFLAGS_*_SUBCLASS " +"`. This function is used by many ``_Check`` " +"functions for common types." +msgstr "" + +#: ../../c-api/type.rst:158 +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 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:144 +#: ../../c-api/type.rst:170 msgid "Return true if *a* is a subtype of *b*." -msgstr "" +msgstr "如果 *a* 是 *b* 的子類別則回傳 true。" -#: ../../c-api/type.rst:146 +#: ../../c-api/type.rst:172 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:154 +#: ../../c-api/type.rst:180 msgid "" "Generic handler for the :c:member:`~PyTypeObject.tp_alloc` slot of a type " -"object. Use Python's default memory allocation mechanism to allocate a new " -"instance and initialize all its contents to ``NULL``." +"object. Uses Python's default memory allocation mechanism to allocate " +"memory for a new instance, zeros the memory, then initializes the memory as " +"if by calling :c:func:`PyObject_Init` or :c:func:`PyObject_InitVar`." +msgstr "" + +#: ../../c-api/type.rst:185 +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 +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:" +"`PyObject_GC_New` or :c:macro:`PyObject_GC_NewVar` (except the memory is " +"guaranteed to be zeroed before initialization), and should be paired with :c:" +"func:`PyObject_GC_Del` in :c:member:`~PyTypeObject.tp_free`. Otherwise, it " +"behaves like :c:macro:`PyObject_New` or :c:macro:`PyObject_NewVar` (except " +"the memory is guaranteed to be zeroed before initialization) and should be " +"paired with :c:func:`PyObject_Free` in :c:member:`~PyTypeObject.tp_free`." msgstr "" -#: ../../c-api/type.rst:160 +#: ../../c-api/type.rst:201 msgid "" "Generic handler for the :c:member:`~PyTypeObject.tp_new` slot of a type " -"object. Create a new instance using the type's :c:member:`~PyTypeObject." -"tp_alloc` slot." +"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:165 +#: ../../c-api/type.rst:208 msgid "" "Finalize a type object. This should be called on all type objects to finish " "their initialization. This function is responsible for adding inherited " @@ -190,7 +241,7 @@ msgid "" "and sets an exception on error." msgstr "" -#: ../../c-api/type.rst:171 +#: ../../c-api/type.rst:214 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 " @@ -201,32 +252,32 @@ msgid "" "handle." msgstr "" -#: ../../c-api/type.rst:181 +#: ../../c-api/type.rst:225 msgid "" "Return the type's name. Equivalent to getting the type's :attr:`~type." "__name__` attribute." msgstr "" -#: ../../c-api/type.rst:188 +#: ../../c-api/type.rst:233 msgid "" "Return the type's qualified name. Equivalent to getting the type's :attr:" "`~type.__qualname__` attribute." msgstr "" -#: ../../c-api/type.rst:195 +#: ../../c-api/type.rst:240 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:203 +#: ../../c-api/type.rst:249 msgid "" "Return the type's module name. Equivalent to getting the :attr:`type." "__module__` attribute." msgstr "" -#: ../../c-api/type.rst:210 +#: ../../c-api/type.rst:257 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 " @@ -234,30 +285,30 @@ msgid "" "result pointer into the appropriate function type." msgstr "" -#: ../../c-api/type.rst:216 +#: ../../c-api/type.rst:263 msgid "" "See :c:member:`PyType_Slot.slot` for possible values of the *slot* argument." msgstr "" -#: ../../c-api/type.rst:220 +#: ../../c-api/type.rst:267 msgid "" ":c:func:`PyType_GetSlot` can now accept all types. Previously, it was " "limited to :ref:`heap types `." msgstr "" -#: ../../c-api/type.rst:226 +#: ../../c-api/type.rst:274 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:229 ../../c-api/type.rst:249 +#: ../../c-api/type.rst:277 ../../c-api/type.rst:298 msgid "" "If no module is associated with the given type, sets :py:class:`TypeError` " "and returns ``NULL``." msgstr "" -#: ../../c-api/type.rst:232 +#: ../../c-api/type.rst:280 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 " @@ -268,31 +319,31 @@ msgid "" "type:`!PyCMethod` cannot be used." msgstr "" -#: ../../c-api/type.rst:245 +#: ../../c-api/type.rst:294 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:252 +#: ../../c-api/type.rst:301 msgid "" "If the *type* has an associated module but its state is ``NULL``, returns " "``NULL`` without setting an exception." msgstr "" -#: ../../c-api/type.rst:259 +#: ../../c-api/type.rst:309 msgid "" "Find the first superclass whose module was created from the given :c:type:" "`PyModuleDef` *def*, and return that module." msgstr "" -#: ../../c-api/type.rst:262 +#: ../../c-api/type.rst:312 msgid "" "If no module is found, raises a :py:class:`TypeError` and returns ``NULL``." msgstr "" -#: ../../c-api/type.rst:264 +#: ../../c-api/type.rst:314 msgid "" "This function is intended to be used together with :c:func:" "`PyModule_GetState()` to get module state from slot methods (such as :c:" @@ -301,65 +352,111 @@ msgid "" "type:`PyCMethod` calling convention." msgstr "" -#: ../../c-api/type.rst:270 +#: ../../c-api/type.rst:320 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:278 +#: ../../c-api/type.rst:329 +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." +msgstr "" + +#: ../../c-api/type.rst:332 +msgid "" +"If found, set *\\*result* to a new :term:`strong reference` to it and return " +"``1``." +msgstr "" + +#: ../../c-api/type.rst:334 +msgid "If not found, set *\\*result* to ``NULL`` and return ``0``." +msgstr "如果沒找到,則將 *\\*result* 設為 ``NULL`` 並回傳 ``0``。" + +#: ../../c-api/type.rst:335 +msgid "" +"On error, set *\\*result* to ``NULL`` and return ``-1`` with an exception " +"set." +msgstr "" +"在發生錯誤時,將 *\\*result* 設為 ``NULL`` 並回傳 ``-1``,同時設定例外。" + +#: ../../c-api/type.rst:338 +msgid "" +"The *result* argument may be ``NULL``, in which case *\\*result* is not set. " +"Use this if you need only the return value." +msgstr "" +"如果 *result* 引數為 ``NULL``,則不會設定 *\\*result*。如果你只需要回傳值,請" +"使用此選項。" + +#: ../../c-api/type.rst:341 +msgid "The *token* argument may not be ``NULL``." +msgstr "*token* 引數不可為 ``NULL``。" + +#: ../../c-api/type.rst:348 msgid "Attempt to assign a version tag to the given type." msgstr "" -#: ../../c-api/type.rst:280 +#: ../../c-api/type.rst:350 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:287 +#: ../../c-api/type.rst:358 +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:362 +msgid ":ref:`weakrefobjects`" +msgstr ":ref:`weakrefobjects`" + +#: ../../c-api/type.rst:363 +msgid ":py:mod:`weakref`" +msgstr ":py:mod:`weakref`" + +#: ../../c-api/type.rst:367 msgid "Creating Heap-Allocated Types" msgstr "" -#: ../../c-api/type.rst:289 +#: ../../c-api/type.rst:369 msgid "" "The following functions and structs are used to create :ref:`heap types " "`." msgstr "" -#: ../../c-api/type.rst:294 +#: ../../c-api/type.rst:374 msgid "" "Create and return a :ref:`heap type ` from the *spec* (see :c:" "macro:`Py_TPFLAGS_HEAPTYPE`)." msgstr "" -#: ../../c-api/type.rst:297 +#: ../../c-api/type.rst:377 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:301 +#: ../../c-api/type.rst:381 msgid "" "Metaclasses that override :c:member:`~PyTypeObject.tp_new` are not " -"supported, except if ``tp_new`` is ``NULL``. (For backwards compatibility, " -"other ``PyType_From*`` functions allow such metaclasses. They ignore " -"``tp_new``, which may result in incomplete initialization. This is " -"deprecated and in Python 3.14+ such metaclasses will not be supported.)" +"supported, except if ``tp_new`` is ``NULL``." msgstr "" -#: ../../c-api/type.rst:308 +#: ../../c-api/type.rst:384 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 " -"*Py_tp_bases* slot is used instead. If that also is ``NULL``, the " -"*Py_tp_base* slot is used instead. If that also is ``NULL``, the new type " +"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`." msgstr "" -#: ../../c-api/type.rst:314 +#: ../../c-api/type.rst:390 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``, " @@ -368,11 +465,11 @@ msgid "" "subclasses; it must be specified for each class individually." msgstr "" -#: ../../c-api/type.rst:321 +#: ../../c-api/type.rst:397 msgid "This function calls :c:func:`PyType_Ready` on the new type." msgstr "" -#: ../../c-api/type.rst:323 +#: ../../c-api/type.rst:399 msgid "" "Note that this function does *not* fully match the behavior of calling :py:" "class:`type() ` or using the :keyword:`class` statement. With user-" @@ -381,84 +478,110 @@ msgid "" "Specifically:" msgstr "" -#: ../../c-api/type.rst:330 +#: ../../c-api/type.rst:406 msgid "" ":py:meth:`~object.__new__` is not called on the new class (and it must be " "set to ``type.__new__``)." msgstr "" +":py:meth:`~object.__new__` 不會在新類別上被呼叫(且它必須被設為 ``type." +"__new__``)。" -#: ../../c-api/type.rst:332 +#: ../../c-api/type.rst:408 msgid ":py:meth:`~object.__init__` is not called on the new class." -msgstr "" +msgstr ":py:meth:`~object.__init__` 不會在新類別上被呼叫。" -#: ../../c-api/type.rst:333 +#: ../../c-api/type.rst:409 msgid ":py:meth:`~object.__init_subclass__` is not called on any bases." -msgstr "" +msgstr ":py:meth:`~object.__init_subclass__` 不會在任何基底上被呼叫。" -#: ../../c-api/type.rst:334 +#: ../../c-api/type.rst:410 msgid ":py:meth:`~object.__set_name__` is not called on new descriptors." -msgstr "" +msgstr ":py:meth:`~object.__set_name__` 不會在新的描述器上被呼叫。" -#: ../../c-api/type.rst:340 +#: ../../c-api/type.rst:417 msgid "Equivalent to ``PyType_FromMetaclass(NULL, module, spec, bases)``." msgstr "等價於 ``PyType_FromMetaclass(NULL, module, spec, bases)``。" -#: ../../c-api/type.rst:346 +#: ../../c-api/type.rst:423 msgid "" "The function now accepts a single class as the *bases* argument and ``NULL`` " "as the ``tp_doc`` slot." msgstr "" -#: ../../c-api/type.rst:351 ../../c-api/type.rst:368 +#: ../../c-api/type.rst:428 ../../c-api/type.rst:450 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:354 ../../c-api/type.rst:371 ../../c-api/type.rst:387 +#: ../../c-api/type.rst:431 ../../c-api/type.rst:453 ../../c-api/type.rst:474 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 and in Python 3.14+ " -"it will be no longer allowed." +"overrides :c:member:`~PyTypeObject.tp_new` is deprecated." msgstr "" -#: ../../c-api/type.rst:362 +#: ../../c-api/type.rst:438 ../../c-api/type.rst:460 ../../c-api/type.rst:481 +msgid "" +"Creating classes whose metaclass overrides :c:member:`~PyTypeObject.tp_new` " +"is no longer allowed." +msgstr "" + +#: ../../c-api/type.rst:444 msgid "Equivalent to ``PyType_FromMetaclass(NULL, NULL, spec, bases)``." msgstr "等價於 ``PyType_FromMetaclass(NULL, NULL, spec, bases)``。" -#: ../../c-api/type.rst:379 +#: ../../c-api/type.rst:466 msgid "Equivalent to ``PyType_FromMetaclass(NULL, NULL, spec, NULL)``." msgstr "等價於 ``PyType_FromMetaclass(NULL, NULL, spec, NULL)``。" -#: ../../c-api/type.rst:383 +#: ../../c-api/type.rst:470 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:404 +#: ../../c-api/type.rst:487 +msgid "" +"Make a type immutable: set the :c:macro:`Py_TPFLAGS_IMMUTABLETYPE` flag." +msgstr "" + +#: ../../c-api/type.rst:489 +msgid "All base classes of *type* must be immutable." +msgstr "所有 *type* 的基底類別都必須是不可變的。" + +#: ../../c-api/type.rst:491 +msgid "On success, return ``0``. On error, set an exception and return ``-1``." +msgstr "" + +#: ../../c-api/type.rst:494 +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." +msgstr "" + +#: ../../c-api/type.rst:510 msgid "Structure defining a type's behavior." msgstr "" -#: ../../c-api/type.rst:408 +#: ../../c-api/type.rst:514 msgid "Name of the type, used to set :c:member:`PyTypeObject.tp_name`." msgstr "" -#: ../../c-api/type.rst:412 +#: ../../c-api/type.rst:518 msgid "" "If positive, specifies the size of the instance in bytes. It is used to set :" "c:member:`PyTypeObject.tp_basicsize`." msgstr "" -#: ../../c-api/type.rst:415 +#: ../../c-api/type.rst:521 msgid "" "If zero, specifies that :c:member:`~PyTypeObject.tp_basicsize` should be " "inherited." msgstr "" -#: ../../c-api/type.rst:418 +#: ../../c-api/type.rst:524 msgid "" "If negative, the absolute value specifies how much space instances of the " "class need *in addition* to the superclass. Use :c:func:" @@ -468,17 +591,17 @@ msgid "" "requirements." msgstr "" -#: ../../c-api/type.rst:428 +#: ../../c-api/type.rst:534 msgid "Previously, this field could not be negative." -msgstr "" +msgstr "在過去此欄位不可為負值。" -#: ../../c-api/type.rst:432 +#: ../../c-api/type.rst:538 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." msgstr "" -#: ../../c-api/type.rst:436 +#: ../../c-api/type.rst:542 msgid "" "If zero, :c:member:`~PyTypeObject.tp_itemsize` is inherited. Extending " "arbitrary variable-sized classes is dangerous, since some types use a fixed " @@ -487,58 +610,60 @@ msgid "" "only possible in the following situations:" msgstr "" -#: ../../c-api/type.rst:443 +#: ../../c-api/type.rst:549 msgid "" "The base is not variable-sized (its :c:member:`~PyTypeObject.tp_itemsize`)." msgstr "" -#: ../../c-api/type.rst:445 +#: ../../c-api/type.rst:551 msgid "" "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:447 +#: ../../c-api/type.rst:553 msgid "" "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:450 +#: ../../c-api/type.rst:556 msgid "With the :c:macro:`Py_TPFLAGS_ITEMS_AT_END` flag." msgstr "" -#: ../../c-api/type.rst:454 +#: ../../c-api/type.rst:560 msgid "Type flags, used to set :c:member:`PyTypeObject.tp_flags`." msgstr "" -#: ../../c-api/type.rst:456 +#: ../../c-api/type.rst:562 msgid "" "If 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:461 +#: ../../c-api/type.rst:567 msgid "" "Array of :c:type:`PyType_Slot` structures. Terminated by the special slot " "value ``{0, NULL}``." msgstr "" -#: ../../c-api/type.rst:464 +#: ../../c-api/type.rst:570 msgid "Each slot ID should be specified at most once." msgstr "" -#: ../../c-api/type.rst:474 +#: ../../c-api/type.rst:580 msgid "" "Structure defining optional functionality of a type, containing a slot ID " "and a value pointer." msgstr "" -#: ../../c-api/type.rst:479 +#: ../../c-api/type.rst:585 msgid "A slot ID." msgstr "" -#: ../../c-api/type.rst:481 +#: ../../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:" @@ -546,30 +671,42 @@ msgid "" "prefix. For example, use:" msgstr "" -#: ../../c-api/type.rst:487 -msgid "``Py_tp_dealloc`` to set :c:member:`PyTypeObject.tp_dealloc`" -msgstr "" +#: ../../c-api/type.rst:593 +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:488 -msgid "``Py_nb_add`` to set :c:member:`PyNumberMethods.nb_add`" -msgstr "" +#: ../../c-api/type.rst:594 +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:489 -msgid "``Py_sq_length`` to set :c:member:`PySequenceMethods.sq_length`" +#: ../../c-api/type.rst:595 +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:597 +msgid "" +"An additional slot is supported that does not correspond to a :c:type:`!" +"PyTypeObject` struct field:" msgstr "" -#: ../../c-api/type.rst:491 +#: ../../c-api/type.rst:600 +msgid ":c:data:`Py_tp_token`" +msgstr ":c:data:`Py_tp_token`" + +#: ../../c-api/type.rst:602 msgid "" "The following “offset” fields cannot be set using :c:type:`PyType_Slot`:" msgstr "" -#: ../../c-api/type.rst:493 +#: ../../c-api/type.rst:604 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:495 +#: ../../c-api/type.rst:606 msgid "" ":c:member:`~PyTypeObject.tp_dictoffset` (use :c:macro:" "`Py_TPFLAGS_MANAGED_DICT` instead if possible)" @@ -577,7 +714,7 @@ msgstr "" ":c:member:`~PyTypeObject.tp_dictoffset`\\ (如果可能,請改用 :c:macro:" "`Py_TPFLAGS_MANAGED_DICT`)" -#: ../../c-api/type.rst:497 +#: ../../c-api/type.rst:608 msgid "" ":c:member:`~PyTypeObject.tp_vectorcall_offset` (use " "``\"__vectorcalloffset__\"`` in :ref:`PyMemberDef `)" @@ -585,57 +722,122 @@ msgstr "" ":c:member:`~PyTypeObject.tp_vectorcall_offset`\\ (請用 :ref:`PyMemberDef " "` 中的 ``\"__vectorcalloffset__\"``)" -#: ../../c-api/type.rst:501 +#: ../../c-api/type.rst:612 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:" -"member:`Py_tp_members `. See :ref:`PyMemberDef " -"documentation ` for details." -msgstr "" - -#: ../../c-api/type.rst:507 -msgid "The following fields cannot be set at all when creating a heap type:" +"data:`Py_tp_members`. See :ref:`PyMemberDef documentation ` for details." msgstr "" -#: ../../c-api/type.rst:509 +#: ../../c-api/type.rst:618 msgid "" -":c:member:`~PyTypeObject.tp_vectorcall` (use :c:member:`~PyTypeObject." -"tp_new` and/or :c:member:`~PyTypeObject.tp_init`)" +"The following internal fields cannot be set at all when creating a heap type:" msgstr "" -#: ../../c-api/type.rst:513 +#: ../../c-api/type.rst:621 msgid "" -"Internal fields: :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`." +":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:520 +#: ../../c-api/type.rst:627 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." msgstr "" -#: ../../c-api/type.rst:525 +#: ../../c-api/type.rst:632 msgid "Slots in :c:type:`PyBufferProcs` may be set in the unlimited API." msgstr "" -#: ../../c-api/type.rst:528 +#: ../../c-api/type.rst:635 msgid "" ":c:member:`~PyBufferProcs.bf_getbuffer` and :c:member:`~PyBufferProcs." "bf_releasebuffer` are now available under the :ref:`limited API `." msgstr "" -#: ../../c-api/type.rst:535 +#: ../../c-api/type.rst:640 +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." +msgstr "" + +#: ../../c-api/type.rst:647 msgid "" "The desired value of the slot. In most cases, this is a pointer to a " "function." msgstr "" -#: ../../c-api/type.rst:538 -msgid "Slots other than ``Py_tp_doc`` may not be ``NULL``." +#: ../../c-api/type.rst:650 +msgid "*pfunc* values may not be ``NULL``, except for the following slots:" +msgstr "" + +#: ../../c-api/type.rst:652 +msgid ":c:data:`Py_tp_doc`" +msgstr ":c:data:`Py_tp_doc`" + +#: ../../c-api/type.rst:653 +msgid "" +":c:data:`Py_tp_token` (for clarity, prefer :c:data:`Py_TP_USE_SPEC` rather " +"than ``NULL``)" +msgstr "" + +#: ../../c-api/type.rst:659 +msgid "" +"A :c:member:`~PyType_Slot.slot` that records a static memory layout ID for a " +"class." +msgstr "" + +#: ../../c-api/type.rst:662 +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`:" +msgstr "" + +#: ../../c-api/type.rst:666 +msgid "" +"static PyType_Slot foo_slots[] = {\n" +" {Py_tp_token, Py_TP_USE_SPEC}," +msgstr "" +"static PyType_Slot foo_slots[] = {\n" +" {Py_tp_token, Py_TP_USE_SPEC}," + +#: ../../c-api/type.rst:671 +msgid "It can also be set to an arbitrary pointer, but you must ensure that:" +msgstr "" + +#: ../../c-api/type.rst:673 +msgid "" +"The pointer outlives the class, so it's not reused for something else while " +"the class exists." +msgstr "" + +#: ../../c-api/type.rst:675 +msgid "" +"It \"belongs\" to the extension module where the class lives, so it will not " +"clash with other extensions." +msgstr "" + +#: ../../c-api/type.rst:678 +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:681 +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:690 +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``." msgstr "" #: ../../c-api/type.rst:8 diff --git a/c-api/typehints.po b/c-api/typehints.po index 3e3361c14e5..113e15ecbc4 100644 --- a/c-api/typehints.po +++ b/c-api/typehints.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -6,7 +6,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-01 22:24+0800\n" "PO-Revision-Date: 2022-10-16 16:16+0800\n" diff --git a/c-api/typeobj.po b/c-api/typeobj.po index 7751ec68cef..285808351ba 100644 --- a/c-api/typeobj.po +++ b/c-api/typeobj.po @@ -1,12 +1,12 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"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: 2025-12-01 00:17+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-" @@ -63,7 +63,7 @@ msgstr "" #: ../../c-api/typeobj.rst:40 ../../c-api/typeobj.rst:201 msgid ":ref:`Type `" -msgstr "" +msgstr ":ref:`Type `" #: ../../c-api/typeobj.rst:40 msgid "special methods/attrs" @@ -93,8 +93,8 @@ msgstr "I" msgid " :c:member:`~PyTypeObject.tp_name`" msgstr " :c:member:`~PyTypeObject.tp_name`" -#: ../../c-api/typeobj.rst:0 ../../c-api/typeobj.rst:44 -#: ../../c-api/typeobj.rst:86 +#: ../../c-api/typeobj.rst:44 ../../c-api/typeobj.rst:86 +#: ../../c-api/typeobj.rst:372 ../../c-api/typeobj.rst:377 msgid "const char *" msgstr "const char *" @@ -125,10 +125,11 @@ msgstr "X" msgid ":c:member:`~PyTypeObject.tp_basicsize`" msgstr ":c:member:`~PyTypeObject.tp_basicsize`" -#: ../../c-api/typeobj.rst:0 ../../c-api/typeobj.rst:46 -#: ../../c-api/typeobj.rst:48 ../../c-api/typeobj.rst:52 -#: ../../c-api/typeobj.rst:99 ../../c-api/typeobj.rst:120 -#: ../../c-api/typeobj.rst:417 +#: ../../c-api/typeobj.rst:46 ../../c-api/typeobj.rst:48 +#: ../../c-api/typeobj.rst:52 ../../c-api/typeobj.rst:99 +#: ../../c-api/typeobj.rst:120 ../../c-api/typeobj.rst:343 +#: ../../c-api/typeobj.rst:417 ../../c-api/typeobj.rst:448 +#: ../../c-api/typeobj.rst:453 msgid ":c:type:`Py_ssize_t`" msgstr ":c:type:`Py_ssize_t`" @@ -402,7 +403,8 @@ msgstr ":c:type:`PyGetSetDef` []" msgid ":c:member:`~PyTypeObject.tp_base`" msgstr ":c:member:`~PyTypeObject.tp_base`" -#: ../../c-api/typeobj.rst:0 ../../c-api/typeobj.rst:111 +#: ../../c-api/typeobj.rst:111 ../../c-api/typeobj.rst:342 +#: ../../c-api/typeobj.rst:357 msgid ":c:type:`PyTypeObject` *" msgstr ":c:type:`PyTypeObject` *" @@ -414,18 +416,32 @@ msgstr "__base__" msgid ":c:member:`~PyTypeObject.tp_dict`" msgstr ":c:member:`~PyTypeObject.tp_dict`" -#: ../../c-api/typeobj.rst:0 ../../c-api/typeobj.rst:113 -#: ../../c-api/typeobj.rst:132 ../../c-api/typeobj.rst:134 -#: ../../c-api/typeobj.rst:136 ../../c-api/typeobj.rst:140 -#: ../../c-api/typeobj.rst:342 ../../c-api/typeobj.rst:347 -#: ../../c-api/typeobj.rst:357 ../../c-api/typeobj.rst:369 -#: ../../c-api/typeobj.rst:371 ../../c-api/typeobj.rst:382 -#: ../../c-api/typeobj.rst:393 ../../c-api/typeobj.rst:405 -#: ../../c-api/typeobj.rst:407 ../../c-api/typeobj.rst:413 -#: ../../c-api/typeobj.rst:415 ../../c-api/typeobj.rst:417 -#: ../../c-api/typeobj.rst:430 ../../c-api/typeobj.rst:432 -#: ../../c-api/typeobj.rst:436 ../../c-api/typeobj.rst:441 -#: ../../c-api/typeobj.rst:447 +#: ../../c-api/typeobj.rst:113 ../../c-api/typeobj.rst:132 +#: ../../c-api/typeobj.rst:134 ../../c-api/typeobj.rst:136 +#: ../../c-api/typeobj.rst:140 ../../c-api/typeobj.rst:342 +#: ../../c-api/typeobj.rst:347 ../../c-api/typeobj.rst:351 +#: ../../c-api/typeobj.rst:357 ../../c-api/typeobj.rst:358 +#: ../../c-api/typeobj.rst:359 ../../c-api/typeobj.rst:363 +#: ../../c-api/typeobj.rst:364 ../../c-api/typeobj.rst:365 +#: ../../c-api/typeobj.rst:369 ../../c-api/typeobj.rst:371 +#: ../../c-api/typeobj.rst:376 ../../c-api/typeobj.rst:378 +#: ../../c-api/typeobj.rst:382 ../../c-api/typeobj.rst:383 +#: ../../c-api/typeobj.rst:387 ../../c-api/typeobj.rst:388 +#: ../../c-api/typeobj.rst:389 ../../c-api/typeobj.rst:393 +#: ../../c-api/typeobj.rst:394 ../../c-api/typeobj.rst:395 +#: ../../c-api/typeobj.rst:399 ../../c-api/typeobj.rst:400 +#: ../../c-api/typeobj.rst:401 ../../c-api/typeobj.rst:405 +#: ../../c-api/typeobj.rst:407 ../../c-api/typeobj.rst:408 +#: ../../c-api/typeobj.rst:413 ../../c-api/typeobj.rst:415 +#: ../../c-api/typeobj.rst:417 ../../c-api/typeobj.rst:419 +#: ../../c-api/typeobj.rst:425 ../../c-api/typeobj.rst:430 +#: ../../c-api/typeobj.rst:432 ../../c-api/typeobj.rst:436 +#: ../../c-api/typeobj.rst:437 ../../c-api/typeobj.rst:441 +#: ../../c-api/typeobj.rst:442 ../../c-api/typeobj.rst:443 +#: ../../c-api/typeobj.rst:447 ../../c-api/typeobj.rst:452 +#: ../../c-api/typeobj.rst:454 ../../c-api/typeobj.rst:458 +#: ../../c-api/typeobj.rst:459 ../../c-api/typeobj.rst:463 +#: ../../c-api/typeobj.rst:464 ../../c-api/typeobj.rst:465 msgid ":c:type:`PyObject` *" msgstr ":c:type:`PyObject` *" @@ -533,8 +549,8 @@ msgstr "[:c:member:`~PyTypeObject.tp_cache`]" msgid "[:c:member:`~PyTypeObject.tp_subclasses`]" msgstr "[:c:member:`~PyTypeObject.tp_subclasses`]" -#: ../../c-api/typeobj.rst:0 ../../c-api/typeobj.rst:138 -#: ../../c-api/typeobj.rst:279 ../../c-api/typeobj.rst:349 +#: ../../c-api/typeobj.rst:138 ../../c-api/typeobj.rst:279 +#: ../../c-api/typeobj.rst:349 ../../c-api/typeobj.rst:353 msgid "void *" msgstr "void *" @@ -1105,7 +1121,6 @@ msgid ":c:func:`getbufferproc`" msgstr ":c:func:`getbufferproc`" #: ../../c-api/typeobj.rst:328 -#, fuzzy msgid "__buffer__" msgstr "__buffer__" @@ -1118,8 +1133,9 @@ msgid ":c:func:`releasebufferproc`" msgstr ":c:func:`releasebufferproc`" #: ../../c-api/typeobj.rst:330 -msgid "__release_\\ buffer\\__" -msgstr "" +#, fuzzy +msgid "__release_ buffer\\__" +msgstr "__buffer__" #: ../../c-api/typeobj.rst:337 msgid "slot typedefs" @@ -1142,16 +1158,16 @@ msgstr "" msgid "void" msgstr "void" -#: ../../c-api/typeobj.rst:0 +#: ../../c-api/typeobj.rst:352 msgid ":c:type:`visitproc`" msgstr ":c:type:`visitproc`" -#: ../../c-api/typeobj.rst:0 ../../c-api/typeobj.rst:351 -#: ../../c-api/typeobj.rst:363 ../../c-api/typeobj.rst:376 -#: ../../c-api/typeobj.rst:387 ../../c-api/typeobj.rst:399 -#: ../../c-api/typeobj.rst:419 ../../c-api/typeobj.rst:430 -#: ../../c-api/typeobj.rst:452 ../../c-api/typeobj.rst:458 -#: ../../c-api/typeobj.rst:463 +#: ../../c-api/typeobj.rst:351 ../../c-api/typeobj.rst:363 +#: ../../c-api/typeobj.rst:376 ../../c-api/typeobj.rst:387 +#: ../../c-api/typeobj.rst:399 ../../c-api/typeobj.rst:409 +#: ../../c-api/typeobj.rst:419 ../../c-api/typeobj.rst:421 +#: ../../c-api/typeobj.rst:430 ../../c-api/typeobj.rst:452 +#: ../../c-api/typeobj.rst:458 ../../c-api/typeobj.rst:463 msgid "int" msgstr "int" @@ -1163,7 +1179,7 @@ msgstr "Py_hash_t" msgid ":c:type:`getbufferproc`" msgstr ":c:type:`getbufferproc`" -#: ../../c-api/typeobj.rst:0 +#: ../../c-api/typeobj.rst:420 ../../c-api/typeobj.rst:426 msgid ":c:type:`Py_buffer` *" msgstr ":c:type:`Py_buffer` *" @@ -1244,11 +1260,11 @@ msgid "" " iternextfunc tp_iternext;\n" "\n" " /* Attribute descriptor and subclassing stuff */\n" -" struct PyMethodDef *tp_methods;\n" -" struct PyMemberDef *tp_members;\n" -" struct PyGetSetDef *tp_getset;\n" +" PyMethodDef *tp_methods;\n" +" PyMemberDef *tp_members;\n" +" PyGetSetDef *tp_getset;\n" " // Strong reference on a heap type, borrowed reference on a static type\n" -" struct _typeobject *tp_base;\n" +" PyTypeObject *tp_base;\n" " PyObject *tp_dict;\n" " descrgetfunc tp_descr_get;\n" " descrsetfunc tp_descr_set;\n" @@ -1260,12 +1276,14 @@ msgid "" " inquiry tp_is_gc; /* For PyObject_IS_GC */\n" " PyObject *tp_bases;\n" " PyObject *tp_mro; /* method resolution order */\n" -" PyObject *tp_cache;\n" -" PyObject *tp_subclasses;\n" -" PyObject *tp_weaklist;\n" +" PyObject *tp_cache; /* no longer used */\n" +" void *tp_subclasses; /* for static builtin types this is an index */\n" +" PyObject *tp_weaklist; /* not used for static builtin types */\n" " destructor tp_del;\n" "\n" -" /* Type attribute cache version tag. Added in version 2.6 */\n" +" /* Type attribute cache version tag. Added in version 2.6.\n" +" * If zero, the cache is invalid and must be initialized.\n" +" */\n" " unsigned int tp_version_tag;\n" "\n" " destructor tp_finalize;\n" @@ -1273,6 +1291,13 @@ msgid "" "\n" " /* bitset of which type-watchers care about this type */\n" " unsigned char tp_watched;\n" +"\n" +" /* Number of tp_version_tag values used.\n" +" * Set to _Py_ATTR_CACHE_UNUSED if the attribute cache is\n" +" * disabled for this type (e.g. due to custom MRO entries).\n" +" * Otherwise, limited to MAX_VERSIONS_PER_CLASS (defined elsewhere).\n" +" */\n" +" uint16_t tp_versions_used;\n" "} PyTypeObject;\n" msgstr "" @@ -1290,9 +1315,13 @@ msgid "" "the :c:member:`~PyVarObject.ob_size` field." msgstr "" +#: ../../c-api/typeobj.rst:495 +msgid ":c:member:`PyObject.ob_refcnt`" +msgstr ":c:member:`PyObject.ob_refcnt`" + #: ../../c-api/typeobj.rst:497 msgid "" -"This is the type object's reference count, initialized to ``1`` by the " +"The type object's reference count is initialized to ``1`` by the " "``PyObject_HEAD_INIT`` macro. Note that for :ref:`statically allocated type " "objects `, the type's instances (objects whose :c:member:" "`~PyObject.ob_type` points back to the type) do *not* count as references. " @@ -1301,45 +1330,49 @@ msgid "" msgstr "" #: ../../c-api/typeobj.rst:504 ../../c-api/typeobj.rst:527 -#: ../../c-api/typeobj.rst:544 ../../c-api/typeobj.rst:588 -#: ../../c-api/typeobj.rst:666 ../../c-api/typeobj.rst:742 -#: ../../c-api/typeobj.rst:783 ../../c-api/typeobj.rst:800 -#: ../../c-api/typeobj.rst:817 ../../c-api/typeobj.rst:835 -#: ../../c-api/typeobj.rst:859 ../../c-api/typeobj.rst:876 -#: ../../c-api/typeobj.rst:888 ../../c-api/typeobj.rst:900 -#: ../../c-api/typeobj.rst:933 ../../c-api/typeobj.rst:955 -#: ../../c-api/typeobj.rst:975 ../../c-api/typeobj.rst:996 -#: ../../c-api/typeobj.rst:1022 ../../c-api/typeobj.rst:1041 -#: ../../c-api/typeobj.rst:1057 ../../c-api/typeobj.rst:1096 -#: ../../c-api/typeobj.rst:1107 ../../c-api/typeobj.rst:1117 -#: ../../c-api/typeobj.rst:1127 ../../c-api/typeobj.rst:1141 -#: ../../c-api/typeobj.rst:1159 ../../c-api/typeobj.rst:1182 -#: ../../c-api/typeobj.rst:1200 ../../c-api/typeobj.rst:1213 -#: ../../c-api/typeobj.rst:1235 ../../c-api/typeobj.rst:1279 -#: ../../c-api/typeobj.rst:1300 ../../c-api/typeobj.rst:1319 -#: ../../c-api/typeobj.rst:1349 ../../c-api/typeobj.rst:1371 -#: ../../c-api/typeobj.rst:1397 ../../c-api/typeobj.rst:1482 -#: ../../c-api/typeobj.rst:1556 ../../c-api/typeobj.rst:1617 -#: ../../c-api/typeobj.rst:1653 ../../c-api/typeobj.rst:1678 -#: ../../c-api/typeobj.rst:1701 ../../c-api/typeobj.rst:1714 -#: ../../c-api/typeobj.rst:1729 ../../c-api/typeobj.rst:1743 -#: ../../c-api/typeobj.rst:1773 ../../c-api/typeobj.rst:1805 -#: ../../c-api/typeobj.rst:1831 ../../c-api/typeobj.rst:1849 -#: ../../c-api/typeobj.rst:1878 ../../c-api/typeobj.rst:1922 -#: ../../c-api/typeobj.rst:1939 ../../c-api/typeobj.rst:1980 -#: ../../c-api/typeobj.rst:2002 ../../c-api/typeobj.rst:2034 -#: ../../c-api/typeobj.rst:2062 ../../c-api/typeobj.rst:2075 -#: ../../c-api/typeobj.rst:2085 ../../c-api/typeobj.rst:2102 -#: ../../c-api/typeobj.rst:2119 ../../c-api/typeobj.rst:2133 -#: ../../c-api/typeobj.rst:2166 ../../c-api/typeobj.rst:2189 +#: ../../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:1367 +#: ../../c-api/typeobj.rst:1388 ../../c-api/typeobj.rst:1407 +#: ../../c-api/typeobj.rst:1437 ../../c-api/typeobj.rst:1459 +#: ../../c-api/typeobj.rst:1487 ../../c-api/typeobj.rst:1580 +#: ../../c-api/typeobj.rst:1726 ../../c-api/typeobj.rst:1793 +#: ../../c-api/typeobj.rst:1829 ../../c-api/typeobj.rst:1856 +#: ../../c-api/typeobj.rst:1881 ../../c-api/typeobj.rst:1896 +#: ../../c-api/typeobj.rst:1913 ../../c-api/typeobj.rst:1929 +#: ../../c-api/typeobj.rst:1961 ../../c-api/typeobj.rst:1993 +#: ../../c-api/typeobj.rst:2021 ../../c-api/typeobj.rst:2041 +#: ../../c-api/typeobj.rst:2070 ../../c-api/typeobj.rst:2116 +#: ../../c-api/typeobj.rst:2135 ../../c-api/typeobj.rst:2177 +#: ../../c-api/typeobj.rst:2202 ../../c-api/typeobj.rst:2242 +#: ../../c-api/typeobj.rst:2272 ../../c-api/typeobj.rst:2285 +#: ../../c-api/typeobj.rst:2295 ../../c-api/typeobj.rst:2312 +#: ../../c-api/typeobj.rst:2329 ../../c-api/typeobj.rst:2345 +#: ../../c-api/typeobj.rst:2489 ../../c-api/typeobj.rst:2549 msgid "**Inheritance:**" msgstr "" -#: ../../c-api/typeobj.rst:506 ../../c-api/typeobj.rst:546 -#: ../../c-api/typeobj.rst:590 +#: ../../c-api/typeobj.rst:506 ../../c-api/typeobj.rst:545 +#: ../../c-api/typeobj.rst:589 msgid "This field is not inherited by subtypes." msgstr "" +#: ../../c-api/typeobj.rst:509 +msgid ":c:member:`PyObject.ob_type`" +msgstr ":c:member:`PyObject.ob_type`" + #: ../../c-api/typeobj.rst:511 msgid "" "This is the type's type, in other words its metatype. It is initialized by " @@ -1364,12 +1397,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:744 -#: ../../c-api/typeobj.rst:861 ../../c-api/typeobj.rst:957 -#: ../../c-api/typeobj.rst:977 ../../c-api/typeobj.rst:1680 -#: ../../c-api/typeobj.rst:1703 ../../c-api/typeobj.rst:1833 -#: ../../c-api/typeobj.rst:1851 ../../c-api/typeobj.rst:1924 -#: ../../c-api/typeobj.rst:2036 ../../c-api/typeobj.rst:2168 +#: ../../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:1858 +#: ../../c-api/typeobj.rst:1883 ../../c-api/typeobj.rst:2023 +#: ../../c-api/typeobj.rst:2043 ../../c-api/typeobj.rst:2118 +#: ../../c-api/typeobj.rst:2244 ../../c-api/typeobj.rst:2491 msgid "This field is inherited by subtypes." msgstr "" @@ -1377,6 +1410,10 @@ msgstr "" msgid "PyVarObject Slots" msgstr "" +#: ../../c-api/typeobj.rst:535 +msgid ":c:member:`PyVarObject.ob_size`" +msgstr ":c:member:`PyVarObject.ob_size`" + #: ../../c-api/typeobj.rst:537 msgid "" "For :ref:`statically allocated type objects `, this should be " @@ -1385,16 +1422,14 @@ msgid "" msgstr "" #: ../../c-api/typeobj.rst:541 -msgid "" -"This field should be accessed using the :c:func:`Py_SIZE()` and :c:func:" -"`Py_SET_SIZE()` macros." +msgid "This field should be accessed using the :c:func:`Py_SIZE()` macro." msgstr "" -#: ../../c-api/typeobj.rst:550 +#: ../../c-api/typeobj.rst:549 msgid "PyTypeObject Slots" msgstr "" -#: ../../c-api/typeobj.rst:552 +#: ../../c-api/typeobj.rst:551 msgid "" "Each slot has a section describing inheritance. If :c:func:`PyType_Ready` " "may set a value when the field is set to ``NULL`` then there will also be a " @@ -1402,7 +1437,7 @@ msgid "" "`PyBaseObject_Type` and :c:data:`PyType_Type` effectively act as defaults.)" msgstr "" -#: ../../c-api/typeobj.rst:559 +#: ../../c-api/typeobj.rst:558 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 " @@ -1414,14 +1449,14 @@ msgid "" "tp_name` initializer ``\"P.Q.M.T\"``." msgstr "" -#: ../../c-api/typeobj.rst:567 +#: ../../c-api/typeobj.rst:566 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:572 +#: ../../c-api/typeobj.rst:571 msgid "" "For :ref:`statically allocated type objects `, the *tp_name* " "field should contain a dot. Everything before the last dot is made " @@ -1429,7 +1464,7 @@ msgid "" "the last dot is made accessible as the :attr:`~type.__name__` attribute." msgstr "" -#: ../../c-api/typeobj.rst:578 +#: ../../c-api/typeobj.rst:577 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:" @@ -1439,19 +1474,19 @@ msgid "" "created with pydoc." msgstr "" -#: ../../c-api/typeobj.rst:584 +#: ../../c-api/typeobj.rst:583 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:596 +#: ../../c-api/typeobj.rst:595 msgid "" "These fields allow calculating the size in bytes of instances of the type." msgstr "" -#: ../../c-api/typeobj.rst:598 +#: ../../c-api/typeobj.rst:597 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 " @@ -1461,7 +1496,7 @@ msgid "" "`PyUnstable_Object_GC_NewWithExtraData`.)" msgstr "" -#: ../../c-api/typeobj.rst:605 +#: ../../c-api/typeobj.rst:604 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:`!" @@ -1469,7 +1504,7 @@ msgid "" "\"length\" of the object." msgstr "" -#: ../../c-api/typeobj.rst:610 +#: ../../c-api/typeobj.rst:609 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` " @@ -1480,13 +1515,13 @@ msgid "" "`PyLong_Export`." msgstr "" -#: ../../c-api/typeobj.rst:620 +#: ../../c-api/typeobj.rst:619 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:623 +#: ../../c-api/typeobj.rst:622 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. " @@ -1496,13 +1531,13 @@ msgid "" "`PyList_Size` instead.)" msgstr "" -#: ../../c-api/typeobj.rst:630 +#: ../../c-api/typeobj.rst:629 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:634 +#: ../../c-api/typeobj.rst:633 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 " @@ -1511,7 +1546,7 @@ msgid "" "tp_basicsize`." msgstr "" -#: ../../c-api/typeobj.rst:640 +#: ../../c-api/typeobj.rst:639 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:" @@ -1520,23 +1555,23 @@ msgid "" "respectively." msgstr "" -#: ../../c-api/typeobj.rst:646 +#: ../../c-api/typeobj.rst:645 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:649 +#: ../../c-api/typeobj.rst:648 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:652 +#: ../../c-api/typeobj.rst:651 msgid "Notes about alignment:" msgstr "" -#: ../../c-api/typeobj.rst:654 +#: ../../c-api/typeobj.rst:653 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 " @@ -1545,7 +1580,7 @@ msgid "" "you." msgstr "" -#: ../../c-api/typeobj.rst:659 +#: ../../c-api/typeobj.rst:658 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 " @@ -1553,14 +1588,14 @@ msgid "" "your responsibility that both fields are a multiple of ``_Alignof(double)``." msgstr "" -#: ../../c-api/typeobj.rst:668 +#: ../../c-api/typeobj.rst:667 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:673 +#: ../../c-api/typeobj.rst:672 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 " @@ -1568,110 +1603,220 @@ msgid "" "implementation of the base type)." msgstr "" -#: ../../c-api/typeobj.rst:680 +#: ../../c-api/typeobj.rst:681 msgid "" -"A pointer to the instance destructor function. This function must be " -"defined unless the type guarantees that its instances will never be " -"deallocated (as is the case for the singletons ``None`` and ``Ellipsis``). " -"The function signature is::" +"A pointer to the instance destructor function. The function signature is::" msgstr "" -#: ../../c-api/typeobj.rst:684 +#: ../../c-api/typeobj.rst:683 msgid "void tp_dealloc(PyObject *self);" msgstr "void tp_dealloc(PyObject *self);" -#: ../../c-api/typeobj.rst:686 +#: ../../c-api/typeobj.rst:685 msgid "" -"The destructor function is called by the :c:func:`Py_DECREF` and :c:func:" -"`Py_XDECREF` macros when the new reference count is zero. At this point, " -"the instance is still in existence, but there are no references to it. The " -"destructor function should free all references which the instance owns, free " -"all memory buffers owned by the instance (using the freeing function " -"corresponding to the allocation function used to allocate the buffer), and " -"call the type's :c:member:`~PyTypeObject.tp_free` function. If the type is " -"not subtypable (doesn't have the :c:macro:`Py_TPFLAGS_BASETYPE` flag bit " -"set), it is permissible to call the object deallocator directly instead of " -"via :c:member:`~PyTypeObject.tp_free`. The object deallocator should be the " -"one used to allocate the instance; this is normally :c:func:`PyObject_Del` " -"if the instance was allocated using :c:macro:`PyObject_New` or :c:macro:" -"`PyObject_NewVar`, or :c:func:`PyObject_GC_Del` if the instance was " -"allocated using :c:macro:`PyObject_GC_New` or :c:macro:`PyObject_GC_NewVar`." +"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 " +"instance, and call the type's :c:member:`~PyTypeObject.tp_free` function to " +"free the object itself." msgstr "" -#: ../../c-api/typeobj.rst:701 +#: ../../c-api/typeobj.rst:690 msgid "" -"If the type supports garbage collection (has the :c:macro:" -"`Py_TPFLAGS_HAVE_GC` flag bit set), the destructor should call :c:func:" -"`PyObject_GC_UnTrack` before clearing any member fields." +"If you may call functions that may set the error indicator, you must use :c:" +"func:`PyErr_GetRaisedException` and :c:func:`PyErr_SetRaisedException` to " +"ensure you don't clobber a preexisting error indicator (the deallocation " +"could have occurred while processing a different error):" msgstr "" -#: ../../c-api/typeobj.rst:705 +#: ../../c-api/typeobj.rst:695 msgid "" -"static void foo_dealloc(foo_object *self) {\n" -" PyObject_GC_UnTrack(self);\n" -" Py_CLEAR(self->ref);\n" -" Py_TYPE(self)->tp_free((PyObject *)self);\n" +"static void\n" +"foo_dealloc(foo_object *self)\n" +"{\n" +" PyObject *et, *ev, *etb;\n" +" PyObject *exc = PyErr_GetRaisedException();\n" +" ...\n" +" PyErr_SetRaisedException(exc);\n" "}" msgstr "" -"static void foo_dealloc(foo_object *self) {\n" -" PyObject_GC_UnTrack(self);\n" -" Py_CLEAR(self->ref);\n" -" Py_TYPE(self)->tp_free((PyObject *)self);\n" -"}" -#: ../../c-api/typeobj.rst:713 +#: ../../c-api/typeobj.rst:706 +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 +msgid "No guarantees are made about when an object is destroyed, except:" +msgstr "" + +#: ../../c-api/typeobj.rst:712 +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 +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 +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 +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 +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 +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 " +"always cleared before destruction. Beware that :c:member:`!tp_clear` might " +"have already been called." +msgstr "" + +#: ../../c-api/typeobj.rst:737 msgid "" -"Finally, if the type is heap allocated (:c:macro:`Py_TPFLAGS_HEAPTYPE`), the " +"If the type is heap allocated (:c:macro:`Py_TPFLAGS_HEAPTYPE`), the " "deallocator should release the owned reference to its type object (via :c:" -"func:`Py_DECREF`) after calling the type deallocator. In order to avoid " -"dangling pointers, the recommended way to achieve this is:" +"func:`Py_DECREF`) after calling the type deallocator. See the example code " +"below.::" +msgstr "" + +#: ../../c-api/typeobj.rst:742 +msgid "" +"static void\n" +"foo_dealloc(PyObject *op)\n" +"{\n" +" foo_object *self = (foo_object *) op;\n" +" PyObject_GC_UnTrack(self);\n" +" Py_CLEAR(self->ref);\n" +" Py_TYPE(self)->tp_free(self);\n" +"}" +msgstr "" +"static void\n" +"foo_dealloc(PyObject *op)\n" +"{\n" +" foo_object *self = (foo_object *) op;\n" +" PyObject_GC_UnTrack(self);\n" +" Py_CLEAR(self->ref);\n" +" Py_TYPE(self)->tp_free(self);\n" +"}" + +#: ../../c-api/typeobj.rst:751 +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 " +"must be backed up first and restored later (after logging any exceptions " +"with :c:func:`PyErr_WriteUnraisable`)." msgstr "" -#: ../../c-api/typeobj.rst:719 +#: ../../c-api/typeobj.rst:756 +msgid "Example::" +msgstr "範例: ::" + +#: ../../c-api/typeobj.rst:758 msgid "" -"static void foo_dealloc(foo_object *self) {\n" +"static void\n" +"foo_dealloc(PyObject *self)\n" +"{\n" +" PyObject *exc = PyErr_GetRaisedException();\n" +"\n" +" if (PyObject_CallFinalizerFromDealloc(self) < 0) {\n" +" // self was resurrected.\n" +" goto done;\n" +" }\n" +"\n" " PyTypeObject *tp = Py_TYPE(self);\n" -" // free references and buffers here\n" +"\n" +" if (tp->tp_flags & Py_TPFLAGS_HAVE_GC) {\n" +" PyObject_GC_UnTrack(self);\n" +" }\n" +"\n" +" // Optional, but convenient to avoid code duplication.\n" +" if (tp->tp_clear && tp->tp_clear(self) < 0) {\n" +" PyErr_WriteUnraisable(self);\n" +" }\n" +"\n" +" // Any additional destruction goes here.\n" +"\n" " tp->tp_free(self);\n" -" Py_DECREF(tp);\n" +" self = NULL; // In case PyErr_WriteUnraisable() is called below.\n" +"\n" +" if (tp->tp_flags & Py_TPFLAGS_HEAPTYPE) {\n" +" Py_CLEAR(tp);\n" +" }\n" +"\n" +"done:\n" +" // Optional, if something was called that might have raised an\n" +" // exception.\n" +" if (PyErr_Occurred()) {\n" +" PyErr_WriteUnraisable(self);\n" +" }\n" +" PyErr_SetRaisedException(exc);\n" "}" msgstr "" -#: ../../c-api/typeobj.rst:730 +#: ../../c-api/typeobj.rst:797 +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 " +"cycle, that cycle might be collected by a garbage collection on any " +"thread). This is not a problem for Python API calls, since the thread on " +"which :c:member:`!tp_dealloc` is called with an :term:`attached thread " +"state`. However, if the object being destroyed in turn destroys objects " +"from some other C library, care should be taken to ensure that destroying " +"those objects on the thread which called :c:member:`!tp_dealloc` will not " +"violate any assumptions of the library." +msgstr "" + +#: ../../c-api/typeobj.rst:815 ../../c-api/typeobj.rst:1737 +#: ../../c-api/typeobj.rst:2504 msgid "" -"In a garbage collected Python, :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 cycle, that cycle might be collected by a " -"garbage collection on any thread). This is not a problem for Python API " -"calls, since the thread on which :c:member:`!tp_dealloc` is called will own " -"the Global Interpreter Lock (GIL). However, if the object being destroyed " -"in turn destroys objects from some other C or C++ library, care should be " -"taken to ensure that destroying those objects on the thread which called :c:" -"member:`!tp_dealloc` will not violate any assumptions of the library." +":ref:`life-cycle` for details about how this slot relates to other slots." msgstr "" -#: ../../c-api/typeobj.rst:749 +#: ../../c-api/typeobj.rst:820 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:754 +#: ../../c-api/typeobj.rst:825 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:758 +#: ../../c-api/typeobj.rst:829 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:762 +#: ../../c-api/typeobj.rst:833 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 " @@ -1679,13 +1824,13 @@ msgid "" "`PyVectorcall_Call`." msgstr "" -#: ../../c-api/typeobj.rst:769 +#: ../../c-api/typeobj.rst:840 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:775 +#: ../../c-api/typeobj.rst:846 msgid "" "Before version 3.12, it was not recommended for :ref:`mutable heap types " "` to implement the vectorcall protocol. When a user sets :attr:" @@ -1695,7 +1840,7 @@ msgid "" "`Py_TPFLAGS_HAVE_VECTORCALL` flag." msgstr "" -#: ../../c-api/typeobj.rst:785 +#: ../../c-api/typeobj.rst:856 msgid "" "This field is always inherited. However, the :c:macro:" "`Py_TPFLAGS_HAVE_VECTORCALL` flag is not always inherited. If it's not set, " @@ -1703,19 +1848,21 @@ msgid "" "func:`PyVectorcall_Call` is explicitly called." msgstr "" -#: ../../c-api/typeobj.rst:794 +#: ../../c-api/typeobj.rst:867 msgid "An optional pointer to the get-attribute-string function." msgstr "" -#: ../../c-api/typeobj.rst:796 +#: ../../c-api/typeobj.rst:869 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, " "but taking a C string instead of a Python string object to give the " "attribute name." msgstr "" +"此欄位已被棄用。當它被定義時,它應該指向一個與 :c:member:`~PyTypeObject." +"tp_getattro` 行為相同但使用 C 字串而非 Python 字串物件來提供屬性名稱的函式。" -#: ../../c-api/typeobj.rst:802 ../../c-api/typeobj.rst:998 +#: ../../c-api/typeobj.rst:875 ../../c-api/typeobj.rst:1083 msgid "" "Group: :c:member:`~PyTypeObject.tp_getattr`, :c:member:`~PyTypeObject." "tp_getattro`" @@ -1723,7 +1870,7 @@ msgstr "" "群組::c:member:`~PyTypeObject.tp_getattr`、:c:member:`~PyTypeObject." "tp_getattro`" -#: ../../c-api/typeobj.rst:804 +#: ../../c-api/typeobj.rst:877 msgid "" "This field is inherited by subtypes together with :c:member:`~PyTypeObject." "tp_getattro`: a subtype inherits both :c:member:`~PyTypeObject.tp_getattr` " @@ -1732,20 +1879,22 @@ msgid "" "tp_getattro` are both ``NULL``." msgstr "" -#: ../../c-api/typeobj.rst:811 ../../c-api/typeobj.rst:1011 +#: ../../c-api/typeobj.rst:886 ../../c-api/typeobj.rst:1098 msgid "" "An optional pointer to the function for setting and deleting attributes." msgstr "" -#: ../../c-api/typeobj.rst:813 +#: ../../c-api/typeobj.rst:888 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, " "but taking a C string instead of a Python string object to give the " "attribute name." msgstr "" +"此欄位已被棄用。當它被定義時,它應該指向一個與 :c:member:`~PyTypeObject." +"tp_setattro` 行為相同但使用 C 字串而非 Python 字串物件來提供屬性名稱的函式。" -#: ../../c-api/typeobj.rst:819 ../../c-api/typeobj.rst:1024 +#: ../../c-api/typeobj.rst:894 ../../c-api/typeobj.rst:1111 msgid "" "Group: :c:member:`~PyTypeObject.tp_setattr`, :c:member:`~PyTypeObject." "tp_setattro`" @@ -1753,7 +1902,7 @@ msgstr "" "群組::c:member:`~PyTypeObject.tp_setattr`、:c:member:`~PyTypeObject." "tp_setattro`" -#: ../../c-api/typeobj.rst:821 +#: ../../c-api/typeobj.rst:896 msgid "" "This field is inherited by subtypes together with :c:member:`~PyTypeObject." "tp_setattro`: a subtype inherits both :c:member:`~PyTypeObject.tp_setattr` " @@ -1762,38 +1911,38 @@ msgid "" "tp_setattro` are both ``NULL``." msgstr "" -#: ../../c-api/typeobj.rst:828 +#: ../../c-api/typeobj.rst:903 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:832 +#: ../../c-api/typeobj.rst:907 msgid "Formerly known as ``tp_compare`` and ``tp_reserved``." -msgstr "" +msgstr "以前稱為 ``tp_compare`` 和 ``tp_reserved``。" -#: ../../c-api/typeobj.rst:837 +#: ../../c-api/typeobj.rst:912 msgid "" "The :c:member:`~PyTypeObject.tp_as_async` field is not inherited, but the " "contained fields are inherited individually." msgstr "" -#: ../../c-api/typeobj.rst:845 +#: ../../c-api/typeobj.rst:922 msgid "" "An optional pointer to a function that implements the built-in function :" "func:`repr`." msgstr "" -#: ../../c-api/typeobj.rst:848 +#: ../../c-api/typeobj.rst:925 msgid "The signature is the same as for :c:func:`PyObject_Repr`::" -msgstr "" +msgstr "函式簽名與 :c:func:`PyObject_Repr` 相同: ::" -#: ../../c-api/typeobj.rst:850 +#: ../../c-api/typeobj.rst:927 msgid "PyObject *tp_repr(PyObject *self);" msgstr "PyObject *tp_repr(PyObject *self);" -#: ../../c-api/typeobj.rst:852 +#: ../../c-api/typeobj.rst:929 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 " @@ -1802,85 +1951,85 @@ msgid "" "``'>'`` from which both the type and the value of the object can be deduced." msgstr "" -#: ../../c-api/typeobj.rst:863 ../../c-api/typeobj.rst:942 -#: ../../c-api/typeobj.rst:979 ../../c-api/typeobj.rst:1004 -#: ../../c-api/typeobj.rst:1030 ../../c-api/typeobj.rst:1071 -#: ../../c-api/typeobj.rst:1626 ../../c-api/typeobj.rst:1660 -#: ../../c-api/typeobj.rst:1777 ../../c-api/typeobj.rst:1810 -#: ../../c-api/typeobj.rst:1885 ../../c-api/typeobj.rst:1926 -#: ../../c-api/typeobj.rst:1944 ../../c-api/typeobj.rst:1986 -#: ../../c-api/typeobj.rst:2007 ../../c-api/typeobj.rst:2038 +#: ../../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:1802 ../../c-api/typeobj.rst:1836 +#: ../../c-api/typeobj.rst:1965 ../../c-api/typeobj.rst:1998 +#: ../../c-api/typeobj.rst:2077 ../../c-api/typeobj.rst:2120 +#: ../../c-api/typeobj.rst:2142 ../../c-api/typeobj.rst:2183 +#: ../../c-api/typeobj.rst:2213 ../../c-api/typeobj.rst:2246 msgid "**Default:**" msgstr "**預設:**" -#: ../../c-api/typeobj.rst:865 +#: ../../c-api/typeobj.rst:942 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:872 +#: ../../c-api/typeobj.rst:949 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:878 +#: ../../c-api/typeobj.rst:955 msgid "" "The :c:member:`~PyTypeObject.tp_as_number` field is not inherited, but the " "contained fields are inherited individually." msgstr "" -#: ../../c-api/typeobj.rst:884 +#: ../../c-api/typeobj.rst:961 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:890 +#: ../../c-api/typeobj.rst:967 msgid "" "The :c:member:`~PyTypeObject.tp_as_sequence` field is not inherited, but the " "contained fields are inherited individually." msgstr "" -#: ../../c-api/typeobj.rst:896 +#: ../../c-api/typeobj.rst:973 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:902 +#: ../../c-api/typeobj.rst:979 msgid "" "The :c:member:`~PyTypeObject.tp_as_mapping` field is not inherited, but the " "contained fields are inherited individually." msgstr "" -#: ../../c-api/typeobj.rst:910 +#: ../../c-api/typeobj.rst:989 msgid "" "An optional pointer to a function that implements the built-in function :" "func:`hash`." msgstr "" -#: ../../c-api/typeobj.rst:913 +#: ../../c-api/typeobj.rst:992 msgid "The signature is the same as for :c:func:`PyObject_Hash`::" -msgstr "" +msgstr "函式簽名與 :c:func:`PyObject_Hash` 相同: ::" -#: ../../c-api/typeobj.rst:915 +#: ../../c-api/typeobj.rst:994 msgid "Py_hash_t tp_hash(PyObject *);" msgstr "Py_hash_t tp_hash(PyObject *);" -#: ../../c-api/typeobj.rst:917 +#: ../../c-api/typeobj.rst:996 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:921 +#: ../../c-api/typeobj.rst:1000 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:" @@ -1888,7 +2037,7 @@ msgid "" "`PyObject_HashNotImplemented`." msgstr "" -#: ../../c-api/typeobj.rst:925 +#: ../../c-api/typeobj.rst:1004 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 " @@ -1899,7 +2048,7 @@ msgid "" "`PyObject_HashNotImplemented`." msgstr "" -#: ../../c-api/typeobj.rst:935 ../../c-api/typeobj.rst:1619 +#: ../../c-api/typeobj.rst:1014 ../../c-api/typeobj.rst:1795 msgid "" "Group: :c:member:`~PyTypeObject.tp_hash`, :c:member:`~PyTypeObject." "tp_richcompare`" @@ -1907,7 +2056,7 @@ msgstr "" "群組::c:member:`~PyTypeObject.tp_hash`、:c:member:`~PyTypeObject." "tp_richcompare`" -#: ../../c-api/typeobj.rst:937 +#: ../../c-api/typeobj.rst:1016 msgid "" "This field is inherited by subtypes together with :c:member:`~PyTypeObject." "tp_richcompare`: a subtype inherits both of :c:member:`~PyTypeObject." @@ -1916,22 +2065,22 @@ msgid "" "are both ``NULL``." msgstr "" -#: ../../c-api/typeobj.rst:944 +#: ../../c-api/typeobj.rst:1023 msgid ":c:data:`PyBaseObject_Type` uses :c:func:`PyObject_GenericHash`." -msgstr "" +msgstr ":c:data:`PyBaseObject_Type` 會使用 :c:func:`PyObject_GenericHash`。" -#: ../../c-api/typeobj.rst:949 +#: ../../c-api/typeobj.rst:1030 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:953 +#: ../../c-api/typeobj.rst:1034 msgid "PyObject *tp_call(PyObject *self, PyObject *args, PyObject *kwargs);" msgstr "PyObject *tp_call(PyObject *self, PyObject *args, PyObject *kwargs);" -#: ../../c-api/typeobj.rst:962 +#: ../../c-api/typeobj.rst:1045 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 " @@ -1940,15 +2089,15 @@ msgid "" "this handler.)" msgstr "" -#: ../../c-api/typeobj.rst:967 +#: ../../c-api/typeobj.rst:1050 msgid "The signature is the same as for :c:func:`PyObject_Str`::" -msgstr "" +msgstr "函式簽名與 :c:func:`PyObject_Str` 相同: ::" -#: ../../c-api/typeobj.rst:969 +#: ../../c-api/typeobj.rst:1052 msgid "PyObject *tp_str(PyObject *self);" msgstr "PyObject *tp_str(PyObject *self);" -#: ../../c-api/typeobj.rst:971 +#: ../../c-api/typeobj.rst:1054 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 " @@ -1956,32 +2105,32 @@ msgid "" "function." msgstr "" -#: ../../c-api/typeobj.rst:981 +#: ../../c-api/typeobj.rst:1064 msgid "" "When this field is not set, :c:func:`PyObject_Repr` is called to return a " "string representation." msgstr "" -#: ../../c-api/typeobj.rst:987 +#: ../../c-api/typeobj.rst:1072 msgid "An optional pointer to the get-attribute function." msgstr "" -#: ../../c-api/typeobj.rst:989 +#: ../../c-api/typeobj.rst:1074 msgid "The signature is the same as for :c:func:`PyObject_GetAttr`::" -msgstr "" +msgstr "函式簽名與 :c:func:`PyObject_GetAttr` 相同: ::" -#: ../../c-api/typeobj.rst:991 +#: ../../c-api/typeobj.rst:1076 msgid "PyObject *tp_getattro(PyObject *self, PyObject *attr);" msgstr "PyObject *tp_getattro(PyObject *self, PyObject *attr);" -#: ../../c-api/typeobj.rst:993 +#: ../../c-api/typeobj.rst:1078 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:1000 +#: ../../c-api/typeobj.rst:1085 msgid "" "This field is inherited by subtypes together with :c:member:`~PyTypeObject." "tp_getattr`: a subtype inherits both :c:member:`~PyTypeObject.tp_getattr` " @@ -1990,19 +2139,19 @@ msgid "" "tp_getattro` are both ``NULL``." msgstr "" -#: ../../c-api/typeobj.rst:1006 +#: ../../c-api/typeobj.rst:1091 msgid ":c:data:`PyBaseObject_Type` uses :c:func:`PyObject_GenericGetAttr`." -msgstr "" +msgstr ":c:data:`PyBaseObject_Type` 會使用 :c:func:`PyObject_GenericGetAttr`。" -#: ../../c-api/typeobj.rst:1013 +#: ../../c-api/typeobj.rst:1100 msgid "The signature is the same as for :c:func:`PyObject_SetAttr`::" -msgstr "" +msgstr "函式簽名與 :c:func:`PyObject_SetAttr` 相同: ::" -#: ../../c-api/typeobj.rst:1015 +#: ../../c-api/typeobj.rst:1102 msgid "int tp_setattro(PyObject *self, PyObject *attr, PyObject *value);" msgstr "int tp_setattro(PyObject *self, PyObject *attr, PyObject *value);" -#: ../../c-api/typeobj.rst:1017 +#: ../../c-api/typeobj.rst:1104 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:" @@ -2010,7 +2159,7 @@ msgid "" "attributes." msgstr "" -#: ../../c-api/typeobj.rst:1026 +#: ../../c-api/typeobj.rst:1113 msgid "" "This field is inherited by subtypes together with :c:member:`~PyTypeObject." "tp_setattr`: a subtype inherits both :c:member:`~PyTypeObject.tp_setattr` " @@ -2019,24 +2168,24 @@ msgid "" "tp_setattro` are both ``NULL``." msgstr "" -#: ../../c-api/typeobj.rst:1032 +#: ../../c-api/typeobj.rst:1119 msgid ":c:data:`PyBaseObject_Type` uses :c:func:`PyObject_GenericSetAttr`." msgstr "" -#: ../../c-api/typeobj.rst:1037 +#: ../../c-api/typeobj.rst:1124 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:1043 +#: ../../c-api/typeobj.rst:1130 msgid "" "The :c:member:`~PyTypeObject.tp_as_buffer` field is not inherited, but the " "contained fields are inherited individually." msgstr "" -#: ../../c-api/typeobj.rst:1049 +#: ../../c-api/typeobj.rst:1136 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 " @@ -2048,7 +2197,7 @@ msgid "" "accessed and must be considered to have a zero or ``NULL`` value instead." msgstr "" -#: ../../c-api/typeobj.rst:1059 +#: ../../c-api/typeobj.rst:1146 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 " @@ -2060,11 +2209,10 @@ msgid "" "and :c:member:`~PyTypeObject.tp_clear` fields, i.e. if the :c:macro:" "`Py_TPFLAGS_HAVE_GC` flag bit is clear in the subtype and the :c:member:" "`~PyTypeObject.tp_traverse` and :c:member:`~PyTypeObject.tp_clear` fields in " -"the subtype exist and have ``NULL`` values. .. XXX are most flag bits " -"*really* inherited individually?" +"the subtype exist and have ``NULL`` values." msgstr "" -#: ../../c-api/typeobj.rst:1073 +#: ../../c-api/typeobj.rst:1161 msgid "" ":c:data:`PyBaseObject_Type` uses ``Py_TPFLAGS_DEFAULT | " "Py_TPFLAGS_BASETYPE``." @@ -2072,11 +2220,11 @@ msgstr "" ":c:data:`PyBaseObject_Type` 使用 ``Py_TPFLAGS_DEFAULT | " "Py_TPFLAGS_BASETYPE``。" -#: ../../c-api/typeobj.rst:1076 +#: ../../c-api/typeobj.rst:1164 msgid "**Bit Masks:**" msgstr "" -#: ../../c-api/typeobj.rst:1080 +#: ../../c-api/typeobj.rst:1168 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." @@ -2085,7 +2233,7 @@ msgid "" "zero." msgstr "" -#: ../../c-api/typeobj.rst:1087 +#: ../../c-api/typeobj.rst:1175 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 " @@ -2098,49 +2246,49 @@ msgid "" "reference cycle with their own module object." msgstr "" -#: ../../c-api/typeobj.rst:1098 ../../c-api/typeobj.rst:1109 -#: ../../c-api/typeobj.rst:1119 ../../c-api/typeobj.rst:1129 -#: ../../c-api/typeobj.rst:1161 +#: ../../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 msgid "???" msgstr "???" -#: ../../c-api/typeobj.rst:1103 +#: ../../c-api/typeobj.rst:1191 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:1114 +#: ../../c-api/typeobj.rst:1202 msgid "" "This bit is set when the type object has been fully initialized by :c:func:" "`PyType_Ready`." msgstr "" -#: ../../c-api/typeobj.rst:1124 +#: ../../c-api/typeobj.rst:1212 msgid "" "This bit is set while :c:func:`PyType_Ready` is in the process of " "initializing the type object." msgstr "" -#: ../../c-api/typeobj.rst:1134 +#: ../../c-api/typeobj.rst:1222 msgid "" "This bit is set when the object supports garbage collection. If this bit is " -"set, instances must be created using :c:macro:`PyObject_GC_New` and " -"destroyed using :c:func:`PyObject_GC_Del`. More information in section :ref:" -"`supporting-cycle-detection`. This bit also implies that the GC-related " -"fields :c:member:`~PyTypeObject.tp_traverse` and :c:member:`~PyTypeObject." -"tp_clear` are present in the type object." +"set, memory for new instances (see :c:member:`~PyTypeObject.tp_alloc`) must " +"be allocated using :c:macro:`PyObject_GC_New` or :c:func:" +"`PyType_GenericAlloc` and deallocated (see :c:member:`~PyTypeObject." +"tp_free`) using :c:func:`PyObject_GC_Del`. More information in section :ref:" +"`supporting-cycle-detection`." msgstr "" -#: ../../c-api/typeobj.rst:1143 ../../c-api/typeobj.rst:1484 -#: ../../c-api/typeobj.rst:1558 +#: ../../c-api/typeobj.rst:1231 ../../c-api/typeobj.rst:1582 +#: ../../c-api/typeobj.rst:1728 msgid "" "Group: :c:macro:`Py_TPFLAGS_HAVE_GC`, :c:member:`~PyTypeObject." "tp_traverse`, :c:member:`~PyTypeObject.tp_clear`" msgstr "" -#: ../../c-api/typeobj.rst:1145 +#: ../../c-api/typeobj.rst:1233 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` " @@ -2150,199 +2298,204 @@ msgid "" "values." msgstr "" -#: ../../c-api/typeobj.rst:1155 +#: ../../c-api/typeobj.rst:1243 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:1166 +#: ../../c-api/typeobj.rst:1254 msgid "This bit indicates that objects behave like unbound methods." msgstr "" -#: ../../c-api/typeobj.rst:1168 +#: ../../c-api/typeobj.rst:1256 msgid "If this flag is set for ``type(meth)``, then:" -msgstr "" +msgstr "如果此旗標為 ``type(meth)`` 所設定,則:" -#: ../../c-api/typeobj.rst:1170 +#: ../../c-api/typeobj.rst:1258 msgid "" "``meth.__get__(obj, cls)(*args, **kwds)`` (with ``obj`` not None) must be " "equivalent to ``meth(obj, *args, **kwds)``." msgstr "" +"``meth.__get__(obj, cls)(*args, **kwds)``\\(其中 ``obj`` 並非 None)必須等價" +"於 ``meth(obj, *args, **kwds)``。" -#: ../../c-api/typeobj.rst:1173 +#: ../../c-api/typeobj.rst:1261 msgid "" "``meth.__get__(None, cls)(*args, **kwds)`` must be equivalent to " "``meth(*args, **kwds)``." msgstr "" +"``meth.__get__(None, cls)(*args, **kwds)`` 必須等價於 ``meth(*args, " +"**kwds)``。" -#: ../../c-api/typeobj.rst:1176 +#: ../../c-api/typeobj.rst:1264 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:1184 +#: ../../c-api/typeobj.rst:1272 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:1190 +#: ../../c-api/typeobj.rst:1278 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:1193 +#: ../../c-api/typeobj.rst:1281 msgid "If this flag is set, :c:macro:`Py_TPFLAGS_HAVE_GC` should also be set." -msgstr "" +msgstr "如果有設定此旗標,則也應該設定 :c:macro:`Py_TPFLAGS_HAVE_GC`。" -#: ../../c-api/typeobj.rst:1195 +#: ../../c-api/typeobj.rst:1283 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:1202 +#: ../../c-api/typeobj.rst:1290 msgid "" "This flag is inherited unless the :c:member:`~PyTypeObject.tp_dictoffset` " "field is set in a superclass." msgstr "" -#: ../../c-api/typeobj.rst:1208 +#: ../../c-api/typeobj.rst:1296 msgid "" "This bit indicates that instances of the class should be weakly " "referenceable." msgstr "" -#: ../../c-api/typeobj.rst:1215 +#: ../../c-api/typeobj.rst:1303 msgid "" "This flag is inherited unless the :c:member:`~PyTypeObject." "tp_weaklistoffset` field is set in a superclass." msgstr "" -#: ../../c-api/typeobj.rst:1221 +#: ../../c-api/typeobj.rst:1309 msgid "" "Only usable with variable-size types, i.e. ones with non-zero :c:member:" "`~PyTypeObject.tp_itemsize`." msgstr "" -#: ../../c-api/typeobj.rst:1224 +#: ../../c-api/typeobj.rst:1312 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:1229 +#: ../../c-api/typeobj.rst:1317 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:1237 +#: ../../c-api/typeobj.rst:1325 msgid "This flag is inherited." msgstr "" -#: ../../c-api/typeobj.rst:1251 +#: ../../c-api/typeobj.rst:1339 msgid "" -"These flags are used by functions such as :c:func:`PyLong_Check` to quickly " -"determine if a type is a subclass of a built-in type; such specific checks " -"are faster than a generic check, like :c:func:`PyObject_IsInstance`. Custom " -"types that inherit from built-ins should have their :c:member:`~PyTypeObject." -"tp_flags` set appropriately, or the code that interacts with such types will " -"behave differently depending on what kind of check is used." +"Functions such as :c:func:`PyLong_Check` will call :c:func:" +"`PyType_FastSubclass` with one of these flags to quickly determine if a type " +"is a subclass of a built-in type; such specific checks are faster than a " +"generic check, like :c:func:`PyObject_IsInstance`. Custom types that inherit " +"from built-ins should have their :c:member:`~PyTypeObject.tp_flags` set " +"appropriately, or the code that interacts with such types will behave " +"differently depending on what kind of check is used." msgstr "" -#: ../../c-api/typeobj.rst:1262 +#: ../../c-api/typeobj.rst:1350 msgid "" "This bit is set when the :c:member:`~PyTypeObject.tp_finalize` slot is " "present in the type structure." msgstr "" -#: ../../c-api/typeobj.rst:1267 +#: ../../c-api/typeobj.rst:1355 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:1275 +#: ../../c-api/typeobj.rst:1363 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:1281 +#: ../../c-api/typeobj.rst:1369 msgid "" "This bit is inherited if :c:member:`~PyTypeObject.tp_call` is also inherited." msgstr "" -#: ../../c-api/typeobj.rst:1288 +#: ../../c-api/typeobj.rst:1376 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:1291 +#: ../../c-api/typeobj.rst:1379 msgid "This flag can now be inherited by mutable classes." msgstr "" -#: ../../c-api/typeobj.rst:1295 +#: ../../c-api/typeobj.rst:1383 msgid "" "This bit is set for type objects that are immutable: type attributes cannot " "be set nor deleted." msgstr "" -#: ../../c-api/typeobj.rst:1297 +#: ../../c-api/typeobj.rst:1385 msgid "" ":c:func:`PyType_Ready` automatically applies this flag to :ref:`static types " "`." msgstr "" -#: ../../c-api/typeobj.rst:1302 +#: ../../c-api/typeobj.rst:1390 msgid "This flag is not inherited." msgstr "" -#: ../../c-api/typeobj.rst:1308 +#: ../../c-api/typeobj.rst:1396 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:1312 +#: ../../c-api/typeobj.rst:1400 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:1315 +#: ../../c-api/typeobj.rst:1403 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:1321 +#: ../../c-api/typeobj.rst:1409 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:1328 +#: ../../c-api/typeobj.rst:1416 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:1339 +#: ../../c-api/typeobj.rst:1427 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 " @@ -2350,23 +2503,23 @@ msgid "" "unset when registering :class:`collections.abc.Sequence`." msgstr "" -#: ../../c-api/typeobj.rst:1346 ../../c-api/typeobj.rst:1368 +#: ../../c-api/typeobj.rst:1434 ../../c-api/typeobj.rst:1456 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:1351 +#: ../../c-api/typeobj.rst:1439 msgid "" "This flag is inherited by types that do not already set :c:macro:" "`Py_TPFLAGS_SEQUENCE`." msgstr "" -#: ../../c-api/typeobj.rst:1354 ../../c-api/typeobj.rst:1376 +#: ../../c-api/typeobj.rst:1442 ../../c-api/typeobj.rst:1464 msgid ":pep:`634` -- Structural Pattern Matching: Specification" msgstr "" -#: ../../c-api/typeobj.rst:1361 +#: ../../c-api/typeobj.rst:1449 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 " @@ -2374,53 +2527,53 @@ msgid "" "unset when registering :class:`collections.abc.Mapping`." msgstr "" -#: ../../c-api/typeobj.rst:1373 +#: ../../c-api/typeobj.rst:1461 msgid "" "This flag is inherited by types that do not already set :c:macro:" "`Py_TPFLAGS_MAPPING`." msgstr "" -#: ../../c-api/typeobj.rst:1383 +#: ../../c-api/typeobj.rst:1471 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:1387 +#: ../../c-api/typeobj.rst:1475 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:1393 +#: ../../c-api/typeobj.rst:1483 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:1399 +#: ../../c-api/typeobj.rst:1489 msgid "This field is *not* inherited by subtypes." -msgstr "" +msgstr "此欄位不會被子型別繼承。" -#: ../../c-api/typeobj.rst:1404 +#: ../../c-api/typeobj.rst:1496 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:1407 +#: ../../c-api/typeobj.rst:1499 msgid "int tp_traverse(PyObject *self, visitproc visit, void *arg);" msgstr "int tp_traverse(PyObject *self, visitproc visit, void *arg);" -#: ../../c-api/typeobj.rst:1409 ../../c-api/typeobj.rst:1553 +#: ../../c-api/typeobj.rst:1501 ../../c-api/typeobj.rst:1723 msgid "" "More information about Python's garbage collection scheme can be found in " "section :ref:`supporting-cycle-detection`." msgstr "" -#: ../../c-api/typeobj.rst:1412 +#: ../../c-api/typeobj.rst:1504 msgid "" "The :c:member:`~PyTypeObject.tp_traverse` pointer is used by the garbage " "collector to detect reference cycles. A typical implementation of a :c:" @@ -2430,11 +2583,12 @@ msgid "" "`!_thread` extension module::" msgstr "" -#: ../../c-api/typeobj.rst:1418 +#: ../../c-api/typeobj.rst:1510 msgid "" "static int\n" -"local_traverse(localobject *self, visitproc visit, void *arg)\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" @@ -2442,15 +2596,16 @@ msgid "" "}" msgstr "" "static int\n" -"local_traverse(localobject *self, visitproc visit, void *arg)\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:1427 +#: ../../c-api/typeobj.rst:1520 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`` " @@ -2458,29 +2613,29 @@ msgid "" "part of a reference cycle." msgstr "" -#: ../../c-api/typeobj.rst:1431 +#: ../../c-api/typeobj.rst:1524 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:1435 +#: ../../c-api/typeobj.rst:1528 msgid "" "Heap types (:c:macro:`Py_TPFLAGS_HEAPTYPE`) must visit their type with::" msgstr "" -#: ../../c-api/typeobj.rst:1437 +#: ../../c-api/typeobj.rst:1530 msgid "Py_VISIT(Py_TYPE(self));" msgstr "Py_VISIT(Py_TYPE(self));" -#: ../../c-api/typeobj.rst:1439 +#: ../../c-api/typeobj.rst:1532 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:1442 +#: ../../c-api/typeobj.rst:1535 msgid "" "#if PY_VERSION_HEX >= 0x03090000\n" " Py_VISIT(Py_TYPE(self));\n" @@ -2490,18 +2645,18 @@ msgstr "" " Py_VISIT(Py_TYPE(self));\n" "#endif" -#: ../../c-api/typeobj.rst:1446 +#: ../../c-api/typeobj.rst:1539 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:1450 +#: ../../c-api/typeobj.rst:1543 msgid "PyObject_VisitManagedDict((PyObject*)self, visit, arg);" msgstr "PyObject_VisitManagedDict((PyObject*)self, visit, arg);" -#: ../../c-api/typeobj.rst:1453 +#: ../../c-api/typeobj.rst:1546 msgid "" "When implementing :c:member:`~PyTypeObject.tp_traverse`, only the members " "that the instance *owns* (by having :term:`strong references ` hold a reference to " "their type. Their traversal function must therefore either visit :c:func:" @@ -2530,14 +2685,20 @@ msgid "" "superclass). If they do not, the type object may not be garbage-collected." msgstr "" -#: ../../c-api/typeobj.rst:1477 +#: ../../c-api/typeobj.rst:1570 +msgid "" +"The :c:member:`~PyTypeObject.tp_traverse` function can be called from any " +"thread." +msgstr ":c:member:`~PyTypeObject.tp_traverse` 函式可以從任何執行緒呼叫。" + +#: ../../c-api/typeobj.rst:1575 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:1486 +#: ../../c-api/typeobj.rst:1584 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:" @@ -2545,33 +2706,161 @@ msgid "" "are all inherited from the base type if they are all zero in the subtype." msgstr "" -#: ../../c-api/typeobj.rst:1494 -msgid "" -"An optional pointer to a clear function for the garbage collector. This is " -"only used if the :c:macro:`Py_TPFLAGS_HAVE_GC` flag bit is set. The " -"signature is::" +#: ../../c-api/typeobj.rst:1594 +msgid "An optional pointer to a clear function. The signature is::" msgstr "" -#: ../../c-api/typeobj.rst:1497 +#: ../../c-api/typeobj.rst:1596 msgid "int tp_clear(PyObject *);" msgstr "int tp_clear(PyObject *);" -#: ../../c-api/typeobj.rst:1499 +#: ../../c-api/typeobj.rst:1598 +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 " +"cleared object is a partially destroyed object; the object is not obligated " +"to satisfy design invariants held during normal use." +msgstr "" + +#: ../../c-api/typeobj.rst:1603 +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 " +"integers. However, it may be convenient to clear all references, and write " +"the type's :c:member:`~PyTypeObject.tp_dealloc` function to invoke :c:member:" +"`!tp_clear` to avoid code duplication. (Beware that :c:member:`!tp_clear` " +"might have already been called. Prefer calling idempotent functions like :c:" +"func:`Py_CLEAR`.)" +msgstr "" + +#: ../../c-api/typeobj.rst:1611 +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:1616 +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:1622 +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:1627 +msgid "" +"The :c:member:`~PyTypeObject.tp_clear` function can be called from any " +"thread." +msgstr ":c:member:`~PyTypeObject.tp_clear` 函式可以從任何執行緒呼叫。" + +#: ../../c-api/typeobj.rst:1632 +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:1635 +msgid "" +"This function differs from the destructor (:c:member:`~PyTypeObject." +"tp_dealloc`) in the following ways:" +msgstr "" + +#: ../../c-api/typeobj.rst:1638 +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, " +"on the other hand, is a superset: it must release *all* resources it owns, " +"including references to objects that cannot participate in a reference cycle " +"(e.g., integers) as well as the object's own memory (by calling :c:member:" +"`~PyTypeObject.tp_free`)." +msgstr "" + +#: ../../c-api/typeobj.rst:1644 +msgid "" +"When :c:member:`!tp_clear` is called, other objects might still hold " +"references to the object being cleared. Because of this, :c:member:`!" +"tp_clear` must not deallocate the object's own memory (:c:member:" +"`~PyTypeObject.tp_free`). The destructor, on the other hand, is only called " +"when no (strong) references exist, and as such, must safely destroy the " +"object itself by deallocating it." +msgstr "" + +#: ../../c-api/typeobj.rst:1650 +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 " +"the object becomes unreachable (i.e., either there are no references to the " +"object or the object is a member of a :term:`cyclic isolate`)." +msgstr "" + +#: ../../c-api/typeobj.rst:1655 +msgid "" +"No guarantees are made about when, if, or how often Python automatically " +"clears an object, except:" +msgstr "" + +#: ../../c-api/typeobj.rst:1658 msgid "" -"The :c:member:`~PyTypeObject.tp_clear` member function is used to break " -"reference cycles in cyclic garbage detected by the garbage collector. Taken " -"together, all :c:member:`~PyTypeObject.tp_clear` functions in the system " -"must combine to break all reference cycles. This is subtle, and if in any " -"doubt supply a :c:member:`~PyTypeObject.tp_clear` function. For example, " -"the tuple type does not implement a :c:member:`~PyTypeObject.tp_clear` " -"function, because it's possible to prove that no reference cycle can be " -"composed entirely of tuples. Therefore the :c:member:`~PyTypeObject." -"tp_clear` functions of other types must be sufficient to break any cycle " +"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:1661 +msgid "" +"Python will not automatically clear an object if it has not been " +"automatically finalized (see :c:member:`~PyTypeObject.tp_finalize`). (If " +"the finalizer resurrected the object, the object may or may not be " +"automatically finalized again before it is cleared.)" +msgstr "" + +#: ../../c-api/typeobj.rst:1665 +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:1668 +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 " +"breaking a reference cycle does not invalidate the ``self`` pointer while :c:" +"member:`!tp_clear` is still executing." +msgstr "" + +#: ../../c-api/typeobj.rst:1672 +msgid "" +"Python will not automatically call :c:member:`!tp_clear` multiple times " +"concurrently." +msgstr "" + +#: ../../c-api/typeobj.rst:1675 +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:1679 +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 " +"in any doubt supply a :c:member:`~PyTypeObject.tp_clear` function. For " +"example, the tuple type does not implement a :c:member:`~PyTypeObject." +"tp_clear` function, because it's possible to prove that no reference cycle " +"can be composed entirely of tuples. Therefore the :c:member:`~PyTypeObject." +"tp_clear` functions of other types are responsible for breaking any cycle " "containing a tuple. This isn't immediately obvious, and there's rarely a " "good reason to avoid implementing :c:member:`~PyTypeObject.tp_clear`." msgstr "" -#: ../../c-api/typeobj.rst:1509 +#: ../../c-api/typeobj.rst:1690 msgid "" "Implementations of :c:member:`~PyTypeObject.tp_clear` should drop the " "instance's references to those of its members that may be Python objects, " @@ -2579,11 +2868,12 @@ msgid "" "example::" msgstr "" -#: ../../c-api/typeobj.rst:1513 +#: ../../c-api/typeobj.rst:1694 msgid "" "static int\n" -"local_clear(localobject *self)\n" +"local_clear(PyObject *op)\n" "{\n" +" localobject *self = (localobject *) op;\n" " Py_CLEAR(self->key);\n" " Py_CLEAR(self->args);\n" " Py_CLEAR(self->kw);\n" @@ -2592,8 +2882,9 @@ msgid "" "}" msgstr "" "static int\n" -"local_clear(localobject *self)\n" +"local_clear(PyObject *op)\n" "{\n" +" localobject *self = (localobject *) op;\n" " Py_CLEAR(self->key);\n" " Py_CLEAR(self->args);\n" " Py_CLEAR(self->kw);\n" @@ -2601,7 +2892,7 @@ msgstr "" " return 0;\n" "}" -#: ../../c-api/typeobj.rst:1523 +#: ../../c-api/typeobj.rst:1705 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 :" @@ -2616,36 +2907,18 @@ msgid "" "performs the operations in a safe order." msgstr "" -#: ../../c-api/typeobj.rst:1535 +#: ../../c-api/typeobj.rst:1717 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:" +"`~PyTypeObject.tp_flags` field, the clear function must call :c:func:" "`PyObject_ClearManagedDict` like this::" msgstr "" -#: ../../c-api/typeobj.rst:1539 +#: ../../c-api/typeobj.rst:1721 msgid "PyObject_ClearManagedDict((PyObject*)self);" msgstr "PyObject_ClearManagedDict((PyObject*)self);" -#: ../../c-api/typeobj.rst:1541 -msgid "" -"Note that :c:member:`~PyTypeObject.tp_clear` is not *always* called before " -"an instance 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:`~PyTypeObject.tp_dealloc` is called directly." -msgstr "" - -#: ../../c-api/typeobj.rst:1547 -msgid "" -"Because the goal of :c:member:`~PyTypeObject.tp_clear` functions is to break " -"reference cycles, it's not necessary to clear contained objects like Python " -"strings or Python integers, which can't participate in reference cycles. On " -"the other hand, it may be convenient to clear all contained Python objects, " -"and write the type's :c:member:`~PyTypeObject.tp_dealloc` function to " -"invoke :c:member:`~PyTypeObject.tp_clear`." -msgstr "" - -#: ../../c-api/typeobj.rst:1560 +#: ../../c-api/typeobj.rst:1730 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, :" @@ -2653,22 +2926,22 @@ msgid "" "are all inherited from the base type if they are all zero in the subtype." msgstr "" -#: ../../c-api/typeobj.rst:1568 +#: ../../c-api/typeobj.rst:1744 msgid "" "An optional pointer to the rich comparison function, whose signature is::" msgstr "" -#: ../../c-api/typeobj.rst:1570 +#: ../../c-api/typeobj.rst:1746 msgid "PyObject *tp_richcompare(PyObject *self, PyObject *other, int op);" msgstr "PyObject *tp_richcompare(PyObject *self, PyObject *other, int op);" -#: ../../c-api/typeobj.rst:1572 +#: ../../c-api/typeobj.rst:1748 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:1575 +#: ../../c-api/typeobj.rst:1751 msgid "" "The function should return the result of the comparison (usually ``Py_True`` " "or ``Py_False``). If the comparison is undefined, it must return " @@ -2676,50 +2949,50 @@ msgid "" "set an exception condition." msgstr "" -#: ../../c-api/typeobj.rst:1580 +#: ../../c-api/typeobj.rst:1756 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:1586 +#: ../../c-api/typeobj.rst:1762 msgid "Constant" msgstr "常數" -#: ../../c-api/typeobj.rst:1586 +#: ../../c-api/typeobj.rst:1762 msgid "Comparison" msgstr "" -#: ../../c-api/typeobj.rst:1588 +#: ../../c-api/typeobj.rst:1764 msgid "``<``" msgstr "``<``" -#: ../../c-api/typeobj.rst:1590 +#: ../../c-api/typeobj.rst:1766 msgid "``<=``" msgstr "``<=``" -#: ../../c-api/typeobj.rst:1592 +#: ../../c-api/typeobj.rst:1768 msgid "``==``" msgstr "``==``" -#: ../../c-api/typeobj.rst:1594 +#: ../../c-api/typeobj.rst:1770 msgid "``!=``" msgstr "``!=``" -#: ../../c-api/typeobj.rst:1596 +#: ../../c-api/typeobj.rst:1772 msgid "``>``" msgstr "``>``" -#: ../../c-api/typeobj.rst:1598 +#: ../../c-api/typeobj.rst:1774 msgid "``>=``" msgstr "``>=``" -#: ../../c-api/typeobj.rst:1601 +#: ../../c-api/typeobj.rst:1777 msgid "" "The following macro is defined to ease writing rich comparison functions:" msgstr "" -#: ../../c-api/typeobj.rst:1605 +#: ../../c-api/typeobj.rst:1781 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 " @@ -2727,15 +3000,15 @@ msgid "" "specifies the requested operation, as for :c:func:`PyObject_RichCompare`." msgstr "" -#: ../../c-api/typeobj.rst:1611 +#: ../../c-api/typeobj.rst:1787 msgid "The returned value is a new :term:`strong reference`." msgstr "" -#: ../../c-api/typeobj.rst:1613 +#: ../../c-api/typeobj.rst:1789 msgid "On error, sets an exception and returns ``NULL`` from the function." msgstr "" -#: ../../c-api/typeobj.rst:1621 +#: ../../c-api/typeobj.rst:1797 msgid "" "This field is inherited by subtypes together with :c:member:`~PyTypeObject." "tp_hash`: a subtype inherits :c:member:`~PyTypeObject.tp_richcompare` and :c:" @@ -2743,7 +3016,7 @@ msgid "" "tp_richcompare` and :c:member:`~PyTypeObject.tp_hash` are both ``NULL``." msgstr "" -#: ../../c-api/typeobj.rst:1628 +#: ../../c-api/typeobj.rst:1804 msgid "" ":c:data:`PyBaseObject_Type` provides a :c:member:`~PyTypeObject." "tp_richcompare` implementation, which may be inherited. However, if only :c:" @@ -2752,13 +3025,13 @@ msgid "" "comparisons." msgstr "" -#: ../../c-api/typeobj.rst:1637 +#: ../../c-api/typeobj.rst:1813 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:1640 +#: ../../c-api/typeobj.rst:1816 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 " @@ -2768,19 +3041,19 @@ msgid "" "`PyObject*` which is initialized to ``NULL``." msgstr "" -#: ../../c-api/typeobj.rst:1647 +#: ../../c-api/typeobj.rst:1823 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:1650 +#: ../../c-api/typeobj.rst:1826 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:1655 +#: ../../c-api/typeobj.rst:1831 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 " @@ -2789,7 +3062,7 @@ msgid "" "not be a problem." msgstr "" -#: ../../c-api/typeobj.rst:1662 +#: ../../c-api/typeobj.rst:1838 msgid "" "If the :c:macro:`Py_TPFLAGS_MANAGED_WEAKREF` bit is set in the :c:member:" "`~PyTypeObject.tp_flags` field, then :c:member:`~PyTypeObject." @@ -2797,32 +3070,32 @@ msgid "" "unsafe to use this field." msgstr "" -#: ../../c-api/typeobj.rst:1670 +#: ../../c-api/typeobj.rst:1848 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:1674 +#: ../../c-api/typeobj.rst:1852 msgid "This function has the same signature as :c:func:`PyObject_GetIter`::" msgstr "" -#: ../../c-api/typeobj.rst:1676 +#: ../../c-api/typeobj.rst:1854 msgid "PyObject *tp_iter(PyObject *self);" msgstr "PyObject *tp_iter(PyObject *self);" -#: ../../c-api/typeobj.rst:1685 +#: ../../c-api/typeobj.rst:1865 msgid "" "An optional pointer to a function that returns the next item in an :term:" "`iterator`. The signature is::" msgstr "" -#: ../../c-api/typeobj.rst:1688 +#: ../../c-api/typeobj.rst:1868 msgid "PyObject *tp_iternext(PyObject *self);" msgstr "PyObject *tp_iternext(PyObject *self);" -#: ../../c-api/typeobj.rst:1690 +#: ../../c-api/typeobj.rst:1870 msgid "" "When the iterator is exhausted, it must return ``NULL``; a :exc:" "`StopIteration` exception may or may not be set. When another error occurs, " @@ -2830,74 +3103,74 @@ msgid "" "this type are iterators." msgstr "" -#: ../../c-api/typeobj.rst:1695 +#: ../../c-api/typeobj.rst:1875 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:1699 +#: ../../c-api/typeobj.rst:1879 msgid "This function has the same signature as :c:func:`PyIter_Next`." msgstr "" -#: ../../c-api/typeobj.rst:1708 +#: ../../c-api/typeobj.rst:1890 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:1711 +#: ../../c-api/typeobj.rst:1893 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:1716 +#: ../../c-api/typeobj.rst:1898 msgid "" "This field is not inherited by subtypes (methods are inherited through a " "different mechanism)." msgstr "" -#: ../../c-api/typeobj.rst:1722 +#: ../../c-api/typeobj.rst:1906 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:1726 +#: ../../c-api/typeobj.rst:1910 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:1731 +#: ../../c-api/typeobj.rst:1915 msgid "" "This field is not inherited by subtypes (members are inherited through a " "different mechanism)." msgstr "" -#: ../../c-api/typeobj.rst:1737 +#: ../../c-api/typeobj.rst:1923 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:1740 +#: ../../c-api/typeobj.rst:1926 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:1745 +#: ../../c-api/typeobj.rst:1931 msgid "" "This field is not inherited by subtypes (computed attributes are inherited " "through a different mechanism)." msgstr "" -#: ../../c-api/typeobj.rst:1751 +#: ../../c-api/typeobj.rst:1939 msgid "" "An optional pointer to a base type from which type properties are " "inherited. At this level, only single inheritance is supported; multiple " @@ -2905,7 +3178,7 @@ msgid "" "metatype." msgstr "" -#: ../../c-api/typeobj.rst:1759 +#: ../../c-api/typeobj.rst:1947 msgid "" "Slot initialization is subject to the rules of initializing globals. C99 " "requires the initializers to be \"address constants\". Function designators " @@ -2913,7 +3186,7 @@ msgid "" "valid C99 address constants." msgstr "" -#: ../../c-api/typeobj.rst:1764 +#: ../../c-api/typeobj.rst:1952 msgid "" "However, the unary '&' operator applied to a non-static variable like :c:" "data:`PyBaseObject_Type` is not required to produce an address constant. " @@ -2921,27 +3194,27 @@ msgid "" "strictly standard conforming in this particular behavior." msgstr "" -#: ../../c-api/typeobj.rst:1770 +#: ../../c-api/typeobj.rst:1958 msgid "" "Consequently, :c:member:`~PyTypeObject.tp_base` should be set in the " "extension module's init function." msgstr "" -#: ../../c-api/typeobj.rst:1775 +#: ../../c-api/typeobj.rst:1963 msgid "This field is not inherited by subtypes (obviously)." msgstr "" -#: ../../c-api/typeobj.rst:1779 +#: ../../c-api/typeobj.rst:1967 msgid "" "This field defaults to ``&PyBaseObject_Type`` (which to Python programmers " "is known as the type :class:`object`)." msgstr "" -#: ../../c-api/typeobj.rst:1785 +#: ../../c-api/typeobj.rst:1973 msgid "The type's dictionary is stored here by :c:func:`PyType_Ready`." msgstr "" -#: ../../c-api/typeobj.rst:1787 +#: ../../c-api/typeobj.rst:1975 msgid "" "This field should normally be initialized to ``NULL`` before PyType_Ready is " "called; it may also be initialized to a dictionary containing initial " @@ -2952,73 +3225,73 @@ msgid "" "be treated as read-only." msgstr "" -#: ../../c-api/typeobj.rst:1795 +#: ../../c-api/typeobj.rst:1983 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:1801 +#: ../../c-api/typeobj.rst:1989 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:1807 +#: ../../c-api/typeobj.rst:1995 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:1812 +#: ../../c-api/typeobj.rst:2000 msgid "" "If this field is ``NULL``, :c:func:`PyType_Ready` will assign a new " "dictionary to it." msgstr "" -#: ../../c-api/typeobj.rst:1817 +#: ../../c-api/typeobj.rst:2005 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:1823 +#: ../../c-api/typeobj.rst:2013 msgid "An optional pointer to a \"descriptor get\" function." msgstr "" -#: ../../c-api/typeobj.rst:1825 ../../c-api/typeobj.rst:1841 -#: ../../c-api/typeobj.rst:1905 ../../c-api/typeobj.rst:1935 -#: ../../c-api/typeobj.rst:1959 +#: ../../c-api/typeobj.rst:2015 ../../c-api/typeobj.rst:2033 +#: ../../c-api/typeobj.rst:2099 ../../c-api/typeobj.rst:2131 +#: ../../c-api/typeobj.rst:2156 msgid "The function signature is::" msgstr "" -#: ../../c-api/typeobj.rst:1827 +#: ../../c-api/typeobj.rst:2017 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:1838 +#: ../../c-api/typeobj.rst:2030 msgid "" "An optional pointer to a function for setting and deleting a descriptor's " "value." msgstr "" -#: ../../c-api/typeobj.rst:1843 +#: ../../c-api/typeobj.rst:2035 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:1845 +#: ../../c-api/typeobj.rst:2037 msgid "The *value* argument is set to ``NULL`` to delete the value." msgstr "" -#: ../../c-api/typeobj.rst:1856 +#: ../../c-api/typeobj.rst:2048 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:1859 +#: ../../c-api/typeobj.rst:2051 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 " @@ -3026,19 +3299,19 @@ msgid "" "func:`PyObject_GenericGetAttr`." msgstr "" -#: ../../c-api/typeobj.rst:1864 +#: ../../c-api/typeobj.rst:2056 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:1867 +#: ../../c-api/typeobj.rst:2059 msgid "" "The value specifies the offset of the dictionary from the start of the " "instance structure." msgstr "" -#: ../../c-api/typeobj.rst:1869 +#: ../../c-api/typeobj.rst:2061 msgid "" "The :c:member:`~PyTypeObject.tp_dictoffset` should be regarded as write-" "only. To get the pointer to the dictionary call :c:func:" @@ -3047,13 +3320,13 @@ msgid "" "to call :c:func:`PyObject_GetAttr` when accessing an attribute on the object." msgstr "" -#: ../../c-api/typeobj.rst:1875 +#: ../../c-api/typeobj.rst:2067 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:1880 +#: ../../c-api/typeobj.rst:2072 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 " @@ -3061,25 +3334,25 @@ msgid "" "`Py_TPFLAGS_MANAGED_DICT`." msgstr "" -#: ../../c-api/typeobj.rst:1887 +#: ../../c-api/typeobj.rst:2079 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:1890 +#: ../../c-api/typeobj.rst:2082 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:1898 +#: ../../c-api/typeobj.rst:2092 msgid "An optional pointer to an instance initialization function." msgstr "" -#: ../../c-api/typeobj.rst:1900 +#: ../../c-api/typeobj.rst:2094 msgid "" "This function corresponds to the :meth:`~object.__init__` method of " "classes. Like :meth:`!__init__`, it is possible to create an instance " @@ -3087,18 +3360,18 @@ msgid "" "instance by calling its :meth:`!__init__` method again." msgstr "" -#: ../../c-api/typeobj.rst:1907 +#: ../../c-api/typeobj.rst:2101 msgid "int tp_init(PyObject *self, PyObject *args, PyObject *kwds);" msgstr "int tp_init(PyObject *self, PyObject *args, PyObject *kwds);" -#: ../../c-api/typeobj.rst:1909 +#: ../../c-api/typeobj.rst:2103 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:1913 +#: ../../c-api/typeobj.rst:2107 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 :" @@ -3110,53 +3383,53 @@ msgid "" "subtype's :c:member:`~PyTypeObject.tp_init` is called." msgstr "" -#: ../../c-api/typeobj.rst:1920 +#: ../../c-api/typeobj.rst:2114 msgid "Returns ``0`` on success, ``-1`` and sets an exception on error." msgstr "" -#: ../../c-api/typeobj.rst:1928 +#: ../../c-api/typeobj.rst:2122 msgid "" "For :ref:`static types ` this field does not have a default." msgstr "" -#: ../../c-api/typeobj.rst:1933 +#: ../../c-api/typeobj.rst:2129 msgid "An optional pointer to an instance allocation function." msgstr "" -#: ../../c-api/typeobj.rst:1937 +#: ../../c-api/typeobj.rst:2133 msgid "PyObject *tp_alloc(PyTypeObject *self, Py_ssize_t nitems);" msgstr "PyObject *tp_alloc(PyTypeObject *self, Py_ssize_t nitems);" -#: ../../c-api/typeobj.rst:1941 +#: ../../c-api/typeobj.rst:2137 msgid "" -"This field is inherited by static subtypes, but not by dynamic subtypes " -"(subtypes created by a class statement)." +"Static subtypes inherit this slot, which will be :c:func:" +"`PyType_GenericAlloc` if inherited from :class:`object`." msgstr "" -#: ../../c-api/typeobj.rst:1946 -msgid "" -"For dynamic subtypes, this field is always set to :c:func:" -"`PyType_GenericAlloc`, to force a standard heap allocation strategy." +#: ../../c-api/typeobj.rst:2140 ../../c-api/typeobj.rst:2211 +msgid ":ref:`Heap subtypes ` do not inherit this slot." msgstr "" -#: ../../c-api/typeobj.rst:1950 +#: ../../c-api/typeobj.rst:2144 msgid "" -"For static subtypes, :c:data:`PyBaseObject_Type` uses :c:func:" -"`PyType_GenericAlloc`. That is the recommended value for all statically " -"defined types." +"For heap subtypes, this field is always set to :c:func:`PyType_GenericAlloc`." +msgstr "" + +#: ../../c-api/typeobj.rst:2147 ../../c-api/typeobj.rst:2219 +msgid "For static subtypes, this slot is inherited (see above)." msgstr "" -#: ../../c-api/typeobj.rst:1957 +#: ../../c-api/typeobj.rst:2154 msgid "An optional pointer to an instance creation function." msgstr "" -#: ../../c-api/typeobj.rst:1961 +#: ../../c-api/typeobj.rst:2158 msgid "" "PyObject *tp_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds);" msgstr "" "PyObject *tp_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds);" -#: ../../c-api/typeobj.rst:1963 +#: ../../c-api/typeobj.rst:2160 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 " @@ -3165,7 +3438,7 @@ msgid "" "that type (but not an unrelated type)." msgstr "" -#: ../../c-api/typeobj.rst:1969 +#: ../../c-api/typeobj.rst:2166 msgid "" "The :c:member:`~PyTypeObject.tp_new` function should call ``subtype-" ">tp_alloc(subtype, nitems)`` to allocate space for the object, and then do " @@ -3177,20 +3450,20 @@ msgid "" "be deferred to :c:member:`~PyTypeObject.tp_init`." msgstr "" -#: ../../c-api/typeobj.rst:1977 +#: ../../c-api/typeobj.rst:2174 msgid "" "Set the :c:macro:`Py_TPFLAGS_DISALLOW_INSTANTIATION` flag to disallow " "creating instances of the type in Python." msgstr "" -#: ../../c-api/typeobj.rst:1982 +#: ../../c-api/typeobj.rst:2179 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:1988 +#: ../../c-api/typeobj.rst:2185 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 " @@ -3198,44 +3471,42 @@ msgid "" "factory function." msgstr "" -#: ../../c-api/typeobj.rst:1996 +#: ../../c-api/typeobj.rst:2195 msgid "" "An optional pointer to an instance deallocation function. Its signature is::" msgstr "" -#: ../../c-api/typeobj.rst:1998 +#: ../../c-api/typeobj.rst:2197 msgid "void tp_free(void *self);" msgstr "void tp_free(void *self);" -#: ../../c-api/typeobj.rst:2000 -msgid "" -"An initializer that is compatible with this signature is :c:func:" -"`PyObject_Free`." -msgstr "" - -#: ../../c-api/typeobj.rst:2004 +#: ../../c-api/typeobj.rst:2199 msgid "" -"This field is inherited by static subtypes, but not by dynamic subtypes " -"(subtypes created by a class statement)" +"This function must free the memory allocated by :c:member:`~PyTypeObject." +"tp_alloc`." msgstr "" -#: ../../c-api/typeobj.rst:2009 +#: ../../c-api/typeobj.rst:2204 msgid "" -"In dynamic subtypes, this field is set to a deallocator suitable to match :c:" -"func:`PyType_GenericAlloc` and the value of the :c:macro:" -"`Py_TPFLAGS_HAVE_GC` flag bit." +"Static subtypes inherit this slot, which will be :c:func:`PyObject_Free` if " +"inherited from :class:`object`. Exception: If the type supports garbage " +"collection (i.e., the :c:macro:`Py_TPFLAGS_HAVE_GC` flag is set in :c:member:" +"`~PyTypeObject.tp_flags`) and it would inherit :c:func:`PyObject_Free`, then " +"this slot is not inherited but instead defaults to :c:func:`PyObject_GC_Del`." msgstr "" -#: ../../c-api/typeobj.rst:2013 +#: ../../c-api/typeobj.rst:2215 msgid "" -"For static subtypes, :c:data:`PyBaseObject_Type` uses :c:func:`PyObject_Del`." +"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:2018 +#: ../../c-api/typeobj.rst:2226 msgid "An optional pointer to a function called by the garbage collector." msgstr "" -#: ../../c-api/typeobj.rst:2020 +#: ../../c-api/typeobj.rst:2228 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 " @@ -3247,93 +3518,93 @@ msgid "" "instance. The signature is::" msgstr "" -#: ../../c-api/typeobj.rst:2028 +#: ../../c-api/typeobj.rst:2236 msgid "int tp_is_gc(PyObject *self);" msgstr "int tp_is_gc(PyObject *self);" -#: ../../c-api/typeobj.rst:2030 +#: ../../c-api/typeobj.rst:2238 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:2040 +#: ../../c-api/typeobj.rst:2248 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:2046 +#: ../../c-api/typeobj.rst:2256 msgid "Tuple of base types." msgstr "" -#: ../../c-api/typeobj.rst:2048 ../../c-api/typeobj.rst:2072 +#: ../../c-api/typeobj.rst:2258 ../../c-api/typeobj.rst:2282 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:2051 +#: ../../c-api/typeobj.rst:2261 msgid "" -"For dynamically created classes, the ``Py_tp_bases`` :c:type:`slot " +"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." msgstr "" -#: ../../c-api/typeobj.rst:2058 +#: ../../c-api/typeobj.rst:2268 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:2064 ../../c-api/typeobj.rst:2087 -#: ../../c-api/typeobj.rst:2104 ../../c-api/typeobj.rst:2121 -#: ../../c-api/typeobj.rst:2135 +#: ../../c-api/typeobj.rst:2274 ../../c-api/typeobj.rst:2297 +#: ../../c-api/typeobj.rst:2314 ../../c-api/typeobj.rst:2331 +#: ../../c-api/typeobj.rst:2347 msgid "This field is not inherited." msgstr "" -#: ../../c-api/typeobj.rst:2069 +#: ../../c-api/typeobj.rst:2279 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:2077 +#: ../../c-api/typeobj.rst:2287 msgid "" "This field is not inherited; it is calculated fresh by :c:func:" "`PyType_Ready`." msgstr "" -#: ../../c-api/typeobj.rst:2083 +#: ../../c-api/typeobj.rst:2293 msgid "Unused. Internal use only." msgstr "" -#: ../../c-api/typeobj.rst:2092 +#: ../../c-api/typeobj.rst:2302 msgid "" "A collection of subclasses. Internal use only. May be an invalid pointer." msgstr "" -#: ../../c-api/typeobj.rst:2094 +#: ../../c-api/typeobj.rst:2304 msgid "" "To get a list of subclasses, call the Python method :py:meth:`~type." "__subclasses__`." msgstr "" -#: ../../c-api/typeobj.rst:2099 +#: ../../c-api/typeobj.rst:2309 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:2109 +#: ../../c-api/typeobj.rst:2319 msgid "" "Weak reference list head, for weak references to this type object. Not " "inherited. Internal use only." msgstr "" -#: ../../c-api/typeobj.rst:2114 +#: ../../c-api/typeobj.rst:2324 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 " @@ -3341,134 +3612,351 @@ msgid "" "``_PyObject_GET_WEAKREFS_LISTPTR()`` macro to avoid the distinction." msgstr "" -#: ../../c-api/typeobj.rst:2126 +#: ../../c-api/typeobj.rst:2338 msgid "" "This field is deprecated. Use :c:member:`~PyTypeObject.tp_finalize` instead." -msgstr "" +msgstr "此欄位已被棄用。請改用 :c:member:`~PyTypeObject.tp_finalize`。" -#: ../../c-api/typeobj.rst:2131 +#: ../../c-api/typeobj.rst:2343 msgid "Used to index into the method cache. Internal use only." msgstr "" -#: ../../c-api/typeobj.rst:2140 +#: ../../c-api/typeobj.rst:2354 msgid "" -"An optional pointer to an instance finalization function. Its signature is::" +"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:2142 +#: ../../c-api/typeobj.rst:2358 msgid "void tp_finalize(PyObject *self);" msgstr "void tp_finalize(PyObject *self);" -#: ../../c-api/typeobj.rst:2144 +#: ../../c-api/typeobj.rst:2360 msgid "" -"If :c:member:`~PyTypeObject.tp_finalize` is set, the interpreter calls it " -"once when finalizing an instance. It is called either from the garbage " -"collector (if the instance is part of an isolated reference cycle) or just " -"before the object is deallocated. Either way, it is guaranteed to be called " -"before attempting to break reference cycles, ensuring that it finds the " -"object in a sane state." +"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 " +"any other objects it directly or indirectly references are still in a " +"consistent state. The finalizer is allowed to execute arbitrary Python code." msgstr "" -#: ../../c-api/typeobj.rst:2151 +#: ../../c-api/typeobj.rst:2366 msgid "" -":c:member:`~PyTypeObject.tp_finalize` should not mutate the current " -"exception status; therefore, a recommended way to write a non-trivial " -"finalizer is::" +"Before Python automatically finalizes an object, some of the object's direct " +"or indirect referents might have themselves been automatically finalized. " +"However, none of the referents will have been automatically cleared (:c:" +"member:`~PyTypeObject.tp_clear`) yet." msgstr "" -#: ../../c-api/typeobj.rst:2154 +#: ../../c-api/typeobj.rst:2371 +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:2377 +msgid "" +"After Python automatically finalizes an object, Python might start " +"automatically clearing (:c:member:`~PyTypeObject.tp_clear`) the object and " +"its referents (direct and indirect). Cleared objects are not guaranteed to " +"be in a consistent state; a finalized object must be able to tolerate " +"cleared referents." +msgstr "" + +#: ../../c-api/typeobj.rst:2385 +msgid "" +"An object is not guaranteed to be automatically finalized before its " +"destructor (:c:member:`~PyTypeObject.tp_dealloc`) is called. 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:2393 +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:2398 +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:2402 +msgid "" +"When Python finalizes an object, it behaves like the following algorithm:" +msgstr "" + +#: ../../c-api/typeobj.rst:2404 +msgid "" +"Python might mark the object as *finalized*. Currently, Python always marks " +"objects whose type supports garbage collection (i.e., the :c:macro:" +"`Py_TPFLAGS_HAVE_GC` flag is set in :c:member:`~PyTypeObject.tp_flags`) and " +"never marks other types of objects; this might change in a future version." +msgstr "" + +#: ../../c-api/typeobj.rst:2409 +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:2412 +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 " +"of a :term:`cyclic isolate`), then the finalizer is said to have " +"*resurrected* the object. It is unspecified whether the finalizer can also " +"resurrect the object by adding a new reference to the object that does not " +"make it reachable, i.e., the object is (still) a member of a cyclic isolate." +msgstr "" + +#: ../../c-api/typeobj.rst:2419 +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. " +"Currently, Python never removes the *finalized* mark; this might change in a " +"future version." +msgstr "" + +#: ../../c-api/typeobj.rst:2424 +msgid "" +"*Automatic finalization* refers to any finalization performed by Python " +"except via calls to :c:func:`PyObject_CallFinalizer` or :c:func:" +"`PyObject_CallFinalizerFromDealloc`. No guarantees are made about when, if, " +"or how often an object is automatically finalized, except:" +msgstr "" + +#: ../../c-api/typeobj.rst:2429 +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:2432 +msgid "" +"Python will not automatically finalize an object if finalizing it would not " +"mark the object as *finalized*. Currently, this applies to objects whose " +"type does not support garbage collection, i.e., the :c:macro:" +"`Py_TPFLAGS_HAVE_GC` flag is not set. Such objects can still be manually " +"finalized by calling :c:func:`PyObject_CallFinalizer` or :c:func:" +"`PyObject_CallFinalizerFromDealloc`." +msgstr "" + +#: ../../c-api/typeobj.rst:2438 +msgid "" +"Python will not automatically finalize any two members of a :term:`cyclic " +"isolate` concurrently." +msgstr "" + +#: ../../c-api/typeobj.rst:2440 +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:2442 +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:2445 +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:2448 +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:2452 +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:2456 +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:2460 +msgid "" +":c:member:`~PyTypeObject.tp_finalize` should leave the current exception " +"status unchanged. The recommended way to write a non-trivial finalizer is " +"to back up the exception at the beginning by calling :c:func:" +"`PyErr_GetRaisedException` and restore the exception at the end by calling :" +"c:func:`PyErr_SetRaisedException`. If an exception is encountered in the " +"middle of the finalizer, log and clear it with :c:func:" +"`PyErr_WriteUnraisable` or :c:func:`PyErr_FormatUnraisable`. For example::" +msgstr "" + +#: ../../c-api/typeobj.rst:2469 msgid "" "static void\n" -"local_finalize(PyObject *self)\n" +"foo_finalize(PyObject *self)\n" "{\n" -" /* Save the current exception, if any. */\n" +" // Save the current exception, if any.\n" " PyObject *exc = PyErr_GetRaisedException();\n" "\n" -" /* ... */\n" +" // ...\n" +"\n" +" if (do_something_that_might_raise() != success_indicator) {\n" +" PyErr_WriteUnraisable(self);\n" +" goto done;\n" +" }\n" "\n" -" /* Restore the saved exception. */\n" +"done:\n" +" // Restore the saved exception. This silently discards any exception\n" +" // raised above, so be sure to call PyErr_WriteUnraisable first if\n" +" // necessary.\n" " PyErr_SetRaisedException(exc);\n" "}" msgstr "" -#: ../../c-api/typeobj.rst:2174 +#: ../../c-api/typeobj.rst:2497 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:2178 -msgid "\"Safe object finalization\" (:pep:`442`)" +#: ../../c-api/typeobj.rst:2503 +msgid ":pep:`442`: \"Safe object finalization\"" +msgstr "" + +#: ../../c-api/typeobj.rst:2506 +msgid ":c:func:`PyObject_CallFinalizer`" +msgstr ":c:func:`PyObject_CallFinalizer`" + +#: ../../c-api/typeobj.rst:2507 +msgid ":c:func:`PyObject_CallFinalizerFromDealloc`" +msgstr ":c:func:`PyObject_CallFinalizerFromDealloc`" + +#: ../../c-api/typeobj.rst:2514 +msgid "" +"A :ref:`vectorcall function ` to use for calls of this type " +"object (rather than instances). In other words, ``tp_vectorcall`` can be " +"used to optimize ``type.__call__``, which typically returns a new instance " +"of *type*." +msgstr "" + +#: ../../c-api/typeobj.rst:2519 +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:2524 +msgid "" +"The :ref:`vectorcall protocol ` requires that the vectorcall " +"function has the same behavior as the corresponding ``tp_call``. This means " +"that ``type->tp_vectorcall`` must match the behavior of ``Py_TYPE(type)-" +">tp_call``." +msgstr "" + +#: ../../c-api/typeobj.rst:2529 +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:2533 +msgid "calls ``type->tp_new``," +msgstr "呼叫 ``type->tp_new``," + +#: ../../c-api/typeobj.rst:2535 +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:2183 +#: ../../c-api/typeobj.rst:2538 +msgid "returns the result of ``tp_new``." +msgstr "回傳 ``tp_new`` 的結果。" + +#: ../../c-api/typeobj.rst:2540 msgid "" -"Vectorcall function to use for calls of this type object. In other words, it " -"is used to implement :ref:`vectorcall ` for ``type.__call__``. " -"If ``tp_vectorcall`` is ``NULL``, the default call implementation using :" -"meth:`~object.__new__` and :meth:`~object.__init__` is used." +"Typically, ``tp_vectorcall`` is overridden to optimize this process for " +"specific :c:member:`~PyTypeObject.tp_new` and :c:member:`~PyTypeObject." +"tp_init`. When doing this for user-subclassable types, note that both can be " +"overridden (using :py:func:`~object.__new__` and :py:func:`~object." +"__init__`, respectively)." msgstr "" -#: ../../c-api/typeobj.rst:2191 +#: ../../c-api/typeobj.rst:2551 msgid "This field is never inherited." msgstr "" -#: ../../c-api/typeobj.rst:2193 +#: ../../c-api/typeobj.rst:2553 msgid "(the field exists since 3.8 but it's only used since 3.9)" msgstr "" -#: ../../c-api/typeobj.rst:2198 +#: ../../c-api/typeobj.rst:2558 msgid "Internal. Do not use." msgstr "" -#: ../../c-api/typeobj.rst:2206 +#: ../../c-api/typeobj.rst:2566 msgid "Static Types" -msgstr "" +msgstr "靜態型別" -#: ../../c-api/typeobj.rst:2208 +#: ../../c-api/typeobj.rst:2568 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:2212 +#: ../../c-api/typeobj.rst:2572 msgid "" "This results in types that are limited relative to types defined in Python:" msgstr "" -#: ../../c-api/typeobj.rst:2214 +#: ../../c-api/typeobj.rst:2574 msgid "" "Static types are limited to one base, i.e. they cannot use multiple " "inheritance." msgstr "" -#: ../../c-api/typeobj.rst:2216 +#: ../../c-api/typeobj.rst:2576 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:2218 +#: ../../c-api/typeobj.rst:2578 msgid "" "Static type objects are shared across :ref:`sub-interpreters `, so they should not include any subinterpreter-" "specific state." msgstr "" -#: ../../c-api/typeobj.rst:2222 +#: ../../c-api/typeobj.rst:2582 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:2230 +#: ../../c-api/typeobj.rst:2590 msgid "Heap Types" -msgstr "" +msgstr "堆積型別" -#: ../../c-api/typeobj.rst:2232 +#: ../../c-api/typeobj.rst:2592 msgid "" "An alternative to :ref:`static types ` is *heap-allocated " "types*, or *heap types* for short, which correspond closely to classes " @@ -3476,29 +3964,29 @@ msgid "" "`Py_TPFLAGS_HEAPTYPE` flag set." msgstr "" -#: ../../c-api/typeobj.rst:2237 +#: ../../c-api/typeobj.rst:2597 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:2245 +#: ../../c-api/typeobj.rst:2605 msgid "Number Object Structures" msgstr "" -#: ../../c-api/typeobj.rst:2252 +#: ../../c-api/typeobj.rst:2612 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:2258 ../../c-api/typeobj.rst:2582 +#: ../../c-api/typeobj.rst:2618 ../../c-api/typeobj.rst:3074 msgid "Here is the structure definition::" msgstr "" -#: ../../c-api/typeobj.rst:2260 +#: ../../c-api/typeobj.rst:2620 msgid "" "typedef struct {\n" " binaryfunc nb_add;\n" @@ -3586,7 +4074,7 @@ msgstr "" " binaryfunc nb_inplace_matrix_multiply;\n" "} PyNumberMethods;" -#: ../../c-api/typeobj.rst:2305 +#: ../../c-api/typeobj.rst:2665 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 " @@ -3596,31 +4084,31 @@ msgid "" "and set an exception." msgstr "" -#: ../../c-api/typeobj.rst:2314 +#: ../../c-api/typeobj.rst:2674 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:2359 +#: ../../c-api/typeobj.rst:2825 msgid "Mapping Object Structures" -msgstr "" +msgstr "對映物件結構" -#: ../../c-api/typeobj.rst:2366 +#: ../../c-api/typeobj.rst:2832 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:2371 +#: ../../c-api/typeobj.rst:2839 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:2377 +#: ../../c-api/typeobj.rst:2847 msgid "" "This function is used by :c:func:`PyObject_GetItem` and :c:func:" "`PySequence_GetSlice`, and has the same signature as :c:func:`!" @@ -3628,7 +4116,7 @@ msgid "" "`PyMapping_Check` function to return ``1``, it can be ``NULL`` otherwise." msgstr "" -#: ../../c-api/typeobj.rst:2385 +#: ../../c-api/typeobj.rst:2857 msgid "" "This function is used by :c:func:`PyObject_SetItem`, :c:func:" "`PyObject_DelItem`, :c:func:`PySequence_SetSlice` and :c:func:" @@ -3638,17 +4126,17 @@ msgid "" "deletion." msgstr "" -#: ../../c-api/typeobj.rst:2396 +#: ../../c-api/typeobj.rst:2868 msgid "Sequence Object Structures" -msgstr "" +msgstr "序列物件結構" -#: ../../c-api/typeobj.rst:2403 +#: ../../c-api/typeobj.rst:2875 msgid "" "This structure holds pointers to the functions which an object uses to " "implement the sequence protocol." msgstr "" -#: ../../c-api/typeobj.rst:2408 +#: ../../c-api/typeobj.rst:2882 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 " @@ -3656,21 +4144,21 @@ msgid "" "member:`~PySequenceMethods.sq_ass_item` slots." msgstr "" -#: ../../c-api/typeobj.rst:2415 +#: ../../c-api/typeobj.rst:2891 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:2421 +#: ../../c-api/typeobj.rst:2899 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:2427 +#: ../../c-api/typeobj.rst:2907 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 " @@ -3679,7 +4167,7 @@ msgid "" "``1``, it can be ``NULL`` otherwise." msgstr "" -#: ../../c-api/typeobj.rst:2433 +#: ../../c-api/typeobj.rst:2913 msgid "" "Negative indexes are handled as follows: if the :c:member:" "`~PySequenceMethods.sq_length` slot is filled, it is called and the sequence " @@ -3688,7 +4176,7 @@ msgid "" "index is passed as is to the function." msgstr "" -#: ../../c-api/typeobj.rst:2440 +#: ../../c-api/typeobj.rst:2922 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:" @@ -3697,14 +4185,14 @@ msgid "" "``NULL`` if the object does not support item assignment and deletion." msgstr "" -#: ../../c-api/typeobj.rst:2449 +#: ../../c-api/typeobj.rst:2933 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:2456 +#: ../../c-api/typeobj.rst:2942 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 " @@ -3714,7 +4202,7 @@ msgid "" "c:member:`~PyNumberMethods.nb_inplace_add` slot." msgstr "" -#: ../../c-api/typeobj.rst:2465 +#: ../../c-api/typeobj.rst:2953 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 " @@ -3724,76 +4212,76 @@ msgid "" "via the :c:member:`~PyNumberMethods.nb_inplace_multiply` slot." msgstr "" -#: ../../c-api/typeobj.rst:2476 +#: ../../c-api/typeobj.rst:2964 msgid "Buffer Object Structures" -msgstr "" +msgstr "緩衝區物件結構" -#: ../../c-api/typeobj.rst:2484 +#: ../../c-api/typeobj.rst:2972 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:2490 ../../c-api/typeobj.rst:2539 -#: ../../c-api/typeobj.rst:2593 ../../c-api/typeobj.rst:2604 -#: ../../c-api/typeobj.rst:2616 ../../c-api/typeobj.rst:2626 +#: ../../c-api/typeobj.rst:2980 ../../c-api/typeobj.rst:3031 +#: ../../c-api/typeobj.rst:3087 ../../c-api/typeobj.rst:3100 +#: ../../c-api/typeobj.rst:3114 ../../c-api/typeobj.rst:3126 msgid "The signature of this function is::" -msgstr "" +msgstr "函式的簽名為: ::" -#: ../../c-api/typeobj.rst:2492 +#: ../../c-api/typeobj.rst:2982 msgid "int (PyObject *exporter, Py_buffer *view, int flags);" msgstr "int (PyObject *exporter, Py_buffer *view, int flags);" -#: ../../c-api/typeobj.rst:2494 +#: ../../c-api/typeobj.rst:2984 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:2498 +#: ../../c-api/typeobj.rst:2988 msgid "" "Check if the request can be met. If not, raise :exc:`BufferError`, set :c:" "expr:`view->obj` to ``NULL`` and return ``-1``." msgstr "" -#: ../../c-api/typeobj.rst:2501 +#: ../../c-api/typeobj.rst:2991 msgid "Fill in the requested fields." msgstr "" -#: ../../c-api/typeobj.rst:2503 +#: ../../c-api/typeobj.rst:2993 msgid "Increment an internal counter for the number of exports." msgstr "" -#: ../../c-api/typeobj.rst:2505 +#: ../../c-api/typeobj.rst:2995 msgid "" "Set :c:expr:`view->obj` to *exporter* and increment :c:expr:`view->obj`." msgstr "" -#: ../../c-api/typeobj.rst:2507 +#: ../../c-api/typeobj.rst:2997 msgid "Return ``0``." msgstr "回傳 ``0``。" -#: ../../c-api/typeobj.rst:2509 +#: ../../c-api/typeobj.rst:2999 msgid "" "If *exporter* is part of a chain or tree of buffer providers, two main " "schemes can be used:" msgstr "" -#: ../../c-api/typeobj.rst:2512 +#: ../../c-api/typeobj.rst:3002 msgid "" "Re-export: Each member of the tree acts as the exporting object and sets :c:" "expr:`view->obj` to a new reference to itself." msgstr "" -#: ../../c-api/typeobj.rst:2515 +#: ../../c-api/typeobj.rst:3005 msgid "" "Redirect: The buffer request is redirected to the root object of the tree. " "Here, :c:expr:`view->obj` will be a new reference to the root object." msgstr "" -#: ../../c-api/typeobj.rst:2519 +#: ../../c-api/typeobj.rst:3009 msgid "" "The individual fields of *view* are described in section :ref:`Buffer " "structure `, the rules how an exporter must react to " @@ -3801,7 +4289,7 @@ msgid "" "types>`." msgstr "" -#: ../../c-api/typeobj.rst:2524 +#: ../../c-api/typeobj.rst:3014 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:" @@ -3810,23 +4298,23 @@ msgid "" "internal` are read-only for the consumer." msgstr "" -#: ../../c-api/typeobj.rst:2531 +#: ../../c-api/typeobj.rst:3021 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:2534 +#: ../../c-api/typeobj.rst:3024 msgid "" ":c:func:`PyObject_GetBuffer` is the interface for the consumer that wraps " "this function." msgstr "" -#: ../../c-api/typeobj.rst:2541 +#: ../../c-api/typeobj.rst:3033 msgid "void (PyObject *exporter, Py_buffer *view);" msgstr "void (PyObject *exporter, Py_buffer *view);" -#: ../../c-api/typeobj.rst:2543 +#: ../../c-api/typeobj.rst:3035 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 " @@ -3834,15 +4322,15 @@ msgid "" "these optional steps:" msgstr "" -#: ../../c-api/typeobj.rst:2548 +#: ../../c-api/typeobj.rst:3040 msgid "Decrement an internal counter for the number of exports." msgstr "" -#: ../../c-api/typeobj.rst:2550 +#: ../../c-api/typeobj.rst:3042 msgid "If the counter is ``0``, free all memory associated with *view*." msgstr "" -#: ../../c-api/typeobj.rst:2552 +#: ../../c-api/typeobj.rst:3044 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 " @@ -3850,30 +4338,30 @@ msgid "" "*view* argument." msgstr "" -#: ../../c-api/typeobj.rst:2558 +#: ../../c-api/typeobj.rst:3050 msgid "" "This function MUST NOT decrement :c:expr:`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:2563 +#: ../../c-api/typeobj.rst:3055 msgid "" ":c:func:`PyBuffer_Release` is the interface for the consumer that wraps this " "function." msgstr "" -#: ../../c-api/typeobj.rst:2571 +#: ../../c-api/typeobj.rst:3063 msgid "Async Object Structures" -msgstr "" +msgstr "非同步物件結構" -#: ../../c-api/typeobj.rst:2579 +#: ../../c-api/typeobj.rst:3071 msgid "" "This structure holds pointers to the functions required to implement :term:" "`awaitable` and :term:`asynchronous iterator` objects." msgstr "" -#: ../../c-api/typeobj.rst:2584 +#: ../../c-api/typeobj.rst:3076 msgid "" "typedef struct {\n" " unaryfunc am_await;\n" @@ -3889,62 +4377,62 @@ msgstr "" " sendfunc am_send;\n" "} PyAsyncMethods;" -#: ../../c-api/typeobj.rst:2595 +#: ../../c-api/typeobj.rst:3089 msgid "PyObject *am_await(PyObject *self);" -msgstr "" +msgstr "PyObject *am_await(PyObject *self);" -#: ../../c-api/typeobj.rst:2597 +#: ../../c-api/typeobj.rst:3091 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:2600 +#: ../../c-api/typeobj.rst:3094 msgid "" "This slot may be set to ``NULL`` if an object is not an :term:`awaitable`." msgstr "" -#: ../../c-api/typeobj.rst:2606 +#: ../../c-api/typeobj.rst:3102 msgid "PyObject *am_aiter(PyObject *self);" msgstr "PyObject *am_aiter(PyObject *self);" -#: ../../c-api/typeobj.rst:2608 +#: ../../c-api/typeobj.rst:3104 msgid "" "Must return an :term:`asynchronous iterator` object. See :meth:`~object." "__anext__` for details." msgstr "" -#: ../../c-api/typeobj.rst:2611 +#: ../../c-api/typeobj.rst:3107 msgid "" "This slot may be set to ``NULL`` if an object does not implement " "asynchronous iteration protocol." msgstr "" -#: ../../c-api/typeobj.rst:2618 +#: ../../c-api/typeobj.rst:3116 msgid "PyObject *am_anext(PyObject *self);" msgstr "PyObject *am_anext(PyObject *self);" -#: ../../c-api/typeobj.rst:2620 +#: ../../c-api/typeobj.rst:3118 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:2628 +#: ../../c-api/typeobj.rst:3128 msgid "PySendResult am_send(PyObject *self, PyObject *arg, PyObject **result);" msgstr "" "PySendResult am_send(PyObject *self, PyObject *arg, PyObject **result);" -#: ../../c-api/typeobj.rst:2630 +#: ../../c-api/typeobj.rst:3130 msgid "" "See :c:func:`PyIter_Send` for details. This slot may be set to ``NULL``." msgstr "" -#: ../../c-api/typeobj.rst:2639 +#: ../../c-api/typeobj.rst:3139 msgid "Slot Type typedefs" msgstr "" -#: ../../c-api/typeobj.rst:2643 +#: ../../c-api/typeobj.rst:3143 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 " @@ -3958,80 +4446,80 @@ msgid "" "length of the block should be :c:member:`~PyTypeObject.tp_basicsize`." msgstr "" -#: ../../c-api/typeobj.rst:2653 +#: ../../c-api/typeobj.rst:3153 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:2660 +#: ../../c-api/typeobj.rst:3160 msgid "See :c:member:`~PyTypeObject.tp_free`." msgstr "請見 :c:member:`~PyTypeObject.tp_free`。" -#: ../../c-api/typeobj.rst:2664 +#: ../../c-api/typeobj.rst:3164 msgid "See :c:member:`~PyTypeObject.tp_new`." msgstr "請見 :c:member:`~PyTypeObject.tp_new`。" -#: ../../c-api/typeobj.rst:2668 +#: ../../c-api/typeobj.rst:3168 msgid "See :c:member:`~PyTypeObject.tp_init`." msgstr "請見 :c:member:`~PyTypeObject.tp_init`。" -#: ../../c-api/typeobj.rst:2672 +#: ../../c-api/typeobj.rst:3172 msgid "See :c:member:`~PyTypeObject.tp_repr`." msgstr "請見 :c:member:`~PyTypeObject.tp_repr`。" -#: ../../c-api/typeobj.rst:2676 ../../c-api/typeobj.rst:2685 +#: ../../c-api/typeobj.rst:3176 ../../c-api/typeobj.rst:3185 msgid "Return the value of the named attribute for the object." msgstr "" -#: ../../c-api/typeobj.rst:2680 ../../c-api/typeobj.rst:2691 +#: ../../c-api/typeobj.rst:3180 ../../c-api/typeobj.rst:3191 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:2687 +#: ../../c-api/typeobj.rst:3187 msgid "See :c:member:`~PyTypeObject.tp_getattro`." msgstr "請見 :c:member:`~PyTypeObject.tp_getattro`。" -#: ../../c-api/typeobj.rst:2694 +#: ../../c-api/typeobj.rst:3194 msgid "See :c:member:`~PyTypeObject.tp_setattro`." msgstr "請見 :c:member:`~PyTypeObject.tp_setattro`。" -#: ../../c-api/typeobj.rst:2698 +#: ../../c-api/typeobj.rst:3198 msgid "See :c:member:`~PyTypeObject.tp_descr_get`." msgstr "請見 :c:member:`~PyTypeObject.tp_descr_get`。" -#: ../../c-api/typeobj.rst:2702 +#: ../../c-api/typeobj.rst:3202 msgid "See :c:member:`~PyTypeObject.tp_descr_set`." msgstr "請見 :c:member:`~PyTypeObject.tp_descr_set`。" -#: ../../c-api/typeobj.rst:2706 +#: ../../c-api/typeobj.rst:3206 msgid "See :c:member:`~PyTypeObject.tp_hash`." msgstr "請見 :c:member:`~PyTypeObject.tp_hash`。" -#: ../../c-api/typeobj.rst:2710 +#: ../../c-api/typeobj.rst:3210 msgid "See :c:member:`~PyTypeObject.tp_richcompare`." msgstr "請見 :c:member:`~PyTypeObject.tp_richcompare`。" -#: ../../c-api/typeobj.rst:2714 +#: ../../c-api/typeobj.rst:3214 msgid "See :c:member:`~PyTypeObject.tp_iter`." msgstr "請見 :c:member:`~PyTypeObject.tp_iter`。" -#: ../../c-api/typeobj.rst:2718 +#: ../../c-api/typeobj.rst:3218 msgid "See :c:member:`~PyTypeObject.tp_iternext`." msgstr "請見 :c:member:`~PyTypeObject.tp_iternext`。" -#: ../../c-api/typeobj.rst:2732 +#: ../../c-api/typeobj.rst:3232 msgid "See :c:member:`~PyAsyncMethods.am_send`." msgstr "請見 :c:member:`~PyAsyncMethods.am_send`。" -#: ../../c-api/typeobj.rst:2748 +#: ../../c-api/typeobj.rst:3248 msgid "Examples" msgstr "範例" -#: ../../c-api/typeobj.rst:2750 +#: ../../c-api/typeobj.rst:3250 msgid "" "The following are simple examples of Python type definitions. They include " "common usage you may encounter. Some demonstrate tricky corner cases. For " @@ -4039,11 +4527,11 @@ msgid "" "and :ref:`new-types-topics`." msgstr "" -#: ../../c-api/typeobj.rst:2755 +#: ../../c-api/typeobj.rst:3255 msgid "A basic :ref:`static type `::" msgstr "" -#: ../../c-api/typeobj.rst:2757 +#: ../../c-api/typeobj.rst:3257 msgid "" "typedef struct {\n" " PyObject_HEAD\n" @@ -4060,14 +4548,28 @@ msgid "" " .tp_repr = (reprfunc)myobj_repr,\n" "};" msgstr "" +"typedef struct {\n" +" PyObject_HEAD\n" +" const char *data;\n" +"} MyObject;\n" +"\n" +"static PyTypeObject MyObject_Type = {\n" +" PyVarObject_HEAD_INIT(NULL, 0)\n" +" .tp_name = \"mymod.MyObject\",\n" +" .tp_basicsize = sizeof(MyObject),\n" +" .tp_doc = PyDoc_STR(\"My objects\"),\n" +" .tp_new = myobj_new,\n" +" .tp_dealloc = (destructor)myobj_dealloc,\n" +" .tp_repr = (reprfunc)myobj_repr,\n" +"};" -#: ../../c-api/typeobj.rst:2772 +#: ../../c-api/typeobj.rst:3272 msgid "" "You may also find older code (especially in the CPython code base) with a " "more verbose initializer::" msgstr "" -#: ../../c-api/typeobj.rst:2775 +#: ../../c-api/typeobj.rst:3275 msgid "" "static PyTypeObject MyObject_Type = {\n" " PyVarObject_HEAD_INIT(NULL, 0)\n" @@ -4151,11 +4653,11 @@ msgstr "" " myobj_new, /* tp_new */\n" "};" -#: ../../c-api/typeobj.rst:2816 +#: ../../c-api/typeobj.rst:3316 msgid "A type that supports weakrefs, instance dicts, and hashing::" msgstr "" -#: ../../c-api/typeobj.rst:2818 +#: ../../c-api/typeobj.rst:3318 msgid "" "typedef struct {\n" " PyObject_HEAD\n" @@ -4181,14 +4683,14 @@ msgid "" "};" msgstr "" -#: ../../c-api/typeobj.rst:2841 +#: ../../c-api/typeobj.rst:3341 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:2845 +#: ../../c-api/typeobj.rst:3345 msgid "" "typedef struct {\n" " PyUnicodeObject raw;\n" @@ -4206,12 +4708,12 @@ msgid "" "};" msgstr "" -#: ../../c-api/typeobj.rst:2860 +#: ../../c-api/typeobj.rst:3360 msgid "" "The simplest :ref:`static type ` with fixed-length instances::" msgstr "" -#: ../../c-api/typeobj.rst:2862 +#: ../../c-api/typeobj.rst:3362 msgid "" "typedef struct {\n" " PyObject_HEAD\n" @@ -4231,13 +4733,13 @@ msgstr "" " .tp_name = \"mymod.MyObject\",\n" "};" -#: ../../c-api/typeobj.rst:2871 +#: ../../c-api/typeobj.rst:3371 msgid "" "The simplest :ref:`static type ` with variable-length " "instances::" msgstr "" -#: ../../c-api/typeobj.rst:2873 +#: ../../c-api/typeobj.rst:3373 msgid "" "typedef struct {\n" " PyObject_VAR_HEAD\n" @@ -4263,14 +4765,14 @@ msgstr "" " .tp_itemsize = sizeof(char *),\n" "};" -#: ../../c-api/typeobj.rst:843 ../../c-api/typeobj.rst:908 +#: ../../c-api/typeobj.rst:920 ../../c-api/typeobj.rst:987 msgid "built-in function" msgstr "built-in function(內建函式)" -#: ../../c-api/typeobj.rst:843 +#: ../../c-api/typeobj.rst:920 msgid "repr" msgstr "repr" -#: ../../c-api/typeobj.rst:908 +#: ../../c-api/typeobj.rst:987 msgid "hash" msgstr "hash(雜湊)" diff --git a/c-api/unicode.po b/c-api/unicode.po index 71b90e9650a..7d9e21a667a 100644 --- a/c-api/unicode.po +++ b/c-api/unicode.po @@ -1,5 +1,4 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -7,9 +6,9 @@ # Liang-Bo Wang , 2016 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"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: 2025-11-05 00:16+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-" @@ -61,78 +60,57 @@ msgid "" "in Python:" msgstr "這些是 Python 中用於 Unicode 實作的基本 Unicode 物件型別:" -#: ../../c-api/unicode.rst:38 +#: ../../c-api/unicode.rst:36 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`." +"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:47 +#: ../../c-api/unicode.rst:42 msgid "" -"This is a typedef of :c:type:`wchar_t`, which is a 16-bit type or 32-bit " -"type depending on the platform." +"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 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." +"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:62 +#: ../../c-api/unicode.rst:61 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:71 -msgid "" -"This instance of :c:type:`PyTypeObject` represents the Python Unicode type. " -"It is exposed to Python code as ``str``." -msgstr "" - -#: ../../c-api/unicode.rst:77 -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:81 +#: ../../c-api/unicode.rst:68 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:86 +#: ../../c-api/unicode.rst:73 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:92 +#: ../../c-api/unicode.rst:79 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:98 -msgid "Returns ``0``. This API is kept only for backward compatibility." -msgstr "回傳 ``0``。此 API 僅保留以維持向後相容性。" - -#: ../../c-api/unicode.rst:102 -msgid "This API does nothing since Python 3.12." -msgstr "自 Python 3.12 起,此 API 不再執行任何動作。" - -#: ../../c-api/unicode.rst:108 +#: ../../c-api/unicode.rst:85 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:118 +#: ../../c-api/unicode.rst:95 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 " @@ -140,15 +118,15 @@ msgid "" "`PyUnicode_KIND` to select the right function." msgstr "" -#: ../../c-api/unicode.rst:130 +#: ../../c-api/unicode.rst:107 msgid "Return values of the :c:func:`PyUnicode_KIND` macro." msgstr "" -#: ../../c-api/unicode.rst:134 +#: ../../c-api/unicode.rst:111 msgid "``PyUnicode_WCHAR_KIND`` has been removed." msgstr "``PyUnicode_WCHAR_KIND`` 已被移除。" -#: ../../c-api/unicode.rst:140 +#: ../../c-api/unicode.rst:117 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. " @@ -156,113 +134,129 @@ msgid "" "(not checked)." msgstr "" -#: ../../c-api/unicode.rst:149 +#: ../../c-api/unicode.rst:126 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:158 +#: ../../c-api/unicode.rst:135 +msgid "" +"Write the code point *value* to the given zero-based *index* in a string." +msgstr "" + +#: ../../c-api/unicode.rst:137 msgid "" -"Write into a canonical representation *data* (as obtained with :c:func:" -"`PyUnicode_DATA`). This function performs no sanity checks, and is intended " -"for usage in loops. The caller should cache the *kind* value and *data* " -"pointer as obtained from other calls. *index* is the index in the string " -"(starts at 0) and *value* is the new code point value which should be " -"written to that location." +"The *kind* value and *data* pointer must have been obtained from a string " +"using :c:func:`PyUnicode_KIND` and :c:func:`PyUnicode_DATA` respectively. " +"You must hold a reference to that string while calling :c:func:`!" +"PyUnicode_WRITE`. All requirements of :c:func:`PyUnicode_WriteChar` also " +"apply." msgstr "" -#: ../../c-api/unicode.rst:171 +#: ../../c-api/unicode.rst:143 +msgid "" +"The function performs no checks for any of its requirements, and is intended " +"for usage in loops." +msgstr "" + +#: ../../c-api/unicode.rst:152 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:179 +#: ../../c-api/unicode.rst:160 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:188 +#: ../../c-api/unicode.rst:169 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:197 +#: ../../c-api/unicode.rst:178 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:200 +#: ../../c-api/unicode.rst:181 msgid "" "The function does not call :c:func:`Py_FatalError` anymore if the string is " "not ready." msgstr "" -#: ../../c-api/unicode.rst:206 +#: ../../c-api/unicode.rst:188 +msgid "" +"Return true if the string only contains ASCII characters. Equivalent to :py:" +"meth:`str.isascii`." +msgstr "" + +#: ../../c-api/unicode.rst:195 msgid "Unicode Character Properties" msgstr "" -#: ../../c-api/unicode.rst:208 +#: ../../c-api/unicode.rst:197 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:215 +#: ../../c-api/unicode.rst:204 msgid "" "Return ``1`` or ``0`` depending on whether *ch* is a whitespace character." msgstr "根據 *ch* 是否為空白字元來回傳 ``1`` 或 ``0``。" -#: ../../c-api/unicode.rst:220 +#: ../../c-api/unicode.rst:209 msgid "" "Return ``1`` or ``0`` depending on whether *ch* is a lowercase character." msgstr "根據 *ch* 是否為小寫字元來回傳 ``1`` 或 ``0``。" -#: ../../c-api/unicode.rst:225 +#: ../../c-api/unicode.rst:214 msgid "" "Return ``1`` or ``0`` depending on whether *ch* is an uppercase character." msgstr "根據 *ch* 是否為大寫字元來回傳 ``1`` 或 ``0``。" -#: ../../c-api/unicode.rst:230 +#: ../../c-api/unicode.rst:219 msgid "" "Return ``1`` or ``0`` depending on whether *ch* is a titlecase character." msgstr "根據 *ch* 是否為首字大寫字元來回傳 ``1`` 或 ``0``。" -#: ../../c-api/unicode.rst:235 +#: ../../c-api/unicode.rst:224 msgid "" "Return ``1`` or ``0`` depending on whether *ch* is a linebreak character." msgstr "根據 *ch* 是否為換行字元來回傳 ``1`` 或 ``0``。" -#: ../../c-api/unicode.rst:240 +#: ../../c-api/unicode.rst:229 msgid "Return ``1`` or ``0`` depending on whether *ch* is a decimal character." msgstr "根據 *ch* 是否為十進位字元來回傳 ``1`` 或 ``0``。" -#: ../../c-api/unicode.rst:245 +#: ../../c-api/unicode.rst:234 msgid "Return ``1`` or ``0`` depending on whether *ch* is a digit character." msgstr "根據 *ch* 是否為數字 (digit) 字元來回傳 ``1`` 或 ``0``。" -#: ../../c-api/unicode.rst:250 +#: ../../c-api/unicode.rst:239 msgid "Return ``1`` or ``0`` depending on whether *ch* is a numeric character." msgstr "根據 *ch* 是否為數值 (numeric) 字元來回傳 ``1`` 或 ``0``。" -#: ../../c-api/unicode.rst:255 +#: ../../c-api/unicode.rst:244 msgid "" "Return ``1`` or ``0`` depending on whether *ch* is an alphabetic character." msgstr "根據 *ch* 是否為字母字元來回傳 ``1`` 或 ``0``。" -#: ../../c-api/unicode.rst:260 +#: ../../c-api/unicode.rst:249 msgid "" "Return ``1`` or ``0`` depending on whether *ch* is an alphanumeric character." msgstr "根據 *ch* 是否為字母數字 (alphanumeric) 字元來回傳 ``1`` 或 ``0``。" -#: ../../c-api/unicode.rst:265 +#: ../../c-api/unicode.rst:254 msgid "" "Return ``1`` or ``0`` depending on whether *ch* is a printable character, in " "the sense of :meth:`str.isprintable`." @@ -270,23 +264,23 @@ msgstr "" "根據 *ch* 是否為可列印字元(如 :meth:`str.isprintable` 所定義)來回傳 ``1`` " "或 ``0``。" -#: ../../c-api/unicode.rst:269 +#: ../../c-api/unicode.rst:258 msgid "These APIs can be used for fast direct character conversions:" msgstr "這些 API 可用於快速直接字元轉換:" -#: ../../c-api/unicode.rst:274 +#: ../../c-api/unicode.rst:263 msgid "Return the character *ch* converted to lower case." msgstr "回傳轉換為小寫的 *ch* 字元。" -#: ../../c-api/unicode.rst:279 +#: ../../c-api/unicode.rst:268 msgid "Return the character *ch* converted to upper case." msgstr "回傳轉換為大寫的 *ch* 字元。" -#: ../../c-api/unicode.rst:284 +#: ../../c-api/unicode.rst:273 msgid "Return the character *ch* converted to title case." msgstr "回傳轉換為首字大寫的 *ch* 字元。" -#: ../../c-api/unicode.rst:289 +#: ../../c-api/unicode.rst:278 msgid "" "Return the character *ch* converted to a decimal positive integer. Return " "``-1`` if this is not possible. This function does not raise exceptions." @@ -294,7 +288,7 @@ msgstr "" "回傳轉換為十進位正整數的 *ch* 字元,若無法轉換則回傳 ``-1``。此函式不會引發例" "外。" -#: ../../c-api/unicode.rst:295 +#: ../../c-api/unicode.rst:284 msgid "" "Return the character *ch* converted to a single digit integer. Return ``-1`` " "if this is not possible. This function does not raise exceptions." @@ -302,7 +296,7 @@ msgstr "" "回傳轉換為單一數字整數的 *ch* 字元,若無法轉換則回傳 ``-1``。此函式不會引發例" "外。" -#: ../../c-api/unicode.rst:301 +#: ../../c-api/unicode.rst:290 msgid "" "Return the character *ch* converted to a double. Return ``-1.0`` if this is " "not possible. This function does not raise exceptions." @@ -310,60 +304,106 @@ msgstr "" "回傳轉換為雙精度浮點數 (double) 的 *ch* 字元,若無法轉換則回傳 ``-1.0``。此函" "式不會引發例外。" -#: ../../c-api/unicode.rst:305 +#: ../../c-api/unicode.rst:294 msgid "These APIs can be used to work with surrogates:" msgstr "這些 API 可用於處理代理字元:" -#: ../../c-api/unicode.rst:309 +#: ../../c-api/unicode.rst:298 msgid "Check if *ch* is a surrogate (``0xD800 <= ch <= 0xDFFF``)." msgstr "檢查 *ch* 是否為代理字元 (surrogate, ``0xD800 <= ch <= 0xDFFF``)。" -#: ../../c-api/unicode.rst:313 +#: ../../c-api/unicode.rst:302 msgid "Check if *ch* is a high surrogate (``0xD800 <= ch <= 0xDBFF``)." msgstr "" "檢查 *ch* 是否為高代理字元 (high surrogate, ``0xD800 <= ch <= 0xDBFF``)。" -#: ../../c-api/unicode.rst:317 +#: ../../c-api/unicode.rst:306 msgid "Check if *ch* is a low surrogate (``0xDC00 <= ch <= 0xDFFF``)." msgstr "" "檢查 *ch* 是否為低代理字元 (low surrogate, ``0xDC00 <= ch <= 0xDFFF``)。" -#: ../../c-api/unicode.rst:321 +#: ../../c-api/unicode.rst:310 +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:315 +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:320 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 " -"surrogate pair. *high* must be in the range [0xD800; 0xDBFF] and *low* must " -"be in the range [0xDC00; 0xDFFF]." +"surrogate pair. *high* must be in the range ``[0xD800; 0xDBFF]`` and *low* " +"must be in the range ``[0xDC00; 0xDFFF]``." msgstr "" -#: ../../c-api/unicode.rst:328 +#: ../../c-api/unicode.rst:327 msgid "Creating and accessing Unicode strings" msgstr "" -#: ../../c-api/unicode.rst:330 +#: ../../c-api/unicode.rst:329 msgid "" "To create Unicode objects and access their basic sequence properties, use " "these APIs:" msgstr "" -#: ../../c-api/unicode.rst:335 +#: ../../c-api/unicode.rst:334 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:339 +#: ../../c-api/unicode.rst:338 +msgid "On error, set an exception and return ``NULL``." +msgstr "" + +#: ../../c-api/unicode.rst:340 msgid "" -"This is the recommended way to allocate a new Unicode object. Objects " -"created using this function are not resizable." +"After creation, the string can be filled by :c:func:`PyUnicode_WriteChar`, :" +"c:func:`PyUnicode_CopyCharacters`, :c:func:`PyUnicode_Fill`, :c:func:" +"`PyUnicode_WRITE` or similar. Since strings are supposed to be immutable, " +"take care to not “use” the result while it is being modified. In particular, " +"before it's filled with its final contents, a string:" msgstr "" -#: ../../c-api/unicode.rst:342 -msgid "On error, set an exception and return ``NULL``." +#: ../../c-api/unicode.rst:347 +msgid "must not be hashed," +msgstr "" + +#: ../../c-api/unicode.rst:348 +msgid "" +"must not be :c:func:`converted to UTF-8 `, or " +"another non-\"canonical\" representation," msgstr "" #: ../../c-api/unicode.rst:350 +msgid "must not have its reference count changed," +msgstr "" + +#: ../../c-api/unicode.rst:351 +msgid "must not be shared with code that might do one of the above." +msgstr "" + +#: ../../c-api/unicode.rst:353 +msgid "" +"This list is not exhaustive. Avoiding these uses is your responsibility; " +"Python does not always check these requirements." +msgstr "" + +#: ../../c-api/unicode.rst:356 +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:367 msgid "" "Create a new Unicode object with the given *kind* (possible values are :c:" "macro:`PyUnicode_1BYTE_KIND` etc., as returned by :c:func:" @@ -371,7 +411,7 @@ msgid "" "1, 2 or 4 bytes per character, as given by the kind." msgstr "" -#: ../../c-api/unicode.rst:355 +#: ../../c-api/unicode.rst:372 msgid "" "If necessary, the input *buffer* is copied and transformed into the " "canonical representation. For example, if the *buffer* is a UCS4 string (:c:" @@ -379,7 +419,7 @@ msgid "" "range, it will be transformed into UCS1 (:c:macro:`PyUnicode_1BYTE_KIND`)." msgstr "" -#: ../../c-api/unicode.rst:366 +#: ../../c-api/unicode.rst:383 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 " @@ -387,29 +427,29 @@ msgid "" "data is not allowed." msgstr "" -#: ../../c-api/unicode.rst:372 +#: ../../c-api/unicode.rst:389 msgid "This function raises :exc:`SystemError` when:" msgstr "此函式在以下情況下會引發 :exc:`SystemError`:" -#: ../../c-api/unicode.rst:374 +#: ../../c-api/unicode.rst:391 msgid "*size* < 0," msgstr "*size* < 0," -#: ../../c-api/unicode.rst:375 +#: ../../c-api/unicode.rst:392 msgid "*str* is ``NULL`` and *size* > 0" msgstr "*str* 為 ``NULL`` 且 *size* > 0" -#: ../../c-api/unicode.rst:377 +#: ../../c-api/unicode.rst:394 msgid "*str* == ``NULL`` with *size* > 0 is not allowed anymore." msgstr "*str* == ``NULL`` 且 *size* > 0 不再被允許。" -#: ../../c-api/unicode.rst:383 +#: ../../c-api/unicode.rst:400 msgid "" "Create a Unicode object from a UTF-8 encoded null-terminated char buffer " "*str*." msgstr "" -#: ../../c-api/unicode.rst:389 +#: ../../c-api/unicode.rst:406 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 " @@ -418,23 +458,23 @@ msgid "" "*format* ASCII-encoded string." msgstr "" -#: ../../c-api/unicode.rst:395 +#: ../../c-api/unicode.rst:412 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:398 +#: ../../c-api/unicode.rst:415 msgid "The ``'%'`` character, which marks the start of the specifier." msgstr "" -#: ../../c-api/unicode.rst:400 +#: ../../c-api/unicode.rst:417 msgid "" "Conversion flags (optional), which affect the result of some conversion " "types." msgstr "" -#: ../../c-api/unicode.rst:403 +#: ../../c-api/unicode.rst:420 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:" @@ -442,7 +482,7 @@ msgid "" "optional precision." msgstr "" -#: ../../c-api/unicode.rst:408 +#: ../../c-api/unicode.rst:425 msgid "" "Precision (optional), given as a ``'.'`` (dot) followed by the precision. If " "specified as ``'*'`` (an asterisk), the actual precision is given in the " @@ -450,316 +490,316 @@ msgid "" "comes after the precision." msgstr "" -#: ../../c-api/unicode.rst:413 +#: ../../c-api/unicode.rst:430 msgid "Length modifier (optional)." msgstr "" -#: ../../c-api/unicode.rst:415 +#: ../../c-api/unicode.rst:432 msgid "Conversion type." msgstr "" -#: ../../c-api/unicode.rst:417 +#: ../../c-api/unicode.rst:434 msgid "The conversion flag characters are:" msgstr "" -#: ../../c-api/unicode.rst:422 +#: ../../c-api/unicode.rst:439 msgid "Flag" msgstr "旗標" -#: ../../c-api/unicode.rst:422 +#: ../../c-api/unicode.rst:439 msgid "Meaning" msgstr "含義" -#: ../../c-api/unicode.rst:424 +#: ../../c-api/unicode.rst:441 msgid "``0``" msgstr "``0``" -#: ../../c-api/unicode.rst:424 +#: ../../c-api/unicode.rst:441 msgid "The conversion will be zero padded for numeric values." msgstr "" -#: ../../c-api/unicode.rst:426 +#: ../../c-api/unicode.rst:443 msgid "``-``" msgstr "``-``" -#: ../../c-api/unicode.rst:426 +#: ../../c-api/unicode.rst:443 msgid "" "The converted value is left adjusted (overrides the ``0`` flag if both are " "given)." msgstr "" -#: ../../c-api/unicode.rst:430 +#: ../../c-api/unicode.rst:447 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:437 +#: ../../c-api/unicode.rst:454 msgid "Modifier" msgstr "" -#: ../../c-api/unicode.rst:437 +#: ../../c-api/unicode.rst:454 msgid "Types" msgstr "" -#: ../../c-api/unicode.rst:439 +#: ../../c-api/unicode.rst:456 msgid "``l``" msgstr "``l``" -#: ../../c-api/unicode.rst:439 +#: ../../c-api/unicode.rst:456 msgid ":c:expr:`long` or :c:expr:`unsigned long`" msgstr ":c:expr:`long` 或 :c:expr:`unsigned long`" -#: ../../c-api/unicode.rst:441 +#: ../../c-api/unicode.rst:458 msgid "``ll``" msgstr "``ll``" -#: ../../c-api/unicode.rst:441 +#: ../../c-api/unicode.rst:458 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:443 +#: ../../c-api/unicode.rst:460 msgid "``j``" msgstr "``j``" -#: ../../c-api/unicode.rst:443 +#: ../../c-api/unicode.rst:460 msgid ":c:type:`intmax_t` or :c:type:`uintmax_t`" msgstr ":c:type:`intmax_t` 或 :c:type:`uintmax_t`" -#: ../../c-api/unicode.rst:445 +#: ../../c-api/unicode.rst:462 msgid "``z``" msgstr "``z``" -#: ../../c-api/unicode.rst:445 +#: ../../c-api/unicode.rst:462 msgid ":c:type:`size_t` or :c:type:`ssize_t`" msgstr ":c:type:`size_t` 或 :c:type:`ssize_t`" -#: ../../c-api/unicode.rst:447 +#: ../../c-api/unicode.rst:464 msgid "``t``" msgstr "``t``" -#: ../../c-api/unicode.rst:447 +#: ../../c-api/unicode.rst:464 msgid ":c:type:`ptrdiff_t`" msgstr ":c:type:`ptrdiff_t`" -#: ../../c-api/unicode.rst:450 +#: ../../c-api/unicode.rst:467 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:453 +#: ../../c-api/unicode.rst:470 msgid "The conversion specifiers are:" msgstr "" -#: ../../c-api/unicode.rst:459 +#: ../../c-api/unicode.rst:476 msgid "Conversion Specifier" msgstr "" -#: ../../c-api/unicode.rst:460 +#: ../../c-api/unicode.rst:477 msgid "Type" msgstr "" -#: ../../c-api/unicode.rst:461 +#: ../../c-api/unicode.rst:478 msgid "Comment" msgstr "" -#: ../../c-api/unicode.rst:463 +#: ../../c-api/unicode.rst:480 msgid "``%``" msgstr "``%``" -#: ../../c-api/unicode.rst:464 +#: ../../c-api/unicode.rst:481 msgid "*n/a*" msgstr "*n/a*" -#: ../../c-api/unicode.rst:465 +#: ../../c-api/unicode.rst:482 msgid "The literal ``%`` character." msgstr "字面 ``%`` 字元。" -#: ../../c-api/unicode.rst:467 +#: ../../c-api/unicode.rst:484 msgid "``d``, ``i``" msgstr "``d``, ``i``" -#: ../../c-api/unicode.rst:468 ../../c-api/unicode.rst:472 -#: ../../c-api/unicode.rst:476 ../../c-api/unicode.rst:480 -#: ../../c-api/unicode.rst:484 +#: ../../c-api/unicode.rst:485 ../../c-api/unicode.rst:489 +#: ../../c-api/unicode.rst:493 ../../c-api/unicode.rst:497 +#: ../../c-api/unicode.rst:501 msgid "Specified by the length modifier" msgstr "" -#: ../../c-api/unicode.rst:469 +#: ../../c-api/unicode.rst:486 msgid "The decimal representation of a signed C integer." msgstr "一個有符號 C 整數的十進位表示法。" -#: ../../c-api/unicode.rst:471 +#: ../../c-api/unicode.rst:488 msgid "``u``" msgstr "``u``" -#: ../../c-api/unicode.rst:473 +#: ../../c-api/unicode.rst:490 msgid "The decimal representation of an unsigned C integer." msgstr "一個無符號 C 整數的十進位表示法。" -#: ../../c-api/unicode.rst:475 +#: ../../c-api/unicode.rst:492 msgid "``o``" msgstr "``o``" -#: ../../c-api/unicode.rst:477 +#: ../../c-api/unicode.rst:494 msgid "The octal representation of an unsigned C integer." msgstr "一個無符號 C 整數的八進位表示法。" -#: ../../c-api/unicode.rst:479 +#: ../../c-api/unicode.rst:496 msgid "``x``" msgstr "``x``" -#: ../../c-api/unicode.rst:481 +#: ../../c-api/unicode.rst:498 msgid "The hexadecimal representation of an unsigned C integer (lowercase)." msgstr "一個無符號 C 整數的十六進位表示法(小寫)。" -#: ../../c-api/unicode.rst:483 +#: ../../c-api/unicode.rst:500 msgid "``X``" msgstr "``X``" -#: ../../c-api/unicode.rst:485 +#: ../../c-api/unicode.rst:502 msgid "The hexadecimal representation of an unsigned C integer (uppercase)." msgstr "一個無符號 C 整數的十六進位表示法(大寫)。" -#: ../../c-api/unicode.rst:487 +#: ../../c-api/unicode.rst:504 msgid "``c``" msgstr "``c``" -#: ../../c-api/unicode.rst:488 +#: ../../c-api/unicode.rst:505 msgid ":c:expr:`int`" msgstr ":c:expr:`int`" -#: ../../c-api/unicode.rst:489 +#: ../../c-api/unicode.rst:506 msgid "A single character." msgstr "一個單一字元。" -#: ../../c-api/unicode.rst:491 +#: ../../c-api/unicode.rst:508 msgid "``s``" msgstr "``s``" -#: ../../c-api/unicode.rst:492 +#: ../../c-api/unicode.rst:509 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:493 +#: ../../c-api/unicode.rst:510 msgid "A null-terminated C character array." msgstr "一個以 null 結尾的 C 字元陣列。" -#: ../../c-api/unicode.rst:495 +#: ../../c-api/unicode.rst:512 msgid "``p``" msgstr "``p``" -#: ../../c-api/unicode.rst:496 +#: ../../c-api/unicode.rst:513 msgid ":c:expr:`const void*`" msgstr ":c:expr:`const void*`" -#: ../../c-api/unicode.rst:497 +#: ../../c-api/unicode.rst:514 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:502 +#: ../../c-api/unicode.rst:519 msgid "``A``" msgstr "``A``" -#: ../../c-api/unicode.rst:503 ../../c-api/unicode.rst:507 -#: ../../c-api/unicode.rst:517 ../../c-api/unicode.rst:521 -#: ../../c-api/unicode.rst:525 ../../c-api/unicode.rst:530 +#: ../../c-api/unicode.rst:520 ../../c-api/unicode.rst:524 +#: ../../c-api/unicode.rst:534 ../../c-api/unicode.rst:538 +#: ../../c-api/unicode.rst:542 ../../c-api/unicode.rst:547 msgid ":c:expr:`PyObject*`" msgstr ":c:expr:`PyObject*`" -#: ../../c-api/unicode.rst:504 +#: ../../c-api/unicode.rst:521 msgid "The result of calling :func:`ascii`." msgstr "呼叫 :func:`ascii` 的結果。" -#: ../../c-api/unicode.rst:506 +#: ../../c-api/unicode.rst:523 msgid "``U``" msgstr "``U``" -#: ../../c-api/unicode.rst:508 +#: ../../c-api/unicode.rst:525 msgid "A Unicode object." msgstr "一個 Unicode 物件。" -#: ../../c-api/unicode.rst:510 +#: ../../c-api/unicode.rst:527 msgid "``V``" msgstr "``V``" -#: ../../c-api/unicode.rst:511 +#: ../../c-api/unicode.rst:528 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:512 +#: ../../c-api/unicode.rst:529 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:516 +#: ../../c-api/unicode.rst:533 msgid "``S``" msgstr "``S``" -#: ../../c-api/unicode.rst:518 +#: ../../c-api/unicode.rst:535 msgid "The result of calling :c:func:`PyObject_Str`." msgstr "呼叫 :c:func:`PyObject_Str` 的結果。" -#: ../../c-api/unicode.rst:520 +#: ../../c-api/unicode.rst:537 msgid "``R``" msgstr "``R``" -#: ../../c-api/unicode.rst:522 +#: ../../c-api/unicode.rst:539 msgid "The result of calling :c:func:`PyObject_Repr`." msgstr "呼叫 :c:func:`PyObject_Repr` 的結果。" -#: ../../c-api/unicode.rst:524 +#: ../../c-api/unicode.rst:541 msgid "``T``" msgstr "``T``" -#: ../../c-api/unicode.rst:526 +#: ../../c-api/unicode.rst:543 msgid "" "Get the fully qualified name of an object type; call :c:func:" "`PyType_GetFullyQualifiedName`." msgstr "" -#: ../../c-api/unicode.rst:529 +#: ../../c-api/unicode.rst:546 msgid "``#T``" msgstr "``#T``" -#: ../../c-api/unicode.rst:531 +#: ../../c-api/unicode.rst:548 msgid "" "Similar to ``T`` format, but use a colon (``:``) as separator between the " "module name and the qualified name." msgstr "" -#: ../../c-api/unicode.rst:534 +#: ../../c-api/unicode.rst:551 msgid "``N``" msgstr "``N``" -#: ../../c-api/unicode.rst:535 ../../c-api/unicode.rst:540 +#: ../../c-api/unicode.rst:552 ../../c-api/unicode.rst:557 msgid ":c:expr:`PyTypeObject*`" msgstr ":c:expr:`PyTypeObject*`" -#: ../../c-api/unicode.rst:536 +#: ../../c-api/unicode.rst:553 msgid "" "Get the fully qualified name of a type; call :c:func:" "`PyType_GetFullyQualifiedName`." msgstr "" -#: ../../c-api/unicode.rst:539 +#: ../../c-api/unicode.rst:556 msgid "``#N``" msgstr "``#N``" -#: ../../c-api/unicode.rst:541 +#: ../../c-api/unicode.rst:558 msgid "" "Similar to ``N`` format, but use a colon (``:``) as separator between the " "module name and the qualified name." msgstr "" -#: ../../c-api/unicode.rst:545 +#: ../../c-api/unicode.rst:562 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 " @@ -769,22 +809,22 @@ msgid "" "``PyObject*`` argument is not ``NULL``)." msgstr "" -#: ../../c-api/unicode.rst:553 +#: ../../c-api/unicode.rst:570 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:557 +#: ../../c-api/unicode.rst:574 msgid "Support for ``\"%lld\"`` and ``\"%llu\"`` added." msgstr "新增對 ``\"%lld\"`` 和 ``\"%llu\"`` 的支援。" -#: ../../c-api/unicode.rst:560 +#: ../../c-api/unicode.rst:577 msgid "Support for ``\"%li\"``, ``\"%lli\"`` and ``\"%zi\"`` added." msgstr "新增對 ``\"%li\"``、``\"%lli\"`` 和 ``\"%zi\"`` 的支援。" -#: ../../c-api/unicode.rst:563 +#: ../../c-api/unicode.rst:580 msgid "" "Support width and precision formatter for ``\"%s\"``, ``\"%A\"``, " "``\"%U\"``, ``\"%V\"``, ``\"%S\"``, ``\"%R\"`` added." @@ -792,7 +832,7 @@ msgstr "" "新增對 ``\"%s\"``、``\"%A\"``、``\"%U\"``、``\"%V\"``、``\"%S\"``、" "``\"%R\"`` 的寬度和精確度格式化支援。" -#: ../../c-api/unicode.rst:567 +#: ../../c-api/unicode.rst:584 msgid "" "Support for conversion specifiers ``o`` and ``X``. Support for length " "modifiers ``j`` and ``t``. Length modifiers are now applied to all integer " @@ -801,50 +841,50 @@ msgid "" "flag ``-``." msgstr "" -#: ../../c-api/unicode.rst:575 +#: ../../c-api/unicode.rst:592 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:579 +#: ../../c-api/unicode.rst:596 msgid "Support for ``%T``, ``%#T``, ``%N`` and ``%#N`` formats added." msgstr "新增對 ``%T``、``%#T``、``%N`` 和 ``%#N`` 格式的支援。" -#: ../../c-api/unicode.rst:585 +#: ../../c-api/unicode.rst:602 msgid "" "Identical to :c:func:`PyUnicode_FromFormat` except that it takes exactly two " "arguments." msgstr "" -#: ../../c-api/unicode.rst:591 +#: ../../c-api/unicode.rst:608 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:595 +#: ../../c-api/unicode.rst:612 msgid "" "Objects other than Unicode or its subtypes will cause a :exc:`TypeError`." msgstr "" -#: ../../c-api/unicode.rst:600 +#: ../../c-api/unicode.rst:617 msgid "Create a Unicode Object from the given Unicode code point *ordinal*." msgstr "" -#: ../../c-api/unicode.rst:602 +#: ../../c-api/unicode.rst:619 msgid "" "The ordinal must be in ``range(0x110000)``. A :exc:`ValueError` is raised in " "the case it is not." msgstr "" -#: ../../c-api/unicode.rst:609 +#: ../../c-api/unicode.rst:626 msgid "Decode an encoded object *obj* to a Unicode object." msgstr "" -#: ../../c-api/unicode.rst:611 +#: ../../c-api/unicode.rst:628 msgid "" ":class:`bytes`, :class:`bytearray` and other :term:`bytes-like objects " "` are decoded according to the given *encoding* and using " @@ -852,48 +892,69 @@ msgid "" "interface use the default values (see :ref:`builtincodecs` for details)." msgstr "" -#: ../../c-api/unicode.rst:617 +#: ../../c-api/unicode.rst:634 msgid "" "All other objects, including Unicode objects, cause a :exc:`TypeError` to be " "set." msgstr "" -#: ../../c-api/unicode.rst:620 +#: ../../c-api/unicode.rst:637 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:626 +#: ../../c-api/unicode.rst:643 +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 (\"steals\") this reference." +msgstr "" + +#: ../../c-api/unicode.rst:647 +msgid "On error, set *\\*p_left* to ``NULL`` and set an exception." +msgstr "於錯誤發生時,將 *\\*p_left* 設為 ``NULL`` 並設定例外。" + +#: ../../c-api/unicode.rst:649 +msgid "On success, set *\\*p_left* to a new strong reference to the result." +msgstr "" + +#: ../../c-api/unicode.rst:654 +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:660 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 " "table, returns either a compact internal mapping object or a dictionary " "mapping character ordinals to byte values. Raises a :exc:`TypeError` and " -"return ``NULL`` on invalid input. .. versionadded:: 3.2" +"return ``NULL`` on invalid input." msgstr "" -#: ../../c-api/unicode.rst:636 +#: ../../c-api/unicode.rst:671 msgid "" "Return the name of the default string encoding, ``\"utf-8\"``. See :func:" "`sys.getdefaultencoding`." msgstr "" -#: ../../c-api/unicode.rst:639 +#: ../../c-api/unicode.rst:674 msgid "" "The returned string does not need to be freed, and is valid until " "interpreter shutdown." msgstr "" -#: ../../c-api/unicode.rst:645 +#: ../../c-api/unicode.rst:680 msgid "Return the length of the Unicode object, in code points." msgstr "" -#: ../../c-api/unicode.rst:647 +#: ../../c-api/unicode.rst:682 msgid "On error, set an exception and return ``-1``." msgstr "發生錯誤時,設定例外並回傳 ``-1``。" -#: ../../c-api/unicode.rst:658 +#: ../../c-api/unicode.rst:693 msgid "" "Copy characters from one Unicode object into another. This function " "performs character conversion when necessary and falls back to :c:func:`!" @@ -901,61 +962,88 @@ msgid "" "otherwise returns the number of copied characters." msgstr "" -#: ../../c-api/unicode.rst:669 +#: ../../c-api/unicode.rst:698 ../../c-api/unicode.rst:728 +#: ../../c-api/unicode.rst:748 +msgid "" +"The string must not have been “used” yet. See :c:func:`PyUnicode_New` for " +"details." +msgstr "" + +#: ../../c-api/unicode.rst:706 +msgid "" +"Resize a Unicode object *\\*unicode* to the new *length* in code points." +msgstr "" + +#: ../../c-api/unicode.rst:708 +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:711 +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:715 +msgid "" +"The function doesn't check string content, the result may not be a string in " +"canonical representation." +msgstr "" + +#: ../../c-api/unicode.rst:722 msgid "" "Fill a string with a character: write *fill_char* into ``unicode[start:" "start+length]``." msgstr "" -#: ../../c-api/unicode.rst:672 +#: ../../c-api/unicode.rst:725 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:675 +#: ../../c-api/unicode.rst:731 msgid "" "Return the number of written character, or return ``-1`` and raise an " "exception on error." msgstr "" -#: ../../c-api/unicode.rst:684 +#: ../../c-api/unicode.rst:740 msgid "" -"Write a character to a string. The string must have been created through :c:" -"func:`PyUnicode_New`. Since Unicode strings are supposed to be immutable, " -"the string must not be shared, or have been hashed yet." +"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:688 +#: ../../c-api/unicode.rst:743 msgid "" "This function checks that *unicode* is a Unicode object, that the index is " -"not out of bounds, and that the object can be modified safely (i.e. that it " -"its reference count is one)." +"not out of bounds, and that the object's reference count is one. See :c:func:" +"`PyUnicode_WRITE` for a version that skips these checks, making them your " +"responsibility." msgstr "" -#: ../../c-api/unicode.rst:692 -msgid "Return ``0`` on success, ``-1`` on error with an exception set." -msgstr "成功時回傳 ``0``,發生錯誤時設定例外並回傳 ``-1``。" - -#: ../../c-api/unicode.rst:699 +#: ../../c-api/unicode.rst:756 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:703 +#: ../../c-api/unicode.rst:760 msgid "Return character on success, ``-1`` on error with an exception set." msgstr "成功時回傳字元,發生錯誤時設定例外並回傳 ``-1``。" -#: ../../c-api/unicode.rst:711 +#: ../../c-api/unicode.rst:768 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:721 +#: ../../c-api/unicode.rst:778 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 " @@ -963,7 +1051,7 @@ msgid "" "*unicode*). *buffer* is returned on success." msgstr "" -#: ../../c-api/unicode.rst:731 +#: ../../c-api/unicode.rst:788 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:" @@ -971,17 +1059,17 @@ msgid "" "appended." msgstr "" -#: ../../c-api/unicode.rst:740 +#: ../../c-api/unicode.rst:797 msgid "Locale Encoding" msgstr "" -#: ../../c-api/unicode.rst:742 +#: ../../c-api/unicode.rst:799 msgid "" "The current locale encoding can be used to decode text from the operating " "system." msgstr "" -#: ../../c-api/unicode.rst:749 +#: ../../c-api/unicode.rst:806 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 " @@ -990,21 +1078,21 @@ msgid "" "null character but cannot contain embedded null characters." msgstr "" -#: ../../c-api/unicode.rst:756 +#: ../../c-api/unicode.rst:813 msgid "" "Use :c:func:`PyUnicode_DecodeFSDefaultAndSize` to decode a string from the :" "term:`filesystem encoding and error handler`." msgstr "" -#: ../../c-api/unicode.rst:759 ../../c-api/unicode.rst:794 +#: ../../c-api/unicode.rst:816 ../../c-api/unicode.rst:851 msgid "This function ignores the :ref:`Python UTF-8 Mode `." msgstr "此函式會忽略 :ref:`Python UTF-8 模式 `。" -#: ../../c-api/unicode.rst:763 ../../c-api/unicode.rst:879 +#: ../../c-api/unicode.rst:820 ../../c-api/unicode.rst:936 msgid "The :c:func:`Py_DecodeLocale` function." msgstr ":c:func:`Py_DecodeLocale` 函式。" -#: ../../c-api/unicode.rst:767 +#: ../../c-api/unicode.rst:824 msgid "" "The function now also uses the current locale encoding for the " "``surrogateescape`` error handler, except on Android. Previously, :c:func:" @@ -1012,7 +1100,7 @@ msgid "" "locale encoding was used for ``strict``." msgstr "" -#: ../../c-api/unicode.rst:776 +#: ../../c-api/unicode.rst:833 msgid "" "Similar to :c:func:`PyUnicode_DecodeLocaleAndSize`, but compute the string " "length using :c:func:`!strlen`." @@ -1020,7 +1108,7 @@ msgstr "" "類似於 :c:func:`PyUnicode_DecodeLocaleAndSize`,但使用 :c:func:`!strlen` 計算" "字串長度。" -#: ../../c-api/unicode.rst:784 +#: ../../c-api/unicode.rst:841 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 " @@ -1029,17 +1117,17 @@ msgid "" "`bytes` object. *unicode* cannot contain embedded null characters." msgstr "" -#: ../../c-api/unicode.rst:791 +#: ../../c-api/unicode.rst:848 msgid "" "Use :c:func:`PyUnicode_EncodeFSDefault` to encode a string to the :term:" "`filesystem encoding and error handler`." msgstr "" -#: ../../c-api/unicode.rst:798 ../../c-api/unicode.rst:910 +#: ../../c-api/unicode.rst:855 ../../c-api/unicode.rst:967 msgid "The :c:func:`Py_EncodeLocale` function." msgstr ":c:func:`Py_EncodeLocale` 函式。" -#: ../../c-api/unicode.rst:802 +#: ../../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:" @@ -1047,24 +1135,24 @@ msgid "" "locale encoding was used for ``strict``." msgstr "" -#: ../../c-api/unicode.rst:811 +#: ../../c-api/unicode.rst:868 msgid "File System Encoding" msgstr "檔案系統編碼" -#: ../../c-api/unicode.rst:813 +#: ../../c-api/unicode.rst:870 msgid "" "Functions encoding to and decoding from the :term:`filesystem encoding and " "error handler` (:pep:`383` and :pep:`529`)." msgstr "" -#: ../../c-api/unicode.rst:816 +#: ../../c-api/unicode.rst:873 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:822 +#: ../../c-api/unicode.rst:879 msgid "" ":ref:`PyArg_Parse\\* converter `: encode :class:`str` objects " "-- obtained directly or through the :class:`os.PathLike` interface -- to :" @@ -1077,24 +1165,24 @@ msgid "" "not allowed in the result. On failure, return ``0`` with an exception set." msgstr "" -#: ../../c-api/unicode.rst:834 +#: ../../c-api/unicode.rst:891 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:839 ../../c-api/unicode.rst:866 +#: ../../c-api/unicode.rst:896 ../../c-api/unicode.rst:923 msgid "Accepts a :term:`path-like object`." msgstr "接受一個 :term:`path-like object`。" -#: ../../c-api/unicode.rst:842 +#: ../../c-api/unicode.rst:899 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:848 +#: ../../c-api/unicode.rst:905 msgid "" ":ref:`PyArg_Parse\\* converter `: decode :class:`bytes` objects " "-- obtained either directly or indirectly through the :class:`os.PathLike` " @@ -1108,63 +1196,63 @@ msgid "" "result. On failure, return ``0`` with an exception set." msgstr "" -#: ../../c-api/unicode.rst:861 +#: ../../c-api/unicode.rst:918 msgid "" "If *obj* is ``NULL``, release the strong reference to the object referred to " "by *result* and return ``1``." msgstr "" -#: ../../c-api/unicode.rst:872 +#: ../../c-api/unicode.rst:929 msgid "Decode a string from the :term:`filesystem encoding and error handler`." msgstr "" -#: ../../c-api/unicode.rst:874 +#: ../../c-api/unicode.rst:931 msgid "" "If you need to decode a string from the current locale encoding, use :c:func:" "`PyUnicode_DecodeLocaleAndSize`." msgstr "" -#: ../../c-api/unicode.rst:881 ../../c-api/unicode.rst:894 -#: ../../c-api/unicode.rst:914 +#: ../../c-api/unicode.rst:938 ../../c-api/unicode.rst:951 +#: ../../c-api/unicode.rst:971 msgid "" "The :term:`filesystem error handler ` " "is now used." msgstr "" -#: ../../c-api/unicode.rst:888 +#: ../../c-api/unicode.rst:945 msgid "" "Decode a null-terminated string from the :term:`filesystem encoding and " "error handler`." msgstr "" -#: ../../c-api/unicode.rst:891 +#: ../../c-api/unicode.rst:948 msgid "" "If the string length is known, use :c:func:" "`PyUnicode_DecodeFSDefaultAndSize`." msgstr "如果字串長度已知,請使用 :c:func:`PyUnicode_DecodeFSDefaultAndSize`。" -#: ../../c-api/unicode.rst:901 +#: ../../c-api/unicode.rst:958 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:905 +#: ../../c-api/unicode.rst:962 msgid "" "If you need to encode a string to the current locale encoding, use :c:func:" "`PyUnicode_EncodeLocale`." msgstr "" -#: ../../c-api/unicode.rst:919 +#: ../../c-api/unicode.rst:976 msgid "wchar_t Support" msgstr "wchar_t 支援" -#: ../../c-api/unicode.rst:921 +#: ../../c-api/unicode.rst:978 msgid ":c:type:`wchar_t` support for platforms which support it:" msgstr "對支援 :c:type:`wchar_t` 的平台提供支援:" -#: ../../c-api/unicode.rst:925 +#: ../../c-api/unicode.rst:982 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 " @@ -1172,7 +1260,7 @@ msgid "" "failure." msgstr "" -#: ../../c-api/unicode.rst:933 +#: ../../c-api/unicode.rst:990 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 " @@ -1180,13 +1268,13 @@ msgid "" "`wchar_t` characters copied or ``-1`` in case of an error." msgstr "" -#: ../../c-api/unicode.rst:938 +#: ../../c-api/unicode.rst:995 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:941 +#: ../../c-api/unicode.rst:998 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:" @@ -1196,7 +1284,7 @@ msgid "" "most C functions." msgstr "" -#: ../../c-api/unicode.rst:951 +#: ../../c-api/unicode.rst:1008 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 " @@ -1207,37 +1295,37 @@ msgid "" "`wchar_t*` string contains null characters a :exc:`ValueError` is raised." msgstr "" -#: ../../c-api/unicode.rst:959 +#: ../../c-api/unicode.rst:1016 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:966 +#: ../../c-api/unicode.rst:1023 msgid "" "Raises a :exc:`ValueError` if *size* is ``NULL`` and the :c:expr:`wchar_t*` " "string contains null characters." msgstr "" -#: ../../c-api/unicode.rst:974 +#: ../../c-api/unicode.rst:1031 msgid "Built-in Codecs" msgstr "內建編解碼器" -#: ../../c-api/unicode.rst:976 +#: ../../c-api/unicode.rst:1033 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:979 +#: ../../c-api/unicode.rst:1036 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:983 +#: ../../c-api/unicode.rst:1040 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 " @@ -1245,28 +1333,42 @@ msgid "" "handler` internally." msgstr "" -#: ../../c-api/unicode.rst:988 +#: ../../c-api/unicode.rst:1045 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:992 +#: ../../c-api/unicode.rst:1049 msgid "" "The codecs all use a similar interface. Only deviations from the following " "generic ones are documented for simplicity." msgstr "" -#: ../../c-api/unicode.rst:997 +#: ../../c-api/unicode.rst:1054 msgid "Generic Codecs" msgstr "泛用編解碼器" -#: ../../c-api/unicode.rst:999 +#: ../../c-api/unicode.rst:1056 +msgid "The following macro is provided:" +msgstr "" + +#: ../../c-api/unicode.rst:1061 +msgid "The Unicode code point ``U+FFFD`` (replacement character)." +msgstr "" + +#: ../../c-api/unicode.rst:1063 +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:1067 msgid "These are the generic codec APIs:" msgstr "這些是泛用編解碼器的 API:" -#: ../../c-api/unicode.rst:1005 +#: ../../c-api/unicode.rst:1073 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 " @@ -1275,7 +1377,7 @@ msgid "" "was raised by the codec." msgstr "" -#: ../../c-api/unicode.rst:1015 +#: ../../c-api/unicode.rst:1083 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 " @@ -1284,21 +1386,21 @@ msgid "" "was raised by the codec." msgstr "" -#: ../../c-api/unicode.rst:1023 +#: ../../c-api/unicode.rst:1091 msgid "UTF-8 Codecs" msgstr "UTF-8 編解碼器" -#: ../../c-api/unicode.rst:1025 +#: ../../c-api/unicode.rst:1093 msgid "These are the UTF-8 codec APIs:" msgstr "這些是 UTF-8 編解碼器的 API:" -#: ../../c-api/unicode.rst:1030 +#: ../../c-api/unicode.rst:1098 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:1037 +#: ../../c-api/unicode.rst:1105 msgid "" "If *consumed* is ``NULL``, behave like :c:func:`PyUnicode_DecodeUTF8`. If " "*consumed* is not ``NULL``, trailing incomplete UTF-8 byte sequences will " @@ -1306,20 +1408,20 @@ msgid "" "of bytes that have been decoded will be stored in *consumed*." msgstr "" -#: ../../c-api/unicode.rst:1045 +#: ../../c-api/unicode.rst:1113 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:1049 ../../c-api/unicode.rst:1064 +#: ../../c-api/unicode.rst:1117 ../../c-api/unicode.rst:1132 msgid "" "The function fails if the string contains surrogate code points (``U+D800`` " "- ``U+DFFF``)." msgstr "" -#: ../../c-api/unicode.rst:1055 +#: ../../c-api/unicode.rst:1123 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* " @@ -1328,7 +1430,7 @@ msgid "" "regardless of whether there are any other null code points." msgstr "" -#: ../../c-api/unicode.rst:1061 +#: ../../c-api/unicode.rst:1129 msgid "" "On error, set an exception, set *size* to ``-1`` (if it's not NULL) and " "return ``NULL``." @@ -1336,7 +1438,7 @@ msgstr "" "發生錯誤時,設定例外並將 *size* 設為 ``-1``\\ (如果不是 NULL),並回傳 " "``NULL``。" -#: ../../c-api/unicode.rst:1067 +#: ../../c-api/unicode.rst:1135 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 " @@ -1345,19 +1447,19 @@ msgid "" "collected." msgstr "" -#: ../../c-api/unicode.rst:1074 ../../c-api/unicode.rst:1096 +#: ../../c-api/unicode.rst:1142 ../../c-api/unicode.rst:1164 msgid "The return type is now ``const char *`` rather of ``char *``." msgstr "回傳型別現在是 ``const char *`` 而不是 ``char *``。" -#: ../../c-api/unicode.rst:1077 +#: ../../c-api/unicode.rst:1145 msgid "This function is a part of the :ref:`limited API `." msgstr "" -#: ../../c-api/unicode.rst:1083 +#: ../../c-api/unicode.rst:1151 msgid "As :c:func:`PyUnicode_AsUTF8AndSize`, but does not store the size." msgstr "與 :c:func:`PyUnicode_AsUTF8AndSize` 類似,但不儲存大小。" -#: ../../c-api/unicode.rst:1087 +#: ../../c-api/unicode.rst:1155 msgid "" "This function does not have any special behavior for `null characters " "`_ embedded within *unicode*. " @@ -1367,35 +1469,35 @@ msgid "" "c:func:`PyUnicode_AsUTF8AndSize` instead." msgstr "" -#: ../../c-api/unicode.rst:1101 +#: ../../c-api/unicode.rst:1169 msgid "UTF-32 Codecs" msgstr "UTF-32 編解碼器" -#: ../../c-api/unicode.rst:1103 +#: ../../c-api/unicode.rst:1171 msgid "These are the UTF-32 codec APIs:" msgstr "這些是 UTF-32 編解碼器的 API:" -#: ../../c-api/unicode.rst:1109 +#: ../../c-api/unicode.rst:1177 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:1113 ../../c-api/unicode.rst:1163 +#: ../../c-api/unicode.rst:1181 ../../c-api/unicode.rst:1231 msgid "" "If *byteorder* is non-``NULL``, the decoder starts decoding using the given " "byte order::" msgstr "" -#: ../../c-api/unicode.rst:1116 ../../c-api/unicode.rst:1166 +#: ../../c-api/unicode.rst:1184 ../../c-api/unicode.rst:1234 msgid "" "*byteorder == -1: little endian\n" "*byteorder == 0: native order\n" "*byteorder == 1: big endian" msgstr "" -#: ../../c-api/unicode.rst:1120 +#: ../../c-api/unicode.rst:1188 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 " @@ -1403,21 +1505,21 @@ msgid "" "``-1`` or ``1``, any byte order mark is copied to the output." msgstr "" -#: ../../c-api/unicode.rst:1125 +#: ../../c-api/unicode.rst:1193 msgid "" "After completion, *\\*byteorder* is set to the current byte order at the end " "of input data." msgstr "" -#: ../../c-api/unicode.rst:1128 ../../c-api/unicode.rst:1179 +#: ../../c-api/unicode.rst:1196 ../../c-api/unicode.rst:1247 msgid "If *byteorder* is ``NULL``, the codec starts in native order mode." msgstr "" -#: ../../c-api/unicode.rst:1130 ../../c-api/unicode.rst:1181 +#: ../../c-api/unicode.rst:1198 ../../c-api/unicode.rst:1249 msgid "Return ``NULL`` if an exception was raised by the codec." msgstr "如果編解碼器引發例外則回傳 ``NULL``。" -#: ../../c-api/unicode.rst:1136 +#: ../../c-api/unicode.rst:1204 msgid "" "If *consumed* is ``NULL``, behave like :c:func:`PyUnicode_DecodeUTF32`. If " "*consumed* is not ``NULL``, :c:func:`PyUnicode_DecodeUTF32Stateful` will not " @@ -1426,29 +1528,29 @@ msgid "" "number of bytes that have been decoded will be stored in *consumed*." msgstr "" -#: ../../c-api/unicode.rst:1145 +#: ../../c-api/unicode.rst:1213 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:1151 +#: ../../c-api/unicode.rst:1219 msgid "UTF-16 Codecs" msgstr "UTF-16 編解碼器" -#: ../../c-api/unicode.rst:1153 +#: ../../c-api/unicode.rst:1221 msgid "These are the UTF-16 codec APIs:" msgstr "這些是 UTF-16 編解碼器的 API:" -#: ../../c-api/unicode.rst:1159 +#: ../../c-api/unicode.rst:1227 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:1170 +#: ../../c-api/unicode.rst:1238 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 " @@ -1457,13 +1559,13 @@ msgid "" "result in either a ``\\ufeff`` or a ``\\ufffe`` character)." msgstr "" -#: ../../c-api/unicode.rst:1176 +#: ../../c-api/unicode.rst:1244 msgid "" "After completion, ``*byteorder`` is set to the current byte order at the end " "of input data." msgstr "" -#: ../../c-api/unicode.rst:1187 +#: ../../c-api/unicode.rst:1255 msgid "" "If *consumed* is ``NULL``, behave like :c:func:`PyUnicode_DecodeUTF16`. If " "*consumed* is not ``NULL``, :c:func:`PyUnicode_DecodeUTF16Stateful` will not " @@ -1473,28 +1575,28 @@ msgid "" "*consumed*." msgstr "" -#: ../../c-api/unicode.rst:1196 +#: ../../c-api/unicode.rst:1264 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:1202 +#: ../../c-api/unicode.rst:1270 msgid "UTF-7 Codecs" msgstr "UTF-7 編解碼器" -#: ../../c-api/unicode.rst:1204 +#: ../../c-api/unicode.rst:1272 msgid "These are the UTF-7 codec APIs:" msgstr "這些是 UTF-7 編解碼器的 API:" -#: ../../c-api/unicode.rst:1209 +#: ../../c-api/unicode.rst:1277 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:1216 +#: ../../c-api/unicode.rst:1284 msgid "" "If *consumed* is ``NULL``, behave like :c:func:`PyUnicode_DecodeUTF7`. If " "*consumed* is not ``NULL``, trailing incomplete UTF-7 base-64 sections will " @@ -1502,101 +1604,101 @@ msgid "" "of bytes that have been decoded will be stored in *consumed*." msgstr "" -#: ../../c-api/unicode.rst:1223 +#: ../../c-api/unicode.rst:1291 msgid "Unicode-Escape Codecs" msgstr "" -#: ../../c-api/unicode.rst:1225 +#: ../../c-api/unicode.rst:1293 msgid "These are the \"Unicode Escape\" codec APIs:" msgstr "" -#: ../../c-api/unicode.rst:1231 +#: ../../c-api/unicode.rst:1299 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:1237 +#: ../../c-api/unicode.rst:1305 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:1243 +#: ../../c-api/unicode.rst:1311 msgid "Raw-Unicode-Escape Codecs" msgstr "" -#: ../../c-api/unicode.rst:1245 +#: ../../c-api/unicode.rst:1313 msgid "These are the \"Raw Unicode Escape\" codec APIs:" msgstr "" -#: ../../c-api/unicode.rst:1251 +#: ../../c-api/unicode.rst:1319 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:1257 +#: ../../c-api/unicode.rst:1325 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:1263 +#: ../../c-api/unicode.rst:1331 msgid "Latin-1 Codecs" msgstr "Latin-1 編解碼器" -#: ../../c-api/unicode.rst:1265 +#: ../../c-api/unicode.rst:1333 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:1271 +#: ../../c-api/unicode.rst:1339 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:1277 +#: ../../c-api/unicode.rst:1345 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:1283 +#: ../../c-api/unicode.rst:1351 msgid "ASCII Codecs" msgstr "ASCII 編解碼器" -#: ../../c-api/unicode.rst:1285 +#: ../../c-api/unicode.rst:1353 msgid "" "These are the ASCII codec APIs. Only 7-bit ASCII data is accepted. All " "other codes generate errors." msgstr "" -#: ../../c-api/unicode.rst:1291 +#: ../../c-api/unicode.rst:1359 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:1297 +#: ../../c-api/unicode.rst:1365 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:1303 +#: ../../c-api/unicode.rst:1371 msgid "Character Map Codecs" msgstr "" -#: ../../c-api/unicode.rst:1305 +#: ../../c-api/unicode.rst:1373 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 " @@ -1606,18 +1708,18 @@ msgid "" "sequences work well." msgstr "" -#: ../../c-api/unicode.rst:1311 +#: ../../c-api/unicode.rst:1379 msgid "These are the mapping codec APIs:" msgstr "這些是對映編解碼器的 API:" -#: ../../c-api/unicode.rst:1316 +#: ../../c-api/unicode.rst:1384 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:1320 +#: ../../c-api/unicode.rst:1388 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 " @@ -1627,14 +1729,14 @@ msgid "" "treated as undefined mappings and cause an error." msgstr "" -#: ../../c-api/unicode.rst:1331 +#: ../../c-api/unicode.rst:1399 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:1335 +#: ../../c-api/unicode.rst:1403 msgid "" "The *mapping* object must map Unicode ordinal integers to bytes objects, " "integers in the range from 0 to 255 or ``None``. Unmapped character " @@ -1642,41 +1744,41 @@ msgid "" "``None`` are treated as \"undefined mapping\" and cause an error." msgstr "" -#: ../../c-api/unicode.rst:1341 +#: ../../c-api/unicode.rst:1409 msgid "The following codec API is special in that maps Unicode to Unicode." msgstr "" -#: ../../c-api/unicode.rst:1345 +#: ../../c-api/unicode.rst:1413 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:1349 +#: ../../c-api/unicode.rst:1417 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:1352 +#: ../../c-api/unicode.rst:1420 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:1356 +#: ../../c-api/unicode.rst:1424 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:1361 +#: ../../c-api/unicode.rst:1429 msgid "MBCS codecs for Windows" msgstr "Windows 的 MBCS 編解碼器" -#: ../../c-api/unicode.rst:1363 +#: ../../c-api/unicode.rst:1431 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 " @@ -1684,13 +1786,13 @@ msgid "" "is defined by the user settings on the machine running the codec." msgstr "" -#: ../../c-api/unicode.rst:1370 +#: ../../c-api/unicode.rst:1438 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:1377 +#: ../../c-api/unicode.rst:1445 msgid "" "If *consumed* is ``NULL``, behave like :c:func:`PyUnicode_DecodeMBCS`. If " "*consumed* is not ``NULL``, :c:func:`PyUnicode_DecodeMBCSStateful` will not " @@ -1698,46 +1800,46 @@ msgid "" "will be stored in *consumed*." msgstr "" -#: ../../c-api/unicode.rst:1386 +#: ../../c-api/unicode.rst:1454 msgid "" "Similar to :c:func:`PyUnicode_DecodeMBCSStateful`, except uses the code page " "specified by *code_page*." msgstr "" -#: ../../c-api/unicode.rst:1392 +#: ../../c-api/unicode.rst:1460 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:1399 +#: ../../c-api/unicode.rst:1467 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:1409 +#: ../../c-api/unicode.rst:1477 msgid "Methods and Slot Functions" msgstr "" -#: ../../c-api/unicode.rst:1411 +#: ../../c-api/unicode.rst:1479 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:1415 +#: ../../c-api/unicode.rst:1483 msgid "They all return ``NULL`` or ``-1`` if an exception occurs." msgstr "如果發生例外,則回傳 ``NULL`` 或 ``-1``。" -#: ../../c-api/unicode.rst:1420 +#: ../../c-api/unicode.rst:1488 msgid "Concat two strings giving a new Unicode string." msgstr "" -#: ../../c-api/unicode.rst:1425 +#: ../../c-api/unicode.rst:1493 msgid "" "Split a string giving a list of Unicode strings. If *sep* is ``NULL``, " "splitting will be done at all whitespace substrings. Otherwise, splits " @@ -1746,33 +1848,33 @@ msgid "" "list." msgstr "" -#: ../../c-api/unicode.rst:1430 ../../c-api/unicode.rst:1440 -#: ../../c-api/unicode.rst:1461 ../../c-api/unicode.rst:1474 +#: ../../c-api/unicode.rst:1498 ../../c-api/unicode.rst:1508 +#: ../../c-api/unicode.rst:1529 ../../c-api/unicode.rst:1542 msgid "On error, return ``NULL`` with an exception set." msgstr "於錯誤發生時回傳 ``NULL`` 並設定例外。" -#: ../../c-api/unicode.rst:1432 +#: ../../c-api/unicode.rst:1500 msgid "Equivalent to :py:meth:`str.split`." msgstr "等價於 :py:meth:`str.split`。" -#: ../../c-api/unicode.rst:1437 +#: ../../c-api/unicode.rst:1505 msgid "" "Similar to :c:func:`PyUnicode_Split`, but splitting will be done beginning " "at the end of the string." msgstr "" -#: ../../c-api/unicode.rst:1442 +#: ../../c-api/unicode.rst:1510 msgid "Equivalent to :py:meth:`str.rsplit`." msgstr "等價於 :py:meth:`str.rsplit`。" -#: ../../c-api/unicode.rst:1447 +#: ../../c-api/unicode.rst:1515 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:1454 +#: ../../c-api/unicode.rst:1522 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 " @@ -1780,39 +1882,39 @@ msgid "" "tuple containing the string itself, followed by two empty strings." msgstr "" -#: ../../c-api/unicode.rst:1459 ../../c-api/unicode.rst:1472 +#: ../../c-api/unicode.rst:1527 ../../c-api/unicode.rst:1540 msgid "*sep* must not be empty." msgstr "*sep* 不得為空。" -#: ../../c-api/unicode.rst:1463 +#: ../../c-api/unicode.rst:1531 msgid "Equivalent to :py:meth:`str.partition`." msgstr "等價於 :py:meth:`str.partition`。" -#: ../../c-api/unicode.rst:1468 +#: ../../c-api/unicode.rst:1536 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:1476 +#: ../../c-api/unicode.rst:1544 msgid "Equivalent to :py:meth:`str.rpartition`." msgstr "等價於 :py:meth:`str.rpartition`。" -#: ../../c-api/unicode.rst:1481 +#: ../../c-api/unicode.rst:1549 msgid "" "Join a sequence of strings using the given *separator* and return the " "resulting Unicode string." msgstr "" -#: ../../c-api/unicode.rst:1488 +#: ../../c-api/unicode.rst:1556 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:1496 +#: ../../c-api/unicode.rst:1564 msgid "" "Return the first position of *substr* in ``unicode[start:end]`` using the " "given *direction* (*direction* == ``1`` means to do a forward search, " @@ -1821,7 +1923,7 @@ msgid "" "``-2`` indicates that an error occurred and an exception has been set." msgstr "" -#: ../../c-api/unicode.rst:1506 +#: ../../c-api/unicode.rst:1574 msgid "" "Return the first position of the character *ch* in ``unicode[start:end]`` " "using the given *direction* (*direction* == ``1`` means to do a forward " @@ -1831,37 +1933,73 @@ msgid "" "set." msgstr "" -#: ../../c-api/unicode.rst:1514 +#: ../../c-api/unicode.rst:1582 msgid "" "*start* and *end* are now adjusted to behave like ``unicode[start:end]``." msgstr "" -#: ../../c-api/unicode.rst:1521 +#: ../../c-api/unicode.rst:1589 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:1528 +#: ../../c-api/unicode.rst:1596 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:1535 +#: ../../c-api/unicode.rst:1603 msgid "" "Compare two strings and return ``-1``, ``0``, ``1`` for less than, equal, " "and greater than, respectively." msgstr "" -#: ../../c-api/unicode.rst:1538 +#: ../../c-api/unicode.rst:1606 msgid "" "This function returns ``-1`` upon failure, so one should call :c:func:" "`PyErr_Occurred` to check for errors." msgstr "" -#: ../../c-api/unicode.rst:1544 +#: ../../c-api/unicode.rst:1611 +msgid "The :c:func:`PyUnicode_Equal` function." +msgstr ":c:func:`PyUnicode_Equal` 函式。" + +#: ../../c-api/unicode.rst:1616 +msgid "Test if two strings are equal:" +msgstr "測試兩個字串是否相等:" + +#: ../../c-api/unicode.rst:1618 +msgid "Return ``1`` if *a* is equal to *b*." +msgstr "如果 *a* 等於 *b*,則回傳 ``1``。" + +#: ../../c-api/unicode.rst:1619 +msgid "Return ``0`` if *a* is not equal to *b*." +msgstr "如果 *a* 不等於 *b*,則回傳 ``0``。" + +#: ../../c-api/unicode.rst:1620 +msgid "" +"Set a :exc:`TypeError` exception and return ``-1`` if *a* or *b* is not a :" +"class:`str` object." +msgstr "" + +#: ../../c-api/unicode.rst:1623 +msgid "The function always succeeds if *a* and *b* are :class:`str` objects." +msgstr "" + +#: ../../c-api/unicode.rst:1625 +msgid "" +"The function works for :class:`str` subclasses, but does not honor custom " +"``__eq__()`` method." +msgstr "" + +#: ../../c-api/unicode.rst:1630 +msgid "The :c:func:`PyUnicode_Compare` function." +msgstr ":c:func:`PyUnicode_Compare` 函式。" + +#: ../../c-api/unicode.rst:1637 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 " @@ -1870,18 +2008,18 @@ msgid "" "is returned." msgstr "" -#: ../../c-api/unicode.rst:1551 ../../c-api/unicode.rst:1572 +#: ../../c-api/unicode.rst:1644 ../../c-api/unicode.rst:1665 msgid "This function does not raise exceptions." msgstr "此函式不會引發例外。" -#: ../../c-api/unicode.rst:1558 +#: ../../c-api/unicode.rst:1651 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:1567 +#: ../../c-api/unicode.rst:1660 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 " @@ -1889,47 +2027,47 @@ msgid "" "string as ISO-8859-1 if it contains non-ASCII characters." msgstr "" -#: ../../c-api/unicode.rst:1577 +#: ../../c-api/unicode.rst:1670 msgid "Rich compare two Unicode strings and return one of the following:" msgstr "" -#: ../../c-api/unicode.rst:1579 +#: ../../c-api/unicode.rst:1672 msgid "``NULL`` in case an exception was raised" msgstr "" -#: ../../c-api/unicode.rst:1580 +#: ../../c-api/unicode.rst:1673 msgid ":c:data:`Py_True` or :c:data:`Py_False` for successful comparisons" msgstr "" -#: ../../c-api/unicode.rst:1581 +#: ../../c-api/unicode.rst:1674 msgid ":c:data:`Py_NotImplemented` in case the type combination is unknown" msgstr "" -#: ../../c-api/unicode.rst:1583 +#: ../../c-api/unicode.rst:1676 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:1589 +#: ../../c-api/unicode.rst:1682 msgid "" "Return a new string object from *format* and *args*; this is analogous to " "``format % args``." msgstr "" -#: ../../c-api/unicode.rst:1595 +#: ../../c-api/unicode.rst:1688 msgid "" "Check whether *substr* is contained in *unicode* and return true or false " "accordingly." msgstr "" -#: ../../c-api/unicode.rst:1598 +#: ../../c-api/unicode.rst:1691 msgid "" "*substr* has to coerce to a one element Unicode string. ``-1`` is returned " "if there was an error." msgstr "" -#: ../../c-api/unicode.rst:1604 +#: ../../c-api/unicode.rst:1697 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. " @@ -1940,7 +2078,7 @@ msgid "" "interns it." msgstr "" -#: ../../c-api/unicode.rst:1611 +#: ../../c-api/unicode.rst:1704 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; " @@ -1948,39 +2086,39 @@ msgid "" "the result.)" msgstr "" -#: ../../c-api/unicode.rst:1616 +#: ../../c-api/unicode.rst:1709 msgid "" "This function never raises an exception. On error, it leaves its argument " "unchanged without interning it." msgstr "" -#: ../../c-api/unicode.rst:1619 +#: ../../c-api/unicode.rst:1712 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:1623 +#: ../../c-api/unicode.rst:1716 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:1629 +#: ../../c-api/unicode.rst:1722 msgid "" "A combination of :c:func:`PyUnicode_FromString` and :c:func:" "`PyUnicode_InternInPlace`, meant for statically allocated strings." msgstr "" -#: ../../c-api/unicode.rst:1632 +#: ../../c-api/unicode.rst:1725 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:1636 +#: ../../c-api/unicode.rst:1729 msgid "" "Python may keep a reference to the result, or make it :term:`immortal`, " "preventing it from being garbage-collected promptly. For interning an " @@ -1988,3 +2126,229 @@ msgid "" "prefer calling :c:func:`PyUnicode_FromString` and :c:func:" "`PyUnicode_InternInPlace` directly." msgstr "" + +#: ../../c-api/unicode.rst:1738 +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:1744 +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 " +"specific string's intern-related details, may change between CPython " +"versions." +msgstr "" + +#: ../../c-api/unicode.rst:1751 +msgid "PyUnicodeWriter" +msgstr "PyUnicodeWriter" + +#: ../../c-api/unicode.rst:1753 +msgid "" +"The :c:type:`PyUnicodeWriter` API can be used to create a Python :class:" +"`str` object." +msgstr "" + +#: ../../c-api/unicode.rst:1760 +msgid "A Unicode writer instance." +msgstr "一個 Unicode 寫入器實例。" + +#: ../../c-api/unicode.rst:1762 +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:1767 +msgid "Create a Unicode writer instance." +msgstr "" + +#: ../../c-api/unicode.rst:1769 +msgid "*length* must be greater than or equal to ``0``." +msgstr "" + +#: ../../c-api/unicode.rst:1771 +msgid "" +"If *length* is greater than ``0``, preallocate an internal buffer of " +"*length* characters." +msgstr "" + +#: ../../c-api/unicode.rst:1774 ../../c-api/unicode.rst:1780 +msgid "Set an exception and return ``NULL`` on error." +msgstr "發生錯誤時,設定例外並回傳 ``NULL``。" + +#: ../../c-api/unicode.rst:1778 +msgid "" +"Return the final Python :class:`str` object and destroy the writer instance." +msgstr "" + +#: ../../c-api/unicode.rst:1782 ../../c-api/unicode.rst:1790 +msgid "The writer instance is invalid after this call." +msgstr "" + +#: ../../c-api/unicode.rst:1786 +msgid "Discard the internal Unicode buffer and destroy the writer instance." +msgstr "" + +#: ../../c-api/unicode.rst:1788 +msgid "If *writer* is ``NULL``, no operation is performed." +msgstr "" + +#: ../../c-api/unicode.rst:1794 +msgid "Write the single Unicode character *ch* into *writer*." +msgstr "" + +#: ../../c-api/unicode.rst:1796 ../../c-api/unicode.rst:1806 +#: ../../c-api/unicode.rst:1821 ../../c-api/unicode.rst:1833 +#: ../../c-api/unicode.rst:1842 ../../c-api/unicode.rst:1849 +#: ../../c-api/unicode.rst:1856 ../../c-api/unicode.rst:1867 +#: ../../c-api/unicode.rst:1874 ../../c-api/unicode.rst:1893 +msgid "" +"On success, return ``0``. On error, set an exception, leave the writer " +"unchanged, and return ``-1``." +msgstr "成功時回傳 ``0``,發生錯誤時設定例外、保持寫入器不變,並回傳 ``-1``。" + +#: ../../c-api/unicode.rst:1801 +msgid "" +"Decode the string *str* from UTF-8 in strict mode and write the output into " +"*writer*." +msgstr "" + +#: ../../c-api/unicode.rst:1803 ../../c-api/unicode.rst:1815 +#: ../../c-api/unicode.rst:1882 +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:1809 +msgid "See also :c:func:`PyUnicodeWriter_DecodeUTF8Stateful`." +msgstr "另請參閱 :c:func:`PyUnicodeWriter_DecodeUTF8Stateful`。" + +#: ../../c-api/unicode.rst:1813 +msgid "Write the ASCII string *str* into *writer*." +msgstr "" + +#: ../../c-api/unicode.rst:1818 +msgid "" +"*str* must only contain ASCII characters. The behavior is undefined if *str* " +"contains non-ASCII characters." +msgstr "" + +#: ../../c-api/unicode.rst:1828 +msgid "Write the wide string *str* into *writer*." +msgstr "" + +#: ../../c-api/unicode.rst:1830 +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:1838 +msgid "Writer the UCS4 string *str* into *writer*." +msgstr "" + +#: ../../c-api/unicode.rst:1840 +msgid "*size* is a number of UCS4 characters." +msgstr "" + +#: ../../c-api/unicode.rst:1847 +msgid "" +"Call :c:func:`PyObject_Str` on *obj* and write the output into *writer*." +msgstr "" + +#: ../../c-api/unicode.rst:1854 +msgid "" +"Call :c:func:`PyObject_Repr` on *obj* and write the output into *writer*." +msgstr "" + +#: ../../c-api/unicode.rst:1861 +msgid "Write the substring ``str[start:end]`` into *writer*." +msgstr "" + +#: ../../c-api/unicode.rst:1863 +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:1872 +msgid "" +"Similar to :c:func:`PyUnicode_FromFormat`, but write the output directly " +"into *writer*." +msgstr "類似於 :c:func:`PyUnicode_FromFormat`,但是直接將輸出寫入 *writer*。" + +#: ../../c-api/unicode.rst:1879 +msgid "" +"Decode the string *str* from UTF-8 with *errors* error handler and write the " +"output into *writer*." +msgstr "" + +#: ../../c-api/unicode.rst:1885 +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:1888 +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:1896 +msgid "See also :c:func:`PyUnicodeWriter_WriteUTF8`." +msgstr "另請參閱 :c:func:`PyUnicodeWriter_WriteUTF8`。" + +#: ../../c-api/unicode.rst:1899 +msgid "Deprecated API" +msgstr "已棄用的 API" + +#: ../../c-api/unicode.rst:1901 +msgid "The following API is deprecated." +msgstr "以下 API 已棄用。" + +#: ../../c-api/unicode.rst:1905 +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:1909 +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:1919 +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:1925 +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:1933 +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:1939 +msgid "" +"This API does nothing since Python 3.12. Previously, this could be called to " +"check if :c:func:`PyUnicode_READY` is necessary." +msgstr "" diff --git a/c-api/utilities.po b/c-api/utilities.po index 4775a245ec9..4510d3cca32 100644 --- a/c-api/utilities.po +++ b/c-api/utilities.po @@ -1,5 +1,4 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -8,7 +7,7 @@ # Phil Lin , 2022 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2018-06-26 18:54+0800\n" "PO-Revision-Date: 2022-01-31 17:38+0800\n" diff --git a/c-api/veryhigh.po b/c-api/veryhigh.po index 4901187f50d..0663dd4fc79 100644 --- a/c-api/veryhigh.po +++ b/c-api/veryhigh.po @@ -1,13 +1,12 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-08-03 00:19+0000\n" +"POT-Creation-Date: 2025-11-25 00:13+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-" @@ -33,11 +32,12 @@ msgstr "" msgid "" "Several of these functions accept a start symbol from the grammar as a " "parameter. The available start symbols are :c:data:`Py_eval_input`, :c:data:" -"`Py_file_input`, and :c:data:`Py_single_input`. These are described " -"following the functions which accept them as parameters." +"`Py_file_input`, :c:data:`Py_single_input`, and :c:data:" +"`Py_func_type_input`. These are described following the functions which " +"accept them as parameters." msgstr "" -#: ../../c-api/veryhigh.rst:19 +#: ../../c-api/veryhigh.rst:20 msgid "" "Note also that several of these functions take :c:expr:`FILE*` parameters. " "One particular issue which needs to be handled carefully is that the :c:type:" @@ -49,25 +49,25 @@ msgid "" "runtime is using." msgstr "" -#: ../../c-api/veryhigh.rst:30 +#: ../../c-api/veryhigh.rst:31 msgid "" "This is a simplified interface to :c:func:`PyRun_AnyFileExFlags` below, " "leaving *closeit* set to ``0`` and *flags* set to ``NULL``." msgstr "" -#: ../../c-api/veryhigh.rst:36 +#: ../../c-api/veryhigh.rst:37 msgid "" "This is a simplified interface to :c:func:`PyRun_AnyFileExFlags` below, " "leaving the *closeit* argument set to ``0``." msgstr "" -#: ../../c-api/veryhigh.rst:42 +#: ../../c-api/veryhigh.rst:43 msgid "" "This is a simplified interface to :c:func:`PyRun_AnyFileExFlags` below, " "leaving the *flags* argument set to ``NULL``." msgstr "" -#: ../../c-api/veryhigh.rst:48 +#: ../../c-api/veryhigh.rst:49 msgid "" "If *fp* refers to a file associated with an interactive device (console or " "terminal input or Unix pseudo-terminal), return the value of :c:func:" @@ -78,13 +78,13 @@ msgid "" "before ``PyRun_SimpleFileExFlags()`` returns." msgstr "" -#: ../../c-api/veryhigh.rst:60 +#: ../../c-api/veryhigh.rst:61 msgid "" "This is a simplified interface to :c:func:`PyRun_SimpleStringFlags` below, " "leaving the :c:struct:`PyCompilerFlags`\\* argument set to ``NULL``." msgstr "" -#: ../../c-api/veryhigh.rst:66 +#: ../../c-api/veryhigh.rst:67 msgid "" "Executes the Python source code from *command* in the :mod:`__main__` module " "according to the *flags* argument. If :mod:`__main__` does not already " @@ -93,26 +93,26 @@ msgid "" "information. For the meaning of *flags*, see below." msgstr "" -#: ../../c-api/veryhigh.rst:72 +#: ../../c-api/veryhigh.rst:73 msgid "" "Note that if an otherwise unhandled :exc:`SystemExit` is raised, this " "function will not return ``-1``, but exit the process, as long as :c:member:" "`PyConfig.inspect` is zero." msgstr "" -#: ../../c-api/veryhigh.rst:79 +#: ../../c-api/veryhigh.rst:80 msgid "" "This is a simplified interface to :c:func:`PyRun_SimpleFileExFlags` below, " "leaving *closeit* set to ``0`` and *flags* set to ``NULL``." msgstr "" -#: ../../c-api/veryhigh.rst:85 +#: ../../c-api/veryhigh.rst:86 msgid "" "This is a simplified interface to :c:func:`PyRun_SimpleFileExFlags` below, " "leaving *flags* set to ``NULL``." msgstr "" -#: ../../c-api/veryhigh.rst:91 +#: ../../c-api/veryhigh.rst:92 msgid "" "Similar to :c:func:`PyRun_SimpleStringFlags`, but the Python source code is " "read from *fp* instead of an in-memory string. *filename* should be the name " @@ -121,28 +121,22 @@ msgid "" "``PyRun_SimpleFileExFlags()`` returns." msgstr "" -#: ../../c-api/veryhigh.rst:98 +#: ../../c-api/veryhigh.rst:99 msgid "" "On Windows, *fp* should be opened as binary mode (e.g. ``fopen(filename, " "\"rb\")``). Otherwise, Python may not handle script file with LF line ending " "correctly." msgstr "" -#: ../../c-api/veryhigh.rst:104 -msgid "" -"This is a simplified interface to :c:func:`PyRun_InteractiveOneFlags` below, " -"leaving *flags* set to ``NULL``." -msgstr "" - -#: ../../c-api/veryhigh.rst:110 +#: ../../c-api/veryhigh.rst:105 msgid "" "Read and execute a single statement from a file associated with an " "interactive device according to the *flags* argument. The user will be " -"prompted using ``sys.ps1`` and ``sys.ps2``. *filename* is decoded from the :" -"term:`filesystem encoding and error handler`." +"prompted using ``sys.ps1`` and ``sys.ps2``. *filename* must be a Python :" +"class:`str` object." msgstr "" -#: ../../c-api/veryhigh.rst:115 +#: ../../c-api/veryhigh.rst:110 msgid "" "Returns ``0`` when the input was executed successfully, ``-1`` if there was " "an exception, or an error code from the :file:`errcode.h` include file " @@ -151,13 +145,26 @@ msgid "" "specifically if needed.)" msgstr "" -#: ../../c-api/veryhigh.rst:124 +#: ../../c-api/veryhigh.rst:119 +msgid "" +"This is a simplified interface to :c:func:`PyRun_InteractiveOneFlags` below, " +"leaving *flags* set to ``NULL``." +msgstr "" + +#: ../../c-api/veryhigh.rst:125 +msgid "" +"Similar to :c:func:`PyRun_InteractiveOneObject`, but *filename* is a :c:expr:" +"`const char*`, which is decoded from the :term:`filesystem encoding and " +"error handler`." +msgstr "" + +#: ../../c-api/veryhigh.rst:132 msgid "" "This is a simplified interface to :c:func:`PyRun_InteractiveLoopFlags` " "below, leaving *flags* set to ``NULL``." msgstr "" -#: ../../c-api/veryhigh.rst:130 +#: ../../c-api/veryhigh.rst:138 msgid "" "Read and execute statements from a file associated with an interactive " "device until EOF is reached. The user will be prompted using ``sys.ps1`` " @@ -165,23 +172,23 @@ msgid "" "and error handler`. Returns ``0`` at EOF or a negative number upon failure." msgstr "" -#: ../../c-api/veryhigh.rst:138 +#: ../../c-api/veryhigh.rst:146 msgid "" "Can be set to point to a function with the prototype ``int func(void)``. " "The function will be called when Python's interpreter prompt is about to " "become idle and wait for user input from the terminal. The return value is " "ignored. Overriding this hook can be used to integrate the interpreter's " -"prompt with other event loops, as done in the :file:`Modules/_tkinter.c` in " -"the Python source code." +"prompt with other event loops, as done in :file:`Modules/_tkinter.c` in the " +"Python source code." msgstr "" -#: ../../c-api/veryhigh.rst:146 ../../c-api/veryhigh.rst:170 +#: ../../c-api/veryhigh.rst:154 ../../c-api/veryhigh.rst:178 msgid "" "This function is only called from the :ref:`main interpreter `." msgstr "" -#: ../../c-api/veryhigh.rst:153 +#: ../../c-api/veryhigh.rst:161 msgid "" "Can be set to point to a function with the prototype ``char *func(FILE " "*stdin, FILE *stdout, char *prompt)``, overriding the default function used " @@ -192,59 +199,59 @@ msgid "" "line-editing and tab-completion features." msgstr "" -#: ../../c-api/veryhigh.rst:162 +#: ../../c-api/veryhigh.rst:170 msgid "" "The result must be a string allocated by :c:func:`PyMem_RawMalloc` or :c:" "func:`PyMem_RawRealloc`, or ``NULL`` if an error occurred." msgstr "" -#: ../../c-api/veryhigh.rst:165 +#: ../../c-api/veryhigh.rst:173 msgid "" "The result must be allocated by :c:func:`PyMem_RawMalloc` or :c:func:" "`PyMem_RawRealloc`, instead of being allocated by :c:func:`PyMem_Malloc` or :" "c:func:`PyMem_Realloc`." msgstr "" -#: ../../c-api/veryhigh.rst:176 +#: ../../c-api/veryhigh.rst:184 msgid "" "This is a simplified interface to :c:func:`PyRun_StringFlags` below, leaving " "*flags* set to ``NULL``." msgstr "" -#: ../../c-api/veryhigh.rst:182 +#: ../../c-api/veryhigh.rst:190 msgid "" "Execute Python source code from *str* in the context specified by the " "objects *globals* and *locals* with the compiler flags specified by " "*flags*. *globals* must be a dictionary; *locals* can be any object that " "implements the mapping protocol. The parameter *start* specifies the start " -"token that should be used to parse the source code." +"symbol and must one of the :ref:`available start symbols `." msgstr "" -#: ../../c-api/veryhigh.rst:188 +#: ../../c-api/veryhigh.rst:196 msgid "" "Returns the result of executing the code as a Python object, or ``NULL`` if " "an exception was raised." msgstr "" -#: ../../c-api/veryhigh.rst:194 +#: ../../c-api/veryhigh.rst:202 msgid "" "This is a simplified interface to :c:func:`PyRun_FileExFlags` below, leaving " "*closeit* set to ``0`` and *flags* set to ``NULL``." msgstr "" -#: ../../c-api/veryhigh.rst:200 +#: ../../c-api/veryhigh.rst:208 msgid "" "This is a simplified interface to :c:func:`PyRun_FileExFlags` below, leaving " "*flags* set to ``NULL``." msgstr "" -#: ../../c-api/veryhigh.rst:206 +#: ../../c-api/veryhigh.rst:214 msgid "" "This is a simplified interface to :c:func:`PyRun_FileExFlags` below, leaving " "*closeit* set to ``0``." msgstr "" -#: ../../c-api/veryhigh.rst:212 +#: ../../c-api/veryhigh.rst:220 msgid "" "Similar to :c:func:`PyRun_StringFlags`, but the Python source code is read " "from *fp* instead of an in-memory string. *filename* should be the name of " @@ -253,30 +260,30 @@ msgid "" "`PyRun_FileExFlags` returns." msgstr "" -#: ../../c-api/veryhigh.rst:221 +#: ../../c-api/veryhigh.rst:229 msgid "" "This is a simplified interface to :c:func:`Py_CompileStringFlags` below, " "leaving *flags* set to ``NULL``." msgstr "" -#: ../../c-api/veryhigh.rst:227 +#: ../../c-api/veryhigh.rst:235 msgid "" "This is a simplified interface to :c:func:`Py_CompileStringExFlags` below, " "with *optimize* set to ``-1``." msgstr "" -#: ../../c-api/veryhigh.rst:233 +#: ../../c-api/veryhigh.rst:241 msgid "" "Parse and compile the Python source code in *str*, returning the resulting " -"code object. The start token is given by *start*; this can be used to " -"constrain the code which can be compiled and should be :c:data:" -"`Py_eval_input`, :c:data:`Py_file_input`, or :c:data:`Py_single_input`. The " -"filename specified by *filename* is used to construct the code object and " -"may appear in tracebacks or :exc:`SyntaxError` exception messages. This " -"returns ``NULL`` if the code cannot be parsed or compiled." +"code object. The start symbol is given by *start*; this can be used to " +"constrain the code which can be compiled and should be :ref:`available start " +"symbols `. The filename specified by *filename* is used to " +"construct the code object and may appear in tracebacks or :exc:`SyntaxError` " +"exception messages. This returns ``NULL`` if the code cannot be parsed or " +"compiled." msgstr "" -#: ../../c-api/veryhigh.rst:241 +#: ../../c-api/veryhigh.rst:249 msgid "" "The integer *optimize* specifies the optimization level of the compiler; a " "value of ``-1`` selects the optimization level of the interpreter as given " @@ -285,20 +292,20 @@ msgid "" "or ``2`` (docstrings are removed too)." msgstr "" -#: ../../c-api/veryhigh.rst:252 +#: ../../c-api/veryhigh.rst:260 msgid "" "Like :c:func:`Py_CompileStringObject`, but *filename* is a byte string " "decoded from the :term:`filesystem encoding and error handler`." msgstr "" -#: ../../c-api/veryhigh.rst:259 +#: ../../c-api/veryhigh.rst:267 msgid "" "This is a simplified interface to :c:func:`PyEval_EvalCodeEx`, with just the " "code object, and global and local variables. The other arguments are set to " "``NULL``." msgstr "" -#: ../../c-api/veryhigh.rst:266 +#: ../../c-api/veryhigh.rst:274 msgid "" "Evaluate a precompiled code object, given a particular environment for its " "evaluation. This environment consists of a dictionary of global variables, " @@ -307,13 +314,13 @@ msgid "" "only_parameter>` arguments and a closure tuple of cells." msgstr "" -#: ../../c-api/veryhigh.rst:275 +#: ../../c-api/veryhigh.rst:283 msgid "" "Evaluate an execution frame. This is a simplified interface to :c:func:" "`PyEval_EvalFrameEx`, for backward compatibility." msgstr "" -#: ../../c-api/veryhigh.rst:281 +#: ../../c-api/veryhigh.rst:289 msgid "" "This is the main, unvarnished function of Python interpretation. The code " "object associated with the execution frame *f* is executed, interpreting " @@ -323,39 +330,19 @@ msgid "" "of generator objects." msgstr "" -#: ../../c-api/veryhigh.rst:288 +#: ../../c-api/veryhigh.rst:296 msgid "" "This function now includes a debug assertion to help ensure that it does not " "silently discard an active exception." msgstr "" -#: ../../c-api/veryhigh.rst:295 +#: ../../c-api/veryhigh.rst:303 msgid "" "This function changes the flags of the current evaluation frame, and returns " "true on success, false on failure." msgstr "" -#: ../../c-api/veryhigh.rst:303 -msgid "" -"The start symbol from the Python grammar for isolated expressions; for use " -"with :c:func:`Py_CompileString`." -msgstr "" - -#: ../../c-api/veryhigh.rst:311 -msgid "" -"The start symbol from the Python grammar for sequences of statements as read " -"from a file or other source; for use with :c:func:`Py_CompileString`. This " -"is the symbol to use when compiling arbitrarily long Python source code." -msgstr "" - -#: ../../c-api/veryhigh.rst:320 -msgid "" -"The start symbol from the Python grammar for a single statement; for use " -"with :c:func:`Py_CompileString`. This is the symbol used for the interactive " -"interpreter loop." -msgstr "" - -#: ../../c-api/veryhigh.rst:327 +#: ../../c-api/veryhigh.rst:309 msgid "" "This is the structure used to hold compiler flags. In cases where code is " "only being compiled, it is passed as ``int flags``, and in cases where code " @@ -363,44 +350,44 @@ msgid "" "case, ``from __future__ import`` can modify *flags*." msgstr "" -#: ../../c-api/veryhigh.rst:332 +#: ../../c-api/veryhigh.rst:314 msgid "" "Whenever ``PyCompilerFlags *flags`` is ``NULL``, :c:member:`~PyCompilerFlags." "cf_flags` is treated as equal to ``0``, and any modification due to ``from " "__future__ import`` is discarded." msgstr "" -#: ../../c-api/veryhigh.rst:338 +#: ../../c-api/veryhigh.rst:320 msgid "Compiler flags." -msgstr "" +msgstr "編譯器旗標。" -#: ../../c-api/veryhigh.rst:342 +#: ../../c-api/veryhigh.rst:324 msgid "" "*cf_feature_version* is the minor Python version. It should be initialized " "to ``PY_MINOR_VERSION``." msgstr "" -#: ../../c-api/veryhigh.rst:345 +#: ../../c-api/veryhigh.rst:327 msgid "" "The field is ignored by default, it is used if and only if ``PyCF_ONLY_AST`` " "flag is set in :c:member:`~PyCompilerFlags.cf_flags`." msgstr "" -#: ../../c-api/veryhigh.rst:348 +#: ../../c-api/veryhigh.rst:330 msgid "Added *cf_feature_version* field." msgstr "新增 *cf_feature_version* 欄位。" -#: ../../c-api/veryhigh.rst:351 +#: ../../c-api/veryhigh.rst:333 msgid "The available compiler flags are accessible as macros:" -msgstr "" +msgstr "可用的編譯器旗標可透過巨集存取:" -#: ../../c-api/veryhigh.rst:360 +#: ../../c-api/veryhigh.rst:342 msgid "" "See :ref:`compiler flags ` in documentation of the :py:" "mod:`!ast` Python module, which exports these constants under the same names." msgstr "" -#: ../../c-api/veryhigh.rst:364 +#: ../../c-api/veryhigh.rst:346 msgid "" "The \"``PyCF``\" flags above can be combined with \"``CO_FUTURE``\" flags " "such as :c:macro:`CO_FUTURE_ANNOTATIONS` to enable features normally " @@ -408,7 +395,88 @@ msgid "" "`c_codeobject_flags` for a complete list." msgstr "" -#: ../../c-api/veryhigh.rst:301 ../../c-api/veryhigh.rst:309 -#: ../../c-api/veryhigh.rst:318 +#: ../../c-api/veryhigh.rst:355 +msgid "Available start symbols" +msgstr "可用的起始符號" + +#: ../../c-api/veryhigh.rst:362 +msgid "" +"The start symbol from the Python grammar for isolated expressions; for use " +"with :c:func:`Py_CompileString`." +msgstr "" + +#: ../../c-api/veryhigh.rst:370 +msgid "" +"The start symbol from the Python grammar for sequences of statements as read " +"from a file or other source; for use with :c:func:`Py_CompileString`. This " +"is the symbol to use when compiling arbitrarily long Python source code." +msgstr "" + +#: ../../c-api/veryhigh.rst:379 +msgid "" +"The start symbol from the Python grammar for a single statement; for use " +"with :c:func:`Py_CompileString`. This is the symbol used for the interactive " +"interpreter loop." +msgstr "" + +#: ../../c-api/veryhigh.rst:388 +msgid "" +"The start symbol from the Python grammar for a function type; for use with :" +"c:func:`Py_CompileString`. This is used to parse \"signature type comments\" " +"from :pep:`484`." +msgstr "" + +#: ../../c-api/veryhigh.rst:392 +msgid "This requires the :c:macro:`PyCF_ONLY_AST` flag to be set." +msgstr "這需要設定 :c:macro:`PyCF_ONLY_AST` 旗標。" + +#: ../../c-api/veryhigh.rst:395 +msgid ":py:class:`ast.FunctionType`" +msgstr ":py:class:`ast.FunctionType`" + +#: ../../c-api/veryhigh.rst:396 +msgid ":pep:`484`" +msgstr ":pep:`484`" + +#: ../../c-api/veryhigh.rst:402 +msgid "Stack Effects" +msgstr "" + +#: ../../c-api/veryhigh.rst:405 +msgid ":py:func:`dis.stack_effect`" +msgstr ":py:func:`dis.stack_effect`" + +#: ../../c-api/veryhigh.rst:410 +msgid "Sentinel value representing an invalid stack effect." +msgstr "" + +#: ../../c-api/veryhigh.rst:412 +msgid "This is currently equivalent to ``INT_MAX``." +msgstr "這目前等同於 ``INT_MAX``。" + +#: ../../c-api/veryhigh.rst:419 +msgid "Compute the stack effect of *opcode* with argument *oparg*." +msgstr "" + +#: ../../c-api/veryhigh.rst:421 ../../c-api/veryhigh.rst:435 +msgid "" +"On success, this function returns the stack effect; on failure, this " +"returns :c:macro:`PY_INVALID_STACK_EFFECT`." +msgstr "" + +#: ../../c-api/veryhigh.rst:429 +msgid "" +"Similar to :c:func:`PyCompile_OpcodeStackEffect`, but don't include the " +"stack effect of jumping if *jump* is zero." +msgstr "" + +#: ../../c-api/veryhigh.rst:432 +msgid "" +"If *jump* is ``0``, this will not include the stack effect of jumping, but " +"if *jump* is ``1`` or ``-1``, this will include it." +msgstr "" + +#: ../../c-api/veryhigh.rst:360 ../../c-api/veryhigh.rst:368 +#: ../../c-api/veryhigh.rst:377 ../../c-api/veryhigh.rst:386 msgid "Py_CompileString (C function)" msgstr "Py_CompileString(C 函式)" diff --git a/c-api/weakref.po b/c-api/weakref.po index 7bbbcb9f449..a6cc8552730 100644 --- a/c-api/weakref.po +++ b/c-api/weakref.po @@ -1,14 +1,13 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Leon H., 2017 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-11-13 00:15+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-" @@ -39,16 +38,22 @@ msgstr "" #: ../../c-api/weakref.rst:22 msgid "" -"Return non-zero if *ob* is a reference object. This function always " -"succeeds." +"Return non-zero if *ob* is a reference object or a subclass of the reference " +"type. This function always succeeds." msgstr "" -#: ../../c-api/weakref.rst:27 +#: ../../c-api/weakref.rst:28 +msgid "" +"Return non-zero if *ob* is a reference object, but not a subclass of the " +"reference type. This function always succeeds." +msgstr "" + +#: ../../c-api/weakref.rst:34 msgid "" "Return non-zero if *ob* is a proxy object. This function always succeeds." msgstr "" -#: ../../c-api/weakref.rst:32 +#: ../../c-api/weakref.rst:39 msgid "" "Return a weak reference object for the object *ob*. This will always return " "a new reference, but is not guaranteed to create a new object; an existing " @@ -60,7 +65,13 @@ msgid "" "``NULL``, this will return ``NULL`` and raise :exc:`TypeError`." msgstr "" -#: ../../c-api/weakref.rst:44 +#: ../../c-api/weakref.rst:49 ../../c-api/weakref.rst:65 +msgid "" +":c:func:`PyType_SUPPORTS_WEAKREFS` for checking if *ob* is weakly " +"referenceable." +msgstr "" + +#: ../../c-api/weakref.rst:55 msgid "" "Return a weak reference proxy object for the object *ob*. This will always " "return a new reference, but is not guaranteed to create a new object; an " @@ -72,33 +83,33 @@ msgid "" "``None``, or ``NULL``, this will return ``NULL`` and raise :exc:`TypeError`." msgstr "" -#: ../../c-api/weakref.rst:56 +#: ../../c-api/weakref.rst:71 msgid "" "Get a :term:`strong reference` to the referenced object from a weak " "reference, *ref*, into *\\*pobj*." msgstr "" -#: ../../c-api/weakref.rst:59 +#: ../../c-api/weakref.rst:74 msgid "" "On success, set *\\*pobj* to a new :term:`strong reference` to the " "referenced object and return 1." msgstr "" -#: ../../c-api/weakref.rst:61 +#: ../../c-api/weakref.rst:76 msgid "If the reference is dead, set *\\*pobj* to ``NULL`` and return 0." msgstr "" -#: ../../c-api/weakref.rst:62 +#: ../../c-api/weakref.rst:77 msgid "On error, raise an exception and return -1." msgstr "" -#: ../../c-api/weakref.rst:69 +#: ../../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:74 +#: ../../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 " @@ -106,32 +117,39 @@ msgid "" "reference." msgstr "" -#: ../../c-api/weakref.rst:79 ../../c-api/weakref.rst:87 +#: ../../c-api/weakref.rst:94 ../../c-api/weakref.rst:102 msgid "Use :c:func:`PyWeakref_GetRef` instead." msgstr "" -#: ../../c-api/weakref.rst:85 +#: ../../c-api/weakref.rst:100 msgid "Similar to :c:func:`PyWeakref_GetObject`, but does no error checking." msgstr "" -#: ../../c-api/weakref.rst:93 +#: ../../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 msgid "" "This function is called by the :c:member:`~PyTypeObject.tp_dealloc` handler " "to clear weak references." msgstr "" -#: ../../c-api/weakref.rst:96 +#: ../../c-api/weakref.rst:120 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:103 +#: ../../c-api/weakref.rst:127 msgid "Clears the weakrefs for *object* without calling the callbacks." msgstr "" -#: ../../c-api/weakref.rst:105 +#: ../../c-api/weakref.rst:129 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 " @@ -140,7 +158,7 @@ msgid "" "clear any weakrefs that may have been created by the finalizer." msgstr "" -#: ../../c-api/weakref.rst:111 +#: ../../c-api/weakref.rst:135 msgid "" "In most circumstances, it's more appropriate to use :c:func:" "`PyObject_ClearWeakRefs` to clear weakrefs instead of this function." diff --git a/contents.po b/contents.po index 3312166d6f2..c7d37814e74 100644 --- a/contents.po +++ b/contents.po @@ -1,5 +1,4 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -7,7 +6,7 @@ # Liang-Bo Wang , 2015 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2018-06-26 18:54+0800\n" "PO-Revision-Date: 2017-09-22 18:26+0000\n" diff --git a/copyright.po b/copyright.po index 50a39fdee2a..b19aacbaaf3 100644 --- a/copyright.po +++ b/copyright.po @@ -1,5 +1,4 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2023, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -9,9 +8,9 @@ # meowmeowcat , 2021 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-09-08 15:25+0800\n" "PO-Revision-Date: 2021-06-25 20:17+0800\n" "Last-Translator: meowmeowcat \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -32,25 +31,25 @@ msgid "Python and this documentation is:" msgstr "Python 和這份說明文件的版權:" #: ../../copyright.rst:7 -msgid "Copyright © 2001-2024 Python Software Foundation. All rights reserved." -msgstr "Copyright © 2001-2024 Python Software Foundation. All rights reserved." +msgid "Copyright © 2001 Python Software Foundation. All rights reserved." +msgstr "Copyright © 2001 Python 軟體基金會。保留所有權利。" #: ../../copyright.rst:9 msgid "Copyright © 2000 BeOpen.com. All rights reserved." -msgstr "Copyright © 2000 BeOpen.com 保留一切權利。" +msgstr "Copyright © 2000 BeOpen.com 保留所有權利。" #: ../../copyright.rst:11 msgid "" "Copyright © 1995-2000 Corporation for National Research Initiatives. All " "rights reserved." msgstr "" -"Copyright © 1995-2000 Corporation for National Research Initiatives 保留一切" +"Copyright © 1995-2000 Corporation for National Research Initiatives 保留所有" "權利。" #: ../../copyright.rst:14 msgid "" "Copyright © 1991-1995 Stichting Mathematisch Centrum. All rights reserved." -msgstr "Copyright © 1991-1995 Stichting Mathematisch Centrum 保留一切權利。" +msgstr "Copyright © 1991-1995 Stichting Mathematisch Centrum 保留所有權利。" #: ../../copyright.rst:18 msgid "" diff --git a/deprecations/c-api-pending-removal-in-3.14.po b/deprecations/c-api-pending-removal-in-3.14.po index 85417537877..8a9ae15c7ce 100644 --- a/deprecations/c-api-pending-removal-in-3.14.po +++ b/deprecations/c-api-pending-removal-in-3.14.po @@ -1,11 +1,11 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-24 07:20+0000\n" +"POT-Creation-Date: 2025-09-08 15:25+0800\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-" @@ -16,7 +16,7 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" #: ../../deprecations/c-api-pending-removal-in-3.14.rst:2 -msgid "Pending Removal in Python 3.14" +msgid "Pending removal in Python 3.14" msgstr "Python 3.14 中待移除的項目" #: ../../deprecations/c-api-pending-removal-in-3.14.rst:4 @@ -34,175 +34,3 @@ msgid "" msgstr "" "使用可變基底建立\\ :c:data:`不可變型別 ` " "(:gh:`95388`)。" - -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:10 -msgid "" -"Functions to configure Python's initialization, deprecated in Python 3.11:" -msgstr "設定 Python 初始化的函式,Python 3.11 中已被棄用:" - -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:12 -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.14.rst:14 -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.14.rst:16 -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.14.rst:18 -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.14.rst:21 -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:71 -msgid "" -"The :c:func:`Py_InitializeFromConfig` API should be used " -"with :c:type:`PyConfig` instead." -msgstr "" -":c:func:`Py_InitializeFromConfig` API 應該與 :c:type:`PyConfig` 一起使用。" - -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:24 -msgid "Global configuration variables:" -msgstr "全域設定變數:" - -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:26 -msgid ":c:var:`Py_DebugFlag`: Use :c:member:`PyConfig.parser_debug` instead." -msgstr ":c:var:`Py_DebugFlag`:請改用 :c:member:`PyConfig.parser_debug`。" - -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:28 -msgid ":c:var:`Py_VerboseFlag`: Use :c:member:`PyConfig.verbose` instead." -msgstr ":c:var:`Py_VerboseFlag`:請改用 :c:member:`PyConfig.verbose`。" - -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:30 -msgid ":c:var:`Py_QuietFlag`: Use :c:member:`PyConfig.quiet` instead." -msgstr ":c:var:`Py_QuietFlag`:請改用 :c:member:`PyConfig.quiet`。" - -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:32 -msgid "" -":c:var:`Py_InteractiveFlag`: Use :c:member:`PyConfig.interactive` instead." -msgstr ":c:var:`Py_InteractiveFlag`:請改用 :c:member:`PyConfig.interactive`。" - -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:34 -msgid ":c:var:`Py_InspectFlag`: Use :c:member:`PyConfig.inspect` instead." -msgstr ":c:var:`Py_InspectFlag`:請改用 :c:member:`PyConfig.inspect`。" - -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:36 -msgid "" -":c:var:`Py_OptimizeFlag`: Use :c:member:`PyConfig.optimization_level` " -"instead." -msgstr "" -":c:var:`Py_OptimizeFlag`:請改用 :c:member:`PyConfig.optimization_level`。" - -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:38 -msgid ":c:var:`Py_NoSiteFlag`: Use :c:member:`PyConfig.site_import` instead." -msgstr ":c:var:`Py_NoSiteFlag`:請改用 :c:member:`PyConfig.site_import`。" - -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:40 -msgid "" -":c:var:`Py_BytesWarningFlag`: Use :c:member:`PyConfig.bytes_warning` instead." -msgstr "" -":c:var:`Py_BytesWarningFlag`:請改用 :c:member:`PyConfig.bytes_warning`。" - -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:42 -msgid "" -":c:var:`Py_FrozenFlag`: Use :c:member:`PyConfig.pathconfig_warnings` instead." -msgstr "" -":c:var:`Py_FrozenFlag`:請改用 :c:member:`PyConfig.pathconfig_warnings`。" - -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:44 -msgid "" -":c:var:`Py_IgnoreEnvironmentFlag`: Use :c:member:`PyConfig.use_environment` " -"instead." -msgstr "" -":c:var:`Py_IgnoreEnvironmentFlag`:請改" -"用 :c:member:`PyConfig.use_environment`。" - -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:46 -msgid "" -":c:var:`Py_DontWriteBytecodeFlag`: Use :c:member:`PyConfig.write_bytecode` " -"instead." -msgstr "" -":c:var:`Py_DontWriteBytecodeFlag`:請改" -"用 :c:member:`PyConfig.write_bytecode`。" - -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:48 -msgid "" -":c:var:`Py_NoUserSiteDirectory`: " -"Use :c:member:`PyConfig.user_site_directory` instead." -msgstr "" -":c:var:`Py_NoUserSiteDirectory`:請改" -"用 :c:member:`PyConfig.user_site_directory`。" - -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:50 -msgid "" -":c:var:`Py_UnbufferedStdioFlag`: Use :c:member:`PyConfig.buffered_stdio` " -"instead." -msgstr "" -":c:var:`Py_UnbufferedStdioFlag`:請改用 :c:member:`PyConfig.buffered_stdio`。" - -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:52 -msgid "" -":c:var:`Py_HashRandomizationFlag`: Use :c:member:`PyConfig.use_hash_seed` " -"and :c:member:`PyConfig.hash_seed` instead." -msgstr "" -":c:var:`Py_HashRandomizationFlag`:請改用 :c:member:`PyConfig.use_hash_seed` " -"和 :c:member:`PyConfig.hash_seed`。" - -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:55 -msgid ":c:var:`Py_IsolatedFlag`: Use :c:member:`PyConfig.isolated` instead." -msgstr ":c:var:`Py_IsolatedFlag`:請改用 :c:member:`PyConfig.isolated`。" - -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:57 -msgid "" -":c:var:`Py_LegacyWindowsFSEncodingFlag`: " -"Use :c:member:`PyPreConfig.legacy_windows_fs_encoding` instead." -msgstr "" -":c:var:`Py_LegacyWindowsFSEncodingFlag`:請改" -"用 :c:member:`PyPreConfig.legacy_windows_fs_encoding`。" - -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:59 -msgid "" -":c:var:`Py_LegacyWindowsStdioFlag`: " -"Use :c:member:`PyConfig.legacy_windows_stdio` instead." -msgstr "" -":c:var:`Py_LegacyWindowsStdioFlag`:請改" -"用 :c:member:`PyConfig.legacy_windows_stdio`。" - -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:61 -msgid "" -":c:var:`!Py_FileSystemDefaultEncoding`: " -"Use :c:member:`PyConfig.filesystem_encoding` instead." -msgstr "" -":c:var:`!Py_FileSystemDefaultEncoding`:請改" -"用 :c:member:`PyConfig.filesystem_encoding`。" - -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:63 -msgid "" -":c:var:`!Py_HasFileSystemDefaultEncoding`: " -"Use :c:member:`PyConfig.filesystem_encoding` instead." -msgstr "" -":c:var:`!Py_HasFileSystemDefaultEncoding`:請改" -"用 :c:member:`PyConfig.filesystem_encoding`。" - -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:65 -msgid "" -":c:var:`!Py_FileSystemDefaultEncodeErrors`: " -"Use :c:member:`PyConfig.filesystem_errors` instead." -msgstr "" -":c:var:`!Py_FileSystemDefaultEncodeErrors`:請改" -"用 :c:member:`PyConfig.filesystem_errors`。" - -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:67 -msgid "" -":c:var:`!Py_UTF8Mode`: Use :c:member:`PyPreConfig.utf8_mode` instead. " -"(see :c:func:`Py_PreInitialize`)" -msgstr "" -":c:var:`!Py_UTF8Mode`:請改用 :c:member:`PyPreConfig.utf8_mode`。(請" -"見 :c:func:`Py_PreInitialize`)" diff --git a/deprecations/c-api-pending-removal-in-3.15.po b/deprecations/c-api-pending-removal-in-3.15.po index 362a44992bc..34f2be4674d 100644 --- a/deprecations/c-api-pending-removal-in-3.15.po +++ b/deprecations/c-api-pending-removal-in-3.15.po @@ -1,11 +1,11 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-07-03 00:17+0000\n" +"POT-Creation-Date: 2025-09-08 15:25+0800\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-" @@ -16,77 +16,367 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" #: ../../deprecations/c-api-pending-removal-in-3.15.rst:2 -msgid "Pending Removal in Python 3.15" +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:" -"`PyImport_ImportModule` instead." +"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:" -"func:`PyWeakref_GetRef` instead." +":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`。" +":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:8 +#: ../../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." +":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:10 -msgid "Python initialization functions:" -msgstr "Python 初始化函式:" +":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 +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 "" +":c:func:`!PyUnicode_AsDecodedUnicode`:請改用 :c:func:`PyCodec_Decode`;請注" +"意某些編解碼器(例如 \"base64\")可能會回傳非 :class:`str` 的型別,例" +"如 :class:`bytes`。" + +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:17 +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 +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 "" +":c:func:`!PyUnicode_AsEncodedUnicode`:請改用 :c:func:`PyCodec_Encode`;請注" +"意某些編解碼器(例如 \"base64\")可能會回傳非 :class:`bytes` 的型別,例" +"如 :class:`str`。" + +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:22 +msgid "Python initialization functions, deprecated in Python 3.13:" +msgstr "Python 初始化函式,自 Python 3.13 起已被棄用:" + +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:24 +msgid "" +":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\") " +"` (:data:`sys.path`)。" + +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:27 +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 "" +":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 +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 "" +":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 +msgid "" +":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`)。" + +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:41 +msgid "" +":c:func:`Py_GetProgramName`: Use :c:func:`PyConfig_Get(\"executable\") " +"` (:data:`sys.executable`) instead." +msgstr "" +":c:func:`Py_GetProgramName`:請改用 :c:func:`PyConfig_Get(\"executable\") " +"` (:data:`sys.executable`)。" + +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:44 +msgid "" +":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\") " +"` 或 :envvar:`PYTHONHOME` 環境變數。" + +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:48 +msgid "" +"The `pythoncapi-compat project `__ can be used to get :c:func:`PyConfig_Get` on Python 3.13 and older." +msgstr "" +"`pythoncapi-compat 專案 `__ 可" +"以用來為 Python 3.13 和更早版本取得 :c:func:`PyConfig_Get`。" + +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:52 +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 +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 +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 +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 +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 +msgid "" ":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:14 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:65 msgid "" -":c:func:`Py_GetExecPrefix`: Get :data:`sys.base_exec_prefix` and :data:`sys." -"exec_prefix` instead." +"The :c:func:`Py_InitializeFromConfig` API should be used " +"with :c:type:`PyConfig` instead." msgstr "" -":c:func:`Py_GetExecPrefix`:請改用 :data:`sys.base_exec_prefix` 與 :data:" -"`sys.exec_prefix`。" +"應改用帶有 :c:type:`PyConfig` 的 :c:func:`Py_InitializeFromConfig` API。" + +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:68 +msgid "Global configuration variables:" +msgstr "全域配置變數:" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:16 -msgid ":c:func:`Py_GetPath`: Get :data:`sys.path` instead." -msgstr ":c:func:`Py_GetPath`:請改用 :data:`sys.path`。" +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:70 +msgid "" +":c:var:`Py_DebugFlag`: Use :c:member:`PyConfig.parser_debug` " +"or :c:func:`PyConfig_Get(\"parser_debug\") ` instead." +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:18 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:73 msgid "" -":c:func:`Py_GetPrefix`: Get :data:`sys.base_prefix` and :data:`sys.prefix` " +":c:var:`Py_VerboseFlag`: Use :c:member:`PyConfig.verbose` " +"or :c:func:`PyConfig_Get(\"verbose\") ` instead." +msgstr "" +":c:var:`Py_VerboseFlag`:請改用 :c:member:`PyConfig.verbose` " +"或 :c:func:`PyConfig_Get(\"verbose\") `。" + +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:76 +msgid "" +":c:var:`Py_QuietFlag`: Use :c:member:`PyConfig.quiet` " +"or :c:func:`PyConfig_Get(\"quiet\") ` instead." +msgstr "" +":c:var:`Py_QuietFlag`:請改用 :c:member:`PyConfig.quiet` " +"或 :c:func:`PyConfig_Get(\"quiet\") `。" + +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:79 +msgid "" +":c:var:`Py_InteractiveFlag`: Use :c:member:`PyConfig.interactive` " +"or :c:func:`PyConfig_Get(\"interactive\") ` instead." +msgstr "" +":c:var:`Py_InteractiveFlag`:請改用 :c:member:`PyConfig.interactive` " +"或 :c:func:`PyConfig_Get(\"interactive\") `。" + +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:82 +msgid "" +":c:var:`Py_InspectFlag`: Use :c:member:`PyConfig.inspect` " +"or :c:func:`PyConfig_Get(\"inspect\") ` instead." +msgstr "" +":c:var:`Py_InspectFlag`:請改用 :c:member:`PyConfig.inspect` " +"或 :c:func:`PyConfig_Get(\"inspect\") `。" + +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:85 +msgid "" +":c:var:`Py_OptimizeFlag`: Use :c:member:`PyConfig.optimization_level` " +"or :c:func:`PyConfig_Get(\"optimization_level\") ` instead." +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 +msgid "" +":c:var:`Py_NoSiteFlag`: Use :c:member:`PyConfig.site_import` " +"or :c:func:`PyConfig_Get(\"site_import\") ` instead." +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 +msgid "" +":c:var:`Py_BytesWarningFlag`: Use :c:member:`PyConfig.bytes_warning` " +"or :c:func:`PyConfig_Get(\"bytes_warning\") ` instead." +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 +msgid "" +":c:var:`Py_FrozenFlag`: Use :c:member:`PyConfig.pathconfig_warnings` " +"or :c:func:`PyConfig_Get(\"pathconfig_warnings\") ` instead." +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 +msgid "" +":c:var:`Py_IgnoreEnvironmentFlag`: Use :c:member:`PyConfig.use_environment` " +"or :c:func:`PyConfig_Get(\"use_environment\") ` instead." +msgstr "" +":c:var:`Py_IgnoreEnvironmentFlag`:請改" +"用 :c:member:`PyConfig.use_environment` " +"或 :c:func:`PyConfig_Get(\"use_environment\") `。" + +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:100 +msgid "" +":c:var:`Py_DontWriteBytecodeFlag`: Use :c:member:`PyConfig.write_bytecode` " +"or :c:func:`PyConfig_Get(\"write_bytecode\") ` instead." +msgstr "" +":c:var:`Py_DontWriteBytecodeFlag`:請改" +"用 :c:member:`PyConfig.write_bytecode` " +"或 :c:func:`PyConfig_Get(\"write_bytecode\") `。" + +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:103 +msgid "" +":c:var:`Py_NoUserSiteDirectory`: " +"Use :c:member:`PyConfig.user_site_directory` " +"or :c:func:`PyConfig_Get(\"user_site_directory\") ` instead." +msgstr "" +":c:var:`Py_NoUserSiteDirectory`:請改" +"用 :c:member:`PyConfig.user_site_directory` " +"或 :c:func:`PyConfig_Get(\"user_site_directory\") `。" + +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:106 +msgid "" +":c:var:`Py_UnbufferedStdioFlag`: Use :c:member:`PyConfig.buffered_stdio` " +"or :c:func:`PyConfig_Get(\"buffered_stdio\") ` instead." +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 +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\") " +"` instead." +msgstr "" +":c:var:`Py_HashRandomizationFlag`:請改用 :c:member:`PyConfig.use_hash_seed` " +"和 :c:member:`PyConfig.hash_seed` 或 :c:func:`PyConfig_Get(\"hash_seed\") " +"`。" + +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:113 +msgid "" +":c:var:`Py_IsolatedFlag`: Use :c:member:`PyConfig.isolated` " +"or :c:func:`PyConfig_Get(\"isolated\") ` instead." +msgstr "" +":c:var:`Py_IsolatedFlag`:請改用 :c:member:`PyConfig.isolated` " +"或 :c:func:`PyConfig_Get(\"isolated\") `。" + +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:116 +msgid "" +":c:var:`Py_LegacyWindowsFSEncodingFlag`: " +"Use :c:member:`PyPreConfig.legacy_windows_fs_encoding` " +"or :c:func:`PyConfig_Get(\"legacy_windows_fs_encoding\") ` " "instead." msgstr "" -":c:func:`Py_GetPrefix`:請改用 :data:`sys.base_prefix` 與 :data:`sys." -"prefix`。" +":c:var:`Py_LegacyWindowsFSEncodingFlag`:請改" +"用 :c:member:`PyPreConfig.legacy_windows_fs_encoding` " +"或 :c:func:`PyConfig_Get(\"legacy_windows_fs_encoding\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:20 -msgid ":c:func:`Py_GetProgramFullPath`: Get :data:`sys.executable` instead." -msgstr ":c:func:`Py_GetProgramFullPath`:請改用 :data:`sys.executable`。" +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:119 +msgid "" +":c:var:`Py_LegacyWindowsStdioFlag`: " +"Use :c:member:`PyConfig.legacy_windows_stdio` " +"or :c:func:`PyConfig_Get(\"legacy_windows_stdio\") ` instead." +msgstr "" +":c:var:`Py_LegacyWindowsStdioFlag`:請改" +"用 :c:member:`PyConfig.legacy_windows_stdio` " +"或 :c:func:`PyConfig_Get(\"legacy_windows_stdio\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:22 -msgid ":c:func:`Py_GetProgramName`: Get :data:`sys.executable` instead." -msgstr ":c:func:`Py_GetProgramName`:請改用 :data:`sys.executable`。" +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:122 +msgid "" +":c:var:`!Py_FileSystemDefaultEncoding`, :c:var:`!" +"Py_HasFileSystemDefaultEncoding`: " +"Use :c:member:`PyConfig.filesystem_encoding` " +"or :c:func:`PyConfig_Get(\"filesystem_encoding\") ` instead." +msgstr "" +":c:var:`!Py_FileSystemDefaultEncoding`、:c:var:`!" +"Py_HasFileSystemDefaultEncoding`:請改" +"用 :c:member:`PyConfig.filesystem_encoding` " +"或 :c:func:`PyConfig_Get(\"filesystem_encoding\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:24 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:125 +msgid "" +":c:var:`!Py_FileSystemDefaultEncodeErrors`: " +"Use :c:member:`PyConfig.filesystem_errors` " +"or :c:func:`PyConfig_Get(\"filesystem_errors\") ` instead." +msgstr "" +":c:var:`!Py_FileSystemDefaultEncodeErrors`:請改" +"用 :c:member:`PyConfig.filesystem_errors` " +"或 :c:func:`PyConfig_Get(\"filesystem_errors\") `。" + +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:128 +msgid "" +":c:var:`!Py_UTF8Mode`: Use :c:member:`PyPreConfig.utf8_mode` " +"or :c:func:`PyConfig_Get(\"utf8_mode\") ` instead. " +"(see :c:func:`Py_PreInitialize`)" +msgstr "" +":c:var:`!Py_UTF8Mode`:請改用 :c:member:`PyPreConfig.utf8_mode` " +"或 :c:func:`PyConfig_Get(\"utf8_mode\") `。(請參" +"閱 :c:func:`Py_PreInitialize`)" + +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:133 msgid "" -":c:func:`Py_GetPythonHome`: Get :c:member:`PyConfig.home` or the :envvar:" -"`PYTHONHOME` environment variable instead." +"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 get these options at runtime." msgstr "" -":c:func:`Py_GetPythonHome`:請改用 :c:member:`PyConfig.home` 或 :envvar:" -"`PYTHONHOME` 環境變數。" +"應改用帶有 :c:type:`PyConfig` 的 :c:func:`Py_InitializeFromConfig` API 來設定" +"這些選項。或者也可以使用 :c:func:`PyConfig_Get` 在執行時取得這些選項。" diff --git a/deprecations/c-api-pending-removal-in-3.16.po b/deprecations/c-api-pending-removal-in-3.16.po index adc146223cf..f6d770d35a4 100644 --- a/deprecations/c-api-pending-removal-in-3.16.po +++ b/deprecations/c-api-pending-removal-in-3.16.po @@ -1,9 +1,9 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2025-07-03 00:17+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" diff --git a/deprecations/c-api-pending-removal-in-3.18.po b/deprecations/c-api-pending-removal-in-3.18.po new file mode 100644 index 00000000000..458022f9a8b --- /dev/null +++ b/deprecations/c-api-pending-removal-in-3.18.po @@ -0,0 +1,172 @@ +# 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.14\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-09-18 00:15+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.18.rst:2 +msgid "Pending removal in Python 3.18" +msgstr "Python 3.18 中待移除的項目" + +#: ../../deprecations/c-api-pending-removal-in-3.18.rst:4 +msgid "" +"The following private functions are deprecated and planned for removal in " +"Python 3.18:" +msgstr "以下私有函式已被棄用,並計劃在 Python 3.18 中移除:" + +#: ../../deprecations/c-api-pending-removal-in-3.18.rst:7 +msgid ":c:func:`!_PyBytes_Join`: use :c:func:`PyBytes_Join`." +msgstr ":c:func:`!_PyBytes_Join`:請改用 :c:func:`PyBytes_Join`。" + +#: ../../deprecations/c-api-pending-removal-in-3.18.rst:8 +msgid "" +":c:func:`!_PyDict_GetItemStringWithError`: use :c:func:" +"`PyDict_GetItemStringRef`." +msgstr "" +":c:func:`!_PyDict_GetItemStringWithError`:請改用 :c:func:" +"`PyDict_GetItemStringRef`。" + +#: ../../deprecations/c-api-pending-removal-in-3.18.rst:9 +msgid ":c:func:`!_PyDict_Pop()`: use :c:func:`PyDict_Pop`." +msgstr ":c:func:`!_PyDict_Pop()`:請改用 :c:func:`PyDict_Pop`。" + +#: ../../deprecations/c-api-pending-removal-in-3.18.rst:10 +msgid ":c:func:`!_PyLong_Sign()`: use :c:func:`PyLong_GetSign`." +msgstr ":c:func:`!_PyLong_Sign()`:請改用 :c:func:`PyLong_GetSign`。" + +#: ../../deprecations/c-api-pending-removal-in-3.18.rst:11 +msgid "" +":c:func:`!_PyLong_FromDigits` and :c:func:`!_PyLong_New`: use :c:func:" +"`PyLongWriter_Create`." +msgstr "" +":c:func:`!_PyLong_FromDigits` 和 :c:func:`!_PyLong_New`:請改用 :c:func:" +"`PyLongWriter_Create`。" + +#: ../../deprecations/c-api-pending-removal-in-3.18.rst:13 +msgid "" +":c:func:`!_PyThreadState_UncheckedGet`: use :c:func:" +"`PyThreadState_GetUnchecked`." +msgstr "" +":c:func:`!_PyThreadState_UncheckedGet`:請改用 :c:func:" +"`PyThreadState_GetUnchecked`。" + +#: ../../deprecations/c-api-pending-removal-in-3.18.rst:14 +msgid ":c:func:`!_PyUnicode_AsString`: use :c:func:`PyUnicode_AsUTF8`." +msgstr ":c:func:`!_PyUnicode_AsString`:請改用 :c:func:`PyUnicode_AsUTF8`。" + +#: ../../deprecations/c-api-pending-removal-in-3.18.rst:15 +msgid "" +":c:func:`!_PyUnicodeWriter_Init`: replace ``_PyUnicodeWriter_Init(&writer)`` " +"with :c:func:`writer = PyUnicodeWriter_Create(0) `." +msgstr "" +":c:func:`!_PyUnicodeWriter_Init`:將 ``_PyUnicodeWriter_Init(&writer)`` 替換" +"為 :c:func:`writer = PyUnicodeWriter_Create(0) `。" + +#: ../../deprecations/c-api-pending-removal-in-3.18.rst:18 +msgid "" +":c:func:`!_PyUnicodeWriter_Finish`: replace " +"``_PyUnicodeWriter_Finish(&writer)`` with :c:func:" +"`PyUnicodeWriter_Finish(writer) `." +msgstr "" +":c:func:`!_PyUnicodeWriter_Finish`:將 ``_PyUnicodeWriter_Finish(&writer)`` " +"替換為 :c:func:`PyUnicodeWriter_Finish(writer) `。" + +#: ../../deprecations/c-api-pending-removal-in-3.18.rst:21 +msgid "" +":c:func:`!_PyUnicodeWriter_Dealloc`: replace " +"``_PyUnicodeWriter_Dealloc(&writer)`` with :c:func:" +"`PyUnicodeWriter_Discard(writer) `." +msgstr "" +":c:func:`!_PyUnicodeWriter_Dealloc`:將 " +"``_PyUnicodeWriter_Dealloc(&writer)`` 替換為 :c:func:" +"`PyUnicodeWriter_Discard(writer) `。" + +#: ../../deprecations/c-api-pending-removal-in-3.18.rst:24 +msgid "" +":c:func:`!_PyUnicodeWriter_WriteChar`: replace " +"``_PyUnicodeWriter_WriteChar(&writer, ch)`` with :c:func:" +"`PyUnicodeWriter_WriteChar(writer, ch) `." +msgstr "" +":c:func:`!_PyUnicodeWriter_WriteChar`:將 " +"``_PyUnicodeWriter_WriteChar(&writer, ch)`` 替換為 :c:func:" +"`PyUnicodeWriter_WriteChar(writer, ch) `。" + +#: ../../deprecations/c-api-pending-removal-in-3.18.rst:27 +msgid "" +":c:func:`!_PyUnicodeWriter_WriteStr`: replace " +"``_PyUnicodeWriter_WriteStr(&writer, str)`` with :c:func:" +"`PyUnicodeWriter_WriteStr(writer, str) `." +msgstr "" +":c:func:`!_PyUnicodeWriter_WriteStr`:將 " +"``_PyUnicodeWriter_WriteStr(&writer, str)`` 替換為 :c:func:" +"`PyUnicodeWriter_WriteStr(writer, str) `。" + +#: ../../deprecations/c-api-pending-removal-in-3.18.rst:30 +msgid "" +":c:func:`!_PyUnicodeWriter_WriteSubstring`: replace " +"``_PyUnicodeWriter_WriteSubstring(&writer, str, start, end)`` with :c:func:" +"`PyUnicodeWriter_WriteSubstring(writer, str, start, end) " +"`." +msgstr "" +":c:func:`!_PyUnicodeWriter_WriteSubstring`:將 " +"``_PyUnicodeWriter_WriteSubstring(&writer, str, start, end)`` 替換為 :c:func:" +"`PyUnicodeWriter_WriteSubstring(writer, str, start, end) " +"`。" + +#: ../../deprecations/c-api-pending-removal-in-3.18.rst:33 +msgid "" +":c:func:`!_PyUnicodeWriter_WriteASCIIString`: replace " +"``_PyUnicodeWriter_WriteASCIIString(&writer, str)`` with :c:func:" +"`PyUnicodeWriter_WriteASCII(writer, str) `." +msgstr "" +":c:func:`!_PyUnicodeWriter_WriteASCIIString`:將 " +"``_PyUnicodeWriter_WriteASCIIString(&writer, str)`` 替換為 :c:func:" +"`PyUnicodeWriter_WriteASCII(writer, str) `。" + +#: ../../deprecations/c-api-pending-removal-in-3.18.rst:36 +msgid "" +":c:func:`!_PyUnicodeWriter_WriteLatin1String`: replace " +"``_PyUnicodeWriter_WriteLatin1String(&writer, str)`` with :c:func:" +"`PyUnicodeWriter_WriteUTF8(writer, str) `." +msgstr "" +":c:func:`!_PyUnicodeWriter_WriteLatin1String`:將 " +"``_PyUnicodeWriter_WriteLatin1String(&writer, str)`` 替換為 :c:func:" +"`PyUnicodeWriter_WriteUTF8(writer, str) `。" + +#: ../../deprecations/c-api-pending-removal-in-3.18.rst:39 +msgid ":c:func:`!_PyUnicodeWriter_Prepare`: (no replacement)." +msgstr ":c:func:`!_PyUnicodeWriter_Prepare`:(無替代方案)。" + +#: ../../deprecations/c-api-pending-removal-in-3.18.rst:40 +msgid ":c:func:`!_PyUnicodeWriter_PrepareKind`: (no replacement)." +msgstr ":c:func:`!_PyUnicodeWriter_PrepareKind`:(無替代方案)。" + +#: ../../deprecations/c-api-pending-removal-in-3.18.rst:41 +msgid ":c:func:`!_Py_HashPointer`: use :c:func:`Py_HashPointer`." +msgstr ":c:func:`!_Py_HashPointer`:請改用 :c:func:`Py_HashPointer`。" + +#: ../../deprecations/c-api-pending-removal-in-3.18.rst:42 +msgid ":c:func:`!_Py_fopen_obj`: use :c:func:`Py_fopen`." +msgstr ":c:func:`!_Py_fopen_obj`:請改用 :c:func:`Py_fopen`。" + +#: ../../deprecations/c-api-pending-removal-in-3.18.rst:44 +msgid "" +"The `pythoncapi-compat project `__ can be used to get these new public functions on Python 3.13 and older. " +"(Contributed by Victor Stinner in :gh:`128863`.)" +msgstr "" +"可以使用 `pythoncapi-compat project `__ 來取得這些於 Python 3.13 及更早版本的新公開函式。(由 " +"Victor Stinner 在 :gh:`128863` 貢獻)" diff --git a/deprecations/c-api-pending-removal-in-future.po b/deprecations/c-api-pending-removal-in-future.po index a9930288d2e..59952a6fbec 100644 --- a/deprecations/c-api-pending-removal-in-future.po +++ b/deprecations/c-api-pending-removal-in-future.po @@ -1,11 +1,11 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-24 07:20+0000\n" +"POT-Creation-Date: 2025-09-08 15:25+0800\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-" @@ -16,7 +16,7 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" #: ../../deprecations/c-api-pending-removal-in-future.rst:2 -msgid "Pending Removal in Future Versions" +msgid "Pending removal in future versions" msgstr "未來版本中的待移除項目" #: ../../deprecations/c-api-pending-removal-in-future.rst:4 @@ -66,45 +66,21 @@ msgstr "" "和 :c:func:`PySlice_AdjustIndices`。" #: ../../deprecations/c-api-pending-removal-in-future.rst:21 -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-future.rst:23 -msgid "" -":c:func:`!PyUnicode_AsDecodedUnicode`: Use :c:func:`PyCodec_Decode` instead." -msgstr "" -":c:func:`!PyUnicode_AsDecodedUnicode`:請改用 :c:func:`PyCodec_Decode`。" - -#: ../../deprecations/c-api-pending-removal-in-future.rst:25 -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-future.rst:27 -msgid "" -":c:func:`!PyUnicode_AsEncodedUnicode`: Use :c:func:`PyCodec_Encode` instead." -msgstr "" -":c:func:`!PyUnicode_AsEncodedUnicode`:請改用 :c:func:`PyCodec_Encode`。" - -#: ../../deprecations/c-api-pending-removal-in-future.rst:29 msgid ":c:func:`PyUnicode_READY`: Unneeded since Python 3.12" msgstr ":c:func:`PyUnicode_READY`:自 Python 3.12 起不再需要" -#: ../../deprecations/c-api-pending-removal-in-future.rst:31 +#: ../../deprecations/c-api-pending-removal-in-future.rst:23 msgid ":c:func:`!PyErr_Display`: Use :c:func:`PyErr_DisplayException` instead." msgstr ":c:func:`!PyErr_Display`:請改用 :c:func:`PyErr_DisplayException`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:33 +#: ../../deprecations/c-api-pending-removal-in-future.rst:25 msgid "" ":c:func:`!_PyErr_ChainExceptions`: Use :c:func:`!_PyErr_ChainExceptions1` " "instead." msgstr "" ":c:func:`!_PyErr_ChainExceptions`:請改用 ``_PyErr_ChainExceptions1``。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:35 +#: ../../deprecations/c-api-pending-removal-in-future.rst:27 msgid "" ":c:member:`!PyBytesObject.ob_shash` member: call :c:func:`PyObject_Hash` " "instead." @@ -112,40 +88,36 @@ msgstr "" ":c:member:`!PyBytesObject.ob_shash` 成員:請改為呼" "叫 :c:func:`PyObject_Hash`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:37 -msgid ":c:member:`!PyDictObject.ma_version_tag` member." -msgstr ":c:member:`!PyDictObject.ma_version_tag` 成員。" - -#: ../../deprecations/c-api-pending-removal-in-future.rst:38 +#: ../../deprecations/c-api-pending-removal-in-future.rst:29 msgid "Thread Local Storage (TLS) API:" msgstr "執行緒局部儲存 (Thread Local Storage, TLS) API:" -#: ../../deprecations/c-api-pending-removal-in-future.rst:40 +#: ../../deprecations/c-api-pending-removal-in-future.rst:31 msgid "" ":c:func:`PyThread_create_key`: Use :c:func:`PyThread_tss_alloc` instead." msgstr ":c:func:`PyThread_create_key`:請改用 :c:func:`PyThread_tss_alloc`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:42 +#: ../../deprecations/c-api-pending-removal-in-future.rst:33 msgid ":c:func:`PyThread_delete_key`: Use :c:func:`PyThread_tss_free` instead." msgstr ":c:func:`PyThread_delete_key`:請改用 :c:func:`PyThread_tss_free`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:44 +#: ../../deprecations/c-api-pending-removal-in-future.rst:35 msgid "" ":c:func:`PyThread_set_key_value`: Use :c:func:`PyThread_tss_set` instead." msgstr ":c:func:`PyThread_set_key_value`:請改用 :c:func:`PyThread_tss_set`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:46 +#: ../../deprecations/c-api-pending-removal-in-future.rst:37 msgid "" ":c:func:`PyThread_get_key_value`: Use :c:func:`PyThread_tss_get` instead." msgstr ":c:func:`PyThread_get_key_value`:請改用 :c:func:`PyThread_tss_get`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:48 +#: ../../deprecations/c-api-pending-removal-in-future.rst:39 msgid "" ":c:func:`PyThread_delete_key_value`: Use :c:func:`PyThread_tss_delete` " "instead." msgstr "" ":c:func:`PyThread_delete_key_value`:請改用 :c:func:`PyThread_tss_delete`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:50 +#: ../../deprecations/c-api-pending-removal-in-future.rst:41 msgid ":c:func:`PyThread_ReInitTLS`: Unneeded since Python 3.7." msgstr ":c:func:`PyThread_ReInitTLS`:自 Python 3.7 起不再需要。" diff --git a/deprecations/index.po b/deprecations/index.po index 0b75d471905..f670deffdeb 100644 --- a/deprecations/index.po +++ b/deprecations/index.po @@ -1,11 +1,11 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-07-03 00:17+0000\n" +"POT-Creation-Date: 2025-10-06 00:15+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -19,245 +19,9 @@ msgstr "" msgid "Deprecations" msgstr "已棄用項目" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:2 -#: ../../deprecations/pending-removal-in-3.14.rst:2 -msgid "Pending Removal in Python 3.14" -msgstr "Python 3.14 中待移除的項目" - -#: ../../deprecations/pending-removal-in-3.14.rst:4 -msgid "" -":mod:`argparse`: The *type*, *choices*, and *metavar* parameters of :class:`!" -"argparse.BooleanOptionalAction` are deprecated and will be removed in 3.14. " -"(Contributed by Nikita Sobolev in :gh:`92248`.)" -msgstr "" -":mod:`argparse`::class:`!argparse.BooleanOptionalAction` 的 *type*、" -"*choices* 和 *metavar* 參數已被棄用,將在 3.14 中移除。 (由 Nikita Sobolev " -"於 :gh:`92248` 貢獻。)" - -#: ../../deprecations/pending-removal-in-3.14.rst:9 -msgid "" -":mod:`ast`: The following features have been deprecated in documentation " -"since Python 3.8, now cause a :exc:`DeprecationWarning` to be emitted at " -"runtime when they are accessed or used, and will be removed in Python 3.14:" -msgstr "" -":mod:`ast`:自 Python 3.8 起,下列功能已在文件中被棄用,現在在存取或使用時會" -"於 runtime 發出 :exc:`DeprecationWarning`,並將在 Python 3.14 中移除:" - -#: ../../deprecations/pending-removal-in-3.14.rst:13 -msgid ":class:`!ast.Num`" -msgstr ":class:`!ast.Num`" - -#: ../../deprecations/pending-removal-in-3.14.rst:14 -msgid ":class:`!ast.Str`" -msgstr ":class:`!ast.Str`" - -#: ../../deprecations/pending-removal-in-3.14.rst:15 -msgid ":class:`!ast.Bytes`" -msgstr ":class:`!ast.Bytes`" - -#: ../../deprecations/pending-removal-in-3.14.rst:16 -msgid ":class:`!ast.NameConstant`" -msgstr ":class:`!ast.NameConstant`" - -#: ../../deprecations/pending-removal-in-3.14.rst:17 -msgid ":class:`!ast.Ellipsis`" -msgstr ":class:`!ast.Ellipsis`" - -#: ../../deprecations/pending-removal-in-3.14.rst:19 -msgid "" -"Use :class:`ast.Constant` instead. (Contributed by Serhiy Storchaka in :gh:" -"`90953`.)" -msgstr "" -"請改用 :class:`ast.Constant`。(由 Serhiy Storchaka 於 :gh:`90953` 貢獻。)" - -#: ../../deprecations/pending-removal-in-3.14.rst:22 -#: ../../deprecations/pending-removal-in-3.16.rst:19 -msgid ":mod:`asyncio`:" -msgstr ":mod:`asyncio`:" - -#: ../../deprecations/pending-removal-in-3.14.rst:24 -msgid "" -"The child watcher classes :class:`~asyncio.MultiLoopChildWatcher`, :class:" -"`~asyncio.FastChildWatcher`, :class:`~asyncio.AbstractChildWatcher` and :" -"class:`~asyncio.SafeChildWatcher` are deprecated and will be removed in " -"Python 3.14. (Contributed by Kumar Aditya in :gh:`94597`.)" -msgstr "" -"已棄用並將在 Python 3.14 中移除的 child watcher 類別::class:`~asyncio." -"MultiLoopChildWatcher`、:class:`~asyncio.FastChildWatcher`、:class:`~asyncio." -"AbstractChildWatcher` 和 :class:`~asyncio.SafeChildWatcher`。 (由 Kumar " -"Aditya 於 :gh:`94597` 貢獻。)" - -#: ../../deprecations/pending-removal-in-3.14.rst:30 -msgid "" -":func:`asyncio.set_child_watcher`, :func:`asyncio.get_child_watcher`, :meth:" -"`asyncio.AbstractEventLoopPolicy.set_child_watcher` and :meth:`asyncio." -"AbstractEventLoopPolicy.get_child_watcher` are deprecated and will be " -"removed in Python 3.14. (Contributed by Kumar Aditya in :gh:`94597`.)" -msgstr "" -":func:`asyncio.set_child_watcher`、:func:`asyncio.get_child_watcher`、:meth:" -"`asyncio.AbstractEventLoopPolicy.set_child_watcher` 和 :meth:`asyncio." -"AbstractEventLoopPolicy.get_child_watcher` 已被棄用並將在 Python 3.14 中移" -"除。(由 Kumar Aditya 於 :gh:`94597` 貢獻。)" - -#: ../../deprecations/pending-removal-in-3.14.rst:36 -msgid "" -"The :meth:`~asyncio.get_event_loop` method of the default event loop policy " -"now emits a :exc:`DeprecationWarning` if there is no current event loop set " -"and it decides to create one. (Contributed by Serhiy Storchaka and Guido van " -"Rossum in :gh:`100160`.)" -msgstr "" -"預設事件迴圈策略的 :meth:`~asyncio.get_event_loop` 方法現在會在沒有設定目前事" -"件迴圈且決定建立一個時發出 :exc:`DeprecationWarning`。 (由 Serhiy Storchaka " -"和 Guido van Rossum 於 :gh:`100160` 貢獻。)" - -#: ../../deprecations/pending-removal-in-3.14.rst:41 -msgid "" -":mod:`collections.abc`: Deprecated :class:`~collections.abc.ByteString`. " -"Prefer :class:`!Sequence` or :class:`~collections.abc.Buffer`. For use in " -"typing, prefer a union, like ``bytes | bytearray``, or :class:`collections." -"abc.Buffer`. (Contributed by Shantanu Jain in :gh:`91896`.)" -msgstr "" -":mod:`collections.abc`:已棄用 :class:`~collections.abc.ByteString`。請改用 :" -"class:`!Sequence` 或 :class:`~collections.abc.Buffer`。在 typing 中使用時,請" -"改用聯集,如 ``bytes | bytearray``,或 :class:`collections.abc.Buffer`。(由 " -"Shantanu Jain 於 :gh:`91896` 貢獻。)" - -#: ../../deprecations/pending-removal-in-3.14.rst:47 -msgid "" -":mod:`email`: Deprecated the *isdst* parameter in :func:`email.utils." -"localtime`. (Contributed by Alan Williams in :gh:`72346`.)" -msgstr "" -":mod:`email`:已棄用 :func:`email.utils.localtime` 中的 *isdst* 參數。(由 " -"Alan Williams 於 :gh:`72346` 貢獻。)" - -#: ../../deprecations/pending-removal-in-3.14.rst:50 -msgid ":mod:`importlib.abc` deprecated classes:" -msgstr ":mod:`importlib.abc` 的已棄用類別:" - -#: ../../deprecations/pending-removal-in-3.14.rst:52 -msgid ":class:`!importlib.abc.ResourceReader`" -msgstr ":class:`!importlib.abc.ResourceReader`" - -#: ../../deprecations/pending-removal-in-3.14.rst:53 -msgid ":class:`!importlib.abc.Traversable`" -msgstr ":class:`!importlib.abc.Traversable`" - -#: ../../deprecations/pending-removal-in-3.14.rst:54 -msgid ":class:`!importlib.abc.TraversableResources`" -msgstr ":class:`!importlib.abc.TraversableResources`" - -#: ../../deprecations/pending-removal-in-3.14.rst:56 -msgid "Use :mod:`importlib.resources.abc` classes instead:" -msgstr "請改用 :mod:`importlib.resources.abc` 類別:" - -#: ../../deprecations/pending-removal-in-3.14.rst:58 -msgid ":class:`importlib.resources.abc.Traversable`" -msgstr ":class:`importlib.resources.abc.Traversable`" - -#: ../../deprecations/pending-removal-in-3.14.rst:59 -msgid ":class:`importlib.resources.abc.TraversableResources`" -msgstr ":class:`importlib.resources.abc.TraversableResources`" - -#: ../../deprecations/pending-removal-in-3.14.rst:61 -msgid "(Contributed by Jason R. Coombs and Hugo van Kemenade in :gh:`93963`.)" -msgstr "(由 Jason R. Coombs 和 Hugo van Kemenade 貢獻於 :gh:`93963`。)" - -#: ../../deprecations/pending-removal-in-3.14.rst:63 -msgid "" -":mod:`itertools` had undocumented, inefficient, historically buggy, and " -"inconsistent support for copy, deepcopy, and pickle operations. This will be " -"removed in 3.14 for a significant reduction in code volume and maintenance " -"burden. (Contributed by Raymond Hettinger in :gh:`101588`.)" -msgstr "" -":mod:`itertools` 有不以文件記錄、效率低下、過去常有 bug 且不一致的 copy、" -"deepcopy 和 pickle 操作支援。將在 3.14 中移除以大幅減少程式碼量和維護負擔。 " -"(由 Raymond Hettinger 於 :gh:`101588` 貢獻。)" - -#: ../../deprecations/pending-removal-in-3.14.rst:69 -msgid "" -":mod:`multiprocessing`: The default start method will change to a safer one " -"on Linux, BSDs, and other non-macOS POSIX platforms where ``'fork'`` is " -"currently the default (:gh:`84559`). Adding a runtime warning about this was " -"deemed too disruptive as the majority of code is not expected to care. Use " -"the :func:`~multiprocessing.get_context` or :func:`~multiprocessing." -"set_start_method` APIs to explicitly specify when your code *requires* " -"``'fork'``. See :ref:`multiprocessing-start-methods`." -msgstr "" -":mod:`multiprocessing`:預設的啟動方法將在 Linux、BSD 和其他非 macOS POSIX 平" -"台上更改為更安全的 方法,目前 ``'fork'`` 是預設值 (:gh:`84559`)。對此增加一" -"個 runtime 警告被認為太過擾人,因為 大多數程式碼不會在意。請使用 :func:" -"`~multiprocessing.get_context` 或 :func:`~multiprocessing.set_start_method` " -"API 來明確指定你的程式碼何時\\ *需要* ``'fork'``。請參閱 :ref:" -"`multiprocessing-start-methods`。" - -#: ../../deprecations/pending-removal-in-3.14.rst:77 -msgid "" -":mod:`pathlib`: :meth:`~pathlib.PurePath.is_relative_to` and :meth:`~pathlib." -"PurePath.relative_to`: passing additional arguments is deprecated." -msgstr "" -":mod:`pathlib`:已棄用 :meth:`~pathlib.PurePath.is_relative_to` 和 :meth:" -"`~pathlib.PurePath.relative_to`:額外引數的傳遞已被棄用。" - -#: ../../deprecations/pending-removal-in-3.14.rst:81 -msgid "" -":mod:`pkgutil`: :func:`~pkgutil.find_loader` and :func:`~pkgutil.get_loader` " -"now raise :exc:`DeprecationWarning`; use :func:`importlib.util.find_spec` " -"instead. (Contributed by Nikita Sobolev in :gh:`97850`.)" -msgstr "" -":mod:`pkgutil`::func:`~pkgutil.find_loader` 和 :func:`~pkgutil.get_loader` " -"現在會引發 :exc:`DeprecationWarning`;請改用 :func:`importlib.util." -"find_spec`。 (由 Nikita Sobolev 於 :gh:`97850` 貢獻。)" - -#: ../../deprecations/pending-removal-in-3.14.rst:86 -msgid ":mod:`pty`:" -msgstr ":mod:`pty`:" - -#: ../../deprecations/pending-removal-in-3.14.rst:88 -msgid "``master_open()``: use :func:`pty.openpty`." -msgstr "``master_open()``:請用 :func:`pty.openpty`。" - -#: ../../deprecations/pending-removal-in-3.14.rst:89 -msgid "``slave_open()``: use :func:`pty.openpty`." -msgstr "``slave_open()``:請用 :func:`pty.openpty`。" - -#: ../../deprecations/pending-removal-in-3.14.rst:91 -msgid ":mod:`sqlite3`:" -msgstr ":mod:`sqlite3`:" - -#: ../../deprecations/pending-removal-in-3.14.rst:93 -msgid ":data:`~sqlite3.version` and :data:`~sqlite3.version_info`." -msgstr ":data:`~sqlite3.version` 和 :data:`~sqlite3.version_info`。" - -#: ../../deprecations/pending-removal-in-3.14.rst:95 -msgid "" -":meth:`~sqlite3.Cursor.execute` and :meth:`~sqlite3.Cursor.executemany` if :" -"ref:`named placeholders ` are used and *parameters* is " -"a sequence instead of a :class:`dict`." -msgstr "" -":meth:`~sqlite3.Cursor.execute` 和 :meth:`~sqlite3.Cursor.executemany`,如果" -"使用 :ref:`named placeholders ` 且 *parameters* 是序列" -"而不是 :class:`dict`。" - -#: ../../deprecations/pending-removal-in-3.14.rst:99 -msgid "" -":mod:`typing`: :class:`~typing.ByteString`, deprecated since Python 3.9, now " -"causes a :exc:`DeprecationWarning` to be emitted when it is used." -msgstr "" -":mod:`typing`:自 Python 3.9 起已被棄用的 :class:`~typing.ByteString` 現在在" -"使用時會發出 :exc:`DeprecationWarning`。" - -#: ../../deprecations/pending-removal-in-3.14.rst:102 -msgid "" -":mod:`urllib`: :class:`!urllib.parse.Quoter` is deprecated: it was not " -"intended to be a public API. (Contributed by Gregory P. Smith in :gh:" -"`88168`.)" -msgstr "" -":mod:`urllib`::class:`!urllib.parse.Quoter` 已被棄用:它並非預期的公開 API。" -"(由 Gregory P. Smith 於 :gh:`88168` 貢獻。)" - #: ../../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" +msgid "Pending removal in Python 3.15" msgstr "Python 3.15 中待移除的項目" #: ../../deprecations/pending-removal-in-3.15.rst:4 @@ -288,6 +52,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`:" @@ -321,7 +86,7 @@ msgstr "" "cgi` 旗標已被棄用。" #: ../../deprecations/pending-removal-in-3.15.rst:32 -#: ../../deprecations/pending-removal-in-future.rst:56 +#: ../../deprecations/pending-removal-in-future.rst:63 msgid ":mod:`importlib`:" msgstr ":mod:`importlib`:" @@ -372,6 +137,7 @@ msgstr "" "援有用,具有令人困惑的 API,基本上未經測試。" #: ../../deprecations/pending-removal-in-3.15.rst:58 +#: ../../deprecations/pending-removal-in-3.16.rst:96 msgid ":mod:`sysconfig`:" msgstr ":mod:`sysconfig`:" @@ -415,15 +181,16 @@ msgstr "" "`101866` 貢獻。)" #: ../../deprecations/pending-removal-in-3.15.rst:80 +#: ../../deprecations/pending-removal-in-3.17.rst:26 msgid ":mod:`typing`:" msgstr ":mod:`typing`:" #: ../../deprecations/pending-removal-in-3.15.rst:82 msgid "" "The undocumented keyword argument syntax for creating :class:`~typing." -"NamedTuple` classes (e.g. ``Point = NamedTuple(\"Point\", x=int, y=int)``) " -"has been deprecated since Python 3.13. Use the class-based syntax or the " -"functional syntax instead." +"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 棄用。請改" @@ -466,6 +233,20 @@ msgstr "" "`~wave.Wave_read.getmark`、:meth:`!setmark` 和 :meth:`~wave.Wave_read." "getmarkers` 方法自 Python 3.13 被棄用。" +#: ../../deprecations/pending-removal-in-3.15.rst:107 +msgid ":mod:`zipimport`:" +msgstr ":mod:`zipimport`:" + +#: ../../deprecations/pending-removal-in-3.15.rst:109 +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 中待移除的項目" @@ -495,22 +276,90 @@ msgstr "" "Python 3.13 起在 runtime 已被棄用。請使用 ``'w'`` 格式碼 (:c:type:`Py_UCS4`) " "來取代 Unicode 字元。" +#: ../../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 " +"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:`!asyncio.iscoroutinefunction` 已被棄用並將在 Python 3.16 中移除;請改" "用 :func:`inspect.iscoroutinefunction`。(由 Jiahao Li 和 Kumar Aditya 於 :" "gh:`122875` 貢獻。)" #: ../../deprecations/pending-removal-in-3.16.rst:26 -#: ../../deprecations/pending-removal-in-future.rst:10 +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:28 +#: ../../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 " @@ -523,11 +372,52 @@ msgstr "" "邏輯否定。在極少數情況下,你需要對底層的整數進行位元反轉,請明確轉換為 " "``~int(x)`` (``~int(x)``)。" -#: ../../deprecations/pending-removal-in-3.16.rst:35 +#: ../../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:37 +#: ../../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 " @@ -536,11 +426,11 @@ msgstr "" "自 Python 3.14 起,:class:`!ExecError` 例外已被棄用。自 Python 3.4 以來,它尚" "未被 :mod:`!shutil` 中的任何函式使用,現在是 :exc:`RuntimeError` 的別名。" -#: ../../deprecations/pending-removal-in-3.16.rst:42 +#: ../../deprecations/pending-removal-in-3.16.rst:85 msgid ":mod:`symtable`:" msgstr ":mod:`symtable`:" -#: ../../deprecations/pending-removal-in-3.16.rst:44 +#: ../../deprecations/pending-removal-in-3.16.rst:87 msgid "" "The :meth:`Class.get_methods ` method has been " "deprecated since Python 3.14." @@ -548,11 +438,11 @@ msgstr "" "自 Python 3.14 起,:meth:`Class.get_methods ` 方" "法已被棄用。" -#: ../../deprecations/pending-removal-in-3.16.rst:47 +#: ../../deprecations/pending-removal-in-3.16.rst:90 msgid ":mod:`sys`:" msgstr ":mod:`sys`:" -#: ../../deprecations/pending-removal-in-3.16.rst:49 +#: ../../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` " @@ -561,11 +451,20 @@ msgstr "" "自 Python 3.13 起,:func:`~sys._enablelegacywindowsfsencoding` 函式已被棄用。" "請改用 :envvar:`PYTHONLEGACYWINDOWSFSENCODING` 環境變數。" -#: ../../deprecations/pending-removal-in-3.16.rst:53 +#: ../../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:55 +#: ../../deprecations/pending-removal-in-3.16.rst:104 msgid "" "The undocumented and unused :attr:`!TarFile.tarfile` attribute has been " "deprecated since Python 3.13." @@ -573,9 +472,94 @@ 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 +msgid ":mod:`collections.abc`:" +msgstr ":mod:`collections.abc`:" + +#: ../../deprecations/pending-removal-in-3.17.rst:6 +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 +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:14 +#: ../../deprecations/pending-removal-in-3.17.rst:42 +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:22 +#: ../../deprecations/pending-removal-in-3.17.rst:50 +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:28 +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 "" +"在 Python 3.14 之前,舊式聯集是使用私有類別 ``typing._UnionGenericAlias`` 實" +"作的。這個類別不再被需要,但為了向後相容性而保留,並計劃將在 Python 3.17 中移" +"除。使用者應該改用文件中記錄的內省輔助函式,例如 :func:`typing.get_origin` " +"和 :func:`typing.get_args`,或者依賴私有實作細節。" + +#: ../../deprecations/pending-removal-in-3.17.rst:33 +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.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/c-api-pending-removal-in-future.rst:2 #: ../../deprecations/pending-removal-in-future.rst:2 -msgid "Pending Removal in Future Versions" +msgid "Pending removal in future versions" msgstr "未來版本中的待移除項目" #: ../../deprecations/pending-removal-in-future.rst:4 @@ -585,16 +569,27 @@ msgid "" 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 "" -":mod:`argparse`: Nesting argument groups and nesting mutually exclusive " -"groups are deprecated." -msgstr ":mod:`argparse`:已棄用巢狀引數群組和巢狀互斥群組。" +"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:12 -msgid "``bool(NotImplemented)``." -msgstr "``bool(NotImplemented)``。" +#: ../../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:13 +#: ../../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 " @@ -603,7 +598,7 @@ msgstr "" "產生器:``throw(type, exc, tb)`` 和 ``athrow(type, exc, tb)`` 簽名已被棄用:" "請改用 ``throw(exc)`` 和 ``athrow(exc)``,為單引數簽名。" -#: ../../deprecations/pending-removal-in-future.rst:16 +#: ../../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 " @@ -615,13 +610,13 @@ msgid "" "syntax error. (:gh:`87999`)" msgstr "" "目前 Python 接受數值字面值後面立即接關鍵字,例如 ``0in x``、``1or x``、``0if " -"1else 2``。它讓表達式模糊且容易混淆,如 ``[0x1for x in y]``\\ (可以解釋為 " +"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:24 +#: ../../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 " @@ -630,7 +625,7 @@ msgstr "" "``__index__()`` 和 ``__int__()`` 方法回傳非 int 型別的支援:這些方法將需要回" "傳 :class:`int` 的嚴格子類別實例。" -#: ../../deprecations/pending-removal-in-future.rst:27 +#: ../../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:" @@ -639,7 +634,7 @@ msgstr "" "回傳 :class:`float` 嚴格子類別 ``__float__()`` 方法的支援:這些方法將需要回" "傳 :class:`float` 的實例。" -#: ../../deprecations/pending-removal-in-future.rst:30 +#: ../../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:" @@ -648,11 +643,11 @@ msgstr "" "回傳 :class:`complex` 嚴格子類別 ``__complex__()`` 方法的支援:這些方法將需要" "回傳 :class:`complex` 的實例。" -#: ../../deprecations/pending-removal-in-future.rst:33 +#: ../../deprecations/pending-removal-in-future.rst:38 msgid "Delegation of ``int()`` to ``__trunc__()`` method." msgstr "將 ``int()`` 委派給 ``__trunc__()`` 方法。" -#: ../../deprecations/pending-removal-in-future.rst:34 +#: ../../deprecations/pending-removal-in-future.rst:39 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 " @@ -662,7 +657,7 @@ msgstr "" "在 :func:`complex` 建構子中將複數作為 *real* 或 *imag* 引數傳遞現在已被棄用;" "它應該只作為單個位置引數傳遞。 (由 Serhiy Storchaka 於 :gh:`109218` 貢獻。)" -#: ../../deprecations/pending-removal-in-future.rst:39 +#: ../../deprecations/pending-removal-in-future.rst:44 msgid "" ":mod:`calendar`: ``calendar.January`` and ``calendar.February`` constants " "are deprecated and replaced by :data:`calendar.JANUARY` and :data:`calendar." @@ -672,18 +667,25 @@ msgstr "" "被 :data:`calendar.JANUARY` 和 :data:`calendar.FEBRUARY` 取代。 (由 Prince " "Roshan 於 :gh:`103636` 貢獻。)" -#: ../../deprecations/pending-removal-in-future.rst:44 +#: ../../deprecations/pending-removal-in-future.rst:49 +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:51 msgid "" ":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:47 +#: ../../deprecations/pending-removal-in-future.rst:54 msgid ":mod:`datetime`:" msgstr ":mod:`datetime`:" -#: ../../deprecations/pending-removal-in-future.rst:49 +#: ../../deprecations/pending-removal-in-future.rst:56 msgid "" ":meth:`~datetime.datetime.utcnow`: use ``datetime.datetime.now(tz=datetime." "UTC)``." @@ -691,7 +693,7 @@ msgstr "" ":meth:`~datetime.datetime.utcnow`:請改用 ``datetime.datetime." "now(tz=datetime.UTC)``。" -#: ../../deprecations/pending-removal-in-future.rst:51 +#: ../../deprecations/pending-removal-in-future.rst:58 msgid "" ":meth:`~datetime.datetime.utcfromtimestamp`: use ``datetime.datetime." "fromtimestamp(timestamp, tz=datetime.UTC)``." @@ -699,11 +701,11 @@ msgstr "" ":meth:`~datetime.datetime.utcfromtimestamp`:請改用 ``datetime.datetime." "fromtimestamp(timestamp, tz=datetime.UTC)``。" -#: ../../deprecations/pending-removal-in-future.rst:54 +#: ../../deprecations/pending-removal-in-future.rst:61 msgid ":mod:`gettext`: Plural value must be an integer." msgstr ":mod:`gettext`:複數值必須是整數。" -#: ../../deprecations/pending-removal-in-future.rst:58 +#: ../../deprecations/pending-removal-in-future.rst:65 msgid "" ":func:`~importlib.util.cache_from_source` *debug_override* parameter is " "deprecated: use the *optimization* parameter instead." @@ -711,19 +713,19 @@ msgstr "" ":func:`~importlib.util.cache_from_source` *debug_override* 參數已被棄用:請改" "用 *optimization* 參數。" -#: ../../deprecations/pending-removal-in-future.rst:61 +#: ../../deprecations/pending-removal-in-future.rst:68 msgid ":mod:`importlib.metadata`:" msgstr ":mod:`importlib.metadata`:" -#: ../../deprecations/pending-removal-in-future.rst:63 +#: ../../deprecations/pending-removal-in-future.rst:70 msgid "``EntryPoints`` tuple interface." msgstr "``EntryPoints`` 元組介面。" -#: ../../deprecations/pending-removal-in-future.rst:64 +#: ../../deprecations/pending-removal-in-future.rst:71 msgid "Implicit ``None`` on return values." msgstr "回傳值上的隱式 ``None``。" -#: ../../deprecations/pending-removal-in-future.rst:66 +#: ../../deprecations/pending-removal-in-future.rst:73 msgid "" ":mod:`logging`: the ``warn()`` method has been deprecated since Python 3.3, " "use :meth:`~logging.warning` instead." @@ -731,19 +733,19 @@ msgstr "" ":mod:`logging`:自 Python 3.3 起,``warn()`` 方法已被棄用,請改用 :meth:" "`~logging.warning`。" -#: ../../deprecations/pending-removal-in-future.rst:69 +#: ../../deprecations/pending-removal-in-future.rst:76 msgid "" ":mod:`mailbox`: Use of StringIO input and text mode is deprecated, use " "BytesIO and binary mode instead." msgstr "" ":mod:`mailbox`:已棄用 StringIO 輸入和文本模式,請改用 BytesIO 和二進位模式。" -#: ../../deprecations/pending-removal-in-future.rst:72 +#: ../../deprecations/pending-removal-in-future.rst:79 msgid "" ":mod:`os`: Calling :func:`os.register_at_fork` in multi-threaded process." msgstr ":mod:`os`:在多執行緒行程中呼叫 :func:`os.register_at_fork`。" -#: ../../deprecations/pending-removal-in-future.rst:74 +#: ../../deprecations/pending-removal-in-future.rst:81 msgid "" ":class:`!pydoc.ErrorDuringImport`: A tuple value for *exc_info* parameter is " "deprecated, use an exception instance." @@ -751,7 +753,7 @@ msgstr "" ":class:`!pydoc.ErrorDuringImport`:*exc_info* 參數的元組值已被棄用,請用例外" "實例。" -#: ../../deprecations/pending-removal-in-future.rst:77 +#: ../../deprecations/pending-removal-in-future.rst:84 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 " @@ -763,12 +765,12 @@ msgstr "" "有 ASCII 數碼序列被接受作為數值參照。位元組模式和替換字串中的群組名稱現在只能" "包含 ASCII 字母、數碼和底線。(由 Serhiy Storchaka 於 :gh:`91760` 貢獻。)" -#: ../../deprecations/pending-removal-in-future.rst:84 +#: ../../deprecations/pending-removal-in-future.rst:91 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:86 +#: ../../deprecations/pending-removal-in-future.rst:93 msgid "" ":mod:`shutil`: :func:`~shutil.rmtree`'s *onerror* parameter is deprecated in " "Python 3.12; use the *onexc* parameter instead." @@ -776,15 +778,15 @@ msgstr "" ":mod:`shutil`::func:`~shutil.rmtree` 的 *onerror* 參數在 Python 3.12 中已被" "棄用;請改用 *onexc* 參數。" -#: ../../deprecations/pending-removal-in-future.rst:89 +#: ../../deprecations/pending-removal-in-future.rst:96 msgid ":mod:`ssl` options and protocols:" msgstr ":mod:`ssl` 選項和協定:" -#: ../../deprecations/pending-removal-in-future.rst:91 +#: ../../deprecations/pending-removal-in-future.rst:98 msgid ":class:`ssl.SSLContext` without protocol argument is deprecated." msgstr "不帶協定引數的 :class:`ssl.SSLContext` 已被棄用。" -#: ../../deprecations/pending-removal-in-future.rst:92 +#: ../../deprecations/pending-removal-in-future.rst:99 msgid "" ":class:`ssl.SSLContext`: :meth:`~ssl.SSLContext.set_npn_protocols` and :meth:" "`!selected_npn_protocol` are deprecated: use ALPN instead." @@ -792,51 +794,51 @@ msgstr "" ":class:`ssl.SSLContext`::meth:`~ssl.SSLContext.set_npn_protocols` 和 :meth:" "`!selected_npn_protocol` 已被棄用:請改用 ALPN。" -#: ../../deprecations/pending-removal-in-future.rst:95 +#: ../../deprecations/pending-removal-in-future.rst:102 msgid "``ssl.OP_NO_SSL*`` options" msgstr "``ssl.OP_NO_SSL*`` 選項" -#: ../../deprecations/pending-removal-in-future.rst:96 +#: ../../deprecations/pending-removal-in-future.rst:103 msgid "``ssl.OP_NO_TLS*`` options" msgstr "``ssl.OP_NO_TLS*`` 選項" -#: ../../deprecations/pending-removal-in-future.rst:97 +#: ../../deprecations/pending-removal-in-future.rst:104 msgid "``ssl.PROTOCOL_SSLv3``" msgstr "``ssl.PROTOCOL_SSLv3``" -#: ../../deprecations/pending-removal-in-future.rst:98 +#: ../../deprecations/pending-removal-in-future.rst:105 msgid "``ssl.PROTOCOL_TLS``" msgstr "``ssl.PROTOCOL_TLS``" -#: ../../deprecations/pending-removal-in-future.rst:99 +#: ../../deprecations/pending-removal-in-future.rst:106 msgid "``ssl.PROTOCOL_TLSv1``" msgstr "``ssl.PROTOCOL_TLSv1``" -#: ../../deprecations/pending-removal-in-future.rst:100 +#: ../../deprecations/pending-removal-in-future.rst:107 msgid "``ssl.PROTOCOL_TLSv1_1``" msgstr "``ssl.PROTOCOL_TLSv1_1``" -#: ../../deprecations/pending-removal-in-future.rst:101 +#: ../../deprecations/pending-removal-in-future.rst:108 msgid "``ssl.PROTOCOL_TLSv1_2``" msgstr "``ssl.PROTOCOL_TLSv1_2``" -#: ../../deprecations/pending-removal-in-future.rst:102 +#: ../../deprecations/pending-removal-in-future.rst:109 msgid "``ssl.TLSVersion.SSLv3``" msgstr "``ssl.TLSVersion.SSLv3``" -#: ../../deprecations/pending-removal-in-future.rst:103 +#: ../../deprecations/pending-removal-in-future.rst:110 msgid "``ssl.TLSVersion.TLSv1``" msgstr "``ssl.TLSVersion.TLSv1``" -#: ../../deprecations/pending-removal-in-future.rst:104 +#: ../../deprecations/pending-removal-in-future.rst:111 msgid "``ssl.TLSVersion.TLSv1_1``" msgstr "``ssl.TLSVersion.TLSv1_1``" -#: ../../deprecations/pending-removal-in-future.rst:106 +#: ../../deprecations/pending-removal-in-future.rst:113 msgid ":mod:`threading` methods:" msgstr ":mod:`threading` 方法:" -#: ../../deprecations/pending-removal-in-future.rst:108 +#: ../../deprecations/pending-removal-in-future.rst:115 msgid "" ":meth:`!threading.Condition.notifyAll`: use :meth:`~threading.Condition." "notify_all`." @@ -844,11 +846,11 @@ msgstr "" ":meth:`!threading.Condition.notifyAll`:請用 :meth:`~threading.Condition." "notify_all`。" -#: ../../deprecations/pending-removal-in-future.rst:109 +#: ../../deprecations/pending-removal-in-future.rst:116 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:110 +#: ../../deprecations/pending-removal-in-future.rst:117 msgid "" ":meth:`!threading.Thread.isDaemon`, :meth:`threading.Thread.setDaemon`: use :" "attr:`threading.Thread.daemon` attribute." @@ -856,7 +858,7 @@ msgstr "" ":meth:`!threading.Thread.isDaemon`、:meth:`threading.Thread.setDaemon`:請" "用 :attr:`threading.Thread.daemon` 屬性。" -#: ../../deprecations/pending-removal-in-future.rst:112 +#: ../../deprecations/pending-removal-in-future.rst:119 msgid "" ":meth:`!threading.Thread.getName`, :meth:`threading.Thread.setName`: use :" "attr:`threading.Thread.name` attribute." @@ -864,20 +866,31 @@ msgstr "" ":meth:`!threading.Thread.getName`、:meth:`threading.Thread.setName`:請用 :" "attr:`threading.Thread.name` 屬性。" -#: ../../deprecations/pending-removal-in-future.rst:114 +#: ../../deprecations/pending-removal-in-future.rst:121 msgid ":meth:`!threading.currentThread`: use :meth:`threading.current_thread`." msgstr "" ":meth:`!threading.currentThread`:請用 :meth:`threading.current_thread`。" -#: ../../deprecations/pending-removal-in-future.rst:115 +#: ../../deprecations/pending-removal-in-future.rst:122 msgid ":meth:`!threading.activeCount`: use :meth:`threading.active_count`." msgstr ":meth:`!threading.activeCount`:請用 :meth:`threading.active_count`。" -#: ../../deprecations/pending-removal-in-future.rst:117 +#: ../../deprecations/pending-removal-in-future.rst:124 msgid ":class:`typing.Text` (:gh:`92332`)." msgstr ":class:`typing.Text` (:gh:`92332`)。" -#: ../../deprecations/pending-removal-in-future.rst:119 +#: ../../deprecations/pending-removal-in-future.rst:126 +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:131 msgid "" ":class:`unittest.IsolatedAsyncioTestCase`: it is deprecated to return a " "value that is not ``None`` from a test case." @@ -885,74 +898,64 @@ msgstr "" ":class:`unittest.IsolatedAsyncioTestCase`:從測試案例中回傳非 ``None`` 的值已" "被棄用。" -#: ../../deprecations/pending-removal-in-future.rst:122 +#: ../../deprecations/pending-removal-in-future.rst:134 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:124 +#: ../../deprecations/pending-removal-in-future.rst:136 msgid "``splitattr()``" msgstr "``splitattr()``" -#: ../../deprecations/pending-removal-in-future.rst:125 +#: ../../deprecations/pending-removal-in-future.rst:137 msgid "``splithost()``" msgstr "``splithost()``" -#: ../../deprecations/pending-removal-in-future.rst:126 +#: ../../deprecations/pending-removal-in-future.rst:138 msgid "``splitnport()``" msgstr "``splitnport()``" -#: ../../deprecations/pending-removal-in-future.rst:127 +#: ../../deprecations/pending-removal-in-future.rst:139 msgid "``splitpasswd()``" msgstr "``splitpasswd()``" -#: ../../deprecations/pending-removal-in-future.rst:128 +#: ../../deprecations/pending-removal-in-future.rst:140 msgid "``splitport()``" msgstr "``splitport()``" -#: ../../deprecations/pending-removal-in-future.rst:129 +#: ../../deprecations/pending-removal-in-future.rst:141 msgid "``splitquery()``" msgstr "``splitquery()``" -#: ../../deprecations/pending-removal-in-future.rst:130 +#: ../../deprecations/pending-removal-in-future.rst:142 msgid "``splittag()``" msgstr "``splittag()``" -#: ../../deprecations/pending-removal-in-future.rst:131 +#: ../../deprecations/pending-removal-in-future.rst:143 msgid "``splittype()``" msgstr "``splittype()``" -#: ../../deprecations/pending-removal-in-future.rst:132 +#: ../../deprecations/pending-removal-in-future.rst:144 msgid "``splituser()``" msgstr "``splituser()``" -#: ../../deprecations/pending-removal-in-future.rst:133 +#: ../../deprecations/pending-removal-in-future.rst:145 msgid "``splitvalue()``" msgstr "``splitvalue()``" -#: ../../deprecations/pending-removal-in-future.rst:134 +#: ../../deprecations/pending-removal-in-future.rst:146 msgid "``to_bytes()``" msgstr "``to_bytes()``" -#: ../../deprecations/pending-removal-in-future.rst:136 -msgid "" -":mod:`urllib.request`: :class:`~urllib.request.URLopener` and :class:" -"`~urllib.request.FancyURLopener` style of invoking requests is deprecated. " -"Use newer :func:`~urllib.request.urlopen` functions and methods." -msgstr "" -":mod:`urllib.request`:呼叫請求的 :class:`~urllib.request.URLopener` 和 :" -"class:`~urllib.request.FancyURLopener` 風格已被棄用。請改用更新的 :func:" -"`~urllib.request.urlopen` 函式和方法。" - -#: ../../deprecations/pending-removal-in-future.rst:140 +#: ../../deprecations/pending-removal-in-future.rst:148 msgid "" ":mod:`wsgiref`: ``SimpleHandler.stdout.write()`` should not do partial " "writes." msgstr ":mod:`wsgiref`:``SimpleHandler.stdout.write()`` 不應該進行部分寫入。" -#: ../../deprecations/pending-removal-in-future.rst:143 +#: ../../deprecations/pending-removal-in-future.rst:151 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 " @@ -963,277 +966,531 @@ msgstr "" "Element` 的真值測試。在未來版本中,它將始終回傳 ``True``。請改用明確的 " "``len(elem)`` 或 ``elem is not None`` 測試。" -#: ../../deprecations/pending-removal-in-future.rst:148 +#: ../../deprecations/pending-removal-in-future.rst:156 msgid "" -":meth:`zipimport.zipimporter.load_module` is deprecated: use :meth:" -"`~zipimport.zipimporter.exec_module` instead." +":func:`sys._clear_type_cache` is deprecated: use :func:`sys." +"_clear_internal_caches` instead." msgstr "" -":meth:`zipimport.zipimporter.load_module` 已被棄用:請改用 :meth:`~zipimport." -"zipimporter.exec_module`。" +":func:`sys._clear_type_cache` 已被棄用:請改用 :func:`sys." +"_clear_internal_caches`。" -#: ../../deprecations/index.rst:13 -msgid "C API Deprecations" +#: ../../deprecations/index.rst:15 +msgid "C API deprecations" msgstr "C API 的棄用項目" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:4 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:4 +msgid "" +"The :c:func:`PyImport_ImportModuleNoBlock`: Use :c:func:" +"`PyImport_ImportModule` instead." +msgstr "" +":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." +msgstr "" +":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 "" -"The ``ma_version_tag`` field in :c:type:`PyDictObject` for extension modules " -"(:pep:`699`; :gh:`101193`)." +":c:type:`Py_UNICODE` type and the :c:macro:`!Py_UNICODE_WIDE` macro: Use :c:" +"type:`wchar_t` instead." msgstr "" -":c:type:`PyDictObject` 中的 ``ma_version_tag`` 欄位,用於擴充模組 (:pep:" -"`699`;:gh:`101193`)。" +":c:type:`Py_UNICODE` 型別與 :c:macro:`!Py_UNICODE_WIDE` 巨集:請改用 :c:type:" +"`wchar_t`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:7 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:12 msgid "" -"Creating :c:data:`immutable types ` with mutable " -"bases (:gh:`95388`)." +":c:func:`!PyUnicode_AsDecodedObject`: Use :c:func:`PyCodec_Decode` instead." msgstr "" -"使用可變基底建立\\ :c:data:`不可變型別 ` (:gh:" -"`95388`)。" +":c:func:`!PyUnicode_AsDecodedObject`:請改用 :c:func:`PyCodec_Decode`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:10 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:14 +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 "" +":c:func:`!PyUnicode_AsDecodedUnicode`:請改用 :c:func:`PyCodec_Decode`;請注" +"意某些編解碼器(例如 \"base64\")可能會回傳非 :class:`str` 的型別,例如 :" +"class:`bytes`。" + +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:17 +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 +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 "" +":c:func:`!PyUnicode_AsEncodedUnicode`:請改用 :c:func:`PyCodec_Encode`;請注" +"意某些編解碼器(例如 \"base64\")可能會回傳非 :class:`bytes` 的型別,例如 :" +"class:`str`。" + +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:22 +msgid "Python initialization functions, deprecated in Python 3.13:" +msgstr "Python 初始化函式,自 Python 3.13 起已被棄用:" + +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:24 +msgid "" +":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\") " +"` (:data:`sys.path`)。" + +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:27 +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 "" +":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 +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 "" +":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 +msgid "" +":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`)。" + +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:41 +msgid "" +":c:func:`Py_GetProgramName`: Use :c:func:`PyConfig_Get(\"executable\") " +"` (:data:`sys.executable`) instead." +msgstr "" +":c:func:`Py_GetProgramName`:請改用 :c:func:`PyConfig_Get(\"executable\") " +"` (:data:`sys.executable`)。" + +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:44 +msgid "" +":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\") " +"` 或 :envvar:`PYTHONHOME` 環境變數。" + +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:48 +msgid "" +"The `pythoncapi-compat project `__ can be used to get :c:func:`PyConfig_Get` on Python 3.13 and older." +msgstr "" +"`pythoncapi-compat 專案 `__ 可" +"以用來為 Python 3.13 和更早版本取得 :c:func:`PyConfig_Get`。" + +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:52 msgid "" "Functions to configure Python's initialization, deprecated in Python 3.11:" -msgstr "設定 Python 初始化的函式,Python 3.11 中已被棄用:" +msgstr "用於配置 Python 初始化的函式,自 Python 3.11 起已被棄用:" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:12 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:54 msgid ":c:func:`!PySys_SetArgvEx()`: Set :c:member:`PyConfig.argv` instead." -msgstr ":c:func:`!PySys_SetArgvEx()`:請改以 :c:member:`PyConfig.argv` 設定。" +msgstr ":c:func:`!PySys_SetArgvEx()`:請改用 :c:member:`PyConfig.argv`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:14 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:56 msgid ":c:func:`!PySys_SetArgv()`: Set :c:member:`PyConfig.argv` instead." -msgstr ":c:func:`!PySys_SetArgv()`:請改以 :c:member:`PyConfig.argv` 設定。" +msgstr ":c:func:`!PySys_SetArgv()`:請改用 :c:member:`PyConfig.argv`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:16 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:58 msgid "" ":c:func:`!Py_SetProgramName()`: Set :c:member:`PyConfig.program_name` " "instead." msgstr "" -":c:func:`!Py_SetProgramName()``:請改以 :c:member:`PyConfig.program_name` 設" -"定。" +":c:func:`!Py_SetProgramName()`:請改用 :c:member:`PyConfig.program_name`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:18 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:60 msgid ":c:func:`!Py_SetPythonHome()`: Set :c:member:`PyConfig.home` instead." -msgstr ":c:func:`!Py_SetPythonHome()`:請改以 :c:member:`PyConfig.home` 設定。" +msgstr ":c:func:`!Py_SetPythonHome()`:請改用 :c:member:`PyConfig.home`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:21 -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:71 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:62 +msgid "" +":c:func:`PySys_ResetWarnOptions`: Clear :data:`sys.warnoptions` and :data:`!" +"warnings.filters` instead." +msgstr "" +":c:func:`PySys_ResetWarnOptions`:請改為清除 :data:`sys.warnoptions` 和 :" +"data:`!warnings.filters`。" + +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:65 msgid "" "The :c:func:`Py_InitializeFromConfig` API should be used with :c:type:" "`PyConfig` instead." msgstr "" -":c:func:`Py_InitializeFromConfig` API 應該與 :c:type:`PyConfig` 一起使用。" +"應改用帶有 :c:type:`PyConfig` 的 :c:func:`Py_InitializeFromConfig` API。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:24 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:68 msgid "Global configuration variables:" -msgstr "全域設定變數:" +msgstr "全域配置變數:" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:26 -msgid ":c:var:`Py_DebugFlag`: Use :c:member:`PyConfig.parser_debug` instead." -msgstr ":c:var:`Py_DebugFlag`:請改用 :c:member:`PyConfig.parser_debug`。" +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:70 +msgid "" +":c:var:`Py_DebugFlag`: Use :c:member:`PyConfig.parser_debug` or :c:func:" +"`PyConfig_Get(\"parser_debug\") ` instead." +msgstr "" +":c:var:`Py_DebugFlag`:請改用 :c:member:`PyConfig.parser_debug` 或 :c:func:" +"`PyConfig_Get(\"parser_debug\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:28 -msgid ":c:var:`Py_VerboseFlag`: Use :c:member:`PyConfig.verbose` instead." -msgstr ":c:var:`Py_VerboseFlag`:請改用 :c:member:`PyConfig.verbose`。" +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:73 +msgid "" +":c:var:`Py_VerboseFlag`: Use :c:member:`PyConfig.verbose` or :c:func:" +"`PyConfig_Get(\"verbose\") ` instead." +msgstr "" +":c:var:`Py_VerboseFlag`:請改用 :c:member:`PyConfig.verbose` 或 :c:func:" +"`PyConfig_Get(\"verbose\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:30 -msgid ":c:var:`Py_QuietFlag`: Use :c:member:`PyConfig.quiet` instead." -msgstr ":c:var:`Py_QuietFlag`:請改用 :c:member:`PyConfig.quiet`。" +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:76 +msgid "" +":c:var:`Py_QuietFlag`: Use :c:member:`PyConfig.quiet` or :c:func:" +"`PyConfig_Get(\"quiet\") ` instead." +msgstr "" +":c:var:`Py_QuietFlag`:請改用 :c:member:`PyConfig.quiet` 或 :c:func:" +"`PyConfig_Get(\"quiet\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:32 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:79 msgid "" -":c:var:`Py_InteractiveFlag`: Use :c:member:`PyConfig.interactive` instead." -msgstr ":c:var:`Py_InteractiveFlag`:請改用 :c:member:`PyConfig.interactive`。" +":c:var:`Py_InteractiveFlag`: Use :c:member:`PyConfig.interactive` or :c:func:" +"`PyConfig_Get(\"interactive\") ` instead." +msgstr "" +":c:var:`Py_InteractiveFlag`:請改用 :c:member:`PyConfig.interactive` 或 :c:" +"func:`PyConfig_Get(\"interactive\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:34 -msgid ":c:var:`Py_InspectFlag`: Use :c:member:`PyConfig.inspect` instead." -msgstr ":c:var:`Py_InspectFlag`:請改用 :c:member:`PyConfig.inspect`。" +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:82 +msgid "" +":c:var:`Py_InspectFlag`: Use :c:member:`PyConfig.inspect` or :c:func:" +"`PyConfig_Get(\"inspect\") ` instead." +msgstr "" +":c:var:`Py_InspectFlag`:請改用 :c:member:`PyConfig.inspect` 或 :c:func:" +"`PyConfig_Get(\"inspect\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:36 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:85 msgid "" -":c:var:`Py_OptimizeFlag`: Use :c:member:`PyConfig.optimization_level` " -"instead." +":c:var:`Py_OptimizeFlag`: Use :c:member:`PyConfig.optimization_level` or :c:" +"func:`PyConfig_Get(\"optimization_level\") ` instead." msgstr "" -":c:var:`Py_OptimizeFlag`:請改用 :c:member:`PyConfig.optimization_level`。" +":c:var:`Py_OptimizeFlag`:請改用 :c:member:`PyConfig.optimization_level` 或 :" +"c:func:`PyConfig_Get(\"optimization_level\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:38 -msgid ":c:var:`Py_NoSiteFlag`: Use :c:member:`PyConfig.site_import` instead." -msgstr ":c:var:`Py_NoSiteFlag`:請改用 :c:member:`PyConfig.site_import`。" +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:88 +msgid "" +":c:var:`Py_NoSiteFlag`: Use :c:member:`PyConfig.site_import` or :c:func:" +"`PyConfig_Get(\"site_import\") ` instead." +msgstr "" +":c:var:`Py_NoSiteFlag`:請改用 :c:member:`PyConfig.site_import` 或 :c:func:" +"`PyConfig_Get(\"site_import\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:40 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:91 msgid "" -":c:var:`Py_BytesWarningFlag`: Use :c:member:`PyConfig.bytes_warning` instead." +":c:var:`Py_BytesWarningFlag`: Use :c:member:`PyConfig.bytes_warning` or :c:" +"func:`PyConfig_Get(\"bytes_warning\") ` instead." msgstr "" -":c:var:`Py_BytesWarningFlag`:請改用 :c:member:`PyConfig.bytes_warning`。" +":c:var:`Py_BytesWarningFlag`:請改用 :c:member:`PyConfig.bytes_warning` 或 :" +"c:func:`PyConfig_Get(\"bytes_warning\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:42 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:94 msgid "" -":c:var:`Py_FrozenFlag`: Use :c:member:`PyConfig.pathconfig_warnings` instead." +":c:var:`Py_FrozenFlag`: Use :c:member:`PyConfig.pathconfig_warnings` or :c:" +"func:`PyConfig_Get(\"pathconfig_warnings\") ` instead." msgstr "" -":c:var:`Py_FrozenFlag`:請改用 :c:member:`PyConfig.pathconfig_warnings`。" +":c:var:`Py_FrozenFlag`:請改用 :c:member:`PyConfig.pathconfig_warnings` 或 :" +"c:func:`PyConfig_Get(\"pathconfig_warnings\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:44 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:97 msgid "" ":c:var:`Py_IgnoreEnvironmentFlag`: Use :c:member:`PyConfig.use_environment` " -"instead." +"or :c:func:`PyConfig_Get(\"use_environment\") ` instead." msgstr "" ":c:var:`Py_IgnoreEnvironmentFlag`:請改用 :c:member:`PyConfig." -"use_environment`。" +"use_environment` 或 :c:func:`PyConfig_Get(\"use_environment\") " +"`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:46 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:100 msgid "" ":c:var:`Py_DontWriteBytecodeFlag`: Use :c:member:`PyConfig.write_bytecode` " -"instead." +"or :c:func:`PyConfig_Get(\"write_bytecode\") ` instead." msgstr "" ":c:var:`Py_DontWriteBytecodeFlag`:請改用 :c:member:`PyConfig." -"write_bytecode`。" +"write_bytecode` 或 :c:func:`PyConfig_Get(\"write_bytecode\") " +"`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:48 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:103 msgid "" ":c:var:`Py_NoUserSiteDirectory`: Use :c:member:`PyConfig." -"user_site_directory` instead." +"user_site_directory` or :c:func:`PyConfig_Get(\"user_site_directory\") " +"` instead." msgstr "" ":c:var:`Py_NoUserSiteDirectory`:請改用 :c:member:`PyConfig." -"user_site_directory`。" +"user_site_directory` 或 :c:func:`PyConfig_Get(\"user_site_directory\") " +"`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:50 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:106 msgid "" -":c:var:`Py_UnbufferedStdioFlag`: Use :c:member:`PyConfig.buffered_stdio` " -"instead." +":c:var:`Py_UnbufferedStdioFlag`: Use :c:member:`PyConfig.buffered_stdio` or :" +"c:func:`PyConfig_Get(\"buffered_stdio\") ` instead." msgstr "" -":c:var:`Py_UnbufferedStdioFlag`:請改用 :c:member:`PyConfig.buffered_stdio`。" +":c:var:`Py_UnbufferedStdioFlag`:請改用 :c:member:`PyConfig.buffered_stdio` " +"或 :c:func:`PyConfig_Get(\"buffered_stdio\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:52 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:109 msgid "" ":c:var:`Py_HashRandomizationFlag`: Use :c:member:`PyConfig.use_hash_seed` " -"and :c:member:`PyConfig.hash_seed` instead." +"and :c:member:`PyConfig.hash_seed` or :c:func:`PyConfig_Get(\"hash_seed\") " +"` instead." msgstr "" ":c:var:`Py_HashRandomizationFlag`:請改用 :c:member:`PyConfig.use_hash_seed` " -"和 :c:member:`PyConfig.hash_seed`。" +"和 :c:member:`PyConfig.hash_seed` 或 :c:func:`PyConfig_Get(\"hash_seed\") " +"`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:55 -msgid ":c:var:`Py_IsolatedFlag`: Use :c:member:`PyConfig.isolated` instead." -msgstr ":c:var:`Py_IsolatedFlag`:請改用 :c:member:`PyConfig.isolated`。" +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:113 +msgid "" +":c:var:`Py_IsolatedFlag`: Use :c:member:`PyConfig.isolated` or :c:func:" +"`PyConfig_Get(\"isolated\") ` instead." +msgstr "" +":c:var:`Py_IsolatedFlag`:請改用 :c:member:`PyConfig.isolated` 或 :c:func:" +"`PyConfig_Get(\"isolated\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:57 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:116 msgid "" ":c:var:`Py_LegacyWindowsFSEncodingFlag`: Use :c:member:`PyPreConfig." -"legacy_windows_fs_encoding` instead." +"legacy_windows_fs_encoding` or :c:func:" +"`PyConfig_Get(\"legacy_windows_fs_encoding\") ` instead." msgstr "" ":c:var:`Py_LegacyWindowsFSEncodingFlag`:請改用 :c:member:`PyPreConfig." -"legacy_windows_fs_encoding`。" +"legacy_windows_fs_encoding` 或 :c:func:" +"`PyConfig_Get(\"legacy_windows_fs_encoding\") `。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:59 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:119 msgid "" ":c:var:`Py_LegacyWindowsStdioFlag`: Use :c:member:`PyConfig." -"legacy_windows_stdio` instead." +"legacy_windows_stdio` or :c:func:`PyConfig_Get(\"legacy_windows_stdio\") " +"` instead." msgstr "" ":c:var:`Py_LegacyWindowsStdioFlag`:請改用 :c:member:`PyConfig." -"legacy_windows_stdio`。" +"legacy_windows_stdio` 或 :c:func:`PyConfig_Get(\"legacy_windows_stdio\") " +"`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:61 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:122 msgid "" -":c:var:`!Py_FileSystemDefaultEncoding`: Use :c:member:`PyConfig." -"filesystem_encoding` instead." +":c:var:`!Py_FileSystemDefaultEncoding`, :c:var:`!" +"Py_HasFileSystemDefaultEncoding`: Use :c:member:`PyConfig." +"filesystem_encoding` or :c:func:`PyConfig_Get(\"filesystem_encoding\") " +"` instead." msgstr "" -":c:var:`!Py_FileSystemDefaultEncoding`:請改用 :c:member:`PyConfig." -"filesystem_encoding`。" +":c:var:`!Py_FileSystemDefaultEncoding`、:c:var:`!" +"Py_HasFileSystemDefaultEncoding`:請改用 :c:member:`PyConfig." +"filesystem_encoding` 或 :c:func:`PyConfig_Get(\"filesystem_encoding\") " +"`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:63 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:125 msgid "" -":c:var:`!Py_HasFileSystemDefaultEncoding`: Use :c:member:`PyConfig." -"filesystem_encoding` instead." +":c:var:`!Py_FileSystemDefaultEncodeErrors`: Use :c:member:`PyConfig." +"filesystem_errors` or :c:func:`PyConfig_Get(\"filesystem_errors\") " +"` instead." msgstr "" -":c:var:`!Py_HasFileSystemDefaultEncoding`:請改用 :c:member:`PyConfig." -"filesystem_encoding`。" +":c:var:`!Py_FileSystemDefaultEncodeErrors`:請改用 :c:member:`PyConfig." +"filesystem_errors` 或 :c:func:`PyConfig_Get(\"filesystem_errors\") " +"`。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:65 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:128 msgid "" -":c:var:`!Py_FileSystemDefaultEncodeErrors`: Use :c:member:`PyConfig." -"filesystem_errors` instead." +":c:var:`!Py_UTF8Mode`: Use :c:member:`PyPreConfig.utf8_mode` or :c:func:" +"`PyConfig_Get(\"utf8_mode\") ` instead. (see :c:func:" +"`Py_PreInitialize`)" msgstr "" -":c:var:`!Py_FileSystemDefaultEncodeErrors`:請改用 :c:member:`PyConfig." -"filesystem_errors`。" +":c:var:`!Py_UTF8Mode`:請改用 :c:member:`PyPreConfig.utf8_mode` 或 :c:func:" +"`PyConfig_Get(\"utf8_mode\") `。(請參閱 :c:func:" +"`Py_PreInitialize`)" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:67 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:133 msgid "" -":c:var:`!Py_UTF8Mode`: Use :c:member:`PyPreConfig.utf8_mode` instead. (see :" -"c:func:`Py_PreInitialize`)" +"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 " +"get these options at runtime." msgstr "" -":c:var:`!Py_UTF8Mode`:請改用 :c:member:`PyPreConfig.utf8_mode`。(請見 :c:" -"func:`Py_PreInitialize`)" +"應改用帶有 :c:type:`PyConfig` 的 :c:func:`Py_InitializeFromConfig` API 來設定" +"這些選項。或者也可以使用 :c:func:`PyConfig_Get` 在執行時取得這些選項。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:4 +#: ../../deprecations/c-api-pending-removal-in-3.18.rst:2 +msgid "Pending removal in Python 3.18" +msgstr "Python 3.18 中待移除的項目" + +#: ../../deprecations/c-api-pending-removal-in-3.18.rst:4 msgid "" -"The :c:func:`PyImport_ImportModuleNoBlock`: Use :c:func:" -"`PyImport_ImportModule` instead." +"The following private functions are deprecated and planned for removal in " +"Python 3.18:" +msgstr "以下私有函式已被棄用,並計劃在 Python 3.18 中移除:" + +#: ../../deprecations/c-api-pending-removal-in-3.18.rst:7 +msgid ":c:func:`!_PyBytes_Join`: use :c:func:`PyBytes_Join`." +msgstr ":c:func:`!_PyBytes_Join`:請改用 :c:func:`PyBytes_Join`。" + +#: ../../deprecations/c-api-pending-removal-in-3.18.rst:8 +msgid "" +":c:func:`!_PyDict_GetItemStringWithError`: use :c:func:" +"`PyDict_GetItemStringRef`." msgstr "" -":c:func:`PyImport_ImportModuleNoBlock`:請改用 :c:func:" -"`PyImport_ImportModule`。" +":c:func:`!_PyDict_GetItemStringWithError`:請改用 :c:func:" +"`PyDict_GetItemStringRef`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:6 +#: ../../deprecations/c-api-pending-removal-in-3.18.rst:9 +msgid ":c:func:`!_PyDict_Pop()`: use :c:func:`PyDict_Pop`." +msgstr ":c:func:`!_PyDict_Pop()`:請改用 :c:func:`PyDict_Pop`。" + +#: ../../deprecations/c-api-pending-removal-in-3.18.rst:10 +msgid ":c:func:`!_PyLong_Sign()`: use :c:func:`PyLong_GetSign`." +msgstr ":c:func:`!_PyLong_Sign()`:請改用 :c:func:`PyLong_GetSign`。" + +#: ../../deprecations/c-api-pending-removal-in-3.18.rst:11 msgid "" -":c:func:`PyWeakref_GetObject` and :c:func:`PyWeakref_GET_OBJECT`: Use :c:" -"func:`PyWeakref_GetRef` instead." +":c:func:`!_PyLong_FromDigits` and :c:func:`!_PyLong_New`: use :c:func:" +"`PyLongWriter_Create`." msgstr "" -":c:func:`PyWeakref_GetObject` 和 :c:func:`PyWeakref_GET_OBJECT`:請改用 :c:" -"func:`PyWeakref_GetRef`。" +":c:func:`!_PyLong_FromDigits` 和 :c:func:`!_PyLong_New`:請改用 :c:func:" +"`PyLongWriter_Create`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:8 +#: ../../deprecations/c-api-pending-removal-in-3.18.rst:13 msgid "" -":c:type:`Py_UNICODE` type and the :c:macro:`!Py_UNICODE_WIDE` macro: Use :c:" -"type:`wchar_t` instead." +":c:func:`!_PyThreadState_UncheckedGet`: use :c:func:" +"`PyThreadState_GetUnchecked`." msgstr "" -":c:type:`Py_UNICODE` 型別與 :c:macro:`!Py_UNICODE_WIDE` 巨集:請改用 :c:type:" -"`wchar_t`。" +":c:func:`!_PyThreadState_UncheckedGet`:請改用 :c:func:" +"`PyThreadState_GetUnchecked`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:10 -msgid "Python initialization functions:" -msgstr "Python 初始化函式:" +#: ../../deprecations/c-api-pending-removal-in-3.18.rst:14 +msgid ":c:func:`!_PyUnicode_AsString`: use :c:func:`PyUnicode_AsUTF8`." +msgstr ":c:func:`!_PyUnicode_AsString`:請改用 :c:func:`PyUnicode_AsUTF8`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:12 +#: ../../deprecations/c-api-pending-removal-in-3.18.rst:15 msgid "" -":c:func:`PySys_ResetWarnOptions`: Clear :data:`sys.warnoptions` and :data:`!" -"warnings.filters` instead." +":c:func:`!_PyUnicodeWriter_Init`: replace ``_PyUnicodeWriter_Init(&writer)`` " +"with :c:func:`writer = PyUnicodeWriter_Create(0) `." msgstr "" -":c:func:`PySys_ResetWarnOptions`:請改為清除 :data:`sys.warnoptions` 和 :" -"data:`!warnings.filters`。" +":c:func:`!_PyUnicodeWriter_Init`:將 ``_PyUnicodeWriter_Init(&writer)`` 替換" +"為 :c:func:`writer = PyUnicodeWriter_Create(0) `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:14 +#: ../../deprecations/c-api-pending-removal-in-3.18.rst:18 msgid "" -":c:func:`Py_GetExecPrefix`: Get :data:`sys.base_exec_prefix` and :data:`sys." -"exec_prefix` instead." +":c:func:`!_PyUnicodeWriter_Finish`: replace " +"``_PyUnicodeWriter_Finish(&writer)`` with :c:func:" +"`PyUnicodeWriter_Finish(writer) `." msgstr "" -":c:func:`Py_GetExecPrefix`:請改用 :data:`sys.base_exec_prefix` 與 :data:" -"`sys.exec_prefix`。" +":c:func:`!_PyUnicodeWriter_Finish`:將 ``_PyUnicodeWriter_Finish(&writer)`` " +"替換為 :c:func:`PyUnicodeWriter_Finish(writer) `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:16 -msgid ":c:func:`Py_GetPath`: Get :data:`sys.path` instead." -msgstr ":c:func:`Py_GetPath`:請改用 :data:`sys.path`。" +#: ../../deprecations/c-api-pending-removal-in-3.18.rst:21 +msgid "" +":c:func:`!_PyUnicodeWriter_Dealloc`: replace " +"``_PyUnicodeWriter_Dealloc(&writer)`` with :c:func:" +"`PyUnicodeWriter_Discard(writer) `." +msgstr "" +":c:func:`!_PyUnicodeWriter_Dealloc`:將 " +"``_PyUnicodeWriter_Dealloc(&writer)`` 替換為 :c:func:" +"`PyUnicodeWriter_Discard(writer) `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:18 +#: ../../deprecations/c-api-pending-removal-in-3.18.rst:24 msgid "" -":c:func:`Py_GetPrefix`: Get :data:`sys.base_prefix` and :data:`sys.prefix` " -"instead." +":c:func:`!_PyUnicodeWriter_WriteChar`: replace " +"``_PyUnicodeWriter_WriteChar(&writer, ch)`` with :c:func:" +"`PyUnicodeWriter_WriteChar(writer, ch) `." msgstr "" -":c:func:`Py_GetPrefix`:請改用 :data:`sys.base_prefix` 與 :data:`sys." -"prefix`。" +":c:func:`!_PyUnicodeWriter_WriteChar`:將 " +"``_PyUnicodeWriter_WriteChar(&writer, ch)`` 替換為 :c:func:" +"`PyUnicodeWriter_WriteChar(writer, ch) `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:20 -msgid ":c:func:`Py_GetProgramFullPath`: Get :data:`sys.executable` instead." -msgstr ":c:func:`Py_GetProgramFullPath`:請改用 :data:`sys.executable`。" +#: ../../deprecations/c-api-pending-removal-in-3.18.rst:27 +msgid "" +":c:func:`!_PyUnicodeWriter_WriteStr`: replace " +"``_PyUnicodeWriter_WriteStr(&writer, str)`` with :c:func:" +"`PyUnicodeWriter_WriteStr(writer, str) `." +msgstr "" +":c:func:`!_PyUnicodeWriter_WriteStr`:將 " +"``_PyUnicodeWriter_WriteStr(&writer, str)`` 替換為 :c:func:" +"`PyUnicodeWriter_WriteStr(writer, str) `。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:22 -msgid ":c:func:`Py_GetProgramName`: Get :data:`sys.executable` instead." -msgstr ":c:func:`Py_GetProgramName`:請改用 :data:`sys.executable`。" +#: ../../deprecations/c-api-pending-removal-in-3.18.rst:30 +msgid "" +":c:func:`!_PyUnicodeWriter_WriteSubstring`: replace " +"``_PyUnicodeWriter_WriteSubstring(&writer, str, start, end)`` with :c:func:" +"`PyUnicodeWriter_WriteSubstring(writer, str, start, end) " +"`." +msgstr "" +":c:func:`!_PyUnicodeWriter_WriteSubstring`:將 " +"``_PyUnicodeWriter_WriteSubstring(&writer, str, start, end)`` 替換為 :c:func:" +"`PyUnicodeWriter_WriteSubstring(writer, str, start, end) " +"`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:24 +#: ../../deprecations/c-api-pending-removal-in-3.18.rst:33 +msgid "" +":c:func:`!_PyUnicodeWriter_WriteASCIIString`: replace " +"``_PyUnicodeWriter_WriteASCIIString(&writer, str)`` with :c:func:" +"`PyUnicodeWriter_WriteASCII(writer, str) `." +msgstr "" +":c:func:`!_PyUnicodeWriter_WriteASCIIString`:將 " +"``_PyUnicodeWriter_WriteASCIIString(&writer, str)`` 替換為 :c:func:" +"`PyUnicodeWriter_WriteASCII(writer, str) `。" + +#: ../../deprecations/c-api-pending-removal-in-3.18.rst:36 +msgid "" +":c:func:`!_PyUnicodeWriter_WriteLatin1String`: replace " +"``_PyUnicodeWriter_WriteLatin1String(&writer, str)`` with :c:func:" +"`PyUnicodeWriter_WriteUTF8(writer, str) `." +msgstr "" +":c:func:`!_PyUnicodeWriter_WriteLatin1String`:將 " +"``_PyUnicodeWriter_WriteLatin1String(&writer, str)`` 替換為 :c:func:" +"`PyUnicodeWriter_WriteUTF8(writer, str) `。" + +#: ../../deprecations/c-api-pending-removal-in-3.18.rst:39 +msgid ":c:func:`!_PyUnicodeWriter_Prepare`: (no replacement)." +msgstr ":c:func:`!_PyUnicodeWriter_Prepare`:(無替代方案)。" + +#: ../../deprecations/c-api-pending-removal-in-3.18.rst:40 +msgid ":c:func:`!_PyUnicodeWriter_PrepareKind`: (no replacement)." +msgstr ":c:func:`!_PyUnicodeWriter_PrepareKind`:(無替代方案)。" + +#: ../../deprecations/c-api-pending-removal-in-3.18.rst:41 +msgid ":c:func:`!_Py_HashPointer`: use :c:func:`Py_HashPointer`." +msgstr ":c:func:`!_Py_HashPointer`:請改用 :c:func:`Py_HashPointer`。" + +#: ../../deprecations/c-api-pending-removal-in-3.18.rst:42 +msgid ":c:func:`!_Py_fopen_obj`: use :c:func:`Py_fopen`." +msgstr ":c:func:`!_Py_fopen_obj`:請改用 :c:func:`Py_fopen`。" + +#: ../../deprecations/c-api-pending-removal-in-3.18.rst:44 msgid "" -":c:func:`Py_GetPythonHome`: Get :c:member:`PyConfig.home` or the :envvar:" -"`PYTHONHOME` environment variable instead." +"The `pythoncapi-compat project `__ can be used to get these new public functions on Python 3.13 and older. " +"(Contributed by Victor Stinner in :gh:`128863`.)" msgstr "" -":c:func:`Py_GetPythonHome`:請改用 :c:member:`PyConfig.home` 或 :envvar:" -"`PYTHONHOME` 環境變數。" +"可以使用 `pythoncapi-compat project `__ 來取得這些於 Python 3.13 及更早版本的新公開函式。(由 Victor " +"Stinner 在 :gh:`128863` 貢獻)" #: ../../deprecations/c-api-pending-removal-in-future.rst:4 msgid "" @@ -1282,45 +1539,21 @@ msgstr "" "`PySlice_AdjustIndices`。" #: ../../deprecations/c-api-pending-removal-in-future.rst:21 -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-future.rst:23 -msgid "" -":c:func:`!PyUnicode_AsDecodedUnicode`: Use :c:func:`PyCodec_Decode` instead." -msgstr "" -":c:func:`!PyUnicode_AsDecodedUnicode`:請改用 :c:func:`PyCodec_Decode`。" - -#: ../../deprecations/c-api-pending-removal-in-future.rst:25 -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-future.rst:27 -msgid "" -":c:func:`!PyUnicode_AsEncodedUnicode`: Use :c:func:`PyCodec_Encode` instead." -msgstr "" -":c:func:`!PyUnicode_AsEncodedUnicode`:請改用 :c:func:`PyCodec_Encode`。" - -#: ../../deprecations/c-api-pending-removal-in-future.rst:29 msgid ":c:func:`PyUnicode_READY`: Unneeded since Python 3.12" msgstr ":c:func:`PyUnicode_READY`:自 Python 3.12 起不再需要" -#: ../../deprecations/c-api-pending-removal-in-future.rst:31 +#: ../../deprecations/c-api-pending-removal-in-future.rst:23 msgid ":c:func:`!PyErr_Display`: Use :c:func:`PyErr_DisplayException` instead." msgstr ":c:func:`!PyErr_Display`:請改用 :c:func:`PyErr_DisplayException`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:33 +#: ../../deprecations/c-api-pending-removal-in-future.rst:25 msgid "" ":c:func:`!_PyErr_ChainExceptions`: Use :c:func:`!_PyErr_ChainExceptions1` " "instead." msgstr "" ":c:func:`!_PyErr_ChainExceptions`:請改用 ``_PyErr_ChainExceptions1``。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:35 +#: ../../deprecations/c-api-pending-removal-in-future.rst:27 msgid "" ":c:member:`!PyBytesObject.ob_shash` member: call :c:func:`PyObject_Hash` " "instead." @@ -1328,46 +1561,36 @@ msgstr "" ":c:member:`!PyBytesObject.ob_shash` 成員:請改為呼叫 :c:func:" "`PyObject_Hash`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:37 -msgid ":c:member:`!PyDictObject.ma_version_tag` member." -msgstr ":c:member:`!PyDictObject.ma_version_tag` 成員。" - -#: ../../deprecations/c-api-pending-removal-in-future.rst:38 +#: ../../deprecations/c-api-pending-removal-in-future.rst:29 msgid "Thread Local Storage (TLS) API:" msgstr "執行緒局部儲存 (Thread Local Storage, TLS) API:" -#: ../../deprecations/c-api-pending-removal-in-future.rst:40 +#: ../../deprecations/c-api-pending-removal-in-future.rst:31 msgid "" ":c:func:`PyThread_create_key`: Use :c:func:`PyThread_tss_alloc` instead." msgstr ":c:func:`PyThread_create_key`:請改用 :c:func:`PyThread_tss_alloc`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:42 +#: ../../deprecations/c-api-pending-removal-in-future.rst:33 msgid ":c:func:`PyThread_delete_key`: Use :c:func:`PyThread_tss_free` instead." msgstr ":c:func:`PyThread_delete_key`:請改用 :c:func:`PyThread_tss_free`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:44 +#: ../../deprecations/c-api-pending-removal-in-future.rst:35 msgid "" ":c:func:`PyThread_set_key_value`: Use :c:func:`PyThread_tss_set` instead." msgstr ":c:func:`PyThread_set_key_value`:請改用 :c:func:`PyThread_tss_set`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:46 +#: ../../deprecations/c-api-pending-removal-in-future.rst:37 msgid "" ":c:func:`PyThread_get_key_value`: Use :c:func:`PyThread_tss_get` instead." msgstr ":c:func:`PyThread_get_key_value`:請改用 :c:func:`PyThread_tss_get`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:48 +#: ../../deprecations/c-api-pending-removal-in-future.rst:39 msgid "" ":c:func:`PyThread_delete_key_value`: Use :c:func:`PyThread_tss_delete` " "instead." msgstr "" ":c:func:`PyThread_delete_key_value`:請改用 :c:func:`PyThread_tss_delete`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:50 +#: ../../deprecations/c-api-pending-removal-in-future.rst:41 msgid ":c:func:`PyThread_ReInitTLS`: Unneeded since Python 3.7." msgstr ":c:func:`PyThread_ReInitTLS`:自 Python 3.7 起不再需要。" - -#~ msgid "The bundled copy of ``libmpdecimal``." -#~ msgstr "``libmpdecimal`` 的打包副本 (bundled copy)。" - -#~ msgid ":mod:`array`'s ``'u'`` format code (:gh:`57281`)" -#~ msgstr ":mod:`array` 的 ``'u'`` 格式碼 (:gh:`57281`)" diff --git a/deprecations/pending-removal-in-3.13.po b/deprecations/pending-removal-in-3.13.po index 6e382beeb8d..75a9fcc92ae 100644 --- a/deprecations/pending-removal-in-3.13.po +++ b/deprecations/pending-removal-in-3.13.po @@ -1,11 +1,11 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-11-14 19:37+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-" @@ -16,7 +16,7 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" #: ../../deprecations/pending-removal-in-3.13.rst:2 -msgid "Pending Removal in Python 3.13" +msgid "Pending removal in Python 3.13" msgstr "Python 3.13 中待移除的項目" #: ../../deprecations/pending-removal-in-3.13.rst:4 @@ -146,45 +146,3 @@ msgstr ":class:`!webbrowser.MacOSX` (:gh:`86421`)" #: ../../deprecations/pending-removal-in-3.13.rst:40 msgid ":class:`classmethod` descriptor chaining (:gh:`89519`)" msgstr ":class:`classmethod` 描述器鏈接 (:gh:`89519`)" - -#: ../../deprecations/pending-removal-in-3.13.rst:41 -msgid ":mod:`importlib.resources` deprecated methods:" -msgstr ":mod:`importlib.resources` 的已棄用方法:" - -#: ../../deprecations/pending-removal-in-3.13.rst:43 -msgid "``contents()``" -msgstr "``contents()``" - -#: ../../deprecations/pending-removal-in-3.13.rst:44 -msgid "``is_resource()``" -msgstr "``is_resource()``" - -#: ../../deprecations/pending-removal-in-3.13.rst:45 -msgid "``open_binary()``" -msgstr "``open_binary()``" - -#: ../../deprecations/pending-removal-in-3.13.rst:46 -msgid "``open_text()``" -msgstr "``open_text()``" - -#: ../../deprecations/pending-removal-in-3.13.rst:47 -msgid "``path()``" -msgstr "``path()``" - -#: ../../deprecations/pending-removal-in-3.13.rst:48 -msgid "``read_binary()``" -msgstr "``read_binary()``" - -#: ../../deprecations/pending-removal-in-3.13.rst:49 -msgid "``read_text()``" -msgstr "``read_text()``" - -#: ../../deprecations/pending-removal-in-3.13.rst:51 -msgid "" -"Use :func:`importlib.resources.files` instead. Refer to `importlib-" -"resources: Migrating from Legacy `_ (:gh:`106531`)" -msgstr "" -"請改用 :func:`importlib.resources.files`。請參閱 `importlib-resources: " -"Migrating from Legacy `_ (:gh:`106531`)" diff --git a/deprecations/pending-removal-in-3.14.po b/deprecations/pending-removal-in-3.14.po index bd8e164bd38..add170a79b4 100644 --- a/deprecations/pending-removal-in-3.14.po +++ b/deprecations/pending-removal-in-3.14.po @@ -1,11 +1,11 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-11-10 17:21+0000\n" +"POT-Creation-Date: 2025-09-18 00:15+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -16,7 +16,7 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" #: ../../deprecations/pending-removal-in-3.14.rst:2 -msgid "Pending Removal in Python 3.14" +msgid "Pending removal in Python 3.14" msgstr "Python 3.14 中待移除的項目" #: ../../deprecations/pending-removal-in-3.14.rst:4 @@ -60,8 +60,8 @@ msgstr ":class:`!ast.Ellipsis`" #: ../../deprecations/pending-removal-in-3.14.rst:19 msgid "" -"Use :class:`ast.Constant` instead. (Contributed by Serhiy Storchaka " -"in :gh:`90953`.)" +"Use :class:`ast.Constant` instead. (Contributed by Serhiy Storchaka in :gh:" +"`90953`.)" msgstr "" "請改用 :class:`ast.Constant`。(由 Serhiy Storchaka 於 :gh:`90953` 貢獻。)" @@ -71,26 +71,27 @@ msgstr ":mod:`asyncio`:" #: ../../deprecations/pending-removal-in-3.14.rst:24 msgid "" -"The child watcher " -"classes :class:`~asyncio.MultiLoopChildWatcher`, :class:`~asyncio.FastChildWatcher`, :class:`~asyncio.AbstractChildWatcher` " -"and :class:`~asyncio.SafeChildWatcher` are deprecated and will be removed in " -"Python 3.14. (Contributed by Kumar Aditya in :gh:`94597`.)" +"The child watcher classes :class:`!asyncio.MultiLoopChildWatcher`, :class:`!" +"asyncio.FastChildWatcher`, :class:`!asyncio.AbstractChildWatcher` and :class:" +"`!asyncio.SafeChildWatcher` are deprecated and will be removed in Python " +"3.14. (Contributed by Kumar Aditya in :gh:`94597`.)" msgstr "" -"已棄用並將在 Python 3.14 中移除的 child watcher 類" -"別::class:`~asyncio.MultiLoopChildWatcher`、:class:`~asyncio.FastChildWatcher`、:class:`~asyncio.AbstractChildWatcher` " -"和 :class:`~asyncio.SafeChildWatcher`。 (由 Kumar Aditya 於 :gh:`94597` 貢" -"獻。)" +"已棄用並將在 Python 3.14 中移除的 child watcher 類別::class:`!asyncio." +"MultiLoopChildWatcher`、:class:`!asyncio.FastChildWatcher`、:class:`!asyncio." +"AbstractChildWatcher` 和 :class:`!asyncio.SafeChildWatcher`。 (由 Kumar " +"Aditya 於 :gh:`94597` 貢獻。)" #: ../../deprecations/pending-removal-in-3.14.rst:30 msgid "" -":func:`asyncio.set_child_watcher`, :func:`asyncio.get_child_watcher`, :meth:`asyncio.AbstractEventLoopPolicy.set_child_watcher` " -"and :meth:`asyncio.AbstractEventLoopPolicy.get_child_watcher` are deprecated " -"and will be removed in Python 3.14. (Contributed by Kumar Aditya " -"in :gh:`94597`.)" +":func:`!asyncio.set_child_watcher`, :func:`!asyncio.get_child_watcher`, :" +"meth:`!asyncio.AbstractEventLoopPolicy.set_child_watcher` and :meth:`!" +"asyncio.AbstractEventLoopPolicy.get_child_watcher` are deprecated and will " +"be removed in Python 3.14. (Contributed by Kumar Aditya in :gh:`94597`.)" msgstr "" -":func:`asyncio.set_child_watcher`、:func:`asyncio.get_child_watcher`、:meth:`asyncio.AbstractEventLoopPolicy.set_child_watcher` " -"和 :meth:`asyncio.AbstractEventLoopPolicy.get_child_watcher` 已被棄用並將在 " -"Python 3.14 中移除。(由 Kumar Aditya 於 :gh:`94597` 貢獻。)" +":func:`!asyncio.set_child_watcher`、:func:`!asyncio.get_child_watcher`、:" +"meth:`!asyncio.AbstractEventLoopPolicy.set_child_watcher` 和 :meth:`!asyncio." +"AbstractEventLoopPolicy.get_child_watcher` 已被棄用並將在 Python 3.14 中移" +"除。(由 Kumar Aditya 於 :gh:`94597` 貢獻。)" #: ../../deprecations/pending-removal-in-3.14.rst:36 msgid "" @@ -105,60 +106,45 @@ msgstr "" #: ../../deprecations/pending-removal-in-3.14.rst:41 msgid "" -":mod:`collections.abc`: Deprecated :class:`~collections.abc.ByteString`. " -"Prefer :class:`!Sequence` or :class:`~collections.abc.Buffer`. For use in " -"typing, prefer a union, like ``bytes | bytearray``, " -"or :class:`collections.abc.Buffer`. (Contributed by Shantanu Jain " -"in :gh:`91896`.)" -msgstr "" -":mod:`collections.abc`:已棄用 :class:`~collections.abc.ByteString`。請改" -"用 :class:`!Sequence` 或 :class:`~collections.abc.Buffer`。在 typing 中使用" -"時,請改用聯集,如 ``bytes | bytearray``," -"或 :class:`collections.abc.Buffer`。(由 Shantanu Jain 於 :gh:`91896` 貢" -"獻。)" - -#: ../../deprecations/pending-removal-in-3.14.rst:47 -msgid "" -":mod:`email`: Deprecated the *isdst* parameter " -"in :func:`email.utils.localtime`. (Contributed by Alan Williams " -"in :gh:`72346`.)" +":mod:`email`: Deprecated the *isdst* parameter in :func:`email.utils." +"localtime`. (Contributed by Alan Williams in :gh:`72346`.)" msgstr "" ":mod:`email`:已棄用 :func:`email.utils.localtime` 中的 *isdst* 參數。(由 " "Alan Williams 於 :gh:`72346` 貢獻。)" -#: ../../deprecations/pending-removal-in-3.14.rst:50 +#: ../../deprecations/pending-removal-in-3.14.rst:44 msgid ":mod:`importlib.abc` deprecated classes:" msgstr ":mod:`importlib.abc` 的已棄用類別:" -#: ../../deprecations/pending-removal-in-3.14.rst:52 +#: ../../deprecations/pending-removal-in-3.14.rst:46 msgid ":class:`!importlib.abc.ResourceReader`" msgstr ":class:`!importlib.abc.ResourceReader`" -#: ../../deprecations/pending-removal-in-3.14.rst:53 +#: ../../deprecations/pending-removal-in-3.14.rst:47 msgid ":class:`!importlib.abc.Traversable`" msgstr ":class:`!importlib.abc.Traversable`" -#: ../../deprecations/pending-removal-in-3.14.rst:54 +#: ../../deprecations/pending-removal-in-3.14.rst:48 msgid ":class:`!importlib.abc.TraversableResources`" msgstr ":class:`!importlib.abc.TraversableResources`" -#: ../../deprecations/pending-removal-in-3.14.rst:56 +#: ../../deprecations/pending-removal-in-3.14.rst:50 msgid "Use :mod:`importlib.resources.abc` classes instead:" msgstr "請改用 :mod:`importlib.resources.abc` 類別:" -#: ../../deprecations/pending-removal-in-3.14.rst:58 +#: ../../deprecations/pending-removal-in-3.14.rst:52 msgid ":class:`importlib.resources.abc.Traversable`" msgstr ":class:`importlib.resources.abc.Traversable`" -#: ../../deprecations/pending-removal-in-3.14.rst:59 +#: ../../deprecations/pending-removal-in-3.14.rst:53 msgid ":class:`importlib.resources.abc.TraversableResources`" msgstr ":class:`importlib.resources.abc.TraversableResources`" -#: ../../deprecations/pending-removal-in-3.14.rst:61 +#: ../../deprecations/pending-removal-in-3.14.rst:55 msgid "(Contributed by Jason R. Coombs and Hugo van Kemenade in :gh:`93963`.)" msgstr "(由 Jason R. Coombs 和 Hugo van Kemenade 貢獻於 :gh:`93963`。)" -#: ../../deprecations/pending-removal-in-3.14.rst:63 +#: ../../deprecations/pending-removal-in-3.14.rst:57 msgid "" ":mod:`itertools` had undocumented, inefficient, historically buggy, and " "inconsistent support for copy, deepcopy, and pickle operations. This will be " @@ -169,86 +155,94 @@ msgstr "" "deepcopy 和 pickle 操作支援。將在 3.14 中移除以大幅減少程式碼量和維護負擔。 " "(由 Raymond Hettinger 於 :gh:`101588` 貢獻。)" -#: ../../deprecations/pending-removal-in-3.14.rst:69 +#: ../../deprecations/pending-removal-in-3.14.rst:63 msgid "" ":mod:`multiprocessing`: The default start method will change to a safer one " "on Linux, BSDs, and other non-macOS POSIX platforms where ``'fork'`` is " "currently the default (:gh:`84559`). Adding a runtime warning about this was " "deemed too disruptive as the majority of code is not expected to care. Use " -"the :func:`~multiprocessing.get_context` " -"or :func:`~multiprocessing.set_start_method` APIs to explicitly specify when " -"your code *requires* ``'fork'``. See :ref:`multiprocessing-start-methods`." +"the :func:`~multiprocessing.get_context` or :func:`~multiprocessing." +"set_start_method` APIs to explicitly specify when your code *requires* " +"``'fork'``. See :ref:`multiprocessing-start-methods`." msgstr "" ":mod:`multiprocessing`:預設的啟動方法將在 Linux、BSD 和其他非 macOS POSIX 平" "台上更改為更安全的 方法,目前 ``'fork'`` 是預設值 (:gh:`84559`)。對此增加一" -"個 runtime 警告被認為太過擾人,因為 大多數程式碼不會在意。請使" -"用 :func:`~multiprocessing.get_context` " -"或 :func:`~multiprocessing.set_start_method` API 來明確指定你的程式碼何時\\ *" -"需要* ``'fork'``。請參閱 :ref:`multiprocessing-start-methods`。" +"個 runtime 警告被認為太過擾人,因為 大多數程式碼不會在意。請使用 :func:" +"`~multiprocessing.get_context` 或 :func:`~multiprocessing.set_start_method` " +"API 來明確指定你的程式碼何時\\ *需要* ``'fork'``。請參閱 :ref:" +"`multiprocessing-start-methods`。" -#: ../../deprecations/pending-removal-in-3.14.rst:77 +#: ../../deprecations/pending-removal-in-3.14.rst:71 msgid "" -":mod:`pathlib`: :meth:`~pathlib.PurePath.is_relative_to` " -"and :meth:`~pathlib.PurePath.relative_to`: passing additional arguments is " -"deprecated." +":mod:`pathlib`: :meth:`~pathlib.PurePath.is_relative_to` and :meth:`~pathlib." +"PurePath.relative_to`: passing additional arguments is deprecated." msgstr "" -":mod:`pathlib`:已棄用 :meth:`~pathlib.PurePath.is_relative_to` " -"和 :meth:`~pathlib.PurePath.relative_to`:額外引數的傳遞已被棄用。" +":mod:`pathlib`:已棄用 :meth:`~pathlib.PurePath.is_relative_to` 和 :meth:" +"`~pathlib.PurePath.relative_to`:額外引數的傳遞已被棄用。" -#: ../../deprecations/pending-removal-in-3.14.rst:81 +#: ../../deprecations/pending-removal-in-3.14.rst:75 msgid "" -":mod:`pkgutil`: :func:`~pkgutil.find_loader` and :func:`~pkgutil.get_loader` " +":mod:`pkgutil`: :func:`!pkgutil.find_loader` and :func:`!pkgutil.get_loader` " "now raise :exc:`DeprecationWarning`; use :func:`importlib.util.find_spec` " "instead. (Contributed by Nikita Sobolev in :gh:`97850`.)" msgstr "" -":mod:`pkgutil`::func:`~pkgutil.find_loader` 和 :func:`~pkgutil.get_loader` " -"現在會引發 :exc:`DeprecationWarning`;請改" -"用 :func:`importlib.util.find_spec`。 (由 Nikita Sobolev 於 :gh:`97850` 貢" -"獻。)" +":mod:`pkgutil`::func:`!pkgutil.find_loader` 和 :func:`!pkgutil.get_loader` " +"現在會引發 :exc:`DeprecationWarning`;請改用 :func:`importlib.util." +"find_spec`。 (由 Nikita Sobolev 於 :gh:`97850` 貢獻。)" -#: ../../deprecations/pending-removal-in-3.14.rst:86 +#: ../../deprecations/pending-removal-in-3.14.rst:80 msgid ":mod:`pty`:" msgstr ":mod:`pty`:" -#: ../../deprecations/pending-removal-in-3.14.rst:88 +#: ../../deprecations/pending-removal-in-3.14.rst:82 msgid "``master_open()``: use :func:`pty.openpty`." msgstr "``master_open()``:請用 :func:`pty.openpty`。" -#: ../../deprecations/pending-removal-in-3.14.rst:89 +#: ../../deprecations/pending-removal-in-3.14.rst:83 msgid "``slave_open()``: use :func:`pty.openpty`." msgstr "``slave_open()``:請用 :func:`pty.openpty`。" -#: ../../deprecations/pending-removal-in-3.14.rst:91 +#: ../../deprecations/pending-removal-in-3.14.rst:85 msgid ":mod:`sqlite3`:" msgstr ":mod:`sqlite3`:" -#: ../../deprecations/pending-removal-in-3.14.rst:93 -msgid ":data:`~sqlite3.version` and :data:`~sqlite3.version_info`." -msgstr ":data:`~sqlite3.version` 和 :data:`~sqlite3.version_info`。" +#: ../../deprecations/pending-removal-in-3.14.rst:87 +msgid ":data:`!version` and :data:`!version_info`." +msgstr ":data:`!version` 和 :data:`!version_info`。" -#: ../../deprecations/pending-removal-in-3.14.rst:95 +#: ../../deprecations/pending-removal-in-3.14.rst:89 msgid "" -":meth:`~sqlite3.Cursor.execute` and :meth:`~sqlite3.Cursor.executemany` " -"if :ref:`named placeholders ` are used and " -"*parameters* is a sequence instead of a :class:`dict`." +":meth:`~sqlite3.Cursor.execute` and :meth:`~sqlite3.Cursor.executemany` if :" +"ref:`named placeholders ` are used and *parameters* is " +"a sequence instead of a :class:`dict`." msgstr "" ":meth:`~sqlite3.Cursor.execute` 和 :meth:`~sqlite3.Cursor.executemany`,如果" "使用 :ref:`named placeholders ` 且 *parameters* 是序列" "而不是 :class:`dict`。" -#: ../../deprecations/pending-removal-in-3.14.rst:99 -msgid "" -":mod:`typing`: :class:`~typing.ByteString`, deprecated since Python 3.9, now " -"causes a :exc:`DeprecationWarning` to be emitted when it is used." -msgstr "" -":mod:`typing`:自 Python 3.9 起已被棄用的 :class:`~typing.ByteString` 現在在" -"使用時會發出 :exc:`DeprecationWarning`。" - -#: ../../deprecations/pending-removal-in-3.14.rst:102 +#: ../../deprecations/pending-removal-in-3.14.rst:93 msgid "" ":mod:`urllib`: :class:`!urllib.parse.Quoter` is deprecated: it was not " -"intended to be a public API. (Contributed by Gregory P. Smith " -"in :gh:`88168`.)" +"intended to be a public API. (Contributed by Gregory P. Smith in :gh:" +"`88168`.)" msgstr "" ":mod:`urllib`::class:`!urllib.parse.Quoter` 已被棄用:它並非預期的公開 API。" "(由 Gregory P. Smith 於 :gh:`88168` 貢獻。)" + +#~ msgid "" +#~ ":mod:`collections.abc`: Deprecated :class:`!collections.abc.ByteString`. " +#~ "Prefer :class:`!Sequence` or :class:`~collections.abc.Buffer`. For use in " +#~ "typing, prefer a union, like ``bytes | bytearray``, or :class:" +#~ "`collections.abc.Buffer`. (Contributed by Shantanu Jain in :gh:`91896`.)" +#~ msgstr "" +#~ ":mod:`collections.abc`:已棄用 :class:`!collections.abc.ByteString`。請改" +#~ "用 :class:`!Sequence` 或 :class:`~collections.abc.Buffer`。在 typing 中使" +#~ "用時,請改用聯集,如 ``bytes | bytearray``,或 :class:`collections.abc." +#~ "Buffer`。(由 Shantanu Jain 於 :gh:`91896` 貢獻。)" + +#~ msgid "" +#~ ":mod:`typing`: :class:`!typing.ByteString`, deprecated since Python 3.9, " +#~ "now causes a :exc:`DeprecationWarning` to be emitted when it is used." +#~ msgstr "" +#~ ":mod:`typing`:自 Python 3.9 起已被棄用的 :class:`!typing.ByteString` 現在" +#~ "在使用時會發出 :exc:`DeprecationWarning`。" diff --git a/deprecations/pending-removal-in-3.15.po b/deprecations/pending-removal-in-3.15.po index 345db845e3c..0d86e896d68 100644 --- a/deprecations/pending-removal-in-3.15.po +++ b/deprecations/pending-removal-in-3.15.po @@ -1,11 +1,11 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"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: 2025-09-08 15:25+0800\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-" @@ -16,7 +16,7 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" #: ../../deprecations/pending-removal-in-3.15.rst:2 -msgid "Pending Removal in Python 3.15" +msgid "Pending removal in Python 3.15" msgstr "Python 3.15 中待移除的項目" #: ../../deprecations/pending-removal-in-3.15.rst:4 @@ -25,10 +25,10 @@ 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 :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 中," @@ -36,10 +36,11 @@ msgstr "" #: ../../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`)" +"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 中," @@ -93,15 +94,17 @@ msgstr ":class:`locale`:" #: ../../deprecations/pending-removal-in-3.15.rst:38 msgid "" "The :func:`~locale.getdefaultlocale` function has been deprecated since " -"Python 3.11. Its removal was originally planned for Python 3.13 (:gh:" -"`90817`), but has been postponed to Python 3.15. Use :func:`~locale." -"getlocale`, :func:`~locale.setlocale`, and :func:`~locale.getencoding` " -"instead. (Contributed by Hugo van Kemenade in :gh:`111187`.)" +"Python 3.11. Its removal was originally planned for Python 3.13 " +"(:gh:`90817`), but has been postponed to Python 3.15. " +"Use :func:`~locale.getlocale`, :func:`~locale.setlocale`, " +"and :func:`~locale.getencoding` instead. (Contributed by Hugo van Kemenade " +"in :gh:`111187`.)" msgstr "" ":func:`~locale.getdefaultlocale` 已在 Python 3.11 中被棄用,原本計劃在 " -"Python 3.13 中移除 (:gh:`90817`),但被延後至 Python 3.15。請改用 :func:" -"`~locale.getlocale`、:func:`~locale.setlocale` 和 :func:`~locale." -"getencoding`。 (由 Hugo van Kemenade 於 :gh:`111187` 貢獻。)" +"Python 3.13 中移除 (:gh:`90817`),但被延後至 Python 3.15。請改" +"用 :func:`~locale.getlocale`、:func:`~locale.setlocale` " +"和 :func:`~locale.getencoding`。 (由 Hugo van Kemenade 於 :gh:`111187` 貢" +"獻。)" #: ../../deprecations/pending-removal-in-3.15.rst:46 msgid ":mod:`pathlib`:" @@ -109,11 +112,11 @@ msgstr ":mod:`pathlib`:" #: ../../deprecations/pending-removal-in-3.15.rst:48 msgid "" -":meth:`.PurePath.is_reserved` has been deprecated since Python 3.13. Use :" -"func:`os.path.isreserved` to detect reserved paths on Windows." +":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:52 msgid ":mod:`platform`:" @@ -167,9 +170,9 @@ msgid "" "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` 貢獻。)" +"在 :pep:`626` 中被棄用,並計劃在 3.12 中移除,但只在 3.12 中於適當時發" +"出 :exc:`DeprecationWarning`。可能在 3.15 中移除。(由 Nikita Sobolev " +"於 :gh:`101866` 貢獻。)" #: ../../deprecations/pending-removal-in-3.15.rst:80 msgid ":mod:`typing`:" @@ -177,10 +180,10 @@ msgstr ":mod:`typing`:" #: ../../deprecations/pending-removal-in-3.15.rst:82 msgid "" -"The undocumented keyword argument syntax for creating :class:`~typing." -"NamedTuple` classes (e.g. ``Point = NamedTuple(\"Point\", x=int, y=int)``) " -"has been deprecated since Python 3.13. Use the class-based syntax or the " -"functional syntax instead." +"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 棄用。請改" @@ -194,11 +197,10 @@ msgid "" "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。" +"當使用 :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:95 msgid "" @@ -216,10 +218,25 @@ msgstr ":mod:`wave`:" #: ../../deprecations/pending-removal-in-3.15.rst:102 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 :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 被棄用。" +"已棄用 :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:107 +msgid ":mod:`zipimport`:" +msgstr ":mod:`zipimport`:" + +#: ../../deprecations/pending-removal-in-3.15.rst:109 +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` 貢獻。)" diff --git a/deprecations/pending-removal-in-3.16.po b/deprecations/pending-removal-in-3.16.po index 168f04617f5..f2590b23cd8 100644 --- a/deprecations/pending-removal-in-3.16.po +++ b/deprecations/pending-removal-in-3.16.po @@ -1,11 +1,11 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-11-10 17:21+0000\n" +"POT-Creation-Date: 2025-09-08 15:25+0800\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-" @@ -55,18 +55,82 @@ 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 " +"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:`!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 msgid ":mod:`builtins`:" msgstr ":mod:`builtins`:" -#: ../../deprecations/pending-removal-in-3.16.rst:28 +#: ../../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 " @@ -79,11 +143,52 @@ msgstr "" "邏輯否定。在極少數情況下,你需要對底層的整數進行位元反轉,請明確轉換為 " "``~int(x)`` (``~int(x)``)。" -#: ../../deprecations/pending-removal-in-3.16.rst:35 +#: ../../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:37 +#: ../../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 " @@ -92,11 +197,11 @@ msgstr "" "自 Python 3.14 起,:class:`!ExecError` 例外已被棄用。自 Python 3.4 以來,它尚" "未被 :mod:`!shutil` 中的任何函式使用,現在是 :exc:`RuntimeError` 的別名。" -#: ../../deprecations/pending-removal-in-3.16.rst:42 +#: ../../deprecations/pending-removal-in-3.16.rst:85 msgid ":mod:`symtable`:" msgstr ":mod:`symtable`:" -#: ../../deprecations/pending-removal-in-3.16.rst:44 +#: ../../deprecations/pending-removal-in-3.16.rst:87 msgid "" "The :meth:`Class.get_methods ` method has been " "deprecated since Python 3.14." @@ -104,11 +209,11 @@ msgstr "" "自 Python 3.14 起,:meth:`Class.get_methods ` 方" "法已被棄用。" -#: ../../deprecations/pending-removal-in-3.16.rst:47 +#: ../../deprecations/pending-removal-in-3.16.rst:90 msgid ":mod:`sys`:" msgstr ":mod:`sys`:" -#: ../../deprecations/pending-removal-in-3.16.rst:49 +#: ../../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` " @@ -117,11 +222,24 @@ msgstr "" "自 Python 3.13 起,:func:`~sys._enablelegacywindowsfsencoding` 函式已被棄用。" "請改用 :envvar:`PYTHONLEGACYWINDOWSFSENCODING` 環境變數。" -#: ../../deprecations/pending-removal-in-3.16.rst:53 +#: ../../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:55 +#: ../../deprecations/pending-removal-in-3.16.rst:104 msgid "" "The undocumented and unused :attr:`!TarFile.tarfile` attribute has been " "deprecated since Python 3.13." diff --git a/deprecations/pending-removal-in-3.17.po b/deprecations/pending-removal-in-3.17.po new file mode 100644 index 00000000000..3357e9e6ed7 --- /dev/null +++ b/deprecations/pending-removal-in-3.17.po @@ -0,0 +1,93 @@ +# 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.14\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-09-19 00:15+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.17.rst:2 +msgid "Pending removal in Python 3.17" +msgstr "Python 3.17 中待移除的項目" + +#: ../../deprecations/pending-removal-in-3.17.rst:4 +msgid ":mod:`collections.abc`:" +msgstr ":mod:`collections.abc`:" + +#: ../../deprecations/pending-removal-in-3.17.rst:6 +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 +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:14 +#: ../../deprecations/pending-removal-in-3.17.rst:42 +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:22 +#: ../../deprecations/pending-removal-in-3.17.rst:50 +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 +msgid ":mod:`typing`:" +msgstr ":mod:`typing`:" + +#: ../../deprecations/pending-removal-in-3.17.rst:28 +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 "" +"在 Python 3.14 之前,舊式聯集是使用私有類別 ``typing._UnionGenericAlias`` 實" +"作的。這個類別不再被需要,但為了向後相容性而保留,並計劃將在 Python 3.17 中移" +"除。使用者應該改用文件中記錄的內省輔助函式,例如 :func:`typing.get_origin` " +"和 :func:`typing.get_args`,或者依賴私有實作細節。" + +#: ../../deprecations/pending-removal-in-3.17.rst:33 +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 中移除。" diff --git a/deprecations/pending-removal-in-3.19.po b/deprecations/pending-removal-in-3.19.po new file mode 100644 index 00000000000..79fc1b949ed --- /dev/null +++ b/deprecations/pending-removal-in-3.19.po @@ -0,0 +1,34 @@ +# 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.14\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-09-08 15:25+0800\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.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 相容的結構佈局。" diff --git a/deprecations/pending-removal-in-future.po b/deprecations/pending-removal-in-future.po index 230bd84669c..6b666a7e95f 100644 --- a/deprecations/pending-removal-in-future.po +++ b/deprecations/pending-removal-in-future.po @@ -1,12 +1,12 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # FIRST AUTHOR , YEAR # msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-04-30 00:15+0000\n" +"POT-Creation-Date: 2025-10-06 00:15+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -17,7 +17,7 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" #: ../../deprecations/pending-removal-in-future.rst:2 -msgid "Pending Removal in Future Versions" +msgid "Pending removal in future versions" msgstr "未來版本中的待移除項目" #: ../../deprecations/pending-removal-in-future.rst:4 @@ -27,20 +27,31 @@ msgid "" 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 "" -":mod:`argparse`: Nesting argument groups and nesting mutually exclusive " -"groups are deprecated." -msgstr ":mod:`argparse`:已棄用巢狀引數群組和巢狀互斥群組。" +"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:10 +#: ../../deprecations/pending-removal-in-future.rst:16 msgid ":mod:`builtins`:" msgstr ":mod:`builtins`:" -#: ../../deprecations/pending-removal-in-future.rst:12 -msgid "``bool(NotImplemented)``." -msgstr "``bool(NotImplemented)``。" - -#: ../../deprecations/pending-removal-in-future.rst:13 +#: ../../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 " @@ -49,7 +60,7 @@ msgstr "" "產生器:``throw(type, exc, tb)`` 和 ``athrow(type, exc, tb)`` 簽名已被棄用:" "請改用 ``throw(exc)`` 和 ``athrow(exc)``,為單引數簽名。" -#: ../../deprecations/pending-removal-in-future.rst:16 +#: ../../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 " @@ -61,13 +72,13 @@ msgid "" "syntax error. (:gh:`87999`)" msgstr "" "目前 Python 接受數值字面值後面立即接關鍵字,例如 ``0in x``、``1or x``、``0if " -"1else 2``。它讓表達式模糊且容易混淆,如 ``[0x1for x in y]``\\ (可以解釋為 " +"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:24 +#: ../../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 " @@ -76,7 +87,7 @@ msgstr "" "``__index__()`` 和 ``__int__()`` 方法回傳非 int 型別的支援:這些方法將需要回" "傳 :class:`int` 的嚴格子類別實例。" -#: ../../deprecations/pending-removal-in-future.rst:27 +#: ../../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:" @@ -85,7 +96,7 @@ msgstr "" "回傳 :class:`float` 嚴格子類別 ``__float__()`` 方法的支援:這些方法將需要回" "傳 :class:`float` 的實例。" -#: ../../deprecations/pending-removal-in-future.rst:30 +#: ../../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:" @@ -94,11 +105,11 @@ msgstr "" "回傳 :class:`complex` 嚴格子類別 ``__complex__()`` 方法的支援:這些方法將需要" "回傳 :class:`complex` 的實例。" -#: ../../deprecations/pending-removal-in-future.rst:33 +#: ../../deprecations/pending-removal-in-future.rst:38 msgid "Delegation of ``int()`` to ``__trunc__()`` method." msgstr "將 ``int()`` 委派給 ``__trunc__()`` 方法。" -#: ../../deprecations/pending-removal-in-future.rst:34 +#: ../../deprecations/pending-removal-in-future.rst:39 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 " @@ -108,7 +119,7 @@ msgstr "" "在 :func:`complex` 建構子中將複數作為 *real* 或 *imag* 引數傳遞現在已被棄用;" "它應該只作為單個位置引數傳遞。 (由 Serhiy Storchaka 於 :gh:`109218` 貢獻。)" -#: ../../deprecations/pending-removal-in-future.rst:39 +#: ../../deprecations/pending-removal-in-future.rst:44 msgid "" ":mod:`calendar`: ``calendar.January`` and ``calendar.February`` constants " "are deprecated and replaced by :data:`calendar.JANUARY` and :data:`calendar." @@ -118,18 +129,25 @@ msgstr "" "被 :data:`calendar.JANUARY` 和 :data:`calendar.FEBRUARY` 取代。 (由 Prince " "Roshan 於 :gh:`103636` 貢獻。)" -#: ../../deprecations/pending-removal-in-future.rst:44 +#: ../../deprecations/pending-removal-in-future.rst:49 +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:51 msgid "" ":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:47 +#: ../../deprecations/pending-removal-in-future.rst:54 msgid ":mod:`datetime`:" msgstr ":mod:`datetime`:" -#: ../../deprecations/pending-removal-in-future.rst:49 +#: ../../deprecations/pending-removal-in-future.rst:56 msgid "" ":meth:`~datetime.datetime.utcnow`: use ``datetime.datetime.now(tz=datetime." "UTC)``." @@ -137,7 +155,7 @@ msgstr "" ":meth:`~datetime.datetime.utcnow`:請改用 ``datetime.datetime." "now(tz=datetime.UTC)``。" -#: ../../deprecations/pending-removal-in-future.rst:51 +#: ../../deprecations/pending-removal-in-future.rst:58 msgid "" ":meth:`~datetime.datetime.utcfromtimestamp`: use ``datetime.datetime." "fromtimestamp(timestamp, tz=datetime.UTC)``." @@ -145,15 +163,15 @@ msgstr "" ":meth:`~datetime.datetime.utcfromtimestamp`:請改用 ``datetime.datetime." "fromtimestamp(timestamp, tz=datetime.UTC)``。" -#: ../../deprecations/pending-removal-in-future.rst:54 +#: ../../deprecations/pending-removal-in-future.rst:61 msgid ":mod:`gettext`: Plural value must be an integer." msgstr ":mod:`gettext`:複數值必須是整數。" -#: ../../deprecations/pending-removal-in-future.rst:56 +#: ../../deprecations/pending-removal-in-future.rst:63 msgid ":mod:`importlib`:" msgstr ":mod:`importlib`:" -#: ../../deprecations/pending-removal-in-future.rst:58 +#: ../../deprecations/pending-removal-in-future.rst:65 msgid "" ":func:`~importlib.util.cache_from_source` *debug_override* parameter is " "deprecated: use the *optimization* parameter instead." @@ -161,19 +179,19 @@ msgstr "" ":func:`~importlib.util.cache_from_source` *debug_override* 參數已被棄用:請改" "用 *optimization* 參數。" -#: ../../deprecations/pending-removal-in-future.rst:61 +#: ../../deprecations/pending-removal-in-future.rst:68 msgid ":mod:`importlib.metadata`:" msgstr ":mod:`importlib.metadata`:" -#: ../../deprecations/pending-removal-in-future.rst:63 +#: ../../deprecations/pending-removal-in-future.rst:70 msgid "``EntryPoints`` tuple interface." msgstr "``EntryPoints`` 元組介面。" -#: ../../deprecations/pending-removal-in-future.rst:64 +#: ../../deprecations/pending-removal-in-future.rst:71 msgid "Implicit ``None`` on return values." msgstr "回傳值上的隱式 ``None``。" -#: ../../deprecations/pending-removal-in-future.rst:66 +#: ../../deprecations/pending-removal-in-future.rst:73 msgid "" ":mod:`logging`: the ``warn()`` method has been deprecated since Python 3.3, " "use :meth:`~logging.warning` instead." @@ -181,19 +199,19 @@ msgstr "" ":mod:`logging`:自 Python 3.3 起,``warn()`` 方法已被棄用,請改用 :meth:" "`~logging.warning`。" -#: ../../deprecations/pending-removal-in-future.rst:69 +#: ../../deprecations/pending-removal-in-future.rst:76 msgid "" ":mod:`mailbox`: Use of StringIO input and text mode is deprecated, use " "BytesIO and binary mode instead." msgstr "" ":mod:`mailbox`:已棄用 StringIO 輸入和文本模式,請改用 BytesIO 和二進位模式。" -#: ../../deprecations/pending-removal-in-future.rst:72 +#: ../../deprecations/pending-removal-in-future.rst:79 msgid "" ":mod:`os`: Calling :func:`os.register_at_fork` in multi-threaded process." msgstr ":mod:`os`:在多執行緒行程中呼叫 :func:`os.register_at_fork`。" -#: ../../deprecations/pending-removal-in-future.rst:74 +#: ../../deprecations/pending-removal-in-future.rst:81 msgid "" ":class:`!pydoc.ErrorDuringImport`: A tuple value for *exc_info* parameter is " "deprecated, use an exception instance." @@ -201,7 +219,7 @@ msgstr "" ":class:`!pydoc.ErrorDuringImport`:*exc_info* 參數的元組值已被棄用,請用例外" "實例。" -#: ../../deprecations/pending-removal-in-future.rst:77 +#: ../../deprecations/pending-removal-in-future.rst:84 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 " @@ -213,12 +231,12 @@ msgstr "" "有 ASCII 數碼序列被接受作為數值參照。位元組模式和替換字串中的群組名稱現在只能" "包含 ASCII 字母、數碼和底線。(由 Serhiy Storchaka 於 :gh:`91760` 貢獻。)" -#: ../../deprecations/pending-removal-in-future.rst:84 +#: ../../deprecations/pending-removal-in-future.rst:91 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:86 +#: ../../deprecations/pending-removal-in-future.rst:93 msgid "" ":mod:`shutil`: :func:`~shutil.rmtree`'s *onerror* parameter is deprecated in " "Python 3.12; use the *onexc* parameter instead." @@ -226,15 +244,15 @@ msgstr "" ":mod:`shutil`::func:`~shutil.rmtree` 的 *onerror* 參數在 Python 3.12 中已被" "棄用;請改用 *onexc* 參數。" -#: ../../deprecations/pending-removal-in-future.rst:89 +#: ../../deprecations/pending-removal-in-future.rst:96 msgid ":mod:`ssl` options and protocols:" msgstr ":mod:`ssl` 選項和協定:" -#: ../../deprecations/pending-removal-in-future.rst:91 +#: ../../deprecations/pending-removal-in-future.rst:98 msgid ":class:`ssl.SSLContext` without protocol argument is deprecated." msgstr "不帶協定引數的 :class:`ssl.SSLContext` 已被棄用。" -#: ../../deprecations/pending-removal-in-future.rst:92 +#: ../../deprecations/pending-removal-in-future.rst:99 msgid "" ":class:`ssl.SSLContext`: :meth:`~ssl.SSLContext.set_npn_protocols` and :meth:" "`!selected_npn_protocol` are deprecated: use ALPN instead." @@ -242,51 +260,51 @@ msgstr "" ":class:`ssl.SSLContext`::meth:`~ssl.SSLContext.set_npn_protocols` 和 :meth:" "`!selected_npn_protocol` 已被棄用:請改用 ALPN。" -#: ../../deprecations/pending-removal-in-future.rst:95 +#: ../../deprecations/pending-removal-in-future.rst:102 msgid "``ssl.OP_NO_SSL*`` options" msgstr "``ssl.OP_NO_SSL*`` 選項" -#: ../../deprecations/pending-removal-in-future.rst:96 +#: ../../deprecations/pending-removal-in-future.rst:103 msgid "``ssl.OP_NO_TLS*`` options" msgstr "``ssl.OP_NO_TLS*`` 選項" -#: ../../deprecations/pending-removal-in-future.rst:97 +#: ../../deprecations/pending-removal-in-future.rst:104 msgid "``ssl.PROTOCOL_SSLv3``" msgstr "``ssl.PROTOCOL_SSLv3``" -#: ../../deprecations/pending-removal-in-future.rst:98 +#: ../../deprecations/pending-removal-in-future.rst:105 msgid "``ssl.PROTOCOL_TLS``" msgstr "``ssl.PROTOCOL_TLS``" -#: ../../deprecations/pending-removal-in-future.rst:99 +#: ../../deprecations/pending-removal-in-future.rst:106 msgid "``ssl.PROTOCOL_TLSv1``" msgstr "``ssl.PROTOCOL_TLSv1``" -#: ../../deprecations/pending-removal-in-future.rst:100 +#: ../../deprecations/pending-removal-in-future.rst:107 msgid "``ssl.PROTOCOL_TLSv1_1``" msgstr "``ssl.PROTOCOL_TLSv1_1``" -#: ../../deprecations/pending-removal-in-future.rst:101 +#: ../../deprecations/pending-removal-in-future.rst:108 msgid "``ssl.PROTOCOL_TLSv1_2``" msgstr "``ssl.PROTOCOL_TLSv1_2``" -#: ../../deprecations/pending-removal-in-future.rst:102 +#: ../../deprecations/pending-removal-in-future.rst:109 msgid "``ssl.TLSVersion.SSLv3``" msgstr "``ssl.TLSVersion.SSLv3``" -#: ../../deprecations/pending-removal-in-future.rst:103 +#: ../../deprecations/pending-removal-in-future.rst:110 msgid "``ssl.TLSVersion.TLSv1``" msgstr "``ssl.TLSVersion.TLSv1``" -#: ../../deprecations/pending-removal-in-future.rst:104 +#: ../../deprecations/pending-removal-in-future.rst:111 msgid "``ssl.TLSVersion.TLSv1_1``" msgstr "``ssl.TLSVersion.TLSv1_1``" -#: ../../deprecations/pending-removal-in-future.rst:106 +#: ../../deprecations/pending-removal-in-future.rst:113 msgid ":mod:`threading` methods:" msgstr ":mod:`threading` 方法:" -#: ../../deprecations/pending-removal-in-future.rst:108 +#: ../../deprecations/pending-removal-in-future.rst:115 msgid "" ":meth:`!threading.Condition.notifyAll`: use :meth:`~threading.Condition." "notify_all`." @@ -294,11 +312,11 @@ msgstr "" ":meth:`!threading.Condition.notifyAll`:請用 :meth:`~threading.Condition." "notify_all`。" -#: ../../deprecations/pending-removal-in-future.rst:109 +#: ../../deprecations/pending-removal-in-future.rst:116 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:110 +#: ../../deprecations/pending-removal-in-future.rst:117 msgid "" ":meth:`!threading.Thread.isDaemon`, :meth:`threading.Thread.setDaemon`: use :" "attr:`threading.Thread.daemon` attribute." @@ -306,7 +324,7 @@ msgstr "" ":meth:`!threading.Thread.isDaemon`、:meth:`threading.Thread.setDaemon`:請" "用 :attr:`threading.Thread.daemon` 屬性。" -#: ../../deprecations/pending-removal-in-future.rst:112 +#: ../../deprecations/pending-removal-in-future.rst:119 msgid "" ":meth:`!threading.Thread.getName`, :meth:`threading.Thread.setName`: use :" "attr:`threading.Thread.name` attribute." @@ -314,20 +332,31 @@ msgstr "" ":meth:`!threading.Thread.getName`、:meth:`threading.Thread.setName`:請用 :" "attr:`threading.Thread.name` 屬性。" -#: ../../deprecations/pending-removal-in-future.rst:114 +#: ../../deprecations/pending-removal-in-future.rst:121 msgid ":meth:`!threading.currentThread`: use :meth:`threading.current_thread`." msgstr "" ":meth:`!threading.currentThread`:請用 :meth:`threading.current_thread`。" -#: ../../deprecations/pending-removal-in-future.rst:115 +#: ../../deprecations/pending-removal-in-future.rst:122 msgid ":meth:`!threading.activeCount`: use :meth:`threading.active_count`." msgstr ":meth:`!threading.activeCount`:請用 :meth:`threading.active_count`。" -#: ../../deprecations/pending-removal-in-future.rst:117 +#: ../../deprecations/pending-removal-in-future.rst:124 msgid ":class:`typing.Text` (:gh:`92332`)." msgstr ":class:`typing.Text` (:gh:`92332`)。" -#: ../../deprecations/pending-removal-in-future.rst:119 +#: ../../deprecations/pending-removal-in-future.rst:126 +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:131 msgid "" ":class:`unittest.IsolatedAsyncioTestCase`: it is deprecated to return a " "value that is not ``None`` from a test case." @@ -335,74 +364,64 @@ msgstr "" ":class:`unittest.IsolatedAsyncioTestCase`:從測試案例中回傳非 ``None`` 的值已" "被棄用。" -#: ../../deprecations/pending-removal-in-future.rst:122 +#: ../../deprecations/pending-removal-in-future.rst:134 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:124 +#: ../../deprecations/pending-removal-in-future.rst:136 msgid "``splitattr()``" msgstr "``splitattr()``" -#: ../../deprecations/pending-removal-in-future.rst:125 +#: ../../deprecations/pending-removal-in-future.rst:137 msgid "``splithost()``" msgstr "``splithost()``" -#: ../../deprecations/pending-removal-in-future.rst:126 +#: ../../deprecations/pending-removal-in-future.rst:138 msgid "``splitnport()``" msgstr "``splitnport()``" -#: ../../deprecations/pending-removal-in-future.rst:127 +#: ../../deprecations/pending-removal-in-future.rst:139 msgid "``splitpasswd()``" msgstr "``splitpasswd()``" -#: ../../deprecations/pending-removal-in-future.rst:128 +#: ../../deprecations/pending-removal-in-future.rst:140 msgid "``splitport()``" msgstr "``splitport()``" -#: ../../deprecations/pending-removal-in-future.rst:129 +#: ../../deprecations/pending-removal-in-future.rst:141 msgid "``splitquery()``" msgstr "``splitquery()``" -#: ../../deprecations/pending-removal-in-future.rst:130 +#: ../../deprecations/pending-removal-in-future.rst:142 msgid "``splittag()``" msgstr "``splittag()``" -#: ../../deprecations/pending-removal-in-future.rst:131 +#: ../../deprecations/pending-removal-in-future.rst:143 msgid "``splittype()``" msgstr "``splittype()``" -#: ../../deprecations/pending-removal-in-future.rst:132 +#: ../../deprecations/pending-removal-in-future.rst:144 msgid "``splituser()``" msgstr "``splituser()``" -#: ../../deprecations/pending-removal-in-future.rst:133 +#: ../../deprecations/pending-removal-in-future.rst:145 msgid "``splitvalue()``" msgstr "``splitvalue()``" -#: ../../deprecations/pending-removal-in-future.rst:134 +#: ../../deprecations/pending-removal-in-future.rst:146 msgid "``to_bytes()``" msgstr "``to_bytes()``" -#: ../../deprecations/pending-removal-in-future.rst:136 -msgid "" -":mod:`urllib.request`: :class:`~urllib.request.URLopener` and :class:" -"`~urllib.request.FancyURLopener` style of invoking requests is deprecated. " -"Use newer :func:`~urllib.request.urlopen` functions and methods." -msgstr "" -":mod:`urllib.request`:呼叫請求的 :class:`~urllib.request.URLopener` 和 :" -"class:`~urllib.request.FancyURLopener` 風格已被棄用。請改用更新的 :func:" -"`~urllib.request.urlopen` 函式和方法。" - -#: ../../deprecations/pending-removal-in-future.rst:140 +#: ../../deprecations/pending-removal-in-future.rst:148 msgid "" ":mod:`wsgiref`: ``SimpleHandler.stdout.write()`` should not do partial " "writes." msgstr ":mod:`wsgiref`:``SimpleHandler.stdout.write()`` 不應該進行部分寫入。" -#: ../../deprecations/pending-removal-in-future.rst:143 +#: ../../deprecations/pending-removal-in-future.rst:151 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 " @@ -413,13 +432,10 @@ msgstr "" "Element` 的真值測試。在未來版本中,它將始終回傳 ``True``。請改用明確的 " "``len(elem)`` 或 ``elem is not None`` 測試。" -#: ../../deprecations/pending-removal-in-future.rst:148 +#: ../../deprecations/pending-removal-in-future.rst:156 msgid "" -":meth:`zipimport.zipimporter.load_module` is deprecated: use :meth:" -"`~zipimport.zipimporter.exec_module` instead." +":func:`sys._clear_type_cache` is deprecated: use :func:`sys." +"_clear_internal_caches` instead." msgstr "" -":meth:`zipimport.zipimporter.load_module` 已被棄用:請改用 :meth:`~zipimport." -"zipimporter.exec_module`。" - -#~ msgid ":mod:`array`'s ``'u'`` format code (:gh:`57281`)" -#~ msgstr ":mod:`array` 的 ``'u'`` 格式碼 (:gh:`57281`)" +":func:`sys._clear_type_cache` 已被棄用:請改用 :func:`sys." +"_clear_internal_caches`。" diff --git a/distributing/index.po b/distributing/index.po index 6ef90c29d0b..6b969cb0e49 100644 --- a/distributing/index.po +++ b/distributing/index.po @@ -1,5 +1,4 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -7,7 +6,7 @@ # Steven Hsu , 2021 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2023-08-18 00:03+0000\n" "PO-Revision-Date: 2021-07-04 18:06+0800\n" diff --git a/extending/building.po b/extending/building.po index 9285c3baeaf..42cf78789f0 100644 --- a/extending/building.po +++ b/extending/building.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -6,9 +6,9 @@ # Matt Wang , 2025 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"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: 2025-09-08 15:25+0800\n" "PO-Revision-Date: 2025-02-07 14:09+0000\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -25,88 +25,32 @@ msgstr "建立 C 與 C++ 擴充套件" #: ../../extending/building.rst:9 msgid "" -"A C extension for CPython is a shared library (e.g. a ``.so`` file on Linux, " -"``.pyd`` on Windows), which exports an *initialization function*." +"A C extension for CPython is a shared library (for example, a ``.so`` file " +"on Linux, ``.pyd`` on Windows), which exports an *initialization function*." msgstr "" "一個 CPython 的 C 擴充套件是一個共用函式庫(例如在 Linux 上的 ``.so`` 檔案," "在 Windows 上的 ``.pyd``),會匯出一個\\ *初始化函式*。" #: ../../extending/building.rst:12 -msgid "" -"To be importable, the shared library must be available on :envvar:" -"`PYTHONPATH`, and must be named after the module name, with an appropriate " -"extension. When using setuptools, the correct filename is generated " -"automatically." -msgstr "" -"要能夠被引入,共用函式庫必須在 :envvar:`PYTHONPATH` 上可用,並且必須以模組名" -"稱命名,並且必須有適當的副檔名。使用 setuptools 時,正確的檔名會自動產生。" - -#: ../../extending/building.rst:16 -msgid "The initialization function has the signature:" -msgstr "初始化函式具有簽名:" - -#: ../../extending/building.rst:20 -msgid "" -"It returns either a fully initialized module, or a :c:type:`PyModuleDef` " -"instance. See :ref:`initializing-modules` for details." -msgstr "" -"它回傳一個完全初始化的模組,或一個 :c:type:`PyModuleDef` 實例。詳細資訊請參" -"見 :ref:`initializing-modules`。" - -#: ../../extending/building.rst:25 -msgid "" -"For modules with ASCII-only names, the function must 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::" -msgstr "" -"對於僅包含 ASCII 名稱的模組,函式必須以 :samp:`PyInit_{}` 命名,其中 " -"```` 要替換為模組的名稱。當使用 :ref:`multi-phase-" -"initialization` 時,允許非 ASCII 模組名稱。在這種情況下,初始化函式名稱是 " -":samp:`PyInitU_{}`,其中 ```` 使用 Python 的 *punycode* 編" -"碼,並將連字符號替換為底線。在 Python 中: ::" +msgid "See :ref:`extension-modules` for details." +msgstr "詳見 :ref:`extension-modules`。" -#: ../../extending/building.rst:32 -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" -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" +#: ../../extending/building.rst:21 +msgid "Building C and C++ Extensions with setuptools" +msgstr "用 setuptools 建置 C 與 C++ 擴充套件" -#: ../../extending/building.rst:39 +#: ../../extending/building.rst:24 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." +"Building, packaging and distributing extension modules is best done with " +"third-party tools, and is out of scope of this document. One suitable tool " +"is Setuptools, whose documentation can be found at https://" +"setuptools.pypa.io/en/latest/setuptools.html." msgstr "" -"可以透過定義多個初始化函式,來從單一共用函式庫中匯出多個模組。然而要引入它們" -"需要使用符號連結或自訂引入器,因為預設只會找到對應於檔名的函式。詳細資訊請參" -"見 :pep:`489` 中的 *\"Multiple modules in one library\"* 部分。" - -#: ../../extending/building.rst:52 -msgid "Building C and C++ Extensions with setuptools" -msgstr "用 setuptools 建置 C 與 C++ 擴充套件" -#: ../../extending/building.rst:54 +#: ../../extending/building.rst:29 msgid "" -"Python 3.12 and newer no longer come with distutils. Please refer to the " -"``setuptools`` documentation at https://setuptools.readthedocs.io/en/latest/" -"setuptools.html to learn more about how build and distribute C/C++ " -"extensions with setuptools." +"The :mod:`distutils` module, which was included in the standard library " +"until Python 3.12, is now maintained as part of Setuptools." msgstr "" -"Python 3.12 與之後的版本不再帶有 distutils。請在 https://setuptools." -"readthedocs.io/en/latest/setuptools.html 上參閱 ``setuptools`` 文件,以了解如" -"何使用 setuptools 建置和發佈 C/C++ 擴充套件。" +"直到 Python 3.12 版本前,:mod:`distutils` 模組都被包含在標準函式庫中," +"現在是作為 Setuptools 的一部分來維護。" \ No newline at end of file diff --git a/extending/embedding.po b/extending/embedding.po index f08b001e48a..c796af330dc 100644 --- a/extending/embedding.po +++ b/extending/embedding.po @@ -1,12 +1,11 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Leon H., 2017 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2018-05-23 14:09+0000\n" @@ -35,6 +34,12 @@ msgid "" "writing some scripts in Python. You can also use it yourself if some of the " "functionality can be written in Python more easily." msgstr "" +"前面的章節討論了如何擴充 Python,也就是如何透過附加一個 C 函式庫來擴充 " +"Python 的功能。但也可以反過來做:將 Python 嵌入你的 C/C++ 應用程式中" +"。嵌入讓你的應用程式能夠以 Python 而非 C 或 C++ 來實作應用程式的某些功能。" +"這可以用於許多目的;其中一個例子是允許使用者透過撰寫一些 Python 腳本來根據他們" +"的需求客製化應用程式。如果某些功能用 Python 寫起來比較容易,你也可以自己使用" +"這種方法。" #: ../../extending/embedding.rst:20 msgid "" @@ -44,6 +49,10 @@ msgid "" "nothing to do with Python --- instead, some parts of the application " "occasionally call the Python interpreter to run some Python code." msgstr "" +"嵌入 Python 與擴充 Python 類似,但不完全相同。差別在於當你擴充 Python 時,應用程式" +"的主程式仍然是 Python 直譯器,而當你嵌入 Python,主程式可能與 Python " +"無關 — 相反地,應用程式的某些部分偶爾會呼叫 Python 直譯器來執行一些 Python " +"程式碼。" #: ../../extending/embedding.rst:26 msgid "" @@ -54,6 +63,10 @@ msgid "" "Python. Then later you can call the interpreter from any part of the " "application." msgstr "" +"所以如果你要嵌入 Python,你要提供自己的主程式。這個主程式必須做的事情之一是" +"初始化 Python 直譯器,或至少必須要呼叫函式 :c:func:`Py_Initialize`。還有一些" +"可選的呼叫來傳遞命令列引數給 Python。然後你就可以在應用程式的任何部分呼叫直譯" +"器。" #: ../../extending/embedding.rst:32 msgid "" @@ -64,6 +77,10 @@ msgid "" "level operations described in the previous chapters to construct and use " "Python objects." msgstr "" +"有幾種不同的方式來呼叫直譯器:你可以傳遞一個包含 Python 陳述式的字串給 :c:func:" +"`PyRun_SimpleString`,或者你可以傳遞一個 stdio 檔案指標和檔案名稱(僅用於錯誤" +"訊息中的識別)給 :c:func:`PyRun_SimpleFile`。你也可以呼叫前面章節中描述的較低" +"層級操作來建構和使用 Python 物件。" #: ../../extending/embedding.rst:41 msgid ":ref:`c-api-index`" @@ -74,10 +91,11 @@ msgid "" "The details of Python's C interface are given in this manual. A great deal " "of necessary information can be found here." msgstr "" +"Python 的 C 介面詳細資訊在此手冊中提供。大量必要的資訊可以在這裡找到。" #: ../../extending/embedding.rst:49 msgid "Very High Level Embedding" -msgstr "" +msgstr "非常高階的嵌入" #: ../../extending/embedding.rst:51 msgid "" @@ -86,6 +104,8 @@ msgid "" "needing to interact with the application directly. This can for example be " "used to perform some operation on a file. ::" msgstr "" +"嵌入 Python 最簡單的形式是使用非常高階的介面。此介面用於執行 Python 腳本而" +"無需直接與應用程式互動。例如這可以用來對檔案執行一些操作。 ::" #: ../../extending/embedding.rst:56 msgid "" @@ -166,6 +186,9 @@ msgid "" "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/embedding.rst:97 msgid "" @@ -181,10 +204,17 @@ msgid "" "`PyRun_SimpleFile` function, which saves you the trouble of allocating " "memory space and loading the file contents." msgstr "" +":c:member:`PyConfig.program_name` 的設定應該在 :c:func:`Py_InitializeFromConfig` " +"前呼叫,以告知直譯器 Python run-time 函式庫的路徑。接下來,Python 直譯器會用 :c:" +"func:`Py_Initialize` 初始化,然後執行一個硬編碼的 Python 腳本來印出日期和時間。" +"之後,:c:func:`Py_FinalizeEx` 呼叫會關閉直譯器,接著程式結束。在真實的程式中," +"你可能想要從另一個來源取得 Python 腳本,或許是文字編輯器例程、檔案或資料庫。" +"從檔案取得 Python 程式碼可以更好地使用 :c:func:`PyRun_SimpleFile` 函式來完成," +"這樣可以省去分配記憶體空間和載入檔案內容的麻煩。" #: ../../extending/embedding.rst:112 msgid "Beyond Very High Level Embedding: An overview" -msgstr "" +msgstr "超越非常高階嵌入:概觀" #: ../../extending/embedding.rst:114 msgid "" @@ -194,6 +224,9 @@ msgid "" "calls. At the cost of having to write more C code, you can achieve almost " "anything." msgstr "" +"高階介面讓你能夠從應用程式中執行任意的 Python 程式碼片段,但交換資料" +"值的過程可以說相當繁瑣。如果你想進行這類操作,應該使用較低階的呼叫。" +"雖然需要撰寫更多的 C 程式碼,但幾乎可以實現任何功能。" #: ../../extending/embedding.rst:119 msgid "" @@ -202,36 +235,39 @@ msgid "" "previous chapters are still valid. To show this, consider what the extension " "code from Python to C really does:" msgstr "" +"需要注意的是,雖然目的不同,但擴充 Python 與嵌入 Python 其實是非常相似的操作," +"前面章節討論的大多數主題在這裡同樣適用。為了說明這一點,請思考從 Python 到 C " +"的擴充程式碼實際上做了什麼:" #: ../../extending/embedding.rst:124 msgid "Convert data values from Python to C," -msgstr "" +msgstr "將資料值從 Python 轉換為 C," #: ../../extending/embedding.rst:126 msgid "Perform a function call to a C routine using the converted values, and" -msgstr "" +msgstr "使用轉換後的值呼叫 C 例程,並" #: ../../extending/embedding.rst:128 msgid "Convert the data values from the call from C to Python." -msgstr "" +msgstr "將呼叫中的資料值從 C 轉換為 Python。" #: ../../extending/embedding.rst:130 msgid "When embedding Python, the interface code does:" -msgstr "" +msgstr "當嵌入 Python 時,介面程式碼會:" #: ../../extending/embedding.rst:132 msgid "Convert data values from C to Python," -msgstr "" +msgstr "將資料值從 C 轉換為 Python," #: ../../extending/embedding.rst:134 msgid "" "Perform a function call to a Python interface routine using the converted " "values, and" -msgstr "" +msgstr "使用轉換後的值呼叫 Python 介面例程,並" #: ../../extending/embedding.rst:137 msgid "Convert the data values from the call from Python to C." -msgstr "" +msgstr "將呼叫中的資料值從 Python 轉換為 C。" #: ../../extending/embedding.rst:139 msgid "" @@ -240,6 +276,9 @@ msgid "" "is the routine that you call between both data conversions. When extending, " "you call a C routine, when embedding, you call a Python routine." msgstr "" +"如你所見,資料轉換的步驟只是互換了順序,以配合跨語言傳遞方向的不同。唯一的差別在於" +"兩個資料轉換之間所呼叫的例程:在擴充時你呼叫的是 C 例程;在嵌入時則呼叫 Python " +"例程。" #: ../../extending/embedding.rst:144 msgid "" @@ -248,10 +287,13 @@ msgid "" "be understood. Since these aspects do not differ from extending the " "interpreter, you can refer to earlier chapters for the required information." msgstr "" +"本章不會討論如何將資料從 Python 轉換為 C 或從 C 轉換回 Python,且假設讀者已經知道參照的" +"正確使用方式與錯誤處理。由於這些部分與擴充直譯器時相同," +"相關資訊可參考前面的章節。" #: ../../extending/embedding.rst:153 msgid "Pure Embedding" -msgstr "" +msgstr "純嵌入" #: ../../extending/embedding.rst:155 msgid "" @@ -260,10 +302,12 @@ msgid "" "directly interact with the application (but that will change in the next " "section)." msgstr "" +"第一個程式的目標是執行 Python 腳本中的函式。就像在非常高階介面的章節中一樣," +"Python 直譯器不會直接與應用程式互動(但這在下一節會改變)。" #: ../../extending/embedding.rst:160 msgid "The code to run a function defined in a Python script is:" -msgstr "" +msgstr "執行 Python 腳本中定義函式的程式碼是:" #: ../../extending/embedding.rst:162 msgid "" @@ -349,6 +393,10 @@ msgid "" "(let's call the finished executable :program:`call`), and use it to execute " "a Python script, such as:" msgstr "" +"此程式碼使用 ``argv[1]`` 載入 Python 腳本,並呼叫 ``argv[2]`` 中所指定的函式。" +"其整數引數則來自 ``argv`` 陣列中的其他值。如果你\\ :ref:`編譯並連結 `\\ 此" +"程式(我們稱完成的可執行檔為 :program:`call`),並用它來執行 Python 腳本," +"例如:" #: ../../extending/embedding.rst:171 msgid "" @@ -359,10 +407,16 @@ msgid "" " c = c + b\n" " return c" msgstr "" +"def multiply(a,b):\n" +" print(\"Will compute\", a, \"times\", b)\n" +" c = 0\n" +" for i in range(0, a):\n" +" c = c + b\n" +" return c" #: ../../extending/embedding.rst:180 msgid "then the result should be:" -msgstr "" +msgstr "那麼結果應該是:" #: ../../extending/embedding.rst:182 msgid "" @@ -370,6 +424,9 @@ msgid "" "Will compute 3 times 2\n" "Result of call: 6" msgstr "" +"$ call multiply multiply 3 2\n" +"Will compute 3 times 2\n" +"Result of call: 6" #: ../../extending/embedding.rst:188 msgid "" @@ -377,6 +434,8 @@ msgid "" "is for data conversion between Python and C, and for error reporting. The " "interesting part with respect to embedding Python starts with ::" msgstr "" +"雖然以其功能而言這個程式相當龐大,但大部分的程式碼是用於 Python 與 C 之間的資料" +"轉換以及錯誤回報。至於與嵌入 Python 有關的重點部分,則從以下開始: ::" #: ../../extending/embedding.rst:192 msgid "" @@ -385,6 +444,10 @@ msgid "" "/* Error checking of pName left out */\n" "pModule = PyImport_Import(pName);" msgstr "" +"Py_Initialize();\n" +"pName = PyUnicode_DecodeFSDefault(argv[1]);\n" +"/* Error checking of pName left out */\n" +"pModule = PyImport_Import(pName);" #: ../../extending/embedding.rst:197 msgid "" @@ -393,6 +456,9 @@ msgid "" "which is constructed using the :c:func:`PyUnicode_DecodeFSDefault` data " "conversion routine. ::" msgstr "" +"在初始化直譯器後,腳本使用 :c:func:`PyImport_Import` 載入。此例程需要一個 " +"Python 字串作為其引數,該字串使用 :c:func:`PyUnicode_DecodeFSDefault` 資料" +"轉換例程建構。 ::" #: ../../extending/embedding.rst:202 msgid "" @@ -404,6 +470,13 @@ msgid "" "}\n" "Py_XDECREF(pFunc);" msgstr "" +"pFunc = PyObject_GetAttrString(pModule, argv[2]);\n" +"/* pFunc is a new reference */\n" +"\n" +"if (pFunc && PyCallable_Check(pFunc)) {\n" +" ...\n" +"}\n" +"Py_XDECREF(pFunc);" #: ../../extending/embedding.rst:210 msgid "" @@ -413,6 +486,9 @@ msgid "" "proceeds by constructing a tuple of arguments as normal. The call to the " "Python function is then made with::" msgstr "" +"腳本載入後,會使用 :c:func:`PyObject_GetAttrString` 來取得所需的名稱。如果" +"該名稱存在,且回傳的物件是可呼叫的,便可安全地假設它是一個函式。接著,程式會以" +"一般方式建立引數的元組。之後便以下列方式呼叫該 Python 函式: ::" #: ../../extending/embedding.rst:216 msgid "pValue = PyObject_CallObject(pFunc, pArgs);" @@ -424,10 +500,12 @@ msgid "" "reference to the return value of the function. Be sure to release the " "reference after examining the value." msgstr "" +"函式回傳時,``pValue`` 要不是 ``NULL`` 就是包含函式回傳值的參照。請務必在檢查" +"值之後釋放參照。" #: ../../extending/embedding.rst:226 msgid "Extending Embedded Python" -msgstr "" +msgstr "擴充嵌入式 Python" #: ../../extending/embedding.rst:228 msgid "" @@ -440,6 +518,11 @@ msgid "" "and write some glue code that gives Python access to those routines, just " "like you would write a normal Python extension. For example::" msgstr "" +"到目前為止,嵌入式 Python 直譯器尚無法存取應用程式本身的功能。Python API 允許透過" +"擴充嵌入式直譯器來達成這點。也就是說,嵌入式直譯器可以由應用程式所提供的例程加以" +"擴充。雖然聽起來複雜但其實並不難。只要暫時忘記是應用程式啟動了 Python 直譯器," +"改以將應用程式視為一組子程序,並撰寫一些膠合程式碼讓 Python 能夠存取" +"這些例程,就像你撰寫一般 Python 擴充一樣。例如: ::" #: ../../extending/embedding.rst:237 msgid "" @@ -479,6 +562,8 @@ msgid "" "Insert the above code just above the :c:func:`main` function. Also, insert " "the following two statements before the call to :c:func:`Py_Initialize`::" msgstr "" +"在 :c:func:`main` 函式的正上方插入上述程式碼。同時,在呼叫 :c:func:" +"`Py_Initialize` 之前插入以下兩個陳述式: ::" #: ../../extending/embedding.rst:270 msgid "" @@ -494,22 +579,26 @@ msgid "" "emb.numargs` function accessible to the embedded Python interpreter. With " "these extensions, the Python script can do things like" msgstr "" +"這兩行初始化 ``numargs`` 變數,並讓 :func:`!emb.numargs` 函式可供嵌入式 Python " +"直譯器使用。有了這些擴充後,Python 腳本便可以執行像是以下的操作" #: ../../extending/embedding.rst:277 msgid "" "import emb\n" "print(\"Number of arguments\", emb.numargs())" msgstr "" +"import emb\n" +"print(\"Number of arguments\", emb.numargs())" #: ../../extending/embedding.rst:282 msgid "" "In a real application, the methods will expose an API of the application to " "Python." -msgstr "" +msgstr "在真實的應用程式中,這些方法會向 Python 公開應用程式的 API。" #: ../../extending/embedding.rst:292 msgid "Embedding Python in C++" -msgstr "" +msgstr "在 C++ 中嵌入 Python" #: ../../extending/embedding.rst:294 msgid "" @@ -519,10 +608,13 @@ msgid "" "and link your program. There is no need to recompile Python itself using C+" "+." msgstr "" +"也可以將 Python 嵌入 C++ 程式中;具體如何做取決於所使用的 C++ 系統的細節;" +"一般來說,你需要用 C++ 撰寫主程式,並使用 C++ 編譯器來編譯和連結你的程式。" +"不需要使用 C++ 重新編譯 Python 本身。" #: ../../extending/embedding.rst:303 msgid "Compiling and Linking under Unix-like systems" -msgstr "" +msgstr "在類 Unix 系統下編譯和連結" #: ../../extending/embedding.rst:305 msgid "" @@ -531,6 +623,9 @@ msgid "" "application, particularly because Python needs to load library modules " "implemented as C dynamic extensions (:file:`.so` files) linked against it." msgstr "" +"要找到傳遞給編譯器(和連結器)的正確旗標以便將 Python 直譯器嵌入你的應用程式" +"中,並不一定是簡單的事,特別是因為 Python 需要載入作為 C 動態擴充(:file:`.so` 檔案)實作的函式庫" +"模組,而這些模組又必須與 Python 進行連結。" #: ../../extending/embedding.rst:311 msgid "" @@ -540,12 +635,15 @@ msgid "" "available). This script has several options, of which the following will be " "directly useful to you:" msgstr "" +"要找出所需的編譯器和連結器旗標,你可以執行作為安裝過程的一部分產生的 :file:" +"`python{X.Y}-config` 腳本(也可能有 :file:`python3-config` 腳本可用)。此腳本" +"提供多種選項,其中以下幾個最為實用:" #: ../../extending/embedding.rst:317 msgid "" "``pythonX.Y-config --cflags`` will give you the recommended flags when " "compiling:" -msgstr "" +msgstr "``pythonX.Y-config --cflags`` 會給你編譯時建議的旗標:" #: ../../extending/embedding.rst:320 msgid "" @@ -561,7 +659,7 @@ msgstr "" msgid "" "``pythonX.Y-config --ldflags --embed`` will give you the recommended flags " "when linking:" -msgstr "" +msgstr "``pythonX.Y-config --ldflags --embed`` 會給你連結時建議的旗標:" #: ../../extending/embedding.rst:328 msgid "" @@ -580,6 +678,8 @@ msgid "" "that you use the absolute path to :file:`python{X.Y}-config`, as in the " "above example." msgstr "" +"為了避免多個 Python 安裝之間產生混淆(特別是系統自帶的 Python 與自行編譯的 Python " +"之間),建議使用 :file:`python{X.Y}-config` 的絕對路徑,如上面的例子所示。" #: ../../extending/embedding.rst:339 msgid "" @@ -592,6 +692,11 @@ msgid "" "extract the configuration values that you will want to combine together. " "For example:" msgstr "" +"如果此程序對你不起作用(並不保證在所有類 Unix 平台上都能運作;不過我們歡迎\\ :ref:" +"`錯誤回報 `),你將需要參閱系統的動態連結相關文件,並/或檢查 " +"Python 的 :file:`Makefile`\\ (可使用 :func:`sysconfig.get_makefile_filename` 來" +"找到其位置)和編譯選項。在這種情況下,:mod:`sysconfig` 模組是一個實用的工具," +"可用於以程式化方式擷取並組合所需的組態值。例如:" #: ../../extending/embedding.rst:348 msgid "" diff --git a/extending/extending.po b/extending/extending.po index 8fed1eb0757..f23b5784bfb 100644 --- a/extending/extending.po +++ b/extending/extending.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -7,9 +7,9 @@ # Matt Wang , 2025 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"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: 2025-11-25 00:13+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-" @@ -859,11 +859,11 @@ msgstr "" #: ../../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` " +"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` 表中有相關條目,否則不會自" +"嵌入 Python 時,除非在 :c:data:`PyImport_Inittab` 表中有相關條目,否則不會自" "動呼叫 :c:func:`!PyInit_spam` 函式。要將模組加入初始化表,請使用 :c:func:" "`PyImport_AppendInittab` 並在隨後選擇性地將該模組引入: ::" diff --git a/extending/index.po b/extending/index.po index 757994de4f7..8b55a614933 100644 --- a/extending/index.po +++ b/extending/index.po @@ -1,11 +1,11 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Steven Hsu , 2021 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2021-07-06 22:18+0800\n" diff --git a/extending/newtypes.po b/extending/newtypes.po index 7029e57821b..6ddb5552cfb 100644 --- a/extending/newtypes.po +++ b/extending/newtypes.po @@ -1,14 +1,13 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Leon H., 2017 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-27 00:14+0000\n" +"POT-Creation-Date: 2025-09-08 15:25+0800\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-" @@ -93,11 +92,11 @@ msgid "" " iternextfunc tp_iternext;\n" "\n" " /* Attribute descriptor and subclassing stuff */\n" -" struct PyMethodDef *tp_methods;\n" -" struct PyMemberDef *tp_members;\n" -" struct PyGetSetDef *tp_getset;\n" +" PyMethodDef *tp_methods;\n" +" PyMemberDef *tp_members;\n" +" PyGetSetDef *tp_getset;\n" " // Strong reference on a heap type, borrowed reference on a static type\n" -" struct _typeobject *tp_base;\n" +" PyTypeObject *tp_base;\n" " PyObject *tp_dict;\n" " descrgetfunc tp_descr_get;\n" " descrsetfunc tp_descr_set;\n" @@ -109,12 +108,14 @@ msgid "" " inquiry tp_is_gc; /* For PyObject_IS_GC */\n" " PyObject *tp_bases;\n" " PyObject *tp_mro; /* method resolution order */\n" -" PyObject *tp_cache;\n" -" PyObject *tp_subclasses;\n" -" PyObject *tp_weaklist;\n" +" PyObject *tp_cache; /* no longer used */\n" +" void *tp_subclasses; /* for static builtin types this is an index */\n" +" PyObject *tp_weaklist; /* not used for static builtin types */\n" " destructor tp_del;\n" "\n" -" /* Type attribute cache version tag. Added in version 2.6 */\n" +" /* Type attribute cache version tag. Added in version 2.6.\n" +" * If zero, the cache is invalid and must be initialized.\n" +" */\n" " unsigned int tp_version_tag;\n" "\n" " destructor tp_finalize;\n" @@ -122,6 +123,13 @@ msgid "" "\n" " /* bitset of which type-watchers care about this type */\n" " unsigned char tp_watched;\n" +"\n" +" /* Number of tp_version_tag values used.\n" +" * Set to _Py_ATTR_CACHE_UNUSED if the attribute cache is\n" +" * disabled for this type (e.g. due to custom MRO entries).\n" +" * Otherwise, limited to MAX_VERSIONS_PER_CLASS (defined elsewhere).\n" +" */\n" +" uint16_t tp_versions_used;\n" "} PyTypeObject;\n" msgstr "" @@ -161,9 +169,9 @@ msgstr "" msgid "" "These fields tell the runtime how much memory to allocate when new objects " "of this type are created. Python has some built-in support for variable " -"length structures (think: strings, tuples) which is where the :c:member:" -"`~PyTypeObject.tp_itemsize` field comes in. This will be dealt with " -"later. ::" +"length structures (think: strings, tuples) which is where " +"the :c:member:`~PyTypeObject.tp_itemsize` field comes in. This will be " +"dealt with later. ::" msgstr "" #: ../../extending/newtypes.rst:44 @@ -202,46 +210,50 @@ msgstr "" #: ../../extending/newtypes.rst:72 msgid "" "static void\n" -"newdatatype_dealloc(newdatatypeobject *obj)\n" +"newdatatype_dealloc(PyObject *op)\n" "{\n" -" free(obj->obj_UnderlyingDatatypePtr);\n" -" Py_TYPE(obj)->tp_free((PyObject *)obj);\n" +" newdatatypeobject *self = (newdatatypeobject *) op;\n" +" free(self->obj_UnderlyingDatatypePtr);\n" +" Py_TYPE(self)->tp_free(self);\n" "}" msgstr "" "static void\n" -"newdatatype_dealloc(newdatatypeobject *obj)\n" +"newdatatype_dealloc(PyObject *op)\n" "{\n" -" free(obj->obj_UnderlyingDatatypePtr);\n" -" Py_TYPE(obj)->tp_free((PyObject *)obj);\n" +" newdatatypeobject *self = (newdatatypeobject *) op;\n" +" free(self->obj_UnderlyingDatatypePtr);\n" +" Py_TYPE(self)->tp_free(self);\n" "}" -#: ../../extending/newtypes.rst:79 +#: ../../extending/newtypes.rst:80 msgid "" -"If your type supports garbage collection, the destructor should call :c:func:" -"`PyObject_GC_UnTrack` before clearing any member fields::" +"If your type supports garbage collection, the destructor should " +"call :c:func:`PyObject_GC_UnTrack` before clearing any member fields::" msgstr "" -#: ../../extending/newtypes.rst:82 +#: ../../extending/newtypes.rst:83 msgid "" "static void\n" -"newdatatype_dealloc(newdatatypeobject *obj)\n" +"newdatatype_dealloc(PyObject *op)\n" "{\n" -" PyObject_GC_UnTrack(obj);\n" -" Py_CLEAR(obj->other_obj);\n" +" newdatatypeobject *self = (newdatatypeobject *) op;\n" +" PyObject_GC_UnTrack(op);\n" +" Py_CLEAR(self->other_obj);\n" " ...\n" -" Py_TYPE(obj)->tp_free((PyObject *)obj);\n" +" Py_TYPE(self)->tp_free(self);\n" "}" msgstr "" "static void\n" -"newdatatype_dealloc(newdatatypeobject *obj)\n" +"newdatatype_dealloc(PyObject *op)\n" "{\n" -" PyObject_GC_UnTrack(obj);\n" -" Py_CLEAR(obj->other_obj);\n" +" newdatatypeobject *self = (newdatatypeobject *) op;\n" +" PyObject_GC_UnTrack(op);\n" +" Py_CLEAR(self->other_obj);\n" " ...\n" -" Py_TYPE(obj)->tp_free((PyObject *)obj);\n" +" Py_TYPE(self)->tp_free(self);\n" "}" -#: ../../extending/newtypes.rst:95 +#: ../../extending/newtypes.rst:97 msgid "" "One important requirement of the deallocator function is that it leaves any " "pending exceptions alone. This is important since deallocators are " @@ -252,11 +264,11 @@ msgid "" "additional Python code to be executed may detect that an exception has been " "set. This can lead to misleading errors from the interpreter. The proper " "way to protect against this is to save a pending exception before performing " -"the unsafe action, and restoring it when done. This can be done using the :" -"c:func:`PyErr_Fetch` and :c:func:`PyErr_Restore` functions::" +"the unsafe action, and restoring it when done. This can be done using " +"the :c:func:`PyErr_Fetch` and :c:func:`PyErr_Restore` functions::" msgstr "" -#: ../../extending/newtypes.rst:107 +#: ../../extending/newtypes.rst:109 msgid "" "static void\n" "my_dealloc(PyObject *obj)\n" @@ -271,56 +283,61 @@ msgid "" " PyErr_Fetch(&err_type, &err_value, &err_traceback);\n" "\n" " cbresult = PyObject_CallNoArgs(self->my_callback);\n" -" if (cbresult == NULL)\n" -" PyErr_WriteUnraisable(self->my_callback);\n" -" else\n" +" if (cbresult == NULL) {\n" +" PyErr_WriteUnraisable(self->my_callback);\n" +" }\n" +" else {\n" " Py_DECREF(cbresult);\n" +" }\n" "\n" " /* This restores the saved exception state */\n" " PyErr_Restore(err_type, err_value, err_traceback);\n" "\n" " Py_DECREF(self->my_callback);\n" " }\n" -" Py_TYPE(obj)->tp_free((PyObject*)self);\n" +" Py_TYPE(self)->tp_free(self);\n" "}" msgstr "" -#: ../../extending/newtypes.rst:134 +#: ../../extending/newtypes.rst:138 msgid "" "There are limitations to what you can safely do in a deallocator function. " -"First, if your type supports garbage collection (using :c:member:" -"`~PyTypeObject.tp_traverse` and/or :c:member:`~PyTypeObject.tp_clear`), some " -"of the object's members can have been cleared or finalized by the time :c:" -"member:`~PyTypeObject.tp_dealloc` is called. Second, in :c:member:" -"`~PyTypeObject.tp_dealloc`, your object is in an unstable state: its " -"reference count is equal to zero. Any call to a non-trivial object or API " -"(as in the example above) might end up calling :c:member:`~PyTypeObject." -"tp_dealloc` again, causing a double free and a crash." +"First, if your type supports garbage collection " +"(using :c:member:`~PyTypeObject.tp_traverse` and/" +"or :c:member:`~PyTypeObject.tp_clear`), some of the object's members can " +"have been cleared or finalized by the " +"time :c:member:`~PyTypeObject.tp_dealloc` is called. Second, " +"in :c:member:`~PyTypeObject.tp_dealloc`, your object is in an unstable " +"state: its reference count is equal to zero. Any call to a non-trivial " +"object or API (as in the example above) might end up " +"calling :c:member:`~PyTypeObject.tp_dealloc` again, causing a double free " +"and a crash." msgstr "" -#: ../../extending/newtypes.rst:143 +#: ../../extending/newtypes.rst:147 msgid "" "Starting with Python 3.4, it is recommended not to put any complex " "finalization code in :c:member:`~PyTypeObject.tp_dealloc`, and instead use " "the new :c:member:`~PyTypeObject.tp_finalize` type method." msgstr "" -#: ../../extending/newtypes.rst:148 +#: ../../extending/newtypes.rst:152 msgid ":pep:`442` explains the new finalization scheme." msgstr "" -#: ../../extending/newtypes.rst:155 +#: ../../extending/newtypes.rst:159 msgid "Object Presentation" msgstr "" -#: ../../extending/newtypes.rst:157 +#: ../../extending/newtypes.rst:161 msgid "" "In Python, there are two ways to generate a textual representation of an " -"object: the :func:`repr` function, and the :func:`str` function. (The :func:" -"`print` function just calls :func:`str`.) These handlers are both optional." +"object: the :func:`repr` function, and the :func:`str` function. " +"(The :func:`print` function just calls :func:`str`.) These handlers are " +"both optional." msgstr "" -#: ../../extending/newtypes.rst:163 +#: ../../extending/newtypes.rst:167 msgid "" "reprfunc tp_repr;\n" "reprfunc tp_str;" @@ -328,72 +345,77 @@ msgstr "" "reprfunc tp_repr;\n" "reprfunc tp_str;" -#: ../../extending/newtypes.rst:166 +#: ../../extending/newtypes.rst:170 msgid "" "The :c:member:`~PyTypeObject.tp_repr` handler should return a string object " "containing a representation of the instance for which it is called. Here is " "a simple example::" msgstr "" -#: ../../extending/newtypes.rst:170 +#: ../../extending/newtypes.rst:174 msgid "" "static PyObject *\n" -"newdatatype_repr(newdatatypeobject *obj)\n" +"newdatatype_repr(PyObject *op)\n" "{\n" +" newdatatypeobject *self = (newdatatypeobject *) op;\n" " return PyUnicode_FromFormat(\"Repr-ified_newdatatype{{size:%d}}\",\n" -" obj->obj_UnderlyingDatatypePtr->size);\n" +" self->obj_UnderlyingDatatypePtr->size);\n" "}" msgstr "" "static PyObject *\n" -"newdatatype_repr(newdatatypeobject *obj)\n" +"newdatatype_repr(PyObject *op)\n" "{\n" +" newdatatypeobject *self = (newdatatypeobject *) op;\n" " return PyUnicode_FromFormat(\"Repr-ified_newdatatype{{size:%d}}\",\n" -" obj->obj_UnderlyingDatatypePtr->size);\n" +" self->obj_UnderlyingDatatypePtr->size);\n" "}" -#: ../../extending/newtypes.rst:177 +#: ../../extending/newtypes.rst:182 msgid "" "If no :c:member:`~PyTypeObject.tp_repr` handler is specified, the " -"interpreter will supply a representation that uses the type's :c:member:" -"`~PyTypeObject.tp_name` and a uniquely identifying value for the object." +"interpreter will supply a representation that uses the " +"type's :c:member:`~PyTypeObject.tp_name` and a uniquely identifying value " +"for the object." msgstr "" -#: ../../extending/newtypes.rst:181 +#: ../../extending/newtypes.rst:186 msgid "" -"The :c:member:`~PyTypeObject.tp_str` handler is to :func:`str` what the :c:" -"member:`~PyTypeObject.tp_repr` handler described above is to :func:`repr`; " -"that is, it is called when Python code calls :func:`str` on an instance of " -"your object. Its implementation is very similar to the :c:member:" -"`~PyTypeObject.tp_repr` function, but the resulting string is intended for " -"human consumption. If :c:member:`~PyTypeObject.tp_str` is not specified, " -"the :c:member:`~PyTypeObject.tp_repr` handler is used instead." +"The :c:member:`~PyTypeObject.tp_str` handler is to :func:`str` what " +"the :c:member:`~PyTypeObject.tp_repr` handler described above is " +"to :func:`repr`; that is, it is called when Python code calls :func:`str` on " +"an instance of your object. Its implementation is very similar to " +"the :c:member:`~PyTypeObject.tp_repr` function, but the resulting string is " +"intended for human consumption. If :c:member:`~PyTypeObject.tp_str` is not " +"specified, the :c:member:`~PyTypeObject.tp_repr` handler is used instead." msgstr "" -#: ../../extending/newtypes.rst:188 +#: ../../extending/newtypes.rst:193 msgid "Here is a simple example::" msgstr "以下是個簡單的範例: ::" -#: ../../extending/newtypes.rst:190 +#: ../../extending/newtypes.rst:195 msgid "" "static PyObject *\n" -"newdatatype_str(newdatatypeobject *obj)\n" +"newdatatype_str(PyObject *op)\n" "{\n" +" newdatatypeobject *self = (newdatatypeobject *) op;\n" " return PyUnicode_FromFormat(\"Stringified_newdatatype{{size:%d}}\",\n" -" obj->obj_UnderlyingDatatypePtr->size);\n" +" self->obj_UnderlyingDatatypePtr->size);\n" "}" msgstr "" "static PyObject *\n" -"newdatatype_str(newdatatypeobject *obj)\n" +"newdatatype_str(PyObject *op)\n" "{\n" +" newdatatypeobject *self = (newdatatypeobject *) op;\n" " return PyUnicode_FromFormat(\"Stringified_newdatatype{{size:%d}}\",\n" -" obj->obj_UnderlyingDatatypePtr->size);\n" +" self->obj_UnderlyingDatatypePtr->size);\n" "}" -#: ../../extending/newtypes.rst:200 +#: ../../extending/newtypes.rst:206 msgid "Attribute Management" msgstr "" -#: ../../extending/newtypes.rst:202 +#: ../../extending/newtypes.rst:208 msgid "" "For every object which can support attributes, the corresponding type must " "provide the functions that control how the attributes are resolved. There " @@ -403,16 +425,17 @@ msgid "" "handler is ``NULL``." msgstr "" -#: ../../extending/newtypes.rst:208 +#: ../../extending/newtypes.rst:214 msgid "" "Python supports two pairs of attribute handlers; a type that supports " "attributes only needs to implement the functions for one pair. The " -"difference is that one pair takes the name of the attribute as a :c:expr:" -"`char\\*`, while the other accepts a :c:expr:`PyObject*`. Each type can use " -"whichever pair makes more sense for the implementation's convenience. ::" +"difference is that one pair takes the name of the attribute as " +"a :c:expr:`char\\*`, while the other accepts a :c:expr:`PyObject*`. Each " +"type can use whichever pair makes more sense for the implementation's " +"convenience. ::" msgstr "" -#: ../../extending/newtypes.rst:214 +#: ../../extending/newtypes.rst:220 msgid "" "getattrfunc tp_getattr; /* char * version */\n" "setattrfunc tp_setattr;\n" @@ -426,7 +449,7 @@ msgstr "" "getattrofunc tp_getattro; /* PyObject * version */\n" "setattrofunc tp_setattro;" -#: ../../extending/newtypes.rst:220 +#: ../../extending/newtypes.rst:226 msgid "" "If accessing attributes of an object is always a simple operation (this will " "be explained shortly), there are generic implementations which can be used " @@ -437,51 +460,52 @@ msgid "" "mechanism that is available." msgstr "" -#: ../../extending/newtypes.rst:231 +#: ../../extending/newtypes.rst:237 msgid "Generic Attribute Management" msgstr "" -#: ../../extending/newtypes.rst:233 +#: ../../extending/newtypes.rst:239 msgid "" "Most extension types only use *simple* attributes. So, what makes the " "attributes simple? There are only a couple of conditions that must be met:" msgstr "" -#: ../../extending/newtypes.rst:236 +#: ../../extending/newtypes.rst:242 msgid "" "The name of the attributes must be known when :c:func:`PyType_Ready` is " "called." msgstr "" -#: ../../extending/newtypes.rst:239 +#: ../../extending/newtypes.rst:245 msgid "" "No special processing is needed to record that an attribute was looked up or " "set, nor do actions need to be taken based on the value." msgstr "" -#: ../../extending/newtypes.rst:242 +#: ../../extending/newtypes.rst:248 msgid "" "Note that this list does not place any restrictions on the values of the " "attributes, when the values are computed, or how relevant data is stored." msgstr "" -#: ../../extending/newtypes.rst:245 +#: ../../extending/newtypes.rst:251 msgid "" "When :c:func:`PyType_Ready` is called, it uses three tables referenced by " "the type object to create :term:`descriptor`\\s which are placed in the " "dictionary of the type object. Each descriptor controls access to one " "attribute of the instance object. Each of the tables is optional; if all " "three are ``NULL``, instances of the type will only have attributes that are " -"inherited from their base type, and should leave the :c:member:" -"`~PyTypeObject.tp_getattro` and :c:member:`~PyTypeObject.tp_setattro` fields " -"``NULL`` as well, allowing the base type to handle attributes." +"inherited from their base type, and should leave " +"the :c:member:`~PyTypeObject.tp_getattro` " +"and :c:member:`~PyTypeObject.tp_setattro` fields ``NULL`` as well, allowing " +"the base type to handle attributes." msgstr "" -#: ../../extending/newtypes.rst:253 +#: ../../extending/newtypes.rst:259 msgid "The tables are declared as three fields of the type object::" msgstr "" -#: ../../extending/newtypes.rst:255 +#: ../../extending/newtypes.rst:261 msgid "" "struct PyMethodDef *tp_methods;\n" "struct PyMemberDef *tp_members;\n" @@ -491,14 +515,14 @@ msgstr "" "struct PyMemberDef *tp_members;\n" "struct PyGetSetDef *tp_getset;" -#: ../../extending/newtypes.rst:259 +#: ../../extending/newtypes.rst:265 msgid "" "If :c:member:`~PyTypeObject.tp_methods` is not ``NULL``, it must refer to an " "array of :c:type:`PyMethodDef` structures. Each entry in the table is an " "instance of this structure::" msgstr "" -#: ../../extending/newtypes.rst:263 +#: ../../extending/newtypes.rst:269 msgid "" "typedef struct PyMethodDef {\n" " const char *ml_name; /* method name */\n" @@ -508,15 +532,15 @@ msgid "" "} PyMethodDef;" msgstr "" -#: ../../extending/newtypes.rst:270 +#: ../../extending/newtypes.rst:276 msgid "" "One entry should be defined for each method provided by the type; no entries " "are needed for methods inherited from a base type. One additional entry is " -"needed at the end; it is a sentinel that marks the end of the array. The :c:" -"member:`~PyMethodDef.ml_name` field of the sentinel must be ``NULL``." +"needed at the end; it is a sentinel that marks the end of the array. " +"The :c:member:`~PyMethodDef.ml_name` field of the sentinel must be ``NULL``." msgstr "" -#: ../../extending/newtypes.rst:275 +#: ../../extending/newtypes.rst:281 msgid "" "The second table is used to define attributes which map directly to data " "stored in the instance. A variety of primitive C types are supported, and " @@ -524,7 +548,7 @@ msgid "" "defined as::" msgstr "" -#: ../../extending/newtypes.rst:279 +#: ../../extending/newtypes.rst:285 msgid "" "typedef struct PyMemberDef {\n" " const char *name;\n" @@ -542,114 +566,115 @@ msgstr "" " const char *doc;\n" "} PyMemberDef;" -#: ../../extending/newtypes.rst:287 +#: ../../extending/newtypes.rst:293 msgid "" "For each entry in the table, a :term:`descriptor` will be constructed and " "added to the type which will be able to extract a value from the instance " "structure. The :c:member:`~PyMemberDef.type` field should contain a type " "code like :c:macro:`Py_T_INT` or :c:macro:`Py_T_DOUBLE`; the value will be " -"used to determine how to convert Python values to and from C values. The :c:" -"member:`~PyMemberDef.flags` field is used to store flags which control how " -"the attribute can be accessed: you can set it to :c:macro:`Py_READONLY` to " -"prevent Python code from setting it." +"used to determine how to convert Python values to and from C values. " +"The :c:member:`~PyMemberDef.flags` field is used to store flags which " +"control how the attribute can be accessed: you can set it " +"to :c:macro:`Py_READONLY` to prevent Python code from setting it." msgstr "" -#: ../../extending/newtypes.rst:295 +#: ../../extending/newtypes.rst:301 msgid "" "An interesting advantage of using the :c:member:`~PyTypeObject.tp_members` " "table to build descriptors that are used at runtime is that any attribute " "defined this way can have an associated doc string simply by providing the " "text in the table. An application can use the introspection API to retrieve " -"the descriptor from the class object, and get the doc string using its :attr:" -"`~type.__doc__` attribute." +"the descriptor from the class object, and get the doc string using " +"its :attr:`~type.__doc__` attribute." msgstr "" -#: ../../extending/newtypes.rst:301 +#: ../../extending/newtypes.rst:307 msgid "" "As with the :c:member:`~PyTypeObject.tp_methods` table, a sentinel entry " "with a :c:member:`~PyMethodDef.ml_name` value of ``NULL`` is required." msgstr "" -#: ../../extending/newtypes.rst:315 +#: ../../extending/newtypes.rst:321 msgid "Type-specific Attribute Management" msgstr "" -#: ../../extending/newtypes.rst:317 +#: ../../extending/newtypes.rst:323 msgid "" "For simplicity, only the :c:expr:`char\\*` version will be demonstrated " -"here; the type of the name parameter is the only difference between the :c:" -"expr:`char\\*` and :c:expr:`PyObject*` flavors of the interface. This " +"here; the type of the name parameter is the only difference between " +"the :c:expr:`char\\*` and :c:expr:`PyObject*` flavors of the interface. This " "example effectively does the same thing as the generic example above, but " "does not use the generic support added in Python 2.2. It explains how the " "handler functions are called, so that if you do need to extend their " "functionality, you'll understand what needs to be done." msgstr "" -#: ../../extending/newtypes.rst:325 +#: ../../extending/newtypes.rst:331 msgid "" "The :c:member:`~PyTypeObject.tp_getattr` handler is called when the object " "requires an attribute look-up. It is called in the same situations where " "the :meth:`~object.__getattr__` method of a class would be called." msgstr "" -#: ../../extending/newtypes.rst:329 +#: ../../extending/newtypes.rst:335 msgid "Here is an example::" msgstr "舉例來說: ::" -#: ../../extending/newtypes.rst:331 +#: ../../extending/newtypes.rst:337 msgid "" "static PyObject *\n" -"newdatatype_getattr(newdatatypeobject *obj, char *name)\n" +"newdatatype_getattr(PyObject *op, char *name)\n" "{\n" -" if (strcmp(name, \"data\") == 0)\n" -" {\n" -" return PyLong_FromLong(obj->data);\n" +" newdatatypeobject *self = (newdatatypeobject *) op;\n" +" if (strcmp(name, \"data\") == 0) {\n" +" return PyLong_FromLong(self->data);\n" " }\n" "\n" " PyErr_Format(PyExc_AttributeError,\n" " \"'%.100s' object has no attribute '%.400s'\",\n" -" Py_TYPE(obj)->tp_name, name);\n" +" Py_TYPE(self)->tp_name, name);\n" " return NULL;\n" "}" msgstr "" -#: ../../extending/newtypes.rst:345 +#: ../../extending/newtypes.rst:351 msgid "" -"The :c:member:`~PyTypeObject.tp_setattr` handler is called when the :meth:" -"`~object.__setattr__` or :meth:`~object.__delattr__` method of a class " -"instance would be called. When an attribute should be deleted, the third " -"parameter will be ``NULL``. Here is an example that simply raises an " -"exception; if this were really all you wanted, the :c:member:`~PyTypeObject." -"tp_setattr` handler should be set to ``NULL``. ::" +"The :c:member:`~PyTypeObject.tp_setattr` handler is called when " +"the :meth:`~object.__setattr__` or :meth:`~object.__delattr__` method of a " +"class instance would be called. When an attribute should be deleted, the " +"third parameter will be ``NULL``. Here is an example that simply raises an " +"exception; if this were really all you wanted, " +"the :c:member:`~PyTypeObject.tp_setattr` handler should be set to " +"``NULL``. ::" msgstr "" -#: ../../extending/newtypes.rst:351 +#: ../../extending/newtypes.rst:357 msgid "" "static int\n" -"newdatatype_setattr(newdatatypeobject *obj, char *name, PyObject *v)\n" +"newdatatype_setattr(PyObject *op, char *name, PyObject *v)\n" "{\n" " PyErr_Format(PyExc_RuntimeError, \"Read-only attribute: %s\", name);\n" " return -1;\n" "}" msgstr "" -#: ../../extending/newtypes.rst:359 +#: ../../extending/newtypes.rst:365 msgid "Object Comparison" msgstr "" -#: ../../extending/newtypes.rst:363 +#: ../../extending/newtypes.rst:369 msgid "richcmpfunc tp_richcompare;" msgstr "richcmpfunc tp_richcompare;" -#: ../../extending/newtypes.rst:365 +#: ../../extending/newtypes.rst:371 msgid "" "The :c:member:`~PyTypeObject.tp_richcompare` handler is called when " "comparisons are needed. It is analogous to the :ref:`rich comparison " -"methods `, like :meth:`!__lt__`, and also called by :c:func:" -"`PyObject_RichCompare` and :c:func:`PyObject_RichCompareBool`." +"methods `, like :meth:`!__lt__`, and also called " +"by :c:func:`PyObject_RichCompare` and :c:func:`PyObject_RichCompareBool`." msgstr "" -#: ../../extending/newtypes.rst:370 +#: ../../extending/newtypes.rst:376 msgid "" "This function is called with two Python objects and the operator as " "arguments, where the operator is one of ``Py_EQ``, ``Py_NE``, ``Py_LE``, " @@ -660,18 +685,19 @@ msgid "" "should be tried, or ``NULL`` if an exception was set." msgstr "" -#: ../../extending/newtypes.rst:378 +#: ../../extending/newtypes.rst:384 msgid "" "Here is a sample implementation, for a datatype that is considered equal if " "the size of an internal pointer is equal::" msgstr "" -#: ../../extending/newtypes.rst:381 +#: ../../extending/newtypes.rst:387 msgid "" "static PyObject *\n" -"newdatatype_richcmp(newdatatypeobject *obj1, newdatatypeobject *obj2, int " -"op)\n" +"newdatatype_richcmp(PyObject *lhs, PyObject *rhs, int op)\n" "{\n" +" newdatatypeobject *obj1 = (newdatatypeobject *) lhs;\n" +" newdatatypeobject *obj2 = (newdatatypeobject *) rhs;\n" " PyObject *result;\n" " int c, size1, size2;\n" "\n" @@ -690,22 +716,21 @@ msgid "" " case Py_GE: c = size1 >= size2; break;\n" " }\n" " result = c ? Py_True : Py_False;\n" -" Py_INCREF(result);\n" -" return result;\n" +" return Py_NewRef(result);\n" " }" msgstr "" -#: ../../extending/newtypes.rst:408 +#: ../../extending/newtypes.rst:415 msgid "Abstract Protocol Support" msgstr "" -#: ../../extending/newtypes.rst:410 +#: ../../extending/newtypes.rst:417 msgid "" "Python supports a variety of *abstract* 'protocols;' the specific interfaces " "provided to use these interfaces are documented in :ref:`abstract`." msgstr "" -#: ../../extending/newtypes.rst:414 +#: ../../extending/newtypes.rst:421 msgid "" "A number of these abstract interfaces were defined early in the development " "of the Python implementation. In particular, the number, mapping, and " @@ -720,7 +745,7 @@ msgid "" "slot, but a slot may still be unfilled.) ::" msgstr "" -#: ../../extending/newtypes.rst:425 +#: ../../extending/newtypes.rst:432 msgid "" "PyNumberMethods *tp_as_number;\n" "PySequenceMethods *tp_as_sequence;\n" @@ -730,50 +755,54 @@ msgstr "" "PySequenceMethods *tp_as_sequence;\n" "PyMappingMethods *tp_as_mapping;" -#: ../../extending/newtypes.rst:429 +#: ../../extending/newtypes.rst:436 msgid "" "If you wish your object to be able to act like a number, a sequence, or a " "mapping object, then you place the address of a structure that implements " -"the C type :c:type:`PyNumberMethods`, :c:type:`PySequenceMethods`, or :c:" -"type:`PyMappingMethods`, respectively. It is up to you to fill in this " +"the C type :c:type:`PyNumberMethods`, :c:type:`PySequenceMethods`, " +"or :c:type:`PyMappingMethods`, respectively. It is up to you to fill in this " "structure with appropriate values. You can find examples of the use of each " "of these in the :file:`Objects` directory of the Python source " "distribution. ::" msgstr "" -#: ../../extending/newtypes.rst:436 +#: ../../extending/newtypes.rst:443 msgid "hashfunc tp_hash;" msgstr "hashfunc tp_hash;" -#: ../../extending/newtypes.rst:438 +#: ../../extending/newtypes.rst:445 msgid "" "This function, if you choose to provide it, should return a hash number for " "an instance of your data type. Here is a simple example::" msgstr "" -#: ../../extending/newtypes.rst:441 +#: ../../extending/newtypes.rst:448 msgid "" "static Py_hash_t\n" -"newdatatype_hash(newdatatypeobject *obj)\n" +"newdatatype_hash(PyObject *op)\n" "{\n" +" newdatatypeobject *self = (newdatatypeobject *) op;\n" " Py_hash_t result;\n" -" result = obj->some_size + 32767 * obj->some_number;\n" -" if (result == -1)\n" -" result = -2;\n" +" result = self->some_size + 32767 * self->some_number;\n" +" if (result == -1) {\n" +" result = -2;\n" +" }\n" " return result;\n" "}" msgstr "" "static Py_hash_t\n" -"newdatatype_hash(newdatatypeobject *obj)\n" +"newdatatype_hash(PyObject *op)\n" "{\n" +" newdatatypeobject *self = (newdatatypeobject *) op;\n" " Py_hash_t result;\n" -" result = obj->some_size + 32767 * obj->some_number;\n" -" if (result == -1)\n" -" result = -2;\n" +" result = self->some_size + 32767 * self->some_number;\n" +" if (result == -1) {\n" +" result = -2;\n" +" }\n" " return result;\n" "}" -#: ../../extending/newtypes.rst:451 +#: ../../extending/newtypes.rst:460 msgid "" ":c:type:`Py_hash_t` is a signed integer type with a platform-varying width. " "Returning ``-1`` from :c:member:`~PyTypeObject.tp_hash` indicates an error, " @@ -781,11 +810,11 @@ msgid "" "computation is successful, as seen above." msgstr "" -#: ../../extending/newtypes.rst:458 +#: ../../extending/newtypes.rst:467 msgid "ternaryfunc tp_call;" msgstr "ternaryfunc tp_call;" -#: ../../extending/newtypes.rst:460 +#: ../../extending/newtypes.rst:469 msgid "" "This function is called when an instance of your data type is \"called\", " "for example, if ``obj1`` is an instance of your data type and the Python " @@ -793,40 +822,42 @@ msgid "" "handler is invoked." msgstr "" -#: ../../extending/newtypes.rst:464 +#: ../../extending/newtypes.rst:473 msgid "This function takes three arguments:" msgstr "" -#: ../../extending/newtypes.rst:466 +#: ../../extending/newtypes.rst:475 msgid "" "*self* is the instance of the data type which is the subject of the call. If " "the call is ``obj1('hello')``, then *self* is ``obj1``." msgstr "" -#: ../../extending/newtypes.rst:469 +#: ../../extending/newtypes.rst:478 msgid "" -"*args* is a tuple containing the arguments to the call. You can use :c:func:" -"`PyArg_ParseTuple` to extract the arguments." +"*args* is a tuple containing the arguments to the call. You can " +"use :c:func:`PyArg_ParseTuple` to extract the arguments." msgstr "" -#: ../../extending/newtypes.rst:472 +#: ../../extending/newtypes.rst:481 msgid "" "*kwds* is a dictionary of keyword arguments that were passed. If this is non-" -"``NULL`` and you support keyword arguments, use :c:func:" -"`PyArg_ParseTupleAndKeywords` to extract the arguments. If you do not want " -"to support keyword arguments and this is non-``NULL``, raise a :exc:" -"`TypeError` with a message saying that keyword arguments are not supported." +"``NULL`` and you support keyword arguments, " +"use :c:func:`PyArg_ParseTupleAndKeywords` to extract the arguments. If you " +"do not want to support keyword arguments and this is non-``NULL``, raise " +"a :exc:`TypeError` with a message saying that keyword arguments are not " +"supported." msgstr "" -#: ../../extending/newtypes.rst:478 +#: ../../extending/newtypes.rst:487 msgid "Here is a toy ``tp_call`` implementation::" msgstr "" -#: ../../extending/newtypes.rst:480 +#: ../../extending/newtypes.rst:489 msgid "" "static PyObject *\n" -"newdatatype_call(newdatatypeobject *obj, PyObject *args, PyObject *kwds)\n" +"newdatatype_call(PyObject *op, PyObject *args, PyObject *kwds)\n" "{\n" +" newdatatypeobject *self = (newdatatypeobject *) op;\n" " PyObject *result;\n" " const char *arg1;\n" " const char *arg2;\n" @@ -837,14 +868,15 @@ msgid "" " }\n" " result = PyUnicode_FromFormat(\n" " \"Returning -- value: [%d] arg1: [%s] arg2: [%s] arg3: [%s]\\n\",\n" -" obj->obj_UnderlyingDatatypePtr->size,\n" +" self->obj_UnderlyingDatatypePtr->size,\n" " arg1, arg2, arg3);\n" " return result;\n" "}" msgstr "" "static PyObject *\n" -"newdatatype_call(newdatatypeobject *obj, PyObject *args, PyObject *kwds)\n" +"newdatatype_call(PyObject *op, PyObject *args, PyObject *kwds)\n" "{\n" +" newdatatypeobject *self = (newdatatypeobject *) op;\n" " PyObject *result;\n" " const char *arg1;\n" " const char *arg2;\n" @@ -855,12 +887,12 @@ msgstr "" " }\n" " result = PyUnicode_FromFormat(\n" " \"Returning -- value: [%d] arg1: [%s] arg2: [%s] arg3: [%s]\\n\",\n" -" obj->obj_UnderlyingDatatypePtr->size,\n" +" self->obj_UnderlyingDatatypePtr->size,\n" " arg1, arg2, arg3);\n" " return result;\n" "}" -#: ../../extending/newtypes.rst:500 +#: ../../extending/newtypes.rst:510 msgid "" "/* Iterators */\n" "getiterfunc tp_iter;\n" @@ -870,70 +902,74 @@ msgstr "" "getiterfunc tp_iter;\n" "iternextfunc tp_iternext;" -#: ../../extending/newtypes.rst:504 +#: ../../extending/newtypes.rst:514 msgid "" "These functions provide support for the iterator protocol. Both handlers " "take exactly one parameter, the instance for which they are being called, " "and return a new reference. In the case of an error, they should set an " "exception and return ``NULL``. :c:member:`~PyTypeObject.tp_iter` " -"corresponds to the Python :meth:`~object.__iter__` method, while :c:member:" -"`~PyTypeObject.tp_iternext` corresponds to the Python :meth:`~iterator." -"__next__` method." +"corresponds to the Python :meth:`~object.__iter__` method, " +"while :c:member:`~PyTypeObject.tp_iternext` corresponds to the " +"Python :meth:`~iterator.__next__` method." msgstr "" -#: ../../extending/newtypes.rst:511 +#: ../../extending/newtypes.rst:521 msgid "" -"Any :term:`iterable` object must implement the :c:member:`~PyTypeObject." -"tp_iter` handler, which must return an :term:`iterator` object. Here the " -"same guidelines apply as for Python classes:" +"Any :term:`iterable` object must implement " +"the :c:member:`~PyTypeObject.tp_iter` handler, which must return " +"an :term:`iterator` object. Here the same guidelines apply as for Python " +"classes:" msgstr "" -#: ../../extending/newtypes.rst:515 +#: ../../extending/newtypes.rst:525 msgid "" "For collections (such as lists and tuples) which can support multiple " "independent iterators, a new iterator should be created and returned by each " "call to :c:member:`~PyTypeObject.tp_iter`." msgstr "" -#: ../../extending/newtypes.rst:518 +#: ../../extending/newtypes.rst:528 msgid "" "Objects which can only be iterated over once (usually due to side effects of " -"iteration, such as file objects) can implement :c:member:`~PyTypeObject." -"tp_iter` by returning a new reference to themselves -- and should also " -"therefore implement the :c:member:`~PyTypeObject.tp_iternext` handler." -msgstr "" - -#: ../../extending/newtypes.rst:523 -msgid "" -"Any :term:`iterator` object should implement both :c:member:`~PyTypeObject." -"tp_iter` and :c:member:`~PyTypeObject.tp_iternext`. An iterator's :c:member:" -"`~PyTypeObject.tp_iter` handler should return a new reference to the " -"iterator. Its :c:member:`~PyTypeObject.tp_iternext` handler should return a " -"new reference to the next object in the iteration, if there is one. If the " -"iteration has reached the end, :c:member:`~PyTypeObject.tp_iternext` may " -"return ``NULL`` without setting an exception, or it may set :exc:" -"`StopIteration` *in addition* to returning ``NULL``; avoiding the exception " -"can yield slightly better performance. If an actual error occurs, :c:member:" -"`~PyTypeObject.tp_iternext` should always set an exception and return " -"``NULL``." -msgstr "" - -#: ../../extending/newtypes.rst:539 +"iteration, such as file objects) can " +"implement :c:member:`~PyTypeObject.tp_iter` by returning a new reference to " +"themselves -- and should also therefore implement " +"the :c:member:`~PyTypeObject.tp_iternext` handler." +msgstr "" + +#: ../../extending/newtypes.rst:533 +msgid "" +"Any :term:`iterator` object should implement " +"both :c:member:`~PyTypeObject.tp_iter` " +"and :c:member:`~PyTypeObject.tp_iternext`. An " +"iterator's :c:member:`~PyTypeObject.tp_iter` handler should return a new " +"reference to the iterator. Its :c:member:`~PyTypeObject.tp_iternext` " +"handler should return a new reference to the next object in the iteration, " +"if there is one. If the iteration has reached the " +"end, :c:member:`~PyTypeObject.tp_iternext` may return ``NULL`` without " +"setting an exception, or it may set :exc:`StopIteration` *in addition* to " +"returning ``NULL``; avoiding the exception can yield slightly better " +"performance. If an actual error " +"occurs, :c:member:`~PyTypeObject.tp_iternext` should always set an exception " +"and return ``NULL``." +msgstr "" + +#: ../../extending/newtypes.rst:549 msgid "Weak Reference Support" msgstr "" -#: ../../extending/newtypes.rst:541 +#: ../../extending/newtypes.rst:551 msgid "" "One of the goals of Python's weak reference implementation is to allow any " "type to participate in the weak reference mechanism without incurring the " "overhead on performance-critical objects (such as numbers)." msgstr "" -#: ../../extending/newtypes.rst:546 +#: ../../extending/newtypes.rst:556 msgid "Documentation for the :mod:`weakref` module." msgstr "" -#: ../../extending/newtypes.rst:548 +#: ../../extending/newtypes.rst:558 msgid "" "For an object to be weakly referenceable, the extension type must set the " "``Py_TPFLAGS_MANAGED_WEAKREF`` bit of the :c:member:`~PyTypeObject.tp_flags` " @@ -941,12 +977,12 @@ msgid "" "be left as zero." msgstr "" -#: ../../extending/newtypes.rst:553 +#: ../../extending/newtypes.rst:563 msgid "" "Concretely, here is how the statically declared type object would look::" msgstr "" -#: ../../extending/newtypes.rst:555 +#: ../../extending/newtypes.rst:565 msgid "" "static PyTypeObject TrivialType = {\n" " PyVarObject_HEAD_INIT(NULL, 0)\n" @@ -955,29 +991,29 @@ msgid "" "};" msgstr "" -#: ../../extending/newtypes.rst:562 +#: ../../extending/newtypes.rst:572 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:565 +#: ../../extending/newtypes.rst:575 msgid "" "static void\n" -"Trivial_dealloc(TrivialObject *self)\n" +"Trivial_dealloc(PyObject *op)\n" "{\n" " /* Clear weakrefs first before calling any destructors */\n" -" PyObject_ClearWeakRefs((PyObject *) self);\n" +" PyObject_ClearWeakRefs(op);\n" " /* ... remainder of destruction code omitted for brevity ... */\n" -" Py_TYPE(self)->tp_free((PyObject *) self);\n" +" Py_TYPE(op)->tp_free(op);\n" "}" msgstr "" -#: ../../extending/newtypes.rst:576 +#: ../../extending/newtypes.rst:586 msgid "More Suggestions" msgstr "" -#: ../../extending/newtypes.rst:578 +#: ../../extending/newtypes.rst:588 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` " @@ -986,14 +1022,14 @@ msgid "" "function you want to implement." msgstr "" -#: ../../extending/newtypes.rst:584 +#: ../../extending/newtypes.rst:594 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:588 +#: ../../extending/newtypes.rst:598 msgid "" "if (!PyObject_TypeCheck(some_object, &MyType)) {\n" " PyErr_SetString(PyExc_TypeError, \"arg #1 not a mything\");\n" @@ -1001,20 +1037,20 @@ msgid "" "}" msgstr "" -#: ../../extending/newtypes.rst:594 +#: ../../extending/newtypes.rst:604 msgid "Download CPython source releases." msgstr "" -#: ../../extending/newtypes.rst:595 +#: ../../extending/newtypes.rst:605 msgid "https://www.python.org/downloads/source/" msgstr "https://www.python.org/downloads/source/" -#: ../../extending/newtypes.rst:597 +#: ../../extending/newtypes.rst:607 msgid "" "The CPython project on GitHub, where the CPython source code is developed." msgstr "" -#: ../../extending/newtypes.rst:598 +#: ../../extending/newtypes.rst:608 msgid "https://github.com/python/cpython" msgstr "https://github.com/python/cpython" @@ -1038,26 +1074,26 @@ msgstr "" msgid "finalization, of objects" msgstr "" -#: ../../extending/newtypes.rst:91 +#: ../../extending/newtypes.rst:93 msgid "PyErr_Fetch (C function)" msgstr "PyErr_Fetch(C 函式)" -#: ../../extending/newtypes.rst:91 +#: ../../extending/newtypes.rst:93 msgid "PyErr_Restore (C function)" msgstr "PyErr_Restore(C 函式)" -#: ../../extending/newtypes.rst:150 +#: ../../extending/newtypes.rst:154 msgid "string" msgstr "string(字串)" -#: ../../extending/newtypes.rst:150 +#: ../../extending/newtypes.rst:154 msgid "object representation" msgstr "object representation(物件表示)" -#: ../../extending/newtypes.rst:150 +#: ../../extending/newtypes.rst:154 msgid "built-in function" msgstr "built-in function(內建函式)" -#: ../../extending/newtypes.rst:150 +#: ../../extending/newtypes.rst:154 msgid "repr" msgstr "repr" diff --git a/extending/newtypes_tutorial.po b/extending/newtypes_tutorial.po index 4f6a0caec2f..f9af9cb62f0 100644 --- a/extending/newtypes_tutorial.po +++ b/extending/newtypes_tutorial.po @@ -1,10 +1,10 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"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: 2025-09-08 15:25+0800\n" "PO-Revision-Date: 2018-07-15 18:56+0800\n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" @@ -33,14 +33,14 @@ msgstr "" #: ../../extending/newtypes_tutorial.rst:26 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 objects. " -"The :c:type:`PyObject` structure itself only contains the object's :term:" -"`reference count` and a pointer to the object's \"type object\". This is " -"where the action is; the type object determines which (C) functions get " -"called by the interpreter when, for instance, an attribute gets looked up on " -"an object, a method called, or it is multiplied by another object. These C " -"functions are called \"type methods\"." +"The :term:`CPython` runtime sees all Python objects as variables of " +"type :c:expr:`PyObject*`, which serves as a \"base type\" for all Python " +"objects. The :c:type:`PyObject` structure itself only contains the " +"object's :term:`reference count` and a pointer to the object's \"type " +"object\". This is where the action is; the type object determines which (C) " +"functions get called by the interpreter when, for instance, an attribute " +"gets looked up on an object, a method called, or it is multiplied by another " +"object. These C functions are called \"type methods\"." msgstr "" #: ../../extending/newtypes_tutorial.rst:35 @@ -60,8 +60,8 @@ msgstr "" 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 " -"allows defining heap-allocated extension types using the :c:func:" -"`PyType_FromSpec` function, which isn't covered in this tutorial." +"allows defining heap-allocated extension types using " +"the :c:func:`PyType_FromSpec` function, which isn't covered in this tutorial." msgstr "" #: ../../extending/newtypes_tutorial.rst:48 @@ -271,14 +271,19 @@ msgid "" " File \"\", line 1, in \n" "TypeError: can only concatenate str (not \"custom.Custom\") to str" msgstr "" +">>> \"\" + custom.Custom()\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"TypeError: can only concatenate str (not \"custom.Custom\") to str" #: ../../extending/newtypes_tutorial.rst:131 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:`!" -"custom` and the type is :class:`!Custom`, so we set the type name to :class:" -"`!custom.Custom`. Using the real dotted import path is important to make " -"your type compatible with the :mod:`pydoc` and :mod:`pickle` modules. ::" +"custom` and the type is :class:`!Custom`, so we set the type name " +"to :class:`!custom.Custom`. Using the real dotted import path is important " +"to make your type compatible with the :mod:`pydoc` and :mod:`pickle` " +"modules. ::" msgstr "" #: ../../extending/newtypes_tutorial.rst:137 @@ -291,9 +296,9 @@ msgstr "" #: ../../extending/newtypes_tutorial.rst:140 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." +"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 @@ -336,11 +341,11 @@ msgstr ".tp_doc = PyDoc_STR(\"Custom objects\")," #: ../../extending/newtypes_tutorial.rst:168 msgid "" -"To enable object creation, we have to provide a :c:member:`~PyTypeObject." -"tp_new` handler. This is the equivalent of the Python method :meth:`~object." -"__new__`, but has to be specified explicitly. In this case, we can just use " -"the default implementation provided by the API function :c:func:" -"`PyType_GenericNew`. ::" +"To enable object creation, we have to provide " +"a :c:member:`~PyTypeObject.tp_new` handler. This is the equivalent of the " +"Python method :meth:`~object.__new__`, but has to be specified explicitly. " +"In this case, we can just use the default implementation provided by the API " +"function :c:func:`PyType_GenericNew`. ::" msgstr "" #: ../../extending/newtypes_tutorial.rst:173 @@ -349,8 +354,8 @@ msgstr ".tp_new = PyType_GenericNew," #: ../../extending/newtypes_tutorial.rst:175 msgid "" -"Everything else in the file should be familiar, except for some code in :c:" -"func:`!custom_module_exec`::" +"Everything else in the file should be familiar, except for some code " +"in :c:func:`!custom_module_exec`::" msgstr "" #: ../../extending/newtypes_tutorial.rst:178 @@ -382,8 +387,8 @@ msgstr "" #: ../../extending/newtypes_tutorial.rst:190 msgid "" -"This adds the type to the module dictionary. This allows us to create :" -"class:`!Custom` instances by calling the :class:`!Custom` class:" +"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 @@ -435,7 +440,7 @@ msgid "in a file called :file:`setup.py`; then typing" msgstr "" #: ../../extending/newtypes_tutorial.rst:212 -#: ../../extending/newtypes_tutorial.rst:527 +#: ../../extending/newtypes_tutorial.rst:550 msgid "$ python -m pip install ." msgstr "$ python -m pip install ." @@ -481,11 +486,12 @@ msgid "" "} CustomObject;\n" "\n" "static void\n" -"Custom_dealloc(CustomObject *self)\n" +"Custom_dealloc(PyObject *op)\n" "{\n" +" CustomObject *self = (CustomObject *) op;\n" " Py_XDECREF(self->first);\n" " Py_XDECREF(self->last);\n" -" Py_TYPE(self)->tp_free((PyObject *) self);\n" +" Py_TYPE(self)->tp_free(self);\n" "}\n" "\n" "static PyObject *\n" @@ -494,12 +500,12 @@ msgid "" " CustomObject *self;\n" " self = (CustomObject *) type->tp_alloc(type, 0);\n" " if (self != NULL) {\n" -" self->first = PyUnicode_FromString(\"\");\n" +" self->first = Py_GetConstant(Py_CONSTANT_EMPTY_STR);\n" " if (self->first == NULL) {\n" " Py_DECREF(self);\n" " return NULL;\n" " }\n" -" self->last = PyUnicode_FromString(\"\");\n" +" self->last = Py_GetConstant(Py_CONSTANT_EMPTY_STR);\n" " if (self->last == NULL) {\n" " Py_DECREF(self);\n" " return NULL;\n" @@ -510,8 +516,9 @@ msgid "" "}\n" "\n" "static int\n" -"Custom_init(CustomObject *self, PyObject *args, PyObject *kwds)\n" +"Custom_init(PyObject *op, PyObject *args, PyObject *kwds)\n" "{\n" +" CustomObject *self = (CustomObject *) op;\n" " static char *kwlist[] = {\"first\", \"last\", \"number\", NULL};\n" " PyObject *first = NULL, *last = NULL;\n" "\n" @@ -540,8 +547,9 @@ msgid "" "};\n" "\n" "static PyObject *\n" -"Custom_name(CustomObject *self, PyObject *Py_UNUSED(ignored))\n" +"Custom_name(PyObject *op, PyObject *Py_UNUSED(dummy))\n" "{\n" +" CustomObject *self = (CustomObject *) op;\n" " if (self->first == NULL) {\n" " PyErr_SetString(PyExc_AttributeError, \"first\");\n" " return NULL;\n" @@ -554,7 +562,7 @@ msgid "" "}\n" "\n" "static PyMethodDef Custom_methods[] = {\n" -" {\"name\", (PyCFunction) Custom_name, METH_NOARGS,\n" +" {\"name\", Custom_name, METH_NOARGS,\n" " \"Return the name, combining the first and last name\"\n" " },\n" " {NULL} /* Sentinel */\n" @@ -568,8 +576,8 @@ msgid "" " .tp_itemsize = 0,\n" " .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,\n" " .tp_new = Custom_new,\n" -" .tp_init = (initproc) Custom_init,\n" -" .tp_dealloc = (destructor) Custom_dealloc,\n" +" .tp_init = Custom_init,\n" +" .tp_dealloc = Custom_dealloc,\n" " .tp_members = Custom_members,\n" " .tp_methods = Custom_methods,\n" "};\n" @@ -652,56 +660,92 @@ msgstr "" #: ../../extending/newtypes_tutorial.rst:254 msgid "" "static void\n" -"Custom_dealloc(CustomObject *self)\n" +"Custom_dealloc(PyObject *op)\n" "{\n" +" CustomObject *self = (CustomObject *) op;\n" " Py_XDECREF(self->first);\n" " Py_XDECREF(self->last);\n" -" Py_TYPE(self)->tp_free((PyObject *) self);\n" +" Py_TYPE(self)->tp_free(self);\n" "}" msgstr "" "static void\n" -"Custom_dealloc(CustomObject *self)\n" +"Custom_dealloc(PyObject *op)\n" "{\n" +" CustomObject *self = (CustomObject *) op;\n" " Py_XDECREF(self->first);\n" " Py_XDECREF(self->last);\n" -" Py_TYPE(self)->tp_free((PyObject *) self);\n" +" Py_TYPE(self)->tp_free(self);\n" "}" -#: ../../extending/newtypes_tutorial.rst:262 +#: ../../extending/newtypes_tutorial.rst:263 msgid "which is assigned to the :c:member:`~PyTypeObject.tp_dealloc` member::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:264 -msgid ".tp_dealloc = (destructor) Custom_dealloc," -msgstr ".tp_dealloc = (destructor) Custom_dealloc," +#: ../../extending/newtypes_tutorial.rst:265 +msgid ".tp_dealloc = Custom_dealloc," +msgstr ".tp_dealloc = Custom_dealloc," -#: ../../extending/newtypes_tutorial.rst:266 +#: ../../extending/newtypes_tutorial.rst:267 msgid "" -"This method first clears the reference counts of the two Python attributes. :" -"c:func:`Py_XDECREF` correctly handles the case where its argument is " -"``NULL`` (which might happen here if ``tp_new`` failed midway). It then " -"calls the :c:member:`~PyTypeObject.tp_free` member of the object's type " -"(computed by ``Py_TYPE(self)``) to free the object's memory. Note that the " -"object's type might not be :class:`!CustomType`, because the object may be " -"an instance of a subclass." +"This method first clears the reference counts of the two Python " +"attributes. :c:func:`Py_XDECREF` correctly handles the case where its " +"argument is ``NULL`` (which might happen here if ``tp_new`` failed midway). " +"It then calls the :c:member:`~PyTypeObject.tp_free` member of the object's " +"type (computed by ``Py_TYPE(self)``) to free the object's memory. Note that " +"the object's type might not be :class:`!CustomType`, because the object may " +"be an instance of a subclass." +msgstr "" + +#: ../../extending/newtypes_tutorial.rst:277 +msgid "" +"The explicit cast to ``CustomObject *`` above is needed because we defined " +"``Custom_dealloc`` to take a ``PyObject *`` argument, as the ``tp_dealloc`` " +"function pointer expects to receive a ``PyObject *`` argument. By assigning " +"to the ``tp_dealloc`` slot of a type, we declare that it can only be called " +"with instances of our ``CustomObject`` class, so the cast to ``(CustomObject " +"*)`` is safe. This is object-oriented polymorphism, in C!" +msgstr "" + +#: ../../extending/newtypes_tutorial.rst:285 +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 +msgid "" +"Custom_dealloc(CustomObject *self)\n" +"{\n" +" Py_XDECREF(self->first);\n" +" Py_XDECREF(self->last);\n" +" Py_TYPE(self)->tp_free((PyObject *) self);\n" +"}\n" +"...\n" +".tp_dealloc = (destructor) Custom_dealloc," msgstr "" +"Custom_dealloc(CustomObject *self)\n" +"{\n" +" Py_XDECREF(self->first);\n" +" Py_XDECREF(self->last);\n" +" Py_TYPE(self)->tp_free((PyObject *) self);\n" +"}\n" +"...\n" +".tp_dealloc = (destructor) Custom_dealloc," -#: ../../extending/newtypes_tutorial.rst:275 +#: ../../extending/newtypes_tutorial.rst:298 msgid "" -"The explicit cast to ``destructor`` above is needed because we defined " -"``Custom_dealloc`` to take a ``CustomObject *`` argument, but the " -"``tp_dealloc`` function pointer expects to receive a ``PyObject *`` " -"argument. Otherwise, the compiler will emit a warning. This is object-" -"oriented polymorphism, in C!" +"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:281 +#: ../../extending/newtypes_tutorial.rst:302 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:284 +#: ../../extending/newtypes_tutorial.rst:305 msgid "" "static PyObject *\n" "Custom_new(PyTypeObject *type, PyObject *args, PyObject *kwds)\n" @@ -745,58 +789,60 @@ msgstr "" " return (PyObject *) self;\n" "}" -#: ../../extending/newtypes_tutorial.rst:305 +#: ../../extending/newtypes_tutorial.rst:326 msgid "and install it in the :c:member:`~PyTypeObject.tp_new` member::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:307 +#: ../../extending/newtypes_tutorial.rst:328 msgid ".tp_new = Custom_new," msgstr ".tp_new = Custom_new," -#: ../../extending/newtypes_tutorial.rst:309 +#: ../../extending/newtypes_tutorial.rst:330 msgid "" "The ``tp_new`` handler is responsible for creating (as opposed to " -"initializing) objects of the type. It is exposed in Python as the :meth:" -"`~object.__new__` method. It is not required to define a ``tp_new`` member, " -"and indeed many extension types will simply reuse :c:func:" -"`PyType_GenericNew` as done in the first version of the :class:`!Custom` " -"type above. In this case, we use the ``tp_new`` handler to initialize the " -"``first`` and ``last`` attributes to non-``NULL`` default values." +"initializing) objects of the type. It is exposed in Python as " +"the :meth:`~object.__new__` method. It is not required to define a " +"``tp_new`` member, and indeed many extension types will simply " +"reuse :c:func:`PyType_GenericNew` as done in the first version of " +"the :class:`!Custom` type above. In this case, we use the ``tp_new`` " +"handler to initialize the ``first`` and ``last`` attributes to non-``NULL`` " +"default values." msgstr "" -#: ../../extending/newtypes_tutorial.rst:317 +#: ../../extending/newtypes_tutorial.rst:338 msgid "" "``tp_new`` is passed the type being instantiated (not necessarily " "``CustomType``, if a subclass is instantiated) and any arguments passed when " "the type was called, and is expected to return the instance created. " "``tp_new`` handlers always accept positional and keyword arguments, but they " -"often ignore the arguments, leaving the argument handling to initializer (a." -"k.a. ``tp_init`` in C or ``__init__`` in Python) methods." +"often ignore the arguments, leaving the argument handling to initializer " +"(a.k.a. ``tp_init`` in C or ``__init__`` in Python) methods." msgstr "" -#: ../../extending/newtypes_tutorial.rst:325 +#: ../../extending/newtypes_tutorial.rst:346 msgid "" "``tp_new`` shouldn't call ``tp_init`` explicitly, as the interpreter will do " "it itself." msgstr "" -#: ../../extending/newtypes_tutorial.rst:328 +#: ../../extending/newtypes_tutorial.rst:349 msgid "" "The ``tp_new`` implementation calls the :c:member:`~PyTypeObject.tp_alloc` " "slot to allocate memory::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:331 +#: ../../extending/newtypes_tutorial.rst:352 msgid "self = (CustomObject *) type->tp_alloc(type, 0);" msgstr "self = (CustomObject *) type->tp_alloc(type, 0);" -#: ../../extending/newtypes_tutorial.rst:333 +#: ../../extending/newtypes_tutorial.rst:354 msgid "" -"Since memory allocation may fail, we must check the :c:member:`~PyTypeObject." -"tp_alloc` result against ``NULL`` before proceeding." +"Since memory allocation may fail, we must check " +"the :c:member:`~PyTypeObject.tp_alloc` result against ``NULL`` before " +"proceeding." msgstr "" -#: ../../extending/newtypes_tutorial.rst:337 +#: ../../extending/newtypes_tutorial.rst:358 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 " @@ -804,30 +850,32 @@ msgid "" "allocation strategy." msgstr "" -#: ../../extending/newtypes_tutorial.rst:343 +#: ../../extending/newtypes_tutorial.rst:364 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` or :meth:`~object." -"__new__`), you must *not* try to determine what method to call using method " -"resolution order at runtime. Always statically determine what type you are " -"going to call, and call its :c:member:`~PyTypeObject.tp_new` directly, or " -"via ``type->tp_base->tp_new``. If you do not do this, Python subclasses of " -"your type that also inherit from other Python-defined classes may not work " -"correctly. (Specifically, you may not be able to create instances of such " -"subclasses without getting a :exc:`TypeError`.)" +"that calls a base type's :c:member:`~PyTypeObject.tp_new` " +"or :meth:`~object.__new__`), you must *not* try to determine what method to " +"call using method resolution order at runtime. Always statically determine " +"what type you are going to call, and call " +"its :c:member:`~PyTypeObject.tp_new` directly, or via ``type->tp_base-" +">tp_new``. If you do not do this, Python subclasses of your type that also " +"inherit from other Python-defined classes may not work correctly. " +"(Specifically, you may not be able to create instances of such subclasses " +"without getting a :exc:`TypeError`.)" msgstr "" -#: ../../extending/newtypes_tutorial.rst:353 +#: ../../extending/newtypes_tutorial.rst:374 msgid "" "We also define an initialization function which accepts arguments to provide " "initial values for our instance::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:356 +#: ../../extending/newtypes_tutorial.rst:377 msgid "" "static int\n" -"Custom_init(CustomObject *self, PyObject *args, PyObject *kwds)\n" +"Custom_init(PyObject *op, PyObject *args, PyObject *kwds)\n" "{\n" +" CustomObject *self = (CustomObject *) op;\n" " static char *kwlist[] = {\"first\", \"last\", \"number\", NULL};\n" " PyObject *first = NULL, *last = NULL, *tmp;\n" "\n" @@ -852,8 +900,9 @@ msgid "" "}" msgstr "" "static int\n" -"Custom_init(CustomObject *self, PyObject *args, PyObject *kwds)\n" +"Custom_init(PyObject *op, PyObject *args, PyObject *kwds)\n" "{\n" +" CustomObject *self = (CustomObject *) op;\n" " static char *kwlist[] = {\"first\", \"last\", \"number\", NULL};\n" " PyObject *first = NULL, *last = NULL, *tmp;\n" "\n" @@ -877,23 +926,23 @@ msgstr "" " return 0;\n" "}" -#: ../../extending/newtypes_tutorial.rst:382 +#: ../../extending/newtypes_tutorial.rst:404 msgid "by filling the :c:member:`~PyTypeObject.tp_init` slot. ::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:384 -msgid ".tp_init = (initproc) Custom_init," -msgstr ".tp_init = (initproc) Custom_init," +#: ../../extending/newtypes_tutorial.rst:406 +msgid ".tp_init = Custom_init," +msgstr ".tp_init = Custom_init," -#: ../../extending/newtypes_tutorial.rst:386 +#: ../../extending/newtypes_tutorial.rst:408 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 after it's " -"created. Initializers always accept positional and keyword arguments, and " -"they should return either ``0`` on success or ``-1`` on error." +"The :c:member:`~PyTypeObject.tp_init` slot is exposed in Python as " +"the :meth:`~object.__init__` method. It is used to initialize an object " +"after it's created. Initializers always accept positional and keyword " +"arguments, and they should return either ``0`` on success or ``-1`` on error." msgstr "" -#: ../../extending/newtypes_tutorial.rst:391 +#: ../../extending/newtypes_tutorial.rst:413 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 " @@ -904,7 +953,7 @@ msgid "" "``first`` member like this::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:399 +#: ../../extending/newtypes_tutorial.rst:421 msgid "" "if (first) {\n" " Py_XDECREF(self->first);\n" @@ -918,47 +967,48 @@ msgstr "" " self->first = first;\n" "}" -#: ../../extending/newtypes_tutorial.rst:405 +#: ../../extending/newtypes_tutorial.rst:427 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 " "destructor that causes code to be executed that tries to access the " -"``first`` member; or that destructor could release the :term:`Global " -"interpreter Lock ` and let arbitrary code run in other threads that " +"``first`` member; or that destructor could detach the :term:`thread state " +"` and let arbitrary code run in other threads that " "accesses and modifies our object." msgstr "" -#: ../../extending/newtypes_tutorial.rst:412 +#: ../../extending/newtypes_tutorial.rst:434 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:416 +#: ../../extending/newtypes_tutorial.rst:438 msgid "when we absolutely know that the reference count is greater than 1;" msgstr "" -#: ../../extending/newtypes_tutorial.rst:418 +#: ../../extending/newtypes_tutorial.rst:440 msgid "" -"when we know that deallocation of the object [#]_ will neither release the :" -"term:`GIL` nor cause any calls back into our type's code;" +"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:421 +#: ../../extending/newtypes_tutorial.rst:443 msgid "" -"when decrementing a reference count in a :c:member:`~PyTypeObject." -"tp_dealloc` handler on a type which doesn't support cyclic garbage " -"collection [#]_." +"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:424 +#: ../../extending/newtypes_tutorial.rst:446 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:427 +#: ../../extending/newtypes_tutorial.rst:449 msgid "" "static PyMemberDef Custom_members[] = {\n" " {\"first\", Py_T_OBJECT_EX, offsetof(CustomObject, first), 0,\n" @@ -971,23 +1021,23 @@ msgid "" "};" msgstr "" -#: ../../extending/newtypes_tutorial.rst:437 +#: ../../extending/newtypes_tutorial.rst:459 msgid "" "and put the definitions in the :c:member:`~PyTypeObject.tp_members` slot::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:439 +#: ../../extending/newtypes_tutorial.rst:461 msgid ".tp_members = Custom_members," msgstr ".tp_members = Custom_members," -#: ../../extending/newtypes_tutorial.rst:441 +#: ../../extending/newtypes_tutorial.rst:463 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:445 +#: ../../extending/newtypes_tutorial.rst:467 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 " @@ -998,17 +1048,18 @@ msgid "" "deleted." msgstr "" -#: ../../extending/newtypes_tutorial.rst:452 +#: ../../extending/newtypes_tutorial.rst:474 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:455 +#: ../../extending/newtypes_tutorial.rst:477 msgid "" "static PyObject *\n" -"Custom_name(CustomObject *self, PyObject *Py_UNUSED(ignored))\n" +"Custom_name(PyObject *op, PyObject *Py_UNUSED(dummy))\n" "{\n" +" CustomObject *self = (CustomObject *) op;\n" " if (self->first == NULL) {\n" " PyErr_SetString(PyExc_AttributeError, \"first\");\n" " return NULL;\n" @@ -1021,8 +1072,9 @@ msgid "" "}" msgstr "" "static PyObject *\n" -"Custom_name(CustomObject *self, PyObject *Py_UNUSED(ignored))\n" +"Custom_name(PyObject *op, PyObject *Py_UNUSED(dummy))\n" "{\n" +" CustomObject *self = (CustomObject *) op;\n" " if (self->first == NULL) {\n" " PyErr_SetString(PyExc_AttributeError, \"first\");\n" " return NULL;\n" @@ -1034,17 +1086,17 @@ msgstr "" " return PyUnicode_FromFormat(\"%S %S\", self->first, self->last);\n" "}" -#: ../../extending/newtypes_tutorial.rst:469 +#: ../../extending/newtypes_tutorial.rst:492 msgid "" -"The method is implemented as a C function that takes a :class:`!Custom` (or :" -"class:`!Custom` subclass) instance as the first argument. Methods always " -"take an instance as the first argument. Methods often take positional and " -"keyword arguments as well, but in this case we don't take any and don't need " -"to accept a positional argument tuple or keyword argument dictionary. This " -"method is equivalent to the Python method:" +"The method is implemented as a C function that takes a :class:`!Custom` " +"(or :class:`!Custom` subclass) instance as the first argument. Methods " +"always take an instance as the first argument. Methods often take positional " +"and keyword arguments as well, but in this case we don't take any and don't " +"need to accept a positional argument tuple or keyword argument dictionary. " +"This method is equivalent to the Python method:" msgstr "" -#: ../../extending/newtypes_tutorial.rst:476 +#: ../../extending/newtypes_tutorial.rst:499 msgid "" "def name(self):\n" " return \"%s %s\" % (self.first, self.last)" @@ -1052,46 +1104,46 @@ msgstr "" "def name(self):\n" " return \"%s %s\" % (self.first, self.last)" -#: ../../extending/newtypes_tutorial.rst:481 +#: ../../extending/newtypes_tutorial.rst:504 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 deleted, in " -"which case they are set to ``NULL``. It would be better to prevent deletion " -"of these attributes and to restrict the attribute values to be strings. " -"We'll see how to do that in the next section." +"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 " +"deleted, in which case they are set to ``NULL``. It would be better to " +"prevent deletion of these attributes and to restrict the attribute values to " +"be strings. We'll see how to do that in the next section." msgstr "" -#: ../../extending/newtypes_tutorial.rst:487 +#: ../../extending/newtypes_tutorial.rst:510 msgid "" "Now that we've defined the method, we need to create an array of method " "definitions::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:490 +#: ../../extending/newtypes_tutorial.rst:513 msgid "" "static PyMethodDef Custom_methods[] = {\n" -" {\"name\", (PyCFunction) Custom_name, METH_NOARGS,\n" +" {\"name\", Custom_name, METH_NOARGS,\n" " \"Return the name, combining the first and last name\"\n" " },\n" " {NULL} /* Sentinel */\n" "};" msgstr "" -#: ../../extending/newtypes_tutorial.rst:497 +#: ../../extending/newtypes_tutorial.rst:520 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:500 +#: ../../extending/newtypes_tutorial.rst:523 msgid "and assign it to the :c:member:`~PyTypeObject.tp_methods` slot::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:502 +#: ../../extending/newtypes_tutorial.rst:525 msgid ".tp_methods = Custom_methods," msgstr ".tp_methods = Custom_methods," -#: ../../extending/newtypes_tutorial.rst:504 +#: ../../extending/newtypes_tutorial.rst:527 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 " @@ -1099,22 +1151,22 @@ msgid "" "to add the :c:macro:`Py_TPFLAGS_BASETYPE` to our class flag definition::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:509 +#: ../../extending/newtypes_tutorial.rst:532 msgid ".tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE," msgstr ".tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE," -#: ../../extending/newtypes_tutorial.rst:511 +#: ../../extending/newtypes_tutorial.rst:534 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:515 +#: ../../extending/newtypes_tutorial.rst:538 msgid "Finally, we update our :file:`setup.py` file to include the new module," msgstr "" -#: ../../extending/newtypes_tutorial.rst:517 +#: ../../extending/newtypes_tutorial.rst:540 msgid "" "from setuptools import Extension, setup\n" "setup(ext_modules=[\n" @@ -1128,24 +1180,24 @@ msgstr "" " Extension(\"custom2\", [\"custom2.c\"]),\n" "])" -#: ../../extending/newtypes_tutorial.rst:525 +#: ../../extending/newtypes_tutorial.rst:548 msgid "and then we re-install so that we can ``import custom2``:" msgstr "" -#: ../../extending/newtypes_tutorial.rst:532 +#: ../../extending/newtypes_tutorial.rst:555 msgid "Providing finer control over data attributes" msgstr "" -#: ../../extending/newtypes_tutorial.rst:534 +#: ../../extending/newtypes_tutorial.rst:557 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 " -"previous version of our module, the instance variables :attr:`!first` and :" -"attr:`!last` could be set to non-string values or even deleted. We want to " -"make sure that these attributes always contain strings." +"previous version of our module, the instance variables :attr:`!first` " +"and :attr:`!last` could be set to non-string values or even deleted. We want " +"to make sure that these attributes always contain strings." msgstr "" -#: ../../extending/newtypes_tutorial.rst:540 +#: ../../extending/newtypes_tutorial.rst:563 msgid "" "#define PY_SSIZE_T_CLEAN\n" "#include \n" @@ -1159,11 +1211,12 @@ msgid "" "} CustomObject;\n" "\n" "static void\n" -"Custom_dealloc(CustomObject *self)\n" +"Custom_dealloc(PyObject *op)\n" "{\n" +" CustomObject *self = (CustomObject *) op;\n" " Py_XDECREF(self->first);\n" " Py_XDECREF(self->last);\n" -" Py_TYPE(self)->tp_free((PyObject *) self);\n" +" Py_TYPE(self)->tp_free(self);\n" "}\n" "\n" "static PyObject *\n" @@ -1172,12 +1225,12 @@ msgid "" " CustomObject *self;\n" " self = (CustomObject *) type->tp_alloc(type, 0);\n" " if (self != NULL) {\n" -" self->first = PyUnicode_FromString(\"\");\n" +" self->first = Py_GetConstant(Py_CONSTANT_EMPTY_STR);\n" " if (self->first == NULL) {\n" " Py_DECREF(self);\n" " return NULL;\n" " }\n" -" self->last = PyUnicode_FromString(\"\");\n" +" self->last = Py_GetConstant(Py_CONSTANT_EMPTY_STR);\n" " if (self->last == NULL) {\n" " Py_DECREF(self);\n" " return NULL;\n" @@ -1188,8 +1241,9 @@ msgid "" "}\n" "\n" "static int\n" -"Custom_init(CustomObject *self, PyObject *args, PyObject *kwds)\n" +"Custom_init(PyObject *op, PyObject *args, PyObject *kwds)\n" "{\n" +" CustomObject *self = (CustomObject *) op;\n" " static char *kwlist[] = {\"first\", \"last\", \"number\", NULL};\n" " PyObject *first = NULL, *last = NULL;\n" "\n" @@ -1214,14 +1268,16 @@ msgid "" "};\n" "\n" "static PyObject *\n" -"Custom_getfirst(CustomObject *self, void *closure)\n" +"Custom_getfirst(PyObject *op, void *closure)\n" "{\n" +" CustomObject *self = (CustomObject *) op;\n" " return Py_NewRef(self->first);\n" "}\n" "\n" "static int\n" -"Custom_setfirst(CustomObject *self, PyObject *value, void *closure)\n" +"Custom_setfirst(PyObject *op, PyObject *value, void *closure)\n" "{\n" +" CustomObject *self = (CustomObject *) op;\n" " if (value == NULL) {\n" " PyErr_SetString(PyExc_TypeError, \"Cannot delete the first " "attribute\");\n" @@ -1237,14 +1293,16 @@ msgid "" "}\n" "\n" "static PyObject *\n" -"Custom_getlast(CustomObject *self, void *closure)\n" +"Custom_getlast(PyObject *op, void *closure)\n" "{\n" +" CustomObject *self = (CustomObject *) op;\n" " return Py_NewRef(self->last);\n" "}\n" "\n" "static int\n" -"Custom_setlast(CustomObject *self, PyObject *value, void *closure)\n" +"Custom_setlast(PyObject *op, PyObject *value, void *closure)\n" "{\n" +" CustomObject *self = (CustomObject *) op;\n" " if (value == NULL) {\n" " PyErr_SetString(PyExc_TypeError, \"Cannot delete the last " "attribute\");\n" @@ -1260,21 +1318,22 @@ msgid "" "}\n" "\n" "static PyGetSetDef Custom_getsetters[] = {\n" -" {\"first\", (getter) Custom_getfirst, (setter) Custom_setfirst,\n" +" {\"first\", Custom_getfirst, Custom_setfirst,\n" " \"first name\", NULL},\n" -" {\"last\", (getter) Custom_getlast, (setter) Custom_setlast,\n" +" {\"last\", Custom_getlast, Custom_setlast,\n" " \"last name\", NULL},\n" " {NULL} /* Sentinel */\n" "};\n" "\n" "static PyObject *\n" -"Custom_name(CustomObject *self, PyObject *Py_UNUSED(ignored))\n" +"Custom_name(PyObject *op, PyObject *Py_UNUSED(dummy))\n" "{\n" +" CustomObject *self = (CustomObject *) op;\n" " return PyUnicode_FromFormat(\"%S %S\", self->first, self->last);\n" "}\n" "\n" "static PyMethodDef Custom_methods[] = {\n" -" {\"name\", (PyCFunction) Custom_name, METH_NOARGS,\n" +" {\"name\", Custom_name, METH_NOARGS,\n" " \"Return the name, combining the first and last name\"\n" " },\n" " {NULL} /* Sentinel */\n" @@ -1288,8 +1347,8 @@ msgid "" " .tp_itemsize = 0,\n" " .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,\n" " .tp_new = Custom_new,\n" -" .tp_init = (initproc) Custom_init,\n" -" .tp_dealloc = (destructor) Custom_dealloc,\n" +" .tp_init = Custom_init,\n" +" .tp_dealloc = Custom_dealloc,\n" " .tp_members = Custom_members,\n" " .tp_methods = Custom_methods,\n" " .tp_getset = Custom_getsetters,\n" @@ -1332,25 +1391,27 @@ msgid "" "}\n" msgstr "" -#: ../../extending/newtypes_tutorial.rst:543 +#: ../../extending/newtypes_tutorial.rst:566 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:547 +#: ../../extending/newtypes_tutorial.rst:570 msgid "" "static PyObject *\n" -"Custom_getfirst(CustomObject *self, void *closure)\n" +"Custom_getfirst(PyObject *op, void *closure)\n" "{\n" +" CustomObject *self = (CustomObject *) op;\n" " Py_INCREF(self->first);\n" " return self->first;\n" "}\n" "\n" "static int\n" -"Custom_setfirst(CustomObject *self, PyObject *value, void *closure)\n" +"Custom_setfirst(PyObject *op, PyObject *value, void *closure)\n" "{\n" +" CustomObject *self = (CustomObject *) op;\n" " PyObject *tmp;\n" " if (value == NULL) {\n" " PyErr_SetString(PyExc_TypeError, \"Cannot delete the first " @@ -1370,7 +1431,7 @@ msgid "" "}" msgstr "" -#: ../../extending/newtypes_tutorial.rst:574 +#: ../../extending/newtypes_tutorial.rst:599 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 " @@ -1380,7 +1441,7 @@ msgid "" "data in the closure.)" msgstr "" -#: ../../extending/newtypes_tutorial.rst:580 +#: ../../extending/newtypes_tutorial.rst:605 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 " @@ -1388,41 +1449,41 @@ msgid "" "deleted or if its new value is not a string." msgstr "" -#: ../../extending/newtypes_tutorial.rst:585 +#: ../../extending/newtypes_tutorial.rst:610 msgid "We create an array of :c:type:`PyGetSetDef` structures::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:587 +#: ../../extending/newtypes_tutorial.rst:612 msgid "" "static PyGetSetDef Custom_getsetters[] = {\n" -" {\"first\", (getter) Custom_getfirst, (setter) Custom_setfirst,\n" +" {\"first\", Custom_getfirst, Custom_setfirst,\n" " \"first name\", NULL},\n" -" {\"last\", (getter) Custom_getlast, (setter) Custom_setlast,\n" +" {\"last\", Custom_getlast, Custom_setlast,\n" " \"last name\", NULL},\n" " {NULL} /* Sentinel */\n" "};" msgstr "" -#: ../../extending/newtypes_tutorial.rst:595 +#: ../../extending/newtypes_tutorial.rst:620 msgid "and register it in the :c:member:`~PyTypeObject.tp_getset` slot::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:597 +#: ../../extending/newtypes_tutorial.rst:622 msgid ".tp_getset = Custom_getsetters," msgstr ".tp_getset = Custom_getsetters," -#: ../../extending/newtypes_tutorial.rst:599 +#: ../../extending/newtypes_tutorial.rst:624 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:602 +#: ../../extending/newtypes_tutorial.rst:627 msgid "We also remove the member definitions for these attributes::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:604 +#: ../../extending/newtypes_tutorial.rst:629 msgid "" "static PyMemberDef Custom_members[] = {\n" " {\"number\", Py_T_INT, offsetof(CustomObject, number), 0,\n" @@ -1431,17 +1492,18 @@ msgid "" "};" msgstr "" -#: ../../extending/newtypes_tutorial.rst:610 +#: ../../extending/newtypes_tutorial.rst:635 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:613 +#: ../../extending/newtypes_tutorial.rst:638 msgid "" "static int\n" -"Custom_init(CustomObject *self, PyObject *args, PyObject *kwds)\n" +"Custom_init(PyObject *op, PyObject *args, PyObject *kwds)\n" "{\n" +" CustomObject *self = (CustomObject *) op;\n" " static char *kwlist[] = {\"first\", \"last\", \"number\", NULL};\n" " PyObject *first = NULL, *last = NULL, *tmp;\n" "\n" @@ -1465,8 +1527,34 @@ msgid "" " return 0;\n" "}" msgstr "" +"static int\n" +"Custom_init(PyObject *op, PyObject *args, PyObject *kwds)\n" +"{\n" +" CustomObject *self = (CustomObject *) op;\n" +" static char *kwlist[] = {\"first\", \"last\", \"number\", NULL};\n" +" PyObject *first = NULL, *last = NULL, *tmp;\n" +"\n" +" if (!PyArg_ParseTupleAndKeywords(args, kwds, \"|UUi\", kwlist,\n" +" &first, &last,\n" +" &self->number))\n" +" return -1;\n" +"\n" +" if (first) {\n" +" tmp = self->first;\n" +" Py_INCREF(first);\n" +" self->first = first;\n" +" Py_DECREF(tmp);\n" +" }\n" +" if (last) {\n" +" tmp = self->last;\n" +" Py_INCREF(last);\n" +" self->last = last;\n" +" Py_DECREF(tmp);\n" +" }\n" +" return 0;\n" +"}" -#: ../../extending/newtypes_tutorial.rst:639 +#: ../../extending/newtypes_tutorial.rst:665 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 " @@ -1476,25 +1564,25 @@ msgid "" "possibility that the initialization of these members failed in ``tp_new``." msgstr "" -#: ../../extending/newtypes_tutorial.rst:646 +#: ../../extending/newtypes_tutorial.rst:672 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:652 +#: ../../extending/newtypes_tutorial.rst:678 msgid "Supporting cyclic garbage collection" msgstr "" -#: ../../extending/newtypes_tutorial.rst:654 +#: ../../extending/newtypes_tutorial.rst:680 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:658 +#: ../../extending/newtypes_tutorial.rst:684 msgid "" ">>> l = []\n" ">>> l.append(l)\n" @@ -1504,7 +1592,7 @@ msgstr "" ">>> l.append(l)\n" ">>> del l" -#: ../../extending/newtypes_tutorial.rst:664 +#: ../../extending/newtypes_tutorial.rst:690 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 " @@ -1512,16 +1600,17 @@ msgid "" "out that the list is garbage and free it." msgstr "" -#: ../../extending/newtypes_tutorial.rst:669 +#: ../../extending/newtypes_tutorial.rst:695 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 " -"[#]_. Besides, in the second and third versions, we allowed subclassing :" -"class:`!Custom`, and subclasses may add arbitrary attributes. For any of " -"those two reasons, :class:`!Custom` objects can participate in cycles:" +"[#]_. Besides, in the second and third versions, we allowed " +"subclassing :class:`!Custom`, and subclasses may add arbitrary attributes. " +"For any of those two reasons, :class:`!Custom` objects can participate in " +"cycles:" msgstr "" -#: ../../extending/newtypes_tutorial.rst:675 +#: ../../extending/newtypes_tutorial.rst:701 msgid "" ">>> import custom3\n" ">>> class Derived(custom3.Custom): pass\n" @@ -1535,7 +1624,7 @@ msgstr "" ">>> n = Derived()\n" ">>> n.some_attribute = n" -#: ../../extending/newtypes_tutorial.rst:683 +#: ../../extending/newtypes_tutorial.rst:709 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` " @@ -1543,7 +1632,7 @@ msgid "" "these slots:" msgstr "" -#: ../../extending/newtypes_tutorial.rst:687 +#: ../../extending/newtypes_tutorial.rst:713 msgid "" "#define PY_SSIZE_T_CLEAN\n" "#include \n" @@ -1557,27 +1646,29 @@ msgid "" "} CustomObject;\n" "\n" "static int\n" -"Custom_traverse(CustomObject *self, visitproc visit, void *arg)\n" +"Custom_traverse(PyObject *op, visitproc visit, void *arg)\n" "{\n" +" CustomObject *self = (CustomObject *) op;\n" " Py_VISIT(self->first);\n" " Py_VISIT(self->last);\n" " return 0;\n" "}\n" "\n" "static int\n" -"Custom_clear(CustomObject *self)\n" +"Custom_clear(PyObject *op)\n" "{\n" +" CustomObject *self = (CustomObject *) op;\n" " Py_CLEAR(self->first);\n" " Py_CLEAR(self->last);\n" " return 0;\n" "}\n" "\n" "static void\n" -"Custom_dealloc(CustomObject *self)\n" +"Custom_dealloc(PyObject *op)\n" "{\n" -" PyObject_GC_UnTrack(self);\n" -" Custom_clear(self);\n" -" Py_TYPE(self)->tp_free((PyObject *) self);\n" +" PyObject_GC_UnTrack(op);\n" +" (void)Custom_clear(op);\n" +" Py_TYPE(op)->tp_free(op);\n" "}\n" "\n" "static PyObject *\n" @@ -1586,12 +1677,12 @@ msgid "" " CustomObject *self;\n" " self = (CustomObject *) type->tp_alloc(type, 0);\n" " if (self != NULL) {\n" -" self->first = PyUnicode_FromString(\"\");\n" +" self->first = Py_GetConstant(Py_CONSTANT_EMPTY_STR);\n" " if (self->first == NULL) {\n" " Py_DECREF(self);\n" " return NULL;\n" " }\n" -" self->last = PyUnicode_FromString(\"\");\n" +" self->last = Py_GetConstant(Py_CONSTANT_EMPTY_STR);\n" " if (self->last == NULL) {\n" " Py_DECREF(self);\n" " return NULL;\n" @@ -1602,8 +1693,9 @@ msgid "" "}\n" "\n" "static int\n" -"Custom_init(CustomObject *self, PyObject *args, PyObject *kwds)\n" +"Custom_init(PyObject *op, PyObject *args, PyObject *kwds)\n" "{\n" +" CustomObject *self = (CustomObject *) op;\n" " static char *kwlist[] = {\"first\", \"last\", \"number\", NULL};\n" " PyObject *first = NULL, *last = NULL;\n" "\n" @@ -1628,14 +1720,16 @@ msgid "" "};\n" "\n" "static PyObject *\n" -"Custom_getfirst(CustomObject *self, void *closure)\n" +"Custom_getfirst(PyObject *op, void *closure)\n" "{\n" +" CustomObject *self = (CustomObject *) op;\n" " return Py_NewRef(self->first);\n" "}\n" "\n" "static int\n" -"Custom_setfirst(CustomObject *self, PyObject *value, void *closure)\n" +"Custom_setfirst(PyObject *op, PyObject *value, void *closure)\n" "{\n" +" CustomObject *self = (CustomObject *) op;\n" " if (value == NULL) {\n" " PyErr_SetString(PyExc_TypeError, \"Cannot delete the first " "attribute\");\n" @@ -1651,14 +1745,16 @@ msgid "" "}\n" "\n" "static PyObject *\n" -"Custom_getlast(CustomObject *self, void *closure)\n" +"Custom_getlast(PyObject *op, void *closure)\n" "{\n" +" CustomObject *self = (CustomObject *) op;\n" " return Py_NewRef(self->last);\n" "}\n" "\n" "static int\n" -"Custom_setlast(CustomObject *self, PyObject *value, void *closure)\n" +"Custom_setlast(PyObject *op, PyObject *value, void *closure)\n" "{\n" +" CustomObject *self = (CustomObject *) op;\n" " if (value == NULL) {\n" " PyErr_SetString(PyExc_TypeError, \"Cannot delete the last " "attribute\");\n" @@ -1674,21 +1770,22 @@ msgid "" "}\n" "\n" "static PyGetSetDef Custom_getsetters[] = {\n" -" {\"first\", (getter) Custom_getfirst, (setter) Custom_setfirst,\n" +" {\"first\", Custom_getfirst, Custom_setfirst,\n" " \"first name\", NULL},\n" -" {\"last\", (getter) Custom_getlast, (setter) Custom_setlast,\n" +" {\"last\", Custom_getlast, Custom_setlast,\n" " \"last name\", NULL},\n" " {NULL} /* Sentinel */\n" "};\n" "\n" "static PyObject *\n" -"Custom_name(CustomObject *self, PyObject *Py_UNUSED(ignored))\n" +"Custom_name(PyObject *op, PyObject *Py_UNUSED(dummy))\n" "{\n" +" CustomObject *self = (CustomObject *) op;\n" " return PyUnicode_FromFormat(\"%S %S\", self->first, self->last);\n" "}\n" "\n" "static PyMethodDef Custom_methods[] = {\n" -" {\"name\", (PyCFunction) Custom_name, METH_NOARGS,\n" +" {\"name\", Custom_name, METH_NOARGS,\n" " \"Return the name, combining the first and last name\"\n" " },\n" " {NULL} /* Sentinel */\n" @@ -1703,10 +1800,10 @@ msgid "" " .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | " "Py_TPFLAGS_HAVE_GC,\n" " .tp_new = Custom_new,\n" -" .tp_init = (initproc) Custom_init,\n" -" .tp_dealloc = (destructor) Custom_dealloc,\n" -" .tp_traverse = (traverseproc) Custom_traverse,\n" -" .tp_clear = (inquiry) Custom_clear,\n" +" .tp_init = Custom_init,\n" +" .tp_dealloc = Custom_dealloc,\n" +" .tp_traverse = Custom_traverse,\n" +" .tp_clear = Custom_clear,\n" " .tp_members = Custom_members,\n" " .tp_methods = Custom_methods,\n" " .tp_getset = Custom_getsetters,\n" @@ -1749,17 +1846,18 @@ msgid "" "}\n" msgstr "" -#: ../../extending/newtypes_tutorial.rst:690 +#: ../../extending/newtypes_tutorial.rst:716 msgid "" "First, the traversal method lets the cyclic GC know about subobjects that " "could participate in cycles::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:693 +#: ../../extending/newtypes_tutorial.rst:719 msgid "" "static int\n" -"Custom_traverse(CustomObject *self, visitproc visit, void *arg)\n" +"Custom_traverse(PyObject *op, visitproc visit, void *arg)\n" "{\n" +" CustomObject *self = (CustomObject *) op;\n" " int vret;\n" " if (self->first) {\n" " vret = visit(self->first, arg);\n" @@ -1775,8 +1873,9 @@ msgid "" "}" msgstr "" "static int\n" -"Custom_traverse(CustomObject *self, visitproc visit, void *arg)\n" +"Custom_traverse(PyObject *op, visitproc visit, void *arg)\n" "{\n" +" CustomObject *self = (CustomObject *) op;\n" " int vret;\n" " if (self->first) {\n" " vret = visit(self->first, arg);\n" @@ -1791,71 +1890,75 @@ msgstr "" " return 0;\n" "}" -#: ../../extending/newtypes_tutorial.rst:710 +#: ../../extending/newtypes_tutorial.rst:737 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. The :c:func:" -"`!visit` function takes as arguments the subobject and the extra argument " -"*arg* passed to the traversal method. It returns an integer value that must " -"be returned if it is non-zero." +"For each subobject that can participate in cycles, we need to call " +"the :c:func:`!visit` function, which is passed to the traversal method. " +"The :c:func:`!visit` function takes as arguments the subobject and the extra " +"argument *arg* passed to the traversal method. It returns an integer value " +"that must be returned if it is non-zero." msgstr "" -#: ../../extending/newtypes_tutorial.rst:716 +#: ../../extending/newtypes_tutorial.rst:743 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:720 +#: ../../extending/newtypes_tutorial.rst:747 msgid "" "static int\n" -"Custom_traverse(CustomObject *self, visitproc visit, void *arg)\n" +"Custom_traverse(PyObject *op, visitproc visit, void *arg)\n" "{\n" +" CustomObject *self = (CustomObject *) op;\n" " Py_VISIT(self->first);\n" " Py_VISIT(self->last);\n" " return 0;\n" "}" msgstr "" "static int\n" -"Custom_traverse(CustomObject *self, visitproc visit, void *arg)\n" +"Custom_traverse(PyObject *op, visitproc visit, void *arg)\n" "{\n" +" CustomObject *self = (CustomObject *) op;\n" " Py_VISIT(self->first);\n" " Py_VISIT(self->last);\n" " return 0;\n" "}" -#: ../../extending/newtypes_tutorial.rst:729 +#: ../../extending/newtypes_tutorial.rst:757 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:732 +#: ../../extending/newtypes_tutorial.rst:760 msgid "" "Second, we need to provide a method for clearing any subobjects that can " "participate in cycles::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:735 +#: ../../extending/newtypes_tutorial.rst:763 msgid "" "static int\n" -"Custom_clear(CustomObject *self)\n" +"Custom_clear(PyObject *op)\n" "{\n" +" CustomObject *self = (CustomObject *) op;\n" " Py_CLEAR(self->first);\n" " Py_CLEAR(self->last);\n" " return 0;\n" "}" msgstr "" "static int\n" -"Custom_clear(CustomObject *self)\n" +"Custom_clear(PyObject *op)\n" "{\n" +" CustomObject *self = (CustomObject *) op;\n" " Py_CLEAR(self->first);\n" " Py_CLEAR(self->last);\n" " return 0;\n" "}" -#: ../../extending/newtypes_tutorial.rst:743 +#: ../../extending/newtypes_tutorial.rst:772 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 " @@ -1865,11 +1968,11 @@ msgid "" "again (*especially* if there is a reference cycle)." msgstr "" -#: ../../extending/newtypes_tutorial.rst:751 +#: ../../extending/newtypes_tutorial.rst:780 msgid "You could emulate :c:func:`Py_CLEAR` by writing::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:753 +#: ../../extending/newtypes_tutorial.rst:782 msgid "" "PyObject *tmp;\n" "tmp = self->first;\n" @@ -1881,65 +1984,66 @@ msgstr "" "self->first = NULL;\n" "Py_XDECREF(tmp);" -#: ../../extending/newtypes_tutorial.rst:758 +#: ../../extending/newtypes_tutorial.rst:787 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!" +"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:762 +#: ../../extending/newtypes_tutorial.rst:791 msgid "" "The deallocator ``Custom_dealloc`` may call arbitrary code when clearing " "attributes. It means the circular GC can be triggered inside the function. " "Since the GC assumes reference count is not zero, we need to untrack the " "object from the GC by calling :c:func:`PyObject_GC_UnTrack` before clearing " -"members. Here is our reimplemented deallocator using :c:func:" -"`PyObject_GC_UnTrack` and ``Custom_clear``::" +"members. Here is our reimplemented deallocator " +"using :c:func:`PyObject_GC_UnTrack` and ``Custom_clear``::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:769 +#: ../../extending/newtypes_tutorial.rst:798 msgid "" "static void\n" -"Custom_dealloc(CustomObject *self)\n" +"Custom_dealloc(PyObject *op)\n" "{\n" -" PyObject_GC_UnTrack(self);\n" -" Custom_clear(self);\n" -" Py_TYPE(self)->tp_free((PyObject *) self);\n" +" PyObject_GC_UnTrack(op);\n" +" (void)Custom_clear(op);\n" +" Py_TYPE(op)->tp_free(op);\n" "}" msgstr "" "static void\n" -"Custom_dealloc(CustomObject *self)\n" +"Custom_dealloc(PyObject *op)\n" "{\n" -" PyObject_GC_UnTrack(self);\n" -" Custom_clear(self);\n" -" Py_TYPE(self)->tp_free((PyObject *) self);\n" +" PyObject_GC_UnTrack(op);\n" +" (void)Custom_clear(op);\n" +" Py_TYPE(op)->tp_free(op);\n" "}" -#: ../../extending/newtypes_tutorial.rst:777 +#: ../../extending/newtypes_tutorial.rst:806 msgid "" "Finally, we add the :c:macro:`Py_TPFLAGS_HAVE_GC` flag to the class flags::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:779 +#: ../../extending/newtypes_tutorial.rst:808 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:781 +#: ../../extending/newtypes_tutorial.rst:810 msgid "" -"That's pretty much it. If we had written custom :c:member:`~PyTypeObject." -"tp_alloc` or :c:member:`~PyTypeObject.tp_free` handlers, we'd need to modify " -"them for cyclic garbage collection. Most extensions will use the versions " +"That's pretty much it. If we had written " +"custom :c:member:`~PyTypeObject.tp_alloc` " +"or :c:member:`~PyTypeObject.tp_free` handlers, we'd need to modify them for " +"cyclic garbage collection. Most extensions will use the versions " "automatically provided." msgstr "" -#: ../../extending/newtypes_tutorial.rst:787 +#: ../../extending/newtypes_tutorial.rst:816 msgid "Subclassing other types" msgstr "" -#: ../../extending/newtypes_tutorial.rst:789 +#: ../../extending/newtypes_tutorial.rst:818 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 " @@ -1947,7 +2051,7 @@ msgid "" "share these :c:type:`PyTypeObject` structures between extension modules." msgstr "" -#: ../../extending/newtypes_tutorial.rst:794 +#: ../../extending/newtypes_tutorial.rst:823 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 " @@ -1955,7 +2059,7 @@ msgid "" "that increases an internal counter:" msgstr "" -#: ../../extending/newtypes_tutorial.rst:799 +#: ../../extending/newtypes_tutorial.rst:828 msgid "" ">>> import sublist\n" ">>> s = sublist.SubList(range(3))\n" @@ -1977,7 +2081,7 @@ msgstr "" ">>> print(s.increment())\n" "2" -#: ../../extending/newtypes_tutorial.rst:811 +#: ../../extending/newtypes_tutorial.rst:840 msgid "" "#define PY_SSIZE_T_CLEAN\n" "#include \n" @@ -1988,22 +2092,24 @@ msgid "" "} SubListObject;\n" "\n" "static PyObject *\n" -"SubList_increment(SubListObject *self, PyObject *unused)\n" +"SubList_increment(PyObject *op, PyObject *Py_UNUSED(dummy))\n" "{\n" +" SubListObject *self = (SubListObject *) op;\n" " self->state++;\n" " return PyLong_FromLong(self->state);\n" "}\n" "\n" "static PyMethodDef SubList_methods[] = {\n" -" {\"increment\", (PyCFunction) SubList_increment, METH_NOARGS,\n" +" {\"increment\", SubList_increment, METH_NOARGS,\n" " PyDoc_STR(\"increment state counter\")},\n" " {NULL},\n" "};\n" "\n" "static int\n" -"SubList_init(SubListObject *self, PyObject *args, PyObject *kwds)\n" +"SubList_init(PyObject *op, PyObject *args, PyObject *kwds)\n" "{\n" -" if (PyList_Type.tp_init((PyObject *) self, args, kwds) < 0)\n" +" SubListObject *self = (SubListObject *) op;\n" +" if (PyList_Type.tp_init(op, args, kwds) < 0)\n" " return -1;\n" " self->state = 0;\n" " return 0;\n" @@ -2016,7 +2122,7 @@ msgid "" " .tp_basicsize = sizeof(SubListObject),\n" " .tp_itemsize = 0,\n" " .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,\n" -" .tp_init = (initproc) SubList_init,\n" +" .tp_init = SubList_init,\n" " .tp_methods = SubList_methods,\n" "};\n" "\n" @@ -2058,14 +2164,14 @@ msgid "" "}\n" msgstr "" -#: ../../extending/newtypes_tutorial.rst:814 +#: ../../extending/newtypes_tutorial.rst:843 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:817 +#: ../../extending/newtypes_tutorial.rst:846 msgid "" "typedef struct {\n" " PyListObject list;\n" @@ -2077,64 +2183,68 @@ msgstr "" " int state;\n" "} SubListObject;" -#: ../../extending/newtypes_tutorial.rst:822 +#: ../../extending/newtypes_tutorial.rst:851 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:826 +#: ../../extending/newtypes_tutorial.rst:855 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:829 +#: ../../extending/newtypes_tutorial.rst:858 msgid "" "static int\n" -"SubList_init(SubListObject *self, PyObject *args, PyObject *kwds)\n" +"SubList_init(PyObject *op, PyObject *args, PyObject *kwds)\n" "{\n" -" if (PyList_Type.tp_init((PyObject *) self, args, kwds) < 0)\n" +" SubListObject *self = (SubListObject *) op;\n" +" if (PyList_Type.tp_init(op, args, kwds) < 0)\n" " return -1;\n" " self->state = 0;\n" " return 0;\n" "}" msgstr "" "static int\n" -"SubList_init(SubListObject *self, PyObject *args, PyObject *kwds)\n" +"SubList_init(PyObject *op, PyObject *args, PyObject *kwds)\n" "{\n" -" if (PyList_Type.tp_init((PyObject *) self, args, kwds) < 0)\n" +" SubListObject *self = (SubListObject *) op;\n" +" if (PyList_Type.tp_init(op, args, kwds) < 0)\n" " return -1;\n" " self->state = 0;\n" " return 0;\n" "}" -#: ../../extending/newtypes_tutorial.rst:838 +#: ../../extending/newtypes_tutorial.rst:868 msgid "" "We see above how to call through to the :meth:`~object.__init__` method of " "the base type." msgstr "" -#: ../../extending/newtypes_tutorial.rst:841 +#: ../../extending/newtypes_tutorial.rst:871 msgid "" -"This pattern is important when writing a type with custom :c:member:" -"`~PyTypeObject.tp_new` and :c:member:`~PyTypeObject.tp_dealloc` members. " +"This pattern is important when writing a type with " +"custom :c:member:`~PyTypeObject.tp_new` " +"and :c:member:`~PyTypeObject.tp_dealloc` members. " "The :c:member:`~PyTypeObject.tp_new` handler should not actually create the " "memory for the object with its :c:member:`~PyTypeObject.tp_alloc`, but let " "the base class handle it by calling its own :c:member:`~PyTypeObject.tp_new`." msgstr "" -#: ../../extending/newtypes_tutorial.rst:847 +#: ../../extending/newtypes_tutorial.rst:877 msgid "" -"The :c:type:`PyTypeObject` struct supports a :c:member:`~PyTypeObject." -"tp_base` specifying the type's concrete base class. Due to cross-platform " -"compiler issues, you can't fill that field directly with a reference to :c:" -"type:`PyList_Type`; it should be done in the :c:data:`Py_mod_exec` function::" +"The :c:type:`PyTypeObject` struct supports " +"a :c:member:`~PyTypeObject.tp_base` specifying the type's concrete base " +"class. Due to cross-platform compiler issues, you can't fill that field " +"directly with a reference to :c:type:`PyList_Type`; it should be done in " +"the :c:data:`Py_mod_exec` function::" msgstr "" -#: ../../extending/newtypes_tutorial.rst:853 +#: ../../extending/newtypes_tutorial.rst:883 msgid "" "static int\n" "sublist_module_exec(PyObject *m)\n" @@ -2168,38 +2278,38 @@ msgstr "" " return 0;\n" "}" -#: ../../extending/newtypes_tutorial.rst:868 +#: ../../extending/newtypes_tutorial.rst:898 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 an " -"existing type, it is not necessary to fill out the :c:member:`~PyTypeObject." -"tp_alloc` slot with :c:func:`PyType_GenericNew` -- the allocation function " -"from the base type will be inherited." +"Before calling :c:func:`PyType_Ready`, the type structure must have " +"the :c:member:`~PyTypeObject.tp_base` slot filled in. When we are deriving " +"an existing type, it is not necessary to fill out " +"the :c:member:`~PyTypeObject.tp_alloc` slot with :c:func:`PyType_GenericNew` " +"-- the allocation function from the base type will be inherited." msgstr "" -#: ../../extending/newtypes_tutorial.rst:874 +#: ../../extending/newtypes_tutorial.rst:904 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:879 +#: ../../extending/newtypes_tutorial.rst:909 msgid "Footnotes" msgstr "註腳" -#: ../../extending/newtypes_tutorial.rst:880 +#: ../../extending/newtypes_tutorial.rst:910 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:883 +#: ../../extending/newtypes_tutorial.rst:913 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:886 +#: ../../extending/newtypes_tutorial.rst:916 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 " @@ -2209,7 +2319,7 @@ msgid "" "objects." msgstr "" -#: ../../extending/newtypes_tutorial.rst:892 +#: ../../extending/newtypes_tutorial.rst:922 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 a85d0b62fa3..39a4c461b15 100644 --- a/extending/windows.po +++ b/extending/windows.po @@ -1,13 +1,12 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"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: 2025-09-08 15:25+0800\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-" @@ -110,15 +109,15 @@ msgstr "" #: ../../extending/windows.rst:76 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 Unix :file:`." -"a` file; it contains code to be included as necessary. An import library is " -"basically used only to reassure the linker that a certain identifier is " -"legal, and will be present in the program when the DLL is loaded. So the " -"linker uses the information from the import library to build the lookup " -"table for using identifiers that are not included in the DLL. When an " -"application or a DLL is linked, an import library may be generated, which " -"will need to be used for all future DLLs that depend on the symbols in the " -"application or DLL." +"library (both called :file:`.lib`). A static library is like a " +"Unix :file:`.a` file; it contains code to be included as necessary. An " +"import library is basically used only to reassure the linker that a certain " +"identifier is legal, and will be present in the program when the DLL is " +"loaded. So the linker uses the information from the import library to build " +"the lookup table for using identifiers that are not included in the DLL. " +"When an application or a DLL is linked, an import library may be generated, " +"which will need to be used for all future DLLs that depend on the symbols in " +"the application or DLL." msgstr "" #: ../../extending/windows.rst:86 @@ -127,9 +126,10 @@ msgid "" "share another block of code A. On Unix, you would *not* pass :file:`A.a` to " "the linker for :file:`B.so` and :file:`C.so`; that would cause it to be " "included twice, so that B and C would each have their own copy. In Windows, " -"building :file:`A.dll` will also build :file:`A.lib`. You *do* pass :file:" -"`A.lib` to the linker for B and C. :file:`A.lib` does not contain code; it " -"just contains information which will be used at runtime to access A's code." +"building :file:`A.dll` will also build :file:`A.lib`. You *do* " +"pass :file:`A.lib` to the linker for B and C. :file:`A.lib` does not " +"contain code; it just contains information which will be used at runtime to " +"access A's code." msgstr "" #: ../../extending/windows.rst:94 @@ -140,47 +140,88 @@ msgid "" "create a separate copy." msgstr "" -#: ../../extending/windows.rst:103 +#: ../../extending/windows.rst:101 +msgid "" +"Turn off the implicit, ``#pragma``-based linkage with the Python library, " +"performed inside CPython header files." +msgstr "" + +#: ../../extending/windows.rst:110 msgid "Using DLLs in Practice" msgstr "" -#: ../../extending/windows.rst:108 +#: ../../extending/windows.rst:115 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:111 +#: ../../extending/windows.rst:118 msgid "" -"When creating DLLs in Windows, you must pass :file:`pythonXY.lib` to the " -"linker. To build two DLLs, spam and ni (which uses C functions found in " -"spam), you could use these commands::" +"When creating DLLs in Windows, you can use the CPython library in two ways:" msgstr "" -#: ../../extending/windows.rst:115 +#: ../../extending/windows.rst:120 msgid "" -"cl /LD /I/python/include spam.c ../libs/pythonXY.lib\n" -"cl /LD /I/python/include ni.c spam.lib ../libs/pythonXY.lib" +"By default, inclusion of :file:`PC/pyconfig.h` directly or " +"via :file:`Python.h` triggers an implicit, configure-aware link with the " +"library. The header file chooses :file:`pythonXY_d.lib` for " +"Debug, :file:`pythonXY.lib` for Release, and :file:`pythonX.lib` for Release " +"with the :ref:`Limited API ` enabled." msgstr "" -"cl /LD /I/python/include spam.c ../libs/pythonXY.lib\n" -"cl /LD /I/python/include ni.c spam.lib ../libs/pythonXY.lib" -#: ../../extending/windows.rst:118 +#: ../../extending/windows.rst:126 ../../extending/windows.rst:144 +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 +msgid "" +"cl /LD /I/python/include spam.c\n" +"cl /LD /I/python/include ni.c spam.lib" +msgstr "" +"cl /LD /I/python/include spam.c\n" +"cl /LD /I/python/include ni.c spam.lib" + +#: ../../extending/windows.rst:132 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 " "functions (such as :c:func:`PyArg_ParseTuple`), but it does know how to find " -"the Python code thanks to :file:`pythonXY.lib`." +"the Python code thanks to the implicitly linked :file:`pythonXY.lib`." msgstr "" -#: ../../extending/windows.rst:123 +#: ../../extending/windows.rst:137 ../../extending/windows.rst:155 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." +"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:127 +#: ../../extending/windows.rst:141 +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 +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" +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 +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 " +"functions (such as :c:func:`PyArg_ParseTuple`), but it does know how to find " +"the Python code thanks to :file:`pythonXY.lib`." +msgstr "" + +#: ../../extending/windows.rst:159 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 " @@ -188,7 +229,7 @@ msgid "" "initspam(void)`` or ``PyObject _declspec(dllexport) *NiGetSpamData(void)``." msgstr "" -#: ../../extending/windows.rst:132 +#: ../../extending/windows.rst:164 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 caed4b8892a..6af58c68be3 100644 --- a/faq/design.po +++ b/faq/design.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -7,9 +7,9 @@ # Steven Hsu , 2023 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-24 07:20+0000\n" +"POT-Creation-Date: 2025-09-08 15:25+0800\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-" @@ -800,7 +800,7 @@ msgstr "" #: ../../faq/design.rst:406 msgid "Why are there separate tuple and list data types?" -msgstr "為何要把元組 (tuple) 和串列 (list) 分成兩個資料型態?" +msgstr "為何要把元組 (tuple) 和串列 (list) 分成兩個資料型別?" #: ../../faq/design.rst:408 msgid "" @@ -1176,16 +1176,16 @@ msgid "" "An appropriate testing discipline can help build large complex applications " "in Python as well as having interface specifications would. In fact, it can " "be better because an interface specification cannot test certain properties " -"of a program. For example, the :meth:`!list.append` method is expected to " +"of a program. For example, the :meth:`list.append` method is expected to " "add new elements to the end of some internal list; an interface " -"specification cannot test that your :meth:`!list.append` implementation will " +"specification cannot test that your :meth:`list.append` implementation will " "actually do this correctly, but it's trivial to check this property in a " "test suite." msgstr "" "就像介面規範一樣,一個適當的測試規則在建造大型又複雜的 Python 應用程式時可以" "幫上忙。事實上,他可能可以有更好的表現,因為介面規範無法測試程式的特定屬性。" -"舉例來說,:meth:`!list.append` 方法應該要在某個內部的串列最後面加上新的元素," -"而介面規範沒辦法測試你的 :meth:`!list.append` 是不是真的有正確的實作,但這在" +"舉例來說,:meth:`list.append` 方法應該要在某個內部的串列最後面加上新的元素," +"而介面規範沒辦法測試你的 :meth:`list.append` 是不是真的有正確的實作,但這在" "測試套件裡是件很簡單的事。" #: ../../faq/design.rst:597 diff --git a/faq/extending.po b/faq/extending.po index 1b0e3995d4e..8eef4ca9250 100644 --- a/faq/extending.po +++ b/faq/extending.po @@ -1,11 +1,10 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2023-02-18 13:08+0800\n" @@ -76,7 +75,6 @@ msgid "How can I execute arbitrary Python statements from C?" msgstr "如何從 C 執行任意 Python 陳述式?" #: ../../faq/extending.rst:48 -#, fuzzy msgid "" "The highest-level function to do this is :c:func:`PyRun_SimpleString` which " "takes a single string argument to be executed in the context of the module " @@ -85,53 +83,49 @@ msgid "" "func:`PyRun_String`; see the source for :c:func:`PyRun_SimpleString` in " "``Python/pythonrun.c``." msgstr "" -"執行此操作的最高級別函式是 :c:func:`PyRun_SimpleString`,它採用單個字串引數在" -"模組 ``__main__`` 的上下文中執行,並回傳 ``0`` 表示成功,``- 1`` 發生例外時" -"(包括 :exc:`SyntaxError`)。如果你想要更多的控制,使用 :c:func:" -"`PyRun_String`;在 ``Python/pythonrun.c`` 中查看 :c:func:" -"`PyRun_SimpleString` 的原始碼。" +"執行此操作的最高階函式是 :c:func:`PyRun_SimpleString`,它接受一個要在模組 " +"``__main__`` 的情境中執行的單一字串引數,成功時回傳 ``0``,發生例外(包" +"括 :exc:`SyntaxError`)時回傳 ``-1``。如果你想要更多控制,請使用 :c:" +"func:`PyRun_String`;請參閱 ``Python/pythonrun.c`` 中 :c:func:`PyRun_SimpleString` 的" +"原始碼。" #: ../../faq/extending.rst:57 -#, fuzzy msgid "How can I evaluate an arbitrary Python expression from C?" msgstr "如何計算來自 C 的任意 Python 運算式?" #: ../../faq/extending.rst:59 -#, fuzzy msgid "" "Call the function :c:func:`PyRun_String` from the previous question with the " "start symbol :c:data:`Py_eval_input`; it parses an expression, evaluates it " "and returns its value." msgstr "" -"呼叫上一個問題中的函式 :c:func:`PyRun_String` 開始符號 :c:data:" -"`Py_eval_input`;它解析一個運算式,對其求值並回傳它的值。" +"呼叫前一個問題中的 :c:func:`PyRun_String` 函式,並使用起始符號 :c:" +"data:`Py_eval_input`;它會剖析一個運算式,計算它並回傳它的值。" #: ../../faq/extending.rst:65 msgid "How do I extract C values from a Python object?" msgstr "如何從 Python 物件中提取 C 值?" #: ../../faq/extending.rst:67 -#, fuzzy msgid "" "That depends on the object's type. If it's a tuple, :c:func:`PyTuple_Size` " "returns its length and :c:func:`PyTuple_GetItem` returns the item at a " "specified index. Lists have similar functions, :c:func:`PyList_Size` and :c:" "func:`PyList_GetItem`." msgstr "" -"這取決於物件的型別。如果它是一個元組,:c:func:`PyTuple_Size` 回傳它的長度,:" -"c:func:`PyTuple_GetItem` 回傳指定索引的項目。列表具有類似的函式:c:func:" +"這取決於物件的型別。如果它是一個元組,:c:func:`PyTuple_Size` 會回傳它的長度,:" +"c:func:`PyTuple_GetItem` 則回傳指定索引的項目。串列具有類似的函式 :c:func:" "`PyList_Size` 和 :c:func:`PyList_GetItem`。" #: ../../faq/extending.rst:72 -#, fuzzy msgid "" "For bytes, :c:func:`PyBytes_Size` returns its length and :c:func:" "`PyBytes_AsStringAndSize` provides a pointer to its value and its length. " "Note that Python bytes objects may contain null bytes so C's :c:func:`!" "strlen` should not be used." msgstr "" -"對於位元組,:c:func:`PyBytes_Size` 回傳它的長度,:c:func:" -"`PyBytes_AsStringAndSize` 提供指向它的值和長度的指標。請注意,Python 位元組物" +"對於位元組,:c:func:`PyBytes_Size` 會回傳它的長度,:c:func:" +"`PyBytes_AsStringAndSize` 則提供指向該值與該長度的指標。請注意,Python 位元組物" "件可能包含空位元組,因此不應使用 C 的 :c:func:`!strlen`。" #: ../../faq/extending.rst:77 @@ -144,7 +138,6 @@ msgstr "" "`PyBytes_Check`、:c:func:`PyTuple_Check`、:c:func:`PyList_Check` 等函式。" #: ../../faq/extending.rst:80 -#, fuzzy msgid "" "There is also a high-level API to Python objects which is provided by the so-" "called 'abstract' interface -- read ``Include/abstract.h`` for further " @@ -153,10 +146,10 @@ msgid "" "as many other useful protocols such as numbers (:c:func:`PyNumber_Index` et " "al.) and mappings in the PyMapping APIs." msgstr "" -"還有一個針對 Python 物件的高級 API,它由所謂的「抽象」介面提供——閱讀 " -"``Include/abstract.h`` 了解更多詳細資訊。它允許使用 :c:func:" -"`PySequence_Length`、:c:func:`PySequence_GetItem` 等呼叫以及許多其他有用的協" -"議(例如數字 (:c:func:`PyNumber_Index) ` 等)和 PyMapping API 中的對映。" +"還有一個針對 Python 物件的高階 API,它由所謂的「抽象」介面所提供 —— 請閱讀 " +"``Include/abstract.h`` 以了解更多詳細資訊。它允許使用 :c:func:`PySequence_Length`" +"、:c:func:`PySequence_GetItem` 等函式的呼叫以及許多其他有用的協定,例如數值" +"(:c:func:`PyNumber_Index` 等)和 PyMapping API 中的對映,來與任何類型的 Python 序列做介接。" #: ../../faq/extending.rst:89 msgid "How do I use Py_BuildValue() to create a tuple of arbitrary length?" @@ -171,7 +164,6 @@ msgid "How do I call an object's method from C?" msgstr "如何從 C 呼叫物件的方法?" #: ../../faq/extending.rst:97 -#, fuzzy msgid "" "The :c:func:`PyObject_CallMethod` function can be used to call an arbitrary " "method of an object. The parameters are the object, the name of the method " @@ -179,7 +171,7 @@ msgid "" "the argument values::" msgstr "" ":c:func:`PyObject_CallMethod` 函式可用於呼叫物件的任意方法。參數是物件、要呼" -"叫的方法的名稱、與 :c:func:`Py_BuildValue` 一起使用的格式字串,以及引數" +"叫的方法名稱、與 :c:func:`Py_BuildValue` 一起使用的格式字串,以及引數" "值: ::" #: ../../faq/extending.rst:102 @@ -245,16 +237,15 @@ msgid "" msgstr "我如何捕捉 PyErr_Print() 的輸出(或任何印出到 stdout/stderr 的東西)?" #: ../../faq/extending.rst:129 -#, fuzzy msgid "" "In Python code, define an object that supports the ``write()`` method. " "Assign this object to :data:`sys.stdout` and :data:`sys.stderr`. Call " "print_error, or just allow the standard traceback mechanism to work. Then, " "the output will go wherever your ``write()`` method sends it." msgstr "" -"在 Python 程式碼中,定義一個支援 ``write()`` 方法的物件。將此物件分配給 :" +"在 Python 程式碼中定義一個支援 ``write()`` 方法的物件。將此物件分配給 :" "data:`sys.stdout` 和 :data:`sys.stderr`。呼叫 print_error,或者只允許標準的回" -"溯機制起作用。然後,輸出將到達你的 ``write()`` 方法發送它的任何地方。" +"溯機制起作用。然後,輸出將會傳送到你的 ``write()`` 方法所指定的位置。" #: ../../faq/extending.rst:134 msgid "The easiest way to do this is to use the :class:`io.StringIO` class:" @@ -349,11 +340,10 @@ msgid "attr = PyObject_GetAttrString(module, \"\");" msgstr "attr = PyObject_GetAttrString(module, \"\");" #: ../../faq/extending.rst:184 -#, fuzzy msgid "" "Calling :c:func:`PyObject_SetAttrString` to assign to variables in the " "module also works." -msgstr "呼叫 :c:func:`PyObject_SetAttrString` 以分配給模組中的變數也可以。" +msgstr "呼叫 :c:func:`PyObject_SetAttrString` 來分配模組中的變數也有效。" #: ../../faq/extending.rst:189 msgid "How do I interface to C++ objects from Python?" @@ -382,7 +372,6 @@ msgid "I added a module using the Setup file and the make fails; why?" msgstr "我使用安裝檔案新增了一個模組,但 make 失敗了;為什麼?" #: ../../faq/extending.rst:203 -#, fuzzy msgid "" "Setup must end in a newline, if there is no newline there, the build process " "fails. (Fixing this requires some ugly shell script hackery, and this bug " @@ -396,7 +385,6 @@ msgid "How do I debug an extension?" msgstr "如何為擴充套件除錯?" #: ../../faq/extending.rst:211 -#, fuzzy msgid "" "When using GDB with dynamically loaded extensions, you can't set a " "breakpoint in your extension until your extension is loaded." @@ -433,13 +421,10 @@ msgstr "" "我想在我的 Linux 系統上編譯一個 Python 模組,但是缺少一些檔案。為什麼?" #: ../../faq/extending.rst:234 -#, fuzzy msgid "" "Most packaged versions of Python omit some files required for compiling " "Python extensions." -msgstr "" -"大多數打包版本的 Python 不包含 :file:`/usr/lib/python2.{x}/config/` 目錄,該" -"目錄包含編譯 Python 擴充所需的各種檔案。" +msgstr "大多數打包版本的 Python 省略了編譯 Python 擴充所需的一些檔案。" #: ../../faq/extending.rst:237 msgid "For Red Hat, install the python3-devel RPM to get the necessary files." @@ -454,7 +439,6 @@ msgid "How do I tell \"incomplete input\" from \"invalid input\"?" msgstr "如何從「無效輸入」區分出「不完整輸入」?" #: ../../faq/extending.rst:244 -#, fuzzy msgid "" "Sometimes you want to emulate the Python interactive interpreter's behavior, " "where it gives you a continuation prompt when the input is incomplete (e.g. " @@ -462,9 +446,9 @@ msgid "" "parentheses or triple string quotes), but it gives you a syntax error " "message immediately when the input is invalid." msgstr "" -"有時你想模擬 Python 交互式直譯器的行為,當輸入不完整時它會給你一個繼續提示" -"(例如,你鍵入了 \"if\" 陳述句的開頭或者你沒有關閉你的括號或三重字串引號)," -"但是當輸入無效時,它會立即為你提供語法錯誤消息。" +"有時你會想模擬 Python 交互式直譯器的行為,當輸入不完整時(例如,當你輸入了 \"if\" 陳述式的" +"開頭或者你沒有關閉你的括號或三重字串引號)它會給你一個繼續提示字元," +"但是當輸入無效時,它會立即為你提供語法錯誤訊息。" #: ../../faq/extending.rst:250 msgid "" @@ -475,7 +459,6 @@ msgstr "" "為。像是 IDLE 就有使用它。" #: ../../faq/extending.rst:253 -#, fuzzy msgid "" "The easiest way to do it in C is to call :c:func:`PyRun_InteractiveLoop` " "(perhaps in a separate thread) and let the Python interpreter handle the " @@ -483,25 +466,24 @@ msgid "" "to point at your custom input function. See ``Modules/readline.c`` and " "``Parser/myreadline.c`` for more hints." msgstr "" -"在 C 中執行此操作的最簡單方法是呼叫:c:func:`PyRun_InteractiveLoop`(可能在單" +"在 C 中執行此操作的最簡單方法是呼叫 :c:func:`PyRun_InteractiveLoop`\\ (可能是在單" "獨的執行緒中)並讓 Python 直譯器為你處理輸入。你還可以將 :c:func:" "`PyOS_ReadlineFunctionPointer` 設定為指向你的自定義輸入函式。有關更多提示,請" -"參閱``Modules/readline.c`` 和``Parser/myreadline.c``。" +"參閱 ``Modules/readline.c`` 和 ``Parser/myreadline.c``。" #: ../../faq/extending.rst:260 msgid "How do I find undefined g++ symbols __builtin_new or __pure_virtual?" msgstr "如何找到未定義的 g++ 符號 __builtin_new 或 __pure_virtual?" #: ../../faq/extending.rst:262 -#, fuzzy msgid "" "To dynamically load g++ extension modules, you must recompile Python, relink " "it using g++ (change LINKCC in the Python Modules Makefile), and link your " "extension module using g++ (e.g., ``g++ -shared -o mymodule.so mymodule.o``)." msgstr "" -"要動態載入 g++ 擴充模組,你必須重新編譯 Python,使用 g++ 重新鏈接它(更改 " -"Python 模組 Makefile 中的 LINKCC),並使用 g++ 鏈接你的擴充模組(例如,``g++ " -"-shared -o mymodule.so mymodule.o` `)。" +"要動態載入 g++ 擴充模組,你必須重新編譯 Python,並使用 g++ 重新鏈接它(更改 " +"Python 模組 Makefile 中的 LINKCC),且使用 g++ 鏈接你的擴充模組(例如,``g++ " +"-shared -o mymodule.so mymodule.o``)。" #: ../../faq/extending.rst:268 msgid "" diff --git a/faq/general.po b/faq/general.po index ac684d513b3..b5ec25461db 100644 --- a/faq/general.po +++ b/faq/general.po @@ -1,5 +1,4 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -8,9 +7,9 @@ # Steven Hsu , 2022 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-02-19 00:13+0000\n" +"POT-Creation-Date: 2025-10-22 00:14+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-" @@ -84,14 +83,14 @@ msgid "" msgstr "" "Python 軟體基金會 (Python Software Foundation) 是一個獨立的非營利性組織,它擁" "有 Python 2.1 版與之後各版本的版權。PSF 的使命在於推展 Python 程式設計語言相" -"關的開放原始碼技術,以及宣傳 Python 的使用。PSF 首頁的網址是 https://" -"www.python.org/psf/。" +"關的開放原始碼技術,以及宣傳 Python 的使用。PSF 首頁的網址是 https://www." +"python.org/psf/。" #: ../../faq/general.rst:42 msgid "" "Donations to the PSF are tax-exempt in the US. If you use Python and find " -"it helpful, please contribute via `the PSF donation page `_." +"it helpful, please contribute via `the PSF donation page `_." msgstr "" "在美國捐款給 PSF 是免稅的。如果你使用了 Python 且發現它很有用,請至 `PSF 捐款" "頁面 `_\\ 為它做出貢獻。" @@ -335,9 +334,8 @@ msgid "" msgstr "" "請參閱\\ `開發人員指南 `__\\ 以獲得更多關於開發週期的資訊,並參閱 :pep:`387` 以瞭" -"解更多關於 Python 的向後相容性政策。另外,也請查" -"看 :data:`sys.version`、:data:`sys.hexversion` 和 :data:`sys.version_info` 的" -"說明文件。" +"解更多關於 Python 的向後相容性政策。另外,也請查看 :data:`sys.version`、:" +"data:`sys.hexversion` 和 :data:`sys.version_info` 的說明文件。" #: ../../faq/general.rst:169 msgid "How do I obtain a copy of the Python source?" @@ -349,9 +347,9 @@ msgid "" "at https://www.python.org/downloads/. The latest development sources can be " "obtained at https://github.com/python/cpython/." msgstr "" -"最新的 Python 原始碼發行版永遠可以從 python.org 取得,在 https://" -"www.python.org/downloads/。最新的開發中原始碼可以在 https://github.com/" -"python/cpython/ 取得。" +"最新的 Python 原始碼發行版永遠可以從 python.org 取得,在 https://www.python." +"org/downloads/。最新的開發中原始碼可以在 https://github.com/python/cpython/ " +"取得。" #: ../../faq/general.rst:175 msgid "" @@ -380,10 +378,10 @@ msgstr "我要如何取得 Python 的說明文件?" #: ../../faq/general.rst:188 msgid "" "The standard documentation for the current stable version of Python is " -"available at https://docs.python.org/3/. PDF, plain text, and downloadable " +"available at https://docs.python.org/3/. EPUB, plain text, and downloadable " "HTML versions are also available at https://docs.python.org/3/download.html." msgstr "" -"Python 目前穩定版本的標準說明文件可在 https://docs.python.org/3/ 找到。PDF、" +"Python 目前穩定版本的標準說明文件可在 https://docs.python.org/3/ 找到。EPUB、" "純文字和可下載的 HTML 版本也可在 https://docs.python.org/3/download.html 找" "到。" @@ -426,10 +424,9 @@ msgid "" "There is a newsgroup, :newsgroup:`comp.lang.python`, and a mailing list, " "`python-list `_. The " "newsgroup and mailing list are gatewayed into each other -- if you can read " -"news it's unnecessary to subscribe to the mailing " -"list. :newsgroup:`comp.lang.python` is high-traffic, receiving hundreds of " -"postings every day, and Usenet readers are often more able to cope with this " -"volume." +"news it's unnecessary to subscribe to the mailing list. :newsgroup:`comp." +"lang.python` is high-traffic, receiving hundreds of postings every day, and " +"Usenet readers are often more able to cope with this volume." msgstr "" "有一個新聞群組 (newsgroup),:newsgroup:`comp.lang.python`,也有一個郵件討論" "群 (mailing list),`python-list `_." msgstr "" "新的軟體發布版本及事件的通知,可以在 comp.lang.python.announce 中找到,這是一" @@ -464,9 +461,9 @@ msgstr "如何取得 Python 的 beta 測試版本?" #: ../../faq/general.rst:229 msgid "" "Alpha and beta releases are available from https://www.python.org/" -"downloads/. All releases are announced on the comp.lang.python and " -"comp.lang.python.announce newsgroups and on the Python home page at https://" -"www.python.org/; an RSS feed of news is available." +"downloads/. All releases are announced on the comp.lang.python and comp." +"lang.python.announce newsgroups and on the Python home page at https://www." +"python.org/; an RSS feed of news is available." msgstr "" "Alpha 和 beta 發布版本可以從 https://www.python.org/downloads/ 取得。所有的發" "布版本都會在 comp.lang.python 和 comp.lang.python.announce 新聞群組上宣布,也" @@ -486,8 +483,8 @@ msgstr "如何提交 Python 的錯誤報告和修補程式?" #: ../../faq/general.rst:241 msgid "" -"To report a bug or submit a patch, use the issue tracker at https://" -"github.com/python/cpython/issues." +"To report a bug or submit a patch, use the issue tracker at https://github." +"com/python/cpython/issues." msgstr "" "要回報一個錯誤 (bug) 或提交一個修補程式 (patch),請使用於 https://github.com/" "python/cpython/issues 的問題追蹤系統。" @@ -553,8 +550,8 @@ msgstr "www.python.org 的真實位置在哪裡?" #: ../../faq/general.rst:274 msgid "" "The Python project's infrastructure is located all over the world and is " -"managed by the Python Infrastructure Team. Details `here `__." +"managed by the Python Infrastructure Team. Details `here `__." msgstr "" "Python 專案的基礎建設遍佈世界各地,由 Python 基礎建設團隊管理。詳細資訊\\ `在" "此 `__。" @@ -566,8 +563,8 @@ msgstr "為什麼要取名為 Python?" #: ../../faq/general.rst:281 msgid "" "When he began implementing Python, Guido van Rossum was also reading the " -"published scripts from `\"Monty Python's Flying Circus\" `__, a BBC comedy series from the 1970s. " +"published scripts from `\"Monty Python's Flying Circus\" `__, a BBC comedy series from the 1970s. " "Van Rossum thought he needed a name that was short, unique, and slightly " "mysterious, so he decided to call the language Python." msgstr "" @@ -627,17 +624,17 @@ msgstr "" "downloads/>`_\\ 上找到。Python 3.x 是推薦的版本,並且被大多數廣泛使用的函式庫" "所支援。Python 2.x :pep:`已不再被維護 <0373>`。" -#: ../../faq/general.rst:318 +#: ../../faq/general.rst:317 msgid "How many people are using Python?" msgstr "有多少人在使用 Python?" -#: ../../faq/general.rst:320 +#: ../../faq/general.rst:319 msgid "" "There are probably millions of users, though it's difficult to obtain an " "exact count." msgstr "可能有幾百萬個使用者,但實際的數量是難以確定的。" -#: ../../faq/general.rst:323 +#: ../../faq/general.rst:322 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 " @@ -646,7 +643,7 @@ msgstr "" "Python 是可以免費下載的,所以不會有銷售數據,而且它可以從許多不同的網站取得," "並與許多 Linux 發行版套裝在一起,所以下載次數的統計也無法反映完整的情況。" -#: ../../faq/general.rst:327 +#: ../../faq/general.rst:326 msgid "" "The comp.lang.python newsgroup is very active, but not all Python users post " "to the group or even read it." @@ -654,41 +651,41 @@ msgstr "" "comp.lang.python 新聞群組非常活躍,但並非所有 Python 使用者都會在該群組發表文" "章或甚至閱讀它。" -#: ../../faq/general.rst:332 +#: ../../faq/general.rst:331 msgid "Have any significant projects been done in Python?" msgstr "有沒有任何重要的專案使用 Python 完成開發?" -#: ../../faq/general.rst:334 +#: ../../faq/general.rst:333 msgid "" "See https://www.python.org/about/success for a list of projects that use " -"Python. Consulting the proceedings for `past Python conferences `_ will reveal contributions from many " +"Python. Consulting the proceedings for `past Python conferences `_ will reveal contributions from many " "different companies and organizations." msgstr "" "要查看使用 Python 的專案清單,請參閱 https://www.python.org/about/success。藉" "由查詢\\ `過去的 Python 會議記錄 `_\\ 可以看見來自許多不同公司和組織的貢獻。" -#: ../../faq/general.rst:339 +#: ../../faq/general.rst:338 msgid "" "High-profile Python projects include `the Mailman mailing list manager " -"`_ and `the Zope application server `_. Several Linux distributions, most notably `Red Hat " -"`_, have written part or all of their installer and " -"system administration software in Python. Companies that use Python " -"internally include Google, Yahoo, and Lucasfilm Ltd." -msgstr "" -"備受矚目的 Python 專案包括 `Mailman 郵件討論群管理員 `_\\ 和 `Zope 應用程式伺服器 `_。有一些 " -"Linux 發行版,最著名的是 `Red Hat `_,已經用 Python " -"編寫了部分或全部的安裝程式及系統管理軟體。內部使用 Python 的公司包括 Google、" -"Yahoo 和 Lucasfilm Ltd。" - -#: ../../faq/general.rst:348 +"`_ and `the Zope application server `_. Several Linux distributions, most notably `Red Hat `_, have written part or all of their installer and system " +"administration software in Python. Companies that use Python internally " +"include Google, Yahoo, and Lucasfilm Ltd." +msgstr "" +"備受矚目的 Python 專案包括 `Mailman 郵件討論群管理員 `_\\ 和 `Zope 應用程式伺服器 `_。有一些 Linux 發行" +"版,最著名的是 `Red Hat `_,已經用 Python 編寫了部分" +"或全部的安裝程式及系統管理軟體。內部使用 Python 的公司包括 Google、Yahoo 和 " +"Lucasfilm Ltd。" + +#: ../../faq/general.rst:347 msgid "What new developments are expected for Python in the future?" msgstr "Python 未來預期會有哪些新的開發?" -#: ../../faq/general.rst:350 +#: ../../faq/general.rst:349 msgid "" "See https://peps.python.org/ for the Python Enhancement Proposals (PEPs). " "PEPs are design documents describing a suggested new feature for Python, " @@ -701,19 +698,19 @@ msgstr "" "簡潔的技術規範及基本原理。請尋找一篇名為「Python X.Y Release Schedule(發布時" "程表)」的 PEP,其中 X.Y 是一個尚未公開發布的版本。" -#: ../../faq/general.rst:356 +#: ../../faq/general.rst:355 msgid "" -"New development is discussed on `the python-dev mailing list `_." +"New development is discussed on `the python-dev mailing list `_." msgstr "" "新的開發會在 `python-dev 郵件討論群 `_\\ 中討論。" -#: ../../faq/general.rst:361 +#: ../../faq/general.rst:360 msgid "Is it reasonable to propose incompatible changes to Python?" msgstr "對 Python 提出不相容的變更建議是否適當?" -#: ../../faq/general.rst:363 +#: ../../faq/general.rst:362 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 " @@ -727,7 +724,7 @@ msgstr "" "式,仍然會有需要更新全部說明文件的問題;市面上已經有很多介紹 Python 的書,而" "我們不想一下子就把它們都變為無效。" -#: ../../faq/general.rst:370 +#: ../../faq/general.rst:369 msgid "" "Providing a gradual upgrade path is necessary if a feature has to be " "changed. :pep:`5` describes the procedure followed for introducing backward-" @@ -737,15 +734,15 @@ msgstr "" "向不相容 (backward-incompatible) 的變更,同時也要對使用者的擾亂最小化,所需遵" "循的程序。" -#: ../../faq/general.rst:376 +#: ../../faq/general.rst:375 msgid "Is Python a good language for beginning programmers?" msgstr "Python 對於入門的程式設計師而言是否為好的語言?" -#: ../../faq/general.rst:378 +#: ../../faq/general.rst:377 msgid "Yes." msgstr "是的。" -#: ../../faq/general.rst:380 +#: ../../faq/general.rst:379 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 " @@ -765,7 +762,7 @@ msgstr "" "速地向學生介紹基本觀念,例如迴圈和程序。他們甚至可能在第一堂課中就學到使用者" "自訂的物件。" -#: ../../faq/general.rst:390 +#: ../../faq/general.rst:389 msgid "" "For a student who has never programmed before, using a statically typed " "language seems unnatural. It presents additional complexity that the " @@ -781,7 +778,7 @@ msgstr "" "考、分解問題、設計一致的介面,並封裝資料。雖然從長遠來看,學習使用靜態型別語" "言很重要,但在學生的第一堂程式設計課程中,它不一定是最好的課程主題。" -#: ../../faq/general.rst:398 +#: ../../faq/general.rst:397 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 " @@ -800,7 +797,7 @@ msgstr "" "用程式的滿足感。使用標準函式庫還可以教導學生程式碼再使用 (code reuse) 的課" "題。像是 PyGame 等第三方模組也有助於延伸學生的學習領域。" -#: ../../faq/general.rst:407 +#: ../../faq/general.rst:406 msgid "" "Python's interactive interpreter enables students to test language features " "while they're programming. They can keep a window with the interpreter " @@ -811,7 +808,7 @@ msgstr "" "行直譯器的視窗,同時在另一個視窗中輸入他們的程式原始碼。如果他們不記得 list" "(串列)的 method(方法),他們可以像這樣做: ::" -#: ../../faq/general.rst:412 +#: ../../faq/general.rst:411 msgid "" ">>> L = []\n" ">>> dir(L)\n" @@ -863,13 +860,13 @@ msgstr "" ">>> L\n" "[1]" -#: ../../faq/general.rst:436 +#: ../../faq/general.rst:435 msgid "" "With the interpreter, documentation is never far from the student as they " "are programming." msgstr "有了直譯器,當學生正在程式設計時,說明文件永遠都不會遠離他們。" -#: ../../faq/general.rst:439 +#: ../../faq/general.rst:438 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 " @@ -885,7 +882,7 @@ msgstr "" "式時存取互動式直譯器。要查看 Python 編輯環境的完整清單,請參閱 `Python wiki " "`_。" -#: ../../faq/general.rst:447 +#: ../../faq/general.rst:446 msgid "" "If you want to discuss Python's use in education, you may be interested in " "joining `the edu-sig mailing list ` to events with the :meth:`!bind` method don't get handled even when " "the appropriate key is pressed." msgstr "" -"一個經常聽到的抱怨是,儘管事件處理程式 (event handler) 已經\\ :ref:`繫結" +"一個經常聽到的抱怨是,儘管事件處理程式 (event handler) 已經\\ :ref:`繫結 " "`\\ 到帶有 :meth:`!bind` method 的事件,但在按下相應的鍵" "時,該事件也沒有被處理。" diff --git a/faq/index.po b/faq/index.po index 37bec953169..914e8e08c4c 100644 --- a/faq/index.po +++ b/faq/index.po @@ -1,12 +1,11 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Adrian Liaw , 2015 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2018-06-26 18:54+0800\n" "PO-Revision-Date: 2017-09-22 18:26+0000\n" diff --git a/faq/installed.po b/faq/installed.po index 260bb53d3cc..f6a7bc424f6 100644 --- a/faq/installed.po +++ b/faq/installed.po @@ -1,5 +1,4 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -8,7 +7,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-09-24 00:11+0000\n" "PO-Revision-Date: 2021-12-09 21:50+0800\n" diff --git a/faq/library.po b/faq/library.po index 19395ef83ab..b9387ec85ed 100644 --- a/faq/library.po +++ b/faq/library.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -6,9 +6,9 @@ # Ching-Lung Chuang, 2015 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-09-08 15:25+0800\n" "PO-Revision-Date: 2023-02-18 13:22+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -37,26 +37,24 @@ msgid "How do I find a module or application to perform task X?" msgstr "我如何找到執行任務 X 的模組或應用程式?" #: ../../faq/library.rst:17 -#, fuzzy msgid "" "Check :ref:`the Library Reference ` to see if there's a " "relevant standard library module. (Eventually you'll learn what's in the " "standard library and will be able to skip this step.)" msgstr "" -"檢查 :ref:`函式庫參考 ` 以查看是否有相關的標準函式庫模組。 " -"(最終你將了解標準函式庫中的內容,並且能夠跳過這一步。)" +"查看\\ :ref:`函式庫參照 `\\ 以了解是否有相關的標準函式庫模組。 " +"(當你熟悉標準函式庫中的內容後就可以能跳過這一步。)" #: ../../faq/library.rst:21 -#, fuzzy msgid "" "For third-party packages, search the `Python Package Index `_ or try `Google `_ or another web search " "engine. Searching for \"Python\" plus a keyword or two for your topic of " "interest will usually find something helpful." msgstr "" -"對於第三方包,搜尋`Python 包索引`_ 或嘗試`Google `_ 或其他網路搜尋引擎。搜尋 \"Python\" 加上你感興趣的主題的一" -"兩個關鍵字通常會找到有用的東西。" +"對於第三方套件,搜尋 `Python 套件索引 `_\\ 或嘗試使用 `Google " +"`_ 或其他網路搜尋引擎。搜尋 \"Python\" 加上你感興趣主題的一" +"兩個關鍵字,通常能夠找到有用的東西。" #: ../../faq/library.rst:28 msgid "Where is the math.py (socket.py, regex.py, etc.) source file?" @@ -135,11 +133,10 @@ msgid "#!/usr/local/bin/python" msgstr "#!/usr/local/bin/python" #: ../../faq/library.rst:61 -#, fuzzy msgid "" "as the very first line of your file, using the pathname for where the Python " "interpreter is installed on your platform." -msgstr "作為檔案的第一行,使用 Python 直譯器在你的平台上的安裝位置的路徑名。" +msgstr "作為檔案的第一行,使用 Python 直譯器安裝在你的平台上的路徑名稱。" #: ../../faq/library.rst:64 #, fuzzy @@ -235,22 +232,20 @@ msgid "Is there an equivalent to C's onexit() in Python?" msgstr "Python 中是否有等同於 C 的 onexit() 的函式?" #: ../../faq/library.rst:113 -#, fuzzy msgid "" "The :mod:`atexit` module provides a register function that is similar to " "C's :c:func:`!onexit`." -msgstr ":mod:`atexit` 模組提供了一個類似於 C :c:func:`onexit` 的註冊器函式。" +msgstr ":mod:`atexit` 模組提供了一個類似於 C :c:func:`!onexit` 的註冊函式。" #: ../../faq/library.rst:118 msgid "Why don't my signal handlers work?" msgstr "為什麼我的訊號處理程式不起作用?" #: ../../faq/library.rst:120 -#, fuzzy msgid "" "The most common problem is that the signal handler is declared with the " "wrong argument list. It is called as ::" -msgstr "最常見的問題是訊號處理程式是用錯誤的引數列表聲明的。它被稱為: ::" +msgstr "最常見的問題是訊號處理程式是用錯誤的引數串列聲明的。它以以下形式來呼叫: ::" #: ../../faq/library.rst:123 msgid "handler(signum, frame)" @@ -287,12 +282,11 @@ msgstr "" "它們,將輸出與文件字串中給出的預期輸出進行比較。" #: ../../faq/library.rst:141 -#, fuzzy msgid "" "The :mod:`unittest` module is a fancier testing framework modelled on Java " "and Smalltalk testing frameworks." msgstr "" -":mod:`unittest` 模組是一個更高階的測試框架,它以 Java 和 Smalltalk 測試框架為" +":mod:`unittest` 模組是一個更炫目的測試框架,它以 Java 和 Smalltalk 測試框架為" "模型。" #: ../../faq/library.rst:144 @@ -394,13 +388,12 @@ msgid "How do I get a single keypress at a time?" msgstr "我如何一次獲得一個按鍵?" #: ../../faq/library.rst:190 -#, fuzzy msgid "" "For Unix variants there are several solutions. It's straightforward to do " "this using curses, but curses is a fairly large module to learn." msgstr "" -"對於 Unix 變體,有幾種解決方案。使用 curses 執行此操作很簡單,但 curses 是一" -"個需要學習的相當大的模組。" +"對於 Unix 變體有幾種解決方案。使用 curses 執行此操作很直觀,但 curses 是一" +"個學習成本較大的模組。" #: ../../faq/library.rst:234 msgid "Threads" @@ -435,12 +428,11 @@ msgstr "" "間做任何工作。" #: ../../faq/library.rst:250 -#, fuzzy msgid "" "A simple fix is to add a sleep to the end of the program that's long enough " "for all the threads to finish::" msgstr "" -"一個簡單的修復方法是在程式末尾新增一個足夠長的睡眠,讓所有執行緒都完成: ::" +"一個簡單的修復方式是在程式末尾新增一個足夠長的 sleep,讓所有執行緒都完成: ::" #: ../../faq/library.rst:253 msgid "" @@ -480,9 +472,8 @@ msgstr "" "緒。" #: ../../faq/library.rst:269 -#, fuzzy msgid "A simple fix is to add a tiny sleep to the start of the run function::" -msgstr "一個簡單的修復方法是在運行函式的開頭新增一個小睡眠: ::" +msgstr "一個簡單的修復方式是在運行函式的開頭新增一個小 sleep: ::" #: ../../faq/library.rst:271 msgid "" @@ -637,9 +628,8 @@ msgstr "" "強大的介面。" #: ../../faq/library.rst:363 -#, fuzzy msgid "What kinds of global value mutation are thread-safe?" -msgstr "什麼樣的全域值突變是執行緒安全的?" +msgstr "什麼樣的全域值變化是執行緒安全的?" #: ../../faq/library.rst:365 #, fuzzy @@ -879,15 +869,14 @@ msgstr "" "數)。" #: ../../faq/library.rst:484 -#, fuzzy msgid "" "The :mod:`shutil` module also contains a number of functions to work on " "files including :func:`~shutil.copyfile`, :func:`~shutil.copytree`, " "and :func:`~shutil.rmtree`." msgstr "" -":mod:`shutil` 模組還包含許多用於處理檔案的函式,包" -"括:func:`~shutil.copyfile`、:func:`~shutil.copytree` " -"和:func:`~shutil.rmtree`。" +":mod:`shutil` 模組還包含許多用於檔案處理的函式,包" +"括 :func:`~shutil.copyfile`、:func:`~shutil.copytree` " +"和 :func:`~shutil.rmtree`。" #: ../../faq/library.rst:490 msgid "How do I copy a file?" @@ -976,7 +965,7 @@ msgid "" "will return :class:`str` objects rather than :class:`bytes` objects." msgstr "" "要讀取和寫入二進位資料,必須以二進位模式打開檔案(這裡,將 ``\"rb\"`` 傳遞" -"給 :func:`open`)。如果你改用 ``\"r\"``(預設設定),檔案將以文本模式打開,並" +"給 :func:`open`)。如果你改用 ``\"r\"``\\ (預設設定),檔案將以文本模式打開,並" "且 ``f.read()`` 將回傳 :class:`str` 物件而不是 :class:`bytes` 物件。" #: ../../faq/library.rst:535 @@ -997,38 +986,38 @@ msgstr "" "型別相同。因此,要從使用 :func:`os.popen` 建立的管道 *p* 中讀取 *n* 個位元" "組,你需要使用 ``p.read(n)``。" -#: ../../faq/library.rst:623 +#: ../../faq/library.rst:545 msgid "How do I access the serial (RS232) port?" msgstr "如何存取序列 (RS232) 連接埠?" -#: ../../faq/library.rst:625 +#: ../../faq/library.rst:547 msgid "For Win32, OSX, Linux, BSD, Jython, IronPython:" msgstr "對於 Win32、OSX、Linux、BSD、Jython、IronPython:" -#: ../../faq/library.rst:627 +#: ../../faq/library.rst:549 msgid ":pypi:`pyserial`" msgstr ":pypi:`pyserial`" -#: ../../faq/library.rst:629 +#: ../../faq/library.rst:551 msgid "For Unix, see a Usenet post by Mitch Chapman:" msgstr "對於 Unix,請參閱 Mitch Chapman 的 Usenet 貼文:" -#: ../../faq/library.rst:631 +#: ../../faq/library.rst:553 msgid "https://groups.google.com/groups?selm=34A04430.CF9@ohioee.com" msgstr "https://groups.google.com/groups?selm=34A04430.CF9@ohioee.com" -#: ../../faq/library.rst:635 +#: ../../faq/library.rst:557 msgid "Why doesn't closing sys.stdout (stdin, stderr) really close it?" msgstr "為什麼關閉 sys.stdout (stdin, stderr) 並沒有真正關閉它?" -#: ../../faq/library.rst:637 +#: ../../faq/library.rst:559 msgid "" "Python :term:`file objects ` are a high-level layer of " "abstraction on low-level C file descriptors." msgstr "" "Python :term:`檔案物件 `\\ 是低階 C 檔案描述器的高階抽象層。" -#: ../../faq/library.rst:640 +#: ../../faq/library.rst:562 #, fuzzy msgid "" "For most file objects you create in Python via the built-in :func:`open` " @@ -1041,7 +1030,7 @@ msgstr "" "``f.close()`` 從 Python 的角度將 Python 檔案物件標記為已關閉,並安排關閉底層 " "C 檔案描述器。當 ``f`` 變成垃圾時,這也會自動發生在 ``f`` 的析構函式中。" -#: ../../faq/library.rst:646 +#: ../../faq/library.rst:568 #, fuzzy msgid "" "But stdin, stdout and stderr are treated specially by Python, because of the " @@ -1053,7 +1042,7 @@ msgstr "" "態。運行 ``sys.stdout.close()`` 將 Python 級檔案物件標記為已關閉,但是 * " "not* 關閉關聯的 C 檔案描述器。" -#: ../../faq/library.rst:651 +#: ../../faq/library.rst:573 #, fuzzy msgid "" "To close the underlying C file descriptor for one of these three, you should " @@ -1063,7 +1052,7 @@ msgstr "" "要關閉這三個之一的底層 C 檔案描述器,你應該首先確定這是你真正想要做的(例如," "你可能會混淆試圖執行 I/O 的擴充模組)。如果是,使用 :func:`os.close`: ::" -#: ../../faq/library.rst:655 +#: ../../faq/library.rst:577 msgid "" "os.close(stdin.fileno())\n" "os.close(stdout.fileno())\n" @@ -1073,19 +1062,19 @@ msgstr "" "os.close(stdout.fileno())\n" "os.close(stderr.fileno())" -#: ../../faq/library.rst:659 +#: ../../faq/library.rst:581 msgid "Or you can use the numeric constants 0, 1 and 2, respectively." msgstr "或者你可以分別使用數字常數 0、1 和 2。" -#: ../../faq/library.rst:663 +#: ../../faq/library.rst:585 msgid "Network/Internet Programming" msgstr "網路 (Network)/網際網路 (Internet) 程式" -#: ../../faq/library.rst:666 +#: ../../faq/library.rst:588 msgid "What WWW tools are there for Python?" msgstr "Python 有哪些 WWW 工具?" -#: ../../faq/library.rst:668 +#: ../../faq/library.rst:590 #, fuzzy msgid "" "See the chapters titled :ref:`internet` and :ref:`netdata` in the Library " @@ -1095,37 +1084,35 @@ msgstr "" "請參閱函式庫參考手冊中標題為 :ref:`internet` 和 :ref:`netdata` 的章節。 " "Python 有許多模組可以幫助你構建伺服器端和用戶端 Web 系統。" -#: ../../faq/library.rst:674 -#, fuzzy +#: ../../faq/library.rst:596 msgid "" "A summary of available frameworks is maintained by Paul Boddie at https://" "wiki.python.org/moin/WebProgramming\\ ." msgstr "" -"可用框架的摘要由 Paul Boddie 在 https://wiki.python.org/moin/" -"WebProgramming\\ 維護。" +"Paul Boddie 有在 https://wiki.python.org/moin/" +"WebProgramming\\ 維護可用框架的摘要。" -#: ../../faq/library.rst:679 +#: ../../faq/library.rst:601 msgid "What module should I use to help with generating HTML?" msgstr "我應該使用什麼模組來輔助產生 HTML?" -#: ../../faq/library.rst:683 -#, fuzzy +#: ../../faq/library.rst:605 msgid "" "You can find a collection of useful links on the `Web Programming wiki page " "`_." msgstr "" -"你可以在 \"Web 編寫程式維基頁面 \" 上找到一組有用的鏈接。" -#: ../../faq/library.rst:688 +#: ../../faq/library.rst:610 msgid "How do I send mail from a Python script?" msgstr "如何從 Python 腳本發送郵件?" -#: ../../faq/library.rst:690 +#: ../../faq/library.rst:612 msgid "Use the standard library module :mod:`smtplib`." msgstr "使用標準函式庫模組 :mod:`smtplib`。" -#: ../../faq/library.rst:692 +#: ../../faq/library.rst:614 #, fuzzy msgid "" "Here's a very simple interactive mail sender that uses it. This method will " @@ -1134,7 +1121,7 @@ msgstr "" "這是一個使用它的非常簡單的交互式郵件發件人。此方法適用於任何支援 SMTP 偵聽器" "的主機。: ::" -#: ../../faq/library.rst:695 +#: ../../faq/library.rst:617 msgid "" "import sys, smtplib\n" "\n" @@ -1170,19 +1157,18 @@ msgstr "" "server.sendmail(fromaddr, toaddrs, msg)\n" "server.quit()" -#: ../../faq/library.rst:712 -#, fuzzy +#: ../../faq/library.rst:634 msgid "" "A Unix-only alternative uses sendmail. The location of the sendmail program " "varies between systems; sometimes it is ``/usr/lib/sendmail``, sometimes ``/" "usr/sbin/sendmail``. The sendmail manual page will help you out. Here's " "some sample code::" msgstr "" -"一個僅適用於 Unix 的替代方案使用 sendmail。 sendmail 程式的位置因係統而異;有" -"時是 \"/usr/lib/sendmail\" ,有時是 \"/usr/sbin/sendmail\" 。 sendmail 手冊頁" -"將幫助你。這是一些示例程式碼: ::" +"使用 sendmail 是僅適用於 Unix 的替代方案。sendmail 程式的位置會因系統而異;有" +"時是 ``/usr/lib/sendmail``,有時是 ``/usr/sbin/sendmail``。sendmail 使用手冊" +"將能夠幫助你。這是一些範例程式碼: ::" -#: ../../faq/library.rst:717 +#: ../../faq/library.rst:639 msgid "" "import os\n" "\n" @@ -1198,18 +1184,17 @@ msgid "" " print(\"Sendmail exit status\", sts)" msgstr "" -#: ../../faq/library.rst:732 -#, fuzzy +#: ../../faq/library.rst:654 msgid "How do I avoid blocking in the connect() method of a socket?" msgstr "如何避免阻塞 socket 的 connect() 方法?" -#: ../../faq/library.rst:734 +#: ../../faq/library.rst:656 msgid "" "The :mod:`select` module is commonly used to help with asynchronous I/O on " "sockets." msgstr ":mod:`select` 模組通常用於幫助處理 socket 上的非同步 I/O。" -#: ../../faq/library.rst:737 +#: ../../faq/library.rst:659 #, fuzzy msgid "" "To prevent the TCP connect from blocking, you can set the socket to non-" @@ -1225,7 +1210,7 @@ msgstr "" "其中包含錯誤號 ``.errno``。 ``errno.EINPROGRESS`` 表示連接正在進行中,但尚未" "完成。不同的作業系統將回傳不同的值,因此你將不得不檢查系統回傳的內容。" -#: ../../faq/library.rst:745 +#: ../../faq/library.rst:667 #, fuzzy msgid "" "You can use the :meth:`~socket.socket.connect_ex` method to avoid creating " @@ -1239,7 +1224,7 @@ msgstr "" "``errno.EISCONN`` 表示你已連接 - 或者你可以將此 socket 傳遞" "給 :meth:`select.select` 檢查它是否可寫。" -#: ../../faq/library.rst:753 +#: ../../faq/library.rst:675 msgid "" "The :mod:`asyncio` module provides a general purpose single-threaded and " "concurrent asynchronous library, which can be used for writing non-blocking " @@ -1250,19 +1235,19 @@ msgstr "" "網路程式碼。第三方 `Twisted `_ 函式庫是一種流行且功能豐" "富的替代方案。" -#: ../../faq/library.rst:761 +#: ../../faq/library.rst:683 msgid "Databases" msgstr "資料庫" -#: ../../faq/library.rst:764 +#: ../../faq/library.rst:686 msgid "Are there any interfaces to database packages in Python?" msgstr "Python 中是否有任何資料庫套件的介面?" -#: ../../faq/library.rst:766 +#: ../../faq/library.rst:688 msgid "Yes." msgstr "有的。" -#: ../../faq/library.rst:768 +#: ../../faq/library.rst:690 #, fuzzy msgid "" "Interfaces to disk-based hashes such as :mod:`DBM ` and :mod:`GDBM " @@ -1270,11 +1255,11 @@ msgid "" "the :mod:`sqlite3` module, which provides a lightweight disk-based " "relational database." msgstr "" -"基於磁盤的雜湊介面,例如 :mod:`DBM ` 和 :mod:`GDBM ` 也包" -"含在標準 Python 中。還有 :mod:`sqlite3` 模組,它提供了一個輕量級的基於磁盤的" +"基於磁碟的雜湊介面,例如 :mod:`DBM ` 和 :mod:`GDBM ` 也包" +"含在標準 Python 中。還有 :mod:`sqlite3` 模組,它提供了一個輕量級的基於磁碟的" "關係資料庫。" -#: ../../faq/library.rst:773 +#: ../../faq/library.rst:695 #, fuzzy msgid "" "Support for most relational databases is available. See the " @@ -1284,11 +1269,11 @@ msgstr "" "支援大多數關係資料庫。有關詳細資訊,請參閱 `DatabaseProgramming 維基頁面 " "`_。" -#: ../../faq/library.rst:779 +#: ../../faq/library.rst:701 msgid "How do you implement persistent objects in Python?" msgstr "你如何在 Python 中實作持久性物件?" -#: ../../faq/library.rst:781 +#: ../../faq/library.rst:703 #, fuzzy msgid "" "The :mod:`pickle` library module solves this in a very general way (though " @@ -1300,21 +1285,21 @@ msgstr "" "儲諸如打開的檔案、socket 或窗口之類的東西),而 :mod:`shelve` 函式庫模組使用 " "pickle 和 (g) dbm 建立包含任意 Python 物件的持久對映。" -#: ../../faq/library.rst:788 +#: ../../faq/library.rst:710 msgid "Mathematics and Numerics" msgstr "數學和數值" -#: ../../faq/library.rst:791 +#: ../../faq/library.rst:713 msgid "How do I generate random numbers in Python?" msgstr "如何在 Python 中生成隨機數?" -#: ../../faq/library.rst:793 +#: ../../faq/library.rst:715 msgid "" "The standard module :mod:`random` implements a random number generator. " "Usage is simple::" msgstr "標準模組 :mod:`random` 實作了一個隨機數生成器。用法很簡單: ::" -#: ../../faq/library.rst:796 +#: ../../faq/library.rst:718 msgid "" "import random\n" "random.random()" @@ -1322,41 +1307,41 @@ msgstr "" "import random\n" "random.random()" -#: ../../faq/library.rst:799 +#: ../../faq/library.rst:721 msgid "This returns a random floating-point number in the range [0, 1)." msgstr "這將回傳 [0, 1) 範圍內的隨機浮點數。" -#: ../../faq/library.rst:801 +#: ../../faq/library.rst:723 msgid "" "There are also many other specialized generators in this module, such as:" msgstr "該模組中還有許多其他專用生成器,例如:" -#: ../../faq/library.rst:803 +#: ../../faq/library.rst:725 msgid "``randrange(a, b)`` chooses an integer in the range [a, b)." msgstr "``randrange(a, b)`` 會選擇 [a, b) 範圍內的一個整數。" -#: ../../faq/library.rst:804 +#: ../../faq/library.rst:726 msgid "``uniform(a, b)`` chooses a floating-point number in the range [a, b)." msgstr "``uniform(a, b)`` 會選擇 [a, b) 範圍內的浮點數。" -#: ../../faq/library.rst:805 +#: ../../faq/library.rst:727 msgid "" "``normalvariate(mean, sdev)`` samples the normal (Gaussian) distribution." msgstr "``normalvariate(mean, sdev)`` 對常態(高斯)分佈進行取樣 (sample)。" -#: ../../faq/library.rst:807 +#: ../../faq/library.rst:729 msgid "Some higher-level functions operate on sequences directly, such as:" msgstr "一些更高階的函式會直接對序列進行操作,例如:" -#: ../../faq/library.rst:809 +#: ../../faq/library.rst:731 msgid "``choice(S)`` chooses a random element from a given sequence." msgstr "``choice(S)`` 會從給定序列中選擇一個隨機元素。" -#: ../../faq/library.rst:810 +#: ../../faq/library.rst:732 msgid "``shuffle(L)`` shuffles a list in-place, i.e. permutes it randomly." msgstr "``shuffle(L)`` 會原地 (in-place) 打亂 list,即隨機排列它。" -#: ../../faq/library.rst:812 +#: ../../faq/library.rst:734 msgid "" "There's also a ``Random`` class you can instantiate to create independent " "multiple random number generators." diff --git a/faq/programming.po b/faq/programming.po index 33bec77f43e..91d2d4b7ae2 100644 --- a/faq/programming.po +++ b/faq/programming.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -7,9 +7,9 @@ # hsiao yi , 2016 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-04-06 00:16+0000\n" +"POT-Creation-Date: 2025-09-08 15:25+0800\n" "PO-Revision-Date: 2024-04-25 14:17+0800\n" "Last-Translator: KNChiu \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -45,8 +45,8 @@ msgstr "有的。" #: ../../faq/programming.rst:19 msgid "" -"Several debuggers for Python are described below, and the built-in function :" -"func:`breakpoint` allows you to drop into any of them." +"Several debuggers for Python are described below, and the built-in " +"function :func:`breakpoint` allows you to drop into any of them." msgstr "" "下面描述了幾個 Python 除錯器,內建函式 :func:`breakpoint` 允許你進入其中任何" "一個。" @@ -340,10 +340,11 @@ msgid "" "a component of an imported module. This clutter would defeat the usefulness " "of the ``global`` declaration for identifying side-effects." msgstr "" -"雖然起初有點令人驚訝,但稍加考慮就可以解釋這一點。一方面,要求 :keyword:" -"`global` 分配的變數可以防止意外的副作用。另一方面,如果所有全域參照都需要 " -"``global``,那麼你將一直使用 ``global``。你必須將對內建函式或引入模組的組件的" -"每個參照聲明為全域。這種混亂會破壞用於識別副作用的 ``global`` 聲明的有用性。" +"雖然起初有點令人驚訝,但稍加考慮就可以解釋這一點。一方面,要" +"求 :keyword:`global` 分配的變數可以防止意外的副作用。另一方面,如果所有全域參" +"照都需要 ``global``,那麼你將一直使用 ``global``。你必須將對內建函式或引入模" +"組的組件的每個參照聲明為全域。這種混亂會破壞用於識別副作用的 ``global`` 聲明" +"的有用性。" #: ../../faq/programming.rst:208 msgid "" @@ -556,8 +557,8 @@ msgstr "如果你按以下順序引入模組,這是一個很好的做法:" #: ../../faq/programming.rst:301 msgid "" -"standard library modules -- e.g. :mod:`sys`, :mod:`os`, :mod:`argparse`, :" -"mod:`re`" +"standard library modules -- " +"e.g. :mod:`sys`, :mod:`os`, :mod:`argparse`, :mod:`re`" msgstr "" "標準函式庫模組 —— 例如 :mod:`sys`、:mod:`os`、:mod:`argparse`、:mod:`re`" @@ -637,8 +638,8 @@ msgstr "" "入移動到局部範圍內,例如在函式定義內。如果根據程式的執行方式,許多引入是不必" "要的,則此技術特別有用。如果模組僅在該函式中使用,你可能還想將引入移動到該函" "式中。請注意,由於模組的一次性初始化,第一次載入模組可能很昂貴,但多次載入模" -"組實際上是免費的,只需幾次字典查詢。即使模組名稱超出範圍,該模組也可能在 :" -"data:`sys.modules` 中可用。" +"組實際上是免費的,只需幾次字典查詢。即使模組名稱超出範圍,該模組也可能" +"在 :data:`sys.modules` 中可用。" #: ../../faq/programming.rst:338 msgid "Why are default values shared between objects?" @@ -809,13 +810,13 @@ msgstr "引數 (arguments) 和參數 (parameters) 有什麼區別?" msgid "" ":term:`Parameters ` are defined by the names that appear in a " "function definition, whereas :term:`arguments ` are the values " -"actually passed to a function when calling it. Parameters define what :term:" -"`kind of arguments ` a function can accept. For example, given " -"the function definition::" +"actually passed to a function when calling it. Parameters define " +"what :term:`kind of arguments ` a function can accept. For " +"example, given the function definition::" msgstr "" ":term:`參數 `\\ 由出現在函式定義中的名稱定義,而\\ :term:`引數 " -"`\\ 是呼叫函式時實際傳遞給函式的值。參數定義函式可以接受的\\ :term:" -"`引數種類 `。例如,給定以下函式定義: ::" +"`\\ 是呼叫函式時實際傳遞給函式的值。參數定義函式可以接受的" +"\\ :term:`引數種類 `。例如,給定以下函式定義: ::" #: ../../faq/programming.rst:423 msgid "" @@ -894,10 +895,11 @@ msgid "" msgstr "list 是 :term:`mutable`,這意味著你可以變更它們的內容。" #: ../../faq/programming.rst:457 +#, fuzzy msgid "" -"After the call to :meth:`!append`, the content of the mutable object has " -"changed from ``[]`` to ``[10]``. Since both the variables refer to the same " -"object, using either name accesses the modified value ``[10]``." +"After the call to :meth:`~sequence.append`, the content of the mutable " +"object has changed from ``[]`` to ``[10]``. Since both the variables refer " +"to the same object, using either name accesses the modified value ``[10]``." msgstr "" "在呼叫 :meth:`!append` 之後,可變物件的內容從 ``[]`` 變成了 ``[10]``。由於這" "兩個變數都參照同一個物件,因此使用任一名稱都可以存取修改後的值 ``[10]``。" @@ -937,7 +939,7 @@ msgid "" msgstr "" "我們可以看到,在這種情況下,``x`` 和 ``y`` 不再相等。這是因為整數是不可變的," "當我們做 x = x + 1 時,我們並沒有透過增加它的值來改變 int 5 ;相反,我們正在" -"建立一個新物件(int ``6``)並將其分配給``x``(也就是說,更改``x``指向的物" +"建立一個新物件(int ``6``)並將其分配給``x``\\ (也就是說,更改``x``指向的物" "件)。在這個賦值之後,我們有兩個物件(整數 ``6`` 和 ``5``)和兩個參照它們的變" "數(``x`` 現在指的是 ``6`` 但 ``y`` 仍然指的是``5``)。" @@ -956,9 +958,9 @@ msgstr "" "一些操作(例如 ``y.append(10)`` 和 ``y.sort()``)會改變物件,而表面上相似的操" "作(例如 ``y = y + [10]`` 和: func:`sorted(y) `) 建立一個新物件。通" "常在 Python 中(以及在標準函式庫中的所有情況下)改變物件的方法將回傳 " -"``None`` 以幫助避免混淆這兩種型別的操作。因此,如果你錯誤地編寫了 ``y." -"sort()``,認為它會為你提供 ``y`` 的排序副本,那麼你最終會得到 ``None``,這可" -"能會導致你的程式生成一個容易診斷的錯誤。" +"``None`` 以幫助避免混淆這兩種型別的操作。因此,如果你錯誤地編寫了 " +"``y.sort()``,認為它會為你提供 ``y`` 的排序副本,那麼你最終會得到 ``None``," +"這可能會導致你的程式生成一個容易診斷的錯誤。" #: ../../faq/programming.rst:488 #, fuzzy @@ -1292,8 +1294,8 @@ msgstr "" #: ../../faq/programming.rst:641 #, fuzzy msgid "" -"Some objects can be copied more easily. Dictionaries have a :meth:`~dict." -"copy` method::" +"Some objects can be copied more easily. Dictionaries have " +"a :meth:`~dict.copy` method::" msgstr "可以更輕鬆地複製某些物件。字典有一個 :meth:`~dict.copy` 方法: ::" #: ../../faq/programming.rst:644 @@ -1562,8 +1564,8 @@ msgid "" "only parameters. Its documentation looks like this::" msgstr "" "函式引數list中的斜線表示它前面的參數是位置參數。僅位置參數是沒有外部可用名稱" -"的參數。在呼叫接受僅位置參數的函式時,參數僅根據其位置對映到參數。例如,:" -"func:`divmod` 是一個只接受位置參數的函式。它的文件看起來像這樣: ::" +"的參數。在呼叫接受僅位置參數的函式時,參數僅根據其位置對映到參數。例" +"如,:func:`divmod` 是一個只接受位置參數的函式。它的文件看起來像這樣: ::" #: ../../faq/programming.rst:786 msgid "" @@ -1585,8 +1587,8 @@ msgid "" "positional-only. Thus, calling :func:`divmod` with keyword arguments would " "lead to an error::" msgstr "" -"參數串列最後的斜線表示兩個參數都是僅限位置參數。因此使用關鍵字引數呼叫 :func:" -"`divmod` 會導致錯誤: ::" +"參數串列最後的斜線表示兩個參數都是僅限位置參數。因此使用關鍵字引數呼" +"叫 :func:`divmod` 會導致錯誤: ::" #: ../../faq/programming.rst:796 msgid "" @@ -1701,8 +1703,8 @@ msgstr "如何取得 int 文字屬性而不是 SyntaxError?" #: ../../faq/programming.rst:850 msgid "" -"Trying to lookup an ``int`` literal attribute in the normal manner gives a :" -"exc:`SyntaxError` because the period is seen as a decimal point::" +"Trying to lookup an ``int`` literal attribute in the normal manner gives " +"a :exc:`SyntaxError` because the period is seen as a decimal point::" msgstr "" "嘗試以正常方式查找 ``int`` 字面值屬性會給出一個 :exc:`SyntaxError`,因為句點" "被視為小數點: ::" @@ -1738,8 +1740,8 @@ msgid "" "``int('144') == 144``. Similarly, :func:`float` converts to a floating-" "point number, e.g. ``float('144') == 144.0``." msgstr "" -"對於整數,使用內建的 int 型別建構函式,例如``int('144') == 144``。同樣,:" -"func:`float` 轉換為浮點數,例如``浮動('144')== 144.0``。" +"對於整數,使用內建的 int 型別建構函式,例如``int('144') == 144``。同" +"樣,:func:`float` 轉換為浮點數,例如``浮動('144')== 144.0``。" #: ../../faq/programming.rst:875 #, fuzzy @@ -1793,14 +1795,14 @@ msgid "" "in type constructor :func:`str`. If you want a hexadecimal or octal " "representation, use the built-in functions :func:`hex` or :func:`oct`. For " "fancy formatting, see the :ref:`f-strings` and :ref:`formatstrings` " -"sections, e.g. ``\"{:04d}\".format(144)`` yields ``'0144'`` and ``\"{:.3f}\"." -"format(1.0/3.0)`` yields ``'0.333'``." +"sections, e.g. ``\"{:04d}\".format(144)`` yields ``'0144'`` and ``\"{:.3f}" +"\".format(1.0/3.0)`` yields ``'0.333'``." msgstr "" -"例如,要將數字 ``144`` 轉換為字串 ``'144'``,請使用內建型別建構函式 :func:" -"`str`。如果你想要十六進製或八進製表示,請使用內建函式 :func:`hex` 或 :func:" -"`oct`。對於精美的格式,請參閱:ref:`f-strings` 和:ref:`formatstrings` 部分,例" -"如``\"{:04d}\".format(144)`` 產生 ``'0144'`` 和 ``\"{:.3f}\"." -"format(1.0/3.0)`` 產生 ``'0.333'`` ." +"例如,要將數字 ``144`` 轉換為字串 ``'144'``,請使用內建型別建構函" +"式 :func:`str`。如果你想要十六進製或八進製表示,請使用內建函式 :func:`hex` " +"或 :func:`oct`。對於精美的格式,請參閱:ref:`f-strings` " +"和:ref:`formatstrings` 部分,例如``\"{:04d}\".format(144)`` 產生 ``'0144'`` " +"和 ``\"{:.3f}\".format(1.0/3.0)`` 產生 ``'0.333'`` ." #: ../../faq/programming.rst:906 msgid "How do I modify a string in place?" @@ -2017,15 +2019,15 @@ msgstr "不是這樣的。" msgid "" "For simple input parsing, the easiest approach is usually to split the line " "into whitespace-delimited words using the :meth:`~str.split` method of " -"string objects and then convert decimal strings to numeric values using :" -"func:`int` or :func:`float`. :meth:`!split` supports an optional \"sep\" " -"parameter which is useful if the line uses something other than whitespace " -"as a separator." +"string objects and then convert decimal strings to numeric values " +"using :func:`int` or :func:`float`. :meth:`!split` supports an optional " +"\"sep\" parameter which is useful if the line uses something other than " +"whitespace as a separator." msgstr "" "對於簡單的輸入解析,最簡單的方法通常是使用字串物件的 :meth:`~str.split` 方法" -"將行拆分為以空格分隔的單詞,然後使用 :func:`int` 或將十進製字串轉換為數值:" -"func:`浮動`。 :meth:`!split` 支援可選的 \"sep\" 參數,如果該行使用空格以外的" -"其他內容作為分隔符,該參數很有用。" +"將行拆分為以空格分隔的單詞,然後使用 :func:`int` 或將十進製字串轉換為數" +"值:func:`浮動`。 :meth:`!split` 支援可選的 \"sep\" 參數,如果該行使用空格以外" +"的其他內容作為分隔符,該參數很有用。" #: ../../faq/programming.rst:1019 #, fuzzy @@ -2175,8 +2177,8 @@ msgid "" "You should always find the hot spots in your program *before* attempting to " "optimize any code (see the :mod:`profile` module)." msgstr "" -"在嘗試最佳化任何程式碼\\ *之前*,你應該始終找到程式中的熱點(請參閱 :mod:" -"`profile` 模組)。" +"在嘗試最佳化任何程式碼\\ *之前*,你應該始終找到程式中的熱點(請參" +"閱 :mod:`profile` 模組)。" #: ../../faq/programming.rst:1084 #, fuzzy @@ -2231,9 +2233,9 @@ msgid "" "When the standard library provides a primitive for doing something, it is " "likely (although not guaranteed) to be faster than any alternative you may " "come up with. This is doubly true for primitives written in C, such as " -"builtins and some extension types. For example, be sure to use either the :" -"meth:`list.sort` built-in method or the related :func:`sorted` function to " -"do sorting (and see the :ref:`sortinghowto` for examples of moderately " +"builtins and some extension types. For example, be sure to use either " +"the :meth:`list.sort` built-in method or the related :func:`sorted` function " +"to do sorting (and see the :ref:`sortinghowto` for examples of moderately " "advanced usage)." msgstr "" "當標準函式庫提供用於執行某些操作的原語時,它很可能(儘管不能保證)比你可能想" @@ -2269,8 +2271,8 @@ msgstr "" "如果你已經達到純 Python 所能允許的極限,可以使用一些工具讓你走得更遠。例如," "`Cython `_ 可以將稍微修改過的 Python 程式碼編譯成 C 擴" "充,並且可以在許多不同的平台上使用。Cython 可以利用編譯(和可選的型別註釋)使" -"你的程式碼比解釋時快得多。如果你對自己的 C 程式設計技能有信心,你也可以\\ :" -"ref:`自己編寫一個 C 擴充模組 `。" +"你的程式碼比解釋時快得多。如果你對自己的 C 程式設計技能有信心,你也可以" +"\\ :ref:`自己編寫一個 C 擴充模組 `。" #: ../../faq/programming.rst:1125 msgid "" @@ -2303,8 +2305,8 @@ msgid "" "To accumulate many :class:`str` objects, the recommended idiom is to place " "them into a list and call :meth:`str.join` at the end::" msgstr "" -"要累積許多 :class:`str` 物件,推薦的習慣用法是將它們放入list中並在末尾呼叫 :" -"meth:`str.join`: ::" +"要累積許多 :class:`str` 物件,推薦的習慣用法是將它們放入list中並在末尾呼" +"叫 :meth:`str.join`: ::" #: ../../faq/programming.rst:1141 msgid "" @@ -2476,8 +2478,8 @@ msgstr "" #: ../../faq/programming.rst:1220 msgid "" -"If all elements of the list may be used as set keys (i.e. they are all :term:" -"`hashable`) this is often faster ::" +"If all elements of the list may be used as set keys (i.e. they are " +"all :term:`hashable`) this is often faster ::" msgstr "" "如果串列的所有元素都可以做為集合的鍵(即它們都必須是 :term:`hashable`),那這" "通常會更快: ::" @@ -2673,8 +2675,8 @@ msgstr "如何將方法或函式應用於物件序列?" #: ../../faq/programming.rst:1327 #, fuzzy msgid "" -"To call a method or function and accumulate the return values is a list, a :" -"term:`list comprehension` is an elegant solution::" +"To call a method or function and accumulate the return values is a list, " +"a :term:`list comprehension` is an elegant solution::" msgstr "" "呼叫一個方法或函式並累積回傳值是一個list,一個 :term:`list comprehension` 是" "一個優雅的解決方案: ::" @@ -2794,7 +2796,6 @@ msgid "" msgstr "產生錯誤的是操作的賦值部分,因為元組是不可變的。" #: ../../faq/programming.rst:1382 -#, fuzzy msgid "When you write something like::" msgstr "當你寫這樣的東西時: ::" @@ -2806,6 +2807,11 @@ msgid "" " ...\n" "TypeError: 'tuple' object does not support item assignment" msgstr "" +">>> a_tuple = (['foo'], 'bar')\n" +">>> a_tuple[0] += ['item']\n" +"Traceback (most recent call last):\n" +" ...\n" +"TypeError: 'tuple' object does not support item assignment" #: ../../faq/programming.rst:1390 #, fuzzy @@ -2829,14 +2835,15 @@ msgid "" "an :meth:`~object.__iadd__` magic method, it gets called when the ``+=`` " "augmented assignment is executed, and its return value is what gets used in " "the assignment statement; and (b) for lists, :meth:`!__iadd__` is equivalent " -"to calling :meth:`!extend` on the list and returning the list. That's why " -"we say that for lists, ``+=`` is a \"shorthand\" for :meth:`!list.extend`::" +"to calling :meth:`~sequence.extend` on the list and returning the list. " +"That's why we say that for lists, ``+=`` is a \"shorthand\" " +"for :meth:`list.extend`::" msgstr "" -"要了解為什麼會發生這種情況,你需要知道 (a) 如果一個物件實作了一個 :meth:" -"`~object.__iadd__` 魔術方法,它會在執行 ``+=`` 增廣賦值時被呼叫,並且它的回傳" -"value 是賦值陳述式中使用的值; (b) 對於list,:meth:`!__iadd__` 相當於在list上" -"呼叫 :meth:`!extend` 並回傳list。這就是為什麼我們說對於list,``+=`` 是 :meth:" -"`!list.extend` 的「簡寫」: ::" +"要了解為什麼會發生這種情況,你需要知道 (a) 如果一個物件實作了一" +"個 :meth:`~object.__iadd__` 魔術方法,它會在執行 ``+=`` 增廣賦值時被呼叫,並" +"且它的回傳value 是賦值陳述式中使用的值; (b) 對於list,:meth:`!__iadd__` 相當" +"於在list上呼叫 :meth:`!extend` 並回傳list。這就是為什麼我們說對於list," +"``+=`` 是 :meth:`!list.extend` 的「簡寫」: ::" #: ../../faq/programming.rst:1404 msgid "" @@ -3007,8 +3014,8 @@ msgstr "什麼是方法 (method)?" #: ../../faq/programming.rst:1481 #, fuzzy msgid "" -"A method is a function on some object ``x`` that you normally call as ``x." -"name(arguments...)``. Methods are defined as functions inside the class " +"A method is a function on some object ``x`` that you normally call as " +"``x.name(arguments...)``. Methods are defined as functions inside the class " "definition::" msgstr "" "方法是一些物件 ``x`` 上的函式,你通常將其稱為 ``x.name(arguments...)`` 。方法" @@ -3067,15 +3074,15 @@ msgstr "" #: ../../faq/programming.rst:1511 msgid "" -"Note that :func:`isinstance` also checks for virtual inheritance from an :" -"term:`abstract base class`. So, the test will return ``True`` for a " +"Note that :func:`isinstance` also checks for virtual inheritance from " +"an :term:`abstract base class`. So, the test will return ``True`` for a " "registered class even if hasn't directly or indirectly inherited from it. " "To test for \"true inheritance\", scan the :term:`MRO` of the class:" msgstr "" "請注意,:func:`isinstance` 還會檢查來自\\ :term:`抽象基底類別 (abstract base " "class) ` 的虛擬繼承。因此對已註冊類別的檢驗會回傳 " -"``True``,即使沒有直接或間接繼承自它。要測試「真正繼承」,請掃描該類別的 :" -"term:`MRO`:" +"``True``,即使沒有直接或間接繼承自它。要測試「真正繼承」,請掃描該類別" +"的 :term:`MRO`:" #: ../../faq/programming.rst:1516 msgid "" @@ -3244,29 +3251,29 @@ msgstr "" #, fuzzy msgid "" "Here the ``UpperOut`` class redefines the ``write()`` method to convert the " -"argument string to uppercase before calling the underlying ``self._outfile." -"write()`` method. All other methods are delegated to the underlying ``self." -"_outfile`` object. The delegation is accomplished via the :meth:`~object." -"__getattr__` method; consult :ref:`the language reference ` for more information about controlling attribute access." +"argument string to uppercase before calling the underlying " +"``self._outfile.write()`` method. All other methods are delegated to the " +"underlying ``self._outfile`` object. The delegation is accomplished via " +"the :meth:`~object.__getattr__` method; consult :ref:`the language reference " +"` for more information about controlling attribute access." msgstr "" -"這裡的 ``UpperOut`` 類別重新定義了``write()`` 方法,在呼叫底層的``self." -"_outfile.write()`` 方法之前將引數字串轉換為大寫。所有其他方法都委託給底層的 " -"``self._outfile`` 物件。委託是透過 :meth:`~object.__getattr__` 方法完成的;有" -"關控制屬性存取的更多資訊,請參閱語言參考 。" +"這裡的 ``UpperOut`` 類別重新定義了``write()`` 方法,在呼叫底層的" +"``self._outfile.write()`` 方法之前將引數字串轉換為大寫。所有其他方法都委託給" +"底層的 ``self._outfile`` 物件。委託是透過 :meth:`~object.__getattr__` 方法完" +"成的;有關控制屬性存取的更多資訊,請參閱語言參考 。" #: ../../faq/programming.rst:1605 #, fuzzy msgid "" "Note that for more general cases delegation can get trickier. When " -"attributes must be set as well as retrieved, the class must define a :meth:" -"`~object.__setattr__` method too, and it must do so carefully. The basic " -"implementation of :meth:`!__setattr__` is roughly equivalent to the " +"attributes must be set as well as retrieved, the class must define " +"a :meth:`~object.__setattr__` method too, and it must do so carefully. The " +"basic implementation of :meth:`!__setattr__` is roughly equivalent to the " "following::" msgstr "" "請注意,對於更一般的情況,委託可能會變得更加棘手。當必須設定和檢索屬性時,該" -"類別也必須定義一個 :meth:`~object.__setattr__` 方法,而且必須小心謹慎。 :" -"meth:`!__setattr__` 的基本實作大致等同於以下: ::" +"類別也必須定義一個 :meth:`~object.__setattr__` 方法,而且必須小心謹" +"慎。 :meth:`!__setattr__` 的基本實作大致等同於以下: ::" #: ../../faq/programming.rst:1610 msgid "" @@ -3284,8 +3291,9 @@ msgstr "" #: ../../faq/programming.rst:1616 msgid "" -"Many :meth:`~object.__setattr__` implementations call :meth:`!object." -"__setattr__` to set an attribute on self without causing infinite recursion::" +"Many :meth:`~object.__setattr__` implementations call :meth:`!" +"object.__setattr__` to set an attribute on self without causing infinite " +"recursion::" msgstr "" "許多 :meth:`~object.__setattr__` 的實作會呼叫 :meth:`!object.__setattr__` 以" "設定 self 的屬性,而不會導致無限遞迴。" @@ -3304,8 +3312,8 @@ msgstr "" #: ../../faq/programming.rst:1624 msgid "" -"Alternatively, it is possible to set attributes by inserting entries into :" -"attr:`self.__dict__ ` directly." +"Alternatively, it is possible to set attributes by inserting entries " +"into :attr:`self.__dict__ ` directly." msgstr "" #: ../../faq/programming.rst:1629 @@ -3624,9 +3632,9 @@ msgstr "這有幾個可能的原因。" #: ../../faq/programming.rst:1782 msgid "" -"The :keyword:`del` statement does not necessarily call :meth:`~object." -"__del__` -- it simply decrements the object's reference count, and if this " -"reaches zero :meth:`!__del__` is called." +"The :keyword:`del` statement does not necessarily " +"call :meth:`~object.__del__` -- it simply decrements the object's reference " +"count, and if this reaches zero :meth:`!__del__` is called." msgstr "" ":keyword:`del` 陳述式不一定會呼叫 :meth:`~object.__del__` -- 它只是減少物件的" "參照計數,如果達到零則呼叫 :meth:`!__del__`。" @@ -3685,8 +3693,8 @@ msgid "" "Finally, if your :meth:`!__del__` method raises an exception, a warning " "message is printed to :data:`sys.stderr`." msgstr "" -"最後,如果你的 :meth:`!__del__` 方法引發例外,則會將一條警告訊息印出到 :data:" -"`sys.stderr`。" +"最後,如果你的 :meth:`!__del__` 方法引發例外,則會將一條警告訊息印出" +"到 :data:`sys.stderr`。" #: ../../faq/programming.rst:1822 msgid "How do I get a list of all instances of a given class?" @@ -3865,8 +3873,8 @@ msgid "" "implement a method that behaves like :meth:`dict.pop`:" msgstr "" "當 ``None`` 是有效輸入值時,檢測可選引數可能會很棘手。在這些情況下,你可以建" -"立一個保證與其他物件不同的單例哨兵物件。例如,這裡是如何實作一個行為類似於 :" -"meth:`dict.pop` 的方法:" +"立一個保證與其他物件不同的單例哨兵物件。例如,這裡是如何實作一個行為類似" +"於 :meth:`dict.pop` 的方法:" #: ../../faq/programming.rst:1917 msgid "" @@ -3903,8 +3911,8 @@ msgstr "" #: ../../faq/programming.rst:1934 msgid "" -"For example, here is the implementation of :meth:`!collections.abc.Sequence." -"__contains__`::" +"For example, here is the implementation of :meth:`!" +"collections.abc.Sequence.__contains__`::" msgstr "" "例如,以下是 :meth:`!collections.abc.Sequence.__contains__` 的實作: ::" @@ -3935,9 +3943,9 @@ msgid "" "*after* an instance is created, which is too late to alter data in an " "immutable instance." msgstr "" -"當對不可變型別進行子類別化時,覆蓋 :meth:`~object.__new__` 方法而不是 :meth:" -"`~object.__init__` 方法。後者僅在*建立實例後*運行,這為時已晚,無法更改不可變" -"實例中的資料。" +"當對不可變型別進行子類別化時,覆蓋 :meth:`~object.__new__` 方法而不" +"是 :meth:`~object.__init__` 方法。後者僅在*建立實例後*運行,這為時已晚,無法" +"更改不可變實例中的資料。" #: ../../faq/programming.rst:1952 msgid "" @@ -4020,12 +4028,14 @@ msgstr "如何快取方法呼叫?" #: ../../faq/programming.rst:1997 #, fuzzy msgid "" -"The two principal tools for caching methods are :func:`functools." -"cached_property` and :func:`functools.lru_cache`. The former stores results " -"at the instance level and the latter at the class level." +"The two principal tools for caching methods " +"are :func:`functools.cached_property` and :func:`functools.lru_cache`. The " +"former stores results at the instance level and the latter at the class " +"level." msgstr "" -"快取方法的兩個主要工具是 func:`functools.cached_property` 和 :func:" -"`functools.lru_cache`。前者在實例級別儲存結果,後者在類別級別儲存結果。" +"快取方法的兩個主要工具是 func:`functools.cached_property` " +"和 :func:`functools.lru_cache`。前者在實例級別儲存結果,後者在類別級別儲存結" +"果。" #: ../../faq/programming.rst:2002 #, fuzzy @@ -4110,12 +4120,13 @@ msgstr "" #, fuzzy msgid "" "To make the *lru_cache* approach work when the *station_id* is mutable, the " -"class needs to define the :meth:`~object.__eq__` and :meth:`~object." -"__hash__` methods so that the cache can detect relevant attribute updates::" +"class needs to define the :meth:`~object.__eq__` " +"and :meth:`~object.__hash__` methods so that the cache can detect relevant " +"attribute updates::" msgstr "" -"要在 *station_id* 可變時使 *lru_cache* 方法起作用,該類別需要定義 :meth:" -"`~object.__eq__` 和 :meth:`~object.__hash__` 方法,以便快取可以檢測相關屬性更" -"新: ::" +"要在 *station_id* 可變時使 *lru_cache* 方法起作用,該類別需要定" +"義 :meth:`~object.__eq__` 和 :meth:`~object.__hash__` 方法,以便快取可以檢測" +"相關屬性更新: ::" #: ../../faq/programming.rst:2053 msgid "" @@ -4162,8 +4173,8 @@ msgstr "" "第一次引入模組時(或者源檔案自建立目前編譯檔案後發生更改時)應在 " "``__pycache__`` 的子目錄中建立包含編譯程式碼的 ``.pyc`` 檔案包含 .py 檔案的目" "錄。 ``.pyc`` 檔案的檔案名以與``.py`` 檔案相同的名稱開頭,以``.pyc`` 結尾,中" -"間部分依賴於特定的``python `` 建立它的二進製檔案。(有關詳細資訊,請參閱 :" -"pep:`3147`。)" +"間部分依賴於特定的``python `` 建立它的二進製檔案。(有關詳細資訊,請參" +"閱 :pep:`3147`。)" #: ../../faq/programming.rst:2088 #, fuzzy @@ -4194,10 +4205,10 @@ msgstr "" #: ../../faq/programming.rst:2098 #, fuzzy msgid "" -"Running Python on a top level script is not considered an import and no ``." -"pyc`` will be created. For example, if you have a top-level module ``foo." -"py`` that imports another module ``xyz.py``, when you run ``foo`` (by typing " -"``python foo.py`` as a shell command), a ``.pyc`` will be created for " +"Running Python on a top level script is not considered an import and no " +"``.pyc`` will be created. For example, if you have a top-level module " +"``foo.py`` that imports another module ``xyz.py``, when you run ``foo`` (by " +"typing ``python foo.py`` as a shell command), a ``.pyc`` will be created for " "``xyz`` because ``xyz`` is imported, but no ``.pyc`` file will be created " "for ``foo`` since ``foo.py`` isn't being imported." msgstr "" @@ -4208,9 +4219,9 @@ msgstr "" #: ../../faq/programming.rst:2105 msgid "" -"If you need to create a ``.pyc`` file for ``foo`` -- that is, to create a ``." -"pyc`` file for a module that is not imported -- you can, using the :mod:" -"`py_compile` and :mod:`compileall` modules." +"If you need to create a ``.pyc`` file for ``foo`` -- that is, to create a " +"``.pyc`` file for a module that is not imported -- you can, using " +"the :mod:`py_compile` and :mod:`compileall` modules." msgstr "" "如果你需要為 ``foo`` 建立一個 ``.pyc`` 檔案 —— 也就是說,要為一個未引入的模組" "建立一個 ``.pyc`` 檔案 —— 你可以使用 :mod:`py_compile` 和 :mod:`compileall` " @@ -4388,11 +4399,11 @@ msgstr "此問題有(至少)三種可能的解決方法。" #: ../../faq/programming.rst:2178 #, fuzzy msgid "" -"Guido van Rossum recommends avoiding all uses of ``from import ..." -"``, and placing all code inside functions. Initializations of global " -"variables and class variables should use constants or built-in functions " -"only. This means everything from an imported module is referenced as " -"``.``." +"Guido van Rossum recommends avoiding all uses of ``from " +"import ...``, and placing all code inside functions. Initializations of " +"global variables and class variables should use constants or built-in " +"functions only. This means everything from an imported module is referenced " +"as ``.``." msgstr "" "Guido van Rossum 建議避免使用``from import ...``,並將所有程式碼放在" "函式中。全域變數和類別變數的初始化應該只使用常數或內建函式。這意味著來自引入" diff --git a/faq/windows.po b/faq/windows.po index 34374de463f..9c39108b538 100644 --- a/faq/windows.po +++ b/faq/windows.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -6,7 +6,7 @@ # Liang-Bo Wang , 2015 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-01 22:24+0800\n" "PO-Revision-Date: 2022-11-09 17:25+0800\n" diff --git a/glossary.po b/glossary.po index 4a87b00ac99..2512332f511 100644 --- a/glossary.po +++ b/glossary.po @@ -1,13 +1,13 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # Translators: # Steven Hsu , 2021-2022 # Matt Wang , 2021 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-08-27 00:15+0000\n" +"POT-Creation-Date: 2025-11-10 16:45+0000\n" "PO-Revision-Date: 2023-07-02 22:47+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -54,15 +54,16 @@ msgstr "" "號、花括號或三引號)內部,或是在指定一個裝飾器 (decorator) 之後,要輸入程式碼" "時,:term:`互動式 ` shell 顯示的預設 Python 提示字元。" -#: ../../glossary.rst:24 -msgid "The :const:`Ellipsis` built-in constant." -msgstr "內建常數 :const:`Ellipsis`。" +#: ../../glossary.rst:26 +msgid "" +"The three dots form of the :ref:`Ellipsis ` object." +msgstr "" -#: ../../glossary.rst:25 +#: ../../glossary.rst:27 msgid "abstract base class" msgstr "abstract base class(抽象基底類別)" -#: ../../glossary.rst:27 +#: ../../glossary.rst:29 msgid "" "Abstract base classes complement :term:`duck-typing` by providing a way to " "define interfaces when other techniques like :func:`hasattr` would be clumsy " @@ -85,11 +86,24 @@ msgstr "" "模組)及 import 尋檢器和載入器(在 :mod:`importlib.abc` 模組)。你可以使用 :" "mod:`abc` 模組建立自己的 ABC。" -#: ../../glossary.rst:38 +#: ../../glossary.rst:40 +msgid "annotate function" +msgstr "annotate function(註釋函式)" + +#: ../../glossary.rst:42 +msgid "" +"A function that can be called to retrieve the :term:`annotations " +"` of an object. This function is accessible as the :attr:" +"`~object.__annotate__` attribute of functions, classes, and modules. " +"Annotate functions are a subset of :term:`evaluate functions `." +msgstr "" + +#: ../../glossary.rst:46 msgid "annotation" msgstr "annotation(註釋)" -#: ../../glossary.rst:40 +#: ../../glossary.rst:48 msgid "" "A label associated with a variable, a class attribute or a function " "parameter or return value, used by convention as a :term:`type hint`." @@ -97,32 +111,31 @@ msgstr "" "一個與變數、class 屬性、函式的參數或回傳值相關聯的標籤。照慣例,它被用來作" "為 :term:`type hint`\\ (型別提示)。" -#: ../../glossary.rst:44 +#: ../../glossary.rst:52 msgid "" "Annotations of local variables cannot be accessed at runtime, but " -"annotations of global variables, class attributes, and functions are stored " -"in the :attr:`__annotations__` special attribute of modules, classes, and " -"functions, respectively." +"annotations of global variables, class attributes, and functions can be " +"retrieved by calling :func:`annotationlib.get_annotations` on modules, " +"classes, and functions, respectively." msgstr "" -"在執行環境 (runtime),區域變數的註釋無法被存取,但全域變數、class 屬性和函式" -"的註解,會分別被儲存在模組、class 和函式的 :attr:`__annotations__` 特殊屬性" -"中。" +"在 runtime 的區域變數註釋無法被存取,但全域變數、類別屬性和函式的註釋,分別能" +"夠以對模組、類別和函式呼叫 :func:`annotationlib.get_annotations` 來取得。" -#: ../../glossary.rst:50 +#: ../../glossary.rst:57 msgid "" -"See :term:`variable annotation`, :term:`function annotation`, :pep:`484` " -"and :pep:`526`, which describe this functionality. Also see :ref:" +"See :term:`variable annotation`, :term:`function annotation`, :pep:`484`, :" +"pep:`526`, and :pep:`649`, which describe this functionality. Also see :ref:" "`annotations-howto` for best practices on working with annotations." msgstr "" -"請參閱 :term:`variable annotation`、:term:`function annotation`、:pep:`484` " -"和 :pep:`526`,這些章節皆有此功能的說明。關於註釋的最佳實踐方法也請參閱 :ref:" -"`annotations-howto`。" +"請參閱 :term:`variable annotation`、:term:`function annotation`、:pep:" +"`484`、:pep:`526` 和 :pep:`649`,這些章節皆有此功能的說明。關於註釋的最佳實踐" +"方法也請參閱 :ref:`annotations-howto`。" -#: ../../glossary.rst:54 +#: ../../glossary.rst:61 msgid "argument" msgstr "argument(引數)" -#: ../../glossary.rst:56 +#: ../../glossary.rst:63 msgid "" "A value passed to a :term:`function` (or :term:`method`) when calling the " "function. There are two kinds of argument:" @@ -130,7 +143,7 @@ msgstr "" "呼叫函式時被傳遞給 :term:`function`\\ (或 :term:`method`\\ )的值。引數有兩" "種:" -#: ../../glossary.rst:59 +#: ../../glossary.rst:66 msgid "" ":dfn:`keyword argument`: an argument preceded by an identifier (e.g. " "``name=``) in a function call or passed as a value in a dictionary preceded " @@ -142,7 +155,7 @@ msgstr "" "遞的引數。例如,``3`` 和 ``5`` 都是以下 :func:`complex` 呼叫中的關鍵字引" "數: ::" -#: ../../glossary.rst:64 +#: ../../glossary.rst:71 msgid "" "complex(real=3, imag=5)\n" "complex(**{'real': 3, 'imag': 5})" @@ -150,7 +163,7 @@ msgstr "" "complex(real=3, imag=5)\n" "complex(**{'real': 3, 'imag': 5})" -#: ../../glossary.rst:67 +#: ../../glossary.rst:74 msgid "" ":dfn:`positional argument`: an argument that is not a keyword argument. " "Positional arguments can appear at the beginning of an argument list and/or " @@ -161,7 +174,7 @@ msgstr "" "引數列表的起始處出現,和(或)作為 ``*`` 之後的 :term:`iterable`\\ (可疊代物" "件)中的元素被傳遞。例如,``3`` 和 ``5`` 都是以下呼叫中的位置引數: ::" -#: ../../glossary.rst:73 +#: ../../glossary.rst:80 msgid "" "complex(3, 5)\n" "complex(*(3, 5))" @@ -169,7 +182,7 @@ msgstr "" "complex(3, 5)\n" "complex(*(3, 5))" -#: ../../glossary.rst:76 +#: ../../glossary.rst:83 msgid "" "Arguments are assigned to the named local variables in a function body. See " "the :ref:`calls` section for the rules governing this assignment. " @@ -180,7 +193,7 @@ msgstr "" "\\ :ref:`calls`\\ 章節。在語法上,任何運算式都可以被用來表示一個引數;其評估" "值會被指定給區域變數。" -#: ../../glossary.rst:81 +#: ../../glossary.rst:88 msgid "" "See also the :term:`parameter` glossary entry, the FAQ question on :ref:`the " "difference between arguments and parameters `, " @@ -189,11 +202,11 @@ msgstr "" "另請參閱術語表的 :term:`parameter`\\ (參數)條目、常見問題中的\\ :ref:`引數" "和參數之間的差異 `,以及 :pep:`362`。" -#: ../../glossary.rst:84 +#: ../../glossary.rst:91 msgid "asynchronous context manager" msgstr "asynchronous context manager(非同步情境管理器)" -#: ../../glossary.rst:86 +#: ../../glossary.rst:93 msgid "" "An object which controls the environment seen in an :keyword:`async with` " "statement by defining :meth:`~object.__aenter__` and :meth:`~object." @@ -203,11 +216,11 @@ msgstr "" "meth:`~object.__aenter__` 和 :meth:`~object.__aexit__` method(方法)來控制" "的。由 :pep:`492` 引入。" -#: ../../glossary.rst:89 +#: ../../glossary.rst:96 msgid "asynchronous generator" msgstr "asynchronous generator(非同步產生器)" -#: ../../glossary.rst:91 +#: ../../glossary.rst:98 msgid "" "A function which returns an :term:`asynchronous generator iterator`. It " "looks like a coroutine function defined with :keyword:`async def` except " @@ -219,7 +232,7 @@ msgstr "" "function),但不同的是它包含了 :keyword:`yield` 運算式,能生成一系列可用於 :" "keyword:`async for` 迴圈的值。" -#: ../../glossary.rst:96 +#: ../../glossary.rst:103 msgid "" "Usually refers to an asynchronous generator function, but may refer to an " "*asynchronous generator iterator* in some contexts. In cases where the " @@ -229,7 +242,7 @@ msgstr "" "同步產生器疊代器 (asynchronous generator iterator)*。萬一想表達的意思不夠清" "楚,那就使用完整的術語,以避免歧義。" -#: ../../glossary.rst:100 +#: ../../glossary.rst:107 msgid "" "An asynchronous generator function may contain :keyword:`await` expressions " "as well as :keyword:`async for`, and :keyword:`async with` statements." @@ -237,16 +250,16 @@ msgstr "" "一個非同步產生器函式可能包含 :keyword:`await` 運算式,以及 :keyword:`async " "for` 和 :keyword:`async with` 陳述式。" -#: ../../glossary.rst:103 +#: ../../glossary.rst:110 msgid "asynchronous generator iterator" msgstr "asynchronous generator iterator(非同步產生器疊代器)" -#: ../../glossary.rst:105 +#: ../../glossary.rst:112 msgid "An object created by an :term:`asynchronous generator` function." msgstr "" "一個由 :term:`asynchronous generator`\\ (非同步產生器)函式所建立的物件。" -#: ../../glossary.rst:107 +#: ../../glossary.rst:114 msgid "" "This is an :term:`asynchronous iterator` which when called using the :meth:" "`~object.__anext__` method returns an awaitable object which will execute " @@ -258,7 +271,7 @@ msgstr "" "object),該物件將執行非同步產生器的函式主體,直到遇到下一個 :keyword:`yield` " "運算式。" -#: ../../glossary.rst:112 +#: ../../glossary.rst:119 msgid "" "Each :keyword:`yield` temporarily suspends processing, remembering the " "execution state (including local variables and pending try-statements). " @@ -271,11 +284,11 @@ msgstr "" "__anext__` 回傳的可等待物件有效地回復時,它會從停止的地方繼續執行。請參閱 :" "pep:`492` 和 :pep:`525`。" -#: ../../glossary.rst:117 +#: ../../glossary.rst:124 msgid "asynchronous iterable" msgstr "asynchronous iterable(非同步可疊代物件)" -#: ../../glossary.rst:119 +#: ../../glossary.rst:126 msgid "" "An object, that can be used in an :keyword:`async for` statement. Must " "return an :term:`asynchronous iterator` from its :meth:`~object.__aiter__` " @@ -285,11 +298,11 @@ msgstr "" "`~object.__aiter__` method 回傳一個 :term:`asynchronous iterator`\\ (非同步" "疊代器)。由 :pep:`492` 引入。" -#: ../../glossary.rst:122 +#: ../../glossary.rst:129 msgid "asynchronous iterator" msgstr "asynchronous iterator(非同步疊代器)" -#: ../../glossary.rst:124 +#: ../../glossary.rst:131 msgid "" "An object that implements the :meth:`~object.__aiter__` and :meth:`~object." "__anext__` methods. :meth:`~object.__anext__` must return an :term:" @@ -303,11 +316,44 @@ msgstr "" "method 所回傳的可等待物件,直到它引發 :exc:`StopAsyncIteration` 例外。由 :" "pep:`492` 引入。" -#: ../../glossary.rst:129 +#: ../../glossary.rst:136 +msgid "attached thread state" +msgstr "" + +#: ../../glossary.rst:139 +msgid "A :term:`thread state` that is active for the current OS thread." +msgstr "" + +#: ../../glossary.rst:141 +msgid "" +"When a :term:`thread state` is attached, the OS thread has access to the " +"full Python C API and can safely invoke the bytecode interpreter." +msgstr "" + +#: ../../glossary.rst:145 +msgid "" +"Unless a function explicitly notes otherwise, attempting to call the C API " +"without an attached thread state will result in a fatal error or undefined " +"behavior. A thread state can be attached and detached explicitly by the " +"user through the C API, or implicitly by the runtime, including during " +"blocking C calls and by the bytecode interpreter in between calls." +msgstr "" + +#: ../../glossary.rst:152 +msgid "" +"On most builds of Python, having an attached thread state implies that the " +"caller holds the :term:`GIL` for the current interpreter, so only one OS " +"thread can have an attached thread state at a given moment. In :term:`free-" +"threaded ` builds of Python, threads can concurrently hold " +"an attached thread state, allowing for true parallelism of the bytecode " +"interpreter." +msgstr "" + +#: ../../glossary.rst:158 msgid "attribute" msgstr "attribute(屬性)" -#: ../../glossary.rst:131 +#: ../../glossary.rst:160 msgid "" "A value associated with an object which is usually referenced by name using " "dotted expressions. For example, if an object *o* has an attribute *a* it " @@ -316,7 +362,7 @@ msgstr "" "一個與某物件相關聯的值,該值大多能透過使用點分隔運算式 (dotted expression) 的" "名稱被參照。例如,如果物件 *o* 有一個屬性 *a*,則該屬性能以 *o.a* 被參照。" -#: ../../glossary.rst:136 +#: ../../glossary.rst:165 msgid "" "It is possible to give an object an attribute whose name is not an " "identifier as defined by :ref:`identifiers`, for example using :func:" @@ -328,11 +374,11 @@ msgstr "" "別符 (identifier) 的屬性是有可能的,例如使用 :func:`setattr`。像這樣的屬性將" "無法使用點分隔運算式來存取,而是需要使用 :func:`getattr` 來取得它。" -#: ../../glossary.rst:141 +#: ../../glossary.rst:170 msgid "awaitable" msgstr "awaitable(可等待物件)" -#: ../../glossary.rst:143 +#: ../../glossary.rst:172 msgid "" "An object that can be used in an :keyword:`await` expression. Can be a :" "term:`coroutine` or an object with an :meth:`~object.__await__` method. See " @@ -342,11 +388,11 @@ msgstr "" "`coroutine`\\ (協程),或是一個有 :meth:`~object.__await__` method 的物件。" "另請參閱 :pep:`492`。" -#: ../../glossary.rst:146 +#: ../../glossary.rst:175 msgid "BDFL" msgstr "BDFL" -#: ../../glossary.rst:148 +#: ../../glossary.rst:177 msgid "" "Benevolent Dictator For Life, a.k.a. `Guido van Rossum `_, Python's creator." @@ -354,11 +400,11 @@ msgstr "" "Benevolent Dictator For Life(終身仁慈獨裁者),又名 `Guido van Rossum " "`_,Python 的創造者。" -#: ../../glossary.rst:150 +#: ../../glossary.rst:179 msgid "binary file" msgstr "binary file(二進位檔案)" -#: ../../glossary.rst:152 +#: ../../glossary.rst:181 msgid "" "A :term:`file object` able to read and write :term:`bytes-like objects " "`. Examples of binary files are files opened in binary " @@ -372,7 +418,7 @@ msgstr "" "`、:data:`sys.stdout.buffer `,以及 :class:`io." "BytesIO` 和 :class:`gzip.GzipFile` 實例。" -#: ../../glossary.rst:159 +#: ../../glossary.rst:188 msgid "" "See also :term:`text file` for a file object able to read and write :class:" "`str` objects." @@ -380,11 +426,11 @@ msgstr "" "另請參閱 :term:`text file`\\ (文字檔案),它是一個能夠讀取和寫入 :class:" "`str` 物件的檔案物件。" -#: ../../glossary.rst:161 +#: ../../glossary.rst:190 msgid "borrowed reference" msgstr "borrowed reference(借用參照)" -#: ../../glossary.rst:163 +#: ../../glossary.rst:192 msgid "" "In Python's C API, a borrowed reference is a reference to an object, where " "the code using the object does not own the reference. It becomes a dangling " @@ -396,7 +442,7 @@ msgstr "" "如,一次垃圾回收 (garbage collection) 可以移除對物件的最後一個 :term:`strong " "reference`\\ (強參照),而將該物件銷毀。" -#: ../../glossary.rst:169 +#: ../../glossary.rst:198 msgid "" "Calling :c:func:`Py_INCREF` on the :term:`borrowed reference` is recommended " "to convert it to a :term:`strong reference` in-place, except when the object " @@ -409,11 +455,11 @@ msgstr "" "借用參照之前被銷毀。:c:func:`Py_NewRef` 函式可用於建立一個新的 :term:`strong " "reference`。" -#: ../../glossary.rst:174 +#: ../../glossary.rst:203 msgid "bytes-like object" msgstr "bytes-like object(類位元組串物件)" -#: ../../glossary.rst:176 +#: ../../glossary.rst:205 msgid "" "An object that supports the :ref:`bufferobjects` and can export a C-:term:" "`contiguous` buffer. This includes all :class:`bytes`, :class:`bytearray`, " @@ -427,7 +473,7 @@ msgstr "" "物件,以及許多常見的 :class:`memoryview` 物件。類位元組串物件可用於處理二進位" "資料的各種運算;這些運算包括壓縮、儲存至二進位檔案和透過 socket(插座)發送。" -#: ../../glossary.rst:183 +#: ../../glossary.rst:212 msgid "" "Some operations need the binary data to be mutable. The documentation often " "refers to these as \"read-write bytes-like objects\". Example mutable " @@ -442,11 +488,11 @@ msgstr "" "的類位元組串物件」)中;這些物件包括 :class:`bytes`,以及 :class:`bytes` 物件" "的 :class:`memoryview`。" -#: ../../glossary.rst:191 +#: ../../glossary.rst:220 msgid "bytecode" msgstr "bytecode(位元組碼)" -#: ../../glossary.rst:193 +#: ../../glossary.rst:222 msgid "" "Python source code is compiled into bytecode, the internal representation of " "a Python program in the CPython interpreter. The bytecode is also cached in " @@ -465,18 +511,18 @@ msgstr "" "上是無法在不同的 Python 虛擬機器之間運作的,也不能在不同版本的 Python 之間保" "持穩定。" -#: ../../glossary.rst:203 +#: ../../glossary.rst:232 msgid "" "A list of bytecode instructions can be found in the documentation for :ref:" "`the dis module `." msgstr "" "位元組碼的指令列表可以在 :ref:`dis 模組 `\\ 的說明文件中找到。" -#: ../../glossary.rst:205 +#: ../../glossary.rst:234 msgid "callable" msgstr "callable(可呼叫物件)" -#: ../../glossary.rst:207 +#: ../../glossary.rst:236 msgid "" "A callable is an object that can be called, possibly with a set of arguments " "(see :term:`argument`), with the following syntax::" @@ -484,11 +530,11 @@ msgstr "" "一個 callable 是可以被呼叫的物件,呼叫時可能以下列形式帶有一組引數(請見 :" "term:`argument`): ::" -#: ../../glossary.rst:210 +#: ../../glossary.rst:239 msgid "callable(argument1, argument2, argumentN)" msgstr "callable(argument1, argument2, argumentN)" -#: ../../glossary.rst:212 +#: ../../glossary.rst:241 msgid "" "A :term:`function`, and by extension a :term:`method`, is a callable. An " "instance of a class that implements the :meth:`~object.__call__` method is " @@ -497,22 +543,22 @@ msgstr "" "一個 :term:`function` 與其延伸的 :term:`method` 都是 callable。一個有實作 :" "meth:`~object.__call__` 方法的 class 之實例也是個 callable。" -#: ../../glossary.rst:215 +#: ../../glossary.rst:244 msgid "callback" msgstr "callback(回呼)" -#: ../../glossary.rst:217 +#: ../../glossary.rst:246 msgid "" "A subroutine function which is passed as an argument to be executed at some " "point in the future." msgstr "" "作為引數被傳遞的一個副程式 (subroutine) 函式,會在未來的某個時間點被執行。" -#: ../../glossary.rst:219 +#: ../../glossary.rst:248 msgid "class" msgstr "class(類別)" -#: ../../glossary.rst:221 +#: ../../glossary.rst:250 msgid "" "A template for creating user-defined objects. Class definitions normally " "contain method definitions which operate on instances of the class." @@ -520,11 +566,11 @@ msgstr "" "一個用於建立使用者定義物件的模板。Class 的定義通常會包含 method 的定義,這些 " "method 可以在 class 的實例上進行操作。" -#: ../../glossary.rst:224 +#: ../../glossary.rst:253 msgid "class variable" msgstr "class variable(類別變數)" -#: ../../glossary.rst:226 +#: ../../glossary.rst:255 msgid "" "A variable defined in a class and intended to be modified only at class " "level (i.e., not in an instance of the class)." @@ -532,11 +578,11 @@ msgstr "" "一個在 class 中被定義,且應該只能在 class 層次(意即不是在 class 的實例中)被" "修改的變數。" -#: ../../glossary.rst:228 +#: ../../glossary.rst:257 msgid "closure variable" msgstr "closure variable(閉包變數)" -#: ../../glossary.rst:230 +#: ../../glossary.rst:259 msgid "" "A :term:`free variable` referenced from a :term:`nested scope` that is " "defined in an outer scope rather than being resolved at runtime from the " @@ -549,7 +595,7 @@ msgstr "" "用 :keyword:`nonlocal` 關鍵字明確定義以允許寫入存取,或者如果僅需讀取變數則隱" "式定義即可。" -#: ../../glossary.rst:235 +#: ../../glossary.rst:264 msgid "" "For example, in the ``inner`` function in the following code, both ``x`` and " "``print`` are :term:`free variables `, but only ``x`` is a " @@ -558,7 +604,7 @@ msgstr "" "例如在下面程式碼中的 ``inner`` 函式中,``x`` 和 ``print`` 都是\\ :term:`自由" "變數 `,但只有 ``x`` 是\\ *閉包變數*: ::" -#: ../../glossary.rst:238 +#: ../../glossary.rst:267 msgid "" "def outer():\n" " x = 0\n" @@ -576,7 +622,7 @@ msgstr "" " print(x)\n" " return inner" -#: ../../glossary.rst:246 +#: ../../glossary.rst:275 msgid "" "Due to the :attr:`codeobject.co_freevars` attribute (which, despite its " "name, only includes the names of closure variables rather than listing all " @@ -588,11 +634,11 @@ msgstr "" "名稱,而不是列出所有參照的自由變數),當預期含義是特指閉包變數時,有時候甚至" "也會使用更通用的\\ :term:`自由變數 `\\ 一詞。" -#: ../../glossary.rst:250 +#: ../../glossary.rst:279 msgid "complex number" msgstr "complex number(複數)" -#: ../../glossary.rst:252 +#: ../../glossary.rst:281 msgid "" "An extension of the familiar real number system in which all numbers are " "expressed as a sum of a real part and an imaginary part. Imaginary numbers " @@ -612,40 +658,40 @@ msgstr "" "相當進階的數學功能。如果你沒有察覺到對它們的需求,那麼幾乎能確定你可以安全地" "忽略它們。" -#: ../../glossary.rst:262 +#: ../../glossary.rst:291 msgid "context" msgstr "context(情境)" -#: ../../glossary.rst:264 +#: ../../glossary.rst:293 msgid "" "This term has different meanings depending on where and how it is used. Some " "common meanings:" msgstr "" -#: ../../glossary.rst:267 +#: ../../glossary.rst:296 msgid "" "The temporary state or environment established by a :term:`context manager` " "via a :keyword:`with` statement." msgstr "" -#: ../../glossary.rst:269 +#: ../../glossary.rst:298 msgid "" "The collection of key­value bindings associated with a particular :class:" "`contextvars.Context` object and accessed via :class:`~contextvars." "ContextVar` objects. Also see :term:`context variable`." msgstr "" -#: ../../glossary.rst:273 +#: ../../glossary.rst:302 msgid "" "A :class:`contextvars.Context` object. Also see :term:`current context`." msgstr "" "一個 :class:`contextvars.Context` 物件。另請參閱 :term:`current context`。" -#: ../../glossary.rst:275 +#: ../../glossary.rst:304 msgid "context management protocol" msgstr "context management protocol(情境管理協定)" -#: ../../glossary.rst:277 +#: ../../glossary.rst:306 msgid "" "The :meth:`~object.__enter__` and :meth:`~object.__exit__` methods called by " "the :keyword:`with` statement. See :pep:`343`." @@ -653,22 +699,22 @@ msgstr "" "由 :keyword:`with` 陳述式所呼叫的 :meth:`~object.__enter__` 和 :meth:" "`~object.__exit__` 方法。另請參閱 :pep:`343`。" -#: ../../glossary.rst:279 +#: ../../glossary.rst:308 msgid "context manager" msgstr "context manager(情境管理器)" -#: ../../glossary.rst:281 +#: ../../glossary.rst:310 msgid "" "An object which implements the :term:`context management protocol` and " "controls the environment seen in a :keyword:`with` statement. See :pep:" "`343`." msgstr "" -#: ../../glossary.rst:284 +#: ../../glossary.rst:313 msgid "context variable" msgstr "context variable(情境變數)" -#: ../../glossary.rst:286 +#: ../../glossary.rst:315 msgid "" "A variable whose value depends on which context is the :term:`current " "context`. Values are accessed via :class:`contextvars.ContextVar` objects. " @@ -676,11 +722,11 @@ msgid "" "asynchronous tasks." msgstr "" -#: ../../glossary.rst:290 +#: ../../glossary.rst:319 msgid "contiguous" msgstr "contiguous(連續的)" -#: ../../glossary.rst:294 +#: ../../glossary.rst:323 msgid "" "A buffer is considered contiguous exactly if it is either *C-contiguous* or " "*Fortran contiguous*. Zero-dimensional buffers are C and Fortran " @@ -697,11 +743,11 @@ msgstr "" "的順序瀏覽各個項目時,最後一個索引的變化最快。然而,在 Fortran contiguous 陣" "列中,第一個索引的變化最快。" -#: ../../glossary.rst:302 +#: ../../glossary.rst:331 msgid "coroutine" msgstr "coroutine(協程)" -#: ../../glossary.rst:304 +#: ../../glossary.rst:333 msgid "" "Coroutines are a more generalized form of subroutines. Subroutines are " "entered at one point and exited at another point. Coroutines can be " @@ -712,11 +758,11 @@ msgstr "" "在另一個時間點被退出。協程可以在許多不同的時間點被進入、退出和回復。它們能夠" "以 :keyword:`async def` 陳述式被實作。另請參閱 :pep:`492`。" -#: ../../glossary.rst:309 +#: ../../glossary.rst:338 msgid "coroutine function" msgstr "coroutine function(協程函式)" -#: ../../glossary.rst:311 +#: ../../glossary.rst:340 msgid "" "A function which returns a :term:`coroutine` object. A coroutine function " "may be defined with the :keyword:`async def` statement, and may contain :" @@ -727,11 +773,11 @@ msgstr "" "`async def` 陳述式被定義,並可能會包含 :keyword:`await`、:keyword:`async " "for` 和 :keyword:`async with` 關鍵字。這些關鍵字由 :pep:`492` 引入。" -#: ../../glossary.rst:316 +#: ../../glossary.rst:345 msgid "CPython" msgstr "CPython" -#: ../../glossary.rst:318 +#: ../../glossary.rst:347 msgid "" "The canonical implementation of the Python programming language, as " "distributed on `python.org `_. The term \"CPython\" " @@ -742,11 +788,11 @@ msgstr "" "`_ 上。「CPython」這個術語在必要時被使用,以區分此實" "作與其它語言的實作,例如 Jython 或 IronPython。" -#: ../../glossary.rst:322 +#: ../../glossary.rst:351 msgid "current context" msgstr "" -#: ../../glossary.rst:324 +#: ../../glossary.rst:353 msgid "" "The :term:`context` (:class:`contextvars.Context` object) that is currently " "used by :class:`~contextvars.ContextVar` objects to access (get or set) the " @@ -756,11 +802,24 @@ msgid "" "context whenever the task starts or resumes execution." msgstr "" -#: ../../glossary.rst:330 +#: ../../glossary.rst:359 +msgid "cyclic isolate" +msgstr "" + +#: ../../glossary.rst:361 +msgid "" +"A subgroup of one or more objects that reference each other in a reference " +"cycle, but are not referenced by objects outside the group. The goal of " +"the :term:`cyclic garbage collector ` is to identify " +"these groups and break the reference cycles so that the memory can be " +"reclaimed." +msgstr "" + +#: ../../glossary.rst:365 msgid "decorator" msgstr "decorator(裝飾器)" -#: ../../glossary.rst:332 +#: ../../glossary.rst:367 msgid "" "A function returning another function, usually applied as a function " "transformation using the ``@wrapper`` syntax. Common examples for " @@ -770,13 +829,13 @@ msgstr "" "式的變換 (function transformation)。裝飾器的常見範例是 :func:`classmethod` " "和 :func:`staticmethod`。" -#: ../../glossary.rst:336 +#: ../../glossary.rst:371 msgid "" "The decorator syntax is merely syntactic sugar, the following two function " "definitions are semantically equivalent::" msgstr "裝飾器語法只是語法糖。以下兩個函式定義在語義上是等效的: ::" -#: ../../glossary.rst:339 +#: ../../glossary.rst:374 msgid "" "def f(arg):\n" " ...\n" @@ -794,7 +853,7 @@ msgstr "" "def f(arg):\n" " ..." -#: ../../glossary.rst:347 +#: ../../glossary.rst:382 msgid "" "The same concept exists for classes, but is less commonly used there. See " "the documentation for :ref:`function definitions ` and :ref:`class " @@ -803,11 +862,11 @@ msgstr "" "Class 也存在相同的概念,但在那裡比較不常用。關於裝飾器的更多內容,請參閱\\ :" "ref:`函式定義 `\\ 和 :ref:`class 定義 `\\ 的說明文件。" -#: ../../glossary.rst:350 +#: ../../glossary.rst:385 msgid "descriptor" msgstr "descriptor(描述器)" -#: ../../glossary.rst:352 +#: ../../glossary.rst:387 msgid "" "Any object which defines the methods :meth:`~object.__get__`, :meth:`~object." "__set__`, or :meth:`~object.__delete__`. When a class attribute is a " @@ -827,7 +886,7 @@ msgstr "" "們是許多功能的基礎,這些功能包括函式、method、屬性 (property)、class method、" "靜態 method,以及對 super class(父類別)的參照。" -#: ../../glossary.rst:363 +#: ../../glossary.rst:398 msgid "" "For more information about descriptors' methods, see :ref:`descriptors` or " "the :ref:`Descriptor How To Guide `." @@ -835,11 +894,11 @@ msgstr "" "關於描述器 method 的更多資訊,請參閱\\ :ref:`descriptors`\\ 或\\ :ref:`描述器" "使用指南 `。" -#: ../../glossary.rst:365 +#: ../../glossary.rst:400 msgid "dictionary" msgstr "dictionary(字典)" -#: ../../glossary.rst:367 +#: ../../glossary.rst:402 msgid "" "An associative array, where arbitrary keys are mapped to values. The keys " "can be any object with :meth:`~object.__hash__` and :meth:`~object.__eq__` " @@ -849,11 +908,11 @@ msgstr "" "有 :meth:`~object.__hash__` 和 :meth:`~object.__eq__` method 的物件。在 Perl " "中被稱為雜湊 (hash)。" -#: ../../glossary.rst:371 +#: ../../glossary.rst:406 msgid "dictionary comprehension" msgstr "dictionary comprehension(字典綜合運算)" -#: ../../glossary.rst:373 +#: ../../glossary.rst:408 msgid "" "A compact way to process all or part of the elements in an iterable and " "return a dictionary with the results. ``results = {n: n ** 2 for n in " @@ -864,11 +923,11 @@ msgstr "" "字典回傳。``results = {n: n ** 2 for n in range(10)}`` 會產生一個字典,它包含" "了鍵 ``n`` 對映到值 ``n ** 2``。請參閱\\ :ref:`comprehensions`。" -#: ../../glossary.rst:377 +#: ../../glossary.rst:412 msgid "dictionary view" msgstr "dictionary view(字典檢視)" -#: ../../glossary.rst:379 +#: ../../glossary.rst:414 msgid "" "The objects returned from :meth:`dict.keys`, :meth:`dict.values`, and :meth:" "`dict.items` are called dictionary views. They provide a dynamic view on the " @@ -881,11 +940,11 @@ msgstr "" "反映這些變動。若要強制將字典檢視轉為完整的 list(串列),須使用 " "``list(dictview)``。請參閱\\ :ref:`dict-views`。" -#: ../../glossary.rst:385 +#: ../../glossary.rst:420 msgid "docstring" msgstr "docstring(說明字串)" -#: ../../glossary.rst:387 +#: ../../glossary.rst:422 msgid "" "A string literal which appears as the first expression in a class, function " "or module. While ignored when the suite is executed, it is recognized by " @@ -898,11 +957,11 @@ msgstr "" "`~definition.__doc__` 屬性中。由於說明字串可以透過內省 (introspection) 來瀏" "覽,因此它是物件的說明文件存放的標準位置。" -#: ../../glossary.rst:393 +#: ../../glossary.rst:428 msgid "duck-typing" msgstr "duck-typing(鴨子型別)" -#: ../../glossary.rst:395 +#: ../../glossary.rst:430 msgid "" "A programming style which does not look at an object's type to determine if " "it has the right interface; instead, the method or attribute is simply " @@ -923,11 +982,11 @@ msgstr "" "來補充。)然而,它通常會採用 :func:`hasattr` 測試,或是 :term:`EAFP` 程式設計" "風格。" -#: ../../glossary.rst:404 +#: ../../glossary.rst:439 msgid "dunder" msgstr "dunder(雙底線)" -#: ../../glossary.rst:406 +#: ../../glossary.rst:441 msgid "" "An informal short-hand for \"double underscore\", used when talking about a :" "term:`special method`. For example, ``__init__`` is often pronounced " @@ -937,11 +996,11 @@ msgstr "" "方法 `\\ 時使用。例如,``__init__`` 通常被叫做 \"dunder " "init\"。" -#: ../../glossary.rst:409 +#: ../../glossary.rst:444 msgid "EAFP" msgstr "EAFP" -#: ../../glossary.rst:411 +#: ../../glossary.rst:446 msgid "" "Easier to ask for forgiveness than permission. This common Python coding " "style assumes the existence of valid keys or attributes and catches " @@ -956,11 +1015,22 @@ msgstr "" "keyword:`except` 陳述式。該技術與許多其他語言(例如 C)常見的 :term:`LBYL` 風" "格形成了對比。" -#: ../../glossary.rst:417 +#: ../../glossary.rst:452 +msgid "evaluate function" +msgstr "evaluate function(求值函式)" + +#: ../../glossary.rst:454 +msgid "" +"A function that can be called to evaluate a lazily evaluated attribute of an " +"object, such as the value of type aliases created with the :keyword:`type` " +"statement." +msgstr "" + +#: ../../glossary.rst:457 msgid "expression" msgstr "expression(運算式)" -#: ../../glossary.rst:419 +#: ../../glossary.rst:459 msgid "" "A piece of syntax which can be evaluated to some value. In other words, an " "expression is an accumulation of expression elements like literals, names, " @@ -976,11 +1046,11 @@ msgstr "" "(陳述式)不能被用作運算式,例如 :keyword:`while`。賦值 (assignment) 也是陳述" "式,而不是運算式。" -#: ../../glossary.rst:426 +#: ../../glossary.rst:466 msgid "extension module" msgstr "extension module(擴充模組)" -#: ../../glossary.rst:428 +#: ../../glossary.rst:468 msgid "" "A module written in C or C++, using Python's C API to interact with the core " "and with user code." @@ -988,24 +1058,28 @@ msgstr "" "一個以 C 或 C++ 編寫的模組,它使用 Python 的 C API 來與核心及使用者程式碼進行" "互動。" -#: ../../glossary.rst:430 +#: ../../glossary.rst:470 msgid "f-string" msgstr "f-string(f 字串)" -#: ../../glossary.rst:432 +#: ../../glossary.rst:471 +msgid "f-strings" +msgstr "f-strings(f 字串)" + +#: ../../glossary.rst:473 msgid "" -"String literals prefixed with ``'f'`` or ``'F'`` are commonly called \"f-" +"String literals prefixed with ``f`` or ``F`` are commonly called \"f-" "strings\" which is short for :ref:`formatted string literals `. " "See also :pep:`498`." msgstr "" -"以 ``'f'`` 或 ``'F'`` 為前綴的字串文本通常被稱為「f 字串」,它是\\ :ref:`格式" -"化的字串文本 `\\ 的縮寫。另請參閱 :pep:`498`。" +"以 ``f`` 或 ``F`` 為前綴的字串文本通常被稱為「f 字串」,它是\\ :ref:`格式化的" +"字串文本 `\\ 的縮寫。另請參閱 :pep:`498`。" -#: ../../glossary.rst:435 +#: ../../glossary.rst:476 msgid "file object" msgstr "file object(檔案物件)" -#: ../../glossary.rst:437 +#: ../../glossary.rst:478 msgid "" "An object exposing a file-oriented API (with methods such as :meth:`!read` " "or :meth:`!write`) to an underlying resource. Depending on the way it was " @@ -1020,7 +1094,7 @@ msgstr "" "衝區、socket(插座)、管線 (pipe) 等)的存取。檔案物件也被稱為\\ :dfn:`類檔案" "物件 (file-like object)` 或\\ :dfn:`串流 (stream)`。" -#: ../../glossary.rst:445 +#: ../../glossary.rst:486 msgid "" "There are actually three categories of file objects: raw :term:`binary files " "`, buffered :term:`binary files ` and :term:`text " @@ -1032,19 +1106,19 @@ msgstr "" "term:`二進位檔案 `\\ 和\\ :term:`文字檔案 `。它們的介" "面在 :mod:`io` 模組中被定義。建立檔案物件的標準方法是使用 :func:`open` 函式。" -#: ../../glossary.rst:450 +#: ../../glossary.rst:491 msgid "file-like object" msgstr "file-like object(類檔案物件)" -#: ../../glossary.rst:452 +#: ../../glossary.rst:493 msgid "A synonym for :term:`file object`." msgstr ":term:`file object`\\ (檔案物件)的同義字。" -#: ../../glossary.rst:453 +#: ../../glossary.rst:494 msgid "filesystem encoding and error handler" msgstr "filesystem encoding and error handler(檔案系統編碼和錯誤處理函式)" -#: ../../glossary.rst:455 +#: ../../glossary.rst:496 msgid "" "Encoding and error handler used by Python to decode bytes from the operating " "system and encode Unicode to the operating system." @@ -1052,7 +1126,7 @@ msgstr "" "Python 所使用的一種編碼和錯誤處理函式,用來解碼來自作業系統的位元組,以及將 " "Unicode 編碼到作業系統。" -#: ../../glossary.rst:458 +#: ../../glossary.rst:499 msgid "" "The filesystem encoding must guarantee to successfully decode all bytes " "below 128. If the file system encoding fails to provide this guarantee, API " @@ -1061,7 +1135,7 @@ msgstr "" "檔案系統編碼必須保證能成功解碼所有小於 128 的位元組。如果檔案系統編碼無法提供" "此保證,則 API 函式會引發 :exc:`UnicodeError`。" -#: ../../glossary.rst:462 +#: ../../glossary.rst:503 msgid "" "The :func:`sys.getfilesystemencoding` and :func:`sys." "getfilesystemencodeerrors` functions can be used to get the filesystem " @@ -1070,7 +1144,7 @@ msgstr "" ":func:`sys.getfilesystemencoding` 和 :func:`sys.getfilesystemencodeerrors` 函" "式可用於取得檔案系統編碼和錯誤處理函式。" -#: ../../glossary.rst:466 +#: ../../glossary.rst:507 msgid "" "The :term:`filesystem encoding and error handler` are configured at Python " "startup by the :c:func:`PyConfig_Read` function: see :c:member:`~PyConfig." @@ -1082,22 +1156,22 @@ msgstr "" "member:`~PyConfig.filesystem_encoding`,以及 :c:type:`PyConfig` 的成員 :c:" "member:`~PyConfig.filesystem_errors`。" -#: ../../glossary.rst:471 +#: ../../glossary.rst:512 msgid "See also the :term:`locale encoding`." msgstr "另請參閱 :term:`locale encoding`\\ (區域編碼)。" -#: ../../glossary.rst:472 +#: ../../glossary.rst:513 msgid "finder" msgstr "finder(尋檢器)" -#: ../../glossary.rst:474 +#: ../../glossary.rst:515 msgid "" "An object that tries to find the :term:`loader` for a module that is being " "imported." msgstr "" "一個物件,它會嘗試為正在被 import 的模組尋找 :term:`loader`\\ (載入器)。" -#: ../../glossary.rst:477 +#: ../../glossary.rst:518 msgid "" "There are two types of finder: :term:`meta path finders ` " "for use with :data:`sys.meta_path`, and :term:`path entry finders ` 會使用 :data:`sys.meta_path`,而\\ :term:`路徑項目尋檢器 (path " "entry finder) ` 會使用 :data:`sys.path_hooks`。" -#: ../../glossary.rst:481 +#: ../../glossary.rst:522 msgid "" "See :ref:`finders-and-loaders` and :mod:`importlib` for much more detail." msgstr "請參閱 :ref:`finders-and-loaders` 和 :mod:`importlib` 以了解更多細節。" -#: ../../glossary.rst:482 +#: ../../glossary.rst:523 msgid "floor division" msgstr "floor division(向下取整除法)" -#: ../../glossary.rst:484 +#: ../../glossary.rst:525 msgid "" "Mathematical division that rounds down to nearest integer. The floor " "division operator is ``//``. For example, the expression ``11 // 4`` " @@ -1129,11 +1203,11 @@ msgstr "" "``2.75`` 不同。請注意,``(-11) // 4`` 的結果是 ``-3``,因為是 ``-2.75`` 被\\ " "*向下*\\ 無條件捨去。請參閱 :pep:`238`。" -#: ../../glossary.rst:489 +#: ../../glossary.rst:530 msgid "free threading" msgstr "free threading(自由執行緒)" -#: ../../glossary.rst:491 +#: ../../glossary.rst:532 msgid "" "A threading model where multiple threads can run Python bytecode " "simultaneously within the same interpreter. This is in contrast to the :" @@ -1144,11 +1218,11 @@ msgstr "" "\\ :term:`全域直譯器鎖 `\\ 形成對比,後者一次只允許" "一個執行緒執行 Python 位元組碼。請參閱 :pep:`703`。" -#: ../../glossary.rst:495 +#: ../../glossary.rst:536 msgid "free variable" msgstr "free variable(自由變數)" -#: ../../glossary.rst:497 +#: ../../glossary.rst:538 msgid "" "Formally, as defined in the :ref:`language execution model `, a " "free variable is any variable used in a namespace which is not a local " @@ -1158,11 +1232,11 @@ msgid "" "variable`." msgstr "" -#: ../../glossary.rst:502 +#: ../../glossary.rst:543 msgid "function" msgstr "function(函式)" -#: ../../glossary.rst:504 +#: ../../glossary.rst:545 msgid "" "A series of statements which returns some value to a caller. It can also be " "passed zero or more :term:`arguments ` which may be used in the " @@ -1174,15 +1248,15 @@ msgstr "" "`parameter`\\ (參數)、:term:`method`\\ (方法),以及\\ :ref:`function`\\ " "章節。" -#: ../../glossary.rst:508 +#: ../../glossary.rst:549 msgid "function annotation" msgstr "function annotation(函式註釋)" -#: ../../glossary.rst:510 +#: ../../glossary.rst:551 msgid "An :term:`annotation` of a function parameter or return value." msgstr "函式參數或回傳值的一個 :term:`annotation`\\ (註釋)。" -#: ../../glossary.rst:512 +#: ../../glossary.rst:553 msgid "" "Function annotations are usually used for :term:`type hints `: " "for example, this function is expected to take two :class:`int` arguments " @@ -1191,7 +1265,7 @@ msgstr "" "函式註釋通常被使用於\\ :term:`型別提示 `:例如,這個函式預期會得到" "兩個 :class:`int` 引數,並會有一個 :class:`int` 回傳值: ::" -#: ../../glossary.rst:517 +#: ../../glossary.rst:558 msgid "" "def sum_two_numbers(a: int, b: int) -> int:\n" " return a + b" @@ -1199,11 +1273,11 @@ msgstr "" "def sum_two_numbers(a: int, b: int) -> int:\n" " return a + b" -#: ../../glossary.rst:520 +#: ../../glossary.rst:561 msgid "Function annotation syntax is explained in section :ref:`function`." msgstr "函式註釋的語法在\\ :ref:`function`\\ 章節有詳細解釋。" -#: ../../glossary.rst:522 +#: ../../glossary.rst:563 msgid "" "See :term:`variable annotation` and :pep:`484`, which describe this " "functionality. Also see :ref:`annotations-howto` for best practices on " @@ -1212,11 +1286,11 @@ msgstr "" "請參閱 :term:`variable annotation` 和 :pep:`484`,皆有此功能的描述。關於註釋" "的最佳實踐方法,另請參閱 :ref:`annotations-howto`。" -#: ../../glossary.rst:526 +#: ../../glossary.rst:567 msgid "__future__" msgstr "__future__" -#: ../../glossary.rst:528 +#: ../../glossary.rst:569 msgid "" "A :ref:`future statement `, ``from __future__ import ``, " "directs the compiler to compile the current module using syntax or semantics " @@ -1232,7 +1306,7 @@ msgstr "" "import 此模組並對其變數求值,你可以看見一個新的功能是何時首次被新增到此語言" "中,以及它何時將會(或已經)成為預設的功能: ::" -#: ../../glossary.rst:536 +#: ../../glossary.rst:577 msgid "" ">>> import __future__\n" ">>> __future__.division\n" @@ -1242,11 +1316,11 @@ msgstr "" ">>> __future__.division\n" "_Feature((2, 2, 0, 'alpha', 2), (3, 0, 0, 'alpha', 0), 8192)" -#: ../../glossary.rst:539 +#: ../../glossary.rst:580 msgid "garbage collection" msgstr "garbage collection(垃圾回收)" -#: ../../glossary.rst:541 +#: ../../glossary.rst:582 msgid "" "The process of freeing memory when it is not used anymore. Python performs " "garbage collection via reference counting and a cyclic garbage collector " @@ -1258,11 +1332,11 @@ msgstr "" "垃圾回收器 (cyclic garbage collector) 來完成。垃圾回收器可以使用 :mod:`gc` 模" "組對其進行控制。" -#: ../../glossary.rst:546 ../../glossary.rst:547 +#: ../../glossary.rst:587 ../../glossary.rst:588 msgid "generator" msgstr "generator(產生器)" -#: ../../glossary.rst:549 +#: ../../glossary.rst:590 msgid "" "A function which returns a :term:`generator iterator`. It looks like a " "normal function except that it contains :keyword:`yield` expressions for " @@ -1273,7 +1347,7 @@ msgstr "" "個正常的函式,但不同的是它包含了 :keyword:`yield` 運算式,能產生一系列的值," "這些值可用於 for 迴圈,或是以 :func:`next` 函式,每次檢索其中的一個值。" -#: ../../glossary.rst:554 +#: ../../glossary.rst:595 msgid "" "Usually refers to a generator function, but may refer to a *generator " "iterator* in some contexts. In cases where the intended meaning isn't " @@ -1282,15 +1356,15 @@ msgstr "" "這個術語通常用來表示一個產生器函式,但在某些情境中,也可能是表示\\ *產生器疊" "代器*。萬一想表達的意思不夠清楚,那就使用完整的術語,以避免歧義。" -#: ../../glossary.rst:557 +#: ../../glossary.rst:598 msgid "generator iterator" msgstr "generator iterator(產生器疊代器)" -#: ../../glossary.rst:559 +#: ../../glossary.rst:600 msgid "An object created by a :term:`generator` function." msgstr "一個由 :term:`generator`\\ (產生器)函式所建立的物件。" -#: ../../glossary.rst:561 +#: ../../glossary.rst:602 msgid "" "Each :keyword:`yield` temporarily suspends processing, remembering the " "execution state (including local variables and pending try-statements). " @@ -1301,11 +1375,11 @@ msgstr "" "try 陳述式)。當\\ *產生器疊代器*\\ 回復時,它會從停止的地方繼續執行(與那些" "每次呼叫時都要重新開始的函式有所不同)。" -#: ../../glossary.rst:567 ../../glossary.rst:568 +#: ../../glossary.rst:608 ../../glossary.rst:609 msgid "generator expression" msgstr "generator expression(產生器運算式)" -#: ../../glossary.rst:570 +#: ../../glossary.rst:611 msgid "" "An :term:`expression` that returns an :term:`iterator`. It looks like a " "normal expression followed by a :keyword:`!for` clause defining a loop " @@ -1317,7 +1391,7 @@ msgstr "" "變數、範圍以及一個選擇性的 :keyword:`!if` 子句。該組合運算式會為外層函式產生" "多個值: ::" -#: ../../glossary.rst:575 +#: ../../glossary.rst:616 msgid "" ">>> sum(i*i for i in range(10)) # sum of squares 0, 1, 4, ... 81\n" "285" @@ -1325,11 +1399,11 @@ msgstr "" ">>> sum(i*i for i in range(10)) # 平方之和 0, 1, 4, ... 81\n" "285" -#: ../../glossary.rst:577 +#: ../../glossary.rst:618 msgid "generic function" msgstr "generic function(泛型函式)" -#: ../../glossary.rst:579 +#: ../../glossary.rst:620 msgid "" "A function composed of multiple functions implementing the same operation " "for different types. Which implementation should be used during a call is " @@ -1338,7 +1412,7 @@ msgstr "" "一個由多個函式組成的函式,該函式會對不同的型別實作相同的運算。呼叫期間應該使" "用哪種實作,是由調度演算法 (dispatch algorithm) 來決定。" -#: ../../glossary.rst:583 +#: ../../glossary.rst:624 msgid "" "See also the :term:`single dispatch` glossary entry, the :func:`functools." "singledispatch` decorator, and :pep:`443`." @@ -1346,11 +1420,11 @@ msgstr "" "另請參閱 :term:`single dispatch`\\ (單一調度)術語表條目、:func:`functools." "singledispatch` 裝飾器和 :pep:`443`。" -#: ../../glossary.rst:585 +#: ../../glossary.rst:626 msgid "generic type" msgstr "generic type(泛型型別)" -#: ../../glossary.rst:587 +#: ../../glossary.rst:628 msgid "" "A :term:`type` that can be parameterized; typically a :ref:`container " "class` such as :class:`list` or :class:`dict`. Used for :" @@ -1360,7 +1434,7 @@ msgstr "" "`容器型別 `,像是 :class:`list` 和 :class:`dict`。它被用於" "\\ :term:`型別提示 `\\ 和\\ :term:`註釋 `。" -#: ../../glossary.rst:592 +#: ../../glossary.rst:633 msgid "" "For more details, see :ref:`generic alias types`, :pep:" "`483`, :pep:`484`, :pep:`585`, and the :mod:`typing` module." @@ -1368,19 +1442,19 @@ msgstr "" "詳情請參閱\\ :ref:`泛型別名型別 `、:pep:`483`、:pep:" "`484`、:pep:`585` 和 :mod:`typing` 模組。" -#: ../../glossary.rst:594 +#: ../../glossary.rst:635 msgid "GIL" msgstr "GIL" -#: ../../glossary.rst:596 +#: ../../glossary.rst:637 msgid "See :term:`global interpreter lock`." msgstr "請參閱 :term:`global interpreter lock`\\ (全域直譯器鎖)。" -#: ../../glossary.rst:597 +#: ../../glossary.rst:638 msgid "global interpreter lock" msgstr "global interpreter lock(全域直譯器鎖)" -#: ../../glossary.rst:599 +#: ../../glossary.rst:640 msgid "" "The mechanism used by the :term:`CPython` interpreter to assure that only " "one thread executes Python :term:`bytecode` at a time. This simplifies the " @@ -1397,7 +1471,7 @@ msgstr "" "(multi-threaded),但代價是會犧牲掉多處理器的機器能夠提供的一大部分平行性 " "(parallelism)。" -#: ../../glossary.rst:608 +#: ../../glossary.rst:649 msgid "" "However, some extension modules, either standard or third-party, are " "designed so as to release the GIL when doing computationally intensive tasks " @@ -1408,7 +1482,7 @@ msgstr "" "計算密集 (computationally intensive) 的任務時,可以解除 GIL。另外,在執行 I/" "O 時,GIL 總是會被解除。" -#: ../../glossary.rst:613 +#: ../../glossary.rst:654 msgid "" "As of Python 3.13, the GIL can be disabled using the :option:`--disable-gil` " "build configuration. After building Python with this option, code must be " @@ -1423,11 +1497,18 @@ msgstr "" "多執行緒應用程式的效能,並使多核心 CPU 的高效使用變得更加容易。有關更多詳細資" "訊,請參閱 :pep:`703`。" -#: ../../glossary.rst:619 +#: ../../glossary.rst:661 +msgid "" +"In prior versions of Python's C API, a function might declare that it " +"requires the GIL to be held in order to use it. This refers to having an :" +"term:`attached thread state`." +msgstr "" + +#: ../../glossary.rst:664 msgid "hash-based pyc" msgstr "hash-based pyc(雜湊架構的 pyc)" -#: ../../glossary.rst:621 +#: ../../glossary.rst:666 msgid "" "A bytecode cache file that uses the hash rather than the last-modified time " "of the corresponding source file to determine its validity. See :ref:`pyc-" @@ -1436,11 +1517,11 @@ msgstr "" "一個位元組碼 (bytecode) 暫存檔,它使用雜湊值而不是對應原始檔案的最後修改時" "間,來確定其有效性。請參閱\\ :ref:`pyc-invalidation`。" -#: ../../glossary.rst:624 +#: ../../glossary.rst:669 msgid "hashable" msgstr "hashable(可雜湊的)" -#: ../../glossary.rst:626 +#: ../../glossary.rst:671 msgid "" "An object is *hashable* if it has a hash value which never changes during " "its lifetime (it needs a :meth:`~object.__hash__` method), and can be " @@ -1452,7 +1533,7 @@ msgstr "" "`~object.__eq__` method),那麼它就是一個\\ *可雜湊*\\ 物件。比較結果為相等的" "多個可雜湊物件,它們必須擁有相同的雜湊值。" -#: ../../glossary.rst:632 +#: ../../glossary.rst:677 msgid "" "Hashability makes an object usable as a dictionary key and a set member, " "because these data structures use the hash value internally." @@ -1460,7 +1541,7 @@ msgstr "" "可雜湊性 (hashability) 使一個物件可用作 dictionary(字典)的鍵和 set(集合)" "的成員,因為這些資料結構都在其內部使用了雜湊值。" -#: ../../glossary.rst:635 +#: ../../glossary.rst:680 msgid "" "Most of Python's immutable built-in objects are hashable; mutable containers " "(such as lists or dictionaries) are not; immutable containers (such as " @@ -1475,11 +1556,11 @@ msgstr "" "則這些物件會被預設為可雜湊的。它們在互相比較時都是不相等的(除非它們與自己比" "較),而它們的雜湊值則是衍生自它們的 :func:`id`。" -#: ../../glossary.rst:642 +#: ../../glossary.rst:687 msgid "IDLE" msgstr "IDLE" -#: ../../glossary.rst:644 +#: ../../glossary.rst:689 msgid "" "An Integrated Development and Learning Environment for Python. :ref:`idle` " "is a basic editor and interpreter environment which ships with the standard " @@ -1489,17 +1570,17 @@ msgstr "" "境)。:ref:`idle` 是一個基本的編輯器和直譯器環境,它和 Python 的標準發行版本" "一起被提供。" -#: ../../glossary.rst:647 +#: ../../glossary.rst:692 msgid "immortal" msgstr "immortal(不滅)" -#: ../../glossary.rst:649 +#: ../../glossary.rst:694 msgid "" "*Immortal objects* are a CPython implementation detail introduced in :pep:" "`683`." msgstr "*不滅物件 (Immortal objects)* 是 :pep:`683` 引入的 CPython 實作細節。" -#: ../../glossary.rst:652 +#: ../../glossary.rst:697 msgid "" "If an object is immortal, its :term:`reference count` is never modified, and " "therefore it is never deallocated while the interpreter is running. For " @@ -1509,11 +1590,17 @@ msgstr "" "修改,因此在直譯器運行時它永遠不會被釋放。例如,:const:`True` 和 :const:" "`None` 在 CPython 中是不滅的。" -#: ../../glossary.rst:655 +#: ../../glossary.rst:701 +msgid "" +"Immortal objects can be identified via :func:`sys._is_immortal`, or via :c:" +"func:`PyUnstable_IsImmortal` in the C API." +msgstr "" + +#: ../../glossary.rst:703 msgid "immutable" msgstr "immutable(不可變物件)" -#: ../../glossary.rst:657 +#: ../../glossary.rst:705 msgid "" "An object with a fixed value. Immutable objects include numbers, strings " "and tuples. Such an object cannot be altered. A new object has to be " @@ -1525,11 +1612,11 @@ msgstr "" "能被改變的。如果一個不同的值必須被儲存,則必須建立一個新的物件。它們在需要恆" "定雜湊值的地方,扮演重要的角色,例如 dictionary(字典)中的一個鍵。" -#: ../../glossary.rst:662 +#: ../../glossary.rst:710 msgid "import path" msgstr "import path(引入路徑)" -#: ../../glossary.rst:664 +#: ../../glossary.rst:712 msgid "" "A list of locations (or :term:`path entries `) that are searched " "by the :term:`path based finder` for modules to import. During import, this " @@ -1541,11 +1628,11 @@ msgstr "" "的位置。在 import 期間,此位置列表通常是來自 :data:`sys.path`,但對於子套件 " "(subpackage) 而言,它也可能是來自父套件的 ``__path__`` 屬性。" -#: ../../glossary.rst:669 +#: ../../glossary.rst:717 msgid "importing" msgstr "importing(引入)" -#: ../../glossary.rst:671 +#: ../../glossary.rst:719 msgid "" "The process by which Python code in one module is made available to Python " "code in another module." @@ -1553,11 +1640,11 @@ msgstr "" "一個過程。一個模組中的 Python 程式碼可以透過此過程,被另一個模組中的 Python " "程式碼使用。" -#: ../../glossary.rst:673 +#: ../../glossary.rst:721 msgid "importer" msgstr "importer(引入器)" -#: ../../glossary.rst:675 +#: ../../glossary.rst:723 msgid "" "An object that both finds and loads a module; both a :term:`finder` and :" "term:`loader` object." @@ -1565,11 +1652,11 @@ msgstr "" "一個能夠尋找及載入模組的物件;它既是 :term:`finder`\\ (尋檢器)也是 :term:" "`loader`\\ (載入器)物件。" -#: ../../glossary.rst:677 +#: ../../glossary.rst:725 msgid "interactive" msgstr "interactive(互動的)" -#: ../../glossary.rst:679 +#: ../../glossary.rst:727 msgid "" "Python has an interactive interpreter which means you can enter statements " "and expressions at the interpreter prompt, immediately execute them and see " @@ -1583,11 +1670,11 @@ msgstr "" "從你的電腦的主選單選擇它)。這是測試新想法或檢查模組和包的非常強大的方法(請" "記住help(x))。更多互動式模式相關資訊請見 :ref:`tut-interac`。" -#: ../../glossary.rst:686 +#: ../../glossary.rst:734 msgid "interpreted" msgstr "interpreted(直譯的)" -#: ../../glossary.rst:688 +#: ../../glossary.rst:736 msgid "" "Python is an interpreted language, as opposed to a compiled one, though the " "distinction can be blurry because of the presence of the bytecode compiler. " @@ -1601,11 +1688,11 @@ msgstr "" "一個執行檔,然後再執行它。直譯語言通常比編譯語言有更短的開發/除錯週期,不過" "它們的程式通常也運行得較慢。另請參閱 :term:`interactive`\\ (互動的)。" -#: ../../glossary.rst:695 +#: ../../glossary.rst:743 msgid "interpreter shutdown" msgstr "interpreter shutdown(直譯器關閉)" -#: ../../glossary.rst:697 +#: ../../glossary.rst:745 msgid "" "When asked to shut down, the Python interpreter enters a special phase where " "it gradually releases all allocated resources, such as modules and various " @@ -1623,18 +1710,18 @@ msgstr "" "段被執行的程式碼會遇到各種例外,因為它所依賴的資源可能不再有作用了(常見的例" "子是函式庫模組或是警告機制)。" -#: ../../glossary.rst:706 +#: ../../glossary.rst:754 msgid "" "The main reason for interpreter shutdown is that the ``__main__`` module or " "the script being run has finished executing." msgstr "" "直譯器關閉的主要原因,是 ``__main__`` 模組或正被運行的腳本已經執行完成。" -#: ../../glossary.rst:708 +#: ../../glossary.rst:756 msgid "iterable" msgstr "iterable(可疊代物件)" -#: ../../glossary.rst:710 +#: ../../glossary.rst:758 msgid "" "An object capable of returning its members one at a time. Examples of " "iterables include all sequence types (such as :class:`list`, :class:`str`, " @@ -1649,7 +1736,7 @@ msgstr "" "只要那些 class 有實作 :term:`sequence`\\ (序列)語意的 :meth:`~object." "__iter__` 或是 :meth:`~object.__getitem__` method,該物件就是可疊代物件。" -#: ../../glossary.rst:718 +#: ../../glossary.rst:766 msgid "" "Iterables can be used in a :keyword:`for` loop and in many other places " "where a sequence is needed (:func:`zip`, :func:`map`, ...). When an " @@ -1669,11 +1756,11 @@ msgstr "" "數,用於在迴圈期間保有該疊代器。另請參閱 :term:`iterator`\\ (疊代器)、:" "term:`sequence`\\ (序列)和 :term:`generator`\\ (產生器)。" -#: ../../glossary.rst:728 +#: ../../glossary.rst:776 msgid "iterator" msgstr "iterator(疊代器)" -#: ../../glossary.rst:730 +#: ../../glossary.rst:778 msgid "" "An object representing a stream of data. Repeated calls to the iterator's :" "meth:`~iterator.__next__` method (or passing it to the built-in function :" @@ -1702,11 +1789,11 @@ msgstr "" "此事(多遍疊代)時,只會回傳在前一遍疊代中被用過的、同一個已被用盡的疊代器物" "件,使其看起來就像一個空的容器。" -#: ../../glossary.rst:745 +#: ../../glossary.rst:793 msgid "More information can be found in :ref:`typeiter`." msgstr "在\\ :ref:`typeiter`\\ 文中可以找到更多資訊。" -#: ../../glossary.rst:749 +#: ../../glossary.rst:797 msgid "" "CPython does not consistently apply the requirement that an iterator define :" "meth:`~iterator.__iter__`. And also please note that the free-threading " @@ -1716,11 +1803,11 @@ msgstr "" "__iter__`\\ 」這個規定。另請注意,free-threading(自由執行緒)CPython 不保證" "疊代器操作的執行緒安全。" -#: ../../glossary.rst:754 +#: ../../glossary.rst:802 msgid "key function" msgstr "key function(鍵函式)" -#: ../../glossary.rst:756 +#: ../../glossary.rst:804 msgid "" "A key function or collation function is a callable that returns a value used " "for sorting or ordering. For example, :func:`locale.strxfrm` is used to " @@ -1730,7 +1817,7 @@ msgstr "" "一個用於排序 (sorting) 或定序 (ordering) 的值。例如,:func:`locale.strxfrm` " "被用來產生一個了解區域特定排序慣例的排序鍵。" -#: ../../glossary.rst:761 +#: ../../glossary.rst:809 msgid "" "A number of tools in Python accept key functions to control how elements are " "ordered or grouped. They include :func:`min`, :func:`max`, :func:`sorted`, :" @@ -1742,7 +1829,7 @@ msgstr "" "merge`、:func:`heapq.nsmallest`、:func:`heapq.nlargest` 和 :func:`itertools." "groupby`。" -#: ../../glossary.rst:767 +#: ../../glossary.rst:815 msgid "" "There are several ways to create a key function. For example. the :meth:" "`str.lower` method can serve as a key function for case insensitive sorts. " @@ -1759,19 +1846,19 @@ msgstr "" "式 (constructor)。關於如何建立和使用鍵函式的範例,請參閱\\ :ref:`如何排序 " "`。" -#: ../../glossary.rst:774 +#: ../../glossary.rst:822 msgid "keyword argument" msgstr "keyword argument(關鍵字引數)" -#: ../../glossary.rst:776 ../../glossary.rst:1091 +#: ../../glossary.rst:824 ../../glossary.rst:1148 msgid "See :term:`argument`." msgstr "請參閱 :term:`argument`\\ (引數)。" -#: ../../glossary.rst:777 +#: ../../glossary.rst:825 msgid "lambda" msgstr "lambda" -#: ../../glossary.rst:779 +#: ../../glossary.rst:827 msgid "" "An anonymous inline function consisting of a single :term:`expression` which " "is evaluated when the function is called. The syntax to create a lambda " @@ -1781,11 +1868,11 @@ msgstr "" "function),於該函式被呼叫時求值。建立 lambda 函式的語法是 ``lambda " "[parameters]: expression``" -#: ../../glossary.rst:782 +#: ../../glossary.rst:830 msgid "LBYL" msgstr "LBYL" -#: ../../glossary.rst:784 +#: ../../glossary.rst:832 msgid "" "Look before you leap. This coding style explicitly tests for pre-conditions " "before making calls or lookups. This style contrasts with the :term:`EAFP` " @@ -1796,7 +1883,7 @@ msgstr "" "地測試先決條件。這種風格與 :term:`EAFP` 方式形成對比,且它的特色是會有許多 :" "keyword:`if` 陳述式的存在。" -#: ../../glossary.rst:789 +#: ../../glossary.rst:837 msgid "" "In a multi-threaded environment, the LBYL approach can risk introducing a " "race condition between \"the looking\" and \"the leaping\". For example, " @@ -1810,19 +1897,19 @@ msgstr "" "了 *key*,則該程式碼就會失效。這個問題可以用鎖 (lock) 或使用 EAFP 編碼方式來" "解決。" -#: ../../glossary.rst:794 +#: ../../glossary.rst:842 msgid "lexical analyzer" msgstr "lexical analyzer(詞法分析器)" -#: ../../glossary.rst:797 +#: ../../glossary.rst:845 msgid "Formal name for the *tokenizer*; see :term:`token`." msgstr "tokenizer 的正式名稱;請參閱 :term:`token`。" -#: ../../glossary.rst:798 +#: ../../glossary.rst:846 msgid "list" msgstr "list(串列)" -#: ../../glossary.rst:800 +#: ../../glossary.rst:848 msgid "" "A built-in Python :term:`sequence`. Despite its name it is more akin to an " "array in other languages than to a linked list since access to elements is " @@ -1832,11 +1919,11 @@ msgstr "" "似其他語言中的一個陣列 (array) 而較不像一個鏈結串列 (linked list),因為存取元" "素的時間複雜度是 *O*\\ (1)。" -#: ../../glossary.rst:803 +#: ../../glossary.rst:851 msgid "list comprehension" msgstr "list comprehension(串列綜合運算)" -#: ../../glossary.rst:805 +#: ../../glossary.rst:853 msgid "" "A compact way to process all or part of the elements in a sequence and " "return a list with the results. ``result = ['{:#04x}'.format(x) for x in " @@ -1850,11 +1937,11 @@ msgstr "" "keyword:`if` 子句是選擇性的。如果省略它,則 ``range(256)`` 中的所有元素都會被" "處理。" -#: ../../glossary.rst:811 +#: ../../glossary.rst:859 msgid "loader" msgstr "loader(載入器)" -#: ../../glossary.rst:813 +#: ../../glossary.rst:861 msgid "" "An object that loads a module. It must define the :meth:`!exec_module` and :" "meth:`!create_module` methods to implement the :class:`~importlib.abc." @@ -1865,23 +1952,23 @@ msgstr "" "create_module` 方法以實作 :class:`~importlib.abc.Loader` 介面。載入器通常是" "被 :term:`finder`\\ (尋檢器)回傳。更多細節請參閱:" -#: ../../glossary.rst:819 +#: ../../glossary.rst:867 msgid ":ref:`finders-and-loaders`" msgstr ":ref:`finders-and-loaders`" -#: ../../glossary.rst:820 +#: ../../glossary.rst:868 msgid ":class:`importlib.abc.Loader`" msgstr ":class:`importlib.abc.Loader`" -#: ../../glossary.rst:821 +#: ../../glossary.rst:869 msgid ":pep:`302`" msgstr ":pep:`302`" -#: ../../glossary.rst:822 +#: ../../glossary.rst:870 msgid "locale encoding" msgstr "locale encoding(區域編碼)" -#: ../../glossary.rst:824 +#: ../../glossary.rst:872 msgid "" "On Unix, it is the encoding of the LC_CTYPE locale. It can be set with :func:" "`locale.setlocale(locale.LC_CTYPE, new_locale) `." @@ -1889,36 +1976,36 @@ msgstr "" "在 Unix 上,它是 LC_CTYPE 區域設定的編碼。它可以用 :func:`locale." "setlocale(locale.LC_CTYPE, new_locale) ` 來設定。" -#: ../../glossary.rst:827 +#: ../../glossary.rst:875 msgid "On Windows, it is the ANSI code page (ex: ``\"cp1252\"``)." msgstr "在 Windows 上,它是 ANSI 碼頁(code page,例如 ``\"cp1252\"``\\ )。" -#: ../../glossary.rst:829 +#: ../../glossary.rst:877 msgid "" "On Android and VxWorks, Python uses ``\"utf-8\"`` as the locale encoding." msgstr "在 Android 和 VxWorks 上,Python 使用 ``\"utf-8\"`` 作為區域編碼。" -#: ../../glossary.rst:831 +#: ../../glossary.rst:879 msgid ":func:`locale.getencoding` can be used to get the locale encoding." msgstr ":func:`locale.getencoding` 可以用來取得區域編碼。" -#: ../../glossary.rst:833 +#: ../../glossary.rst:881 msgid "See also the :term:`filesystem encoding and error handler`." msgstr "也請參考 :term:`filesystem encoding and error handler`。" -#: ../../glossary.rst:834 +#: ../../glossary.rst:882 msgid "magic method" msgstr "magic method(魔術方法)" -#: ../../glossary.rst:838 +#: ../../glossary.rst:886 msgid "An informal synonym for :term:`special method`." msgstr ":term:`special method`\\ (特殊方法)的一個非正式同義詞。" -#: ../../glossary.rst:839 +#: ../../glossary.rst:887 msgid "mapping" msgstr "mapping(對映)" -#: ../../glossary.rst:841 +#: ../../glossary.rst:889 msgid "" "A container object that supports arbitrary key lookups and implements the " "methods specified in the :class:`collections.abc.Mapping` or :class:" @@ -1933,11 +2020,11 @@ msgstr "" "包括 :class:`dict`、:class:`collections.defaultdict`、:class:`collections." "OrderedDict` 和 :class:`collections.Counter`。" -#: ../../glossary.rst:847 +#: ../../glossary.rst:895 msgid "meta path finder" msgstr "meta path finder(元路徑尋檢器)" -#: ../../glossary.rst:849 +#: ../../glossary.rst:897 msgid "" "A :term:`finder` returned by a search of :data:`sys.meta_path`. Meta path " "finders are related to, but different from :term:`path entry finders ` " "相關但是不同。" -#: ../../glossary.rst:853 +#: ../../glossary.rst:901 msgid "" "See :class:`importlib.abc.MetaPathFinder` for the methods that meta path " "finders implement." msgstr "" "關於元路徑尋檢器實作的 method,請參閱 :class:`importlib.abc.MetaPathFinder`。" -#: ../../glossary.rst:855 +#: ../../glossary.rst:903 msgid "metaclass" msgstr "metaclass(元類別)" -#: ../../glossary.rst:857 +#: ../../glossary.rst:905 msgid "" "The class of a class. Class definitions create a class name, a class " "dictionary, and a list of base classes. The metaclass is responsible for " @@ -1978,15 +2065,15 @@ msgstr "" "性存取、增加執行緒安全性、追蹤物件建立、實作單例模式 (singleton),以及許多其" "他的任務。" -#: ../../glossary.rst:867 +#: ../../glossary.rst:915 msgid "More information can be found in :ref:`metaclasses`." msgstr "更多資訊可以在\\ :ref:`metaclasses`\\ 章節中找到。" -#: ../../glossary.rst:836 ../../glossary.rst:868 ../../glossary.rst:1241 +#: ../../glossary.rst:884 ../../glossary.rst:916 ../../glossary.rst:1299 msgid "method" msgstr "method(方法)" -#: ../../glossary.rst:870 +#: ../../glossary.rst:918 msgid "" "A function which is defined inside a class body. If called as an attribute " "of an instance of that class, the method will get the instance object as its " @@ -1998,11 +2085,11 @@ msgstr "" "通常被稱為 ``self``)。請參閱 :term:`function`\\ (函式)和 :term:`nested " "scope`\\ (巢狀作用域)。" -#: ../../glossary.rst:874 +#: ../../glossary.rst:922 msgid "method resolution order" msgstr "method resolution order(方法解析順序)" -#: ../../glossary.rst:876 +#: ../../glossary.rst:924 msgid "" "Method Resolution Order is the order in which base classes are searched for " "a member during lookup. See :ref:`python_2.3_mro` for details of the " @@ -2011,11 +2098,11 @@ msgstr "" "方法解析順序是在查找某個成員的過程中,base class(基底類別)被搜尋的順序。關" "於 Python 自 2.3 版直譯器所使用的演算法細節,請參閱 :ref:`python_2.3_mro`。" -#: ../../glossary.rst:879 +#: ../../glossary.rst:927 msgid "module" msgstr "module(模組)" -#: ../../glossary.rst:881 +#: ../../glossary.rst:929 msgid "" "An object that serves as an organizational unit of Python code. Modules " "have a namespace containing arbitrary Python objects. Modules are loaded " @@ -2025,15 +2112,15 @@ msgstr "" "空間,它包含任意的 Python 物件。模組是藉由 :term:`importing` 的過程,被載入" "至 Python。" -#: ../../glossary.rst:885 +#: ../../glossary.rst:933 msgid "See also :term:`package`." msgstr "另請參閱 :term:`package`\\ (套件)。" -#: ../../glossary.rst:886 +#: ../../glossary.rst:934 msgid "module spec" msgstr "module spec(模組規格)" -#: ../../glossary.rst:888 +#: ../../glossary.rst:936 msgid "" "A namespace containing the import-related information used to load a module. " "An instance of :class:`importlib.machinery.ModuleSpec`." @@ -2041,23 +2128,23 @@ msgstr "" "一個命名空間,它包含用於載入模組的 import 相關資訊。它是 :class:`importlib." "machinery.ModuleSpec` 的一個實例。" -#: ../../glossary.rst:891 +#: ../../glossary.rst:939 msgid "See also :ref:`module-specs`." msgstr "另請參閱 :ref:`module-specs`。" -#: ../../glossary.rst:892 +#: ../../glossary.rst:940 msgid "MRO" msgstr "MRO" -#: ../../glossary.rst:894 +#: ../../glossary.rst:942 msgid "See :term:`method resolution order`." msgstr "請參閱 :term:`method resolution order`\\ (方法解析順序)。" -#: ../../glossary.rst:895 +#: ../../glossary.rst:943 msgid "mutable" msgstr "mutable(可變物件)" -#: ../../glossary.rst:897 +#: ../../glossary.rst:945 msgid "" "Mutable objects can change their value but keep their :func:`id`. See also :" "term:`immutable`." @@ -2065,11 +2152,11 @@ msgstr "" "可變物件可以改變它們的值,但維持它們的 :func:`id`。另請參閱 :term:" "`immutable`\\ (不可變物件)。" -#: ../../glossary.rst:899 +#: ../../glossary.rst:947 msgid "named tuple" msgstr "named tuple(附名元組)" -#: ../../glossary.rst:901 +#: ../../glossary.rst:949 msgid "" "The term \"named tuple\" applies to any type or class that inherits from " "tuple and whose indexable elements are also accessible using named " @@ -2079,7 +2166,7 @@ msgstr "" "索引 (indexable) 元素也可以用附名屬性來存取。這些型別或 class 也可以具有其他" "的特性。" -#: ../../glossary.rst:905 +#: ../../glossary.rst:953 msgid "" "Several built-in types are named tuples, including the values returned by :" "func:`time.localtime` and :func:`os.stat`. Another example is :data:`sys." @@ -2088,7 +2175,7 @@ msgstr "" "有些內建型別是 named tuple,包括由 :func:`time.localtime` 和 :func:`os.stat` " "回傳的值。另一個例子是 :data:`sys.float_info`: ::" -#: ../../glossary.rst:909 +#: ../../glossary.rst:957 msgid "" ">>> sys.float_info[1] # indexed access\n" "1024\n" @@ -2104,7 +2191,7 @@ msgstr "" ">>> isinstance(sys.float_info, tuple) # 屬於 tuple 型別\n" "True" -#: ../../glossary.rst:916 +#: ../../glossary.rst:964 msgid "" "Some named tuples are built-in types (such as the above examples). " "Alternatively, a named tuple can be created from a regular class definition " @@ -2121,11 +2208,11 @@ msgstr "" "namedtuple` 來建立。後者技術也增加了一些額外的 method,這些 method 可能是在手" "寫或內建的 named tuple 中,無法找到的。" -#: ../../glossary.rst:924 +#: ../../glossary.rst:972 msgid "namespace" msgstr "namespace(命名空間)" -#: ../../glossary.rst:926 +#: ../../glossary.rst:974 msgid "" "The place where a variable is stored. Namespaces are implemented as " "dictionaries. There are the local, global and built-in namespaces as well " @@ -2145,11 +2232,11 @@ msgstr "" "func:`itertools.islice` 明確地表示,這些函式分別是由 :mod:`random` 和 :mod:" "`itertools` 模組在實作。" -#: ../../glossary.rst:936 +#: ../../glossary.rst:984 msgid "namespace package" msgstr "namespace package(命名空間套件)" -#: ../../glossary.rst:938 +#: ../../glossary.rst:986 msgid "" "A :term:`package` which serves only as a container for subpackages. " "Namespace packages may have no physical representation, and specifically are " @@ -2159,7 +2246,7 @@ msgstr "" "名空間套件可能沒有實體的表示法,而且具體來說它們不像是一個 :term:`regular " "package`\\ (正規套件),因為它們並沒有 ``__init__.py`` 這個檔案。" -#: ../../glossary.rst:943 +#: ../../glossary.rst:991 msgid "" "Namespace packages allow several individually installable packages to have a " "common parent package. Otherwise, it is recommended to use a :term:`regular " @@ -2168,20 +2255,20 @@ msgstr "" "命名空間套件允許數個可獨立安裝的套件擁有一個共同的父套件。除此之外,建議使" "用 :term:`regular package`。" -#: ../../glossary.rst:946 +#: ../../glossary.rst:994 msgid "" "For more information, see :pep:`420` and :ref:`reference-namespace-package`." msgstr "更多資訊,請參閱 :pep:`420` 和 :ref:`reference-namespace-package`。" -#: ../../glossary.rst:948 +#: ../../glossary.rst:996 msgid "See also :term:`module`." msgstr "另請參閱 :term:`module`\\ (模組)。" -#: ../../glossary.rst:949 +#: ../../glossary.rst:997 msgid "nested scope" msgstr "nested scope(巢狀作用域)" -#: ../../glossary.rst:951 +#: ../../glossary.rst:999 msgid "" "The ability to refer to a variable in an enclosing definition. For " "instance, a function defined inside another function can refer to variables " @@ -2196,11 +2283,11 @@ msgstr "" "寫入。同樣地,全域變數是在全域命名空間中讀取及寫入。:keyword:`nonlocal` 容許" "對外層作用域進行寫入。" -#: ../../glossary.rst:958 +#: ../../glossary.rst:1006 msgid "new-style class" msgstr "new-style class(新式類別)" -#: ../../glossary.rst:960 +#: ../../glossary.rst:1008 msgid "" "Old name for the flavor of classes now used for all class objects. In " "earlier Python versions, only new-style classes could use Python's newer, " @@ -2212,11 +2299,11 @@ msgstr "" "__slots__`、描述器 (descriptor)、屬性 (property)、:meth:`~object." "__getattribute__`、class method(類別方法)和 static method(靜態方法)。" -#: ../../glossary.rst:965 +#: ../../glossary.rst:1013 msgid "object" msgstr "object(物件)" -#: ../../glossary.rst:967 +#: ../../glossary.rst:1015 msgid "" "Any data with state (attributes or value) and defined behavior (methods). " "Also the ultimate base class of any :term:`new-style class`." @@ -2224,11 +2311,11 @@ msgstr "" "具有狀態(屬性或值)及被定義的行為(method)的任何資料。它也是任何 :term:" "`new-style class`\\ (新式類別)的最終 base class(基底類別)。" -#: ../../glossary.rst:970 +#: ../../glossary.rst:1018 msgid "optimized scope" msgstr "optimized scope(最佳化作用域)" -#: ../../glossary.rst:972 +#: ../../glossary.rst:1020 msgid "" "A scope where target local variable names are reliably known to the compiler " "when the code is compiled, allowing optimization of read and write access to " @@ -2239,11 +2326,29 @@ msgid "" "to optimized scopes." msgstr "" -#: ../../glossary.rst:979 +#: ../../glossary.rst:1027 +msgid "optional module" +msgstr "optional module(可選模組)" + +#: ../../glossary.rst:1029 +msgid "" +"An :term:`extension module` that is part of the :term:`standard library`, " +"but may be absent in some builds of :term:`CPython`, usually due to missing " +"third-party libraries or because the module is not available for a given " +"platform." +msgstr "" + +#: ../../glossary.rst:1034 +msgid "" +"See :ref:`optional-module-requirements` for a list of optional modules that " +"require third-party libraries." +msgstr "" + +#: ../../glossary.rst:1036 msgid "package" msgstr "package(套件)" -#: ../../glossary.rst:981 +#: ../../glossary.rst:1038 msgid "" "A Python :term:`module` which can contain submodules or recursively, " "subpackages. Technically, a package is a Python module with a ``__path__`` " @@ -2253,17 +2358,17 @@ msgstr "" "迴的子套件 (subpackage)。技術上而言,套件就是具有 ``__path__`` 屬性的一個 " "Python 模組。" -#: ../../glossary.rst:985 +#: ../../glossary.rst:1042 msgid "See also :term:`regular package` and :term:`namespace package`." msgstr "" "另請參閱 :term:`regular package`\\ (正規套件)和 :term:`namespace " "package`\\ (命名空間套件)。" -#: ../../glossary.rst:986 +#: ../../glossary.rst:1043 msgid "parameter" msgstr "parameter(參數)" -#: ../../glossary.rst:988 +#: ../../glossary.rst:1045 msgid "" "A named entity in a :term:`function` (or method) definition that specifies " "an :term:`argument` (or in some cases, arguments) that the function can " @@ -2273,7 +2378,7 @@ msgstr "" "它指明該函式能夠接受的一個 :term:`argument`\\ (引數),或在某些情況下指示多" "個引數。共有有五種不同的參數類型:" -#: ../../glossary.rst:992 +#: ../../glossary.rst:1049 msgid "" ":dfn:`positional-or-keyword`: specifies an argument that can be passed " "either :term:`positionally ` or as a :term:`keyword argument " @@ -2284,11 +2389,11 @@ msgstr "" "置 `\\ 或是作為\\ :term:`關鍵字引數 `\\ 被傳遞的引數。這" "是參數的預設類型,例如以下的 *foo* 和 *bar*: ::" -#: ../../glossary.rst:997 +#: ../../glossary.rst:1054 msgid "def func(foo, bar=None): ..." msgstr "def func(foo, bar=None): ..." -#: ../../glossary.rst:1001 +#: ../../glossary.rst:1058 msgid "" ":dfn:`positional-only`: specifies an argument that can be supplied only by " "position. Positional-only parameters can be defined by including a ``/`` " @@ -2299,11 +2404,11 @@ msgstr "" "式定義的參數列表中包含一個 ``/`` 字元,就可以在該字元前面定義僅限位置參數,例" "如以下的 *posonly1* 和 *posonly2*: ::" -#: ../../glossary.rst:1006 +#: ../../glossary.rst:1063 msgid "def func(posonly1, posonly2, /, positional_or_keyword): ..." msgstr "def func(posonly1, posonly2, /, positional_or_keyword): ..." -#: ../../glossary.rst:1010 +#: ../../glossary.rst:1067 msgid "" ":dfn:`keyword-only`: specifies an argument that can be supplied only by " "keyword. Keyword-only parameters can be defined by including a single var-" @@ -2316,11 +2421,11 @@ msgstr "" "單純的 ``*`` 字元,就可以在其後方定義僅限關鍵字參數,例如以下的 *kw_only1* " "和 *kw_only2*: ::" -#: ../../glossary.rst:1016 +#: ../../glossary.rst:1073 msgid "def func(arg, *, kw_only1, kw_only2): ..." msgstr "def func(arg, *, kw_only1, kw_only2): ..." -#: ../../glossary.rst:1018 +#: ../../glossary.rst:1075 msgid "" ":dfn:`var-positional`: specifies that an arbitrary sequence of positional " "arguments can be provided (in addition to any positional arguments already " @@ -2332,11 +2437,11 @@ msgstr "" "數(在已被其他參數接受的任何位置引數之外)。這類參數是透過在其參數名稱字首加" "上 ``*`` 來定義的,例如以下的 *args*: ::" -#: ../../glossary.rst:1024 +#: ../../glossary.rst:1081 msgid "def func(*args, **kwargs): ..." msgstr "def func(*args, **kwargs): ..." -#: ../../glossary.rst:1026 +#: ../../glossary.rst:1083 msgid "" ":dfn:`var-keyword`: specifies that arbitrarily many keyword arguments can be " "provided (in addition to any keyword arguments already accepted by other " @@ -2347,14 +2452,14 @@ msgstr "" "已被其他參數接受的任何關鍵字引數之外)。這類參數是透過在其參數名稱字首加上 " "``**`` 來定義的,例如上面範例中的 *kwargs*。" -#: ../../glossary.rst:1032 +#: ../../glossary.rst:1089 msgid "" "Parameters can specify both optional and required arguments, as well as " "default values for some optional arguments." msgstr "" "參數可以指明引數是選擇性的或必需的,也可以為一些選擇性的引數指定預設值。" -#: ../../glossary.rst:1035 +#: ../../glossary.rst:1092 msgid "" "See also the :term:`argument` glossary entry, the FAQ question on :ref:`the " "difference between arguments and parameters `, " @@ -2365,11 +2470,11 @@ msgstr "" "參數之間的差異 `、:class:`inspect.Parameter` " "class、:ref:`function`\\ 章節,以及 :pep:`362`。" -#: ../../glossary.rst:1039 +#: ../../glossary.rst:1096 msgid "path entry" msgstr "path entry(路徑項目)" -#: ../../glossary.rst:1041 +#: ../../glossary.rst:1098 msgid "" "A single location on the :term:`import path` which the :term:`path based " "finder` consults to find modules for importing." @@ -2377,11 +2482,11 @@ msgstr "" "在 :term:`import path`\\ (引入路徑)中的一個位置,而 :term:`path based " "finder` (基於路徑的尋檢器)會參考該位置來尋找要 import 的模組。" -#: ../../glossary.rst:1043 +#: ../../glossary.rst:1100 msgid "path entry finder" msgstr "path entry finder(路徑項目尋檢器)" -#: ../../glossary.rst:1045 +#: ../../glossary.rst:1102 msgid "" "A :term:`finder` returned by a callable on :data:`sys.path_hooks` (i.e. a :" "term:`path entry hook`) which knows how to locate modules given a :term:" @@ -2391,7 +2496,7 @@ msgstr "" "`path entry hook`\\ )所回傳的一種 :term:`finder`,它知道如何以一個 :term:" "`path entry`\\ 定位模組。" -#: ../../glossary.rst:1049 +#: ../../glossary.rst:1106 msgid "" "See :class:`importlib.abc.PathEntryFinder` for the methods that path entry " "finders implement." @@ -2399,11 +2504,11 @@ msgstr "" "關於路徑項目尋檢器實作的 method,請參閱 :class:`importlib.abc." "PathEntryFinder`。" -#: ../../glossary.rst:1051 +#: ../../glossary.rst:1108 msgid "path entry hook" msgstr "path entry hook(路徑項目鉤)" -#: ../../glossary.rst:1053 +#: ../../glossary.rst:1110 msgid "" "A callable on the :data:`sys.path_hooks` list which returns a :term:`path " "entry finder` if it knows how to find modules on a specific :term:`path " @@ -2413,11 +2518,11 @@ msgstr "" "個特定的 :term:`path entry` 中尋找模組,則會回傳一個 :term:`path entry " "finder`\\ (路徑項目尋檢器)。" -#: ../../glossary.rst:1056 +#: ../../glossary.rst:1113 msgid "path based finder" msgstr "path based finder(基於路徑的尋檢器)" -#: ../../glossary.rst:1058 +#: ../../glossary.rst:1115 msgid "" "One of the default :term:`meta path finders ` which " "searches an :term:`import path` for modules." @@ -2425,11 +2530,11 @@ msgstr "" "預設的\\ :term:`元路徑尋檢器 (meta path finder) ` 之一,它" "會在一個 :term:`import path` 中搜尋模組。" -#: ../../glossary.rst:1060 +#: ../../glossary.rst:1117 msgid "path-like object" msgstr "path-like object(類路徑物件)" -#: ../../glossary.rst:1062 +#: ../../glossary.rst:1119 msgid "" "An object representing a file system path. A path-like object is either a :" "class:`str` or :class:`bytes` object representing a path, or an object " @@ -2447,11 +2552,11 @@ msgstr "" "`os.fsencode` 則分別可用於確保 :class:`str` 及 :class:`bytes` 的結果。由 :" "pep:`519` 引入。" -#: ../../glossary.rst:1070 +#: ../../glossary.rst:1127 msgid "PEP" msgstr "PEP" -#: ../../glossary.rst:1072 +#: ../../glossary.rst:1129 msgid "" "Python Enhancement Proposal. A PEP is a design document providing " "information to the Python community, or describing a new feature for Python " @@ -2462,7 +2567,7 @@ msgstr "" "為 Python 社群提供資訊,或是描述 Python 的一個新功能或該功能的程序和環境。" "PEP 應該要提供簡潔的技術規範以及被提案功能的運作原理。" -#: ../../glossary.rst:1078 +#: ../../glossary.rst:1135 msgid "" "PEPs are intended to be the primary mechanisms for proposing major new " "features, for collecting community input on an issue, and for documenting " @@ -2474,15 +2579,15 @@ msgstr "" "已納入 Python 的設計決策的記錄,這些過程的主要機制。PEP 的作者要負責在社群內" "建立共識並記錄反對意見。" -#: ../../glossary.rst:1084 +#: ../../glossary.rst:1141 msgid "See :pep:`1`." msgstr "請參閱 :pep:`1`。" -#: ../../glossary.rst:1085 +#: ../../glossary.rst:1142 msgid "portion" msgstr "portion(部分)" -#: ../../glossary.rst:1087 +#: ../../glossary.rst:1144 msgid "" "A set of files in a single directory (possibly stored in a zip file) that " "contribute to a namespace package, as defined in :pep:`420`." @@ -2490,15 +2595,15 @@ msgstr "" "在單一目錄中的一組檔案(也可能儲存在一個 zip 檔中),這些檔案能對一個命名空間" "套件 (namespace package) 有所貢獻,如同 :pep:`420` 中的定義。" -#: ../../glossary.rst:1089 +#: ../../glossary.rst:1146 msgid "positional argument" msgstr "positional argument(位置引數)" -#: ../../glossary.rst:1092 +#: ../../glossary.rst:1149 msgid "provisional API" msgstr "provisional API(暫行 API)" -#: ../../glossary.rst:1094 +#: ../../glossary.rst:1151 msgid "" "A provisional API is one which has been deliberately excluded from the " "standard library's backwards compatibility guarantees. While major changes " @@ -2514,7 +2619,7 @@ msgstr "" "該介面)。這種變更並不會無端地產生——只有 API 被納入之前未察覺的嚴重基本缺陷被" "揭露時,它們才會發生。" -#: ../../glossary.rst:1103 +#: ../../glossary.rst:1160 msgid "" "Even for provisional APIs, backwards incompatible changes are seen as a " "\"solution of last resort\" - every attempt will still be made to find a " @@ -2523,7 +2628,7 @@ msgstr "" "即使對於暫行 API,向後不相容的變更也會被視為「最後的解決方案」——對於任何被發" "現的問題,仍然會盡可能找出一個向後相容的解決方案。" -#: ../../glossary.rst:1107 +#: ../../glossary.rst:1164 msgid "" "This process allows the standard library to continue to evolve over time, " "without locking in problematic design errors for extended periods of time. " @@ -2532,19 +2637,19 @@ msgstr "" "這個過程使得標準函式庫能隨著時間不斷進化,而避免耗費過長的時間去鎖定有問題的" "設計錯誤。請參閱 :pep:`411` 了解更多細節。" -#: ../../glossary.rst:1110 +#: ../../glossary.rst:1167 msgid "provisional package" msgstr "provisional package(暫行套件)" -#: ../../glossary.rst:1112 +#: ../../glossary.rst:1169 msgid "See :term:`provisional API`." msgstr "請參閱 :term:`provisional API`\\ (暫行 API)。" -#: ../../glossary.rst:1113 +#: ../../glossary.rst:1170 msgid "Python 3000" msgstr "Python 3000" -#: ../../glossary.rst:1115 +#: ../../glossary.rst:1172 msgid "" "Nickname for the Python 3.x release line (coined long ago when the release " "of version 3 was something in the distant future.) This is also abbreviated " @@ -2553,11 +2658,11 @@ msgstr "" "Python 3.x 系列版本的暱稱(很久以前創造的,當時第 3 版的發布是在遙遠的未" "來。)也可以縮寫為「Py3k」。" -#: ../../glossary.rst:1118 +#: ../../glossary.rst:1175 msgid "Pythonic" msgstr "Pythonic(Python 風格的)" -#: ../../glossary.rst:1120 +#: ../../glossary.rst:1177 msgid "" "An idea or piece of code which closely follows the most common idioms of the " "Python language, rather than implementing code using concepts common to " @@ -2571,7 +2676,7 @@ msgstr "" "keyword:`for` 陳述式,對一個可疊代物件的所有元素進行迴圈。許多其他語言並沒有" "這種類型的架構,所以不熟悉 Python 的人有時會使用一個數值計數器來代替: ::" -#: ../../glossary.rst:1127 +#: ../../glossary.rst:1184 msgid "" "for i in range(len(food)):\n" " print(food[i])" @@ -2579,11 +2684,11 @@ msgstr "" "for i in range(len(food)):\n" " print(food[i])" -#: ../../glossary.rst:1130 +#: ../../glossary.rst:1187 msgid "As opposed to the cleaner, Pythonic method::" msgstr "相較之下,以下方法更簡潔、更具有 Python 風格: ::" -#: ../../glossary.rst:1132 +#: ../../glossary.rst:1189 msgid "" "for piece in food:\n" " print(piece)" @@ -2591,11 +2696,11 @@ msgstr "" "for piece in food:\n" " print(piece)" -#: ../../glossary.rst:1134 +#: ../../glossary.rst:1191 msgid "qualified name" msgstr "qualified name(限定名稱)" -#: ../../glossary.rst:1136 +#: ../../glossary.rst:1193 msgid "" "A dotted name showing the \"path\" from a module's global scope to a class, " "function or method defined in that module, as defined in :pep:`3155`. For " @@ -2606,7 +2711,7 @@ msgstr "" "或 method 的「路徑」,如 :pep:`3155` 中的定義。對於頂層的函式和 class 而言," "限定名稱與其物件名稱相同: ::" -#: ../../glossary.rst:1141 +#: ../../glossary.rst:1198 msgid "" ">>> class C:\n" "... class D:\n" @@ -2632,7 +2737,7 @@ msgstr "" ">>> C.D.meth.__qualname__\n" "'C.D.meth'" -#: ../../glossary.rst:1153 +#: ../../glossary.rst:1210 msgid "" "When used to refer to modules, the *fully qualified name* means the entire " "dotted path to the module, including any parent packages, e.g. ``email.mime." @@ -2641,7 +2746,7 @@ msgstr "" "當用於引用模組時,*完全限定名稱 (fully qualified name)* 是表示該模組的完整點" "分隔路徑,包括任何的父套件,例如 ``email.mime.text``: ::" -#: ../../glossary.rst:1157 +#: ../../glossary.rst:1214 msgid "" ">>> import email.mime.text\n" ">>> email.mime.text.__name__\n" @@ -2651,11 +2756,11 @@ msgstr "" ">>> email.mime.text.__name__\n" "'email.mime.text'" -#: ../../glossary.rst:1160 +#: ../../glossary.rst:1217 msgid "reference count" msgstr "reference count(參照計數)" -#: ../../glossary.rst:1162 +#: ../../glossary.rst:1219 msgid "" "The number of references to an object. When the reference count of an " "object drops to zero, it is deallocated. Some objects are :term:`immortal` " @@ -2671,7 +2776,7 @@ msgstr "" "看不到,但它卻是 :term:`CPython` 實作的一個關鍵元素。程式設計師可以呼叫 :" "func:`~sys.getrefcount` 函式來回傳一個特定物件的參照計數。" -#: ../../glossary.rst:1171 +#: ../../glossary.rst:1228 msgid "" "In :term:`CPython`, reference counts are not considered to be stable or well-" "defined values; the number of references to an object, and how that number " @@ -2680,11 +2785,11 @@ msgstr "" "在 :term:`CPython` 中,參照計數不被視為穩定或明確定義的值;對物件的參照數量," "以及該數量如何受到 Python 程式碼的影響,在不同版本之間可能會有所不同。" -#: ../../glossary.rst:1175 +#: ../../glossary.rst:1232 msgid "regular package" msgstr "regular package(正規套件)" -#: ../../glossary.rst:1177 +#: ../../glossary.rst:1234 msgid "" "A traditional :term:`package`, such as a directory containing an ``__init__." "py`` file." @@ -2692,15 +2797,15 @@ msgstr "" "一個傳統的 :term:`package`\\ (套件),例如一個包含 ``__init__.py`` 檔案的目" "錄。" -#: ../../glossary.rst:1180 +#: ../../glossary.rst:1237 msgid "See also :term:`namespace package`." msgstr "另請參閱 :term:`namespace package`\\ (命名空間套件)。" -#: ../../glossary.rst:1181 +#: ../../glossary.rst:1238 msgid "REPL" msgstr "REPL" -#: ../../glossary.rst:1183 +#: ../../glossary.rst:1240 msgid "" "An acronym for the \"read–eval–print loop\", another name for the :term:" "`interactive` interpreter shell." @@ -2708,11 +2813,11 @@ msgstr "" "「read-eval-print 迴圈 (read–eval–print loop)」的縮寫,是\\ :term:`互動式 " "`\\ 直譯器 shell 的另一個名稱。" -#: ../../glossary.rst:1185 +#: ../../glossary.rst:1242 msgid "__slots__" msgstr "__slots__" -#: ../../glossary.rst:1187 +#: ../../glossary.rst:1244 msgid "" "A declaration inside a class that saves memory by pre-declaring space for " "instance attributes and eliminating instance dictionaries. Though popular, " @@ -2725,11 +2830,11 @@ msgstr "" "最好保留給那種在一個記憶體關鍵 (memory-critical) 的應用程式中存在大量實例的罕" "見情況。" -#: ../../glossary.rst:1192 +#: ../../glossary.rst:1249 msgid "sequence" msgstr "sequence(序列)" -#: ../../glossary.rst:1194 +#: ../../glossary.rst:1251 msgid "" "An :term:`iterable` which supports efficient element access using integer " "indices via the :meth:`~object.__getitem__` special method and defines a :" @@ -2748,28 +2853,28 @@ msgstr "" "為對映 (mapping) 而不是序列,因為其查找方式是使用任意的 :term:`hashable` 鍵," "而不是整數。" -#: ../../glossary.rst:1203 +#: ../../glossary.rst:1260 msgid "" "The :class:`collections.abc.Sequence` abstract base class defines a much " "richer interface that goes beyond just :meth:`~object.__getitem__` and :meth:" -"`~object.__len__`, adding :meth:`!count`, :meth:`!index`, :meth:`~object." -"__contains__`, and :meth:`~object.__reversed__`. Types that implement this " -"expanded interface can be registered explicitly using :func:`~abc.ABCMeta." -"register`. For more documentation on sequence methods generally, see :ref:" -"`Common Sequence Operations `." +"`~object.__len__`, adding :meth:`~sequence.count`, :meth:`~sequence.index`, :" +"meth:`~object.__contains__`, and :meth:`~object.__reversed__`. Types that " +"implement this expanded interface can be registered explicitly using :func:" +"`~abc.ABCMeta.register`. For more documentation on sequence methods " +"generally, see :ref:`Common Sequence Operations `." msgstr "" "抽象基底類別 (abstract base class) :class:`collections.abc.Sequence` 定義了一" "個更加豐富的介面,並不僅止於 :meth:`~object.__getitem__` 和 :meth:`~object." -"__len__`,還增加了 :meth:`!count`、:meth:`!index`、:meth:`~object." -"__contains__` 和 :meth:`~object.__reversed__`。實作此擴充介面的型別,可以使" -"用 :func:`~abc.ABCMeta.register` 被明確地註冊。更多關於序列方法的文件,請見" -"\\ :ref:`常見序列操作 `。" +"__len__`,還增加了 :meth:`~sequence.count`、:meth:`~sequence.index`、:meth:" +"`~object.__contains__` 和 :meth:`~object.__reversed__`。實作此擴充介面的型" +"別,可以使用 :func:`~abc.ABCMeta.register` 被明確地註冊。更多關於序列方法的文" +"件,請見\\ :ref:`常見序列操作 `。" -#: ../../glossary.rst:1212 +#: ../../glossary.rst:1270 msgid "set comprehension" msgstr "set comprehension(集合綜合運算)" -#: ../../glossary.rst:1214 +#: ../../glossary.rst:1272 msgid "" "A compact way to process all or part of the elements in an iterable and " "return a set with the results. ``results = {c for c in 'abracadabra' if c " @@ -2780,11 +2885,11 @@ msgstr "" "set 回傳。``results = {c for c in 'abracadabra' if c not in 'abc'}`` 會產生一" "個字串 set:``{'r', 'd'}``。請參閱\\ :ref:`comprehensions`。" -#: ../../glossary.rst:1218 +#: ../../glossary.rst:1276 msgid "single dispatch" msgstr "single dispatch(單一調度)" -#: ../../glossary.rst:1220 +#: ../../glossary.rst:1278 msgid "" "A form of :term:`generic function` dispatch where the implementation is " "chosen based on the type of a single argument." @@ -2792,11 +2897,11 @@ msgstr "" ":term:`generic function`\\ (泛型函式)調度的一種形式,在此,實作的選擇是基於" "單一引數的型別。" -#: ../../glossary.rst:1222 +#: ../../glossary.rst:1280 msgid "slice" msgstr "slice(切片)" -#: ../../glossary.rst:1224 +#: ../../glossary.rst:1282 msgid "" "An object usually containing a portion of a :term:`sequence`. A slice is " "created using the subscript notation, ``[]`` with colons between numbers " @@ -2808,11 +2913,11 @@ msgstr "" "之間使用冒號,例如 ``variable_name[1:3:5]``。在括號(下標)符號的內部,會使" "用 :class:`slice` 物件。" -#: ../../glossary.rst:1228 +#: ../../glossary.rst:1286 msgid "soft deprecated" msgstr "soft deprecated(軟性棄用)" -#: ../../glossary.rst:1230 +#: ../../glossary.rst:1288 msgid "" "A soft deprecated API should not be used in new code, but it is safe for " "already existing code to use it. The API remains documented and tested, but " @@ -2821,13 +2926,13 @@ msgstr "" "被軟性棄用的 API 代表不應再用於新程式碼中,但在現有程式碼中繼續使用它仍會是安" "全的。API 仍會以文件記錄並會被測試,但不會被繼續改進。" -#: ../../glossary.rst:1234 +#: ../../glossary.rst:1292 msgid "" "Soft deprecation, unlike normal deprecation, does not plan on removing the " "API and will not emit warnings." msgstr "與正常棄用不同,軟性棄用沒有刪除 API 的規劃,也不會發出警告。" -#: ../../glossary.rst:1237 +#: ../../glossary.rst:1295 msgid "" "See `PEP 387: Soft Deprecation `_." @@ -2835,11 +2940,11 @@ msgstr "" "請參閱 `PEP 387:軟性棄用 `_。" -#: ../../glossary.rst:1239 +#: ../../glossary.rst:1297 msgid "special method" msgstr "special method(特殊方法)" -#: ../../glossary.rst:1243 +#: ../../glossary.rst:1301 msgid "" "A method that is called implicitly by Python to execute a certain operation " "on a type, such as addition. Such methods have names starting and ending " @@ -2850,11 +2955,11 @@ msgstr "" "種 method 的名稱會在開頭和結尾有兩個下底線。Special method 在\\ :ref:" "`specialnames`\\ 中有詳細說明。" -#: ../../glossary.rst:1247 +#: ../../glossary.rst:1305 msgid "standard library" msgstr "標準函式庫" -#: ../../glossary.rst:1249 +#: ../../glossary.rst:1307 msgid "" "The collection of :term:`packages `, :term:`modules ` and :" "term:`extension modules ` distributed as a part of the " @@ -2867,7 +2972,7 @@ msgstr "" "行。該集合的成員可能會因平台、可用的系統函式庫或其他條件而有所不同。相關文件" "可以在 :ref:`library-index` 中找到。" -#: ../../glossary.rst:1255 +#: ../../glossary.rst:1313 msgid "" "See also :data:`sys.stdlib_module_names` for a list of all possible standard " "library module names." @@ -2875,11 +2980,11 @@ msgstr "" "請參閱 :data:`sys.stdlib_module_names` 以取得所有可能的標準函式庫模組名稱的列" "表。" -#: ../../glossary.rst:1257 +#: ../../glossary.rst:1315 msgid "statement" msgstr "statement(陳述式)" -#: ../../glossary.rst:1259 +#: ../../glossary.rst:1317 msgid "" "A statement is part of a suite (a \"block\" of code). A statement is either " "an :term:`expression` or one of several constructs with a keyword, such as :" @@ -2889,11 +2994,11 @@ msgstr "" "term:`expression`\\ (運算式),或是含有關鍵字(例如 :keyword:`if`、:keyword:" "`while` 或 :keyword:`for`\\ )的多種結構之一。" -#: ../../glossary.rst:1262 +#: ../../glossary.rst:1320 msgid "static type checker" msgstr "static type checker(靜態型別檢查器)" -#: ../../glossary.rst:1264 +#: ../../glossary.rst:1322 msgid "" "An external tool that reads Python code and analyzes it, looking for issues " "such as incorrect types. See also :term:`type hints ` and the :" @@ -2903,19 +3008,19 @@ msgstr "" "另請參閱\\ :term:`型別提示 (type hints) ` 以及 :mod:`typing` 模" "組。" -#: ../../glossary.rst:1267 +#: ../../glossary.rst:1325 msgid "stdlib" msgstr "stdlib(標準函式庫)" -#: ../../glossary.rst:1269 +#: ../../glossary.rst:1327 msgid "An abbreviation of :term:`standard library`." msgstr ":term:`standard library` 的縮寫。" -#: ../../glossary.rst:1270 +#: ../../glossary.rst:1328 msgid "strong reference" msgstr "strong reference(強參照)" -#: ../../glossary.rst:1272 +#: ../../glossary.rst:1330 msgid "" "In Python's C API, a strong reference is a reference to an object which is " "owned by the code holding the reference. The strong reference is taken by " @@ -2926,7 +3031,7 @@ msgstr "" "有。建立參照時透過呼叫 :c:func:`Py_INCREF` 來獲得強參照、刪除參照時透過 :c:" "func:`Py_DECREF` 釋放強參照。" -#: ../../glossary.rst:1278 +#: ../../glossary.rst:1336 msgid "" "The :c:func:`Py_NewRef` function can be used to create a strong reference to " "an object. Usually, the :c:func:`Py_DECREF` function must be called on the " @@ -2936,24 +3041,41 @@ msgstr "" ":c:func:`Py_NewRef` 函式可用於建立一個對物件的強參照。通常,在退出強參照的作" "用域之前,必須在該強參照上呼叫 :c:func:`Py_DECREF` 函式,以避免洩漏一個參照。" -#: ../../glossary.rst:1283 +#: ../../glossary.rst:1341 msgid "See also :term:`borrowed reference`." msgstr "另請參閱 :term:`borrowed reference`\\ (借用參照)。" -#: ../../glossary.rst:1284 +#: ../../glossary.rst:1342 +msgid "t-string" +msgstr "t-string(t 字串)" + +#: ../../glossary.rst:1343 +msgid "t-strings" +msgstr "t-strings(t 字串)" + +#: ../../glossary.rst:1345 +msgid "" +"String literals prefixed with ``t`` or ``T`` are commonly called \"t-" +"strings\" which is short for :ref:`template string literals `." +msgstr "" +"以 ``t`` 或 ``T`` 為前綴的字串文本通常被稱為「t 字串」,它是\\ :ref:`模板化的" +"字串文本 `\\ 的縮寫。" + +#: ../../glossary.rst:1348 msgid "text encoding" msgstr "text encoding(文字編碼)" -#: ../../glossary.rst:1286 +#: ../../glossary.rst:1350 msgid "" "A string in Python is a sequence of Unicode code points (in range " "``U+0000``--``U+10FFFF``). To store or transfer a string, it needs to be " "serialized as a sequence of bytes." msgstr "" -"Python 中的字串是一個 Unicode 碼點 (code point) 的序列(範圍在 ``U+0000`` -- " -"``U+10FFFF`` 之間)。若要儲存或傳送一個字串,它必須被序列化為一個位元組序列。" +"Python 中的字串是一個 Unicode 編碼位置 (code point) 的序列(範圍在 " +"``U+0000`` -- ``U+10FFFF`` 之間)。若要儲存或傳送一個字串,它必須被序列化為一" +"個位元組序列。" -#: ../../glossary.rst:1290 +#: ../../glossary.rst:1354 msgid "" "Serializing a string into a sequence of bytes is known as \"encoding\", and " "recreating the string from the sequence of bytes is known as \"decoding\"." @@ -2961,7 +3083,7 @@ msgstr "" "將一個字串序列化為位元組序列,稱為「編碼」,而從位元組序列重新建立該字串則稱" "為「解碼 (decoding)」。" -#: ../../glossary.rst:1293 +#: ../../glossary.rst:1357 msgid "" "There are a variety of different text serialization :ref:`codecs `, which are collectively referred to as \"text encodings\"." @@ -2969,11 +3091,11 @@ msgstr "" "有多種不同的文字序列化編解碼器 (:ref:`codecs `),它們被統" "稱為「文字編碼」。" -#: ../../glossary.rst:1296 +#: ../../glossary.rst:1360 msgid "text file" msgstr "text file(文字檔案)" -#: ../../glossary.rst:1298 +#: ../../glossary.rst:1362 msgid "" "A :term:`file object` able to read and write :class:`str` objects. Often, a " "text file actually accesses a byte-oriented datastream and handles the :term:" @@ -2987,7 +3109,7 @@ msgstr "" "有:以文字模式(``'r'`` 或 ``'w'``)開啟的檔案、:data:`sys.stdin`、:data:" "`sys.stdout` 以及 :class:`io.StringIO` 的實例。" -#: ../../glossary.rst:1305 +#: ../../glossary.rst:1369 msgid "" "See also :term:`binary file` for a file object able to read and write :term:" "`bytes-like objects `." @@ -2995,11 +3117,51 @@ msgstr "" "另請參閱 :term:`binary file`\\ (二進位檔案),它是一個能夠讀取和寫入\\ :" "term:`類位元組串物件 (bytes-like object) ` 的檔案物件。" -#: ../../glossary.rst:1307 +#: ../../glossary.rst:1371 +msgid "thread state" +msgstr "" + +#: ../../glossary.rst:1374 +msgid "" +"The information used by the :term:`CPython` runtime to run in an OS thread. " +"For example, this includes the current exception, if any, and the state of " +"the bytecode interpreter." +msgstr "" + +#: ../../glossary.rst:1378 +msgid "" +"Each thread state is bound to a single OS thread, but threads may have many " +"thread states available. At most, one of them may be :term:`attached " +"` at once." +msgstr "" + +#: ../../glossary.rst:1382 +msgid "" +"An :term:`attached thread state` is required to call most of Python's C API, " +"unless a function explicitly documents otherwise. The bytecode interpreter " +"only runs under an attached thread state." +msgstr "" + +#: ../../glossary.rst:1386 +msgid "" +"Each thread state belongs to a single interpreter, but each interpreter may " +"have many thread states, including multiple for the same OS thread. Thread " +"states from multiple interpreters may be bound to the same thread, but only " +"one can be :term:`attached ` in that thread at any " +"given moment." +msgstr "" + +#: ../../glossary.rst:1392 +msgid "" +"See :ref:`Thread State and the Global Interpreter Lock ` for more " +"information." +msgstr "" + +#: ../../glossary.rst:1394 msgid "token" msgstr "token" -#: ../../glossary.rst:1310 +#: ../../glossary.rst:1397 msgid "" "A small unit of source code, generated by the :ref:`lexical analyzer " "` (also called the *tokenizer*). Names, numbers, strings, " @@ -3008,7 +3170,7 @@ msgstr "" "原始碼的小單位,由 :ref:`詞法分析器 ` (也稱為 *tokenizer*)產生。名" "稱、數字、字串、運算子、換行符號等都以 token 表示。" -#: ../../glossary.rst:1315 +#: ../../glossary.rst:1402 msgid "" "The :mod:`tokenize` module exposes Python's lexical analyzer. The :mod:" "`token` module contains information on the various types of tokens." @@ -3016,11 +3178,11 @@ msgstr "" ":mod:`tokenize` 模組公開了 Python 的詞法分析器。:mod:`token` 模組包含各種 " "token 類型的資訊。" -#: ../../glossary.rst:1318 +#: ../../glossary.rst:1405 msgid "triple-quoted string" msgstr "triple-quoted string(三引號內字串)" -#: ../../glossary.rst:1320 +#: ../../glossary.rst:1407 msgid "" "A string which is bound by three instances of either a quotation mark (\") " "or an apostrophe ('). While they don't provide any functionality not " @@ -3035,11 +3197,11 @@ msgstr "" "中包含未跳脫 (unescaped) 的單引號和雙引號,而且它們不需使用連續字元 " "(continuation character) 就可以跨越多行,這使得它們在編寫說明字串時特別有用。" -#: ../../glossary.rst:1327 +#: ../../glossary.rst:1414 msgid "type" msgstr "type(型別)" -#: ../../glossary.rst:1329 +#: ../../glossary.rst:1416 msgid "" "The type of a Python object determines what kind of object it is; every " "object has a type. An object's type is accessible as its :attr:`~object." @@ -3049,22 +3211,22 @@ msgstr "" "件的型別可以用它的 :attr:`~object.__class__` 屬性來存取,或以 ``type(obj)`` " "來檢索。" -#: ../../glossary.rst:1333 +#: ../../glossary.rst:1420 msgid "type alias" msgstr "type alias(型別別名)" -#: ../../glossary.rst:1335 +#: ../../glossary.rst:1422 msgid "A synonym for a type, created by assigning the type to an identifier." msgstr "一個型別的同義詞,透過將型別指定給一個識別符 (identifier) 來建立。" -#: ../../glossary.rst:1337 +#: ../../glossary.rst:1424 msgid "" "Type aliases are useful for simplifying :term:`type hints `. For " "example::" msgstr "" "型別別名對於簡化\\ :term:`型別提示 (type hint) ` 很有用。例如: ::" -#: ../../glossary.rst:1340 +#: ../../glossary.rst:1427 msgid "" "def remove_gray_shades(\n" " colors: list[tuple[int, int, int]]) -> list[tuple[int, int, int]]:\n" @@ -3074,11 +3236,11 @@ msgstr "" " colors: list[tuple[int, int, int]]) -> list[tuple[int, int, int]]:\n" " pass" -#: ../../glossary.rst:1344 +#: ../../glossary.rst:1431 msgid "could be made more readable like this::" msgstr "可以寫成這樣,更具有可讀性: ::" -#: ../../glossary.rst:1346 +#: ../../glossary.rst:1433 msgid "" "Color = tuple[int, int, int]\n" "\n" @@ -3090,15 +3252,15 @@ msgstr "" "def remove_gray_shades(colors: list[Color]) -> list[Color]:\n" " pass" -#: ../../glossary.rst:1351 ../../glossary.rst:1365 +#: ../../glossary.rst:1438 ../../glossary.rst:1452 msgid "See :mod:`typing` and :pep:`484`, which describe this functionality." msgstr "請參閱 :mod:`typing` 和 :pep:`484`,有此功能的描述。" -#: ../../glossary.rst:1352 +#: ../../glossary.rst:1439 msgid "type hint" msgstr "type hint(型別提示)" -#: ../../glossary.rst:1354 +#: ../../glossary.rst:1441 msgid "" "An :term:`annotation` that specifies the expected type for a variable, a " "class attribute, or a function parameter or return value." @@ -3106,7 +3268,7 @@ msgstr "" "一種 :term:`annotation`\\ (註釋),它指定一個變數、一個 class 屬性或一個函式" "的參數或回傳值的預期型別。" -#: ../../glossary.rst:1357 +#: ../../glossary.rst:1444 msgid "" "Type hints are optional and are not enforced by Python but they are useful " "to :term:`static type checkers `. They can also aid " @@ -3116,7 +3278,7 @@ msgstr "" "(static type checkers) `\\ 很有用,並能協助 IDE 完成程式" "碼的補全 (completion) 和重構 (refactoring)。" -#: ../../glossary.rst:1361 +#: ../../glossary.rst:1448 msgid "" "Type hints of global variables, class attributes, and functions, but not " "local variables, can be accessed using :func:`typing.get_type_hints`." @@ -3124,11 +3286,11 @@ msgstr "" "全域變數、class 屬性和函式(不含區域變數)的型別提示,都可以使用 :func:" "`typing.get_type_hints` 來存取。" -#: ../../glossary.rst:1366 +#: ../../glossary.rst:1453 msgid "universal newlines" msgstr "universal newlines(通用換行字元)" -#: ../../glossary.rst:1368 +#: ../../glossary.rst:1455 msgid "" "A manner of interpreting text streams in which all of the following are " "recognized as ending a line: the Unix end-of-line convention ``'\\n'``, the " @@ -3141,20 +3303,20 @@ msgstr "" "``'\\r'``。請參閱 :pep:`278` 和 :pep:`3116`,以及用於 :func:`bytes." "splitlines` 的附加用途。" -#: ../../glossary.rst:1373 +#: ../../glossary.rst:1460 msgid "variable annotation" msgstr "variable annotation(變數註釋)" -#: ../../glossary.rst:1375 +#: ../../glossary.rst:1462 msgid "An :term:`annotation` of a variable or a class attribute." msgstr "一個變數或 class 屬性的 :term:`annotation`\\ (註釋)。" -#: ../../glossary.rst:1377 +#: ../../glossary.rst:1464 msgid "" "When annotating a variable or a class attribute, assignment is optional::" msgstr "註釋變數或 class 屬性時,賦值是選擇性的: ::" -#: ../../glossary.rst:1379 +#: ../../glossary.rst:1466 msgid "" "class C:\n" " field: 'annotation'" @@ -3162,7 +3324,7 @@ msgstr "" "class C:\n" " field: 'annotation'" -#: ../../glossary.rst:1382 +#: ../../glossary.rst:1469 msgid "" "Variable annotations are usually used for :term:`type hints `: " "for example this variable is expected to take :class:`int` values::" @@ -3170,15 +3332,15 @@ msgstr "" "變數註釋通常用於\\ :term:`型別提示 (type hint) `:例如,這個變數預" "期會取得 :class:`int`\\ (整數)值: ::" -#: ../../glossary.rst:1386 +#: ../../glossary.rst:1473 msgid "count: int = 0" msgstr "count: int = 0" -#: ../../glossary.rst:1388 +#: ../../glossary.rst:1475 msgid "Variable annotation syntax is explained in section :ref:`annassign`." msgstr "變數註釋的語法在\\ :ref:`annassign`\\ 章節有詳細的解釋。" -#: ../../glossary.rst:1390 +#: ../../glossary.rst:1477 msgid "" "See :term:`function annotation`, :pep:`484` and :pep:`526`, which describe " "this functionality. Also see :ref:`annotations-howto` for best practices on " @@ -3187,11 +3349,11 @@ msgstr "" "請參閱 :term:`function annotation`\\ (函式註釋)、:pep:`484` 和 :pep:`526`," "皆有此功能的描述。關於註釋的最佳實踐方法,另請參閱 :ref:`annotations-howto`。" -#: ../../glossary.rst:1394 +#: ../../glossary.rst:1481 msgid "virtual environment" msgstr "virtual environment(虛擬環境)" -#: ../../glossary.rst:1396 +#: ../../glossary.rst:1483 msgid "" "A cooperatively isolated runtime environment that allows Python users and " "applications to install and upgrade Python distribution packages without " @@ -3202,15 +3364,15 @@ msgstr "" "程式得以安裝和升級 Python 發佈套件,而不會對同一個系統上運行的其他 Python 應" "用程式的行為產生干擾。" -#: ../../glossary.rst:1401 +#: ../../glossary.rst:1488 msgid "See also :mod:`venv`." msgstr "另請參閱 :mod:`venv`。" -#: ../../glossary.rst:1402 +#: ../../glossary.rst:1489 msgid "virtual machine" msgstr "virtual machine(虛擬機器)" -#: ../../glossary.rst:1404 +#: ../../glossary.rst:1491 msgid "" "A computer defined entirely in software. Python's virtual machine executes " "the :term:`bytecode` emitted by the bytecode compiler." @@ -3218,22 +3380,22 @@ msgstr "" "一部完全由軟體所定義的電腦 (computer)。Python 的虛擬機器會執行由 :term:" "`bytecode`\\ (位元組碼)編譯器所發出的位元組碼。" -#: ../../glossary.rst:1406 +#: ../../glossary.rst:1493 msgid "walrus operator" msgstr "walrus operator(海象運算子)" -#: ../../glossary.rst:1408 +#: ../../glossary.rst:1495 msgid "" "A light-hearted way to refer to the :ref:`assignment expression ` operator ``:=`` because it looks a bit like a walrus if you " "turn your head." msgstr "" -#: ../../glossary.rst:1411 +#: ../../glossary.rst:1498 msgid "Zen of Python" msgstr "Zen of Python(Python 之禪)" -#: ../../glossary.rst:1413 +#: ../../glossary.rst:1500 msgid "" "Listing of Python design principles and philosophies that are helpful in " "understanding and using the language. The listing can be found by typing " @@ -3242,84 +3404,29 @@ msgstr "" "Python 設計原則與哲學的列表,其內容有助於理解和使用此語言。此列表可以透過在互" "動式提式字元後輸入「``import this``」來找到它。" -#: ../../glossary.rst:292 +#: ../../glossary.rst:24 +msgid "..." +msgstr "..." + +#: ../../glossary.rst:24 +msgid "ellipsis literal" +msgstr "刪節號字面值" + +#: ../../glossary.rst:321 msgid "C-contiguous" msgstr "C-contiguous(C 連續的)" -#: ../../glossary.rst:292 +#: ../../glossary.rst:321 msgid "Fortran contiguous" msgstr "Fortran contiguous(Fortran 連續的)" -#: ../../glossary.rst:836 +#: ../../glossary.rst:884 msgid "magic" msgstr "magic" -#: ../../glossary.rst:1241 +#: ../../glossary.rst:1299 msgid "special" msgstr "special" -#~ msgid "" -#~ "An object which controls the environment seen in a :keyword:`with` " -#~ "statement by defining :meth:`~object.__enter__` and :meth:`~object." -#~ "__exit__` methods. See :pep:`343`." -#~ msgstr "" -#~ "一個可以控制 :keyword:`with` 陳述式中所見環境的物件,而它是透過定義 :meth:" -#~ "`~object.__enter__` 和 :meth:`~object.__exit__` method 來控制的。請參閱 :" -#~ "pep:`343`。" - -#~ msgid "" -#~ "A variable which can have different values depending on its context. This " -#~ "is similar to Thread-Local Storage in which each execution thread may " -#~ "have a different value for a variable. However, with context variables, " -#~ "there may be several contexts in one execution thread and the main usage " -#~ "for context variables is to keep track of variables in concurrent " -#~ "asynchronous tasks. See :mod:`contextvars`." -#~ msgstr "" -#~ "一個變數,其值可以根據上下文的情境而有所不同。這類似執行緒區域儲存區 " -#~ "(Thread-Local Storage),在其中,一個變數在每個執行緒可能具有不同的值。然" -#~ "而,關於情境變數,在一個執行緒中可能會有多個情境,而情境變數的主要用途,是" -#~ "在並行的非同步任務 (concurrent asynchronous task) 中,對於變數狀態的追蹤。" -#~ "請參閱 :mod:`contextvars`。" - -#~ msgid "" -#~ "The main difference between a \"soft\" and a (regular) \"hard\" " -#~ "deprecation is that the soft deprecation does not imply scheduling the " -#~ "removal of the deprecated API." -#~ msgstr "" -#~ "「軟性」棄用和(常規的)「硬性」棄用之間的主要區別在於,軟性棄用並不代表已" -#~ "經確定要什麼時候刪除已棄用的 API。" - -#~ msgid "" -#~ "Another difference is that a soft deprecation does not issue a warning." -#~ msgstr "另一個區別是軟性棄用不會發出警告。" - -#~ msgid "2to3" -#~ msgstr "2to3" - -#~ msgid "" -#~ "A tool that tries to convert Python 2.x code to Python 3.x code by " -#~ "handling most of the incompatibilities which can be detected by parsing " -#~ "the source and traversing the parse tree." -#~ msgstr "" -#~ "一個試著將 Python 2.x 程式碼轉換為 Python 3.x 程式碼的工具,它是透過處理大" -#~ "部分的不相容性來達成此目的,而這些不相容性能夠透過剖析原始碼和遍歷剖析樹而" -#~ "被檢測出來。" - -#~ msgid "" -#~ "2to3 is available in the standard library as :mod:`lib2to3`; a standalone " -#~ "entry point is provided as :file:`Tools/scripts/2to3`. See :ref:`2to3-" -#~ "reference`." -#~ msgstr "" -#~ "2to3 在可以標準函式庫中以 :mod:`lib2to3` 被使用;它提供了一個獨立的入口" -#~ "點,在 :file:`Tools/scripts/2to3`。請參閱 :ref:`2to3-reference`。" - -#~ msgid "" -#~ "Past efforts to create a \"free-threaded\" interpreter (one which locks " -#~ "shared data at a much finer granularity) have not been successful because " -#~ "performance suffered in the common single-processor case. It is believed " -#~ "that overcoming this performance issue would make the implementation much " -#~ "more complicated and therefore costlier to maintain." -#~ msgstr "" -#~ "過去對於建立「無限制執行緒」直譯器(以更高的精細度鎖定共享資料的直譯器)的" -#~ "努力並未成功,因為在一般的單一處理器情況下,效能會有所損失。一般認為,若要" -#~ "克服這個效能問題,會使實作變得複雜許多,進而付出更高的維護成本。" +#~ msgid "The :const:`Ellipsis` built-in constant." +#~ msgstr "內建常數 :const:`Ellipsis`。" diff --git a/howto/a-conceptual-overview-of-asyncio.po b/howto/a-conceptual-overview-of-asyncio.po index ce462ac5e76..d07c49702c0 100644 --- a/howto/a-conceptual-overview-of-asyncio.po +++ b/howto/a-conceptual-overview-of-asyncio.po @@ -1,13 +1,13 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# 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.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-08-10 00:19+0000\n" +"POT-Creation-Date: 2025-11-26 00:14+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -29,63 +29,63 @@ msgstr "" #: ../../howto/a-conceptual-overview-of-asyncio.rst:11 msgid "" -"You might be curious about some key :mod:`!asyncio` concepts. You'll be " -"comfortably able to answer these questions by the end of this article:" +"You might be curious about some key :mod:`!asyncio` concepts. By the end of " +"this article, you'll be able to comfortably answer these questions:" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:15 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:14 msgid "What's happening behind the scenes when an object is awaited?" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:16 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:15 msgid "" -"How does :mod:`!asyncio` differentiate between a task which doesn't need CPU-" +"How does :mod:`!asyncio` differentiate between a task which doesn't need CPU " "time (such as a network request or file read) as opposed to a task that does " "(such as computing n-factorial)?" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:19 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:18 msgid "" "How to write an asynchronous variant of an operation, such as an async sleep " "or database request." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:24 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:23 msgid "" "The `guide `_ that inspired this HOWTO article, by Alexander Nordin." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:26 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:25 msgid "" "This in-depth `YouTube tutorial series `_ on ``asyncio`` " "created by Python core team member, Łukasz Langa." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:29 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:28 msgid "" "`500 Lines or Less: A Web Crawler With asyncio Coroutines `_ by A. Jesse Jiryu " "Davis and Guido van Rossum." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:35 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:34 msgid "A conceptual overview part 1: the high-level" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:37 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:36 msgid "" "In part 1, we'll cover the main, high-level building blocks of :mod:`!" -"asyncio`: the event loop, coroutine functions, coroutine objects, tasks and " +"asyncio`: the event loop, coroutine functions, coroutine objects, tasks, and " "``await``." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:42 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:41 msgid "Event Loop" msgstr "事件迴圈" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:44 +#: ../../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 " @@ -94,7 +94,7 @@ msgid "" "worker bees." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:51 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:50 msgid "" "In more technical terms, the event loop contains a collection of jobs to be " "run. Some jobs are added directly by you, and some indirectly by :mod:`!" @@ -104,20 +104,20 @@ msgid "" "event loop will then select another job from its pool and invoke it. You can " "*roughly* think of the collection of jobs as a queue: jobs are added and " "then processed one at a time, generally (but not always) in order. This " -"process repeats indefinitely with the event loop cycling endlessly onwards. " +"process repeats indefinitely, with the event loop cycling endlessly onwards. " "If there are no more jobs pending execution, the event loop is smart enough " "to rest and avoid needlessly wasting CPU cycles, and will come back when " "there's more work to be done." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:65 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:64 msgid "" "Effective execution relies on jobs sharing well and cooperating; a greedy " "job could hog control and leave the other jobs to starve, rendering the " "overall event loop approach rather useless." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:71 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:70 msgid "" "import asyncio\n" "\n" @@ -127,15 +127,15 @@ msgid "" "event_loop.run_forever()" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:80 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:79 msgid "Asynchronous functions and coroutines" msgstr "非同步函式與協程" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:82 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:81 msgid "This is a basic, boring Python function::" msgstr "這是一個基本的、無聊的 Python 函式:" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:84 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:83 msgid "" "def hello_printer():\n" " print(\n" @@ -151,11 +151,11 @@ msgstr "" " \"partner in crime.\"\n" " )" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:91 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:90 msgid "Calling a regular function invokes its logic or body::" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:93 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:92 msgid "" ">>> hello_printer()\n" "Hi, I am a lowly, simple printer, though I have all I need in life --\n" @@ -165,14 +165,14 @@ msgstr "" "Hi, I am a lowly, simple printer, though I have all I need in life --\n" "fresh paper and my dearly beloved octopus partner in crime." -#: ../../howto/a-conceptual-overview-of-asyncio.rst:97 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:96 msgid "" "The :ref:`async def `, as opposed to just a plain ``def``, makes " "this an asynchronous function (or \"coroutine function\"). Calling it " "creates and returns a :ref:`coroutine ` object." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:103 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:102 msgid "" "async def loudmouth_penguin(magic_number: int):\n" " print(\n" @@ -188,13 +188,13 @@ msgstr "" " f\"By the way, my lucky number is: {magic_number}.\"\n" " )" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:109 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:108 msgid "" "Calling the async function, ``loudmouth_penguin``, does not execute the " "print statement; instead, it creates a coroutine object::" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:112 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:111 msgid "" ">>> loudmouth_penguin(magic_number=3)\n" "" @@ -202,7 +202,7 @@ msgstr "" ">>> loudmouth_penguin(magic_number=3)\n" "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:115 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:114 msgid "" "The terms \"coroutine function\" and \"coroutine object\" are often " "conflated as coroutine. That can be confusing! In this article, coroutine " @@ -212,7 +212,7 @@ msgid "" "distinction that matters for type checking." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:124 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:123 msgid "" "A coroutine represents the function's body or logic. A coroutine has to be " "explicitly started; again, merely creating the coroutine does not start it. " @@ -221,7 +221,7 @@ msgid "" "asynchronous behavior!" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:131 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:130 msgid "" "Coroutines and coroutine functions were built by leveraging the " "functionality of :term:`generators ` and :term:" @@ -229,7 +229,7 @@ msgid "" "function that :keyword:`yield`\\s, like this one::" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:137 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:136 msgid "" "def get_random_number():\n" " # This would be a bad random number generator!\n" @@ -251,13 +251,13 @@ msgstr "" " yield 4\n" " ..." -#: ../../howto/a-conceptual-overview-of-asyncio.rst:147 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:146 msgid "" "Similar to a coroutine function, calling a generator function does not run " "it. Instead, it creates a generator object::" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:150 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:149 msgid "" ">>> get_random_number()\n" "" @@ -265,14 +265,14 @@ msgstr "" ">>> get_random_number()\n" "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:153 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:152 msgid "" "You can proceed to the next ``yield`` of a generator by using the built-in " "function :func:`next`. In other words, the generator runs, then pauses. For " "example::" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:158 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:157 msgid "" ">>> generator = get_random_number()\n" ">>> next(generator)\n" @@ -290,11 +290,11 @@ msgstr "" "Hello\n" "7" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:168 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:167 msgid "Tasks" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:170 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:169 msgid "" "Roughly speaking, :ref:`tasks ` are coroutines (not " "coroutine functions) tied to an event loop. A task also maintains a list of " @@ -303,21 +303,23 @@ msgid "" "`asyncio.create_task`." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:176 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:175 msgid "" "Creating a task automatically schedules it for execution (by adding a " "callback to run it in the event loop's to-do list, that is, collection of " "jobs)." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:179 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:178 msgid "" -"Since there's only one event loop (in each thread), :mod:`!asyncio` takes " -"care of associating the task with the event loop for you. As such, there's " -"no need to specify the event loop." +":mod:`!asyncio` automatically associates tasks with the event loop for you. " +"This automatic association was purposely designed into :mod:`!asyncio` for " +"the sake of simplicity. Without it, you'd have to keep track of the event " +"loop object and pass it to any coroutine function that wants to create " +"tasks, adding redundant clutter to your code." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:185 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:187 msgid "" "coroutine = loudmouth_penguin(magic_number=5)\n" "# This creates a Task object and schedules its execution via the event " @@ -325,7 +327,7 @@ msgid "" "task = asyncio.create_task(coroutine)" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:189 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:191 msgid "" "Earlier, we manually created the event loop and set it to run forever. In " "practice, it's recommended to use (and common to see) :func:`asyncio.run`, " @@ -334,7 +336,7 @@ msgid "" "this setup::" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:195 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:197 msgid "" "import asyncio\n" "\n" @@ -349,7 +351,7 @@ msgid "" " print(\"coroutine main() is done!\")" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:207 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:209 msgid "" "It's important to be aware that the task itself is not added to the event " "loop, only a callback to the task is. This matters if the task object you " @@ -357,7 +359,7 @@ msgid "" "example, consider this program:" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:213 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:215 msgid "" "async def hello():\n" " print(\"hello!\")\n" @@ -371,7 +373,7 @@ msgid "" "asyncio.run(main())" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:227 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:229 msgid "" "Because there's no reference to the task object created on line 5, it " "*might* be garbage collected before the event loop invokes it. Later " @@ -385,17 +387,17 @@ msgid "" "doesn't happen. But that's no reason to be reckless!" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:243 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:245 msgid "await" msgstr "await" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:245 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:247 msgid "" ":keyword:`await` is a Python keyword that's commonly used in one of two " "different ways::" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:248 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:250 msgid "" "await task\n" "await coroutine" @@ -403,20 +405,20 @@ msgstr "" "await task\n" "await coroutine" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:251 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:253 msgid "" "In a crucial way, the behavior of ``await`` depends on the type of object " "being awaited." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:254 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:256 msgid "" "Awaiting a task will cede control from the current task or coroutine to the " "event loop. In the process of relinquishing control, a few important things " "happen. We'll use the following code example to illustrate::" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:259 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:261 msgid "" "async def plant_a_tree():\n" " dig_the_hole_task = asyncio.create_task(dig_the_hole())\n" @@ -426,7 +428,7 @@ msgid "" " ..." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:266 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:268 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 " @@ -439,21 +441,21 @@ msgid "" "this case, a call to resume ``plant_a_tree()``." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:277 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:279 msgid "" "Generally speaking, when the awaited task finishes (``dig_the_hole_task``), " "the original task or coroutine (``plant_a_tree()``) is added back to the " -"event loops to-do list to be resumed." +"event loop's to-do list to be resumed." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:281 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:283 msgid "" "This is a basic, yet reliable mental model. In practice, the control " "handoffs are slightly more complex, but not by much. In part 2, we'll walk " "through the details that make this possible." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:285 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:287 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 " @@ -461,7 +463,7 @@ msgid "" "invoking a regular, synchronous Python function. Consider this program::" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:293 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:295 msgid "" "import asyncio\n" "\n" @@ -497,16 +499,16 @@ msgstr "" "\n" "asyncio.run(main())" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:310 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:312 msgid "" "The first statement in the coroutine ``main()`` creates ``task_b`` and " "schedules it for execution via the event loop. Then, ``coro_a()`` is " -"repeatedly awaited. Control never cedes to the event loop which is why we " +"repeatedly awaited. Control never cedes to the event loop, which is why we " "see the output of all three ``coro_a()`` invocations before ``coro_b()``'s " "output:" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:316 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:318 msgid "" "I am coro_a(). Hi!\n" "I am coro_a(). Hi!\n" @@ -518,7 +520,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:323 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:325 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 " @@ -527,7 +529,7 @@ msgid "" "before resuming the coroutine ``main()``." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:330 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:332 msgid "" "I am coro_b(). I sure hope no one hogs the event loop...\n" "I am coro_a(). Hi!\n" @@ -539,31 +541,31 @@ msgstr "" "I am coro_a(). Hi!\n" "I am coro_a(). Hi!" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:337 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:339 msgid "" "This behavior of ``await coroutine`` can trip a lot of people up! That " "example highlights how using only ``await coroutine`` could unintentionally " "hog control from other tasks and effectively stall the event loop. :func:" -"`asyncio.run` can help you detect such occurences via the ``debug=True`` " -"flag which accordingly enables :ref:`debug mode `. Among " -"other things, it will log any coroutines that monopolize execution for 100ms " -"or longer." +"`asyncio.run` can help you detect such occurrences via the ``debug=True`` " +"flag, which enables :ref:`debug mode `. Among other " +"things, it will log any coroutines that monopolize execution for 100ms or " +"longer." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:347 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:349 msgid "" "The design intentionally trades off some conceptual clarity around usage of " "``await`` for improved performance. Each time a task is awaited, control " "needs to be passed all the way up the call stack to the event loop. That " -"might sound minor, but in a large program with many ``await``'s and a deep " -"callstack that overhead can add up to a meaningful performance drag." +"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." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:356 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:358 msgid "A conceptual overview part 2: the nuts and bolts" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:358 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:360 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 " @@ -571,24 +573,24 @@ msgid "" "own asynchronous operators." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:366 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:368 msgid "The inner workings of coroutines" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:368 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:370 msgid ":mod:`!asyncio` leverages four components to pass around control." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:370 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:372 msgid "" ":meth:`coroutine.send(arg) ` is the method used to start or " "resume a coroutine. If the coroutine was paused and is now being resumed, " "the argument ``arg`` will be sent in as the return value of the ``yield`` " "statement which originally paused it. If the coroutine is being used for the " -"first time (as opposed to being resumed) ``arg`` must be ``None``." +"first time (as opposed to being resumed), ``arg`` must be ``None``." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:378 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:380 msgid "" "class Rock:\n" " def __await__(self):\n" @@ -642,18 +644,18 @@ msgstr "" " returned_value = e.value\n" "print(f\"Coroutine main() finished and provided value: {returned_value}.\")" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:406 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:408 msgid "" -":ref:`yield `, like usual, pauses execution and returns control " -"to the caller. In the example above, the ``yield``, on line 3, is called by " +":ref:`yield `, as usual, pauses execution and returns control to " +"the caller. In the example above, the ``yield``, on line 3, is called by " "``... = await rock`` on line 11. More broadly speaking, ``await`` calls the :" "meth:`~object.__await__` method of the given object. ``await`` also does one " "more very special thing: it propagates (or \"passes along\") any ``yield``\\ " -"s it receives up the call-chain. In this case, that's back to ``... = " +"s it receives up the call chain. In this case, that's back to ``... = " "coroutine.send(None)`` on line 16." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:416 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:418 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 " @@ -662,11 +664,11 @@ msgid "" "attached in the :attr:`~StopIteration.value` attribute." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:422 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:424 msgid "That snippet produces this output:" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:424 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:426 msgid "" "Beginning coroutine main().\n" "Awaiting rock...\n" @@ -684,28 +686,28 @@ msgstr "" "Coroutine received value: 42 from rock.\n" "Coroutine main() finished and provided value: 23." -#: ../../howto/a-conceptual-overview-of-asyncio.rst:434 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:436 msgid "" "It's worth pausing for a moment here and making sure you followed the " "various ways that control flow and values were passed. A lot of important " "ideas were covered and it's worth ensuring your understanding is firm." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:438 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:440 msgid "" "The only way to yield (or effectively cede control) from a coroutine is to " "``await`` an object that ``yield``\\ s in its ``__await__`` method. That " "might sound odd to you. You might be thinking:" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:442 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:444 msgid "" "1. What about a ``yield`` directly within the coroutine function? The " "coroutine function becomes an :ref:`async generator function `, a different beast entirely." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:447 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:449 msgid "" "2. What about a :ref:`yield from ` within the coroutine function " "to a (plain) generator? That causes the error: ``SyntaxError: yield from not " @@ -716,11 +718,11 @@ msgid "" "same thing." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:458 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:460 msgid "Futures" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:460 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:462 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 " @@ -728,17 +730,17 @@ msgid "" "that something." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:465 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:467 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 " +"A future has a few important attributes. One is its state, which can be " +"either \"pending\", \"cancelled\", or \"done\". Another is its result, which " "is set when the state transitions to done. Unlike a coroutine, a future does " "not represent the actual computation to be done; instead, it represents the " "status and result of that computation, kind of like a status light (red, " -"yellow or green) or indicator." +"yellow, or green) or indicator." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:472 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:474 msgid "" ":class:`asyncio.Task` subclasses :class:`asyncio.Future` in order to gain " "these various capabilities. The prior section said tasks store a list of " @@ -746,7 +748,7 @@ msgid "" "class that implements this logic, which ``Task`` inherits." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:479 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:481 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 " @@ -754,26 +756,26 @@ msgid "" "interface for you to make your own conditions for waiting and resuming." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:487 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:489 msgid "A homemade asyncio.sleep" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:489 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:491 msgid "" "We'll go through an example of how you could leverage a future to create " "your own variant of asynchronous sleep (``async_sleep``) which mimics :func:" "`asyncio.sleep`." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:493 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:495 msgid "" -"This snippet registers a few tasks with the event loop and then awaits a " -"coroutine wrapped in a task: ``async_sleep(3)``. We want that task to finish " -"only after three seconds have elapsed, but without preventing other tasks " -"from running." +"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)`` " +"coroutine. We want that task to finish only after three seconds have " +"elapsed, but without preventing other tasks from running." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:500 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:502 msgid "" "async def other_work():\n" " print(\"I like work. Work work.\")\n" @@ -799,7 +801,7 @@ msgid "" " await asyncio.gather(*work_tasks)" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:524 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:526 msgid "" "Below, we use a future to enable custom control over when that task will be " "marked as done. If :meth:`future.set_result() ` " @@ -809,7 +811,7 @@ msgid "" "elapsed and, accordingly, call ``future.set_result()``." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:535 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:537 msgid "" "async def async_sleep(seconds: float):\n" " future = asyncio.Future()\n" @@ -821,31 +823,31 @@ msgid "" " await future" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:543 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:545 msgid "" -"Below, we'll use a rather bare object, ``YieldToEventLoop()``, to ``yield`` " -"from ``__await__`` in order to cede control to the event loop. This is " +"Below, we use a rather bare ``YieldToEventLoop()`` object to ``yield`` from " +"its ``__await__`` method, ceding control to the event loop. This is " "effectively the same as calling ``asyncio.sleep(0)``, but this approach " "offers more clarity, not to mention it's somewhat cheating to use ``asyncio." "sleep`` when showcasing how to implement it!" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:549 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:551 msgid "" "As usual, the event loop cycles through its tasks, giving them control and " "receiving control back when they pause or finish. The ``watcher_task``, " "which runs the coroutine ``_sleep_watcher(...)``, will be invoked once per " "full cycle of the event loop. On each resumption, it'll check the time and " "if not enough has elapsed, then it'll pause once again and hand control back " -"to the event loop. Eventually, enough time will have elapsed, and " -"``_sleep_watcher(...)`` will mark the future as done, and then itself finish " -"too by breaking out of the infinite ``while`` loop. Given this helper task " -"is only invoked once per cycle of the event loop, you'd be correct to note " -"that this asynchronous sleep will sleep *at least* three seconds, rather " -"than exactly three seconds. Note this is also of true of ``asyncio.sleep``." +"to the event loop. Once enough time has elapsed, ``_sleep_watcher(...)`` " +"marks the future as done and completes by exiting its infinite ``while`` " +"loop. Given this helper task is only invoked once per cycle of the event " +"loop, you'd be correct to note that this asynchronous sleep will sleep *at " +"least* three seconds, rather than exactly three seconds. Note this is also " +"true of ``asyncio.sleep``." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:565 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:567 msgid "" "class YieldToEventLoop:\n" " def __await__(self):\n" @@ -861,11 +863,11 @@ msgid "" " await YieldToEventLoop()" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:578 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:580 msgid "Here is the full program's output:" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:580 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:582 msgid "" "$ python custom-async-sleep.py\n" "Beginning asynchronous sleep at time: 14:52:22.\n" @@ -881,7 +883,7 @@ msgstr "" "I like work. Work work.\n" "Done asynchronous sleep at time: 14:52:25." -#: ../../howto/a-conceptual-overview-of-asyncio.rst:589 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:591 msgid "" "You might feel this implementation of asynchronous sleep was unnecessarily " "convoluted. And, well, it was. The example was meant to showcase the " @@ -890,7 +892,7 @@ msgid "" "so::" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:596 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:598 msgid "" "async def simpler_async_sleep(seconds):\n" " time_to_wake = time.time() + seconds\n" @@ -908,9 +910,9 @@ msgstr "" " else:\n" " await YieldToEventLoop()" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:604 +#: ../../howto/a-conceptual-overview-of-asyncio.rst:606 msgid "" -"But, that's all for now. Hopefully you're ready to more confidently dive " -"into some async programming or check out advanced topics in the :mod:`rest " -"of the documentation `." +"But that's all for now. Hopefully you're ready to more confidently dive into " +"some async programming or check out advanced topics in the :mod:`rest of the " +"documentation `." msgstr "" diff --git a/howto/annotations.po b/howto/annotations.po index 67acc522c35..f6a5b8f4caf 100644 --- a/howto/annotations.po +++ b/howto/annotations.po @@ -1,13 +1,12 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # FIRST AUTHOR , YEAR. # msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-27 00:14+0000\n" +"POT-Creation-Date: 2025-12-01 00:17+0000\n" "PO-Revision-Date: 2023-11-08 23:11+0800\n" "Last-Translator: rockleon \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -30,7 +29,7 @@ msgstr "作者" msgid "Larry Hastings" msgstr "Larry Hastings" -#: ../../howto/annotations.rst:-1 +#: ../../howto/annotations.rst:9 msgid "Abstract" msgstr "摘要" @@ -75,17 +74,25 @@ msgstr "在 Python 3.10 及更高版本中存取物件的註釋字典" #: ../../howto/annotations.rst:35 msgid "" "Python 3.10 adds a new function to the standard library: :func:`inspect." -"get_annotations`. In Python versions 3.10 and newer, calling this function " -"is the best practice for accessing the annotations dict of any object that " -"supports annotations. This function can also \"un-stringize\" stringized " -"annotations for you." +"get_annotations`. In Python versions 3.10 through 3.13, calling this " +"function is the best practice for accessing the annotations dict of any " +"object that supports annotations. This function can also \"un-stringize\" " +"stringized annotations for you." msgstr "" "Python 3.10 在標準函式庫中新增了一個新函式::func:`inspect.get_annotations`。" -"在 Python 3.10 及更高版本中,呼叫此函式是存取任何支援註釋的物件的註釋字典的最" -"佳實踐。此函式也可以為你「取消字串化 (un-stringize)」字串化註釋。" +"在 Python 3.10 到 3.13,呼叫此函式是存取任何支援註釋的物件的註釋字典的最佳實" +"踐。此函式也可以為你「取消字串化 (un-stringize)」字串化註釋。" #: ../../howto/annotations.rst:42 msgid "" +"In Python 3.14, there is a new :mod:`annotationlib` module with " +"functionality for working with annotations. This includes a :func:" +"`annotationlib.get_annotations` function, which supersedes :func:`inspect." +"get_annotations`." +msgstr "" + +#: ../../howto/annotations.rst:47 +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 " "practice for this changed in Python 3.10 as well: as of Python 3.10, ``o." @@ -100,7 +107,7 @@ msgstr "" "類別 (class) 和模組。如果你確定正在檢查的物件是這三個\\ *特定*\\ 物件之一,你" "可以簡單地使用 ``o.__annotations__`` 來取得物件的註釋字典。" -#: ../../howto/annotations.rst:52 +#: ../../howto/annotations.rst:57 msgid "" "However, other types of callables--for example, callables created by :func:" "`functools.partial`--may not have an ``__annotations__`` attribute defined. " @@ -114,7 +121,7 @@ msgstr "" "用三個參數呼叫 :func:`getattr`,例如 ``getattr(o, '__annotations__', " "None)``。" -#: ../../howto/annotations.rst:60 +#: ../../howto/annotations.rst:65 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 " @@ -125,11 +132,11 @@ msgstr "" "``__annotations__`` 將傳回父類別的 ``__annotations__``。在 Python 3.10 及更高" "版本中,子類別的註釋將會是一個空字典。" -#: ../../howto/annotations.rst:68 +#: ../../howto/annotations.rst:73 msgid "Accessing The Annotations Dict Of An Object In Python 3.9 And Older" msgstr "在 Python 3.9 及更早版本中存取物件的註釋字典" -#: ../../howto/annotations.rst:70 +#: ../../howto/annotations.rst:75 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 " @@ -138,7 +145,7 @@ msgstr "" "在 Python 3.9 及更早版本中,存取物件的註釋字典比新版本複雜得多。問題出在於這" "些舊版 Python 中有設計缺陷,特別是與類別註釋有關的設計缺陷。" -#: ../../howto/annotations.rst:75 +#: ../../howto/annotations.rst:80 msgid "" "Best practice for accessing the annotations dict of other objects--" "functions, other callables, and modules--is the same as best practice for " @@ -150,7 +157,7 @@ msgstr "" "佳實踐相同,假設你沒有呼叫 :func:`inspect.get_annotations`:你應該使用三個:" "參數 :func:`getattr` 來存取物件的 ``__annotations__`` 屬性。" -#: ../../howto/annotations.rst:82 +#: ../../howto/annotations.rst:87 msgid "" "Unfortunately, this isn't best practice for classes. The problem is that, " "since ``__annotations__`` is optional on classes, and because classes can " @@ -163,7 +170,7 @@ msgstr "" "類別的 ``__annotations__`` 屬性可能會無意中回傳\\ *基底類別的註釋字典。*\\ 舉" "例來說: ::" -#: ../../howto/annotations.rst:89 +#: ../../howto/annotations.rst:94 msgid "" "class Base:\n" " a: int = 3\n" @@ -183,11 +190,11 @@ msgstr "" "\n" "print(Derived.__annotations__)" -#: ../../howto/annotations.rst:98 +#: ../../howto/annotations.rst:103 msgid "This will print the annotations dict from ``Base``, not ``Derived``." msgstr "這將印出 (print) 來自 ``Base`` 的註釋字典,而不是 ``Derived``。" -#: ../../howto/annotations.rst:101 +#: ../../howto/annotations.rst:106 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 " @@ -202,7 +209,7 @@ msgstr "" "attr:`~type.__dict__` 字典中。由於類別可能定義了註釋,也可能沒有定義,因此最" "佳實踐是在類別字典上呼叫 :meth:`~dict.get` 方法。" -#: ../../howto/annotations.rst:109 +#: ../../howto/annotations.rst:114 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 " @@ -211,7 +218,7 @@ msgstr "" "總而言之,以下是一些範例程式碼,可以安全地存取 Python 3.9 及先前版本中任意物" "件上的 ``__annotations__`` 屬性:" -#: ../../howto/annotations.rst:113 +#: ../../howto/annotations.rst:118 msgid "" "if isinstance(o, type):\n" " ann = o.__dict__.get('__annotations__', None)\n" @@ -223,7 +230,7 @@ msgstr "" "else:\n" " ann = getattr(o, '__annotations__', None)" -#: ../../howto/annotations.rst:118 +#: ../../howto/annotations.rst:123 msgid "" "After running this code, ``ann`` should be either a dictionary or ``None``. " "You're encouraged to double-check the type of ``ann`` using :func:" @@ -232,7 +239,7 @@ msgstr "" "運行此程式碼後,``ann`` 應該是字典或 ``None``。我們鼓勵你在進一步檢查之前使" "用 :func:`isinstance` 仔細檢查 ``ann`` 的型別。" -#: ../../howto/annotations.rst:123 +#: ../../howto/annotations.rst:128 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 use :func:" @@ -242,11 +249,11 @@ msgstr "" "`~type.__dict__` 屬性,因此為了額外的安全,你可能還希望使用 :func:`getattr` " "來存取 :attr:`!__dict__`。" -#: ../../howto/annotations.rst:129 +#: ../../howto/annotations.rst:134 msgid "Manually Un-Stringizing Stringized Annotations" msgstr "手動取消字串化註釋" -#: ../../howto/annotations.rst:131 +#: ../../howto/annotations.rst:136 msgid "" "In situations where some annotations may be \"stringized\", and you wish to " "evaluate those strings to produce the Python values they represent, it " @@ -256,7 +263,7 @@ msgstr "" "在某些註釋可能被「字串化」的情況下,並且你希望評估這些字串以產生它們表示的 " "Python 值,最好呼叫 :func:`inspect.get_annotations` 來為你完成這項工作。" -#: ../../howto/annotations.rst:137 +#: ../../howto/annotations.rst:142 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. You're " @@ -267,13 +274,13 @@ msgstr "" "`inspect.get_annotations`,則需要複製其邏輯。我們鼓勵你檢查目前 Python 版本" "中 :func:`inspect.get_annotations` 的實作並遵循類似的方法。" -#: ../../howto/annotations.rst:143 +#: ../../howto/annotations.rst:148 msgid "" "In a nutshell, if you wish to evaluate a stringized annotation on an " "arbitrary object ``o``:" msgstr "簡而言之,如果你希望評估任意物件 ``o`` 上的字串化註釋: ::" -#: ../../howto/annotations.rst:146 +#: ../../howto/annotations.rst:151 msgid "" "If ``o`` is a module, use ``o.__dict__`` as the ``globals`` when calling :" "func:`eval`." @@ -281,7 +288,7 @@ msgstr "" "如果 ``o`` 是一個模組,則在呼叫 :func:`eval` 時使用 ``o.__dict__`` 作為\\ ``" "全域變數``。" -#: ../../howto/annotations.rst:148 +#: ../../howto/annotations.rst:153 msgid "" "If ``o`` is a class, use ``sys.modules[o.__module__].__dict__`` as the " "``globals``, and ``dict(vars(o))`` as the ``locals``, when calling :func:" @@ -291,7 +298,7 @@ msgstr "" "__module__].__dict__`` 作為\\ ``全域變數``,使用 ``dict(vars(o))`` 作為\\ ``" "區域變數``。" -#: ../../howto/annotations.rst:151 +#: ../../howto/annotations.rst:156 msgid "" "If ``o`` is a wrapped callable using :func:`functools.update_wrapper`, :func:" "`functools.wraps`, or :func:`functools.partial`, iteratively unwrap it by " @@ -302,7 +309,7 @@ msgstr "" "或 :func:`functools.partial` 包裝的 callable ,請依據需求,透過存取 ``o." "__wrapped__`` 或 ``o.func`` 來疊代解開它,直到找到根解包函式。" -#: ../../howto/annotations.rst:155 +#: ../../howto/annotations.rst:160 msgid "" "If ``o`` is a callable (but not a class), use :attr:`o.__globals__ ` as the globals when calling :func:`eval`." @@ -310,7 +317,7 @@ msgstr "" "如果 ``o`` 是 callable(但不是類別),則在呼叫 :func:`eval` 時使用 :attr:`o." "__globals__ ` 作為全域變數。" -#: ../../howto/annotations.rst:159 +#: ../../howto/annotations.rst:164 msgid "" "However, not all string values used as annotations can be successfully " "turned into Python values by :func:`eval`. String values could theoretically " @@ -322,21 +329,21 @@ msgstr "" "理論上,字串值可以包含任何有效的字串,並且在實踐中,型別提示存在有效的用例," "需要使用特定「無法」評估的字串值進行註釋。例如: ::" -#: ../../howto/annotations.rst:166 +#: ../../howto/annotations.rst:171 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:168 +#: ../../howto/annotations.rst:173 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:171 +#: ../../howto/annotations.rst:176 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, " @@ -346,11 +353,11 @@ msgstr "" "如果 :func:`eval` 嘗試計算這類型的值,它將失敗並引發例外。因此,在設計使用註" "釋的函式庫 API 時,建議僅在呼叫者 (caller) 明確請求時嘗試評估字串值。" -#: ../../howto/annotations.rst:179 +#: ../../howto/annotations.rst:184 msgid "Best Practices For ``__annotations__`` In Any Python Version" msgstr "任何 Python 版本中 ``__annotations__`` 的最佳實踐" -#: ../../howto/annotations.rst:181 +#: ../../howto/annotations.rst:186 msgid "" "You should avoid assigning to the ``__annotations__`` member of objects " "directly. Let Python manage setting ``__annotations__``." @@ -358,7 +365,7 @@ msgstr "" "你應該避免直接指派給物件的 ``__annotations__`` 成員。讓 Python 管理設定 " "``__annotations__``。" -#: ../../howto/annotations.rst:184 +#: ../../howto/annotations.rst:189 msgid "" "If you do assign directly to the ``__annotations__`` member of an object, " "you should always set it to a ``dict`` object." @@ -366,29 +373,36 @@ msgstr "" "如果你直接指派給物件的 ``__annotations__`` 成員,則應始終將其設為 ``dict`` 物" "件。" -#: ../../howto/annotations.rst:187 +#: ../../howto/annotations.rst:192 msgid "" -"If you directly access the ``__annotations__`` member of an object, you " +"You should avoid accessing ``__annotations__`` directly on any object. " +"Instead, use :func:`annotationlib.get_annotations` (Python 3.14+) or :func:" +"`inspect.get_annotations` (Python 3.10+)." +msgstr "" + +#: ../../howto/annotations.rst:196 +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 " "contents." msgstr "" -"如果直接存取物件的 ``__annotations__`` 成員,則應在嘗試檢查其內容之前確保它是" -"字典。" +"如果直接存取物件的 ``__annotations__`` 成員,則應確保它是字典,然後再嘗試檢查" +"其內容。" -#: ../../howto/annotations.rst:191 +#: ../../howto/annotations.rst:200 msgid "You should avoid modifying ``__annotations__`` dicts." msgstr "你應該避免修改 ``__annotations__`` 字典。" -#: ../../howto/annotations.rst:193 +#: ../../howto/annotations.rst:202 msgid "" "You should avoid deleting the ``__annotations__`` attribute of an object." msgstr "你應該避免刪除物件的 ``__annotations__`` 屬性。" -#: ../../howto/annotations.rst:198 +#: ../../howto/annotations.rst:207 msgid "``__annotations__`` Quirks" msgstr "``__annotations__`` 奇異之處" -#: ../../howto/annotations.rst:200 +#: ../../howto/annotations.rst:209 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 " @@ -406,13 +420,13 @@ msgstr "" "上的註釋將拋出 ``AttributeError``;連續兩次使用 ``del fn.__annotations__`` 保" "證總是拋出 ``AttributeError`` 。" -#: ../../howto/annotations.rst:210 +#: ../../howto/annotations.rst:219 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:213 +#: ../../howto/annotations.rst:222 msgid "" "In all versions of Python 3, you can set ``__annotations__`` on a function " "object to ``None``. However, subsequently accessing the annotations on that " @@ -428,7 +442,7 @@ msgstr "" "\\ *並非如此*\\;這些物件允許將 ``__annotations__`` 設定為任何 Python 值,並" "且將保留設定的任何值。" -#: ../../howto/annotations.rst:221 +#: ../../howto/annotations.rst:230 msgid "" "If Python stringizes your annotations for you (using ``from __future__ " "import annotations``), and you specify a string as an annotation, the string " @@ -439,7 +453,7 @@ msgstr "" "annotations``),並且你指定一個字串作為註釋,則該字串本身將被引用。實際上,註" "釋被引用了\\ *兩次。*\\ 例如: ::" -#: ../../howto/annotations.rst:227 +#: ../../howto/annotations.rst:236 msgid "" "from __future__ import annotations\n" "def foo(a: \"str\"): pass\n" @@ -451,10 +465,30 @@ msgstr "" "\n" "print(foo.__annotations__)" -#: ../../howto/annotations.rst:232 +#: ../../howto/annotations.rst:241 msgid "" "This prints ``{'a': \"'str'\"}``. This shouldn't really be considered a " "\"quirk\"; it's mentioned here simply because it might be surprising." msgstr "" "這會印出 ``{'a': \"'str'\"}``。這不應該被認為是一個「奇異的事」,他在這裡被簡" "單提及,因為他可能會讓人意想不到。" + +#: ../../howto/annotations.rst:244 +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-" +"metaclasses>` for some examples. You can avoid these quirks by using :func:" +"`annotationlib.get_annotations` on Python 3.14+ or :func:`inspect." +"get_annotations` on Python 3.10+. On earlier versions of Python, you can " +"avoid these bugs by accessing the annotations from the class's :attr:`~type." +"__dict__` (for example, ``cls.__dict__.get('__annotations__', None)``)." +msgstr "" + +#: ../../howto/annotations.rst:253 +msgid "" +"In some versions of Python, instances of classes may have an " +"``__annotations__`` attribute. However, this is not supported functionality. " +"If you need the annotations of an instance, you can use :func:`type` to " +"access its class (for example, ``annotationlib." +"get_annotations(type(myinstance))`` on Python 3.14+)." +msgstr "" diff --git a/howto/argparse-optparse.po b/howto/argparse-optparse.po index 62fdf4ecdd2..6d64dccdf78 100644 --- a/howto/argparse-optparse.po +++ b/howto/argparse-optparse.po @@ -1,10 +1,10 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # #, fuzzy msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-12-29 11:18+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" diff --git a/howto/argparse.po b/howto/argparse.po index 5f4710c87fc..b40a18cb2c5 100644 --- a/howto/argparse.po +++ b/howto/argparse.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -10,7 +10,7 @@ # Matt Wang , 2023 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-12-29 11:18+0000\n" "PO-Revision-Date: 2023-12-11 17:33+0800\n" diff --git a/howto/clinic.po b/howto/clinic.po index 4deac0b4299..091628bfa06 100644 --- a/howto/clinic.po +++ b/howto/clinic.po @@ -1,11 +1,10 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2023, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2023-10-13 00:03+0000\n" "PO-Revision-Date: 2018-05-23 14:36+0000\n" diff --git a/howto/cporting.po b/howto/cporting.po index 06a67dd24b2..63e3f6d9df5 100644 --- a/howto/cporting.po +++ b/howto/cporting.po @@ -1,12 +1,11 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Leon H., 2017 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2018-05-23 14:36+0000\n" diff --git a/howto/curses.po b/howto/curses.po index 5c22aaf3798..38eb0c2a5e6 100644 --- a/howto/curses.po +++ b/howto/curses.po @@ -1,13 +1,12 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-04-11 00:15+0000\n" +"POT-Creation-Date: 2025-12-01 00:17+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-" @@ -38,7 +37,7 @@ msgstr "發佈版本" msgid "2.04" msgstr "2.04" -#: ../../howto/curses.rst:-1 +#: ../../howto/curses.rst:13 msgid "Abstract" msgstr "摘要" diff --git a/howto/descriptor.po b/howto/descriptor.po index 955ed73e512..a706a11acaa 100644 --- a/howto/descriptor.po +++ b/howto/descriptor.po @@ -1,13 +1,13 @@ -# Copyright (C) 2001-2023, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Leon H., 2017 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-09-01 00:19+0000\n" +"POT-Creation-Date: 2025-09-09 05:11+0800\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-" @@ -75,8 +75,9 @@ msgstr "" 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 " -"bound methods or about the implementation of common tools like :func:" -"`classmethod`, :func:`staticmethod`, :func:`property`, and :term:`__slots__`." +"bound methods or about the implementation of common tools " +"like :func:`classmethod`, :func:`staticmethod`, :func:`property`, " +"and :term:`__slots__`." msgstr "" #: ../../howto/descriptor.rst:36 @@ -230,8 +231,9 @@ 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 " "the actual data is stored as a private attribute in the instance " -"dictionary. The descriptor's :meth:`~object.__get__` and :meth:`~object." -"__set__` methods are triggered when the public attribute is accessed." +"dictionary. The descriptor's :meth:`~object.__get__` " +"and :meth:`~object.__set__` methods are triggered when the public attribute " +"is accessed." msgstr "" #: ../../howto/descriptor.rst:139 @@ -369,9 +371,10 @@ msgstr "" #: ../../howto/descriptor.rst:256 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:" +"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 @@ -428,8 +431,9 @@ msgstr "" #: ../../howto/descriptor.rst:297 msgid "" -"A :term:`descriptor` is what we call any object that defines :meth:`~object." -"__get__`, :meth:`~object.__set__`, or :meth:`~object.__delete__`." +"A :term:`descriptor` is what we call any object that " +"defines :meth:`~object.__get__`, :meth:`~object.__set__`, " +"or :meth:`~object.__delete__`." msgstr "" #: ../../howto/descriptor.rst:300 @@ -469,9 +473,9 @@ msgstr "" #: ../../howto/descriptor.rst:319 msgid "" "Descriptors are used throughout the language. It is how functions turn into " -"bound methods. Common tools like :func:`classmethod`, :func:" -"`staticmethod`, :func:`property`, and :func:`functools.cached_property` are " -"all implemented as descriptors." +"bound methods. Common tools " +"like :func:`classmethod`, :func:`staticmethod`, :func:`property`, " +"and :func:`functools.cached_property` are all implemented as descriptors." msgstr "" #: ../../howto/descriptor.rst:326 @@ -561,9 +565,9 @@ msgstr "" #: ../../howto/descriptor.rst:374 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 " -"maximum." +":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 maximum." msgstr "" #: ../../howto/descriptor.rst:378 @@ -716,9 +720,10 @@ msgstr "" #: ../../howto/descriptor.rst:503 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__`, :" -"meth:`~object.__set__`, and :meth:`~object.__delete__`. If any of those " -"methods are defined for an attribute, it is said to be a :term:`descriptor`." +"in the descriptor protocol. Those methods " +"are :meth:`~object.__get__`, :meth:`~object.__set__`, " +"and :meth:`~object.__delete__`. If any of those methods are defined for an " +"attribute, it is said to be a :term:`descriptor`." msgstr "" #: ../../howto/descriptor.rst:508 @@ -736,10 +741,10 @@ msgstr "" #: ../../howto/descriptor.rst:517 msgid "" "Descriptors are a powerful, general purpose protocol. They are the " -"mechanism behind properties, methods, static methods, class methods, and :" -"func:`super`. They are used throughout Python itself. Descriptors simplify " -"the underlying C code and offer a flexible set of new tools for everyday " -"Python programs." +"mechanism behind properties, methods, static methods, class methods, " +"and :func:`super`. They are used throughout Python itself. Descriptors " +"simplify the underlying C code and offer a flexible set of new tools for " +"everyday Python programs." msgstr "" #: ../../howto/descriptor.rst:525 @@ -768,9 +773,9 @@ msgstr "" #: ../../howto/descriptor.rst:537 msgid "" "If an object defines :meth:`~object.__set__` or :meth:`~object.__delete__`, " -"it is considered a data descriptor. Descriptors that only define :meth:" -"`~object.__get__` are called non-data descriptors (they are often used for " -"methods but other uses are possible)." +"it is considered a data descriptor. Descriptors that only " +"define :meth:`~object.__get__` are called non-data descriptors (they are " +"often used for methods but other uses are possible)." msgstr "" #: ../../howto/descriptor.rst:542 @@ -785,9 +790,10 @@ msgstr "" #: ../../howto/descriptor.rst:548 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:" -"`AttributeError` when called. Defining the :meth:`~object.__set__` method " -"with an exception raising placeholder is enough to make it a data descriptor." +"and :meth:`~object.__set__` with the :meth:`~object.__set__` raising " +"an :exc:`AttributeError` when called. Defining the :meth:`~object.__set__` " +"method with an exception raising placeholder is enough to make it a data " +"descriptor." msgstr "" #: ../../howto/descriptor.rst:555 @@ -796,8 +802,8 @@ msgstr "" #: ../../howto/descriptor.rst:557 msgid "" -"A descriptor can be called directly with ``desc.__get__(obj)`` or ``desc." -"__get__(None, cls)``." +"A descriptor can be called directly with ``desc.__get__(obj)`` or " +"``desc.__get__(None, cls)``." msgstr "" #: ../../howto/descriptor.rst:560 @@ -834,8 +840,8 @@ msgstr "" #: ../../howto/descriptor.rst:580 msgid "" -"If a descriptor is found for ``a.x``, then it is invoked with: ``desc." -"__get__(a, type(a))``." +"If a descriptor is found for ``a.x``, then it is invoked with: " +"``desc.__get__(a, type(a))``." msgstr "" #: ../../howto/descriptor.rst:583 @@ -875,18 +881,19 @@ msgstr "" #: ../../howto/descriptor.rst:722 msgid "" -"Note, there is no :meth:`~object.__getattr__` hook in the :meth:`~object." -"__getattribute__` code. That is why calling :meth:`~object." -"__getattribute__` directly or with ``super().__getattribute__`` will bypass :" -"meth:`~object.__getattr__` entirely." +"Note, there is no :meth:`~object.__getattr__` hook in " +"the :meth:`~object.__getattribute__` code. That is why " +"calling :meth:`~object.__getattribute__` directly or with " +"``super().__getattribute__`` will bypass :meth:`~object.__getattr__` " +"entirely." msgstr "" #: ../../howto/descriptor.rst:726 msgid "" "Instead, it is the dot operator and the :func:`getattr` function that are " -"responsible for invoking :meth:`~object.__getattr__` whenever :meth:`~object." -"__getattribute__` raises an :exc:`AttributeError`. Their logic is " -"encapsulated in a helper function:" +"responsible for invoking :meth:`~object.__getattr__` " +"whenever :meth:`~object.__getattribute__` raises an :exc:`AttributeError`. " +"Their logic is encapsulated in a helper function:" msgstr "" #: ../../howto/descriptor.rst:731 @@ -915,10 +922,10 @@ msgstr "" #: ../../howto/descriptor.rst:778 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." -"__getattribute__` but the instance dictionary lookup is replaced by a search " -"through the class's :term:`method resolution order`." +"The logic for a dotted lookup such as ``A.x`` is in :meth:`!" +"type.__getattribute__`. The steps are similar to those for :meth:`!" +"object.__getattribute__` but the instance dictionary lookup is replaced by a " +"search through the class's :term:`method resolution order`." msgstr "" #: ../../howto/descriptor.rst:783 @@ -927,8 +934,8 @@ msgstr "" #: ../../howto/descriptor.rst:785 msgid "" -"The full C implementation can be found in :c:func:`!type_getattro` and :c:" -"func:`!_PyType_Lookup` in :source:`Objects/typeobject.c`." +"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 @@ -937,22 +944,23 @@ msgstr "" #: ../../howto/descriptor.rst:792 msgid "" -"The logic for super's dotted lookup is in the :meth:`~object." -"__getattribute__` method for object returned by :func:`super`." +"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 msgid "" -"A dotted lookup such as ``super(A, obj).m`` searches ``obj.__class__." -"__mro__`` for the base class ``B`` immediately following ``A`` and then " -"returns ``B.__dict__['m'].__get__(obj, A)``. If not a descriptor, ``m`` is " -"returned unchanged." +"A dotted lookup such as ``super(A, obj).m`` searches " +"``obj.__class__.__mro__`` for the base class ``B`` immediately following " +"``A`` and then returns ``B.__dict__['m'].__get__(obj, A)``. If not a " +"descriptor, ``m`` is returned unchanged." msgstr "" #: ../../howto/descriptor.rst:800 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 " +"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 " "`Guido's Tutorial `_." msgstr "" @@ -963,9 +971,9 @@ msgstr "" #: ../../howto/descriptor.rst:809 msgid "" -"The mechanism for descriptors is embedded in the :meth:`~object." -"__getattribute__` methods for :class:`object`, :class:`type`, and :func:" -"`super`." +"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 @@ -978,8 +986,8 @@ msgstr "" #: ../../howto/descriptor.rst:816 msgid "" -"Classes inherit this machinery from :class:`object`, :class:`type`, or :func:" -"`super`." +"Classes inherit this machinery from :class:`object`, :class:`type`, " +"or :func:`super`." msgstr "" #: ../../howto/descriptor.rst:819 @@ -1038,8 +1046,8 @@ msgstr "ORM 範例" #: ../../howto/descriptor.rst:853 msgid "" "The following code is a simplified skeleton showing how data descriptors " -"could be used to implement an `object relational mapping `_." +"could be used to implement an `object relational mapping `_." msgstr "" #: ../../howto/descriptor.rst:857 @@ -1083,9 +1091,9 @@ msgstr "" #: ../../howto/descriptor.rst:876 msgid "" -"We can use the :class:`!Field` class to define `models `_ that describe the schema for each table in a " -"database:" +"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 @@ -1342,10 +1350,10 @@ msgstr "" #: ../../howto/descriptor.rst:1189 msgid "" -"To support automatic creation of methods, functions include the :meth:" -"`~object.__get__` method for binding methods during attribute access. This " -"means that functions are non-data descriptors that return bound methods " -"during dotted lookup from an instance. Here's how it works:" +"To support automatic creation of methods, functions include " +"the :meth:`~object.__get__` method for binding methods during attribute " +"access. This means that functions are non-data descriptors that return " +"bound methods during dotted lookup from an instance. Here's how it works:" msgstr "" #: ../../howto/descriptor.rst:1194 @@ -1397,8 +1405,9 @@ msgstr "" #: ../../howto/descriptor.rst:1233 msgid "" -"Accessing the function through the class dictionary does not invoke :meth:" -"`~object.__get__`. Instead, it just returns the underlying function object::" +"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 @@ -1535,10 +1544,10 @@ msgstr "" #: ../../howto/descriptor.rst:1293 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." -"__getattribute__(c, \"f\")`` or ``object.__getattribute__(C, \"f\")``. As a " -"result, the function becomes identically accessible from either an object or " -"a class." +"either ``c.f`` or ``C.f`` is the equivalent of a direct lookup into " +"``object.__getattribute__(c, \"f\")`` or ``object.__getattribute__(C, " +"\"f\")``. As a result, the function becomes identically accessible from " +"either an object or a class." msgstr "" #: ../../howto/descriptor.rst:1299 @@ -1591,8 +1600,8 @@ msgstr "" #: ../../howto/descriptor.rst:1328 msgid "" -"Using the non-data descriptor protocol, a pure Python version of :func:" -"`staticmethod` would look like this:" +"Using the non-data descriptor protocol, a pure Python version " +"of :func:`staticmethod` would look like this:" msgstr "" #: ../../howto/descriptor.rst:1331 @@ -1610,30 +1619,34 @@ msgid "" " return self.f\n" "\n" " def __call__(self, *args, **kwds):\n" -" return self.f(*args, **kwds)" +" return self.f(*args, **kwds)\n" +"\n" +" @property\n" +" def __annotations__(self):\n" +" return self.f.__annotations__" msgstr "" -#: ../../howto/descriptor.rst:1348 +#: ../../howto/descriptor.rst:1352 msgid "" "The :func:`functools.update_wrapper` call adds a ``__wrapped__`` attribute " "that refers to the underlying function. Also it carries forward the " -"attributes necessary to make the wrapper look like the wrapped function: :" -"attr:`~function.__name__`, :attr:`~function.__qualname__`, :attr:`~function." -"__doc__`, and :attr:`~function.__annotations__`." +"attributes necessary to make the wrapper look like the wrapped function, " +"including :attr:`~function.__name__`, :attr:`~function.__qualname__`, " +"and :attr:`~function.__doc__`." msgstr "" -#: ../../howto/descriptor.rst:1417 +#: ../../howto/descriptor.rst:1421 msgid "Class methods" msgstr "" -#: ../../howto/descriptor.rst:1419 +#: ../../howto/descriptor.rst:1423 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:1423 +#: ../../howto/descriptor.rst:1427 msgid "" "class F:\n" " @classmethod\n" @@ -1645,7 +1658,7 @@ msgstr "" " def f(cls, x):\n" " return cls.__name__, x" -#: ../../howto/descriptor.rst:1430 +#: ../../howto/descriptor.rst:1434 msgid "" ">>> F.f(3)\n" "('F', 3)\n" @@ -1657,7 +1670,7 @@ msgstr "" ">>> F().f(3)\n" "('F', 3)" -#: ../../howto/descriptor.rst:1437 +#: ../../howto/descriptor.rst:1441 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 " @@ -1666,7 +1679,7 @@ msgid "" "of keys. The pure Python equivalent is:" msgstr "" -#: ../../howto/descriptor.rst:1443 +#: ../../howto/descriptor.rst:1447 msgid "" "class Dict(dict):\n" " @classmethod\n" @@ -1678,11 +1691,11 @@ msgid "" " return d" msgstr "" -#: ../../howto/descriptor.rst:1454 +#: ../../howto/descriptor.rst:1458 msgid "Now a new dictionary of unique keys can be constructed like this:" msgstr "" -#: ../../howto/descriptor.rst:1456 +#: ../../howto/descriptor.rst:1460 msgid "" ">>> d = Dict.fromkeys('abracadabra')\n" ">>> type(d) is Dict\n" @@ -1696,13 +1709,13 @@ msgstr "" ">>> d\n" "{'a': None, 'b': None, 'r': None, 'c': None, 'd': None}" -#: ../../howto/descriptor.rst:1464 +#: ../../howto/descriptor.rst:1468 msgid "" -"Using the non-data descriptor protocol, a pure Python version of :func:" -"`classmethod` would look like this:" +"Using the non-data descriptor protocol, a pure Python version " +"of :func:`classmethod` would look like this:" msgstr "" -#: ../../howto/descriptor.rst:1467 +#: ../../howto/descriptor.rst:1471 msgid "" "import functools\n" "\n" @@ -1719,34 +1732,34 @@ msgid "" " return MethodType(self.f, cls)" msgstr "" -#: ../../howto/descriptor.rst:1529 +#: ../../howto/descriptor.rst:1533 msgid "" "The :func:`functools.update_wrapper` call in ``ClassMethod`` adds a " "``__wrapped__`` attribute that refers to the underlying function. Also it " "carries forward the attributes necessary to make the wrapper look like the " -"wrapped function: :attr:`~function.__name__`, :attr:`~function." -"__qualname__`, :attr:`~function.__doc__`, and :attr:`~function." -"__annotations__`." +"wrapped " +"function: :attr:`~function.__name__`, :attr:`~function.__qualname__`, :attr:`~function.__doc__`, " +"and :attr:`~function.__annotations__`." msgstr "" -#: ../../howto/descriptor.rst:1538 +#: ../../howto/descriptor.rst:1542 msgid "Member objects and __slots__" msgstr "" -#: ../../howto/descriptor.rst:1540 +#: ../../howto/descriptor.rst:1544 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:1544 +#: ../../howto/descriptor.rst:1548 msgid "" "1. Provides immediate detection of bugs due to misspelled attribute " "assignments. Only attribute names specified in ``__slots__`` are allowed:" msgstr "" -#: ../../howto/descriptor.rst:1547 +#: ../../howto/descriptor.rst:1551 msgid "" "class Vehicle:\n" " __slots__ = ('id_number', 'make', 'model')" @@ -1754,7 +1767,7 @@ msgstr "" "class Vehicle:\n" " __slots__ = ('id_number', 'make', 'model')" -#: ../../howto/descriptor.rst:1552 +#: ../../howto/descriptor.rst:1556 msgid "" ">>> auto = Vehicle()\n" ">>> auto.id_nubmer = 'VYE483814LQEX'\n" @@ -1768,13 +1781,13 @@ msgstr "" " ...\n" "AttributeError: 'Vehicle' object has no attribute 'id_nubmer'" -#: ../../howto/descriptor.rst:1560 +#: ../../howto/descriptor.rst:1564 msgid "" "2. Helps create immutable objects where descriptors manage access to private " "attributes stored in ``__slots__``:" msgstr "" -#: ../../howto/descriptor.rst:1563 +#: ../../howto/descriptor.rst:1567 msgid "" "class Immutable:\n" "\n" @@ -1794,7 +1807,7 @@ msgid "" " return self._name" msgstr "" -#: ../../howto/descriptor.rst:1581 +#: ../../howto/descriptor.rst:1585 msgid "" ">>> mark = Immutable('Botany', 'Mark Watney')\n" ">>> mark.dept\n" @@ -1820,7 +1833,7 @@ msgstr "" " ...\n" "AttributeError: 'Immutable' object has no attribute 'location'" -#: ../../howto/descriptor.rst:1595 +#: ../../howto/descriptor.rst:1599 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 " @@ -1828,19 +1841,19 @@ msgid "" "only matters when a large number of instances are going to be created." msgstr "" -#: ../../howto/descriptor.rst:1600 +#: ../../howto/descriptor.rst:1604 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:1603 +#: ../../howto/descriptor.rst:1607 msgid "" "5. Blocks tools like :func:`functools.cached_property` which require an " "instance dictionary to function correctly:" msgstr "" -#: ../../howto/descriptor.rst:1606 +#: ../../howto/descriptor.rst:1610 msgid "" "from functools import cached_property\n" "\n" @@ -1853,7 +1866,7 @@ msgid "" " for n in reversed(range(100_000)))" msgstr "" -#: ../../howto/descriptor.rst:1618 +#: ../../howto/descriptor.rst:1622 msgid "" ">>> CP().pi\n" "Traceback (most recent call last):\n" @@ -1865,7 +1878,7 @@ msgstr "" " ...\n" "TypeError: No '__dict__' attribute on 'CP' instance to cache 'pi' property." -#: ../../howto/descriptor.rst:1625 +#: ../../howto/descriptor.rst:1629 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 " @@ -1875,7 +1888,7 @@ msgid "" "managed by member descriptors:" msgstr "" -#: ../../howto/descriptor.rst:1632 +#: ../../howto/descriptor.rst:1636 msgid "" "null = object()\n" "\n" @@ -1914,13 +1927,13 @@ msgid "" " return f''" msgstr "" -#: ../../howto/descriptor.rst:1670 +#: ../../howto/descriptor.rst:1674 msgid "" "The :meth:`!type.__new__` method takes care of adding member objects to " "class variables:" msgstr "" -#: ../../howto/descriptor.rst:1673 +#: ../../howto/descriptor.rst:1677 msgid "" "class Type(type):\n" " 'Simulate how the type metaclass adds member objects for slots'\n" @@ -1934,14 +1947,14 @@ msgid "" " return type.__new__(mcls, clsname, bases, mapping, **kwargs)" msgstr "" -#: ../../howto/descriptor.rst:1686 +#: ../../howto/descriptor.rst:1690 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:1690 +#: ../../howto/descriptor.rst:1694 msgid "" "class Object:\n" " 'Simulate how object.__new__() allocates memory for __slots__'\n" @@ -1973,13 +1986,13 @@ msgid "" " super().__delattr__(name)" msgstr "" -#: ../../howto/descriptor.rst:1721 +#: ../../howto/descriptor.rst:1725 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:1724 +#: ../../howto/descriptor.rst:1728 msgid "" "class H(Object, metaclass=Type):\n" " 'Instance variables stored in slots'\n" @@ -1991,12 +2004,12 @@ msgid "" " self.y = y" msgstr "" -#: ../../howto/descriptor.rst:1735 +#: ../../howto/descriptor.rst:1739 msgid "" "At this point, the metaclass has loaded member objects for *x* and *y*::" msgstr "" -#: ../../howto/descriptor.rst:1737 +#: ../../howto/descriptor.rst:1741 msgid "" ">>> from pprint import pp\n" ">>> pp(dict(vars(H)))\n" @@ -2016,13 +2029,13 @@ msgstr "" " 'x': ,\n" " 'y': }" -#: ../../howto/descriptor.rst:1756 +#: ../../howto/descriptor.rst:1760 msgid "" "When instances are created, they have a ``slot_values`` list where the " "attributes are stored:" msgstr "" -#: ../../howto/descriptor.rst:1759 +#: ../../howto/descriptor.rst:1763 msgid "" ">>> h = H(10, 20)\n" ">>> vars(h)\n" @@ -2038,11 +2051,11 @@ msgstr "" ">>> vars(h)\n" "{'_slotvalues': [55, 20]}" -#: ../../howto/descriptor.rst:1768 +#: ../../howto/descriptor.rst:1772 msgid "Misspelled or unassigned attributes will raise an exception:" msgstr "" -#: ../../howto/descriptor.rst:1770 +#: ../../howto/descriptor.rst:1774 msgid "" ">>> h.xz\n" "Traceback (most recent call last):\n" diff --git a/howto/enum.po b/howto/enum.po index 31233ba9023..cbddd1538c2 100644 --- a/howto/enum.po +++ b/howto/enum.po @@ -1,12 +1,12 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # #, fuzzy msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-08-13 00:16+0000\n" +"POT-Creation-Date: 2025-09-12 00:14+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-" @@ -45,6 +45,15 @@ msgid "" "... SATURDAY = 6\n" "... SUNDAY = 7" msgstr "" +">>> from enum import Enum\n" +">>> class Weekday(Enum):\n" +"... MONDAY = 1\n" +"... TUESDAY = 2\n" +"... WEDNESDAY = 3\n" +"... THURSDAY = 4\n" +"... FRIDAY = 5\n" +"... SATURDAY = 6\n" +"... SUNDAY = 7" #: ../../howto/enum.rst:28 msgid "Or perhaps the RGB primary colors::" @@ -58,6 +67,11 @@ msgid "" "... GREEN = 2\n" "... BLUE = 3" msgstr "" +">>> from enum import Enum\n" +">>> class Color(Enum):\n" +"... RED = 1\n" +"... GREEN = 2\n" +"... BLUE = 3" #: ../../howto/enum.rst:36 msgid "" @@ -1004,6 +1018,15 @@ msgid "" ">>> Color.RED == Color.BLUE # problem is here: they should not be equal\n" "True" msgstr "" +">>> @dataclass # 不要這樣做,這並不合理\n" +"... class Color(Enum):\n" +"... RED = 1\n" +"... BLUE = 2\n" +"...\n" +">>> Color.RED is Color.BLUE\n" +"False\n" +">>> Color.RED == Color.BLUE # 問題在此:它們不應該相等\n" +"True" #: ../../howto/enum.rst:529 msgid "Pickling" @@ -2132,6 +2155,16 @@ msgid "" ">>> (Perm.R & Perm.W).name is None # effectively Perm(0)\n" "True" msgstr "" +">>> (Color.RED | Color.GREEN).name\n" +"'RED|GREEN'\n" +"\n" +">>> class Perm(IntFlag):\n" +"... R = 4\n" +"... W = 2\n" +"... X = 1\n" +"...\n" +">>> (Perm.R & Perm.W).name is None # 效果為 Perm(0)\n" +"True" #: ../../howto/enum.rst:1164 msgid "multi-bit flags, aka aliases, can be returned from operations::" @@ -2543,6 +2576,13 @@ msgid "" "... return obj\n" "..." msgstr "" +">>> class AutoNumber(Enum):\n" +"... def __new__(cls, *args): # 這是和上面相比唯一的變更\n" +"... value = len(cls.__members__) + 1\n" +"... obj = object.__new__(cls)\n" +"... obj._value_ = value\n" +"... return obj\n" +"..." #: ../../howto/enum.rst:1382 msgid "" @@ -2686,6 +2726,26 @@ msgid "" " ...\n" "ValueError: aliases not allowed in DuplicateFreeEnum: 'GRENE' --> 'GREEN'" msgstr "" +">>> class DuplicateFreeEnum(Enum):\n" +"... def __init__(self, *args):\n" +"... cls = self.__class__\n" +"... if any(self.value == e.value for e in cls):\n" +"... a = self.name\n" +"... e = cls(self.value).name\n" +"... raise ValueError(\n" +"... \"aliases not allowed in DuplicateFreeEnum: %r --> " +"%r\"\n" +"... % (a, e))\n" +"...\n" +">>> class Color(DuplicateFreeEnum):\n" +"... RED = 1\n" +"... GREEN = 2\n" +"... BLUE = 3\n" +"... GRENE = 2\n" +"...\n" +"Traceback (most recent call last):\n" +" ...\n" +"ValueError: aliases not allowed in DuplicateFreeEnum: 'GRENE' --> 'GREEN'" #: ../../howto/enum.rst:1477 msgid "" @@ -2721,6 +2781,22 @@ msgid "" ">>> DType(9)\n" "" msgstr "" +">>> class MultiValueEnum(Enum):\n" +"... def __new__(cls, value, *values):\n" +"... self = object.__new__(cls)\n" +"... self._value_ = value\n" +"... for v in values:\n" +"... self._add_value_alias_(v)\n" +"... return self\n" +"...\n" +">>> class DType(MultiValueEnum):\n" +"... float32 = 'f', 8\n" +"... double64 = 'd', 9\n" +"...\n" +">>> DType('f')\n" +"\n" +">>> DType(9)\n" +"" #: ../../howto/enum.rst:1506 msgid "Planet" @@ -2757,6 +2833,28 @@ msgid "" ">>> Planet.EARTH.surface_gravity\n" "9.802652743337129" msgstr "" +">>> class Planet(Enum):\n" +"... MERCURY = (3.303e+23, 2.4397e6)\n" +"... VENUS = (4.869e+24, 6.0518e6)\n" +"... EARTH = (5.976e+24, 6.37814e6)\n" +"... MARS = (6.421e+23, 3.3972e6)\n" +"... JUPITER = (1.9e+27, 7.1492e7)\n" +"... SATURN = (5.688e+26, 6.0268e7)\n" +"... URANUS = (8.686e+25, 2.5559e7)\n" +"... NEPTUNE = (1.024e+26, 2.4746e7)\n" +"... def __init__(self, mass, radius):\n" +"... self.mass = mass # 以公斤表示\n" +"... self.radius = radius # 以公尺表示\n" +"... @property\n" +"... def surface_gravity(self):\n" +"... # 萬有引力常數 (m3 kg-1 s-2)\n" +"... G = 6.67300E-11\n" +"... return G * self.mass / (self.radius * self.radius)\n" +"...\n" +">>> Planet.EARTH.value\n" +"(5.976e+24, 6378140.0)\n" +">>> Planet.EARTH.surface_gravity\n" +"9.802652743337129" #: ../../howto/enum.rst:1537 msgid "TimePeriod" @@ -2783,6 +2881,20 @@ msgid "" "[, ]" msgstr "" +">>> from datetime import timedelta\n" +">>> class Period(timedelta, Enum):\n" +"... \"不同長度的時間\"\n" +"... _ignore_ = 'Period i'\n" +"... Period = vars()\n" +"... for i in range(367):\n" +"... Period['day_%d' % i] = i\n" +"...\n" +">>> list(Period)[:2]\n" +"[, ]\n" +">>> list(Period)[-2:]\n" +"[, ]" #: ../../howto/enum.rst:1558 msgid "Subclassing EnumType" diff --git a/howto/free-threading-extensions.po b/howto/free-threading-extensions.po index 42af41a8d97..fbb99717379 100644 --- a/howto/free-threading-extensions.po +++ b/howto/free-threading-extensions.po @@ -1,12 +1,12 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # #, fuzzy msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-07-24 00:16+0000\n" +"POT-Creation-Date: 2025-11-07 00:14+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,9 +22,9 @@ msgstr "支援自由執行緒的 C API 擴充" #: ../../howto/free-threading-extensions.rst:9 msgid "" -"Starting with the 3.13 release, CPython has experimental support for running " -"with the :term:`global interpreter lock` (GIL) disabled in a configuration " -"called :term:`free threading`. This document describes how to adapt C API " +"Starting with the 3.13 release, CPython has support for running with the :" +"term:`global interpreter lock` (GIL) disabled in a configuration called :" +"term:`free threading`. This document describes how to adapt C API " "extensions to support free threading." msgstr "" @@ -182,12 +182,14 @@ msgstr "" #: ../../howto/free-threading-extensions.rst:107 msgid "" -"**Macros**: Accessor macros like :c:macro:`PyList_GET_ITEM` and :c:macro:" -"`PyList_SET_ITEM` do not perform any error checking or locking. These macros " -"are not thread-safe if the container object may be modified concurrently." +"**Macros**: Accessor macros like :c:macro:`PyList_GET_ITEM`, :c:macro:" +"`PyList_SET_ITEM`, and macros like :c:macro:`PySequence_Fast_GET_SIZE` that " +"use the object returned by :c:func:`PySequence_Fast` do not perform any " +"error checking or locking. These macros are not thread-safe if the container " +"object may be modified concurrently." msgstr "" -#: ../../howto/free-threading-extensions.rst:111 +#: ../../howto/free-threading-extensions.rst:113 msgid "" "**Borrowed References**: C API functions that return :term:`borrowed " "references ` may not be thread-safe if the containing " @@ -195,11 +197,11 @@ msgid "" "references ` for more information." msgstr "" -#: ../../howto/free-threading-extensions.rst:118 +#: ../../howto/free-threading-extensions.rst:120 msgid "Container Thread Safety" msgstr "容器執行緒安全性" -#: ../../howto/free-threading-extensions.rst:120 +#: ../../howto/free-threading-extensions.rst:122 msgid "" "Containers like :c:struct:`PyListObject`, :c:struct:`PyDictObject`, and :c:" "struct:`PySetObject` perform internal locking in the free-threaded build. " @@ -207,11 +209,11 @@ msgid "" "an item." msgstr "" -#: ../../howto/free-threading-extensions.rst:128 +#: ../../howto/free-threading-extensions.rst:130 msgid "``PyDict_Next``" msgstr "``PyDict_Next``" -#: ../../howto/free-threading-extensions.rst:130 +#: ../../howto/free-threading-extensions.rst:132 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 " @@ -219,7 +221,7 @@ msgid "" "modified::" msgstr "" -#: ../../howto/free-threading-extensions.rst:135 +#: ../../howto/free-threading-extensions.rst:137 msgid "" "Py_BEGIN_CRITICAL_SECTION(dict);\n" "PyObject *key, *value;\n" @@ -237,11 +239,11 @@ msgstr "" "}\n" "Py_END_CRITICAL_SECTION();" -#: ../../howto/free-threading-extensions.rst:145 +#: ../../howto/free-threading-extensions.rst:147 msgid "Borrowed References" msgstr "借用參照" -#: ../../howto/free-threading-extensions.rst:149 +#: ../../howto/free-threading-extensions.rst:151 msgid "" "Some C API functions return :term:`borrowed references `. These APIs are not thread-safe if the containing object is " @@ -249,92 +251,100 @@ msgid "" "`PyList_GetItem` if the list may be modified concurrently." msgstr "" -#: ../../howto/free-threading-extensions.rst:154 +#: ../../howto/free-threading-extensions.rst:156 msgid "" "The following table lists some borrowed reference APIs and their " "replacements that return :term:`strong references `." msgstr "" -#: ../../howto/free-threading-extensions.rst:158 +#: ../../howto/free-threading-extensions.rst:160 msgid "Borrowed reference API" msgstr "借用參照 API" -#: ../../howto/free-threading-extensions.rst:158 +#: ../../howto/free-threading-extensions.rst:160 msgid "Strong reference API" msgstr "強參照 API" -#: ../../howto/free-threading-extensions.rst:160 +#: ../../howto/free-threading-extensions.rst:162 msgid ":c:func:`PyList_GetItem`" msgstr ":c:func:`PyList_GetItem`" -#: ../../howto/free-threading-extensions.rst:160 #: ../../howto/free-threading-extensions.rst:162 +#: ../../howto/free-threading-extensions.rst:164 msgid ":c:func:`PyList_GetItemRef`" msgstr ":c:func:`PyList_GetItemRef`" -#: ../../howto/free-threading-extensions.rst:162 +#: ../../howto/free-threading-extensions.rst:164 msgid ":c:func:`PyList_GET_ITEM`" msgstr ":c:func:`PyList_GET_ITEM`" -#: ../../howto/free-threading-extensions.rst:164 +#: ../../howto/free-threading-extensions.rst:166 msgid ":c:func:`PyDict_GetItem`" msgstr ":c:func:`PyDict_GetItem`" -#: ../../howto/free-threading-extensions.rst:164 #: ../../howto/free-threading-extensions.rst:166 +#: ../../howto/free-threading-extensions.rst:168 msgid ":c:func:`PyDict_GetItemRef`" msgstr ":c:func:`PyDict_GetItemRef`" -#: ../../howto/free-threading-extensions.rst:166 +#: ../../howto/free-threading-extensions.rst:168 msgid ":c:func:`PyDict_GetItemWithError`" msgstr ":c:func:`PyDict_GetItemWithError`" -#: ../../howto/free-threading-extensions.rst:168 +#: ../../howto/free-threading-extensions.rst:170 msgid ":c:func:`PyDict_GetItemString`" msgstr ":c:func:`PyDict_GetItemString`" -#: ../../howto/free-threading-extensions.rst:168 +#: ../../howto/free-threading-extensions.rst:170 msgid ":c:func:`PyDict_GetItemStringRef`" msgstr ":c:func:`PyDict_GetItemStringRef`" -#: ../../howto/free-threading-extensions.rst:170 +#: ../../howto/free-threading-extensions.rst:172 msgid ":c:func:`PyDict_SetDefault`" msgstr ":c:func:`PyDict_SetDefault`" -#: ../../howto/free-threading-extensions.rst:170 +#: ../../howto/free-threading-extensions.rst:172 msgid ":c:func:`PyDict_SetDefaultRef`" msgstr ":c:func:`PyDict_SetDefaultRef`" -#: ../../howto/free-threading-extensions.rst:172 +#: ../../howto/free-threading-extensions.rst:174 msgid ":c:func:`PyDict_Next`" msgstr ":c:func:`PyDict_Next`" -#: ../../howto/free-threading-extensions.rst:172 +#: ../../howto/free-threading-extensions.rst:174 msgid "none (see :ref:`PyDict_Next`)" msgstr "" -#: ../../howto/free-threading-extensions.rst:174 +#: ../../howto/free-threading-extensions.rst:176 msgid ":c:func:`PyWeakref_GetObject`" msgstr ":c:func:`PyWeakref_GetObject`" -#: ../../howto/free-threading-extensions.rst:174 #: ../../howto/free-threading-extensions.rst:176 +#: ../../howto/free-threading-extensions.rst:178 msgid ":c:func:`PyWeakref_GetRef`" msgstr ":c:func:`PyWeakref_GetRef`" -#: ../../howto/free-threading-extensions.rst:176 +#: ../../howto/free-threading-extensions.rst:178 msgid ":c:func:`PyWeakref_GET_OBJECT`" msgstr ":c:func:`PyWeakref_GET_OBJECT`" -#: ../../howto/free-threading-extensions.rst:178 +#: ../../howto/free-threading-extensions.rst:180 msgid ":c:func:`PyImport_AddModule`" msgstr ":c:func:`PyImport_AddModule`" -#: ../../howto/free-threading-extensions.rst:178 +#: ../../howto/free-threading-extensions.rst:180 msgid ":c:func:`PyImport_AddModuleRef`" msgstr ":c:func:`PyImport_AddModuleRef`" -#: ../../howto/free-threading-extensions.rst:181 +#: ../../howto/free-threading-extensions.rst:182 +msgid ":c:func:`PyCell_GET`" +msgstr ":c:func:`PyCell_GET`" + +#: ../../howto/free-threading-extensions.rst:182 +msgid ":c:func:`PyCell_Get`" +msgstr ":c:func:`PyCell_Get`" + +#: ../../howto/free-threading-extensions.rst:185 msgid "" "Not all APIs that return borrowed references are problematic. For example, :" "c:func:`PyTuple_GetItem` is safe because tuples are immutable. Similarly, " @@ -345,57 +355,57 @@ msgid "" "context is safe." msgstr "" -#: ../../howto/free-threading-extensions.rst:189 +#: ../../howto/free-threading-extensions.rst:193 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:197 +#: ../../howto/free-threading-extensions.rst:201 msgid "Memory Allocation APIs" msgstr "" -#: ../../howto/free-threading-extensions.rst:199 +#: ../../howto/free-threading-extensions.rst:203 msgid "" "Python's memory management C API provides functions in three different :ref:" "`allocation domains `: \"raw\", \"mem\", and \"object\". " "For thread-safety, the free-threaded build requires that only Python objects " -"are allocated using the object domain, and that all Python object are " +"are allocated using the object domain, and that all Python objects are " "allocated using that domain. This differs from the prior Python versions, " "where this was only a best practice and not a hard requirement." msgstr "" -#: ../../howto/free-threading-extensions.rst:208 +#: ../../howto/free-threading-extensions.rst:212 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:215 +#: ../../howto/free-threading-extensions.rst:219 msgid "Thread State and GIL APIs" msgstr "" -#: ../../howto/free-threading-extensions.rst:217 +#: ../../howto/free-threading-extensions.rst:221 msgid "" "Python provides a set of functions and macros to manage thread state and the " "GIL, such as:" msgstr "" -#: ../../howto/free-threading-extensions.rst:220 +#: ../../howto/free-threading-extensions.rst:224 msgid ":c:func:`PyGILState_Ensure` and :c:func:`PyGILState_Release`" msgstr ":c:func:`PyGILState_Ensure` 和 :c:func:`PyGILState_Release`" -#: ../../howto/free-threading-extensions.rst:221 +#: ../../howto/free-threading-extensions.rst:225 msgid ":c:func:`PyEval_SaveThread` and :c:func:`PyEval_RestoreThread`" msgstr ":c:func:`PyEval_SaveThread` 和 :c:func:`PyEval_RestoreThread`" -#: ../../howto/free-threading-extensions.rst:222 +#: ../../howto/free-threading-extensions.rst:226 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:224 +#: ../../howto/free-threading-extensions.rst:228 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 " @@ -404,7 +414,7 @@ msgid "" "Python thread state." msgstr "" -#: ../../howto/free-threading-extensions.rst:230 +#: ../../howto/free-threading-extensions.rst:234 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 " @@ -412,25 +422,25 @@ msgid "" "collector `." msgstr "" -#: ../../howto/free-threading-extensions.rst:237 +#: ../../howto/free-threading-extensions.rst:241 msgid "Protecting Internal Extension State" msgstr "" -#: ../../howto/free-threading-extensions.rst:239 +#: ../../howto/free-threading-extensions.rst:243 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:243 +#: ../../howto/free-threading-extensions.rst:247 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:246 +#: ../../howto/free-threading-extensions.rst:250 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 " @@ -438,34 +448,247 @@ msgid "" "language/storage_duration>`_." msgstr "" -#: ../../howto/free-threading-extensions.rst:253 +#: ../../howto/free-threading-extensions.rst:257 +msgid "Critical Sections" +msgstr "" + +#: ../../howto/free-threading-extensions.rst:261 +msgid "" +"In the free-threaded build, CPython provides a mechanism called \"critical " +"sections\" to protect data that would otherwise be protected by the GIL. " +"While extension authors may not interact with the internal critical section " +"implementation directly, understanding their behavior is crucial when using " +"certain C API functions or managing shared state in the free-threaded build." +msgstr "" + +#: ../../howto/free-threading-extensions.rst:268 +msgid "What Are Critical Sections?" +msgstr "" + +#: ../../howto/free-threading-extensions.rst:270 +msgid "" +"Conceptually, critical sections act as a deadlock avoidance layer built on " +"top of simple mutexes. Each thread maintains a stack of active critical " +"sections. When a thread needs to acquire a lock associated with a critical " +"section (e.g., implicitly when calling a thread-safe C API function like :c:" +"func:`PyDict_SetItem`, or explicitly using macros), it attempts to acquire " +"the underlying mutex." +msgstr "" + +#: ../../howto/free-threading-extensions.rst:278 +msgid "Using Critical Sections" +msgstr "" + +#: ../../howto/free-threading-extensions.rst:280 +msgid "The primary APIs for using critical sections are:" +msgstr "" + +#: ../../howto/free-threading-extensions.rst:282 +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 +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 +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 " +"non-free-threaded builds, so they can be safely added to code that needs to " +"support both build types." +msgstr "" + +#: ../../howto/free-threading-extensions.rst:293 +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 " +"has an internal count field, you could use a critical section while reading " +"or writing that field::" +msgstr "" + +#: ../../howto/free-threading-extensions.rst:298 +msgid "" +"// read the count, returns new reference to internal count value\n" +"PyObject *result;\n" +"Py_BEGIN_CRITICAL_SECTION(obj);\n" +"result = Py_NewRef(obj->count);\n" +"Py_END_CRITICAL_SECTION();\n" +"return result;\n" +"\n" +"// write the count, consumes reference from new_count\n" +"Py_BEGIN_CRITICAL_SECTION(obj);\n" +"obj->count = new_count;\n" +"Py_END_CRITICAL_SECTION();" +msgstr "" + +#: ../../howto/free-threading-extensions.rst:312 +msgid "How Critical Sections Work" +msgstr "" + +#: ../../howto/free-threading-extensions.rst:314 +msgid "" +"Unlike traditional locks, critical sections do not guarantee exclusive " +"access throughout their entire duration. If a thread would block while " +"holding a critical section (e.g., by acquiring another lock or performing I/" +"O), the critical section is temporarily suspended—all locks are released—and " +"then resumed when the blocking operation completes." +msgstr "" + +#: ../../howto/free-threading-extensions.rst:320 +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 +msgid "Critical sections operate on a per-object basis rather than globally" +msgstr "" + +#: ../../howto/free-threading-extensions.rst:325 +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 +msgid "" +"Critical sections automatically release and reacquire locks around potential " +"blocking operations" +msgstr "" + +#: ../../howto/free-threading-extensions.rst:332 +msgid "Deadlock Avoidance" +msgstr "" + +#: ../../howto/free-threading-extensions.rst:334 +msgid "Critical sections help avoid deadlocks in two ways:" +msgstr "" + +#: ../../howto/free-threading-extensions.rst:336 +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 +msgid "" +"When the blocking operation completes, only the top-most critical section is " +"reacquired first" +msgstr "" + +#: ../../howto/free-threading-extensions.rst:343 +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. " +"Instead, use :c:macro:`Py_BEGIN_CRITICAL_SECTION2` to lock two objects " +"simultaneously." +msgstr "" + +#: ../../howto/free-threading-extensions.rst:347 +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 " +"locking mechanisms that might be in use, like POSIX mutexes. Also note that " +"while blocking on any :c:type:`PyMutex` causes the critical sections to be " +"suspended, only the mutexes that are part of the critical sections are " +"released. If :c:type:`PyMutex` is used without a critical section, it will " +"not be released and therefore does not get the same deadlock avoidance." +msgstr "" + +#: ../../howto/free-threading-extensions.rst:356 +msgid "Important Considerations" +msgstr "" + +#: ../../howto/free-threading-extensions.rst:358 +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 +msgid "" +"Because locks can be temporarily released (suspended), entering a critical " +"section does not guarantee exclusive access to the protected resource " +"throughout the section's duration. If code within a critical section calls " +"another function that blocks (e.g., acquires another lock, performs blocking " +"I/O), all locks held by the thread via critical sections will be released. " +"This is similar to how the GIL can be released during blocking calls." +msgstr "" + +#: ../../howto/free-threading-extensions.rst:369 +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 +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 +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 +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 +msgid "" +"Remember that the critical section macros are primarily for protecting " +"access to *Python objects* that might be involved in internal CPython " +"operations susceptible to the deadlock scenarios described above. For " +"protecting purely internal extension state, standard mutexes or other " +"synchronization primitives might be more appropriate." +msgstr "" + +#: ../../howto/free-threading-extensions.rst:392 msgid "Building Extensions for the Free-Threaded Build" msgstr "" -#: ../../howto/free-threading-extensions.rst:255 +#: ../../howto/free-threading-extensions.rst:394 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:258 +#: ../../howto/free-threading-extensions.rst:397 msgid "" "`pypa/manylinux `_ supports the free-" "threaded build, with the ``t`` suffix, such as ``python3.13t``." msgstr "" -#: ../../howto/free-threading-extensions.rst:260 +#: ../../howto/free-threading-extensions.rst:399 msgid "" "`pypa/cibuildwheel `_ supports the " -"free-threaded build if you set `CIBW_ENABLE to cpython-freethreading " -"`_." +"free-threaded build on Python 3.13 and 3.14. On Python 3.14, free-threaded " +"wheels will be built by default. On Python 3.13, you will need to set " +"`CIBW_ENABLE to cpython-freethreading `_." msgstr "" -#: ../../howto/free-threading-extensions.rst:265 +#: ../../howto/free-threading-extensions.rst:405 msgid "Limited C API and Stable ABI" msgstr "" -#: ../../howto/free-threading-extensions.rst:267 +#: ../../howto/free-threading-extensions.rst:407 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/free-threading-python.po b/howto/free-threading-python.po index ada1b6f51fb..8ecf25ae553 100644 --- a/howto/free-threading-python.po +++ b/howto/free-threading-python.po @@ -1,13 +1,13 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# 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.13\n" +"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: 2025-12-03 00:14+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,76 +18,77 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" #: ../../howto/free-threading-python.rst:5 -msgid "Python experimental support for free threading" -msgstr "Python 自由執行緒的實驗性支援" +msgid "Python support for free threading" +msgstr "Python 自由執行緒的支援" #: ../../howto/free-threading-python.rst:7 msgid "" -"Starting with the 3.13 release, CPython has experimental support for a build " -"of Python called :term:`free threading` where the :term:`global interpreter " -"lock` (GIL) is disabled. Free-threaded execution allows for full " -"utilization of the available processing power by running threads in parallel " -"on available CPU cores. While not all software will benefit from this " -"automatically, programs designed with threading in mind will run faster on " -"multi-core hardware." +"Starting with the 3.13 release, CPython has support for a build of Python " +"called :term:`free threading` where the :term:`global interpreter lock` " +"(GIL) is disabled. Free-threaded execution allows for full utilization of " +"the available processing power by running threads in parallel on available " +"CPU cores. While not all software will benefit from this automatically, " +"programs designed with threading in mind will run faster on multi-core " +"hardware." msgstr "" #: ../../howto/free-threading-python.rst:14 msgid "" -"**The free-threaded mode is experimental** and work is ongoing to improve " -"it: expect some bugs and a substantial single-threaded performance hit." +"Some 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`." msgstr "" -#: ../../howto/free-threading-python.rst:17 +#: ../../howto/free-threading-python.rst:18 msgid "" "This document describes the implications of free threading for Python code. " "See :ref:`freethreading-extensions-howto` for information on how to write C " "extensions that support the free-threaded build." msgstr "" -#: ../../howto/free-threading-python.rst:23 +#: ../../howto/free-threading-python.rst:24 msgid "" ":pep:`703` – Making the Global Interpreter Lock Optional in CPython for an " "overall description of free-threaded Python." msgstr "" -#: ../../howto/free-threading-python.rst:28 +#: ../../howto/free-threading-python.rst:29 msgid "Installation" msgstr "安裝" -#: ../../howto/free-threading-python.rst:30 +#: ../../howto/free-threading-python.rst:31 msgid "" "Starting with Python 3.13, the official macOS and Windows installers " "optionally support installing free-threaded Python binaries. The installers " "are available at https://www.python.org/downloads/." msgstr "" -#: ../../howto/free-threading-python.rst:34 +#: ../../howto/free-threading-python.rst:35 msgid "" "For information on other platforms, see the `Installing a Free-Threaded " "Python `_, a " "community-maintained installation guide for installing free-threaded Python." msgstr "" -#: ../../howto/free-threading-python.rst:38 +#: ../../howto/free-threading-python.rst:39 msgid "" "When building CPython from source, the :option:`--disable-gil` configure " "option should be used to build a free-threaded Python interpreter." msgstr "" -#: ../../howto/free-threading-python.rst:43 +#: ../../howto/free-threading-python.rst:44 msgid "Identifying free-threaded Python" msgstr "" -#: ../../howto/free-threading-python.rst:45 +#: ../../howto/free-threading-python.rst:46 msgid "" "To check if the current interpreter supports free-threading, :option:`python " -"-VV <-V>` and :data:`sys.version` contain \"experimental free-threading " -"build\". The new :func:`sys._is_gil_enabled` function can be used to check " -"whether the GIL is actually disabled in the running process." +"-VV <-V>` and :data:`sys.version` contain \"free-threading build\". The new :" +"func:`sys._is_gil_enabled` function can be used to check whether the GIL is " +"actually disabled in the running process." msgstr "" -#: ../../howto/free-threading-python.rst:50 +#: ../../howto/free-threading-python.rst:51 msgid "" "The ``sysconfig.get_config_var(\"Py_GIL_DISABLED\")`` configuration variable " "can be used to determine whether the build supports free threading. If the " @@ -95,43 +96,43 @@ msgid "" "the recommended mechanism for decisions related to the build configuration." msgstr "" -#: ../../howto/free-threading-python.rst:57 +#: ../../howto/free-threading-python.rst:58 msgid "The global interpreter lock in free-threaded Python" msgstr "" -#: ../../howto/free-threading-python.rst:59 +#: ../../howto/free-threading-python.rst:60 msgid "" "Free-threaded builds of CPython support optionally running with the GIL " "enabled at runtime using the environment variable :envvar:`PYTHON_GIL` or " "the command-line option :option:`-X gil`." msgstr "" -#: ../../howto/free-threading-python.rst:63 +#: ../../howto/free-threading-python.rst:64 msgid "" "The GIL may also automatically be enabled when importing a C-API extension " "module that is not explicitly marked as supporting free threading. A " "warning will be printed in this case." msgstr "" -#: ../../howto/free-threading-python.rst:67 +#: ../../howto/free-threading-python.rst:68 msgid "" "In addition to individual package documentation, the following websites " "track the status of popular packages support for free threading:" msgstr "" -#: ../../howto/free-threading-python.rst:70 +#: ../../howto/free-threading-python.rst:71 msgid "https://py-free-threading.github.io/tracking/" msgstr "https://py-free-threading.github.io/tracking/" -#: ../../howto/free-threading-python.rst:71 +#: ../../howto/free-threading-python.rst:72 msgid "https://hugovk.github.io/free-threaded-wheels/" msgstr "https://hugovk.github.io/free-threaded-wheels/" -#: ../../howto/free-threading-python.rst:75 +#: ../../howto/free-threading-python.rst:76 msgid "Thread safety" msgstr "執行緒安全" -#: ../../howto/free-threading-python.rst:77 +#: ../../howto/free-threading-python.rst:78 msgid "" "The free-threaded build of CPython aims to provide similar thread-safety " "behavior at the Python level to the default GIL-enabled build. Built-in " @@ -143,115 +144,118 @@ msgid "" "current or future behavior." msgstr "" -#: ../../howto/free-threading-python.rst:88 +#: ../../howto/free-threading-python.rst:89 msgid "" "It's recommended to use the :class:`threading.Lock` or other synchronization " "primitives instead of relying on the internal locks of built-in types, when " "possible." msgstr "" -#: ../../howto/free-threading-python.rst:94 +#: ../../howto/free-threading-python.rst:95 msgid "Known limitations" msgstr "已知限制" -#: ../../howto/free-threading-python.rst:96 +#: ../../howto/free-threading-python.rst:97 msgid "" "This section describes known limitations of the free-threaded CPython build." msgstr "" -#: ../../howto/free-threading-python.rst:99 +#: ../../howto/free-threading-python.rst:100 msgid "Immortalization" msgstr "不滅化 (Immortalization)" -#: ../../howto/free-threading-python.rst:101 +#: ../../howto/free-threading-python.rst:102 msgid "" -"The free-threaded build of the 3.13 release makes some objects :term:" -"`immortal`. Immortal objects are not deallocated and have reference counts " -"that are never modified. This is done to avoid reference count contention " -"that would prevent efficient multi-threaded scaling." +"In the free-threaded build, some objects are :term:`immortal`. Immortal " +"objects are not deallocated and have reference counts that are never " +"modified. This is done to avoid reference count contention that would " +"prevent efficient multi-threaded scaling." msgstr "" -#: ../../howto/free-threading-python.rst:106 -msgid "" -"An object will be made immortal when a new thread is started for the first " -"time after the main thread is running. The following objects are " -"immortalized:" +#: ../../howto/free-threading-python.rst:107 +msgid "As of the 3.14 release, immortalization is limited to:" msgstr "" #: ../../howto/free-threading-python.rst:109 msgid "" -":ref:`function ` objects declared at the module level" -msgstr "在模組層級宣告的\\ :ref:`函式 `\\ 物件" - -#: ../../howto/free-threading-python.rst:110 -msgid ":ref:`method ` descriptors" -msgstr ":ref:`方法 `\\ 描述器" +"Code constants: numeric literals, string literals, and tuple literals " +"composed of other constants." +msgstr "" #: ../../howto/free-threading-python.rst:111 -msgid ":ref:`code ` objects" -msgstr ":ref:`程式碼 `\\ 物件" +msgid "Strings interned by :func:`sys.intern`." +msgstr "" + +#: ../../howto/free-threading-python.rst:115 +msgid "Frame objects" +msgstr "" -#: ../../howto/free-threading-python.rst:112 -msgid ":term:`module` objects and their dictionaries" -msgstr ":term:`模組 `\\ 物件及其字典" +#: ../../howto/free-threading-python.rst:117 +msgid "" +"It is not safe to access :attr:`frame.f_locals` from a :ref:`frame ` object if that frame is currently executing in another thread, and " +"doing so may crash the interpreter." +msgstr "" -#: ../../howto/free-threading-python.rst:113 -msgid ":ref:`classes ` (type objects)" -msgstr ":ref:`類別 `\\ (型別物件)" +#: ../../howto/free-threading-python.rst:123 +msgid "Iterators" +msgstr "疊代器" -#: ../../howto/free-threading-python.rst:115 +#: ../../howto/free-threading-python.rst:125 msgid "" -"Because immortal objects are never deallocated, applications that create " -"many objects of these types may see increased memory usage. This is " -"expected to be addressed in the 3.14 release." +"It is generally not thread-safe to access the same iterator object from " +"multiple threads concurrently, and threads may see duplicate or missing " +"elements." msgstr "" -#: ../../howto/free-threading-python.rst:119 +#: ../../howto/free-threading-python.rst:131 +msgid "Single-threaded performance" +msgstr "單執行緒效能" + +#: ../../howto/free-threading-python.rst:133 msgid "" -"Additionally, numeric and string literals in the code as well as strings " -"returned by :func:`sys.intern` are also immortalized. This behavior is " -"expected to remain in the 3.14 free-threaded build." +"The free-threaded build has additional overhead when executing Python code " +"compared to the default GIL-enabled build. The amount of overhead depends " +"on the workload and hardware. On the pyperformance benchmark suite, the " +"average overhead ranges from about 1% on macOS aarch64 to 8% on x86-64 Linux " +"systems." msgstr "" -#: ../../howto/free-threading-python.rst:125 -msgid "Frame objects" +#: ../../howto/free-threading-python.rst:141 +msgid "Behavioral changes" msgstr "" -#: ../../howto/free-threading-python.rst:127 +#: ../../howto/free-threading-python.rst:143 msgid "" -"It is not safe to access :ref:`frame ` objects from other " -"threads and doing so may cause your program to crash . This means that :" -"func:`sys._current_frames` is generally not safe to use in a free-threaded " -"build. Functions like :func:`inspect.currentframe` and :func:`sys." -"_getframe` are generally safe as long as the resulting frame object is not " -"passed to another thread." +"This section describes CPython behavioural changes with the free-threaded " +"build." msgstr "" -#: ../../howto/free-threading-python.rst:135 -msgid "Iterators" -msgstr "疊代器" +#: ../../howto/free-threading-python.rst:148 +msgid "Context variables" +msgstr "" -#: ../../howto/free-threading-python.rst:137 +#: ../../howto/free-threading-python.rst:150 msgid "" -"Sharing the same iterator object between multiple threads is generally not " -"safe and threads may see duplicate or missing elements when iterating or " -"crash the interpreter." +"In the free-threaded build, the flag :data:`~sys.flags." +"thread_inherit_context` is set to true by default which causes threads " +"created with :class:`threading.Thread` to start with a copy of the :class:" +"`~contextvars.Context()` of the caller of :meth:`~threading.Thread.start`. " +"In the default GIL-enabled build, the flag defaults to false so threads " +"start with an empty :class:`~contextvars.Context()`." msgstr "" -#: ../../howto/free-threading-python.rst:143 -msgid "Single-threaded performance" -msgstr "單執行緒效能" +#: ../../howto/free-threading-python.rst:160 +msgid "Warning filters" +msgstr "" -#: ../../howto/free-threading-python.rst:145 +#: ../../howto/free-threading-python.rst:162 msgid "" -"The free-threaded build has additional overhead when executing Python code " -"compared to the default GIL-enabled build. In 3.13, this overhead is about " -"40% on the `pyperformance `_ suite. " -"Programs that spend most of their time in C extensions or I/O will see less " -"of an impact. The largest impact is because the specializing adaptive " -"interpreter (:pep:`659`) is disabled in the free-threaded build. We expect " -"to re-enable it in a thread-safe way in the 3.14 release. This overhead is " -"expected to be reduced in upcoming Python release. We are aiming for an " -"overhead of 10% or less on the pyperformance suite compared to the default " -"GIL-enabled build." +"In the free-threaded build, the flag :data:`~sys.flags." +"context_aware_warnings` is set to true by default. In the default GIL-" +"enabled build, the flag defaults to false. If the flag is true then the :" +"class:`warnings.catch_warnings` context manager uses a context variable for " +"warning filters. If the flag is false then :class:`~warnings." +"catch_warnings` modifies the global filters list, which is not thread-safe. " +"See the :mod:`warnings` module for more details." msgstr "" diff --git a/howto/functional.po b/howto/functional.po index f3022836611..8e186ab5448 100644 --- a/howto/functional.po +++ b/howto/functional.po @@ -1,13 +1,13 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Leon H., 2017 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-07-04 00:16+0000\n" +"POT-Creation-Date: 2025-11-30 00:16+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-" @@ -27,8 +27,8 @@ msgid "Author" msgstr "作者" #: ../../howto/functional.rst:7 -msgid "A. M. Kuchling" -msgstr "A. M. Kuchling" +msgid "\\A. M. Kuchling" +msgstr "\\A. M. Kuchling" #: ../../howto/functional.rst:0 msgid "Release" @@ -1018,6 +1018,15 @@ msgid "" ">>> sorted(rand_list, reverse=True)\n" "[9878, 9828, 8442, 7953, 6431, 6213, 2207, 769]" msgstr "" +">>> import random\n" +">>> # 產生 8 個範圍在 [0, 10000) 的隨機數字\n" +">>> rand_list = random.sample(range(10000), 8)\n" +">>> rand_list\n" +"[769, 7953, 9828, 6431, 8442, 9878, 6213, 2207]\n" +">>> sorted(rand_list)\n" +"[769, 2207, 6213, 6431, 7953, 8442, 9828, 9878]\n" +">>> sorted(rand_list, reverse=True)\n" +"[9878, 9828, 8442, 7953, 6431, 6213, 2207, 769]" #: ../../howto/functional.rst:698 msgid "" diff --git a/howto/gdb_helpers.po b/howto/gdb_helpers.po index 1fb852831b6..76983819c82 100644 --- a/howto/gdb_helpers.po +++ b/howto/gdb_helpers.po @@ -1,11 +1,11 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Matt Wang , 2024 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-12-06 00:14+0000\n" "PO-Revision-Date: 2024-05-11 14:42+0800\n" diff --git a/howto/index.po b/howto/index.po index 1405805e943..399d00a18aa 100644 --- a/howto/index.po +++ b/howto/index.po @@ -1,13 +1,13 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Steven Hsu , 2021 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-08-10 00:19+0000\n" +"POT-Creation-Date: 2025-09-08 15:25+0800\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,110 +34,114 @@ msgstr "" "定的主題。以 Linux 說明文件專案的 HOWTO 系列為模範,本系列的目標是提供比 " "Python 函式庫參考手冊更實用的說明文件。" -#: ../../howto/index.rst:41 +#: ../../howto/index.rst:42 msgid "General:" msgstr "一般:" -#: ../../howto/index.rst:43 +#: ../../howto/index.rst:44 msgid ":ref:`a-conceptual-overview-of-asyncio`" msgstr ":ref:`a-conceptual-overview-of-asyncio`" -#: ../../howto/index.rst:44 +#: ../../howto/index.rst:45 msgid ":ref:`annotations-howto`" msgstr ":ref:`annotations-howto`" -#: ../../howto/index.rst:45 +#: ../../howto/index.rst:46 msgid ":ref:`argparse-tutorial`" msgstr ":ref:`argparse-tutorial`" -#: ../../howto/index.rst:46 +#: ../../howto/index.rst:47 msgid ":ref:`descriptorhowto`" msgstr ":ref:`descriptorhowto`" -#: ../../howto/index.rst:47 +#: ../../howto/index.rst:48 msgid ":ref:`enum-howto`" msgstr ":ref:`enum-howto`" -#: ../../howto/index.rst:48 +#: ../../howto/index.rst:49 msgid ":ref:`functional-howto`" msgstr ":ref:`functional-howto`" -#: ../../howto/index.rst:49 +#: ../../howto/index.rst:50 msgid ":ref:`ipaddress-howto`" msgstr ":ref:`ipaddress-howto`" -#: ../../howto/index.rst:50 +#: ../../howto/index.rst:51 msgid ":ref:`logging-howto`" msgstr ":ref:`logging-howto`" -#: ../../howto/index.rst:51 +#: ../../howto/index.rst:52 msgid ":ref:`logging-cookbook`" msgstr ":ref:`logging-cookbook`" -#: ../../howto/index.rst:52 +#: ../../howto/index.rst:53 msgid ":ref:`regex-howto`" msgstr ":ref:`regex-howto`" -#: ../../howto/index.rst:53 +#: ../../howto/index.rst:54 msgid ":ref:`sortinghowto`" msgstr ":ref:`sortinghowto`" -#: ../../howto/index.rst:54 +#: ../../howto/index.rst:55 msgid ":ref:`unicode-howto`" msgstr ":ref:`unicode-howto`" -#: ../../howto/index.rst:55 +#: ../../howto/index.rst:56 msgid ":ref:`urllib-howto`" msgstr ":ref:`urllib-howto`" -#: ../../howto/index.rst:57 +#: ../../howto/index.rst:58 msgid "Advanced development:" msgstr "進階開發:" -#: ../../howto/index.rst:59 +#: ../../howto/index.rst:60 msgid ":ref:`curses-howto`" msgstr ":ref:`curses-howto`" -#: ../../howto/index.rst:60 +#: ../../howto/index.rst:61 msgid ":ref:`freethreading-python-howto`" msgstr ":ref:`freethreading-python-howto`" -#: ../../howto/index.rst:61 +#: ../../howto/index.rst:62 msgid ":ref:`freethreading-extensions-howto`" msgstr ":ref:`freethreading-extensions-howto`" -#: ../../howto/index.rst:62 +#: ../../howto/index.rst:63 msgid ":ref:`isolating-extensions-howto`" msgstr ":ref:`isolating-extensions-howto`" -#: ../../howto/index.rst:63 +#: ../../howto/index.rst:64 msgid ":ref:`python_2.3_mro`" msgstr ":ref:`python_2.3_mro`" -#: ../../howto/index.rst:64 +#: ../../howto/index.rst:65 msgid ":ref:`socket-howto`" msgstr ":ref:`socket-howto`" -#: ../../howto/index.rst:65 +#: ../../howto/index.rst:66 msgid ":ref:`timerfd-howto`" msgstr ":ref:`timerfd-howto`" -#: ../../howto/index.rst:66 +#: ../../howto/index.rst:67 msgid ":ref:`cporting-howto`" msgstr ":ref:`cporting-howto`" -#: ../../howto/index.rst:68 +#: ../../howto/index.rst:69 msgid "Debugging and profiling:" msgstr "偵錯與效能分析:" -#: ../../howto/index.rst:70 +#: ../../howto/index.rst:71 msgid ":ref:`gdb`" msgstr ":ref:`gdb`" -#: ../../howto/index.rst:71 +#: ../../howto/index.rst:72 msgid ":ref:`instrumentation`" msgstr ":ref:`instrumentation`" -#: ../../howto/index.rst:72 +#: ../../howto/index.rst:73 msgid ":ref:`perf_profiling`" msgstr ":ref:`perf_profiling`" + +#: ../../howto/index.rst:74 +msgid ":ref:`remote-debugging`" +msgstr ":ref:`remote-debugging`" diff --git a/howto/instrumentation.po b/howto/instrumentation.po index be4be21d271..961dac6817f 100644 --- a/howto/instrumentation.po +++ b/howto/instrumentation.po @@ -1,11 +1,11 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Matt Wang msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2025-09-04 00:15+0000\n" "PO-Revision-Date: 2023-08-17 22:17+0800\n" diff --git a/howto/ipaddress.po b/howto/ipaddress.po index b4124f004d5..29659813c84 100644 --- a/howto/ipaddress.po +++ b/howto/ipaddress.po @@ -1,13 +1,13 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Leon H., 2017 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-02-19 00:13+0000\n" +"POT-Creation-Date: 2025-12-01 00:17+0000\n" "PO-Revision-Date: 2024-07-20 16:09+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -35,7 +35,7 @@ msgstr "Peter Moody" msgid "Nick Coghlan" msgstr "Nick Coghlan" -#: ../../howto/ipaddress.rst:-1 +#: ../../howto/ipaddress.rst:14 msgid "Overview" msgstr "總攬" @@ -145,8 +145,8 @@ msgstr "定義網路" #: ../../howto/ipaddress.rst:84 msgid "" -"Host addresses are usually grouped together into IP networks, " -"so :mod:`ipaddress` provides a way to create, inspect and manipulate network " +"Host addresses are usually grouped together into IP networks, so :mod:" +"`ipaddress` provides a way to create, inspect and manipulate network " "definitions. IP network objects are constructed from strings that define the " "range of host addresses that are part of that network. The simplest form for " "that information is a \"network address/network prefix\" pair, where the " @@ -242,11 +242,11 @@ msgid "" "network, neither the address nor the network classes are sufficient. " "Notation like ``192.0.2.1/24`` is commonly used by network engineers and the " "people who write tools for firewalls and routers as shorthand for \"the host " -"``192.0.2.1`` on the network ``192.0.2.0/24``\", " -"Accordingly, :mod:`ipaddress` provides a set of hybrid classes that " -"associate an address with a particular network. The interface for creation " -"is identical to that for defining network objects, except that the address " -"portion isn't constrained to being a network address." +"``192.0.2.1`` on the network ``192.0.2.0/24``\", Accordingly, :mod:" +"`ipaddress` provides a set of hybrid classes that associate an address with " +"a particular network. The interface for creation is identical to that for " +"defining network objects, except that the address portion isn't constrained " +"to being a network address." msgstr "" #: ../../howto/ipaddress.rst:152 @@ -262,8 +262,8 @@ msgstr "檢視 Address/Network/Interface 物件" #: ../../howto/ipaddress.rst:159 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:`ipaddress` tries to make doing this easy and intuitive." +"Interface) object, so you probably want to get information about it. :mod:" +"`ipaddress` tries to make doing this easy and intuitive." msgstr "" #: ../../howto/ipaddress.rst:163 @@ -522,9 +522,9 @@ msgstr "" #: ../../howto/ipaddress.rst:305 msgid "" "To support use cases where it is useful to have access to this additional " -"detail, the individual class constructors actually raise " -"the :exc:`ValueError` subclasses :exc:`ipaddress.AddressValueError` " -"and :exc:`ipaddress.NetmaskValueError` to indicate exactly which part of the " +"detail, the individual class constructors actually raise the :exc:" +"`ValueError` subclasses :exc:`ipaddress.AddressValueError` and :exc:" +"`ipaddress.NetmaskValueError` to indicate exactly which part of the " "definition failed to parse correctly." msgstr "" diff --git a/howto/isolating-extensions.po b/howto/isolating-extensions.po index bdaa2710231..2c5f99df61a 100644 --- a/howto/isolating-extensions.po +++ b/howto/isolating-extensions.po @@ -1,14 +1,13 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# 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.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-07-03 00:17+0000\n" +"POT-Creation-Date: 2025-12-01 00:17+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,7 +21,7 @@ msgstr "" msgid "Isolating Extension Modules" msgstr "隔離擴充模組" -#: ../../howto/isolating-extensions.rst:-1 +#: ../../howto/isolating-extensions.rst:9 msgid "Abstract" msgstr "摘要" @@ -527,8 +526,8 @@ msgstr "" #: ../../howto/isolating-extensions.rst:356 msgid "" -"Define a traverse function using ``Py_tp_traverse``, which visits the type " -"(e.g. using ``Py_VISIT(Py_TYPE(self))``)." +"Define a traverse function using :c:data:`Py_tp_traverse`, which visits the " +"type (e.g. using ``Py_VISIT(Py_TYPE(self))``)." msgstr "" #: ../../howto/isolating-extensions.rst:359 @@ -632,7 +631,7 @@ msgstr "" #: ../../howto/isolating-extensions.rst:418 msgid "Defining ``tp_dealloc``" -msgstr "" +msgstr "定義 ``tp_dealloc``" #: ../../howto/isolating-extensions.rst:420 msgid "" @@ -693,7 +692,7 @@ msgstr "" #: ../../howto/isolating-extensions.rst:452 msgid "Avoiding ``PyObject_New``" -msgstr "" +msgstr "避免使用 ``PyObject_New``" #: ../../howto/isolating-extensions.rst:454 msgid "GC-tracked objects need to be allocated using GC-aware functions." @@ -844,7 +843,7 @@ msgstr "" #: ../../howto/isolating-extensions.rst:538 msgid "For example::" -msgstr "" +msgstr "舉例來說: ::" #: ../../howto/isolating-extensions.rst:540 msgid "" diff --git a/howto/logging-cookbook.po b/howto/logging-cookbook.po index d4055b489d2..e0640a56fc3 100644 --- a/howto/logging-cookbook.po +++ b/howto/logging-cookbook.po @@ -1,13 +1,12 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-07-10 00:16+0000\n" +"POT-Creation-Date: 2025-09-08 15:25+0800\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-" @@ -68,8 +67,8 @@ msgid "" "ch = logging.StreamHandler()\n" "ch.setLevel(logging.ERROR)\n" "# create formatter and add it to the handlers\n" -"formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - " -"%(message)s')\n" +"formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %" +"(message)s')\n" "fh.setFormatter(formatter)\n" "ch.setFormatter(formatter)\n" "# add the handlers to the logger\n" @@ -100,8 +99,8 @@ msgid "" "\n" "class Auxiliary:\n" " def __init__(self):\n" -" self.logger = logging.getLogger('spam_application.auxiliary." -"Auxiliary')\n" +" self.logger = " +"logging.getLogger('spam_application.auxiliary.Auxiliary')\n" " self.logger.info('creating an instance of Auxiliary')\n" "\n" " def do_something(self):\n" @@ -163,8 +162,8 @@ msgid "" " time.sleep(0.5)\n" "\n" "def main():\n" -" logging.basicConfig(level=logging.DEBUG, format='%(relativeCreated)6d " -"%(threadName)s %(message)s')\n" +" logging.basicConfig(level=logging.DEBUG, format='%(relativeCreated)6d %" +"(threadName)s %(message)s')\n" " info = {'stop': False}\n" " thread = threading.Thread(target=worker, args=(info,))\n" " thread.start()\n" @@ -241,8 +240,8 @@ msgid "" "ch = logging.StreamHandler()\n" "ch.setLevel(logging.ERROR)\n" "# create formatter and add it to the handlers\n" -"formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - " -"%(message)s')\n" +"formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %" +"(message)s')\n" "ch.setFormatter(formatter)\n" "fh.setFormatter(formatter)\n" "# add the handlers to logger\n" @@ -295,8 +294,8 @@ msgid "" "\n" "# set up logging to file - see previous section for more details\n" "logging.basicConfig(level=logging.DEBUG,\n" -" format='%(asctime)s %(name)-12s %(levelname)-8s " -"%(message)s',\n" +" format='%(asctime)s %(name)-12s %(levelname)-8s %" +"(message)s',\n" " datefmt='%m-%d %H:%M',\n" " filename='/tmp/myapp.log',\n" " filemode='w')\n" @@ -497,6 +496,13 @@ msgid "" "\n" " return filter" msgstr "" +"def filter_maker(level):\n" +" level = getattr(logging, level)\n" +"\n" +" def filter(record):\n" +" return record.levelno <= level\n" +"\n" +" return filter" #: ../../howto/logging-cookbook.rst:379 msgid "" @@ -504,9 +510,9 @@ msgid "" "a function which only returns ``True`` if the level of the passed in record " "is at or below the specified level. Note that in this example I have defined " "the ``filter_maker`` in a test script ``main.py`` that I run from the " -"command line, so its module will be ``__main__`` - hence the ``__main__." -"filter_maker`` in the filter configuration. You will need to change that if " -"you define it in a different module." +"command line, so its module will be ``__main__`` - hence the " +"``__main__.filter_maker`` in the filter configuration. You will need to " +"change that if you define it in a different module." msgstr "" #: ../../howto/logging-cookbook.rst:387 @@ -713,13 +719,13 @@ msgstr "" #: ../../howto/logging-cookbook.rst:555 msgid "" -"A common culprit which demonstrates sluggish behaviour is the :class:" -"`SMTPHandler`: sending emails can take a long time, for a number of reasons " -"outside the developer's control (for example, a poorly performing mail or " -"network infrastructure). But almost any network-based handler can block: " -"Even a :class:`SocketHandler` operation may do a DNS query under the hood " -"which is too slow (and this query can be deep in the socket library code, " -"below the Python layer, and outside your control)." +"A common culprit which demonstrates sluggish behaviour is " +"the :class:`SMTPHandler`: sending emails can take a long time, for a number " +"of reasons outside the developer's control (for example, a poorly performing " +"mail or network infrastructure). But almost any network-based handler can " +"block: Even a :class:`SocketHandler` operation may do a DNS query under the " +"hood which is too slow (and this query can be deep in the socket library " +"code, below the Python layer, and outside your control)." msgstr "" #: ../../howto/logging-cookbook.rst:563 @@ -739,12 +745,12 @@ msgstr "" #: ../../howto/logging-cookbook.rst:574 msgid "" "The second part of the solution is :class:`QueueListener`, which has been " -"designed as the counterpart to :class:`QueueHandler`. A :class:" -"`QueueListener` is very simple: it's passed a queue and some handlers, and " -"it fires up an internal thread which listens to its queue for LogRecords " -"sent from ``QueueHandlers`` (or any other source of ``LogRecords``, for that " -"matter). The ``LogRecords`` are removed from the queue and passed to the " -"handlers for processing." +"designed as the counterpart to :class:`QueueHandler`. " +"A :class:`QueueListener` is very simple: it's passed a queue and some " +"handlers, and it fires up an internal thread which listens to its queue for " +"LogRecords sent from ``QueueHandlers`` (or any other source of " +"``LogRecords``, for that matter). The ``LogRecords`` are removed from the " +"queue and passed to the handlers for processing." msgstr "" #: ../../howto/logging-cookbook.rst:582 @@ -792,10 +798,10 @@ msgid "" "Although the earlier discussion wasn't specifically talking about async " "code, but rather about slow logging handlers, it should be noted that when " "logging from async code, network and even file handlers could lead to " -"problems (blocking the event loop) because some logging is done from :mod:" -"`asyncio` internals. It might be best, if any async code is used in an " -"application, to use the above approach for logging, so that any blocking " -"code runs only in the ``QueueListener`` thread." +"problems (blocking the event loop) because some logging is done " +"from :mod:`asyncio` internals. It might be best, if any async code is used " +"in an application, to use the above approach for logging, so that any " +"blocking code runs only in the ``QueueListener`` thread." msgstr "" #: ../../howto/logging-cookbook.rst:619 @@ -810,18 +816,34 @@ msgid "" "handler if it's appropriate to do so." msgstr "" -#: ../../howto/logging-cookbook.rst:632 +#: ../../howto/logging-cookbook.rst:629 +msgid "" +"The :class:`QueueListener` can be started (and stopped) via " +"the :keyword:`with` statement. For example:" +msgstr "" + +#: ../../howto/logging-cookbook.rst:633 +msgid "" +"with QueueListener(que, handler) as listener:\n" +" # The queue listener automatically starts\n" +" # when the 'with' block is entered.\n" +" pass\n" +"# The queue listener automatically stops once\n" +"# the 'with' block is exited." +msgstr "" + +#: ../../howto/logging-cookbook.rst:645 msgid "Sending and receiving logging events across a network" msgstr "" -#: ../../howto/logging-cookbook.rst:634 +#: ../../howto/logging-cookbook.rst:647 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::" +"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:638 +#: ../../howto/logging-cookbook.rst:651 msgid "" "import logging, logging.handlers\n" "\n" @@ -849,13 +871,13 @@ msgid "" "logger2.error('The five boxing wizards jump quickly.')" msgstr "" -#: ../../howto/logging-cookbook.rst:662 +#: ../../howto/logging-cookbook.rst:675 msgid "" -"At the receiving end, you can set up a receiver using the :mod:" -"`socketserver` module. Here is a basic working example::" +"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:665 +#: ../../howto/logging-cookbook.rst:678 msgid "" "import pickle\n" "import logging\n" @@ -936,8 +958,8 @@ msgid "" "\n" "def main():\n" " logging.basicConfig(\n" -" format='%(relativeCreated)5d %(name)-15s %(levelname)-8s " -"%(message)s')\n" +" format='%(relativeCreated)5d %(name)-15s %(levelname)-8s %" +"(message)s')\n" " tcpserver = LogRecordSocketReceiver()\n" " print('About to start TCP server...')\n" " tcpserver.serve_until_stopped()\n" @@ -946,13 +968,13 @@ msgid "" " main()" msgstr "" -#: ../../howto/logging-cookbook.rst:750 +#: ../../howto/logging-cookbook.rst:763 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:753 +#: ../../howto/logging-cookbook.rst:766 msgid "" "About to start TCP server...\n" " 59 root INFO Jackdaws love my big sphinx of quartz.\n" @@ -962,7 +984,7 @@ msgid "" " 69 myapp.area2 ERROR The five boxing wizards jump quickly." msgstr "" -#: ../../howto/logging-cookbook.rst:762 +#: ../../howto/logging-cookbook.rst:775 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 " @@ -971,11 +993,11 @@ msgid "" "alternative serialization." msgstr "" -#: ../../howto/logging-cookbook.rst:770 +#: ../../howto/logging-cookbook.rst:783 msgid "Running a logging socket listener in production" msgstr "" -#: ../../howto/logging-cookbook.rst:774 +#: ../../howto/logging-cookbook.rst:787 msgid "" "To run a logging listener in production, you may need to use a process-" "management tool such as `Supervisor `_. `Here is a " @@ -983,79 +1005,79 @@ msgid "" "the above functionality using Supervisor. It consists of the following files:" msgstr "" -#: ../../howto/logging-cookbook.rst:781 +#: ../../howto/logging-cookbook.rst:794 msgid "File" msgstr "檔案" -#: ../../howto/logging-cookbook.rst:781 +#: ../../howto/logging-cookbook.rst:794 msgid "Purpose" msgstr "目的" -#: ../../howto/logging-cookbook.rst:783 +#: ../../howto/logging-cookbook.rst:796 msgid ":file:`prepare.sh`" msgstr ":file:`prepare.sh`" -#: ../../howto/logging-cookbook.rst:783 +#: ../../howto/logging-cookbook.rst:796 msgid "A Bash script to prepare the environment for testing" msgstr "" -#: ../../howto/logging-cookbook.rst:786 +#: ../../howto/logging-cookbook.rst:799 msgid ":file:`supervisor.conf`" msgstr ":file:`supervisor.conf`" -#: ../../howto/logging-cookbook.rst:786 +#: ../../howto/logging-cookbook.rst:799 msgid "" "The Supervisor configuration file, which has entries for the listener and a " "multi-process web application" msgstr "" -#: ../../howto/logging-cookbook.rst:790 +#: ../../howto/logging-cookbook.rst:803 msgid ":file:`ensure_app.sh`" msgstr ":file:`ensure_app.sh`" -#: ../../howto/logging-cookbook.rst:790 +#: ../../howto/logging-cookbook.rst:803 msgid "" "A Bash script to ensure that Supervisor is running with the above " "configuration" msgstr "" -#: ../../howto/logging-cookbook.rst:793 +#: ../../howto/logging-cookbook.rst:806 msgid ":file:`log_listener.py`" msgstr ":file:`log_listener.py`" -#: ../../howto/logging-cookbook.rst:793 +#: ../../howto/logging-cookbook.rst:806 msgid "" "The socket listener program which receives log events and records them to a " "file" msgstr "" -#: ../../howto/logging-cookbook.rst:796 +#: ../../howto/logging-cookbook.rst:809 msgid ":file:`main.py`" msgstr ":file:`main.py`" -#: ../../howto/logging-cookbook.rst:796 +#: ../../howto/logging-cookbook.rst:809 msgid "" "A simple web application which performs logging via a socket connected to " "the listener" msgstr "" -#: ../../howto/logging-cookbook.rst:799 +#: ../../howto/logging-cookbook.rst:812 msgid ":file:`webapp.json`" msgstr ":file:`webapp.json`" -#: ../../howto/logging-cookbook.rst:799 +#: ../../howto/logging-cookbook.rst:812 msgid "A JSON configuration file for the web application" msgstr "" -#: ../../howto/logging-cookbook.rst:801 +#: ../../howto/logging-cookbook.rst:814 msgid ":file:`client.py`" msgstr ":file:`client.py`" -#: ../../howto/logging-cookbook.rst:801 +#: ../../howto/logging-cookbook.rst:814 msgid "A Python script to exercise the web application" msgstr "" -#: ../../howto/logging-cookbook.rst:804 +#: ../../howto/logging-cookbook.rst:817 msgid "" "The web application uses `Gunicorn `_, which is a " "popular web application server that starts multiple worker processes to " @@ -1064,21 +1086,21 @@ msgid "" "the socket listener." msgstr "" -#: ../../howto/logging-cookbook.rst:809 +#: ../../howto/logging-cookbook.rst:822 msgid "To test these files, do the following in a POSIX environment:" msgstr "" -#: ../../howto/logging-cookbook.rst:811 +#: ../../howto/logging-cookbook.rst:824 msgid "" -"Download `the Gist `__ as a ZIP archive using the :" -"guilabel:`Download ZIP` button." +"Download `the Gist `__ as a ZIP archive using " +"the :guilabel:`Download ZIP` button." msgstr "" -#: ../../howto/logging-cookbook.rst:814 +#: ../../howto/logging-cookbook.rst:827 msgid "Unzip the above files from the archive into a scratch directory." msgstr "" -#: ../../howto/logging-cookbook.rst:816 +#: ../../howto/logging-cookbook.rst:829 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 " @@ -1086,19 +1108,19 @@ msgid "" "which ``bottle``, ``gunicorn`` and ``supervisor`` are installed." msgstr "" -#: ../../howto/logging-cookbook.rst:821 +#: ../../howto/logging-cookbook.rst:834 msgid "" "Run ``bash ensure_app.sh`` to ensure that Supervisor is running with the " "above configuration." msgstr "" -#: ../../howto/logging-cookbook.rst:824 +#: ../../howto/logging-cookbook.rst:837 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:827 +#: ../../howto/logging-cookbook.rst:840 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 " @@ -1106,25 +1128,25 @@ msgid "" "by different worker processes in a non-deterministic way." msgstr "" -#: ../../howto/logging-cookbook.rst:832 +#: ../../howto/logging-cookbook.rst:845 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:835 +#: ../../howto/logging-cookbook.rst:848 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:838 +#: ../../howto/logging-cookbook.rst:851 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:841 +#: ../../howto/logging-cookbook.rst:854 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 " @@ -1132,18 +1154,18 @@ msgid "" "ignored)." msgstr "" -#: ../../howto/logging-cookbook.rst:846 +#: ../../howto/logging-cookbook.rst:859 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:856 +#: ../../howto/logging-cookbook.rst:869 msgid "Adding contextual information to your logging output" msgstr "" -#: ../../howto/logging-cookbook.rst:858 +#: ../../howto/logging-cookbook.rst:871 msgid "" "Sometimes you want logging output to contain contextual information in " "addition to the parameters passed to the logging call. For example, in a " @@ -1155,37 +1177,37 @@ msgid "" "is not a good idea because these instances are not garbage collected. While " "this is not a problem in practice, when the number of :class:`Logger` " "instances is dependent on the level of granularity you want to use in " -"logging an application, it could be hard to manage if the number of :class:" -"`Logger` instances becomes effectively unbounded." +"logging an application, it could be hard to manage if the number " +"of :class:`Logger` instances becomes effectively unbounded." msgstr "" -#: ../../howto/logging-cookbook.rst:873 +#: ../../howto/logging-cookbook.rst:886 msgid "Using LoggerAdapters to impart contextual information" msgstr "" -#: ../../howto/logging-cookbook.rst:875 +#: ../../howto/logging-cookbook.rst:888 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. " -"This class is designed to look like a :class:`Logger`, so that you can call :" -"meth:`debug`, :meth:`info`, :meth:`warning`, :meth:`error`, :meth:" -"`exception`, :meth:`critical` and :meth:`log`. These methods have the same " -"signatures as their counterparts in :class:`Logger`, so you can use the two " -"types of instances interchangeably." +"This class is designed to look like a :class:`Logger`, so that you can " +"call :meth:`debug`, :meth:`info`, :meth:`warning`, :meth:`error`, :meth:`exception`, :meth:`critical` " +"and :meth:`log`. These methods have the same signatures as their " +"counterparts in :class:`Logger`, so you can use the two types of instances " +"interchangeably." msgstr "" -#: ../../howto/logging-cookbook.rst:883 +#: ../../howto/logging-cookbook.rst:896 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 " -"information. When you call one of the logging methods on an instance of :" -"class:`LoggerAdapter`, it delegates the call to the underlying instance of :" -"class:`Logger` passed to its constructor, and arranges to pass the " -"contextual information in the delegated call. Here's a snippet from the code " -"of :class:`LoggerAdapter`::" +"When you create an instance of :class:`LoggerAdapter`, you pass it " +"a :class:`Logger` instance and a dict-like object which contains your " +"contextual information. When you call one of the logging methods on an " +"instance of :class:`LoggerAdapter`, it delegates the call to the underlying " +"instance of :class:`Logger` passed to its constructor, and arranges to pass " +"the contextual information in the delegated call. Here's a snippet from the " +"code of :class:`LoggerAdapter`::" msgstr "" -#: ../../howto/logging-cookbook.rst:891 +#: ../../howto/logging-cookbook.rst:904 msgid "" "def debug(self, msg, /, *args, **kwargs):\n" " \"\"\"\n" @@ -1196,7 +1218,7 @@ msgid "" " self.logger.debug(msg, *args, **kwargs)" msgstr "" -#: ../../howto/logging-cookbook.rst:899 +#: ../../howto/logging-cookbook.rst:912 msgid "" "The :meth:`~LoggerAdapter.process` method of :class:`LoggerAdapter` is where " "the contextual information is added to the logging output. It's passed the " @@ -1209,18 +1231,19 @@ msgid "" "be silently overwritten." msgstr "" -#: ../../howto/logging-cookbook.rst:908 +#: ../../howto/logging-cookbook.rst:921 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 " "use customized strings with your :class:`Formatter` instances which know " "about the keys of the dict-like object. If you need a different method, e.g. " "if you want to prepend or append the contextual information to the message " -"string, you just need to subclass :class:`LoggerAdapter` and override :meth:" -"`~LoggerAdapter.process` to do what you need. Here is a simple example::" +"string, you just need to subclass :class:`LoggerAdapter` and " +"override :meth:`~LoggerAdapter.process` to do what you need. Here is a " +"simple example::" msgstr "" -#: ../../howto/logging-cookbook.rst:916 +#: ../../howto/logging-cookbook.rst:929 msgid "" "class CustomAdapter(logging.LoggerAdapter):\n" " \"\"\"\n" @@ -1231,27 +1254,27 @@ msgid "" " return '[%s] %s' % (self.extra['connid'], msg), kwargs" msgstr "" -#: ../../howto/logging-cookbook.rst:924 +#: ../../howto/logging-cookbook.rst:937 msgid "which you can use like this::" msgstr "" -#: ../../howto/logging-cookbook.rst:926 +#: ../../howto/logging-cookbook.rst:939 msgid "" "logger = logging.getLogger(__name__)\n" "adapter = CustomAdapter(logger, {'connid': some_conn_id})" msgstr "" -#: ../../howto/logging-cookbook.rst:929 +#: ../../howto/logging-cookbook.rst:942 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:933 +#: ../../howto/logging-cookbook.rst:946 msgid "Using objects other than dicts to pass contextual information" msgstr "" -#: ../../howto/logging-cookbook.rst:935 +#: ../../howto/logging-cookbook.rst:948 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 " @@ -1260,32 +1283,32 @@ msgid "" "would be constant)." msgstr "" -#: ../../howto/logging-cookbook.rst:944 +#: ../../howto/logging-cookbook.rst:957 msgid "Using Filters to impart contextual information" msgstr "" -#: ../../howto/logging-cookbook.rst:946 +#: ../../howto/logging-cookbook.rst:959 msgid "" -"You can also add contextual information to log output using a user-defined :" -"class:`Filter`. ``Filter`` instances are allowed to modify the " +"You can also add contextual information to log output using a user-" +"defined :class:`Filter`. ``Filter`` instances are allowed to modify the " "``LogRecords`` passed to them, including adding additional attributes which " -"can then be output using a suitable format string, or if needed a custom :" -"class:`Formatter`." +"can then be output using a suitable format string, or if needed a " +"custom :class:`Formatter`." msgstr "" -#: ../../howto/logging-cookbook.rst:951 +#: ../../howto/logging-cookbook.rst:964 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:" -"`threading.local`) variable, and then accessed from a ``Filter`` to add, " -"say, information from the request - say, the remote IP address and remote " -"user's username - to the ``LogRecord``, using the attribute names 'ip' and " -"'user' as in the ``LoggerAdapter`` example above. In that case, the same " -"format string can be used to get similar output to that shown above. Here's " -"an example script::" +"the interesting parts of it) can be stored in a threadlocal " +"(:class:`threading.local`) variable, and then accessed from a ``Filter`` to " +"add, say, information from the request - say, the remote IP address and " +"remote user's username - to the ``LogRecord``, using the attribute names " +"'ip' and 'user' as in the ``LoggerAdapter`` example above. In that case, the " +"same format string can be used to get similar output to that shown above. " +"Here's an example script::" msgstr "" -#: ../../howto/logging-cookbook.rst:960 +#: ../../howto/logging-cookbook.rst:973 msgid "" "import logging\n" "from random import choice\n" @@ -1328,11 +1351,11 @@ msgid "" "'parameters')" msgstr "" -#: ../../howto/logging-cookbook.rst:997 +#: ../../howto/logging-cookbook.rst:1010 msgid "which, when run, produces something like:" msgstr "" -#: ../../howto/logging-cookbook.rst:999 +#: ../../howto/logging-cookbook.rst:1012 msgid "" "2010-09-06 22:38:15,292 a.b.c DEBUG IP: 123.231.231.123 User: fred A " "debug message\n" @@ -1360,11 +1383,11 @@ msgid "" "message at INFO level with 2 parameters" msgstr "" -#: ../../howto/logging-cookbook.rst:1015 +#: ../../howto/logging-cookbook.rst:1028 msgid "Use of ``contextvars``" msgstr "" -#: ../../howto/logging-cookbook.rst:1017 +#: ../../howto/logging-cookbook.rst:1030 msgid "" "Since Python 3.7, the :mod:`contextvars` module has provided context-local " "storage which works for both :mod:`threading` and :mod:`asyncio` processing " @@ -1374,7 +1397,7 @@ msgid "" "attributes handled by web applications." msgstr "" -#: ../../howto/logging-cookbook.rst:1023 +#: ../../howto/logging-cookbook.rst:1036 msgid "" "For the purposes of illustration, say that you have different web " "applications, each independent of the other but running in the same Python " @@ -1385,11 +1408,11 @@ msgid "" "information such as client IP, HTTP request method and client username?" msgstr "" -#: ../../howto/logging-cookbook.rst:1030 +#: ../../howto/logging-cookbook.rst:1043 msgid "Let's assume that the library can be simulated by the following code:" msgstr "" -#: ../../howto/logging-cookbook.rst:1032 +#: ../../howto/logging-cookbook.rst:1045 msgid "" "# webapplib.py\n" "import logging\n" @@ -1404,14 +1427,14 @@ msgid "" " time.sleep(0.01)" msgstr "" -#: ../../howto/logging-cookbook.rst:1046 +#: ../../howto/logging-cookbook.rst:1059 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:1050 +#: ../../howto/logging-cookbook.rst:1063 msgid "" "# main.py\n" "import argparse\n" @@ -1439,8 +1462,8 @@ msgid "" "\n" "# A dummy set of requests which will be used in the simulation - we'll just " "pick\n" -"# from this list randomly. Note that all GET requests are from 192.168.2." -"XXX\n" +"# from this list randomly. Note that all GET requests are from " +"192.168.2.XXX\n" "# addresses, whereas POST requests are from 192.16.3.XXX addresses. Three " "users\n" "# are represented in the sample requests.\n" @@ -1458,8 +1481,8 @@ msgid "" "information\n" "# such as HTTP method, client IP and username\n" "\n" -"formatter = logging.Formatter('%(threadName)-11s %(appName)s %(name)-9s " -"%(user)-6s %(ip)s %(method)-4s %(message)s')\n" +"formatter = logging.Formatter('%(threadName)-11s %(appName)s %(name)-9s %" +"(user)-6s %(ip)s %(method)-4s %(message)s')\n" "\n" "# Create our context variables. These will be filled at the start of " "request\n" @@ -1566,7 +1589,7 @@ msgid "" " main()" msgstr "" -#: ../../howto/logging-cookbook.rst:1190 +#: ../../howto/logging-cookbook.rst:1203 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 " @@ -1577,7 +1600,7 @@ msgid "" "illustrated by the following shell output:" msgstr "" -#: ../../howto/logging-cookbook.rst:1197 +#: ../../howto/logging-cookbook.rst:1210 msgid "" "~/logging-contextual-webapp$ python main.py\n" "app1 processed 51 requests\n" @@ -1632,11 +1655,11 @@ msgid "" "147" msgstr "" -#: ../../howto/logging-cookbook.rst:1237 +#: ../../howto/logging-cookbook.rst:1250 msgid "Imparting contextual information in handlers" msgstr "" -#: ../../howto/logging-cookbook.rst:1239 +#: ../../howto/logging-cookbook.rst:1252 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 " @@ -1644,7 +1667,7 @@ msgid "" "instead of modifying it in-place, as shown in the following script::" msgstr "" -#: ../../howto/logging-cookbook.rst:1244 +#: ../../howto/logging-cookbook.rst:1257 msgid "" "import copy\n" "import logging\n" @@ -1684,11 +1707,11 @@ msgstr "" "\n" " logger.info('A log message')" -#: ../../howto/logging-cookbook.rst:1266 +#: ../../howto/logging-cookbook.rst:1279 msgid "Logging to a single file from multiple processes" msgstr "" -#: ../../howto/logging-cookbook.rst:1268 +#: ../../howto/logging-cookbook.rst:1281 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 " @@ -1698,21 +1721,22 @@ msgid "" "this is to have all the processes log to a :class:`~handlers.SocketHandler`, " "and have a separate process which implements a socket server which reads " "from the socket and logs to file. (If you prefer, you can dedicate one " -"thread in one of the existing processes to perform this function.) :ref:" -"`This section ` documents this approach in more detail and " -"includes a working socket receiver which can be used as a starting point for " -"you to adapt in your own applications." +"thread in one of the existing processes to perform this " +"function.) :ref:`This section ` documents this approach in " +"more detail and includes a working socket receiver which can be used as a " +"starting point for you to adapt in your own applications." msgstr "" -#: ../../howto/logging-cookbook.rst:1281 +#: ../../howto/logging-cookbook.rst:1294 msgid "" -"You could also write your own handler which uses the :class:" -"`~multiprocessing.Lock` class from the :mod:`multiprocessing` module to " -"serialize access to the file from your processes. The stdlib :class:" -"`FileHandler` and subclasses do not make use of :mod:`multiprocessing`." +"You could also write your own handler which uses " +"the :class:`~multiprocessing.Lock` class from the :mod:`multiprocessing` " +"module to serialize access to the file from your processes. The " +"stdlib :class:`FileHandler` and subclasses do not make use " +"of :mod:`multiprocessing`." msgstr "" -#: ../../howto/logging-cookbook.rst:1288 +#: ../../howto/logging-cookbook.rst:1301 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 " @@ -1727,7 +1751,7 @@ msgid "" "requirements::" msgstr "" -#: ../../howto/logging-cookbook.rst:1299 +#: ../../howto/logging-cookbook.rst:1312 msgid "" "# You'll need these imports in your own code\n" "import logging\n" @@ -1760,8 +1784,8 @@ msgid "" "def listener_configurer():\n" " root = logging.getLogger()\n" " h = logging.handlers.RotatingFileHandler('mptest.log', 'a', 300, 10)\n" -" f = logging.Formatter('%(asctime)s %(processName)-10s %(name)s " -"%(levelname)-8s %(message)s')\n" +" f = logging.Formatter('%(asctime)s %(processName)-10s %(name)s %" +"(levelname)-8s %(message)s')\n" " h.setFormatter(f)\n" " root.addHandler(h)\n" "\n" @@ -1847,13 +1871,13 @@ msgid "" " main()" msgstr "" -#: ../../howto/logging-cookbook.rst:1404 +#: ../../howto/logging-cookbook.rst:1417 msgid "" "A variant of the above script keeps the logging in the main process, in a " "separate thread::" msgstr "" -#: ../../howto/logging-cookbook.rst:1407 +#: ../../howto/logging-cookbook.rst:1420 msgid "" "import logging\n" "import logging.config\n" @@ -1893,8 +1917,8 @@ msgid "" " 'formatters': {\n" " 'detailed': {\n" " 'class': 'logging.Formatter',\n" -" 'format': '%(asctime)s %(name)-15s %(levelname)-8s " -"%(processName)-10s %(message)s'\n" +" 'format': '%(asctime)s %(name)-15s %(levelname)-8s %" +"(processName)-10s %(message)s'\n" " }\n" " },\n" " 'handlers': {\n" @@ -1950,7 +1974,7 @@ msgid "" " lp.join()" msgstr "" -#: ../../howto/logging-cookbook.rst:1499 +#: ../../howto/logging-cookbook.rst:1512 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 " @@ -1960,36 +1984,36 @@ msgid "" "appropriate destinations." msgstr "" -#: ../../howto/logging-cookbook.rst:1506 +#: ../../howto/logging-cookbook.rst:1519 msgid "Using concurrent.futures.ProcessPoolExecutor" msgstr "使用 concurrent.futures.ProcessPoolExecutor" -#: ../../howto/logging-cookbook.rst:1508 +#: ../../howto/logging-cookbook.rst:1521 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:1512 +#: ../../howto/logging-cookbook.rst:1525 msgid "queue = multiprocessing.Queue(-1)" msgstr "queue = multiprocessing.Queue(-1)" -#: ../../howto/logging-cookbook.rst:1516 +#: ../../howto/logging-cookbook.rst:1529 msgid "you should use" msgstr "" -#: ../../howto/logging-cookbook.rst:1518 +#: ../../howto/logging-cookbook.rst:1531 msgid "" "queue = multiprocessing.Manager().Queue(-1) # also works with the examples " "above" msgstr "" -#: ../../howto/logging-cookbook.rst:1522 +#: ../../howto/logging-cookbook.rst:1535 msgid "and you can then replace the worker creation from this::" msgstr "" -#: ../../howto/logging-cookbook.rst:1524 +#: ../../howto/logging-cookbook.rst:1537 msgid "" "workers = []\n" "for i in range(10):\n" @@ -2001,22 +2025,22 @@ msgid "" " w.join()" msgstr "" -#: ../../howto/logging-cookbook.rst:1533 +#: ../../howto/logging-cookbook.rst:1546 msgid "to this (remembering to first import :mod:`concurrent.futures`)::" msgstr "" -#: ../../howto/logging-cookbook.rst:1535 +#: ../../howto/logging-cookbook.rst:1548 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:1540 +#: ../../howto/logging-cookbook.rst:1553 msgid "Deploying Web applications using Gunicorn and uWSGI" msgstr "" -#: ../../howto/logging-cookbook.rst:1542 +#: ../../howto/logging-cookbook.rst:1555 msgid "" "When deploying Web applications using `Gunicorn `_ or " "`uWSGI `_ (or similar), " @@ -2028,11 +2052,11 @@ msgid "" "listener in production`_ for more details." msgstr "" -#: ../../howto/logging-cookbook.rst:1552 +#: ../../howto/logging-cookbook.rst:1565 msgid "Using file rotation" msgstr "" -#: ../../howto/logging-cookbook.rst:1557 +#: ../../howto/logging-cookbook.rst:1570 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, " @@ -2041,7 +2065,7 @@ msgid "" "usage pattern, the logging package provides a :class:`RotatingFileHandler`::" msgstr "" -#: ../../howto/logging-cookbook.rst:1563 +#: ../../howto/logging-cookbook.rst:1576 msgid "" "import glob\n" "import logging\n" @@ -2070,13 +2094,13 @@ msgid "" " print(filename)" msgstr "" -#: ../../howto/logging-cookbook.rst:1589 +#: ../../howto/logging-cookbook.rst:1602 msgid "" "The result should be 6 separate files, each with part of the log history for " "the application:" msgstr "" -#: ../../howto/logging-cookbook.rst:1592 +#: ../../howto/logging-cookbook.rst:1605 msgid "" "logging_rotatingfile_example.out\n" "logging_rotatingfile_example.out.1\n" @@ -2086,7 +2110,7 @@ msgid "" "logging_rotatingfile_example.out.5" msgstr "" -#: ../../howto/logging-cookbook.rst:1601 +#: ../../howto/logging-cookbook.rst:1614 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 " @@ -2094,26 +2118,26 @@ msgid "" "(``.1`` becomes ``.2``, etc.) and the ``.6`` file is erased." msgstr "" -#: ../../howto/logging-cookbook.rst:1606 +#: ../../howto/logging-cookbook.rst:1619 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:1614 +#: ../../howto/logging-cookbook.rst:1627 msgid "Use of alternative formatting styles" msgstr "" -#: ../../howto/logging-cookbook.rst:1616 +#: ../../howto/logging-cookbook.rst:1629 msgid "" "When logging was added to the Python standard library, the only way of " "formatting messages with variable content was to use the %-formatting " -"method. Since then, Python has gained two new formatting approaches: :class:" -"`string.Template` (added in Python 2.4) and :meth:`str.format` (added in " -"Python 2.6)." +"method. Since then, Python has gained two new formatting " +"approaches: :class:`string.Template` (added in Python 2.4) " +"and :meth:`str.format` (added in Python 2.6)." msgstr "" -#: ../../howto/logging-cookbook.rst:1622 +#: ../../howto/logging-cookbook.rst:1635 msgid "" "Logging (as of 3.2) provides improved support for these two additional " "formatting styles. The :class:`Formatter` class been enhanced to take an " @@ -2121,12 +2145,12 @@ msgid "" "``'%'``, but other possible values are ``'{'`` and ``'$'``, which correspond " "to the other two formatting styles. Backwards compatibility is maintained by " "default (as you would expect), but by explicitly specifying a style " -"parameter, you get the ability to specify format strings which work with :" -"meth:`str.format` or :class:`string.Template`. Here's an example console " -"session to show the possibilities:" +"parameter, you get the ability to specify format strings which work " +"with :meth:`str.format` or :class:`string.Template`. Here's an example " +"console session to show the possibilities:" msgstr "" -#: ../../howto/logging-cookbook.rst:1632 +#: ../../howto/logging-cookbook.rst:1645 msgid "" ">>> import logging\n" ">>> root = logging.getLogger()\n" @@ -2150,22 +2174,46 @@ msgid "" "2010-10-28 15:13:11,494 foo.bar CRITICAL This is a CRITICAL message\n" ">>>" msgstr "" +">>> import logging\n" +">>> root = logging.getLogger()\n" +">>> root.setLevel(logging.DEBUG)\n" +">>> handler = logging.StreamHandler()\n" +">>> bf = logging.Formatter('{asctime} {name} {levelname:8s} {message}',\n" +"... style='{')\n" +">>> handler.setFormatter(bf)\n" +">>> root.addHandler(handler)\n" +">>> logger = logging.getLogger('foo.bar')\n" +">>> logger.debug('This is a DEBUG message')\n" +"2010-10-28 15:11:55,341 foo.bar DEBUG This is a DEBUG message\n" +">>> logger.critical('This is a CRITICAL message')\n" +"2010-10-28 15:12:11,526 foo.bar CRITICAL This is a CRITICAL message\n" +">>> df = logging.Formatter('$asctime $name ${levelname} $message',\n" +"... style='$')\n" +">>> handler.setFormatter(df)\n" +">>> logger.debug('This is a DEBUG message')\n" +"2010-10-28 15:13:06,924 foo.bar DEBUG This is a DEBUG message\n" +">>> logger.critical('This is a CRITICAL message')\n" +"2010-10-28 15:13:11,494 foo.bar CRITICAL This is a CRITICAL message\n" +">>>" -#: ../../howto/logging-cookbook.rst:1656 +#: ../../howto/logging-cookbook.rst:1669 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:1660 +#: ../../howto/logging-cookbook.rst:1673 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" ">>>" msgstr "" +">>> 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" +">>>" -#: ../../howto/logging-cookbook.rst:1664 +#: ../../howto/logging-cookbook.rst:1677 msgid "" "Logging calls (``logger.debug()``, ``logger.info()`` etc.) only take " "positional parameters for the actual logging message itself, with keyword " @@ -2173,15 +2221,15 @@ msgid "" "logging call (e.g. the ``exc_info`` keyword parameter to indicate that " "traceback information should be logged, or the ``extra`` keyword parameter " "to indicate additional contextual information to be added to the log). So " -"you cannot directly make logging calls using :meth:`str.format` or :class:" -"`string.Template` syntax, because internally the logging package uses %-" -"formatting to merge the format string and the variable arguments. There " -"would be no changing this while preserving backward compatibility, since all " -"logging calls which are out there in existing code will be using %-format " -"strings." +"you cannot directly make logging calls using :meth:`str.format` " +"or :class:`string.Template` syntax, because internally the logging package " +"uses %-formatting to merge the format string and the variable arguments. " +"There would be no changing this while preserving backward compatibility, " +"since all logging calls which are out there in existing code will be using %-" +"format strings." msgstr "" -#: ../../howto/logging-cookbook.rst:1677 +#: ../../howto/logging-cookbook.rst:1690 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 " @@ -2190,7 +2238,7 @@ msgid "" "the following two classes::" msgstr "" -#: ../../howto/logging-cookbook.rst:1683 ../../howto/logging-cookbook.rst:2771 +#: ../../howto/logging-cookbook.rst:1696 ../../howto/logging-cookbook.rst:2784 msgid "" "class BraceMessage:\n" " def __init__(self, fmt, /, *args, **kwargs):\n" @@ -2228,7 +2276,7 @@ msgstr "" " from string import Template\n" " return Template(self.fmt).substitute(**self.kwargs)" -#: ../../howto/logging-cookbook.rst:1701 +#: ../../howto/logging-cookbook.rst:1714 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 " @@ -2239,14 +2287,14 @@ msgid "" "used as a synonym/alias for :func:`gettext.gettext` or its brethren)." msgstr "" -#: ../../howto/logging-cookbook.rst:1709 +#: ../../howto/logging-cookbook.rst:1722 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:1713 +#: ../../howto/logging-cookbook.rst:1726 msgid "" ">>> from wherever import BraceMessage as __\n" ">>> print(__('Message with {0} {name}', 2, name='placeholders'))\n" @@ -2264,15 +2312,30 @@ msgid "" "Message with 2 placeholders\n" ">>>" msgstr "" +">>> from wherever import BraceMessage as __\n" +">>> print(__('Message with {0} {name}', 2, name='placeholders'))\n" +"Message with 2 placeholders\n" +">>> class Point: pass\n" +"...\n" +">>> p = Point()\n" +">>> p.x = 0.5\n" +">>> p.y = 0.5\n" +">>> print(__('Message with coordinates: ({point.x:.2f}, {point.y:.2f})',\n" +"... point=p))\n" +"Message with coordinates: (0.50, 0.50)\n" +">>> from wherever import DollarMessage as __\n" +">>> print(__('Message with $num $what', num=2, what='placeholders'))\n" +"Message with 2 placeholders\n" +">>>" -#: ../../howto/logging-cookbook.rst:1731 +#: ../../howto/logging-cookbook.rst:1744 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:1735 +#: ../../howto/logging-cookbook.rst:1748 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 " @@ -2283,13 +2346,13 @@ msgid "" "sugar for a constructor call to one of the :samp:`{XXX}Message` classes." msgstr "" -#: ../../howto/logging-cookbook.rst:1743 +#: ../../howto/logging-cookbook.rst:1756 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:1746 +#: ../../howto/logging-cookbook.rst:1759 msgid "" "import logging\n" "\n" @@ -2318,63 +2381,64 @@ msgid "" " main()" msgstr "" -#: ../../howto/logging-cookbook.rst:1772 +#: ../../howto/logging-cookbook.rst:1785 msgid "" "The above script should log the message ``Hello, world!`` when run with " "Python 3.8 or later." msgstr "" -#: ../../howto/logging-cookbook.rst:1781 +#: ../../howto/logging-cookbook.rst:1794 msgid "Customizing ``LogRecord``" msgstr "" -#: ../../howto/logging-cookbook.rst:1783 +#: ../../howto/logging-cookbook.rst:1796 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:" -"`LogRecord` is created, populated with information about the event and then " -"passed to the handlers for that logger (and its ancestors, up to and " -"including the logger where further propagation up the hierarchy is " +"event is logged and not filtered out by a logger's level, " +"a :class:`LogRecord` is created, populated with information about the event " +"and then passed to the handlers for that logger (and its ancestors, up to " +"and including the logger where further propagation up the hierarchy is " "disabled). Before Python 3.2, there were only two places where this creation " "was done:" msgstr "" -#: ../../howto/logging-cookbook.rst:1790 +#: ../../howto/logging-cookbook.rst:1803 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:1793 +#: ../../howto/logging-cookbook.rst:1806 msgid "" ":func:`makeLogRecord`, which is called with a dictionary containing " "attributes to be added to the LogRecord. This is typically invoked when a " "suitable dictionary has been received over the network (e.g. in pickle form " -"via a :class:`~handlers.SocketHandler`, or in JSON form via an :class:" -"`~handlers.HTTPHandler`)." +"via a :class:`~handlers.SocketHandler`, or in JSON form via " +"an :class:`~handlers.HTTPHandler`)." msgstr "" -#: ../../howto/logging-cookbook.rst:1799 +#: ../../howto/logging-cookbook.rst:1812 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." +"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:1802 +#: ../../howto/logging-cookbook.rst:1815 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." +"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:1805 +#: ../../howto/logging-cookbook.rst:1818 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:1809 +#: ../../howto/logging-cookbook.rst:1822 msgid "" "The first approach would be a little unwieldy in the scenario where (say) " "several different libraries wanted to do different things. Each would " @@ -2382,7 +2446,7 @@ msgid "" "last would win." msgstr "" -#: ../../howto/logging-cookbook.rst:1814 +#: ../../howto/logging-cookbook.rst:1827 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 " @@ -2391,11 +2455,11 @@ msgid "" "would do simply by adding new packages or modules and doing ::" msgstr "" -#: ../../howto/logging-cookbook.rst:1820 +#: ../../howto/logging-cookbook.rst:1833 msgid "logger = logging.getLogger(__name__)" msgstr "logger = logging.getLogger(__name__)" -#: ../../howto/logging-cookbook.rst:1822 +#: ../../howto/logging-cookbook.rst:1835 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` " @@ -2405,17 +2469,17 @@ msgid "" "developer." msgstr "" -#: ../../howto/logging-cookbook.rst:1828 +#: ../../howto/logging-cookbook.rst:1841 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 " -"can set with :func:`~logging.setLogRecordFactory`, and interrogate with :" -"func:`~logging.getLogRecordFactory`. The factory is invoked with the same " -"signature as the :class:`~logging.LogRecord` constructor, as :class:" -"`LogRecord` is the default setting for the factory." +"can set with :func:`~logging.setLogRecordFactory`, and interrogate " +"with :func:`~logging.getLogRecordFactory`. The factory is invoked with the " +"same signature as the :class:`~logging.LogRecord` constructor, " +"as :class:`LogRecord` is the default setting for the factory." msgstr "" -#: ../../howto/logging-cookbook.rst:1835 +#: ../../howto/logging-cookbook.rst:1848 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 " @@ -2423,7 +2487,7 @@ msgid "" "this::" msgstr "" -#: ../../howto/logging-cookbook.rst:1839 +#: ../../howto/logging-cookbook.rst:1852 msgid "" "old_factory = logging.getLogRecordFactory()\n" "\n" @@ -2435,7 +2499,7 @@ msgid "" "logging.setLogRecordFactory(record_factory)" msgstr "" -#: ../../howto/logging-cookbook.rst:1848 +#: ../../howto/logging-cookbook.rst:1861 msgid "" "This pattern allows different libraries to chain factories together, and as " "long as they don't overwrite each other's attributes or unintentionally " @@ -2445,22 +2509,22 @@ msgid "" "used when the use of a :class:`Filter` does not provide the desired result." msgstr "" -#: ../../howto/logging-cookbook.rst:1860 +#: ../../howto/logging-cookbook.rst:1873 msgid "Subclassing QueueHandler and QueueListener- a ZeroMQ example" msgstr "" -#: ../../howto/logging-cookbook.rst:1863 ../../howto/logging-cookbook.rst:1996 +#: ../../howto/logging-cookbook.rst:1876 ../../howto/logging-cookbook.rst:2009 msgid "Subclass ``QueueHandler``" msgstr "" -#: ../../howto/logging-cookbook.rst:1865 +#: ../../howto/logging-cookbook.rst:1878 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:1869 +#: ../../howto/logging-cookbook.rst:1882 msgid "" "import zmq # using pyzmq, the Python binding for ZeroMQ\n" "import json # for serializing records portably\n" @@ -2477,13 +2541,13 @@ msgid "" "handler = ZeroMQSocketHandler(sock)" msgstr "" -#: ../../howto/logging-cookbook.rst:1884 +#: ../../howto/logging-cookbook.rst:1897 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:1887 +#: ../../howto/logging-cookbook.rst:1900 msgid "" "class ZeroMQSocketHandler(QueueHandler):\n" " def __init__(self, uri, socktype=zmq.PUB, ctx=None):\n" @@ -2499,17 +2563,17 @@ msgid "" " self.queue.close()" msgstr "" -#: ../../howto/logging-cookbook.rst:1902 ../../howto/logging-cookbook.rst:1932 +#: ../../howto/logging-cookbook.rst:1915 ../../howto/logging-cookbook.rst:1945 msgid "Subclass ``QueueListener``" msgstr "" -#: ../../howto/logging-cookbook.rst:1904 +#: ../../howto/logging-cookbook.rst:1917 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:1907 +#: ../../howto/logging-cookbook.rst:1920 msgid "" "class ZeroMQSocketListener(QueueListener):\n" " def __init__(self, uri, /, *handlers, **kwargs):\n" @@ -2525,20 +2589,20 @@ msgid "" " return logging.makeLogRecord(msg)" msgstr "" -#: ../../howto/logging-cookbook.rst:1922 +#: ../../howto/logging-cookbook.rst:1935 msgid "Subclassing QueueHandler and QueueListener- a ``pynng`` example" msgstr "" -#: ../../howto/logging-cookbook.rst:1924 +#: ../../howto/logging-cookbook.rst:1937 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 `_, billed as a spiritual successor to ZeroMQ. The following " -"snippets illustrate -- you can test them in an environment which has " -"``pynng`` installed. Just for variety, we present the listener first." +"handler using :pypi:`pynng`, which is a Python binding to `NNG `_, billed as a spiritual successor to ZeroMQ. The " +"following snippets illustrate -- you can test them in an environment which " +"has ``pynng`` installed. Just for variety, we present the listener first." msgstr "" -#: ../../howto/logging-cookbook.rst:1934 +#: ../../howto/logging-cookbook.rst:1947 msgid "" "# listener.py\n" "import json\n" @@ -2600,7 +2664,7 @@ msgid "" " listener.stop()" msgstr "" -#: ../../howto/logging-cookbook.rst:2000 +#: ../../howto/logging-cookbook.rst:2013 msgid "" "# sender.py\n" "import json\n" @@ -2633,8 +2697,8 @@ msgid "" "# Make sure the process ID is in the output\n" "logging.basicConfig(level=logging.DEBUG,\n" " handlers=[logging.StreamHandler(), handler],\n" -" format='%(levelname)-8s %(name)10s %(process)6s " -"%(message)s')\n" +" format='%(levelname)-8s %(name)10s %(process)6s %" +"(message)s')\n" "levels = (logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR,\n" " logging.CRITICAL)\n" "logger_names = ('myapp', 'myapp.lib1', 'myapp.lib2')\n" @@ -2649,14 +2713,14 @@ msgid "" " time.sleep(delay)" msgstr "" -#: ../../howto/logging-cookbook.rst:2047 +#: ../../howto/logging-cookbook.rst:2060 msgid "" "You can run the above two snippets in separate command shells. If we run the " "listener in one shell and run the sender in two separate shells, we should " "see something like the following. In the first sender shell:" msgstr "" -#: ../../howto/logging-cookbook.rst:2051 +#: ../../howto/logging-cookbook.rst:2064 msgid "" "$ python sender.py\n" "DEBUG myapp 613 Message no. 1\n" @@ -2670,11 +2734,11 @@ msgid "" "(and so on)" msgstr "" -#: ../../howto/logging-cookbook.rst:2064 +#: ../../howto/logging-cookbook.rst:2077 msgid "In the second sender shell:" msgstr "" -#: ../../howto/logging-cookbook.rst:2066 +#: ../../howto/logging-cookbook.rst:2079 msgid "" "$ python sender.py\n" "INFO myapp.lib2 657 Message no. 1\n" @@ -2688,11 +2752,11 @@ msgid "" "(and so on)" msgstr "" -#: ../../howto/logging-cookbook.rst:2079 +#: ../../howto/logging-cookbook.rst:2092 msgid "In the listener shell:" msgstr "" -#: ../../howto/logging-cookbook.rst:2081 +#: ../../howto/logging-cookbook.rst:2094 msgid "" "$ python listener.py\n" "Press Ctrl-C to stop.\n" @@ -2715,25 +2779,25 @@ msgid "" "(and so on)" msgstr "" -#: ../../howto/logging-cookbook.rst:2103 +#: ../../howto/logging-cookbook.rst:2116 msgid "" "As you can see, the logging from the two sender processes is interleaved in " "the listener's output." msgstr "" -#: ../../howto/logging-cookbook.rst:2108 +#: ../../howto/logging-cookbook.rst:2121 msgid "An example dictionary-based configuration" msgstr "" -#: ../../howto/logging-cookbook.rst:2110 +#: ../../howto/logging-cookbook.rst:2123 msgid "" "Below is an example of a logging configuration dictionary - it's taken from " "the `documentation on the Django project `_. This dictionary is passed to :" -"func:`~config.dictConfig` to put the configuration into effect::" +"stable/topics/logging/#configuring-logging>`_. This dictionary is passed " +"to :func:`~config.dictConfig` to put the configuration into effect::" msgstr "" -#: ../../howto/logging-cookbook.rst:2114 +#: ../../howto/logging-cookbook.rst:2127 msgid "" "LOGGING = {\n" " 'version': 1,\n" @@ -2835,24 +2899,24 @@ msgstr "" " }\n" "}" -#: ../../howto/logging-cookbook.rst:2163 +#: ../../howto/logging-cookbook.rst:2176 msgid "" "For more information about this configuration, you can see the `relevant " "section `_ of the Django documentation." msgstr "" -#: ../../howto/logging-cookbook.rst:2170 +#: ../../howto/logging-cookbook.rst:2183 msgid "Using a rotator and namer to customize log rotation processing" msgstr "" -#: ../../howto/logging-cookbook.rst:2172 +#: ../../howto/logging-cookbook.rst:2185 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:2175 +#: ../../howto/logging-cookbook.rst:2188 msgid "" "import gzip\n" "import logging\n" @@ -2912,12 +2976,12 @@ msgstr "" "for i in range(1000):\n" " root.info(f'Message no. {i + 1}')" -#: ../../howto/logging-cookbook.rst:2203 +#: ../../howto/logging-cookbook.rst:2216 msgid "" "After running this, you will see six new files, five of which are compressed:" msgstr "" -#: ../../howto/logging-cookbook.rst:2205 +#: ../../howto/logging-cookbook.rst:2218 msgid "" "$ ls rotated.log*\n" "rotated.log rotated.log.2.gz rotated.log.4.gz\n" @@ -2935,11 +2999,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:2216 +#: ../../howto/logging-cookbook.rst:2229 msgid "A more elaborate multiprocessing example" msgstr "" -#: ../../howto/logging-cookbook.rst:2218 +#: ../../howto/logging-cookbook.rst:2231 msgid "" "The following working example shows how logging can be used with " "multiprocessing using configuration files. The configurations are fairly " @@ -2947,7 +3011,7 @@ msgid "" "in a real multiprocessing scenario." msgstr "" -#: ../../howto/logging-cookbook.rst:2223 +#: ../../howto/logging-cookbook.rst:2236 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 " @@ -2960,13 +3024,13 @@ msgid "" "own scenario." msgstr "" -#: ../../howto/logging-cookbook.rst:2233 +#: ../../howto/logging-cookbook.rst:2246 msgid "" "Here's the script - the docstrings and the comments hopefully explain how it " "works::" msgstr "" -#: ../../howto/logging-cookbook.rst:2236 +#: ../../howto/logging-cookbook.rst:2249 msgid "" "import logging\n" "import logging.config\n" @@ -3111,13 +3175,13 @@ msgid "" " 'formatters': {\n" " 'detailed': {\n" " 'class': 'logging.Formatter',\n" -" 'format': '%(asctime)s %(name)-15s %(levelname)-8s " -"%(processName)-10s %(message)s'\n" +" 'format': '%(asctime)s %(name)-15s %(levelname)-8s %" +"(processName)-10s %(message)s'\n" " },\n" " 'simple': {\n" " 'class': 'logging.Formatter',\n" -" 'format': '%(name)-15s %(levelname)-8s %(processName)-10s " -"%(message)s'\n" +" 'format': '%(name)-15s %(levelname)-8s %(processName)-10s %" +"(message)s'\n" " }\n" " },\n" " 'handlers': {\n" @@ -3189,11 +3253,11 @@ msgid "" " main()" msgstr "" -#: ../../howto/logging-cookbook.rst:2445 +#: ../../howto/logging-cookbook.rst:2458 msgid "Inserting a BOM into messages sent to a SysLogHandler" msgstr "" -#: ../../howto/logging-cookbook.rst:2447 +#: ../../howto/logging-cookbook.rst:2460 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 " @@ -3202,7 +3266,7 @@ msgid "" "<5424#section-6>`.)" msgstr "" -#: ../../howto/logging-cookbook.rst:2453 +#: ../../howto/logging-cookbook.rst:2466 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 " @@ -3210,7 +3274,7 @@ msgid "" "hence not allowing any pure-ASCII component to appear before it." msgstr "" -#: ../../howto/logging-cookbook.rst:2459 +#: ../../howto/logging-cookbook.rst:2472 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 " @@ -3219,37 +3283,38 @@ msgid "" "encoded using UTF-8, then you need to do the following:" msgstr "" -#: ../../howto/logging-cookbook.rst:2465 +#: ../../howto/logging-cookbook.rst:2478 msgid "" -"Attach a :class:`~logging.Formatter` instance to your :class:`~logging." -"handlers.SysLogHandler` instance, with a format string such as::" +"Attach a :class:`~logging.Formatter` instance to " +"your :class:`~logging.handlers.SysLogHandler` instance, with a format string " +"such as::" msgstr "" -#: ../../howto/logging-cookbook.rst:2469 +#: ../../howto/logging-cookbook.rst:2482 msgid "'ASCII section\\ufeffUnicode section'" msgstr "" -#: ../../howto/logging-cookbook.rst:2471 +#: ../../howto/logging-cookbook.rst:2484 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:2474 +#: ../../howto/logging-cookbook.rst:2487 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:2478 +#: ../../howto/logging-cookbook.rst:2491 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:2482 +#: ../../howto/logging-cookbook.rst:2495 msgid "" "The formatted message *will* be encoded using UTF-8 encoding by " "``SysLogHandler``. If you follow the above rules, you should be able to " @@ -3258,11 +3323,11 @@ msgid "" "daemon may complain." msgstr "" -#: ../../howto/logging-cookbook.rst:2489 +#: ../../howto/logging-cookbook.rst:2502 msgid "Implementing structured logging" msgstr "" -#: ../../howto/logging-cookbook.rst:2491 +#: ../../howto/logging-cookbook.rst:2504 msgid "" "Although most logging messages are intended for reading by humans, and thus " "not readily machine-parseable, there might be circumstances where you want " @@ -3274,7 +3339,7 @@ msgid "" "machine-parseable manner::" msgstr "" -#: ../../howto/logging-cookbook.rst:2499 +#: ../../howto/logging-cookbook.rst:2512 msgid "" "import json\n" "import logging\n" @@ -3293,11 +3358,11 @@ msgid "" "logging.info(_('message 1', foo='bar', bar='baz', num=123, fnum=123.456))" msgstr "" -#: ../../howto/logging-cookbook.rst:2515 +#: ../../howto/logging-cookbook.rst:2528 msgid "If the above script is run, it prints:" msgstr "" -#: ../../howto/logging-cookbook.rst:2517 +#: ../../howto/logging-cookbook.rst:2530 msgid "" "message 1 >>> {\"fnum\": 123.456, \"num\": 123, \"bar\": \"baz\", \"foo\": " "\"bar\"}" @@ -3305,19 +3370,19 @@ msgstr "" "message 1 >>> {\"fnum\": 123.456, \"num\": 123, \"bar\": \"baz\", \"foo\": " "\"bar\"}" -#: ../../howto/logging-cookbook.rst:2521 ../../howto/logging-cookbook.rst:2563 +#: ../../howto/logging-cookbook.rst:2534 ../../howto/logging-cookbook.rst:2576 msgid "" "Note that the order of items might be different according to the version of " "Python used." msgstr "" -#: ../../howto/logging-cookbook.rst:2524 +#: ../../howto/logging-cookbook.rst:2537 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:2527 +#: ../../howto/logging-cookbook.rst:2540 msgid "" "import json\n" "import logging\n" @@ -3350,19 +3415,19 @@ msgid "" " main()" msgstr "" -#: ../../howto/logging-cookbook.rst:2557 +#: ../../howto/logging-cookbook.rst:2570 msgid "When the above script is run, it prints:" msgstr "" -#: ../../howto/logging-cookbook.rst:2559 +#: ../../howto/logging-cookbook.rst:2572 msgid "message 1 >>> {\"snowman\": \"\\u2603\", \"set_value\": [1, 2, 3]}" msgstr "message 1 >>> {\"snowman\": \"\\u2603\", \"set_value\": [1, 2, 3]}" -#: ../../howto/logging-cookbook.rst:2572 +#: ../../howto/logging-cookbook.rst:2585 msgid "Customizing handlers with :func:`dictConfig`" msgstr "" -#: ../../howto/logging-cookbook.rst:2574 +#: ../../howto/logging-cookbook.rst:2587 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 " @@ -3372,7 +3437,7 @@ msgid "" "customize handler creation using a plain function such as::" msgstr "" -#: ../../howto/logging-cookbook.rst:2581 +#: ../../howto/logging-cookbook.rst:2594 msgid "" "def owned_file_handler(filename, mode='a', encoding=None, owner=None):\n" " if owner:\n" @@ -3388,13 +3453,14 @@ msgstr "" " shutil.chown(filename, *owner)\n" " return logging.FileHandler(filename, mode, encoding)" -#: ../../howto/logging-cookbook.rst:2588 +#: ../../howto/logging-cookbook.rst:2601 msgid "" -"You can then specify, in a logging configuration passed to :func:" -"`dictConfig`, that a logging handler be created by calling this function::" +"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:2591 +#: ../../howto/logging-cookbook.rst:2604 msgid "" "LOGGING = {\n" " 'version': 1,\n" @@ -3427,14 +3493,14 @@ msgid "" "}" msgstr "" -#: ../../howto/logging-cookbook.rst:2621 +#: ../../howto/logging-cookbook.rst:2634 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:2625 +#: ../../howto/logging-cookbook.rst:2638 msgid "" "import logging, logging.config, os, shutil\n" "\n" @@ -3480,11 +3546,11 @@ msgid "" "logger.debug('A debug message')" msgstr "" -#: ../../howto/logging-cookbook.rst:2668 +#: ../../howto/logging-cookbook.rst:2681 msgid "To run this, you will probably need to run as ``root``:" msgstr "" -#: ../../howto/logging-cookbook.rst:2670 +#: ../../howto/logging-cookbook.rst:2683 msgid "" "$ sudo python3.3 chowntest.py\n" "$ cat chowntest.log\n" @@ -3493,34 +3559,34 @@ msgid "" "-rw-r--r-- 1 pulse pulse 55 2013-11-05 09:34 chowntest.log" msgstr "" -#: ../../howto/logging-cookbook.rst:2678 +#: ../../howto/logging-cookbook.rst:2691 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 " -"version that supports :func:`dictConfig` - namely, Python 2.7, 3.2 or later. " -"With pre-3.3 versions, you would need to implement the actual ownership " -"change using e.g. :func:`os.chown`." +"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 version that supports :func:`dictConfig` - namely, Python " +"2.7, 3.2 or later. With pre-3.3 versions, you would need to implement the " +"actual ownership change using e.g. :func:`os.chown`." msgstr "" -#: ../../howto/logging-cookbook.rst:2684 +#: ../../howto/logging-cookbook.rst:2697 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:2687 +#: ../../howto/logging-cookbook.rst:2700 msgid "'()': owned_file_handler," msgstr "'()': owned_file_handler," -#: ../../howto/logging-cookbook.rst:2689 +#: ../../howto/logging-cookbook.rst:2702 msgid "you could use e.g.::" msgstr "" -#: ../../howto/logging-cookbook.rst:2691 +#: ../../howto/logging-cookbook.rst:2704 msgid "'()': 'ext://project.util.owned_file_handler'," msgstr "'()': 'ext://project.util.owned_file_handler'," -#: ../../howto/logging-cookbook.rst:2693 +#: ../../howto/logging-cookbook.rst:2706 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://" @@ -3528,25 +3594,25 @@ msgid "" "resolved by :func:`dictConfig` from the ``ext://`` specification." msgstr "" -#: ../../howto/logging-cookbook.rst:2698 +#: ../../howto/logging-cookbook.rst:2711 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:2702 +#: ../../howto/logging-cookbook.rst:2715 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:2712 +#: ../../howto/logging-cookbook.rst:2725 msgid "Using particular formatting styles throughout your application" msgstr "" -#: ../../howto/logging-cookbook.rst:2714 +#: ../../howto/logging-cookbook.rst:2727 msgid "" "In Python 3.2, the :class:`~logging.Formatter` gained a ``style`` keyword " "parameter which, while defaulting to ``%`` for backward compatibility, " @@ -3557,7 +3623,7 @@ msgid "" "is constructed." msgstr "" -#: ../../howto/logging-cookbook.rst:2721 +#: ../../howto/logging-cookbook.rst:2734 msgid "" "Logging calls (:meth:`~Logger.debug`, :meth:`~Logger.info` etc.) only take " "positional parameters for the actual logging message itself, with keyword " @@ -3565,14 +3631,15 @@ msgid "" "call (e.g. the ``exc_info`` keyword parameter to indicate that traceback " "information should be logged, or the ``extra`` keyword parameter to indicate " "additional contextual information to be added to the log). So you cannot " -"directly make logging calls using :meth:`str.format` or :class:`string." -"Template` syntax, because internally the logging package uses %-formatting " -"to merge the format string and the variable arguments. There would be no " -"changing this while preserving backward compatibility, since all logging " -"calls which are out there in existing code will be using %-format strings." +"directly make logging calls using :meth:`str.format` " +"or :class:`string.Template` syntax, because internally the logging package " +"uses %-formatting to merge the format string and the variable arguments. " +"There would be no changing this while preserving backward compatibility, " +"since all logging calls which are out there in existing code will be using %-" +"format strings." msgstr "" -#: ../../howto/logging-cookbook.rst:2733 +#: ../../howto/logging-cookbook.rst:2746 msgid "" "There have been suggestions to associate format styles with specific " "loggers, but that approach also runs into backward compatibility problems " @@ -3580,7 +3647,7 @@ msgid "" "formatting." msgstr "" -#: ../../howto/logging-cookbook.rst:2737 +#: ../../howto/logging-cookbook.rst:2750 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 " @@ -3588,11 +3655,11 @@ msgid "" "formatting styles can be accommodated." msgstr "" -#: ../../howto/logging-cookbook.rst:2744 +#: ../../howto/logging-cookbook.rst:2757 msgid "Using LogRecord factories" msgstr "" -#: ../../howto/logging-cookbook.rst:2746 +#: ../../howto/logging-cookbook.rst:2759 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 " @@ -3607,27 +3674,27 @@ msgid "" "implementation does." msgstr "" -#: ../../howto/logging-cookbook.rst:2757 +#: ../../howto/logging-cookbook.rst:2770 msgid "" -"Refer to the reference documentation on :func:`setLogRecordFactory` and :" -"class:`LogRecord` for more information." +"Refer to the reference documentation on :func:`setLogRecordFactory` " +"and :class:`LogRecord` for more information." msgstr "" -#: ../../howto/logging-cookbook.rst:2762 +#: ../../howto/logging-cookbook.rst:2775 msgid "Using custom message objects" msgstr "" -#: ../../howto/logging-cookbook.rst:2764 +#: ../../howto/logging-cookbook.rst:2777 msgid "" "There is another, perhaps simpler way that you can use {}- and $- formatting " -"to construct your individual log messages. You may recall (from :ref:" -"`arbitrary-object-messages`) that when logging you can use an arbitrary " -"object as a message format string, and that the logging package will call :" -"func:`str` on that object to get the actual format string. Consider the " -"following two classes::" +"to construct your individual log messages. You may recall " +"(from :ref:`arbitrary-object-messages`) that when logging you can use an " +"arbitrary object as a message format string, and that the logging package " +"will call :func:`str` on that object to get the actual format string. " +"Consider the following two classes::" msgstr "" -#: ../../howto/logging-cookbook.rst:2789 +#: ../../howto/logging-cookbook.rst:2802 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 " @@ -3638,13 +3705,13 @@ msgid "" "using ``_`` for localization)." msgstr "" -#: ../../howto/logging-cookbook.rst:2797 +#: ../../howto/logging-cookbook.rst:2810 msgid "" -"Examples of this approach are given below. Firstly, formatting with :meth:" -"`str.format`::" +"Examples of this approach are given below. Firstly, formatting " +"with :meth:`str.format`::" msgstr "" -#: ../../howto/logging-cookbook.rst:2800 +#: ../../howto/logging-cookbook.rst:2813 msgid "" ">>> __ = BraceMessage\n" ">>> print(__('Message with {0} {1}', 2, 'placeholders'))\n" @@ -3658,20 +3725,35 @@ msgid "" "point=p))\n" "Message with coordinates: (0.50, 0.50)" msgstr "" +">>> __ = BraceMessage\n" +">>> print(__('Message with {0} {1}', 2, 'placeholders'))\n" +"Message with 2 placeholders\n" +">>> class Point: pass\n" +"...\n" +">>> p = Point()\n" +">>> p.x = 0.5\n" +">>> p.y = 0.5\n" +">>> print(__('Message with coordinates: ({point.x:.2f}, {point.y:.2f})', " +"point=p))\n" +"Message with coordinates: (0.50, 0.50)" -#: ../../howto/logging-cookbook.rst:2811 +#: ../../howto/logging-cookbook.rst:2824 msgid "Secondly, formatting with :class:`string.Template`::" msgstr "" -#: ../../howto/logging-cookbook.rst:2813 +#: ../../howto/logging-cookbook.rst:2826 msgid "" ">>> __ = DollarMessage\n" ">>> print(__('Message with $num $what', num=2, what='placeholders'))\n" "Message with 2 placeholders\n" ">>>" msgstr "" +">>> __ = DollarMessage\n" +">>> print(__('Message with $num $what', num=2, what='placeholders'))\n" +"Message with 2 placeholders\n" +">>>" -#: ../../howto/logging-cookbook.rst:2818 +#: ../../howto/logging-cookbook.rst:2831 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 " @@ -3683,26 +3765,26 @@ msgid "" "shown above." msgstr "" -#: ../../howto/logging-cookbook.rst:2832 +#: ../../howto/logging-cookbook.rst:2845 msgid "Configuring filters with :func:`dictConfig`" msgstr "" -#: ../../howto/logging-cookbook.rst:2834 +#: ../../howto/logging-cookbook.rst:2847 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). " "Since :class:`~logging.Filter` is the only filter class included in the " "standard library, and it is unlikely to cater to many requirements (it's " -"only there as a base class), you will typically need to define your own :" -"class:`~logging.Filter` subclass with an overridden :meth:`~logging.Filter." -"filter` method. To do this, specify the ``()`` key in the configuration " -"dictionary for the filter, specifying a callable which will be used to " -"create the filter (a class is the most obvious, but you can provide any " -"callable which returns a :class:`~logging.Filter` instance). Here is a " -"complete example::" +"only there as a base class), you will typically need to define your " +"own :class:`~logging.Filter` subclass with an " +"overridden :meth:`~logging.Filter.filter` method. To do this, specify the " +"``()`` key in the configuration dictionary for the filter, specifying a " +"callable which will be used to create the filter (a class is the most " +"obvious, but you can provide any callable which returns " +"a :class:`~logging.Filter` instance). Here is a complete example::" msgstr "" -#: ../../howto/logging-cookbook.rst:2845 +#: ../../howto/logging-cookbook.rst:2858 msgid "" "import logging\n" "import logging.config\n" @@ -3788,26 +3870,26 @@ msgstr "" " logging.debug('hello')\n" " logging.debug('hello - noshow')" -#: ../../howto/logging-cookbook.rst:2887 +#: ../../howto/logging-cookbook.rst:2900 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:2891 +#: ../../howto/logging-cookbook.rst:2904 msgid "changed: hello" msgstr "changed: hello" -#: ../../howto/logging-cookbook.rst:2895 +#: ../../howto/logging-cookbook.rst:2908 msgid "which shows that the filter is working as configured." msgstr "" -#: ../../howto/logging-cookbook.rst:2897 +#: ../../howto/logging-cookbook.rst:2910 msgid "A couple of extra points to note:" msgstr "" -#: ../../howto/logging-cookbook.rst:2899 +#: ../../howto/logging-cookbook.rst:2912 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 " @@ -3817,7 +3899,7 @@ msgid "" "the above example." msgstr "" -#: ../../howto/logging-cookbook.rst:2906 +#: ../../howto/logging-cookbook.rst:2919 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 " @@ -3826,11 +3908,11 @@ msgid "" "above." msgstr "" -#: ../../howto/logging-cookbook.rst:2915 +#: ../../howto/logging-cookbook.rst:2928 msgid "Customized exception formatting" msgstr "" -#: ../../howto/logging-cookbook.rst:2917 +#: ../../howto/logging-cookbook.rst:2930 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, " @@ -3838,7 +3920,7 @@ msgid "" "formatter class, as shown in the following example::" msgstr "" -#: ../../howto/logging-cookbook.rst:2922 +#: ../../howto/logging-cookbook.rst:2935 msgid "" "import logging\n" "\n" @@ -3877,53 +3959,51 @@ msgid "" " main()" msgstr "" -#: ../../howto/logging-cookbook.rst:2958 +#: ../../howto/logging-cookbook.rst:2971 msgid "When run, this produces a file with exactly two lines:" msgstr "" -#: ../../howto/logging-cookbook.rst:2960 +#: ../../howto/logging-cookbook.rst:2973 msgid "" "28/01/2015 07:21:23|INFO|Sample message|\n" -"28/01/2015 07:21:23|ERROR|ZeroDivisionError: integer division or modulo by " -"zero|'Traceback (most recent call last):\\n File \"logtest7.py\", line 30, " -"in main\\n x = 1 / 0\\nZeroDivisionError: integer division or modulo by " -"zero'|" +"28/01/2015 07:21:23|ERROR|ZeroDivisionError: division by zero|'Traceback " +"(most recent call last):\\n File \"logtest7.py\", line 30, in main\\n x " +"= 1 / 0\\nZeroDivisionError: division by zero'|" msgstr "" "28/01/2015 07:21:23|INFO|Sample message|\n" -"28/01/2015 07:21:23|ERROR|ZeroDivisionError: integer division or modulo by " -"zero|'Traceback (most recent call last):\\n File \"logtest7.py\", line 30, " -"in main\\n x = 1 / 0\\nZeroDivisionError: integer division or modulo by " -"zero'|" +"28/01/2015 07:21:23|ERROR|ZeroDivisionError: division by zero|'Traceback " +"(most recent call last):\\n File \"logtest7.py\", line 30, in main\\n x " +"= 1 / 0\\nZeroDivisionError: division by zero'|" -#: ../../howto/logging-cookbook.rst:2965 +#: ../../howto/logging-cookbook.rst:2978 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:2972 +#: ../../howto/logging-cookbook.rst:2985 msgid "Speaking logging messages" msgstr "" -#: ../../howto/logging-cookbook.rst:2974 +#: ../../howto/logging-cookbook.rst:2987 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 " "you have text-to-speech (TTS) functionality available in your system, even " "if it doesn't have a Python binding. Most TTS systems have a command line " -"program you can run, and this can be invoked from a handler using :mod:" -"`subprocess`. It's assumed here that TTS command line programs won't expect " -"to interact with users or take a long time to complete, and that the " -"frequency of logged messages will be not so high as to swamp the user with " -"messages, and that it's acceptable to have the messages spoken one at a time " -"rather than concurrently, The example implementation below waits for one " -"message to be spoken before the next is processed, and this might cause " -"other handlers to be kept waiting. Here is a short example showing the " +"program you can run, and this can be invoked from a handler " +"using :mod:`subprocess`. It's assumed here that TTS command line programs " +"won't expect to interact with users or take a long time to complete, and " +"that the frequency of logged messages will be not so high as to swamp the " +"user with messages, and that it's acceptable to have the messages spoken one " +"at a time rather than concurrently, The example implementation below waits " +"for one message to be spoken before the next is processed, and this might " +"cause other handlers to be kept waiting. Here is a short example showing the " "approach, which assumes that the ``espeak`` TTS package is available::" msgstr "" -#: ../../howto/logging-cookbook.rst:2987 +#: ../../howto/logging-cookbook.rst:3000 msgid "" "import logging\n" "import subprocess\n" @@ -3955,24 +4035,24 @@ msgid "" " sys.exit(main())" msgstr "" -#: ../../howto/logging-cookbook.rst:3016 +#: ../../howto/logging-cookbook.rst:3029 msgid "" "When run, this script should say \"Hello\" and then \"Goodbye\" in a female " "voice." msgstr "" -#: ../../howto/logging-cookbook.rst:3018 +#: ../../howto/logging-cookbook.rst:3031 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:3026 +#: ../../howto/logging-cookbook.rst:3039 msgid "Buffering logging messages and outputting them conditionally" msgstr "" -#: ../../howto/logging-cookbook.rst:3028 +#: ../../howto/logging-cookbook.rst:3041 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 " @@ -3982,7 +4062,7 @@ msgid "" "debug information to be output as well as the error." msgstr "" -#: ../../howto/logging-cookbook.rst:3035 +#: ../../howto/logging-cookbook.rst:3048 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 " @@ -3995,7 +4075,7 @@ msgid "" "subclass of ``MemoryHandler`` if you want custom flushing behavior." msgstr "" -#: ../../howto/logging-cookbook.rst:3045 +#: ../../howto/logging-cookbook.rst:3058 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 " @@ -4004,23 +4084,23 @@ msgid "" "levels - otherwise, it only logs at DEBUG, INFO and WARNING levels." msgstr "" -#: ../../howto/logging-cookbook.rst:3051 +#: ../../howto/logging-cookbook.rst:3064 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 " "parameter and attaches a memory handler for the duration of the call to the " "decorated function. The decorator can be additionally parameterised using a " "target handler, a level at which flushing should occur, and a capacity for " -"the buffer (number of records buffered). These default to a :class:`~logging." -"StreamHandler` which writes to ``sys.stderr``, ``logging.ERROR`` and ``100`` " -"respectively." +"the buffer (number of records buffered). These default to " +"a :class:`~logging.StreamHandler` which writes to ``sys.stderr``, " +"``logging.ERROR`` and ``100`` respectively." msgstr "" -#: ../../howto/logging-cookbook.rst:3059 +#: ../../howto/logging-cookbook.rst:3072 msgid "Here's the script::" msgstr "" -#: ../../howto/logging-cookbook.rst:3061 +#: ../../howto/logging-cookbook.rst:3074 msgid "" "import logging\n" "from logging.handlers import MemoryHandler\n" @@ -4086,11 +4166,11 @@ msgid "" " assert decorated_foo(True)" msgstr "" -#: ../../howto/logging-cookbook.rst:3122 +#: ../../howto/logging-cookbook.rst:3135 msgid "When this script is run, the following output should be observed:" msgstr "" -#: ../../howto/logging-cookbook.rst:3124 +#: ../../howto/logging-cookbook.rst:3137 msgid "" "Calling undecorated foo with False\n" "about to log at DEBUG ...\n" @@ -4119,40 +4199,41 @@ msgid "" "Actually logged at CRITICAL" msgstr "" -#: ../../howto/logging-cookbook.rst:3152 +#: ../../howto/logging-cookbook.rst:3165 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:3156 +#: ../../howto/logging-cookbook.rst:3169 msgid "You can of course use the conventional means of decoration::" msgstr "" -#: ../../howto/logging-cookbook.rst:3158 +#: ../../howto/logging-cookbook.rst:3171 msgid "" "@log_if_errors(logger)\n" "def foo(fail=False):\n" " ..." msgstr "" -#: ../../howto/logging-cookbook.rst:3166 +#: ../../howto/logging-cookbook.rst:3179 msgid "Sending logging messages to email, with buffering" msgstr "" -#: ../../howto/logging-cookbook.rst:3168 +#: ../../howto/logging-cookbook.rst:3181 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." -"BufferingHandler`. In the following example, which you can adapt to suit " -"your specific needs, a simple test harness is provided which allows you to " -"run the script with command line arguments specifying what you typically " -"need to send things via SMTP. (Run the downloaded script with the ``-h`` " -"argument to see the required and optional arguments.)" +"of messages are sent per email, you can " +"subclass :class:`~logging.handlers.BufferingHandler`. In the following " +"example, which you can adapt to suit your specific needs, a simple test " +"harness is provided which allows you to run the script with command line " +"arguments specifying what you typically need to send things via SMTP. (Run " +"the downloaded script with the ``-h`` argument to see the required and " +"optional arguments.)" msgstr "" -#: ../../howto/logging-cookbook.rst:3176 +#: ../../howto/logging-cookbook.rst:3189 msgid "" "import logging\n" "import logging.handlers\n" @@ -4172,8 +4253,8 @@ msgid "" " toaddrs = [toaddrs]\n" " self.toaddrs = toaddrs\n" " self.subject = subject\n" -" self.setFormatter(logging.Formatter(\"%(asctime)s %(levelname)-5s " -"%(message)s\"))\n" +" self.setFormatter(logging.Formatter(\"%(asctime)s %(levelname)-5s %" +"(message)s\"))\n" "\n" " def flush(self):\n" " if len(self.buffer) > 0:\n" @@ -4220,7 +4301,7 @@ msgid "" " h.close()" msgstr "" -#: ../../howto/logging-cookbook.rst:3240 +#: ../../howto/logging-cookbook.rst:3253 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 " @@ -4228,17 +4309,17 @@ msgid "" "messages. That makes up 102 messages as specified in the script." msgstr "" -#: ../../howto/logging-cookbook.rst:3248 +#: ../../howto/logging-cookbook.rst:3261 msgid "Formatting times using UTC (GMT) via configuration" msgstr "" -#: ../../howto/logging-cookbook.rst:3250 +#: ../../howto/logging-cookbook.rst:3263 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:3253 +#: ../../howto/logging-cookbook.rst:3266 msgid "" "import logging\n" "import time\n" @@ -4246,16 +4327,21 @@ msgid "" "class UTCFormatter(logging.Formatter):\n" " converter = time.gmtime" msgstr "" +"import logging\n" +"import time\n" +"\n" +"class UTCFormatter(logging.Formatter):\n" +" converter = time.gmtime" -#: ../../howto/logging-cookbook.rst:3259 +#: ../../howto/logging-cookbook.rst:3272 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 " -"the :func:`~logging.config.dictConfig` API with an approach illustrated by " -"the following complete example::" +"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 the :func:`~logging.config.dictConfig` API with an approach " +"illustrated by the following complete example::" msgstr "" -#: ../../howto/logging-cookbook.rst:3264 +#: ../../howto/logging-cookbook.rst:3277 msgid "" "import logging\n" "import logging.config\n" @@ -4295,12 +4381,49 @@ msgid "" " logging.config.dictConfig(LOGGING)\n" " logging.warning('The local time is %s', time.asctime())" msgstr "" +"import logging\n" +"import logging.config\n" +"import time\n" +"\n" +"class UTCFormatter(logging.Formatter):\n" +" converter = time.gmtime\n" +"\n" +"LOGGING = {\n" +" 'version': 1,\n" +" 'disable_existing_loggers': False,\n" +" 'formatters': {\n" +" 'utc': {\n" +" '()': UTCFormatter,\n" +" 'format': '%(asctime)s %(message)s',\n" +" },\n" +" 'local': {\n" +" 'format': '%(asctime)s %(message)s',\n" +" }\n" +" },\n" +" 'handlers': {\n" +" 'console1': {\n" +" 'class': 'logging.StreamHandler',\n" +" 'formatter': 'utc',\n" +" },\n" +" 'console2': {\n" +" 'class': 'logging.StreamHandler',\n" +" 'formatter': 'local',\n" +" },\n" +" },\n" +" 'root': {\n" +" 'handlers': ['console1', 'console2'],\n" +" }\n" +"}\n" +"\n" +"if __name__ == '__main__':\n" +" logging.config.dictConfig(LOGGING)\n" +" logging.warning('The local time is %s', time.asctime())" -#: ../../howto/logging-cookbook.rst:3302 +#: ../../howto/logging-cookbook.rst:3315 msgid "When this script is run, it should print something like:" msgstr "" -#: ../../howto/logging-cookbook.rst:3304 +#: ../../howto/logging-cookbook.rst:3317 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" @@ -4308,17 +4431,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:3309 +#: ../../howto/logging-cookbook.rst:3322 msgid "" "showing how the time is formatted both as local time and UTC, one for each " "handler." msgstr "" -#: ../../howto/logging-cookbook.rst:3316 +#: ../../howto/logging-cookbook.rst:3329 msgid "Using a context manager for selective logging" msgstr "" -#: ../../howto/logging-cookbook.rst:3318 +#: ../../howto/logging-cookbook.rst:3331 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 " @@ -4328,7 +4451,7 @@ msgid "" "scope of the context manager::" msgstr "" -#: ../../howto/logging-cookbook.rst:3325 +#: ../../howto/logging-cookbook.rst:3338 msgid "" "import logging\n" "import sys\n" @@ -4357,7 +4480,7 @@ msgid "" " # implicit return of None => don't swallow exceptions" msgstr "" -#: ../../howto/logging-cookbook.rst:3351 +#: ../../howto/logging-cookbook.rst:3364 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 " @@ -4366,13 +4489,13 @@ msgid "" "block exit - you could do this if you don't need the handler any more." msgstr "" -#: ../../howto/logging-cookbook.rst:3357 +#: ../../howto/logging-cookbook.rst:3370 msgid "" "To illustrate how it works, we can add the following block of code to the " "above::" msgstr "" -#: ../../howto/logging-cookbook.rst:3360 +#: ../../howto/logging-cookbook.rst:3373 msgid "" "if __name__ == '__main__':\n" " logger = logging.getLogger('foo')\n" @@ -4391,8 +4514,24 @@ msgid "" " logger.info('6. This should appear just once on stderr.')\n" " logger.debug('7. This should not appear.')" msgstr "" +"if __name__ == '__main__':\n" +" logger = logging.getLogger('foo')\n" +" logger.addHandler(logging.StreamHandler())\n" +" logger.setLevel(logging.INFO)\n" +" logger.info('1. This should appear just once on stderr.')\n" +" logger.debug('2. This should not appear.')\n" +" with LoggingContext(logger, level=logging.DEBUG):\n" +" logger.debug('3. This should appear once on stderr.')\n" +" logger.debug('4. This should not appear.')\n" +" h = logging.StreamHandler(sys.stdout)\n" +" with LoggingContext(logger, level=logging.DEBUG, handler=h, " +"close=True):\n" +" logger.debug('5. This should appear twice - once on stderr and once " +"on stdout.')\n" +" logger.info('6. This should appear just once on stderr.')\n" +" logger.debug('7. This should not appear.')" -#: ../../howto/logging-cookbook.rst:3375 +#: ../../howto/logging-cookbook.rst:3388 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 " @@ -4405,11 +4544,11 @@ msgid "" "(like message #1) whereas message #7 doesn't (just like message #2)." msgstr "" -#: ../../howto/logging-cookbook.rst:3385 +#: ../../howto/logging-cookbook.rst:3398 msgid "If we run the resulting script, the result is as follows:" msgstr "" -#: ../../howto/logging-cookbook.rst:3387 +#: ../../howto/logging-cookbook.rst:3400 msgid "" "$ python logctx.py\n" "1. This should appear just once on stderr.\n" @@ -4418,24 +4557,30 @@ msgid "" "5. This should appear twice - once on stderr and once on stdout.\n" "6. This should appear just once on stderr." msgstr "" +"$ python logctx.py\n" +"1. This should appear just once on stderr.\n" +"3. This should appear once on stderr.\n" +"5. This should appear twice - once on stderr and once on stdout.\n" +"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:3396 +#: ../../howto/logging-cookbook.rst:3409 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:3399 +#: ../../howto/logging-cookbook.rst:3412 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:3404 +#: ../../howto/logging-cookbook.rst:3417 msgid "Once again, but piping ``stdout`` to ``/dev/null``, we get:" msgstr "" -#: ../../howto/logging-cookbook.rst:3406 +#: ../../howto/logging-cookbook.rst:3419 msgid "" "$ python logctx.py >/dev/null\n" "1. This should appear just once on stderr.\n" @@ -4443,54 +4588,59 @@ msgid "" "5. This should appear twice - once on stderr and once on stdout.\n" "6. This should appear just once on stderr." msgstr "" +"$ python logctx.py >/dev/null\n" +"1. This should appear just once on stderr.\n" +"3. This should appear once on stderr.\n" +"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:3414 +#: ../../howto/logging-cookbook.rst:3427 msgid "" "In this case, the message #5 printed to ``stdout`` doesn't appear, as " "expected." msgstr "" -#: ../../howto/logging-cookbook.rst:3416 +#: ../../howto/logging-cookbook.rst:3429 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:3424 +#: ../../howto/logging-cookbook.rst:3437 msgid "A CLI application starter template" msgstr "" -#: ../../howto/logging-cookbook.rst:3426 +#: ../../howto/logging-cookbook.rst:3439 msgid "Here's an example which shows how you can:" msgstr "" -#: ../../howto/logging-cookbook.rst:3428 +#: ../../howto/logging-cookbook.rst:3441 msgid "Use a logging level based on command-line arguments" msgstr "" -#: ../../howto/logging-cookbook.rst:3429 +#: ../../howto/logging-cookbook.rst:3442 msgid "" "Dispatch to multiple subcommands in separate files, all logging at the same " "level in a consistent way" msgstr "" -#: ../../howto/logging-cookbook.rst:3431 +#: ../../howto/logging-cookbook.rst:3444 msgid "Make use of simple, minimal configuration" msgstr "" -#: ../../howto/logging-cookbook.rst:3433 +#: ../../howto/logging-cookbook.rst:3446 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 " "illustration as a file ``app.py`` that is the main script for the " -"application, with individual commands implemented in ``start.py``, ``stop." -"py`` and ``restart.py``. Suppose further that we want to control the " +"application, with individual commands implemented in ``start.py``, " +"``stop.py`` and ``restart.py``. Suppose further that we want to control the " "verbosity of the application via a command-line argument, defaulting to " "``logging.INFO``. Here's one way that ``app.py`` could be written::" msgstr "" -#: ../../howto/logging-cookbook.rst:3441 +#: ../../howto/logging-cookbook.rst:3454 msgid "" "import argparse\n" "import importlib\n" @@ -4525,8 +4675,8 @@ msgid "" " mod = importlib.import_module(options.command)\n" " cmd = getattr(mod, 'command')\n" " except (ImportError, AttributeError):\n" -" print('Unable to find the code for command \\'%s\\'' % options." -"command)\n" +" print('Unable to find the code for command \\'%s\\'' % " +"options.command)\n" " return 1\n" " # Could get fancy here and load configuration from file or dictionary\n" " logging.basicConfig(level=options.log_level,\n" @@ -4537,13 +4687,13 @@ msgid "" " sys.exit(main())" msgstr "" -#: ../../howto/logging-cookbook.rst:3482 +#: ../../howto/logging-cookbook.rst:3495 msgid "" "And the ``start``, ``stop`` and ``restart`` commands can be implemented in " "separate modules, like so for starting::" msgstr "" -#: ../../howto/logging-cookbook.rst:3485 +#: ../../howto/logging-cookbook.rst:3498 msgid "" "# start.py\n" "import logging\n" @@ -4555,12 +4705,21 @@ msgid "" " # actually do the command processing here ...\n" " logger.info('Started the \\'%s\\' service.', options.name)" msgstr "" +"# start.py\n" +"import logging\n" +"\n" +"logger = logging.getLogger(__name__)\n" +"\n" +"def command(options):\n" +" logger.debug('About to start %s', options.name)\n" +" # 在這裡實際執行命令處理 ...\n" +" logger.info('Started the \\'%s\\' service.', options.name)" -#: ../../howto/logging-cookbook.rst:3495 +#: ../../howto/logging-cookbook.rst:3508 msgid "and thus for stopping::" msgstr "" -#: ../../howto/logging-cookbook.rst:3497 +#: ../../howto/logging-cookbook.rst:3510 msgid "" "# stop.py\n" "import logging\n" @@ -4581,12 +4740,30 @@ msgid "" " # actually do the command processing here ...\n" " logger.info('Stopped the %s service%s.', services, plural)" msgstr "" +"# stop.py\n" +"import logging\n" +"\n" +"logger = logging.getLogger(__name__)\n" +"\n" +"def command(options):\n" +" n = len(options.names)\n" +" if n == 1:\n" +" plural = ''\n" +" services = '\\'%s\\'' % options.names[0]\n" +" else:\n" +" plural = 's'\n" +" services = ', '.join('\\'%s\\'' % name for name in options.names)\n" +" i = services.rfind(', ')\n" +" services = services[:i] + ' and ' + services[i + 2:]\n" +" logger.debug('About to stop %s', services)\n" +" # 在這裡實際執行命令處理 ...\n" +" logger.info('Stopped the %s service%s.', services, plural)" -#: ../../howto/logging-cookbook.rst:3516 +#: ../../howto/logging-cookbook.rst:3529 msgid "and similarly for restarting::" msgstr "" -#: ../../howto/logging-cookbook.rst:3518 +#: ../../howto/logging-cookbook.rst:3531 msgid "" "# restart.py\n" "import logging\n" @@ -4607,14 +4784,32 @@ msgid "" " # actually do the command processing here ...\n" " logger.info('Restarted the %s service%s.', services, plural)" msgstr "" +"# restart.py\n" +"import logging\n" +"\n" +"logger = logging.getLogger(__name__)\n" +"\n" +"def command(options):\n" +" n = len(options.names)\n" +" if n == 1:\n" +" plural = ''\n" +" services = '\\'%s\\'' % options.names[0]\n" +" else:\n" +" plural = 's'\n" +" services = ', '.join('\\'%s\\'' % name for name in options.names)\n" +" i = services.rfind(', ')\n" +" services = services[:i] + ' and ' + services[i + 2:]\n" +" logger.debug('About to restart %s', services)\n" +" # 在這裡實際執行命令處理 ...\n" +" logger.info('Restarted the %s service%s.', services, plural)" -#: ../../howto/logging-cookbook.rst:3537 +#: ../../howto/logging-cookbook.rst:3550 msgid "" "If we run this application with the default log level, we get output like " "this:" msgstr "" -#: ../../howto/logging-cookbook.rst:3539 +#: ../../howto/logging-cookbook.rst:3552 msgid "" "$ python app.py start foo\n" "INFO start Started the 'foo' service.\n" @@ -4625,20 +4820,28 @@ msgid "" "$ python app.py restart foo bar baz\n" "INFO restart Restarted the 'foo', 'bar' and 'baz' services." msgstr "" +"$ python app.py start foo\n" +"INFO start Started the 'foo' service.\n" +"\n" +"$ python app.py stop foo bar\n" +"INFO stop Stopped the 'foo' and 'bar' services.\n" +"\n" +"$ python app.py restart foo bar baz\n" +"INFO restart Restarted the 'foo', 'bar' and 'baz' services." -#: ../../howto/logging-cookbook.rst:3550 +#: ../../howto/logging-cookbook.rst:3563 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:3553 +#: ../../howto/logging-cookbook.rst:3566 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:3556 +#: ../../howto/logging-cookbook.rst:3569 msgid "" "$ python app.py --log-level DEBUG start foo\n" "DEBUG start About to start foo\n" @@ -4652,37 +4855,51 @@ msgid "" "DEBUG restart About to restart 'foo', 'bar' and 'baz'\n" "INFO restart Restarted the 'foo', 'bar' and 'baz' services." msgstr "" +"$ python app.py --log-level DEBUG start foo\n" +"DEBUG start About to start foo\n" +"INFO start Started the 'foo' service.\n" +"\n" +"$ python app.py --log-level DEBUG stop foo bar\n" +"DEBUG stop About to stop 'foo' and 'bar'\n" +"INFO stop Stopped the 'foo' and 'bar' services.\n" +"\n" +"$ python app.py --log-level DEBUG restart foo bar baz\n" +"DEBUG restart About to restart 'foo', 'bar' and 'baz'\n" +"INFO restart Restarted the 'foo', 'bar' and 'baz' services." -#: ../../howto/logging-cookbook.rst:3570 +#: ../../howto/logging-cookbook.rst:3583 msgid "And if we want less:" msgstr "" -#: ../../howto/logging-cookbook.rst:3572 +#: ../../howto/logging-cookbook.rst:3585 msgid "" "$ python app.py --log-level WARNING start foo\n" "$ python app.py --log-level WARNING stop foo bar\n" "$ python app.py --log-level WARNING restart foo bar baz" msgstr "" +"$ python app.py --log-level WARNING start foo\n" +"$ python app.py --log-level WARNING stop foo bar\n" +"$ python app.py --log-level WARNING restart foo bar baz" -#: ../../howto/logging-cookbook.rst:3578 +#: ../../howto/logging-cookbook.rst:3591 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:3584 +#: ../../howto/logging-cookbook.rst:3597 msgid "A Qt GUI for logging" msgstr "" -#: ../../howto/logging-cookbook.rst:3586 +#: ../../howto/logging-cookbook.rst:3599 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-" -"platform UI framework with Python bindings using :pypi:`PySide2` or :pypi:" -"`PyQt5` libraries." +"platform UI framework with Python bindings using :pypi:`PySide2` " +"or :pypi:`PyQt5` libraries." msgstr "" -#: ../../howto/logging-cookbook.rst:3591 +#: ../../howto/logging-cookbook.rst:3604 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 " @@ -4692,14 +4909,14 @@ msgid "" "logging messages at random levels with random short delays in between)." msgstr "" -#: ../../howto/logging-cookbook.rst:3598 +#: ../../howto/logging-cookbook.rst:3611 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:3602 +#: ../../howto/logging-cookbook.rst:3615 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 " @@ -4707,7 +4924,7 @@ msgid "" "more detailed information." msgstr "" -#: ../../howto/logging-cookbook.rst:3607 +#: ../../howto/logging-cookbook.rst:3620 msgid "" "import datetime\n" "import logging\n" @@ -4890,8 +5107,8 @@ msgid "" " self.start_thread()\n" " self.work_button.clicked.connect(self.worker.start)\n" " # Once started, the button should be disabled\n" -" self.work_button.clicked.connect(lambda : self.work_button." -"setEnabled(False))\n" +" self.work_button.clicked.connect(lambda : " +"self.work_button.setEnabled(False))\n" "\n" " def start_thread(self):\n" " self.worker = Worker()\n" @@ -4958,28 +5175,29 @@ msgid "" " main()" msgstr "" -#: ../../howto/logging-cookbook.rst:3839 +#: ../../howto/logging-cookbook.rst:3852 msgid "Logging to syslog with RFC5424 support" msgstr "" -#: ../../howto/logging-cookbook.rst:3841 +#: ../../howto/logging-cookbook.rst:3854 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 " "``logging`` was added to Python in 2003, it supported the earlier (and only " "existing) protocol at the time. Since RFC5424 came out, as there has not " -"been widespread deployment of it in syslog servers, the :class:`~logging." -"handlers.SysLogHandler` functionality has not been updated." +"been widespread deployment of it in syslog servers, " +"the :class:`~logging.handlers.SysLogHandler` functionality has not been " +"updated." msgstr "" -#: ../../howto/logging-cookbook.rst:3848 +#: ../../howto/logging-cookbook.rst:3861 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:3852 +#: ../../howto/logging-cookbook.rst:3865 msgid "" "import datetime\n" "import logging.handlers\n" @@ -4999,8 +5217,8 @@ msgid "" "\n" " def format(self, record):\n" " version = 1\n" -" asctime = datetime.datetime.fromtimestamp(record.created)." -"isoformat()\n" +" asctime = " +"datetime.datetime.fromtimestamp(record.created).isoformat()\n" " m = self.tz_offset.match(time.strftime('%z'))\n" " has_offset = False\n" " if m and time.timezone:\n" @@ -5049,7 +5267,7 @@ msgid "" "{sdata} {msg}'" msgstr "" -#: ../../howto/logging-cookbook.rst:3914 +#: ../../howto/logging-cookbook.rst:3927 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 " @@ -5058,7 +5276,7 @@ msgid "" "using something like this::" msgstr "" -#: ../../howto/logging-cookbook.rst:3919 +#: ../../howto/logging-cookbook.rst:3932 msgid "" "sd = {\n" " 'foo@12345': {'bar': 'baz', 'baz': 'bozz', 'fizz': r'buzz'},\n" @@ -5076,11 +5294,11 @@ msgstr "" "i = 1\n" "logger.debug('Message %d', i, extra=extra)" -#: ../../howto/logging-cookbook.rst:3928 +#: ../../howto/logging-cookbook.rst:3941 msgid "How to treat a logger like an output stream" msgstr "" -#: ../../howto/logging-cookbook.rst:3930 +#: ../../howto/logging-cookbook.rst:3943 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 " @@ -5088,7 +5306,7 @@ msgid "" "API. Here's a short script illustrating such a class:" msgstr "" -#: ../../howto/logging-cookbook.rst:3935 +#: ../../howto/logging-cookbook.rst:3948 msgid "" "import logging\n" "\n" @@ -5126,11 +5344,11 @@ msgid "" " main()" msgstr "" -#: ../../howto/logging-cookbook.rst:3970 +#: ../../howto/logging-cookbook.rst:3983 msgid "When this script is run, it prints" msgstr "" -#: ../../howto/logging-cookbook.rst:3972 +#: ../../howto/logging-cookbook.rst:3985 msgid "" "INFO:demo:An INFO message\n" "DEBUG:demo:A DEBUG message" @@ -5138,13 +5356,13 @@ msgstr "" "INFO:demo:An INFO message\n" "DEBUG:demo:A DEBUG message" -#: ../../howto/logging-cookbook.rst:3977 +#: ../../howto/logging-cookbook.rst:3990 msgid "" -"You could also use ``LoggerWriter`` to redirect ``sys.stdout`` and ``sys." -"stderr`` by doing something like this:" +"You could also use ``LoggerWriter`` to redirect ``sys.stdout`` and " +"``sys.stderr`` by doing something like this:" msgstr "" -#: ../../howto/logging-cookbook.rst:3980 +#: ../../howto/logging-cookbook.rst:3993 msgid "" "import sys\n" "\n" @@ -5156,15 +5374,15 @@ msgstr "" "sys.stdout = LoggerWriter(logger, logging.INFO)\n" "sys.stderr = LoggerWriter(logger, logging.WARNING)" -#: ../../howto/logging-cookbook.rst:3987 +#: ../../howto/logging-cookbook.rst:4000 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." -"stderr`` value *before* it is overwritten by a ``LoggerWriter`` instance). " -"Then, you'd get this kind of result:" +"example, the :func:`~logging.basicConfig` call does this (using the " +"``sys.stderr`` value *before* it is overwritten by a ``LoggerWriter`` " +"instance). Then, you'd get this kind of result:" msgstr "" -#: ../../howto/logging-cookbook.rst:3992 +#: ../../howto/logging-cookbook.rst:4005 msgid "" ">>> print('Foo')\n" "INFO:demo:Foo\n" @@ -5178,31 +5396,33 @@ msgstr "" "WARNING:demo:Bar\n" ">>>" -#: ../../howto/logging-cookbook.rst:4000 +#: ../../howto/logging-cookbook.rst:4013 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." +"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:4004 +#: ../../howto/logging-cookbook.rst:4017 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:4008 +#: ../../howto/logging-cookbook.rst:4021 msgid "" "sys.stderr = LoggerWriter(logger, logging.WARNING)\n" "1 / 0" msgstr "" +"sys.stderr = LoggerWriter(logger, logging.WARNING)\n" +"1 / 0" -#: ../../howto/logging-cookbook.rst:4013 +#: ../../howto/logging-cookbook.rst:4026 msgid "then running the script results in" msgstr "" -#: ../../howto/logging-cookbook.rst:4015 +#: ../../howto/logging-cookbook.rst:4028 msgid "" "WARNING:demo:Traceback (most recent call last):\n" "\n" @@ -5220,8 +5440,23 @@ msgid "" "WARNING:demo::\n" "WARNING:demo:division by zero" msgstr "" +"WARNING:demo:Traceback (most recent call last):\n" +"\n" +"WARNING:demo: File \"/home/runner/cookbook-loggerwriter/test.py\", line 53, " +"in \n" +"\n" +"WARNING:demo:\n" +"WARNING:demo:main()\n" +"WARNING:demo: File \"/home/runner/cookbook-loggerwriter/test.py\", line 49, " +"in main\n" +"\n" +"WARNING:demo:\n" +"WARNING:demo:1 / 0\n" +"WARNING:demo:ZeroDivisionError\n" +"WARNING:demo::\n" +"WARNING:demo:division by zero" -#: ../../howto/logging-cookbook.rst:4031 +#: ../../howto/logging-cookbook.rst:4044 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 " @@ -5231,7 +5466,7 @@ msgid "" "``LoggerWriter``:" msgstr "" -#: ../../howto/logging-cookbook.rst:4037 +#: ../../howto/logging-cookbook.rst:4050 msgid "" "class BufferingLoggerWriter(LoggerWriter):\n" " def __init__(self, logger, level):\n" @@ -5267,13 +5502,13 @@ msgstr "" " for part in parts:\n" " self.logger.log(self.level, part)" -#: ../../howto/logging-cookbook.rst:4056 +#: ../../howto/logging-cookbook.rst:4069 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:4059 +#: ../../howto/logging-cookbook.rst:4072 msgid "" "WARNING:demo:Traceback (most recent call last):\n" "WARNING:demo: File \"/home/runner/cookbook-loggerwriter/main.py\", line 55, " @@ -5293,11 +5528,11 @@ msgstr "" "WARNING:demo: 1/0\n" "WARNING:demo:ZeroDivisionError: division by zero" -#: ../../howto/logging-cookbook.rst:4069 +#: ../../howto/logging-cookbook.rst:4082 msgid "How to uniformly handle newlines in logging output" msgstr "" -#: ../../howto/logging-cookbook.rst:4071 +#: ../../howto/logging-cookbook.rst:4084 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 " @@ -5308,7 +5543,7 @@ msgid "" "handler mixin, as in the following snippet:" msgstr "" -#: ../../howto/logging-cookbook.rst:4079 +#: ../../howto/logging-cookbook.rst:4092 msgid "" "# Assume this is in a module mymixins.py\n" "import copy\n" @@ -5327,11 +5562,11 @@ msgid "" " super().emit(rec)" msgstr "" -#: ../../howto/logging-cookbook.rst:4097 +#: ../../howto/logging-cookbook.rst:4110 msgid "You can use the mixin as in the following script:" msgstr "" -#: ../../howto/logging-cookbook.rst:4099 +#: ../../howto/logging-cookbook.rst:4112 msgid "" "import logging\n" "\n" @@ -5343,8 +5578,8 @@ msgid "" " pass\n" "\n" "if __name__ == '__main__':\n" -" logging.basicConfig(level=logging.DEBUG, format='%(asctime)s " -"%(levelname)-9s %(message)s',\n" +" logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %" +"(levelname)-9s %(message)s',\n" " handlers = [StreamHandler()])\n" " logger.debug('Single line')\n" " logger.debug('Multiple lines:\\nfool me once ...')\n" @@ -5352,12 +5587,30 @@ msgid "" " logger.debug('Multiple lines:\\n%s', 'fool me ...\\ncan\\'t get fooled " "again')" msgstr "" +"import logging\n" +"\n" +"from mymixins import MultilineMixin\n" +"\n" +"logger = logging.getLogger(__name__)\n" +"\n" +"class StreamHandler(MultilineMixin, logging.StreamHandler):\n" +" pass\n" +"\n" +"if __name__ == '__main__':\n" +" logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %" +"(levelname)-9s %(message)s',\n" +" handlers = [StreamHandler()])\n" +" logger.debug('Single line')\n" +" logger.debug('Multiple lines:\\nfool me once ...')\n" +" logger.debug('Another single line')\n" +" logger.debug('Multiple lines:\\n%s', 'fool me ...\\ncan\\'t get fooled " +"again')" -#: ../../howto/logging-cookbook.rst:4118 +#: ../../howto/logging-cookbook.rst:4131 msgid "The script, when run, prints something like:" msgstr "" -#: ../../howto/logging-cookbook.rst:4120 +#: ../../howto/logging-cookbook.rst:4133 msgid "" "2025-07-02 13:54:47,234 DEBUG Single line\n" "2025-07-02 13:54:47,234 DEBUG Multiple lines:\n" @@ -5367,15 +5620,22 @@ msgid "" "2025-07-02 13:54:47,234 DEBUG fool me ...\n" "2025-07-02 13:54:47,234 DEBUG can't get fooled again" msgstr "" +"2025-07-02 13:54:47,234 DEBUG Single line\n" +"2025-07-02 13:54:47,234 DEBUG Multiple lines:\n" +"2025-07-02 13:54:47,234 DEBUG fool me once ...\n" +"2025-07-02 13:54:47,234 DEBUG Another single line\n" +"2025-07-02 13:54:47,234 DEBUG Multiple lines:\n" +"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:4130 +#: ../../howto/logging-cookbook.rst:4143 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:" +"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:4134 +#: ../../howto/logging-cookbook.rst:4147 msgid "" "import logging\n" "\n" @@ -5388,8 +5648,8 @@ msgid "" "\n" "if __name__ == '__main__':\n" " h = logging.StreamHandler()\n" -" h.setFormatter(EscapingFormatter('%(asctime)s %(levelname)-9s " -"%(message)s'))\n" +" h.setFormatter(EscapingFormatter('%(asctime)s %(levelname)-9s %" +"(message)s'))\n" " logging.basicConfig(level=logging.DEBUG, handlers = [h])\n" " logger.debug('Single line')\n" " logger.debug('Multiple lines:\\nfool me once ...')\n" @@ -5397,14 +5657,33 @@ msgid "" " logger.debug('Multiple lines:\\n%s', 'fool me ...\\ncan\\'t get fooled " "again')" msgstr "" +"import logging\n" +"\n" +"logger = logging.getLogger(__name__)\n" +"\n" +"class EscapingFormatter(logging.Formatter):\n" +" def format(self, record):\n" +" s = super().format(record)\n" +" return s.replace('\\n', r'\\n')\n" +"\n" +"if __name__ == '__main__':\n" +" h = logging.StreamHandler()\n" +" h.setFormatter(EscapingFormatter('%(asctime)s %(levelname)-9s %" +"(message)s'))\n" +" logging.basicConfig(level=logging.DEBUG, handlers = [h])\n" +" logger.debug('Single line')\n" +" logger.debug('Multiple lines:\\nfool me once ...')\n" +" logger.debug('Another single line')\n" +" logger.debug('Multiple lines:\\n%s', 'fool me ...\\ncan\\'t get fooled " +"again')" -#: ../../howto/logging-cookbook.rst:4154 +#: ../../howto/logging-cookbook.rst:4167 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:4157 +#: ../../howto/logging-cookbook.rst:4170 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" @@ -5412,18 +5691,23 @@ msgid "" "2025-07-09 06:47:33,783 DEBUG Multiple lines:\\nfool me ...\\ncan't get " "fooled again" msgstr "" +"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" +"2025-07-09 06:47:33,783 DEBUG Another single line\n" +"2025-07-09 06:47:33,783 DEBUG Multiple lines:\\nfool me ...\\ncan't get " +"fooled again" -#: ../../howto/logging-cookbook.rst:4164 +#: ../../howto/logging-cookbook.rst:4177 msgid "" "Escaping behaviour can't be the stdlib default , as it would break backwards " "compatibility." msgstr "" -#: ../../howto/logging-cookbook.rst:4170 +#: ../../howto/logging-cookbook.rst:4183 msgid "Patterns to avoid" msgstr "" -#: ../../howto/logging-cookbook.rst:4172 +#: ../../howto/logging-cookbook.rst:4185 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 " @@ -5431,11 +5715,11 @@ msgid "" "The following sections are in no particular order." msgstr "" -#: ../../howto/logging-cookbook.rst:4178 +#: ../../howto/logging-cookbook.rst:4191 msgid "Opening the same log file multiple times" msgstr "" -#: ../../howto/logging-cookbook.rst:4180 +#: ../../howto/logging-cookbook.rst:4193 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. " @@ -5443,32 +5727,32 @@ msgid "" "file multiple times. This could be done accidentally, for example by:" msgstr "" -#: ../../howto/logging-cookbook.rst:4185 +#: ../../howto/logging-cookbook.rst:4198 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:4188 +#: ../../howto/logging-cookbook.rst:4201 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:4191 +#: ../../howto/logging-cookbook.rst:4204 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:4195 +#: ../../howto/logging-cookbook.rst:4208 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:4198 +#: ../../howto/logging-cookbook.rst:4211 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 " @@ -5477,7 +5761,7 @@ msgid "" "different handler instances which happen to point to the same file." msgstr "" -#: ../../howto/logging-cookbook.rst:4204 +#: ../../howto/logging-cookbook.rst:4217 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 " @@ -5487,17 +5771,17 @@ msgid "" "being supposedly in place." msgstr "" -#: ../../howto/logging-cookbook.rst:4211 +#: ../../howto/logging-cookbook.rst:4224 msgid "" "Use the techniques outlined in :ref:`multiple-processes` to circumvent such " "issues." msgstr "" -#: ../../howto/logging-cookbook.rst:4215 +#: ../../howto/logging-cookbook.rst:4228 msgid "Using loggers as attributes in a class or passing them as parameters" msgstr "" -#: ../../howto/logging-cookbook.rst:4217 +#: ../../howto/logging-cookbook.rst:4230 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 " @@ -5508,13 +5792,13 @@ msgid "" "module (and not the class) is the unit of software decomposition." msgstr "" -#: ../../howto/logging-cookbook.rst:4226 +#: ../../howto/logging-cookbook.rst:4239 msgid "" "Adding handlers other than :class:`~logging.NullHandler` to a logger in a " "library" msgstr "" -#: ../../howto/logging-cookbook.rst:4228 +#: ../../howto/logging-cookbook.rst:4241 msgid "" "Configuring logging by adding handlers, formatters and filters is the " "responsibility of the application developer, not the library developer. If " @@ -5522,11 +5806,11 @@ msgid "" "your loggers other than a :class:`~logging.NullHandler` instance." msgstr "" -#: ../../howto/logging-cookbook.rst:4234 +#: ../../howto/logging-cookbook.rst:4247 msgid "Creating a lot of loggers" msgstr "" -#: ../../howto/logging-cookbook.rst:4236 +#: ../../howto/logging-cookbook.rst:4249 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. " @@ -5537,38 +5821,38 @@ msgid "" "occasionally slightly more fine-grained than that)." msgstr "" -#: ../../howto/logging-cookbook.rst:4247 +#: ../../howto/logging-cookbook.rst:4260 msgid "Other resources" msgstr "其他資源" -#: ../../howto/logging-cookbook.rst:4251 +#: ../../howto/logging-cookbook.rst:4264 msgid "Module :mod:`logging`" msgstr ":mod:`logging` 模組" -#: ../../howto/logging-cookbook.rst:4252 +#: ../../howto/logging-cookbook.rst:4265 msgid "API reference for the logging module." msgstr "" -#: ../../howto/logging-cookbook.rst:4254 +#: ../../howto/logging-cookbook.rst:4267 msgid "Module :mod:`logging.config`" msgstr ":mod:`logging.config` 模組" -#: ../../howto/logging-cookbook.rst:4255 +#: ../../howto/logging-cookbook.rst:4268 msgid "Configuration API for the logging module." msgstr "" -#: ../../howto/logging-cookbook.rst:4257 +#: ../../howto/logging-cookbook.rst:4270 msgid "Module :mod:`logging.handlers`" msgstr ":mod:`logging.handlers` 模組" -#: ../../howto/logging-cookbook.rst:4258 +#: ../../howto/logging-cookbook.rst:4271 msgid "Useful handlers included with the logging module." msgstr "" -#: ../../howto/logging-cookbook.rst:4260 +#: ../../howto/logging-cookbook.rst:4273 msgid ":ref:`Basic Tutorial `" msgstr ":ref:`基礎教學 `" -#: ../../howto/logging-cookbook.rst:4262 +#: ../../howto/logging-cookbook.rst:4275 msgid ":ref:`Advanced Tutorial `" msgstr ":ref:`進階教學 `" diff --git a/howto/logging.po b/howto/logging.po index 42a56983bca..9337a55f282 100644 --- a/howto/logging.po +++ b/howto/logging.po @@ -1,14 +1,13 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # 文俊 高 , 2016 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-07-22 00:17+0000\n" +"POT-Creation-Date: 2025-09-08 15:25+0800\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-" @@ -63,10 +62,10 @@ msgstr "什麼時候使用 logging" #: ../../howto/logging.rst:30 msgid "" "You can access logging functionality by creating a logger via ``logger = " -"getLogger(__name__)``, and then calling the logger's :meth:`~Logger.debug`, :" -"meth:`~Logger.info`, :meth:`~Logger.warning`, :meth:`~Logger.error` and :" -"meth:`~Logger.critical` methods. To determine when to use logging, and to " -"see which logger methods to use when, see the table below. It states, for " +"getLogger(__name__)``, and then calling the " +"logger's :meth:`~Logger.debug`, :meth:`~Logger.info`, :meth:`~Logger.warning`, :meth:`~Logger.error` " +"and :meth:`~Logger.critical` methods. To determine when to use logging, and " +"to see which logger methods to use when, see the table below. It states, for " "each of a set of common tasks, the best tool to use for that task." msgstr "" @@ -121,7 +120,7 @@ msgstr "" #: ../../howto/logging.rst:60 msgid "Raise an exception" -msgstr "" +msgstr "引發一個例外" #: ../../howto/logging.rst:63 msgid "" @@ -131,8 +130,8 @@ msgstr "" #: ../../howto/logging.rst:63 msgid "" -"A logger's :meth:`~Logger.error`, :meth:`~Logger.exception` or :meth:" -"`~Logger.critical` method as appropriate for the specific error and " +"A logger's :meth:`~Logger.error`, :meth:`~Logger.exception` " +"or :meth:`~Logger.critical` method as appropriate for the specific error and " "application domain" msgstr "" @@ -243,8 +242,8 @@ msgstr "WARNING:root:Watch out!" 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 " -"the level and the description of the event provided in the logging call, i." -"e. 'Watch out!'. The actual output can be formatted quite flexibly if you " +"the level and the description of the event provided in the logging call, " +"i.e. 'Watch out!'. The actual output can be formatted quite flexibly if you " "need that; formatting options will also be explained later." msgstr "" @@ -252,7 +251,7 @@ msgstr "" msgid "" "Notice that in this example, we use functions directly on the ``logging`` " "module, like ``logging.debug``, rather than creating a logger and calling " -"functions on it. These functions operation on the root logger, but can be " +"functions on it. These functions operate on the root logger, but can be " "useful as they will call :func:`~logging.basicConfig` for you if it has not " "been called yet, like in this example. In larger programs you'll usually " "want to control the logging configuration explicitly however - so for that " @@ -276,13 +275,21 @@ msgstr "" msgid "" "import logging\n" "logger = logging.getLogger(__name__)\n" -"logging.basicConfig(filename='example.log', encoding='utf-8', level=logging." -"DEBUG)\n" +"logging.basicConfig(filename='example.log', encoding='utf-8', " +"level=logging.DEBUG)\n" "logger.debug('This message should go to the log file')\n" "logger.info('So should this')\n" "logger.warning('And this, too')\n" "logger.error('And non-ASCII stuff, too, like Øresund and Malmö')" msgstr "" +"import logging\n" +"logger = logging.getLogger(__name__)\n" +"logging.basicConfig(filename='example.log', encoding='utf-8', " +"level=logging.DEBUG)\n" +"logger.debug('This message should go to the log file')\n" +"logger.info('So should this')\n" +"logger.warning('And this, too')\n" +"logger.error('And non-ASCII stuff, too, like Øresund and Malmö')" #: ../../howto/logging.rst:151 msgid "" @@ -368,11 +375,11 @@ msgstr "" #: ../../howto/logging.rst:204 msgid "" -"logging.basicConfig(filename='example.log', filemode='w', level=logging." -"DEBUG)" +"logging.basicConfig(filename='example.log', filemode='w', " +"level=logging.DEBUG)" msgstr "" -"logging.basicConfig(filename='example.log', filemode='w', level=logging." -"DEBUG)" +"logging.basicConfig(filename='example.log', filemode='w', " +"level=logging.DEBUG)" #: ../../howto/logging.rst:206 msgid "" @@ -429,12 +436,18 @@ msgstr "" #: ../../howto/logging.rst:239 msgid "" "import logging\n" -"logging.basicConfig(format='%(levelname)s:%(message)s', level=logging." -"DEBUG)\n" +"logging.basicConfig(format='%(levelname)s:%(message)s', " +"level=logging.DEBUG)\n" "logging.debug('This message should appear on the console')\n" "logging.info('So should this')\n" "logging.warning('And this, too')" msgstr "" +"import logging\n" +"logging.basicConfig(format='%(levelname)s:%(message)s', " +"level=logging.DEBUG)\n" +"logging.debug('This message should appear on the console')\n" +"logging.info('So should this')\n" +"logging.warning('And this, too')" #: ../../howto/logging.rst:245 msgid "which would print:" @@ -473,6 +486,9 @@ msgid "" "logging.basicConfig(format='%(asctime)s %(message)s')\n" "logging.warning('is when this event was logged.')" msgstr "" +"import logging\n" +"logging.basicConfig(format='%(asctime)s %(message)s')\n" +"logging.warning('is when this event was logged.')" #: ../../howto/logging.rst:271 msgid "which should print something like this:" @@ -484,9 +500,9 @@ msgstr "" #: ../../howto/logging.rst:277 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::" +"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 @@ -496,6 +512,10 @@ msgid "" "%M:%S %p')\n" "logging.warning('is when this event was logged.')" msgstr "" +"import logging\n" +"logging.basicConfig(format='%(asctime)s %(message)s', datefmt='%m/%d/%Y %I:" +"%M:%S %p')\n" +"logging.warning('is when this event was logged.')" #: ../../howto/logging.rst:285 msgid "which would display something like this:" @@ -507,8 +527,8 @@ msgstr "" #: ../../howto/logging.rst:291 msgid "" -"The format of the *datefmt* argument is the same as supported by :func:`time." -"strftime`." +"The format of the *datefmt* argument is the same as supported " +"by :func:`time.strftime`." msgstr "" #: ../../howto/logging.rst:296 @@ -606,10 +626,11 @@ msgstr "" #: ../../howto/logging.rst:348 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`, :" -"func:`error` and :func:`critical`, which just call the same-named method of " -"the root logger. The functions and the methods have the same signatures. The " -"root logger's name is printed as 'root' in the logged output." +"logger used by the " +"functions :func:`debug`, :func:`info`, :func:`warning`, :func:`error` " +"and :func:`critical`, which just call the same-named method of the root " +"logger. The functions and the methods have the same signatures. The root " +"logger's name is printed as 'root' in the logged output." msgstr "" #: ../../howto/logging.rst:354 @@ -627,12 +648,12 @@ msgstr "" 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 " -"the tutorial examples. If you call the functions :func:`debug`, :func:" -"`info`, :func:`warning`, :func:`error` and :func:`critical`, they will check " -"to see if no destination is set; and if one is not set, they will set a " -"destination of the console (``sys.stderr``) and a default format for the " -"displayed message before delegating to the root logger to do the actual " -"message output." +"the tutorial examples. If you call the " +"functions :func:`debug`, :func:`info`, :func:`warning`, :func:`error` " +"and :func:`critical`, they will check to see if no destination is set; and " +"if one is not set, they will set a destination of the console " +"(``sys.stderr``) and a default format for the displayed message before " +"delegating to the root logger to do the actual message output." msgstr "" #: ../../howto/logging.rst:369 @@ -720,22 +741,23 @@ msgstr "" #: ../../howto/logging.rst:465 msgid "" -":meth:`Logger.debug`, :meth:`Logger.info`, :meth:`Logger.warning`, :meth:" -"`Logger.error`, and :meth:`Logger.critical` all create log records with a " -"message and a level that corresponds to their respective method names. The " -"message is actually a format string, which may contain the standard string " -"substitution syntax of ``%s``, ``%d``, ``%f``, and so on. The rest of their " -"arguments is a list of objects that correspond with the substitution fields " -"in the message. With regard to ``**kwargs``, the logging methods care only " -"about a keyword of ``exc_info`` and use it to determine whether to log " -"exception information." +":meth:`Logger.debug`, :meth:`Logger.info`, :meth:`Logger.warning`, :meth:`Logger.error`, " +"and :meth:`Logger.critical` all create log records with a message and a " +"level that corresponds to their respective method names. The message is " +"actually a format string, which may contain the standard string substitution " +"syntax of ``%s``, ``%d``, ``%f``, and so on. The rest of their arguments is " +"a list of objects that correspond with the substitution fields in the " +"message. With regard to ``**kwargs``, the logging methods care only about a " +"keyword of ``exc_info`` and use it to determine whether to log exception " +"information." msgstr "" #: ../../howto/logging.rst:475 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." +":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 @@ -800,8 +822,8 @@ msgstr "" #: ../../howto/logging.rst:522 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." +"handlers`); the tutorials use mainly :class:`StreamHandler` " +"and :class:`FileHandler` in its examples." msgstr "" #: ../../howto/logging.rst:526 @@ -836,10 +858,10 @@ msgstr "" #: ../../howto/logging.rst:543 msgid "" -"Application code should not directly instantiate and use instances of :class:" -"`Handler`. Instead, the :class:`Handler` class is a base class that defines " -"the interface that all handlers should have and establishes some default " -"behavior that child classes can use (or override)." +"Application code should not directly instantiate and use instances " +"of :class:`Handler`. Instead, the :class:`Handler` class is a base class " +"that defines the interface that all handlers should have and establishes " +"some default behavior that child classes can use (or override)." msgstr "" #: ../../howto/logging.rst:550 @@ -876,8 +898,8 @@ msgstr "" #: ../../howto/logging.rst:571 msgid "" "If the ``style`` is ``'%'``, the message format string uses ``%()s`` styled string substitution; the possible keys are documented in :" -"ref:`logrecord-attributes`. If the style is ``'{'``, the message format " +"key>)s`` styled string substitution; the possible keys are documented " +"in :ref:`logrecord-attributes`. If the style is ``'{'``, the message format " "string is assumed to be compatible with :meth:`str.format` (using keyword " "arguments), while if the style is ``'$'`` then the message format string " "should conform to what is expected by :meth:`string.Template.substitute`." @@ -931,8 +953,8 @@ msgstr "" #: ../../howto/logging.rst:607 msgid "" -"Creating a dictionary of configuration information and passing it to the :" -"func:`dictConfig` function." +"Creating a dictionary of configuration information and passing it to " +"the :func:`dictConfig` function." msgstr "" #: ../../howto/logging.rst:610 @@ -955,8 +977,8 @@ msgid "" "ch.setLevel(logging.DEBUG)\n" "\n" "# create formatter\n" -"formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - " -"%(message)s')\n" +"formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %" +"(message)s')\n" "\n" "# add formatter to ch\n" "ch.setFormatter(formatter)\n" @@ -1093,11 +1115,11 @@ msgstr "" 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 " -"using normal import mechanisms. Thus, you could use either :class:`~logging." -"handlers.WatchedFileHandler` (relative to the logging module) or ``mypackage." -"mymodule.MyHandler`` (for a class defined in package ``mypackage`` and " -"module ``mymodule``, where ``mypackage`` is available on the Python import " -"path)." +"using normal import mechanisms. Thus, you could use " +"either :class:`~logging.handlers.WatchedFileHandler` (relative to the " +"logging module) or ``mypackage.mymodule.MyHandler`` (for a class defined in " +"package ``mypackage`` and module ``mymodule``, where ``mypackage`` is " +"available on the Python import path)." msgstr "" #: ../../howto/logging.rst:743 @@ -1162,10 +1184,10 @@ msgstr "" #: ../../howto/logging.rst:789 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 " -"acts like a :class:`~logging.StreamHandler` which writes the event " -"description message to the current value of ``sys.stderr`` (therefore " +"The event is output using a 'handler of last resort', stored " +"in :data:`lastResort`. This internal handler is not associated with any " +"logger, and acts like a :class:`~logging.StreamHandler` which writes the " +"event description message to the current value of ``sys.stderr`` (therefore " "respecting any redirections which may be in effect). No formatting is done " "on the message - just the bare event description message is printed. The " "handler's level is set to ``WARNING``, so all events at this and greater " @@ -1222,13 +1244,13 @@ msgstr "" #: ../../howto/logging.rst:833 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 " -"to the top-level logger of the logging namespace used by the library (*if* " -"you want to prevent your library's logged events being output to ``sys." -"stderr`` in the absence of logging configuration). If all logging by a " -"library *foo* is done using loggers with names matching 'foo.x', 'foo.x.y', " -"etc. then the code::" +"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 to the top-level logger of the logging namespace " +"used by the library (*if* you want to prevent your library's logged events " +"being output to ``sys.stderr`` in the absence of logging configuration). If " +"all logging by a library *foo* is done using loggers with names matching " +"'foo.x', 'foo.x.y', etc. then the code::" msgstr "" #: ../../howto/logging.rst:841 @@ -1236,6 +1258,8 @@ msgid "" "import logging\n" "logging.getLogger('foo').addHandler(logging.NullHandler())" msgstr "" +"import logging\n" +"logging.getLogger('foo').addHandler(logging.NullHandler())" #: ../../howto/logging.rst:844 msgid "" @@ -1256,13 +1280,14 @@ msgstr "" #: ../../howto/logging.rst:855 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 " -"configuration of handlers is the prerogative of the application developer " -"who uses your library. The application developer knows their target audience " -"and what handlers are most appropriate for their application: if you add " -"handlers 'under the hood', you might well interfere with their ability to " -"carry out unit tests and deliver logs which suit their requirements." +"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 configuration of handlers is the prerogative of the application " +"developer who uses your library. The application developer knows their " +"target audience and what handlers are most appropriate for their " +"application: if you add handlers 'under the hood', you might well interfere " +"with their ability to carry out unit tests and deliver logs which suit their " +"requirements." msgstr "" #: ../../howto/logging.rst:866 @@ -1323,35 +1348,35 @@ msgstr "" #: ../../howto/logging.rst:897 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." +"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 msgid "" -"Logging messages are subjected to a dispatch mechanism through the use of :" -"dfn:`handlers`, which are instances of subclasses of the :class:`Handler` " -"class. Handlers are responsible for ensuring that a logged message (in the " -"form of a :class:`LogRecord`) ends up in a particular location (or set of " -"locations) which is useful for the target audience for that message (such as " -"end users, support desk staff, system administrators, developers). Handlers " -"are passed :class:`LogRecord` instances intended for particular " -"destinations. Each logger can have zero, one or more handlers associated " -"with it (via the :meth:`~Logger.addHandler` method of :class:`Logger`). In " -"addition to any handlers directly associated with a logger, *all handlers " -"associated with all ancestors of the logger* are called to dispatch the " -"message (unless the *propagate* flag for a logger is set to a false value, " -"at which point the passing to ancestor handlers stops)." +"Logging messages are subjected to a dispatch mechanism through the use " +"of :dfn:`handlers`, which are instances of subclasses of " +"the :class:`Handler` class. Handlers are responsible for ensuring that a " +"logged message (in the form of a :class:`LogRecord`) ends up in a particular " +"location (or set of locations) which is useful for the target audience for " +"that message (such as end users, support desk staff, system administrators, " +"developers). Handlers are passed :class:`LogRecord` instances intended for " +"particular destinations. Each logger can have zero, one or more handlers " +"associated with it (via the :meth:`~Logger.addHandler` method " +"of :class:`Logger`). In addition to any handlers directly associated with a " +"logger, *all handlers associated with all ancestors of the logger* are " +"called to dispatch the message (unless the *propagate* flag for a logger is " +"set to a false value, at which point the passing to ancestor handlers stops)." msgstr "" #: ../../howto/logging.rst:915 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. " -"If a handler decides to actually dispatch an event, the :meth:`~Handler." -"emit` method is used to send the message to its destination. Most user-" -"defined subclasses of :class:`Handler` will need to override this :meth:" -"`~Handler.emit`." +"If a handler decides to actually dispatch an event, " +"the :meth:`~Handler.emit` method is used to send the message to its " +"destination. Most user-defined subclasses of :class:`Handler` will need to " +"override this :meth:`~Handler.emit`." msgstr "" #: ../../howto/logging.rst:924 @@ -1395,8 +1420,8 @@ msgstr "" 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 " -"directly. Instead, use :class:`~handlers.RotatingFileHandler` or :class:" -"`~handlers.TimedRotatingFileHandler`." +"directly. Instead, use :class:`~handlers.RotatingFileHandler` " +"or :class:`~handlers.TimedRotatingFileHandler`." msgstr "" #: ../../howto/logging.rst:954 @@ -1437,8 +1462,8 @@ msgstr "" #: ../../howto/logging.rst:972 msgid "" -":class:`~handlers.NTEventLogHandler` instances send messages to a Windows " -"NT/2000/XP event log." +":class:`~handlers.NTEventLogHandler` instances send messages to a Windows NT/" +"2000/XP event log." msgstr "" #: ../../howto/logging.rst:975 @@ -1494,27 +1519,27 @@ msgstr "" #: ../../howto/logging.rst:1006 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." +"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 msgid "" -"For formatting multiple messages in a batch, instances of :class:" -"`BufferingFormatter` can be used. In addition to the format string (which is " -"applied to each message in the batch), there is provision for header and " -"trailer format strings." +"For formatting multiple messages in a batch, instances " +"of :class:`BufferingFormatter` can be used. In addition to the format string " +"(which is applied to each message in the batch), there is provision for " +"header and trailer format strings." msgstr "" #: ../../howto/logging.rst:1015 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:" -"`Handler` instances (through their :meth:`~Handler.addFilter` method). " -"Before deciding to process a message further, both loggers and handlers " -"consult all their filters for permission. If any filter returns a false " -"value, the message is not processed further." +"instances of :class:`Filter` can be added to both :class:`Logger` " +"and :class:`Handler` instances (through their :meth:`~Handler.addFilter` " +"method). Before deciding to process a message further, both loggers and " +"handlers consult all their filters for permission. If any filter returns a " +"false value, the message is not processed further." msgstr "" #: ../../howto/logging.rst:1022 @@ -1540,16 +1565,16 @@ msgstr "" msgid "" ":class:`SystemExit` and :class:`KeyboardInterrupt` exceptions are never " "swallowed. Other exceptions which occur during the :meth:`~Handler.emit` " -"method of a :class:`Handler` subclass are passed to its :meth:`~Handler." -"handleError` method." +"method of a :class:`Handler` subclass are passed to " +"its :meth:`~Handler.handleError` method." msgstr "" #: ../../howto/logging.rst:1042 msgid "" -"The default implementation of :meth:`~Handler.handleError` in :class:" -"`Handler` checks to see if a module-level variable, :data:`raiseExceptions`, " -"is set. If set, a traceback is printed to :data:`sys.stderr`. If not set, " -"the exception is swallowed." +"The default implementation of :meth:`~Handler.handleError` " +"in :class:`Handler` checks to see if a module-level " +"variable, :data:`raiseExceptions`, is set. If set, a traceback is printed " +"to :data:`sys.stderr`. If not set, the exception is swallowed." msgstr "" #: ../../howto/logging.rst:1048 @@ -1568,12 +1593,12 @@ msgstr "" 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 " -"possibility. You can pass an arbitrary object as a message, and its :meth:" -"`~object.__str__` method will be called when the logging system needs to " -"convert it to a string representation. In fact, if you want to, you can " -"avoid computing a string representation altogether - for example, the :class:" -"`~handlers.SocketHandler` emits an event by pickling it and sending it over " -"the wire." +"possibility. You can pass an arbitrary object as a message, and " +"its :meth:`~object.__str__` method will be called when the logging system " +"needs to convert it to a string representation. In fact, if you want to, you " +"can avoid computing a string representation altogether - for example, " +"the :class:`~handlers.SocketHandler` emits an event by pickling it and " +"sending it over the wire." msgstr "" #: ../../howto/logging.rst:1071 @@ -1585,10 +1610,10 @@ msgid "" "Formatting of message arguments is deferred until it cannot be avoided. " "However, computing the arguments passed to the logging method can also be " "expensive, and you may want to avoid doing it if the logger will just throw " -"away your event. To decide what to do, you can call the :meth:`~Logger." -"isEnabledFor` method which takes a level argument and returns true if the " -"event would be created by the Logger for that level of call. You can write " -"code like this::" +"away your event. To decide what to do, you can call " +"the :meth:`~Logger.isEnabledFor` method which takes a level argument and " +"returns true if the event would be created by the Logger for that level of " +"call. You can write code like this::" msgstr "" #: ../../howto/logging.rst:1081 @@ -1638,9 +1663,10 @@ msgstr "" #: ../../howto/logging.rst:1105 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`)." +"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 diff --git a/howto/mro.po b/howto/mro.po index 1f107b45fd2..a480b153b7e 100644 --- a/howto/mro.po +++ b/howto/mro.po @@ -1,11 +1,11 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# 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.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2025-01-22 00:13+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" @@ -19,7 +19,7 @@ msgstr "" #: ../../howto/mro.rst:4 msgid "The Python 2.3 Method Resolution Order" -msgstr "" +msgstr "Python 2.3 方法解析順序" #: ../../howto/mro.rst:8 msgid "" @@ -27,10 +27,13 @@ msgid "" "documentation. The Method Resolution Order discussed here was *introduced* " "in Python 2.3, but it is still used in later versions -- including Python 3." msgstr "" +"這是一份歷史文件,作為正式文件的附錄提供。此處討論的方法解析順序 (Method " +"Resolution Order) 是在 Python 2.3 中 *引入* 的,但仍在後續版本中使用,包" +"括 Python 3。" #: ../../howto/mro.rst:13 msgid "By `Michele Simionato `__." -msgstr "" +msgstr "作者:`Michele Simionato `__。" #: ../../howto/mro.rst:0 msgid "Abstract" @@ -44,10 +47,13 @@ msgid "" "not aware of other publicly available documents with the same scope, " "therefore it should be useful.*" msgstr "" +"*此文件適用於想要了解 Python 2.3 中使用的 C3 方法解析順序的 Python 程式設計" +"師。雖然它不是為初學者準備的,但透過許多實際範例進行教學。我沒找到其他具有相" +"同範圍的公開文件,因此這應該很有用。*" #: ../../howto/mro.rst:23 msgid "Disclaimer:" -msgstr "" +msgstr "免責聲明:" #: ../../howto/mro.rst:25 msgid "" @@ -56,10 +62,12 @@ msgid "" "follows* should *be correct, but I don't give any warranty. Use it at your " "own risk and peril!*" msgstr "" +"*我根據 Python 2.3 授權條款將此文件捐贈給 Python 軟體基金會。如同往常,我警告" +"讀者,以下內容 *應該* 是正確的,但我不提供任何保證。使用時風險自負!*" #: ../../howto/mro.rst:30 msgid "Acknowledgments:" -msgstr "致謝" +msgstr "致謝:" #: ../../howto/mro.rst:32 msgid "" @@ -70,14 +78,18 @@ msgid "" "Rossum who enthusiastically added this document to the official Python 2.3 " "home-page.*" msgstr "" +"*感謝 Python 郵件列表中所有給予我支持的人。Paul Foley 指出了各種不精確之處,並" +"促使我加入了區域優先順序(local precedence ordering)的部分。David Goodger 協" +"助 reStructuredText 的格式化。David Mertz 協助編輯。最後,Guido van Rossum 熱" +"情地將此文件加入到 Python 2.3 官方首頁。*" #: ../../howto/mro.rst:40 msgid "The beginning" -msgstr "" +msgstr "開端" #: ../../howto/mro.rst:42 msgid "*Felix qui potuit rerum cognoscere causas* -- Virgilius" -msgstr "" +msgstr "*Felix qui potuit rerum cognoscere causas* -- Virgilius" #: ../../howto/mro.rst:44 msgid "" @@ -91,6 +103,12 @@ msgid "" "readable discussion of the C3 algorithm for Pythonistas who want to " "understand the reasons for the change." msgstr "" +"一切始於 Samuele Pedroni 向 Python 開發郵件列表發表的貼文 [#]_。在他的貼文" +"中,Samuele 指出 Python 2.2 的方法解析順序不具單調性(monotonic),並提議以 " +"C3 方法解析順序來取代。Guido 同意他的論點,因此 Python 2.3 現在使用 C3。C3 方" +"法本身與 Python 無關,因為它是由研究 Dylan 語言的人所發明,並在一篇針對 Lisp " +"程式設計師的論文 [#]_ 中描述。本文為想要了解此變更原因的 Python 程式設計師提" +"供了 C3 演算法(希望是)易讀的討論。" #: ../../howto/mro.rst:55 msgid "" @@ -103,10 +121,15 @@ msgid "" "differs from the Python 2.2 method resolution order are so rare that no real " "breaking of code is expected. Therefore:" msgstr "" +"首先讓我指出,我要說的僅適用於 Python 2.2 中引入的 *新式類別(new style " +"classes)*:*經典類別(classic classes)* 維持其舊有的方法解析順序,即深度" +"優先然後由左至右。因此,經典類別的舊程式碼不會受到影響;即使原則上 Python 2.2 " +"新式類別的程式碼可能會受影響,但實際上 C3 解析順序與 Python 2.2 方法解析順序不" +"同的情況極為罕見,因此預期不會真正破壞程式碼。因此:" #: ../../howto/mro.rst:64 msgid "*Don't be scared!*" -msgstr "" +msgstr "*別怕!*" #: ../../howto/mro.rst:66 msgid "" @@ -116,10 +139,13 @@ msgid "" "know how multiple inheritance works, then this paper is for you. The good " "news is that things are not as complicated as you might expect." msgstr "" +"此外,除非你大量使用多重繼承且有複雜的類別階層,否則你無需了解 C3 演算法,可" +"以輕鬆跳過本文。另一方面,如果你真的想知道多重繼承如何運作,那麼本文就是為你" +"準備的。好消息是,事情並不像你想像的那樣複雜。" #: ../../howto/mro.rst:73 msgid "Let me begin with some basic definitions." -msgstr "" +msgstr "讓我從一些基本定義開始。" #: ../../howto/mro.rst:75 msgid "" @@ -127,6 +153,8 @@ msgid "" "trivial task to specify the order in which methods are overridden, i.e. to " "specify the order of the ancestors of C." msgstr "" +"給定複雜多重繼承階層中的類別 C,要指定方法被覆寫(override)的順序並非易事," +"也就是要指定 C 的祖先順序。" #: ../../howto/mro.rst:79 msgid "" @@ -134,6 +162,8 @@ msgid "" "from the nearest ancestor to the furthest, is called the class precedence " "list or the *linearization* of C." msgstr "" +"類別 C 的祖先串列(包含類別本身),從最近的祖先到最遠的祖先排序,稱為類別優先" +"串列(class precedence list)或 C 的\\ *線性化(linearization)*。" #: ../../howto/mro.rst:83 msgid "" @@ -141,6 +171,8 @@ msgid "" "linearization. In the Python literature, the idiom \"the MRO of C\" is also " "used as a synonymous for the linearization of the class C." msgstr "" +"*方法解析順序 (Method Resolution Order, MRO)* 是建構線性化的一組規則。在 " +"Python 文獻中,習慣用語「C 的 MRO」也是 C 類別線性化的同義詞。" #: ../../howto/mro.rst:88 msgid "" @@ -151,6 +183,10 @@ msgid "" "it is more difficult to construct a linearization that respects *local " "precedence ordering* and *monotonicity*." msgstr "" +"例如,在單一繼承階層的情況下,如果 C 是 C1 的子類別,而 C1 是 C2 的子類別,那" +"麼 C 的線性化就是串列 [C, C1, C2]。然而,在多重繼承階層中,線性化的建構更加複" +"雜,因為要建構一個遵守\\ *區域優先順序(local precedence ordering)* 和\\ *" +"單調性(monotonicity)* 的線性化更加困難。" #: ../../howto/mro.rst:96 msgid "" @@ -162,6 +198,10 @@ msgid "" "potentially introducing very subtle bugs. Examples where this happens will " "be shown later." msgstr "" +"我將在稍後討論區域優先順序,但可以在此給出單調性的定義。當以下條件為真時," +"MRO 具有單調性:*如果 C1 在 C 的線性化中先於 C2,那麼 C1 在 C 的任何子類別的" +"線性化中也先於 C2*。否則,衍生新類別這個看似無害的操作可能會改變方法的解析順" +"序,進而引入非常微妙的錯誤。稍後將展示發生這種情況的範例。" #: ../../howto/mro.rst:104 msgid "" @@ -169,10 +209,12 @@ msgid "" "hierarchies, where it is not possible to derive a class such that its " "linearization respects all the desired properties." msgstr "" +"並非所有類別都能進行線性化。在複雜的階層結構中,有些情況下無法衍生出一個類別," +"使其線性化遵守所有所需的屬性。" #: ../../howto/mro.rst:108 msgid "Here I give an example of this situation. Consider the hierarchy" -msgstr "" +msgstr "以下是這種情況的範例。考慮以下階層結構" #: ../../howto/mro.rst:116 msgid "" @@ -180,6 +222,8 @@ msgid "" "denoted with O the ``object`` class, which is the beginning of any hierarchy " "for new style classes:" msgstr "" +"可以用以下繼承圖來表示,其中我用 O 標示 ``object`` 類別,這是新式類別的任何階" +"層結構的起點:" #: ../../howto/mro.rst:120 msgid "" @@ -211,6 +255,8 @@ msgid "" "X precedes Y in A, but Y precedes X in B, therefore the method resolution " "order would be ambiguous in C." msgstr "" +"在這種情況下,不可能從 A 和 B 衍生出新的類別 C,因為 X 在 A 中先於 Y,但 Y 在 " +"B 中先於 X,因此 C 的方法解析順序會產生歧義。" #: ../../howto/mro.rst:137 msgid "" @@ -219,16 +265,19 @@ msgid "" "hierarchies. Python 2.2 instead does not raise an exception, but chooses an " "*ad hoc* ordering (CABXYO in this case)." msgstr "" +"Python 2.3 在這種情況下會引發例外(TypeError: MRO conflict among bases Y, X)," +"防止程式設計師建立有歧義的階層結構。Python 2.2 則不會引發例外,而是選擇 *ad " +"hoc* 順序(在這種情況下為 CABXYO)。" #: ../../howto/mro.rst:143 msgid "The C3 Method Resolution Order" -msgstr "" +msgstr "C3 方法解析順序" #: ../../howto/mro.rst:145 msgid "" "Let me introduce a few simple notations which will be useful for the " "following discussion. I will use the shortcut notation::" -msgstr "" +msgstr "讓我介紹一些簡單的符號標示法,這對以下討論很有用。我將使用簡寫符號: ::" #: ../../howto/mro.rst:148 msgid "C1 C2 ... CN" @@ -236,11 +285,11 @@ msgstr "C1 C2 ... CN" #: ../../howto/mro.rst:150 msgid "to indicate the list of classes [C1, C2, ... , CN]." -msgstr "" +msgstr "用來表示類別串列 [C1, C2, ... , CN]。" #: ../../howto/mro.rst:152 msgid "The *head* of the list is its first element::" -msgstr "" +msgstr "串列的 *head*\\ (頭部)是其第一個元素: ::" #: ../../howto/mro.rst:154 msgid "head = C1" @@ -248,7 +297,7 @@ msgstr "head = C1" #: ../../howto/mro.rst:156 msgid "whereas the *tail* is the rest of the list::" -msgstr "" +msgstr "而 *tail*\\ (尾部)是串列的其餘部分: ::" #: ../../howto/mro.rst:158 msgid "tail = C2 ... CN." @@ -256,7 +305,7 @@ msgstr "tail = C2 ... CN." #: ../../howto/mro.rst:160 msgid "I shall also use the notation::" -msgstr "" +msgstr "我還將使用以下符號: ::" #: ../../howto/mro.rst:162 msgid "C + (C1 C2 ... CN) = C C1 C2 ... CN" @@ -264,11 +313,11 @@ msgstr "C + (C1 C2 ... CN) = C C1 C2 ... CN" #: ../../howto/mro.rst:164 msgid "to denote the sum of the lists [C] + [C1, C2, ... ,CN]." -msgstr "" +msgstr "標示串列的和 [C] + [C1, C2, ..., CN]。" #: ../../howto/mro.rst:166 msgid "Now I can explain how the MRO works in Python 2.3." -msgstr "" +msgstr "現在我就可以繼續解釋 MRO 在 Python 2.3 中的運作方式。" #: ../../howto/mro.rst:168 msgid "" @@ -276,16 +325,18 @@ msgid "" "from the base classes B1, B2, ... , BN. We want to compute the " "linearization L[C] of the class C. The rule is the following:" msgstr "" +"考慮多重繼承階層結構中的類別 C,C 從基底類別 B1、B2、...、BN 繼承。我們想計算" +"類別 C 的線性化 L[C]。規則如下:" #: ../../howto/mro.rst:173 msgid "" "*the linearization of C is the sum of C plus the merge of the linearizations " "of the parents and the list of the parents.*" -msgstr "" +msgstr "*C 的線性化是 C 加上父類別線性化的合併以及父類別串列的和。*" #: ../../howto/mro.rst:176 msgid "In symbolic notation::" -msgstr "" +msgstr "用符號標示: ::" #: ../../howto/mro.rst:178 msgid "L[C(B1 ... BN)] = C + merge(L[B1] ... L[BN], B1 ... BN)" @@ -296,6 +347,7 @@ msgid "" "In particular, if C is the ``object`` class, which has no parents, the " "linearization is trivial::" msgstr "" +"特別是如果 C 是沒有父類別的 ``object`` 類別,那麼線性化是簡單的:" #: ../../howto/mro.rst:183 msgid "L[object] = object." @@ -305,7 +357,7 @@ msgstr "L[object] = object." msgid "" "However, in general one has to compute the merge according to the following " "prescription:" -msgstr "" +msgstr "然而,一般來說必須根據以下規則來計算合併:" #: ../../howto/mro.rst:188 msgid "" @@ -317,6 +369,10 @@ msgid "" "this case, it is impossible to construct the merge, Python 2.3 will refuse " "to create the class C and will raise an exception.*" msgstr "" +"*取第一個串列的頭部,即 L[B1][0];如果此頭部不在其他任何串列的尾部中,那麼將" +"它加入到 C 的線性化中,並從合併中的所有串列移除它;否則查看下一個串列的頭部," +"如果它是一個好的頭部就取它。然後重複此操作,直到所有類別都被移除或無法找到好的" +"頭部。在後面這種情況下,無法建構合併,Python 2.3 將拒絕建立類別 C 並引發例外。*" #: ../../howto/mro.rst:197 msgid "" @@ -325,12 +381,16 @@ msgid "" "preserved (as in the example of serious order disagreement discussed above) " "then the merge cannot be computed." msgstr "" +"此規則確保合併操作\\ *保留*\\ 順序(如果順序可以被保留)。另一方面,如果無法保" +"留順序(如上面討論的嚴重順序分歧的範例),則無法計算合併。" #: ../../howto/mro.rst:202 msgid "" "The computation of the merge is trivial if C has only one parent (single " "inheritance); in this case::" msgstr "" +"如果 C 只有一個父類別(單一繼承),則合併的計算是微不足道的。在這種情況" +"下: ::" #: ../../howto/mro.rst:205 msgid "L[C(B)] = C + merge(L[B],B) = C + L[B]" @@ -341,6 +401,7 @@ msgid "" "However, in the case of multiple inheritance things are more cumbersome and " "I don't expect you can understand the rule without a couple of examples ;-)" msgstr "" +"但是,在多重繼承的情況下,事情更加複雜,我不指望你能在沒有幾個範例的情況下理解這個規則 ;-)" #: ../../howto/mro.rst:212 msgid "Examples" @@ -348,11 +409,11 @@ msgstr "範例" #: ../../howto/mro.rst:214 msgid "First example. Consider the following hierarchy:" -msgstr "" +msgstr "第一個例子,請參考以下階層結構:" #: ../../howto/mro.rst:224 msgid "In this case the inheritance graph can be drawn as:" -msgstr "" +msgstr "在這種情況下,繼承圖可以繪製為:" #: ../../howto/mro.rst:226 msgid "" @@ -378,10 +439,31 @@ msgid "" "Level 0 0 | A | (more specialized)\n" " ---" msgstr "" +" 6\n" +" ---\n" +"Level 3 | O | (更廣泛)\n" +" / --- \\\n" +" / | \\ |\n" +" / | \\ |\n" +" / | \\ |\n" +" --- --- --- |\n" +"Level 2 3 | D | 4| E | | F | 5 |\n" +" --- --- --- |\n" +" \\ \\ _ / | |\n" +" \\ / \\ _ | |\n" +" \\ / \\ | |\n" +" --- --- |\n" +"Level 1 1 | B | | C | 2 |\n" +" --- --- |\n" +" \\ / |\n" +" \\ / \\ /\n" +" ---\n" +"Level 0 0 | A | (更專精)\n" +" ---" #: ../../howto/mro.rst:251 msgid "The linearizations of O,D,E and F are trivial::" -msgstr "" +msgstr "O、D、E 和 F 的線性化很簡單: ::" #: ../../howto/mro.rst:253 msgid "" @@ -390,10 +472,14 @@ msgid "" "L[E] = E O\n" "L[F] = F O" msgstr "" +"L[O] = O\n" +"L[D] = D O\n" +"L[E] = E O\n" +"L[F] = F O" #: ../../howto/mro.rst:258 msgid "The linearization of B can be computed as::" -msgstr "" +msgstr "B 的線性化可以計算為: ::" #: ../../howto/mro.rst:260 msgid "L[B] = B + merge(DO, EO, DE)" @@ -407,6 +493,10 @@ msgid "" "the next sequence. Then we see that E is a good head; we take it and we are " "reduced to compute ``merge(O,O)`` which gives O. Therefore::" msgstr "" +"我們看到 D 是一個好的頭部,因此我們取它,並將其簡化為 ``merge(O,EO,E)``。現" +"在 O 不是一個好的頭部,因為它位於序列 EO 的尾部。在這種情況下,規則說我們必須" +"跳到下一個序列。然後我們看到 E 是一個好的頭部;我們取它,並簡化為計算 " +"``merge(O, O)`` 得出 O。因此: ::" #: ../../howto/mro.rst:268 msgid "L[B] = B D E O" @@ -414,7 +504,7 @@ msgstr "L[B] = B D E O" #: ../../howto/mro.rst:270 msgid "Using the same procedure one finds::" -msgstr "" +msgstr "使用相同的程序可以發現: ::" #: ../../howto/mro.rst:272 msgid "" @@ -430,7 +520,7 @@ msgstr "" #: ../../howto/mro.rst:277 msgid "Now we can compute::" -msgstr "" +msgstr "現在我們可以計算出: ::" #: ../../howto/mro.rst:279 msgid "" @@ -457,19 +547,23 @@ msgid "" "specialized classes) have higher precedence (see the inheritance graph). " "However, this is not the general case." msgstr "" +"在此範例中,線性化是根據繼承層級以相當不錯的方式排序的,因為較低層級(即更專" +"精的類別)具有更高的優先級(請參見繼承圖)。但是這不是一般情況。" #: ../../howto/mro.rst:292 msgid "" "I leave as an exercise for the reader to compute the linearization for my " "second example:" -msgstr "" +msgstr "第二個範例的線性化之計算我留給讀者當作練習:" #: ../../howto/mro.rst:303 msgid "" -"The only difference with the previous example is the change B(D,E) --> B(E," -"D); however even such a little modification completely changes the ordering " -"of the hierarchy:" +"The only difference with the previous example is the change B(D,E) --> " +"B(E,D); however even such a little modification completely changes the " +"ordering of the hierarchy:" msgstr "" +"與上一個範例的唯一區別是 B(D,E) --> B(E,D) 的變化;但是即使是這樣小小的修改,也完" +"全改變了階層結構的順序:" #: ../../howto/mro.rst:307 msgid "" @@ -523,6 +617,8 @@ msgid "" "precedes the class C, which is in the first level of the hierarchy, i.e. E " "is more specialized than C, even if it is in a higher level." msgstr "" +"請注意,階層結構的第二層中的類別 E,先於階層結構第一層的類別 C,即 E 比 C 更" +"專精,即使它處於更高層。" #: ../../howto/mro.rst:336 msgid "" @@ -530,6 +626,8 @@ msgid "" "case it coincides with the Python 2.3 linearization. It is enough to invoke " "the :meth:`~type.mro` method of class A:" msgstr "" +"懶惰的程式設計師可以直接從 Python 2.2 取得 MRO,因為在這種情況下,它與 " +"Python 2.3 線性化一致。呼叫類別 A 的 :meth:`~type.mro` 方法就足夠了:" #: ../../howto/mro.rst:345 msgid "" @@ -537,6 +635,8 @@ msgid "" "involving a serious order disagreement. In this case, it is straightforward " "to compute the linearizations of O, X, Y, A and B:" msgstr "" +"最後,讓我考慮第一部分中討論的範例,涉及嚴重的順序分歧。在這種情況下,計算 " +"O、X、Y、A 和 B 的線性化是很簡單的:" #: ../../howto/mro.rst:349 msgid "" @@ -556,7 +656,7 @@ msgstr "" msgid "" "However, it is impossible to compute the linearization for a class C that " "inherits from A and B::" -msgstr "" +msgstr "但是,我們不可能計算出從 A 和 B 繼承的類別 C 的線性化: ::" #: ../../howto/mro.rst:360 msgid "" @@ -575,10 +675,13 @@ msgid "" "and the C3 algorithm stops. Python 2.3 raises an error and refuses to " "create the class C." msgstr "" +"在這一點上,我們無法合併串列 XYO 和 YXO,因為 X 位於 YXO 的尾部,而 Y 則位於 " +"XYO 的尾部:因此,沒有好的頭部,C3 演算法停止。Python 2.3 會引發錯誤而拒絕建" +"立類別 C。" #: ../../howto/mro.rst:370 msgid "Bad Method Resolution Orders" -msgstr "" +msgstr "不良的方法解析順序" #: ../../howto/mro.rst:372 msgid "" @@ -587,16 +690,18 @@ msgid "" "both the MRO for classic classes and the MRO for new style classes in Python " "2.2 are bad." msgstr "" +"當 MRO 打破諸如區域優先順序和單調性之類的基本屬性時,MRO 是\\ *不良*\\ 的。在本節" +"中,我將證明經典類別的 MRO 和 Python 2.2 的新式類別的 MRO 都是不好的。" #: ../../howto/mro.rst:377 msgid "" "It is easier to start with the local precedence ordering. Consider the " "following example:" -msgstr "" +msgstr "從區域優先順序開始更容易。考慮以下範例:" #: ../../howto/mro.rst:384 msgid "with inheritance diagram" -msgstr "" +msgstr "包含繼承圖" #: ../../howto/mro.rst:386 msgid "" @@ -610,13 +715,25 @@ msgid "" "\n" " (buy eggs or spam ?)" msgstr "" +" O\n" +" |\n" +"(buy spam) F\n" +" | \\\n" +" | E (buy eggs)\n" +" | /\n" +" G\n" +"\n" +" (buy eggs or spam ?)" #: ../../howto/mro.rst:399 msgid "" "We see that class G inherits from F and E, with F *before* E: therefore we " -"would expect the attribute *G.remember2buy* to be inherited by *F." -"remember2buy* and not by *E.remember2buy*: nevertheless Python 2.2 gives" +"would expect the attribute *G.remember2buy* to be inherited by " +"*F.remember2buy* and not by *E.remember2buy*: nevertheless Python 2.2 gives" msgstr "" +"我們看到類別 G 從 F 和 E 繼承,F 在 E *之前*:因此,我們希望屬性 " +"*G.remember2buy* 被 *F.remember2buy* 繼承,而不是 *E.remember2buy*:儘管如" +"此,Python 2.2 給出" #: ../../howto/mro.rst:407 msgid "" @@ -624,10 +741,12 @@ msgid "" "precedence list, i.e. the list of the parents of G, is not preserved in the " "Python 2.2 linearization of G::" msgstr "" +"這是區域優先順序的破壞,因為區域優先串列中的順序,即 G 的父類別串列,在 " +"Python 2.2 的 G 的線性化中不被保留:" #: ../../howto/mro.rst:411 msgid "L[G,P22]= G E F object # F *follows* E" -msgstr "L[G,P22]= G E F object # F *follows* E" +msgstr "L[G,P22]= G E F object # F *跟隨* E" #: ../../howto/mro.rst:413 msgid "" @@ -637,11 +756,14 @@ msgid "" "quite non-intuitive and error prone. This is particularly true since it is " "a different from old style classes:" msgstr "" +"有人可能會說,F 在 Python 2.2 線性化中跟隨 E 的原因是 F 比 E 特化程度較低," +"因為 F 是 E 的超類別;然而,局部優先順序的破壞非常不直覺且容易出錯。尤其如" +"此,因為它與舊式類別不同:" #: ../../howto/mro.rst:425 msgid "" "In this case the MRO is GFEF and the local precedence ordering is preserved." -msgstr "" +msgstr "在這種情況下,MRO 是 GFEF 並且保留區域優先順序。" #: ../../howto/mro.rst:428 msgid "" @@ -651,6 +773,9 @@ msgid "" "effectively stopping the programmer from generating ambiguous hierarchies. " "The reason for that is that the C3 algorithm fails when the merge::" msgstr "" +"通常應避免諸如上一個等階層結構,因為尚不清楚 F 是否應覆蓋 E 或反過來。 " +"Python 2.3 透過在建立類別 G 時引發例外來解決歧義,從而有效地阻止程式設計師產" +"生模棱兩可的階層結構。原因是當這樣合併時 C3 演算法會失敗: ::" #: ../../howto/mro.rst:435 msgid "merge(FO,EFO,FE)" @@ -660,7 +785,7 @@ msgstr "merge(FO,EFO,FE)" msgid "" "cannot be computed, because F is in the tail of EFO and E is in the tail of " "FE." -msgstr "" +msgstr "無法計算,因為 F 在 EFO 的尾部,而 E 在 FE 的尾部。" #: ../../howto/mro.rst:440 msgid "" @@ -668,6 +793,8 @@ msgid "" "from E and F (the more specific first) and not from F and E; in this case " "the MRO is GEF without any doubt." msgstr "" +"真正的解決方案是設計一個非歧義的階層結構,即源自 E 和 F(更具體的第一)而不" +"是 F 和 E;在這種情況下,MRO 毫無疑問是 GEF。" #: ../../howto/mro.rst:444 msgid "" @@ -680,12 +807,20 @@ msgid "" " G\n" " (eggs, no doubt)" msgstr "" +" O\n" +" |\n" +" F (spam)\n" +" / |\n" +"(eggs) E |\n" +" \\ |\n" +" G\n" +" (eggs, no doubt)" #: ../../howto/mro.rst:456 msgid "" "Python 2.3 forces the programmer to write good hierarchies (or, at least, " "less error-prone ones)." -msgstr "" +msgstr "Python 2.3 迫使程式設計師要編寫良好(或至少較不易於出錯)的階層結構。" #: ../../howto/mro.rst:459 msgid "" @@ -693,29 +828,32 @@ msgid "" "enough to recognize obvious mistakes, as the duplication of classes in the " "list of parents:" msgstr "" +"與之相關的是,我指出 Python 2.3 演算法足夠聰明,可以識別出明顯的錯誤,例" +"如父類別串列中類別的重複:" #: ../../howto/mro.rst:469 msgid "" "Python 2.2 (both for classic classes and new style classes) in this " "situation, would not raise any exception." msgstr "" +"在這種情況下,Python 2.2(無論是經典類別還是新式類別)不會引發任何例外。" #: ../../howto/mro.rst:472 msgid "" "Finally, I would like to point out two lessons we have learned from this " "example:" -msgstr "" +msgstr "最後,我想指出我們從這個範例中學到的兩個教訓:" #: ../../howto/mro.rst:475 msgid "" "despite the name, the MRO determines the resolution order of attributes, not " "only of methods;" -msgstr "" +msgstr "儘管名稱如此,但不僅是方法的解析順序,MRO 也決定了屬性的解析順序;" #: ../../howto/mro.rst:478 msgid "" "the default food for Pythonistas is spam ! (but you already knew that ;-)" -msgstr "" +msgstr "Pythonistas 的預設食物是 spam!(但是你已經知道 ;-)" #: ../../howto/mro.rst:481 msgid "" @@ -723,12 +861,14 @@ msgid "" "the issue of monotonicity. My goal is to show that neither the MRO for " "classic classes nor that for Python 2.2 new style classes is monotonic." msgstr "" +"在討論了區域優先順序的問題之後,現在讓我考慮單調性問題。我的目標是表明經典類" +"別的 MRO 或 Python 2.2 新式類別都不是單調的。" #: ../../howto/mro.rst:486 msgid "" "To prove that the MRO for classic classes is non-monotonic is rather " "trivial, it is enough to look at the diamond diagram:" -msgstr "" +msgstr "為了證明經典類別的 MRO 是非單調的,查看鑽石圖就足夠了:" #: ../../howto/mro.rst:489 msgid "" @@ -750,19 +890,21 @@ msgstr "" #: ../../howto/mro.rst:500 msgid "One easily discerns the inconsistency::" -msgstr "" +msgstr "可以很容易地辨別出這種不一致:" #: ../../howto/mro.rst:502 msgid "" "L[B,P21] = B C # B precedes C : B's methods win\n" "L[D,P21] = D A C B C # B follows C : C's methods win!" msgstr "" +"L[B,P21] = B C # B 優先於 C:B 的方法勝出\n" +"L[D,P21] = D A C B C # B 跟隨 C:C 的方法勝出!" #: ../../howto/mro.rst:505 msgid "" "On the other hand, there are no problems with the Python 2.2 and 2.3 MROs, " "they give both::" -msgstr "" +msgstr "另一方面,Python 2.2 和 2.3 MRO 沒有問題,它們兩個都給出了: ::" #: ../../howto/mro.rst:508 msgid "L[D] = D A B C" @@ -775,6 +917,9 @@ msgid "" "all new style classes inherit from ``object``, therefore diamonds are " "unavoidable and inconsistencies shows up in every multiple inheritance graph." msgstr "" +"Guido 在他的文章 [#]_ 中指出,經典的 MRO 在實踐中還不錯,因為通常可以避開經典" +"類別的鑽石圖。但是所有新式類別都從 ``object`` 繼承,因此鑽石圖是不可避免的," +"並且在每個多重繼承圖中都出現了不一致之處。" #: ../../howto/mro.rst:516 msgid "" @@ -782,6 +927,8 @@ msgid "" "impossible. The following example, originally provided by Samuele Pedroni, " "shows that the MRO of Python 2.2 is non-monotonic:" msgstr "" +"Python 2.2 的 MRO 讓打破單調性變得困難,但並非不可能。以下最初由 Samuele " +"Pedroni 提供的範例展示 Python 2.2 的 MRO 是非單調的:" #: ../../howto/mro.rst:530 msgid "" @@ -789,6 +936,8 @@ msgid "" "verify these linearizations as an exercise and draw the inheritance " "diagram ;-) ::" msgstr "" +"以下是根據 C3 MRO 的線性化(讀者應練習驗證這些線性化並繪製繼承" +"圖 ;-) : ::" #: ../../howto/mro.rst:534 msgid "" @@ -817,6 +966,8 @@ msgid "" "Python 2.2 gives exactly the same linearizations for A, B, C, D, E, K1, K2 " "and K3, but a different linearization for Z::" msgstr "" +"Python 2.2 給出了 A、B、C、D、E、K1、K2 和 K3 完全相同的線性化,但是 Z 的線性" +"化卻不同: ::" #: ../../howto/mro.rst:547 msgid "L[Z,P22] = Z K1 K3 A K2 D B C E O" @@ -834,10 +985,16 @@ msgid "" "the linearization of Z K2 *follows* K3. These problems explain why the 2.2 " "rule has been dismissed in favor of the C3 rule." msgstr "" +"顯然,這種線性化是\\ *錯誤*\\ 的,因為 A 在 D 之前,而在 K3 的線性化中,A 在 " +"D *之後*。換句話說,在 K3 中由 D 衍生的方法會覆寫由 A 衍生的方法,但在 Z 中" +"(它仍然是 K3 的子類別),由 A 衍生的方法卻覆寫由 D 衍生的方法!這是對單調性" +"的違反。此外,Z 的 Python 2.2 線性化也與局部優先順序不一致,因為類別 Z 的局部" +"優先串列是 [K1, K2, K3](K2 先於 K3),但在 Z 的線性化中 K2 *跟隨* K3。這些問" +"題解釋了為什麼 2.2 規則被摒棄而採用 C3 規則。" #: ../../howto/mro.rst:561 msgid "The end" -msgstr "" +msgstr "結語" #: ../../howto/mro.rst:563 msgid "" @@ -852,6 +1009,12 @@ msgid "" "the last line to play with the various examples I have discussed in this " "paper.::" msgstr "" +"本節適用於那些不耐煩、所有先前部分都跳過並直接滑到最後的讀者,也適" +"用於懶得鍛鍊大腦的程式設計師。最後,這也是針對一些自負的程式" +"設計師,不然她/他也不會想閱讀有關多重繼承階層中 C3 方法解析順序的文章;-)" +"擁有這三種美德(注意是同時擁有,不是分開)就值得獲得獎品:獎品是一個簡短的 Python 2.2 腳" +"本,可以幫你計算 2.3 MRO 而不用傷腦筋。只需更改最後一行就可以試跑我在本" +"文中討論的各種範例。 ::" #: ../../howto/mro.rst:574 msgid "" @@ -938,30 +1101,115 @@ msgid "" "\n" "#" msgstr "" +"#\n" +"\n" +"\"\"\"Samuele Pedroni 撰寫的 C3 演算法(由我改善了可讀性)。\"\"\"\n" +"\n" +"class __metaclass__(type):\n" +" \"所有類別都會被神奇地修改以便美觀地列印\"\n" +" __repr__ = lambda cls: cls.__name__\n" +"\n" +"class ex_2:\n" +" \"嚴重的順序分歧\" # 來自 Guido\n" +" class O: pass\n" +" class X(O): pass\n" +" class Y(O): pass\n" +" class A(X,Y): pass\n" +" class B(Y,X): pass\n" +" try:\n" +" class Z(A,B): pass # 在 Python 2.2 中會建立 Z(A,B)\n" +" except TypeError:\n" +" pass # 在 Python 2.3 中無法建立 Z(A,B)\n" +"\n" +"class ex_5:\n" +" \"我的第一個範例\"\n" +" class O: pass\n" +" class F(O): pass\n" +" class E(O): pass\n" +" class D(O): pass\n" +" class C(D,F): pass\n" +" class B(D,E): pass\n" +" class A(B,C): pass\n" +"\n" +"class ex_6:\n" +" \"我的第二個範例\"\n" +" class O: pass\n" +" class F(O): pass\n" +" class E(O): pass\n" +" class D(O): pass\n" +" class C(D,F): pass\n" +" class B(E,D): pass\n" +" class A(B,C): pass\n" +"\n" +"class ex_9:\n" +" \"Python 2.2 MRO 與 C3 的差異\" # 來自 Samuele\n" +" class O: pass\n" +" class A(O): pass\n" +" class B(O): pass\n" +" class C(O): pass\n" +" class D(O): pass\n" +" class E(O): pass\n" +" class K1(A,B,C): pass\n" +" class K2(D,B,E): pass\n" +" class K3(D,A): pass\n" +" class Z(K1,K2,K3): pass\n" +"\n" +"def merge(seqs):\n" +" print '\\n\\nCPL[%s]=%s' % (seqs[0][0],seqs),\n" +" res = []; i=0\n" +" while 1:\n" +" nonemptyseqs=[seq for seq in seqs if seq]\n" +" if not nonemptyseqs: return res\n" +" i+=1; print '\\n',i,'round: candidates...',\n" +" for seq in nonemptyseqs: # 在序列頭部中尋找合併候選者\n" +" cand = seq[0]; print ' ',cand,\n" +" nothead=[s for s in nonemptyseqs if cand in s[1:]]\n" +" if nothead: cand=None # 拒絕候選者\n" +" else: break\n" +" if not cand: raise \"不一致的階層結構\"\n" +" res.append(cand)\n" +" for seq in nonemptyseqs: # 移除候選者\n" +" if seq[0] == cand: del seq[0]\n" +"\n" +"def mro(C):\n" +" \"根據 C3 計算類別優先串列 (mro)\"\n" +" return merge([[C]]+map(mro,C.__bases__)+[list(C.__bases__)])\n" +"\n" +"def print_mro(C):\n" +" print '\\nMRO[%s]=%s' % (C,mro(C))\n" +" print '\\nP22 MRO[%s]=%s' % (C,C.mro())\n" +"\n" +"print_mro(ex_9.Z)\n" +"\n" +"#" #: ../../howto/mro.rst:656 msgid "That's all folks," -msgstr "" +msgstr "就這樣,各位," #: ../../howto/mro.rst:658 msgid "enjoy !" -msgstr "" +msgstr "祝使用愉快!" #: ../../howto/mro.rst:662 msgid "Resources" -msgstr "" +msgstr "資源" #: ../../howto/mro.rst:664 msgid "" "The thread on python-dev started by Samuele Pedroni: https://mail.python.org/" "pipermail/python-dev/2002-October/029035.html" msgstr "" +"Samuele Pedroni 發起的 python-dev 主題討論:https://mail.python.org/" +"pipermail/python-dev/2002-October/029035.html" #: ../../howto/mro.rst:667 msgid "" -"The paper *A Monotonic Superclass Linearization for Dylan*: https://doi." -"org/10.1145/236337.236343" +"The paper *A Monotonic Superclass Linearization for Dylan*: https://doi.org/" +"10.1145/236337.236343" msgstr "" +"論文 *A Monotonic Superclass Linearization for Dylan*: https://doi.org/" +"10.1145/236337.236343" #: ../../howto/mro.rst:670 msgid "" @@ -969,3 +1217,6 @@ msgid "" "https://web.archive.org/web/20140210194412/http://www.python.org/download/" "releases/2.2.2/descrintro" msgstr "" +"Guido van Rossum 的文章 *Unifying types and classes in Python 2.2*:https://" +"web.archive.org/web/20140210194412/http://www.python.org/download/releases/" +"2.2.2/descrintro" diff --git a/howto/perf_profiling.po b/howto/perf_profiling.po index 07ffef15b49..d606afed568 100644 --- a/howto/perf_profiling.po +++ b/howto/perf_profiling.po @@ -1,11 +1,11 @@ -# Copyright (C) 2001-2023, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Matt Wang , 2023 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2025-04-19 00:14+0000\n" "PO-Revision-Date: 2023-12-09 17:39+0800\n" diff --git a/howto/pyporting.po b/howto/pyporting.po index 61899804cc1..7220c627b30 100644 --- a/howto/pyporting.po +++ b/howto/pyporting.po @@ -1,12 +1,11 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # jerrychen , 2016 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-05-31 00:03+0000\n" "PO-Revision-Date: 2018-05-23 14:37+0000\n" diff --git a/howto/regex.po b/howto/regex.po index 782ee533c40..02a25aaf4df 100644 --- a/howto/regex.po +++ b/howto/regex.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -6,9 +6,9 @@ # Kai-han Chang , 2015 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"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: 2025-12-01 00:17+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-" @@ -31,7 +31,7 @@ msgstr "作者" msgid "A.M. Kuchling " msgstr "A.M. Kuchling " -#: ../../howto/regex.rst:-1 +#: ../../howto/regex.rst:16 msgid "Abstract" msgstr "摘要" @@ -659,12 +659,12 @@ msgid "" msgstr "" #: ../../howto/regex.rst:363 ../../howto/regex.rst:417 -#: ../../howto/regex.rst:1069 +#: ../../howto/regex.rst:1072 msgid "Method/Attribute" msgstr "方法/屬性" #: ../../howto/regex.rst:363 ../../howto/regex.rst:417 -#: ../../howto/regex.rst:1069 +#: ../../howto/regex.rst:1072 msgid "Purpose" msgstr "" @@ -1318,18 +1318,26 @@ msgid "" msgstr "" #: ../../howto/regex.rst:741 -msgid "``\\Z``" -msgstr "``\\Z``" +msgid "``\\z``" +msgstr "``\\z``" #: ../../howto/regex.rst:742 msgid "Matches only at the end of the string." msgstr "" #: ../../howto/regex.rst:744 +msgid "``\\Z``" +msgstr "``\\Z``" + +#: ../../howto/regex.rst:745 +msgid "The same as ``\\z``. For compatibility with old Python versions." +msgstr "" + +#: ../../howto/regex.rst:747 msgid "``\\b``" msgstr "``\\b``" -#: ../../howto/regex.rst:745 +#: ../../howto/regex.rst:748 msgid "" "Word boundary. This is a zero-width assertion that matches only at the " "beginning or end of a word. A word is defined as a sequence of alphanumeric " @@ -1337,13 +1345,13 @@ msgid "" "alphanumeric character." msgstr "" -#: ../../howto/regex.rst:750 +#: ../../howto/regex.rst:753 msgid "" "The following example matches ``class`` only when it's a complete word; it " "won't match when it's contained inside another word. ::" msgstr "" -#: ../../howto/regex.rst:753 +#: ../../howto/regex.rst:756 msgid "" ">>> p = re.compile(r'\\bclass\\b')\n" ">>> print(p.search('no class at all'))\n" @@ -1361,7 +1369,7 @@ msgstr "" ">>> print(p.search('one subclass is'))\n" "None" -#: ../../howto/regex.rst:761 +#: ../../howto/regex.rst:764 msgid "" "There are two subtleties you should remember when using this special " "sequence. First, this is the worst collision between Python's string " @@ -1372,7 +1380,7 @@ msgid "" "previous RE, but omits the ``'r'`` in front of the RE string. ::" msgstr "" -#: ../../howto/regex.rst:769 +#: ../../howto/regex.rst:772 msgid "" ">>> p = re.compile('\\bclass\\b')\n" ">>> print(p.search('no class at all'))\n" @@ -1386,28 +1394,28 @@ msgstr "" ">>> print(p.search('\\b' + 'class' + '\\b'))\n" "" -#: ../../howto/regex.rst:775 +#: ../../howto/regex.rst:778 msgid "" "Second, inside a character class, where there's no use for this assertion, " "``\\b`` represents the backspace character, for compatibility with Python's " "string literals." msgstr "" -#: ../../howto/regex.rst:779 +#: ../../howto/regex.rst:782 msgid "``\\B``" msgstr "``\\B``" -#: ../../howto/regex.rst:780 +#: ../../howto/regex.rst:783 msgid "" "Another zero-width assertion, this is the opposite of ``\\b``, only matching " "when the current position is not at a word boundary." msgstr "" -#: ../../howto/regex.rst:785 +#: ../../howto/regex.rst:788 msgid "Grouping" msgstr "" -#: ../../howto/regex.rst:787 +#: ../../howto/regex.rst:790 msgid "" "Frequently you need to obtain more information than just whether the RE " "matched or not. Regular expressions are often used to dissect strings by " @@ -1416,7 +1424,7 @@ msgid "" "name and a value, separated by a ``':'``, like this:" msgstr "" -#: ../../howto/regex.rst:793 +#: ../../howto/regex.rst:796 msgid "" "From: author@example.com\n" "User-Agent: Thunderbird 1.5.0.9 (X11/20061227)\n" @@ -1428,14 +1436,14 @@ msgstr "" "MIME-Version: 1.0\n" "To: editor@example.com" -#: ../../howto/regex.rst:800 +#: ../../howto/regex.rst:803 msgid "" "This can be handled by writing a regular expression which matches an entire " "header line, and has one group which matches the header name, and another " "group which matches the header's value." msgstr "" -#: ../../howto/regex.rst:804 +#: ../../howto/regex.rst:807 msgid "" "Groups are marked by the ``'('``, ``')'`` metacharacters. ``'('`` and " "``')'`` have much the same meaning as they do in mathematical expressions; " @@ -1445,7 +1453,7 @@ msgid "" "repetitions of ``ab``. ::" msgstr "" -#: ../../howto/regex.rst:811 +#: ../../howto/regex.rst:814 msgid "" ">>> p = re.compile('(ab)*')\n" ">>> print(p.match('ababababab').span())\n" @@ -1455,7 +1463,7 @@ msgstr "" ">>> print(p.match('ababababab').span())\n" "(0, 10)" -#: ../../howto/regex.rst:815 +#: ../../howto/regex.rst:818 msgid "" "Groups indicated with ``'('``, ``')'`` also capture the starting and ending " "index of the text that they match; this can be retrieved by passing an " @@ -1467,7 +1475,7 @@ msgid "" "they match. ::" msgstr "" -#: ../../howto/regex.rst:824 +#: ../../howto/regex.rst:827 msgid "" ">>> p = re.compile('(a)b')\n" ">>> m = p.match('ab')\n" @@ -1483,14 +1491,14 @@ msgstr "" ">>> m.group(0)\n" "'ab'" -#: ../../howto/regex.rst:831 +#: ../../howto/regex.rst:834 msgid "" "Subgroups are numbered from left to right, from 1 upward. Groups can be " "nested; to determine the number, just count the opening parenthesis " "characters, going from left to right. ::" msgstr "" -#: ../../howto/regex.rst:835 +#: ../../howto/regex.rst:838 msgid "" ">>> p = re.compile('(a(b)c)d')\n" ">>> m = p.match('abcd')\n" @@ -1510,14 +1518,14 @@ msgstr "" ">>> m.group(2)\n" "'b'" -#: ../../howto/regex.rst:844 +#: ../../howto/regex.rst:847 msgid "" ":meth:`~re.Match.group` can be passed multiple group numbers at a time, in " "which case it will return a tuple containing the corresponding values for " "those groups. ::" msgstr "" -#: ../../howto/regex.rst:847 +#: ../../howto/regex.rst:850 msgid "" ">>> m.group(2,1,2)\n" "('b', 'abc', 'b')" @@ -1525,13 +1533,13 @@ msgstr "" ">>> m.group(2,1,2)\n" "('b', 'abc', 'b')" -#: ../../howto/regex.rst:850 +#: ../../howto/regex.rst:853 msgid "" "The :meth:`~re.Match.groups` method returns a tuple containing the strings " "for all the subgroups, from 1 up to however many there are. ::" msgstr "" -#: ../../howto/regex.rst:853 +#: ../../howto/regex.rst:856 msgid "" ">>> m.groups()\n" "('abc', 'b')" @@ -1539,7 +1547,7 @@ msgstr "" ">>> m.groups()\n" "('abc', 'b')" -#: ../../howto/regex.rst:856 +#: ../../howto/regex.rst:859 msgid "" "Backreferences in a pattern allow you to specify that the contents of an " "earlier capturing group must also be found at the current location in the " @@ -1550,11 +1558,11 @@ msgid "" "when incorporating backreferences in a RE." msgstr "" -#: ../../howto/regex.rst:864 +#: ../../howto/regex.rst:867 msgid "For example, the following RE detects doubled words in a string. ::" msgstr "" -#: ../../howto/regex.rst:866 +#: ../../howto/regex.rst:869 msgid "" ">>> p = re.compile(r'\\b(\\w+)\\s+\\1\\b')\n" ">>> p.search('Paris in the the spring').group()\n" @@ -1564,7 +1572,7 @@ msgstr "" ">>> p.search('Paris in the the spring').group()\n" "'the the'" -#: ../../howto/regex.rst:870 +#: ../../howto/regex.rst:873 msgid "" "Backreferences like this aren't often useful for just searching through a " "string --- there are few text formats which repeat data in this way --- but " @@ -1572,11 +1580,11 @@ msgid "" "substitutions." msgstr "" -#: ../../howto/regex.rst:876 +#: ../../howto/regex.rst:879 msgid "Non-capturing and Named Groups" msgstr "" -#: ../../howto/regex.rst:878 +#: ../../howto/regex.rst:881 msgid "" "Elaborate REs may use many groups, both to capture substrings of interest, " "and to group and structure the RE itself. In complex REs, it becomes " @@ -1585,7 +1593,7 @@ msgid "" "expression extensions, so we'll look at that first." msgstr "" -#: ../../howto/regex.rst:884 +#: ../../howto/regex.rst:887 msgid "" "Perl 5 is well known for its powerful additions to standard regular " "expressions. For these new features the Perl developers couldn't choose new " @@ -1596,7 +1604,7 @@ msgid "" "wouldn't have escaped it by writing ``\\&`` or ``[&]``." msgstr "" -#: ../../howto/regex.rst:891 +#: ../../howto/regex.rst:894 msgid "" "The solution chosen by the Perl developers was to use ``(?...)`` as the " "extension syntax. ``?`` immediately after a parenthesis was a syntax error " @@ -1607,20 +1615,20 @@ msgid "" "capturing group containing the subexpression ``foo``)." msgstr "" -#: ../../howto/regex.rst:899 +#: ../../howto/regex.rst:902 msgid "" "Python supports several of Perl's extensions and adds an extension syntax to " "Perl's extension syntax. If the first character after the question mark is " "a ``P``, you know that it's an extension that's specific to Python." msgstr "" -#: ../../howto/regex.rst:904 +#: ../../howto/regex.rst:907 msgid "" "Now that we've looked at the general extension syntax, we can return to the " "features that simplify working with groups in complex REs." msgstr "" -#: ../../howto/regex.rst:907 +#: ../../howto/regex.rst:910 msgid "" "Sometimes you'll want to use a group to denote a part of a regular " "expression, but aren't interested in retrieving the group's contents. You " @@ -1628,7 +1636,7 @@ msgid "" "where you can replace the ``...`` with any other regular expression. ::" msgstr "" -#: ../../howto/regex.rst:912 +#: ../../howto/regex.rst:915 msgid "" ">>> m = re.match(\"([abc])+\", \"abc\")\n" ">>> m.groups()\n" @@ -1644,7 +1652,7 @@ msgstr "" ">>> m.groups()\n" "()" -#: ../../howto/regex.rst:919 +#: ../../howto/regex.rst:922 msgid "" "Except for the fact that you can't retrieve the contents of what the group " "matched, a non-capturing group behaves exactly the same as a capturing " @@ -1657,13 +1665,13 @@ msgid "" "groups; neither form is any faster than the other." msgstr "" -#: ../../howto/regex.rst:928 +#: ../../howto/regex.rst:931 msgid "" "A more significant feature is named groups: instead of referring to them by " "numbers, groups can be referenced by a name." msgstr "" -#: ../../howto/regex.rst:931 +#: ../../howto/regex.rst:934 msgid "" "The syntax for a named group is one of the Python-specific extensions: ``(?" "P...)``. *name* is, obviously, the name of the group. Named groups " @@ -1675,7 +1683,7 @@ msgid "" "ways::" msgstr "" -#: ../../howto/regex.rst:939 +#: ../../howto/regex.rst:942 msgid "" ">>> p = re.compile(r'(?P\\b\\w+\\b)')\n" ">>> m = p.search( '(((( Lots of punctuation )))' )\n" @@ -1691,13 +1699,13 @@ msgstr "" ">>> m.group(1)\n" "'Lots'" -#: ../../howto/regex.rst:946 +#: ../../howto/regex.rst:949 msgid "" "Additionally, you can retrieve named groups as a dictionary with :meth:`~re." "Match.groupdict`::" msgstr "" -#: ../../howto/regex.rst:949 +#: ../../howto/regex.rst:952 msgid "" ">>> m = re.match(r'(?P\\w+) (?P\\w+)', 'Jane Doe')\n" ">>> m.groupdict()\n" @@ -1707,14 +1715,14 @@ msgstr "" ">>> m.groupdict()\n" "{'first': 'Jane', 'last': 'Doe'}" -#: ../../howto/regex.rst:953 +#: ../../howto/regex.rst:956 msgid "" "Named groups are handy because they let you use easily remembered names, " "instead of having to remember numbers. Here's an example RE from the :mod:" "`imaplib` module::" msgstr "" -#: ../../howto/regex.rst:957 +#: ../../howto/regex.rst:960 msgid "" "InternalDate = re.compile(r'INTERNALDATE \"'\n" " r'(?P[ 123][0-9])-(?P[A-Z][a-z][a-z])-'\n" @@ -1730,13 +1738,13 @@ msgstr "" " r' (?P[-+])(?P[0-9][0-9])(?P[0-9][0-9])'\n" " r'\"')" -#: ../../howto/regex.rst:964 +#: ../../howto/regex.rst:967 msgid "" "It's obviously much easier to retrieve ``m.group('zonem')``, instead of " "having to remember to retrieve group 9." msgstr "" -#: ../../howto/regex.rst:967 +#: ../../howto/regex.rst:970 msgid "" "The syntax for backreferences in an expression such as ``(...)\\1`` refers " "to the number of the group. There's naturally a variant that uses the group " @@ -1747,7 +1755,7 @@ msgid "" "P\\w+)\\s+(?P=word)\\b``::" msgstr "" -#: ../../howto/regex.rst:974 +#: ../../howto/regex.rst:977 msgid "" ">>> p = re.compile(r'\\b(?P\\w+)\\s+(?P=word)\\b')\n" ">>> p.search('Paris in the the spring').group()\n" @@ -1757,22 +1765,22 @@ msgstr "" ">>> p.search('Paris in the the spring').group()\n" "'the the'" -#: ../../howto/regex.rst:980 +#: ../../howto/regex.rst:983 msgid "Lookahead Assertions" msgstr "" -#: ../../howto/regex.rst:982 +#: ../../howto/regex.rst:985 msgid "" "Another zero-width assertion is the lookahead assertion. Lookahead " "assertions are available in both positive and negative form, and look like " "this:" msgstr "" -#: ../../howto/regex.rst:985 +#: ../../howto/regex.rst:988 msgid "``(?=...)``" msgstr "``(?=...)``" -#: ../../howto/regex.rst:986 +#: ../../howto/regex.rst:989 msgid "" "Positive lookahead assertion. This succeeds if the contained regular " "expression, represented here by ``...``, successfully matches at the current " @@ -1781,18 +1789,18 @@ msgid "" "is tried right where the assertion started." msgstr "" -#: ../../howto/regex.rst:992 +#: ../../howto/regex.rst:995 msgid "``(?!...)``" msgstr "``(?!...)``" -#: ../../howto/regex.rst:993 +#: ../../howto/regex.rst:996 msgid "" "Negative lookahead assertion. This is the opposite of the positive " "assertion; it succeeds if the contained expression *doesn't* match at the " "current position in the string." msgstr "" -#: ../../howto/regex.rst:997 +#: ../../howto/regex.rst:1000 msgid "" "To make this concrete, let's look at a case where a lookahead is useful. " "Consider a simple pattern to match a filename and split it apart into a base " @@ -1800,15 +1808,15 @@ msgid "" "``news`` is the base name, and ``rc`` is the filename's extension." msgstr "" -#: ../../howto/regex.rst:1002 +#: ../../howto/regex.rst:1005 msgid "The pattern to match this is quite simple:" msgstr "" -#: ../../howto/regex.rst:1004 +#: ../../howto/regex.rst:1007 msgid "``.*[.].*$``" msgstr "``.*[.].*$``" -#: ../../howto/regex.rst:1006 +#: ../../howto/regex.rst:1009 msgid "" "Notice that the ``.`` needs to be treated specially because it's a " "metacharacter, so it's inside a character class to only match that specific " @@ -1818,28 +1826,28 @@ msgid "" "``printers.conf``." msgstr "" -#: ../../howto/regex.rst:1013 +#: ../../howto/regex.rst:1016 msgid "" "Now, consider complicating the problem a bit; what if you want to match " "filenames where the extension is not ``bat``? Some incorrect attempts:" msgstr "" -#: ../../howto/regex.rst:1016 +#: ../../howto/regex.rst:1019 msgid "``.*[.][^b].*$``" msgstr "``.*[.][^b].*$``" -#: ../../howto/regex.rst:1018 +#: ../../howto/regex.rst:1021 msgid "" "The first attempt above tries to exclude ``bat`` by requiring that the first " "character of the extension is not a ``b``. This is wrong, because the " "pattern also doesn't match ``foo.bar``." msgstr "" -#: ../../howto/regex.rst:1022 +#: ../../howto/regex.rst:1025 msgid "``.*[.]([^b]..|.[^a].|..[^t])$``" msgstr "``.*[.]([^b]..|.[^a].|..[^t])$``" -#: ../../howto/regex.rst:1024 +#: ../../howto/regex.rst:1027 msgid "" "The expression gets messier when you try to patch up the first solution by " "requiring one of the following cases to match: the first character of the " @@ -1850,18 +1858,18 @@ msgid "" "pattern again in an effort to fix it." msgstr "" -#: ../../howto/regex.rst:1032 +#: ../../howto/regex.rst:1035 msgid "``.*[.]([^b].?.?|.[^a]?.?|..?[^t]?)$``" msgstr "``.*[.]([^b].?.?|.[^a]?.?|..?[^t]?)$``" -#: ../../howto/regex.rst:1034 +#: ../../howto/regex.rst:1037 msgid "" "In the third attempt, the second and third letters are all made optional in " "order to allow matching extensions shorter than three characters, such as " "``sendmail.cf``." msgstr "" -#: ../../howto/regex.rst:1038 +#: ../../howto/regex.rst:1041 msgid "" "The pattern's getting really complicated now, which makes it hard to read " "and understand. Worse, if the problem changes and you want to exclude both " @@ -1869,15 +1877,15 @@ msgid "" "complicated and confusing." msgstr "" -#: ../../howto/regex.rst:1043 +#: ../../howto/regex.rst:1046 msgid "A negative lookahead cuts through all this confusion:" msgstr "" -#: ../../howto/regex.rst:1045 +#: ../../howto/regex.rst:1048 msgid "``.*[.](?!bat$)[^.]*$``" msgstr "``.*[.](?!bat$)[^.]*$``" -#: ../../howto/regex.rst:1047 +#: ../../howto/regex.rst:1050 msgid "" "The negative lookahead means: if the expression ``bat`` doesn't match at " "this point, try the rest of the pattern; if ``bat$`` does match, the whole " @@ -1887,61 +1895,61 @@ msgid "" "multiple dots in the filename." msgstr "" -#: ../../howto/regex.rst:1054 +#: ../../howto/regex.rst:1057 msgid "" "Excluding another filename extension is now easy; simply add it as an " "alternative inside the assertion. The following pattern excludes filenames " "that end in either ``bat`` or ``exe``:" msgstr "" -#: ../../howto/regex.rst:1058 +#: ../../howto/regex.rst:1061 msgid "``.*[.](?!bat$|exe$)[^.]*$``" msgstr "``.*[.](?!bat$|exe$)[^.]*$``" -#: ../../howto/regex.rst:1062 +#: ../../howto/regex.rst:1065 msgid "Modifying Strings" msgstr "" -#: ../../howto/regex.rst:1064 +#: ../../howto/regex.rst:1067 msgid "" "Up to this point, we've simply performed searches against a static string. " "Regular expressions are also commonly used to modify strings in various " "ways, using the following pattern methods:" msgstr "" -#: ../../howto/regex.rst:1071 +#: ../../howto/regex.rst:1074 msgid "``split()``" msgstr "``split()``" -#: ../../howto/regex.rst:1071 +#: ../../howto/regex.rst:1074 msgid "Split the string into a list, splitting it wherever the RE matches" msgstr "" -#: ../../howto/regex.rst:1074 +#: ../../howto/regex.rst:1077 msgid "``sub()``" msgstr "``sub()``" -#: ../../howto/regex.rst:1074 +#: ../../howto/regex.rst:1077 msgid "" "Find all substrings where the RE matches, and replace them with a different " "string" msgstr "" -#: ../../howto/regex.rst:1077 +#: ../../howto/regex.rst:1080 msgid "``subn()``" msgstr "``subn()``" -#: ../../howto/regex.rst:1077 +#: ../../howto/regex.rst:1080 msgid "" "Does the same thing as :meth:`!sub`, but returns the new string and the " "number of replacements" msgstr "" -#: ../../howto/regex.rst:1084 +#: ../../howto/regex.rst:1087 msgid "Splitting Strings" msgstr "" -#: ../../howto/regex.rst:1086 +#: ../../howto/regex.rst:1089 msgid "" "The :meth:`~re.Pattern.split` method of a pattern splits a string apart " "wherever the RE matches, returning a list of the pieces. It's similar to " @@ -1951,7 +1959,7 @@ msgid "" "module-level :func:`re.split` function, too." msgstr "" -#: ../../howto/regex.rst:1097 +#: ../../howto/regex.rst:1100 msgid "" "Split *string* by the matches of the regular expression. If capturing " "parentheses are used in the RE, then their contents will also be returned as " @@ -1959,7 +1967,7 @@ msgid "" "splits are performed." msgstr "" -#: ../../howto/regex.rst:1102 +#: ../../howto/regex.rst:1105 msgid "" "You can limit the number of splits made, by passing a value for *maxsplit*. " "When *maxsplit* is nonzero, at most *maxsplit* splits will be made, and the " @@ -1968,7 +1976,7 @@ msgid "" "characters. ::" msgstr "" -#: ../../howto/regex.rst:1108 +#: ../../howto/regex.rst:1111 msgid "" ">>> p = re.compile(r'\\W+')\n" ">>> p.split('This is a test, short and sweet, of split().')\n" @@ -1982,7 +1990,7 @@ msgstr "" ">>> p.split('This is a test, short and sweet, of split().', 3)\n" "['This', 'is', 'a', 'test, short and sweet, of split().']" -#: ../../howto/regex.rst:1114 +#: ../../howto/regex.rst:1117 msgid "" "Sometimes you're not only interested in what the text between delimiters is, " "but also need to know what the delimiter was. If capturing parentheses are " @@ -1990,7 +1998,7 @@ msgid "" "Compare the following calls::" msgstr "" -#: ../../howto/regex.rst:1119 +#: ../../howto/regex.rst:1122 msgid "" ">>> p = re.compile(r'\\W+')\n" ">>> p2 = re.compile(r'(\\W+)')\n" @@ -2006,13 +2014,13 @@ msgstr "" ">>> p2.split('This... is a test.')\n" "['This', '... ', 'is', ' ', 'a', ' ', 'test', '.', '']" -#: ../../howto/regex.rst:1126 +#: ../../howto/regex.rst:1129 msgid "" "The module-level function :func:`re.split` adds the RE to be used as the " "first argument, but is otherwise the same. ::" msgstr "" -#: ../../howto/regex.rst:1129 +#: ../../howto/regex.rst:1132 msgid "" ">>> re.split(r'[\\W]+', 'Words, words, words.')\n" "['Words', 'words', 'words', '']\n" @@ -2028,11 +2036,11 @@ msgstr "" ">>> re.split(r'[\\W]+', 'Words, words, words.', 1)\n" "['Words', 'words, words.']" -#: ../../howto/regex.rst:1138 +#: ../../howto/regex.rst:1141 msgid "Search and Replace" msgstr "" -#: ../../howto/regex.rst:1140 +#: ../../howto/regex.rst:1143 msgid "" "Another common task is to find all the matches for a pattern, and replace " "them with a different string. The :meth:`~re.Pattern.sub` method takes a " @@ -2040,27 +2048,27 @@ msgid "" "string to be processed." msgstr "" -#: ../../howto/regex.rst:1147 +#: ../../howto/regex.rst:1150 msgid "" "Returns the string obtained by replacing the leftmost non-overlapping " "occurrences of the RE in *string* by the replacement *replacement*. If the " "pattern isn't found, *string* is returned unchanged." msgstr "" -#: ../../howto/regex.rst:1151 +#: ../../howto/regex.rst:1154 msgid "" "The optional argument *count* is the maximum number of pattern occurrences " "to be replaced; *count* must be a non-negative integer. The default value " "of 0 means to replace all occurrences." msgstr "" -#: ../../howto/regex.rst:1155 +#: ../../howto/regex.rst:1158 msgid "" "Here's a simple example of using the :meth:`~re.Pattern.sub` method. It " "replaces colour names with the word ``colour``::" msgstr "" -#: ../../howto/regex.rst:1158 +#: ../../howto/regex.rst:1161 msgid "" ">>> p = re.compile('(blue|white|red)')\n" ">>> p.sub('colour', 'blue socks and red shoes')\n" @@ -2074,14 +2082,14 @@ msgstr "" ">>> p.sub('colour', 'blue socks and red shoes', count=1)\n" "'colour socks and red shoes'" -#: ../../howto/regex.rst:1164 +#: ../../howto/regex.rst:1167 msgid "" "The :meth:`~re.Pattern.subn` method does the same work, but returns a 2-" "tuple containing the new string value and the number of replacements that " "were performed::" msgstr "" -#: ../../howto/regex.rst:1167 +#: ../../howto/regex.rst:1170 msgid "" ">>> p = re.compile('(blue|white|red)')\n" ">>> p.subn('colour', 'blue socks and red shoes')\n" @@ -2095,13 +2103,13 @@ msgstr "" ">>> p.subn('colour', 'no colours at all')\n" "('no colours at all', 0)" -#: ../../howto/regex.rst:1173 +#: ../../howto/regex.rst:1176 msgid "" "Empty matches are replaced only when they're not adjacent to a previous " "empty match. ::" msgstr "" -#: ../../howto/regex.rst:1176 +#: ../../howto/regex.rst:1179 msgid "" ">>> p = re.compile('x*')\n" ">>> p.sub('-', 'abxd')\n" @@ -2111,7 +2119,7 @@ msgstr "" ">>> p.sub('-', 'abxd')\n" "'-a-b--d-'" -#: ../../howto/regex.rst:1180 +#: ../../howto/regex.rst:1183 msgid "" "If *replacement* is a string, any backslash escapes in it are processed. " "That is, ``\\n`` is converted to a single newline character, ``\\r`` is " @@ -2122,13 +2130,13 @@ msgid "" "string." msgstr "" -#: ../../howto/regex.rst:1187 +#: ../../howto/regex.rst:1190 msgid "" "This example matches the word ``section`` followed by a string enclosed in " "``{``, ``}``, and changes ``section`` to ``subsection``::" msgstr "" -#: ../../howto/regex.rst:1190 +#: ../../howto/regex.rst:1193 msgid "" ">>> p = re.compile('section{ ( [^}]* ) }', re.VERBOSE)\n" ">>> p.sub(r'subsection{\\1}','section{First} section{second}')\n" @@ -2138,7 +2146,7 @@ msgstr "" ">>> p.sub(r'subsection{\\1}','section{First} section{second}')\n" "'subsection{First} subsection{second}'" -#: ../../howto/regex.rst:1194 +#: ../../howto/regex.rst:1197 msgid "" "There's also a syntax for referring to named groups as defined by the ``(?" "P...)`` syntax. ``\\g`` will use the substring matched by the " @@ -2150,7 +2158,7 @@ msgid "" "but use all three variations of the replacement string. ::" msgstr "" -#: ../../howto/regex.rst:1203 +#: ../../howto/regex.rst:1206 msgid "" ">>> p = re.compile('section{ (?P [^}]* ) }', re.VERBOSE)\n" ">>> p.sub(r'subsection{\\1}','section{First}')\n" @@ -2168,7 +2176,7 @@ msgstr "" ">>> p.sub(r'subsection{\\g}','section{First}')\n" "'subsection{First}'" -#: ../../howto/regex.rst:1211 +#: ../../howto/regex.rst:1214 msgid "" "*replacement* can also be a function, which gives you even more control. If " "*replacement* is a function, the function is called for every non-" @@ -2177,13 +2185,13 @@ msgid "" "this information to compute the desired replacement string and return it." msgstr "" -#: ../../howto/regex.rst:1217 +#: ../../howto/regex.rst:1220 msgid "" "In the following example, the replacement function translates decimals into " "hexadecimal::" msgstr "" -#: ../../howto/regex.rst:1220 +#: ../../howto/regex.rst:1223 msgid "" ">>> def hexrepl(match):\n" "... \"Return the hex string for a decimal number\"\n" @@ -2195,7 +2203,7 @@ msgid "" "'Call 0xffd2 for printing, 0xc000 for user code.'" msgstr "" -#: ../../howto/regex.rst:1229 +#: ../../howto/regex.rst:1232 msgid "" "When using the module-level :func:`re.sub` function, the pattern is passed " "as the first argument. The pattern may be provided as an object or as a " @@ -2205,11 +2213,11 @@ msgid "" "x'``." msgstr "" -#: ../../howto/regex.rst:1237 +#: ../../howto/regex.rst:1240 msgid "Common Problems" msgstr "" -#: ../../howto/regex.rst:1239 +#: ../../howto/regex.rst:1242 msgid "" "Regular expressions are a powerful tool for some applications, but in some " "ways their behaviour isn't intuitive and at times they don't behave the way " @@ -2217,11 +2225,11 @@ msgid "" "pitfalls." msgstr "" -#: ../../howto/regex.rst:1245 +#: ../../howto/regex.rst:1248 msgid "Use String Methods" msgstr "" -#: ../../howto/regex.rst:1247 +#: ../../howto/regex.rst:1250 msgid "" "Sometimes using the :mod:`re` module is a mistake. If you're matching a " "fixed string, or a single character class, and you're not using any :mod:" @@ -2233,7 +2241,7 @@ msgid "" "engine." msgstr "" -#: ../../howto/regex.rst:1255 +#: ../../howto/regex.rst:1258 msgid "" "One example might be replacing a single fixed string with another one; for " "example, you might replace ``word`` with ``deed``. :func:`re.sub` seems " @@ -2246,7 +2254,7 @@ msgid "" "meth:`!replace`'s abilities.)" msgstr "" -#: ../../howto/regex.rst:1264 +#: ../../howto/regex.rst:1267 msgid "" "Another common task is deleting every occurrence of a single character from " "a string or replacing it with another single character. You might do this " @@ -2255,17 +2263,17 @@ msgid "" "operation can be." msgstr "" -#: ../../howto/regex.rst:1270 +#: ../../howto/regex.rst:1273 msgid "" "In short, before turning to the :mod:`re` module, consider whether your " "problem can be solved with a faster and simpler string method." msgstr "" -#: ../../howto/regex.rst:1275 +#: ../../howto/regex.rst:1278 msgid "match() versus search()" msgstr "" -#: ../../howto/regex.rst:1277 +#: ../../howto/regex.rst:1280 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 " @@ -2275,7 +2283,7 @@ msgid "" "report it. ::" msgstr "" -#: ../../howto/regex.rst:1283 +#: ../../howto/regex.rst:1286 msgid "" ">>> print(re.match('super', 'superstition').span())\n" "(0, 5)\n" @@ -2287,13 +2295,13 @@ msgstr "" ">>> print(re.match('super', 'insuperable'))\n" "None" -#: ../../howto/regex.rst:1288 +#: ../../howto/regex.rst:1291 msgid "" "On the other hand, :func:`~re.search` will scan forward through the string, " "reporting the first match it finds. ::" msgstr "" -#: ../../howto/regex.rst:1291 +#: ../../howto/regex.rst:1294 msgid "" ">>> print(re.search('super', 'superstition').span())\n" "(0, 5)\n" @@ -2305,7 +2313,7 @@ msgstr "" ">>> print(re.search('super', 'insuperable').span())\n" "(2, 7)" -#: ../../howto/regex.rst:1296 +#: ../../howto/regex.rst:1299 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." @@ -2317,18 +2325,18 @@ msgid "" "starting character, only trying the full match if a ``'C'`` is found." msgstr "" -#: ../../howto/regex.rst:1305 +#: ../../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:1311 +#: ../../howto/regex.rst:1314 msgid "Greedy versus Non-Greedy" msgstr "" -#: ../../howto/regex.rst:1313 +#: ../../howto/regex.rst:1316 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 " @@ -2337,7 +2345,7 @@ msgid "" "HTML tag doesn't work because of the greedy nature of ``.*``. ::" msgstr "" -#: ../../howto/regex.rst:1319 +#: ../../howto/regex.rst:1322 msgid "" ">>> s = 'Title'\n" ">>> len(s)\n" @@ -2355,7 +2363,7 @@ msgstr "" ">>> print(re.match('<.*>', s).group())\n" "Title" -#: ../../howto/regex.rst:1327 +#: ../../howto/regex.rst:1330 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 ``>`` " @@ -2365,7 +2373,7 @@ msgid "" "``''``, which isn't what you want." msgstr "" -#: ../../howto/regex.rst:1334 +#: ../../howto/regex.rst:1337 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 " @@ -2374,7 +2382,7 @@ msgid "" "retrying the ``'>'`` at every step. This produces just the right result::" msgstr "" -#: ../../howto/regex.rst:1340 +#: ../../howto/regex.rst:1343 msgid "" ">>> print(re.match('<.*?>', s).group())\n" "" @@ -2382,7 +2390,7 @@ msgstr "" ">>> print(re.match('<.*?>', s).group())\n" "" -#: ../../howto/regex.rst:1343 +#: ../../howto/regex.rst:1346 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 " @@ -2392,11 +2400,11 @@ msgid "" "such tasks.)" msgstr "" -#: ../../howto/regex.rst:1351 +#: ../../howto/regex.rst:1354 msgid "Using re.VERBOSE" msgstr "" -#: ../../howto/regex.rst:1353 +#: ../../howto/regex.rst:1356 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 " @@ -2404,14 +2412,14 @@ msgid "" "making them difficult to read and understand." msgstr "" -#: ../../howto/regex.rst:1358 +#: ../../howto/regex.rst:1361 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:1362 +#: ../../howto/regex.rst:1365 msgid "" "The ``re.VERBOSE`` flag has several effects. Whitespace in the regular " "expression that *isn't* inside a character class is ignored. This means " @@ -2422,7 +2430,7 @@ msgid "" "quoted strings, this enables REs to be formatted more neatly::" msgstr "" -#: ../../howto/regex.rst:1370 +#: ../../howto/regex.rst:1373 msgid "" "pat = re.compile(r\"\"\"\n" " \\s* # Skip leading whitespace\n" @@ -2434,19 +2442,19 @@ msgid "" "\"\"\", re.VERBOSE)" msgstr "" -#: ../../howto/regex.rst:1379 +#: ../../howto/regex.rst:1382 msgid "This is far more readable than::" msgstr "" -#: ../../howto/regex.rst:1381 +#: ../../howto/regex.rst:1384 msgid "pat = re.compile(r\"\\s*(?P
[^:]+)\\s*:(?P.*?)\\s*$\")" msgstr "pat = re.compile(r\"\\s*(?P
[^:]+)\\s*:(?P.*?)\\s*$\")" -#: ../../howto/regex.rst:1385 +#: ../../howto/regex.rst:1388 msgid "Feedback" msgstr "" -#: ../../howto/regex.rst:1387 +#: ../../howto/regex.rst:1390 msgid "" "Regular expressions are a complicated topic. Did this document help you " "understand them? Were there parts that were unclear, or Problems you " @@ -2454,7 +2462,7 @@ msgid "" "improvements to the author." msgstr "" -#: ../../howto/regex.rst:1392 +#: ../../howto/regex.rst:1395 msgid "" "The most complete book on regular expressions is almost certainly Jeffrey " "Friedl's Mastering Regular Expressions, published by O'Reilly. " diff --git a/howto/remote_debugging.po b/howto/remote_debugging.po new file mode 100644 index 00000000000..198ff189c4a --- /dev/null +++ b/howto/remote_debugging.po @@ -0,0 +1,1265 @@ +# 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.14\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-09-13 00:14+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/remote_debugging.rst:4 +msgid "Remote debugging attachment protocol" +msgstr "遠端偵錯附加協議" + +#: ../../howto/remote_debugging.rst:6 +msgid "" +"This protocol enables external tools to attach to a running CPython process " +"and execute Python code remotely." +msgstr "此協議使外部工具能夠附加到正在執行的 CPython 行程並遠端執行 Python 程式碼。" + +#: ../../howto/remote_debugging.rst:9 +msgid "" +"Most platforms require elevated privileges to attach to another Python " +"process." +msgstr "大多數平台上都會需要更高的權限才能附加到另一個 Python 行程。" + +#: ../../howto/remote_debugging.rst:14 +msgid "Permission requirements" +msgstr "權限需求" + +#: ../../howto/remote_debugging.rst:16 +msgid "" +"Attaching to a running Python process for remote debugging requires elevated " +"privileges on most platforms. The specific requirements and troubleshooting " +"steps depend on your operating system:" +msgstr "" +"在大多數平台上,附加到正在執行的 Python 行程進行遠端偵錯需要更高的權限。具體要求和疑難排" +"解步驟會取決於你的作業系統:" + +#: ../../howto/remote_debugging.rst:21 +msgid "Linux" +msgstr "Linux" + +#: ../../howto/remote_debugging.rst:22 +msgid "" +"The tracer process must have the ``CAP_SYS_PTRACE`` capability or equivalent " +"privileges. You can only trace processes you own and can signal. Tracing may " +"fail if the process is already being traced, or if it is running with set-" +"user-ID or set-group-ID. Security modules like Yama may further restrict " +"tracing." +msgstr "" +"執行追蹤的行程 (tracer process) 必須具有 ``CAP_SYS_PTRACE`` 功能或同等權限。" +"你只能追蹤你擁有且可以發送訊號的行程。如果行程已經被追蹤,或者它以 set-user-ID 或 " +"set-group-ID 執行,則追蹤可能會失敗。像 Yama 這樣的安全模組可能會進一步限制追蹤。" + +#: ../../howto/remote_debugging.rst:28 +msgid "To temporarily relax ptrace restrictions (until reboot), run:" +msgstr "要暫時放寬 ptrace 限制(直到重新開機),請執行:" + +#: ../../howto/remote_debugging.rst:30 +msgid "``echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope``" +msgstr "``echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope``" + +#: ../../howto/remote_debugging.rst:34 +msgid "" +"Disabling ``ptrace_scope`` reduces system hardening and should only be done " +"in trusted environments." +msgstr "停用 ``ptrace_scope`` 會降低系統安全性,應僅在受信任的環境中執行此操作。" + +#: ../../howto/remote_debugging.rst:37 +msgid "" +"If running inside a container, use ``--cap-add=SYS_PTRACE`` or ``--" +"privileged``, and run as root if needed." +msgstr "" +"如果在容器內執行,請使用 ``--cap-add=SYS_PTRACE`` 或 ``--privileged``," +"並在需要時以 root 身分執行。" + +#: ../../howto/remote_debugging.rst:40 +msgid "Try re-running the command with elevated privileges:" +msgstr "嘗試使用提升後的權限重新執行命令:" + +#: ../../howto/remote_debugging.rst:42 +msgid "``sudo -E !!``" +msgstr "``sudo -E !!``" + +#: ../../howto/remote_debugging.rst:46 +msgid "macOS" +msgstr "macOS" + +#: ../../howto/remote_debugging.rst:47 +msgid "" +"To attach to another process, you typically need to run your debugging tool " +"with elevated privileges. This can be done by using ``sudo`` or running as " +"root." +msgstr "" +"要附加到另一個行程,你通常需要以提升過的權限來執行偵錯工具。這可以透過使用 ``sudo`` " +"或以 root 身分執行來完成。" + +#: ../../howto/remote_debugging.rst:51 +msgid "" +"Even when attaching to processes you own, macOS may block debugging unless " +"the debugger is run with root privileges due to system security restrictions." +msgstr "" +"即使附加到你擁有的行程,macOS 也可能會阻止偵錯,除非偵錯器以 root 權限執行,這是由於系統安全限制。" + +#: ../../howto/remote_debugging.rst:56 +msgid "Windows" +msgstr "Windows" + +#: ../../howto/remote_debugging.rst:57 +msgid "" +"To attach to another process, you usually need to run your debugging tool " +"with administrative privileges. Start the command prompt or terminal as " +"Administrator." +msgstr "" +"要附加到另一個行程,你通常需要以系統管理員權限執行偵錯工具。以系統管理員身分啟動命令提示字元或終端機。" + +#: ../../howto/remote_debugging.rst:61 +msgid "" +"Some processes may still be inaccessible even with Administrator rights, " +"unless you have the ``SeDebugPrivilege`` privilege enabled." +msgstr "即使具有系統管理員權限,某些行程仍可能無法存取,除非你啟用了 ``SeDebugPrivilege`` 權限。" + +#: ../../howto/remote_debugging.rst:64 +msgid "" +"To resolve file or folder access issues, adjust the security permissions:" +msgstr "要解決檔案或資料夾存取問題,請調整安全權限:" + +#: ../../howto/remote_debugging.rst:66 +msgid "Right-click the file or folder and select **Properties**." +msgstr "右鍵點擊檔案或資料夾並選擇 **Properties**。" + +#: ../../howto/remote_debugging.rst:67 +msgid "Go to the **Security** tab to view users and groups with access." +msgstr "前往 **Security** 分頁以檢視具有存取權限的使用者和群組。" + +#: ../../howto/remote_debugging.rst:68 +msgid "Click **Edit** to modify permissions." +msgstr "點擊 **Edit** 以修改權限。" + +#: ../../howto/remote_debugging.rst:69 +msgid "Select your user account." +msgstr "選擇你的使用者帳戶。" + +#: ../../howto/remote_debugging.rst:70 +msgid "In **Permissions**, check **Read** or **Full control** as needed." +msgstr "在 **Permissions** 中,視需要勾選 **Read** 或 **Full control**。" + +#: ../../howto/remote_debugging.rst:71 +msgid "Click **Apply**, then **OK** to confirm." +msgstr "點擊 **Apply**,然後點擊 **OK** 來確認。" + +#: ../../howto/remote_debugging.rst:76 +msgid "" +"Ensure you've satisfied all :ref:`permission-requirements` before proceeding." +msgstr "在繼續之前,請確保你已滿足所有 :ref:`permission-requirements`。" + +#: ../../howto/remote_debugging.rst:78 +msgid "" +"This section describes the low-level protocol that enables external tools to " +"inject and execute a Python script within a running CPython process." +msgstr "本節描述了低階協議,使外部工具能夠在正在執行的 CPython 行程中注入並執行 Python 腳本。" + +#: ../../howto/remote_debugging.rst:81 +msgid "" +"This mechanism forms the basis of the :func:`sys.remote_exec` function, " +"which instructs a remote Python process to execute a ``.py`` file. However, " +"this section does not document the usage of that function. Instead, it " +"provides a detailed explanation of the underlying protocol, which takes as " +"input the ``pid`` of a target Python process and the path to a Python source " +"file to be executed. This information supports independent reimplementation " +"of the protocol, regardless of programming language." +msgstr "" +"此機制構成了 :func:`sys.remote_exec` 函式的基礎,該函式指示遠端 Python 行程執行 ``.py`` " +"檔案。但本節不記錄該函式的用法,而是提供底層協議的詳細說明,該協議以目標 Python 行程的 " +"``pid`` 和要執行的 Python 原始檔路徑作為輸入。此資訊支援該協議的獨立重新實作,無論使用何種程式語言。" + +#: ../../howto/remote_debugging.rst:91 +msgid "" +"The execution of the injected script depends on the interpreter reaching a " +"safe evaluation point. As a result, execution may be delayed depending on " +"the runtime state of the target process." +msgstr "" +"注入腳本的執行取決於直譯器是否到達安全執行點 (safe evaluation point)。因此,執行可能會根據" +"目標行程的 runtime 狀態而延遲。" + +#: ../../howto/remote_debugging.rst:95 +msgid "" +"Once injected, the script is executed by the interpreter within the target " +"process the next time a safe evaluation point is reached. This approach " +"enables remote execution capabilities without modifying the behavior or " +"structure of the running Python application." +msgstr "" +"一旦注入,腳本將在下次到達安全執行點時會由目標行程內的直譯器執行。這種方法使遠端執行功能成為可能," +"而不需修改正在執行的 Python 應用程式的行為或結構。" + +#: ../../howto/remote_debugging.rst:100 +msgid "" +"Subsequent sections provide a step-by-step description of the protocol, " +"including techniques for locating interpreter structures in memory, safely " +"accessing internal fields, and triggering code execution. Platform-specific " +"variations are noted where applicable, and example implementations are " +"included to clarify each operation." +msgstr "" +"後續章節提供了協議的逐步描述,包括在記憶體中定位直譯器結構、安全存取內部欄位以及觸發程式碼執行的技術。" +"在適用的情況下會註明平台特有的變化,並包含範例實作以闡明每個操作。" + +#: ../../howto/remote_debugging.rst:107 +msgid "Locating the PyRuntime structure" +msgstr "定位 PyRuntime 結構" + +#: ../../howto/remote_debugging.rst:109 +msgid "" +"CPython places the ``PyRuntime`` structure in a dedicated binary section to " +"help external tools find it at runtime. The name and format of this section " +"vary by platform. For example, ``.PyRuntime`` is used on ELF systems, and " +"``__DATA,__PyRuntime`` is used on macOS. Tools can find the offset of this " +"structure by examining the binary on disk." +msgstr "" +"CPython 將 ``PyRuntime`` 結構放置在專用的二進位區段(section)中,以幫助外部工具在 " +"runtime 找到它。此區段的名稱和格式因平台而異。例如,ELF 系統使用 ``.PyRuntime``、macOS " +"使用 ``__DATA,__PyRuntime``。工具可以透過檢查磁碟上的二進位檔案來找到此結構的偏移量。" + +#: ../../howto/remote_debugging.rst:115 +msgid "" +"The ``PyRuntime`` structure contains CPython’s global interpreter state and " +"provides access to other internal data, including the list of interpreters, " +"thread states, and debugger support fields." +msgstr "" +"``PyRuntime`` 結構包含 CPython 的全域直譯器狀態,並可存取其他內部資料," +"包括直譯器清單、執行緒狀態和偵錯器支援欄位。" + +#: ../../howto/remote_debugging.rst:119 +msgid "" +"To work with a remote Python process, a debugger must first find the memory " +"address of the ``PyRuntime`` structure in the target process. This address " +"can’t be hardcoded or calculated from a symbol name, because it depends on " +"where the operating system loaded the binary." +msgstr "" +"要與遠端 Python 行程協作,偵錯器必須首先找到目標行程中 ``PyRuntime`` 結構的記憶體位址。" +"此位址無法寫死或從符號名稱計算出,因為它取決於作業系統載入二進位檔案的位置。" + +#: ../../howto/remote_debugging.rst:124 +msgid "" +"The method for finding ``PyRuntime`` depends on the platform, but the steps " +"are the same in general:" +msgstr "尋找 ``PyRuntime`` 的方法取決於平台,但步驟大致相同:" + +#: ../../howto/remote_debugging.rst:127 +msgid "" +"Find the base address where the Python binary or shared library was loaded " +"in the target process." +msgstr "找到目標行程中 Python 二進位檔案或共享函式庫被載入的基底位址。" + +#: ../../howto/remote_debugging.rst:129 +msgid "" +"Use the on-disk binary to locate the offset of the ``.PyRuntime`` section." +msgstr "使用磁碟上的二進位檔案來定位 ``.PyRuntime`` 區段的偏移量。" + +#: ../../howto/remote_debugging.rst:130 +msgid "" +"Add the section offset to the base address to compute the address in memory." +msgstr "將區段偏移量加到基底位址以計算記憶體中的位址。" + +#: ../../howto/remote_debugging.rst:132 +msgid "" +"The sections below explain how to do this on each supported platform and " +"include example code." +msgstr "以下各節說明如何在每個支援的平台上執行此操作,並包含範例程式碼。" + +#: ../../howto/remote_debugging.rst:136 +msgid "Linux (ELF)" +msgstr "Linux (ELF)" + +#: ../../howto/remote_debugging.rst:137 +msgid "To find the ``PyRuntime`` structure on Linux:" +msgstr "在 Linux 上尋找 ``PyRuntime`` 結構:" + +#: ../../howto/remote_debugging.rst:139 +msgid "" +"Read the process’s memory map (for example, ``/proc//maps``) to find " +"the address where the Python executable or ``libpython`` was loaded." +msgstr "" +"讀取行程的記憶體對映(例如 ``/proc//maps``)以找到 Python 可執行檔位址或 " +"``libpython`` 被載入的位址。" + +#: ../../howto/remote_debugging.rst:141 +msgid "" +"Parse the ELF section headers in the binary to get the offset of the ``." +"PyRuntime`` section." +msgstr "剖析二進位檔案中的 ELF 區段標頭以取得 ``.PyRuntime`` 區段的偏移量。" + +#: ../../howto/remote_debugging.rst:143 +msgid "" +"Add that offset to the base address from step 1 to get the memory address of " +"``PyRuntime``." +msgstr "將該偏移量加到步驟 1 的基底位址以取得 ``PyRuntime`` 的記憶體位址。" + +#: ../../howto/remote_debugging.rst:146 ../../howto/remote_debugging.rst:208 +#: ../../howto/remote_debugging.rst:278 ../../howto/remote_debugging.rst:547 +msgid "The following is an example implementation::" +msgstr "以下是一個範例實作: ::" + +#: ../../howto/remote_debugging.rst:148 +msgid "" +"def find_py_runtime_linux(pid: int) -> int:\n" +" # Step 1: Try to find the Python executable in memory\n" +" binary_path, base_address = find_mapped_binary(\n" +" pid, name_contains=\"python\"\n" +" )\n" +"\n" +" # Step 2: Fallback to shared library if executable is not found\n" +" if binary_path is None:\n" +" binary_path, base_address = find_mapped_binary(\n" +" pid, name_contains=\"libpython\"\n" +" )\n" +"\n" +" # Step 3: Parse ELF headers to get .PyRuntime section offset\n" +" section_offset = parse_elf_section_offset(\n" +" binary_path, \".PyRuntime\"\n" +" )\n" +"\n" +" # Step 4: Compute PyRuntime address in memory\n" +" return base_address + section_offset" +msgstr "" +"def find_py_runtime_linux(pid: int) -> int:\n" +" # 步驟 1:嘗試在記憶體中找到 Python 可執行檔\n" +" binary_path, base_address = find_mapped_binary(\n" +" pid, name_contains=\"python\"\n" +" )\n" +"\n" +" # 步驟 2:如果找不到可執行檔,則改用共享函式庫\n" +" if binary_path is None:\n" +" binary_path, base_address = find_mapped_binary(\n" +" pid, name_contains=\"libpython\"\n" +" )\n" +"\n" +" # 步驟 3:剖析 ELF 標頭以取得 .PyRuntime 區段偏移量\n" +" section_offset = parse_elf_section_offset(\n" +" binary_path, \".PyRuntime\"\n" +" )\n" +"\n" +" # 步驟 4:計算 PyRuntime 在記憶體中的位址\n" +" return base_address + section_offset" + +#: ../../howto/remote_debugging.rst:169 +msgid "" +"On Linux systems, there are two main approaches to read memory from another " +"process. The first is through the ``/proc`` filesystem, specifically by " +"reading from ``/proc/[pid]/mem`` which provides direct access to the " +"process's memory. This requires appropriate permissions - either being the " +"same user as the target process or having root access. The second approach " +"is using the ``process_vm_readv()`` system call which provides a more " +"efficient way to copy memory between processes. While ptrace's " +"``PTRACE_PEEKTEXT`` operation can also be used to read memory, it is " +"significantly slower as it only reads one word at a time and requires " +"multiple context switches between the tracer and tracee processes." +msgstr "" +"在 Linux 系統上,有兩種主要方法可以從另一個行程讀取記憶體。第一種是透過 ``/proc`` " +"檔案系統,特別是從 ``/proc/[pid]/mem`` 讀取,這提供了對行程記憶體的直接存取。這需要" +"適當的權限 - 要麼與目標行程是同一使用者,要麼就要擁有 root 存取權限。第二種方法是使用 " +"``process_vm_readv()`` 系統呼叫,它提供了在行程之間複製記憶體的更有效方式。雖然 ptrace " +"的 ``PTRACE_PEEKTEXT`` 操作也可以用來讀取記憶體,但它明顯較慢,因為它一次只讀取一個字," +"並且需要追蹤器和被追蹤行程之間的多次情境切換。" + +#: ../../howto/remote_debugging.rst:180 +msgid "" +"For parsing ELF sections, the process involves reading and interpreting the " +"ELF file format structures from the binary file on disk. The ELF header " +"contains a pointer to the section header table. Each section header contains " +"metadata about a section including its name (stored in a separate string " +"table), offset, and size. To find a specific section like .PyRuntime, you " +"need to walk through these headers and match the section name. The section " +"header then provides the offset where that section exists in the file, which " +"can be used to calculate its runtime address when the binary is loaded into " +"memory." +msgstr "" +"對於剖析 ELF 區段,該過程涉及從磁碟上的二進位檔案讀取並解釋 ELF 檔案格式結構。ELF" +"標頭包含指向區段標頭表的指標。每個區段標頭包含關於區段的中介資料,包括其名稱(儲存在單獨" +"的字串表中)、偏移量和大小。要找到像 .PyRuntime 這樣的特定區段,你需要遍歷這些標頭並匹" +"配區段名稱。然後區段標頭會提供該區段在檔案中存在的偏移量,當二進位檔案載入到記憶體時," +"可以用它來計算 runtime 位址。" + +#: ../../howto/remote_debugging.rst:189 +msgid "" +"You can read more about the ELF file format in the `ELF specification " +"`_." +msgstr "" +"你可以在 `ELF 規範 `_\\ " +"中閱讀更多關於 ELF 檔案格式的資訊。" + +#: ../../howto/remote_debugging.rst:194 +msgid "macOS (Mach-O)" +msgstr "macOS (Mach-O)" + +#: ../../howto/remote_debugging.rst:195 +msgid "To find the ``PyRuntime`` structure on macOS:" +msgstr "在 macOS 上找 ``PyRuntime`` 結構:" + +#: ../../howto/remote_debugging.rst:197 +msgid "" +"Call ``task_for_pid()`` to get the ``mach_port_t`` task port for the target " +"process. This handle is needed to read memory using APIs like " +"``mach_vm_read_overwrite`` and ``mach_vm_region``." +msgstr "" +"呼叫 ``task_for_pid()`` 以取得目標行程的 ``mach_port_t`` 任務埠 (task port)。" +"此控制代碼 (handle) 用於使用像 ``mach_vm_read_overwrite`` 和 ``mach_vm_region`` " +"這樣的 API 來讀取記憶體。" + +#: ../../howto/remote_debugging.rst:200 +msgid "" +"Scan the memory regions to find the one containing the Python executable or " +"``libpython``." +msgstr "掃描記憶體區域以找到包含 Python 可執行檔或 ``libpython`` 的區域。" + +#: ../../howto/remote_debugging.rst:202 +msgid "" +"Load the binary file from disk and parse the Mach-O headers to find the " +"section named ``PyRuntime`` in the ``__DATA`` segment. On macOS, symbol " +"names are automatically prefixed with an underscore, so the ``PyRuntime`` " +"symbol appears as ``_PyRuntime`` in the symbol table, but the section name " +"is not affected." +msgstr "" +"從磁碟載入二進位檔案並剖析 Mach-O 標頭以找到 ``__DATA`` 程式段(segment)中名為 " +"``PyRuntime`` 的區段。在 macOS 上,符號名稱會自動加上底線前綴,因此 ``PyRuntime`` " +"符號在符號表中顯示為 ``_PyRuntime``,但區段名稱不受影響。" + +#: ../../howto/remote_debugging.rst:210 +msgid "" +"def find_py_runtime_macos(pid: int) -> int:\n" +" # Step 1: Get access to the process's memory\n" +" handle = get_memory_access_handle(pid)\n" +"\n" +" # Step 2: Try to find the Python executable in memory\n" +" binary_path, base_address = find_mapped_binary(\n" +" handle, name_contains=\"python\"\n" +" )\n" +"\n" +" # Step 3: Fallback to libpython if the executable is not found\n" +" if binary_path is None:\n" +" binary_path, base_address = find_mapped_binary(\n" +" handle, name_contains=\"libpython\"\n" +" )\n" +"\n" +" # Step 4: Parse Mach-O headers to get __DATA,__PyRuntime section offset\n" +" section_offset = parse_macho_section_offset(\n" +" binary_path, \"__DATA\", \"__PyRuntime\"\n" +" )\n" +"\n" +" # Step 5: Compute the PyRuntime address in memory\n" +" return base_address + section_offset" +msgstr "" +"def find_py_runtime_macos(pid: int) -> int:\n" +" # 步驟 1:取得對行程記憶體的存取權限\n" +" handle = get_memory_access_handle(pid)\n" +"\n" +" # 步驟 2:嘗試在記憶體中找到 Python 可執行檔\n" +" binary_path, base_address = find_mapped_binary(\n" +" handle, name_contains=\"python\"\n" +" )\n" +"\n" +" # 步驟 3:如果找不到可執行檔,則改用 libpython\n" +" if binary_path is None:\n" +" binary_path, base_address = find_mapped_binary(\n" +" handle, name_contains=\"libpython\"\n" +" )\n" +"\n" +" # 步驟 4:剖析 Mach-O 標頭以取得 __DATA,__PyRuntime 區段偏移量\n" +" section_offset = parse_macho_section_offset(\n" +" binary_path, \"__DATA\", \"__PyRuntime\"\n" +" )\n" +"\n" +" # 步驟 5:計算 PyRuntime 在記憶體中的位址\n" +" return base_address + section_offset" + +#: ../../howto/remote_debugging.rst:233 +msgid "" +"On macOS, accessing another process's memory requires using Mach-O specific " +"APIs and file formats. The first step is obtaining a ``task_port`` handle " +"via ``task_for_pid()``, which provides access to the target process's memory " +"space. This handle enables memory operations through APIs like " +"``mach_vm_read_overwrite()``." +msgstr "" +"在 macOS 上,存取另一個行程的記憶體需要使用 Mach-O 特定的 API 和檔案格式。第一步是透過 " +"``task_for_pid()`` 取得 ``task_port`` 控制代碼,它提供對目標行程記憶體空間的存取。" +"此控制代碼透過像 ``mach_vm_read_overwrite()`` 這樣的 API 啟用記憶體操作。" + +#: ../../howto/remote_debugging.rst:239 +msgid "" +"The process memory can be examined using ``mach_vm_region()`` to scan " +"through the virtual memory space, while ``proc_regionfilename()`` helps " +"identify which binary files are loaded at each memory region. When the " +"Python binary or library is found, its Mach-O headers need to be parsed to " +"locate the ``PyRuntime`` structure." +msgstr "" +"可以使用 ``mach_vm_region()`` 掃描虛擬記憶體空間來檢查行程記憶體,而 ``proc_regionfilename()`` " +"幫助識別在每個記憶體區域載入了哪些二進位檔案。當找到 Python 二進位檔案或函式庫時,需要剖析其 Mach-O " +"標頭以定位 ``PyRuntime`` 結構。" + +#: ../../howto/remote_debugging.rst:244 +msgid "" +"The Mach-O format organizes code and data into segments and sections. The " +"``PyRuntime`` structure lives in a section named ``__PyRuntime`` within the " +"``__DATA`` segment. The actual runtime address calculation involves finding " +"the ``__TEXT`` segment which serves as the binary's base address, then " +"locating the ``__DATA`` segment containing our target section. The final " +"address is computed by combining the base address with the appropriate " +"section offsets from the Mach-O headers." +msgstr "" +"Mach-O 格式將程式碼和資料組織成程式段和區段。``PyRuntime`` 結構位於 ``__DATA`` 程式段內名" +"為 ``__PyRuntime`` 的區段中。實際的 runtime 位址計算涉及找到作為二進位檔案基底位址的 ``__TEXT`` " +"程式段,然後定位包含我們目標區段的 ``__DATA`` 程式段。最終位址是透過將基底位址與來自 Mach-O " +"標頭的適當區段偏移量組合來計算的。" + +#: ../../howto/remote_debugging.rst:252 +msgid "" +"Note that accessing another process's memory on macOS typically requires " +"elevated privileges - either root access or special security entitlements " +"granted to the debugging process." +msgstr "" +"請注意,在 macOS 上存取另一個行程的記憶體通常需要提升過後的權限 - " +"要麼是 root 存取權限,要麼是授予偵錯行程的特殊安全授權。" + +#: ../../howto/remote_debugging.rst:258 +msgid "Windows (PE)" +msgstr "Windows (PE)" + +#: ../../howto/remote_debugging.rst:259 +msgid "To find the ``PyRuntime`` structure on Windows:" +msgstr "在 Windows 上找 ``PyRuntime`` 結構:" + +#: ../../howto/remote_debugging.rst:261 +msgid "" +"Use the ToolHelp API to enumerate all modules loaded in the target process. " +"This is done using functions such as `CreateToolhelp32Snapshot `_, `Module32First `_, and " +"`Module32Next `_." +msgstr "" +"使用 ToolHelp API 來列舉目標行程中載入的所有模組。這是使用諸如 `CreateToolhelp32Snapshot " +"`_、`Module32First `_ 和 " +"`Module32Next `_ 等函式來完成的。" + +#: ../../howto/remote_debugging.rst:268 +msgid "" +"Identify the module corresponding to :file:`python.exe` or :file:`python{XY}." +"dll`, where ``X`` and ``Y`` are the major and minor version numbers of the " +"Python version, and record its base address." +msgstr "" +"識別對應於 :file:`python.exe` 或 :file:`python{XY}.dll` 的模組,其中 ``X`` 和 ``Y`` 是" +"Python 版本的主要和次要版本號,並記錄其基底位址。" + +#: ../../howto/remote_debugging.rst:271 +msgid "" +"Locate the ``PyRuntim`` section. Due to the PE format's 8-character limit on " +"section names (defined as ``IMAGE_SIZEOF_SHORT_NAME``), the original name " +"``PyRuntime`` is truncated. This section contains the ``PyRuntime`` " +"structure." +msgstr "" +"定位 ``PyRuntim`` 區段。由於 PE 格式對區段名稱有 8 個字元的限制(定義為 " +"``IMAGE_SIZEOF_SHORT_NAME``),所以原始名稱 ``PyRuntime`` 會被截斷。此區段包含 " +"``PyRuntime`` 結構。" + +#: ../../howto/remote_debugging.rst:275 +msgid "" +"Retrieve the section’s relative virtual address (RVA) and add it to the base " +"address of the module." +msgstr "檢索區段的相對虛擬位址 (RVA, relative virtual address) 並將其加到模組的基底位址。" + +#: ../../howto/remote_debugging.rst:280 +msgid "" +"def find_py_runtime_windows(pid: int) -> int:\n" +" # Step 1: Try to find the Python executable in memory\n" +" binary_path, base_address = find_loaded_module(\n" +" pid, name_contains=\"python\"\n" +" )\n" +"\n" +" # Step 2: Fallback to shared pythonXY.dll if the executable is not\n" +" # found\n" +" if binary_path is None:\n" +" binary_path, base_address = find_loaded_module(\n" +" pid, name_contains=\"python3\"\n" +" )\n" +"\n" +" # Step 3: Parse PE section headers to get the RVA of the PyRuntime\n" +" # section. The section name appears as \"PyRuntim\" due to the\n" +" # 8-character limit defined by the PE format (IMAGE_SIZEOF_SHORT_NAME).\n" +" section_rva = parse_pe_section_offset(binary_path, \"PyRuntim\")\n" +"\n" +" # Step 4: Compute PyRuntime address in memory\n" +" return base_address + section_rva" +msgstr "" +"def find_py_runtime_windows(pid: int) -> int:\n" +" # 步驟 1:嘗試在記憶體中找到 Python 可執行檔\n" +" binary_path, base_address = find_loaded_module(\n" +" pid, name_contains=\"python\"\n" +" )\n" +"\n" +" # 步驟 2:如果找不到可執行檔,則改用共享函式庫 pythonXY.dll\n" +" if binary_path is None:\n" +" binary_path, base_address = find_loaded_module(\n" +" pid, name_contains=\"python3\"\n" +" )\n" +"\n" +" # 步驟 3:剖析 PE 區段標頭以取得 PyRuntime 區段的 RVA。\n" +" # 由於 PE 格式 (IMAGE_SIZEOF_SHORT_NAME) 有8 字元的限制,\n" +" # 區段名稱顯示為 \"PyRuntim\"。\n" +" section_rva = parse_pe_section_offset(binary_path, \"PyRuntim\")\n" +"\n" +" # 步驟 4:計算 PyRuntime 在記憶體中的位址\n" +" return base_address + section_rva" + +#: ../../howto/remote_debugging.rst:302 +msgid "" +"On Windows, accessing another process's memory requires using the Windows " +"API functions like ``CreateToolhelp32Snapshot()`` and ``Module32First()/" +"Module32Next()`` to enumerate loaded modules. The ``OpenProcess()`` function " +"provides a handle to access the target process's memory space, enabling " +"memory operations through ``ReadProcessMemory()``." +msgstr "" +"在 Windows 上,存取另一個行程的記憶體需要使用像 ``CreateToolhelp32Snapshot()`` 和 " +"``Module32First()/Module32Next()`` 這樣的 Windows API 函式來列舉載入的模組。" +"``OpenProcess()`` 函式提供一個控制代碼來存取目標行程的記憶體空間,並透過 " +"``ReadProcessMemory()`` 啟用記憶體操作。" + +#: ../../howto/remote_debugging.rst:308 +msgid "" +"The process memory can be examined by enumerating loaded modules to find the " +"Python binary or DLL. When found, its PE headers need to be parsed to locate " +"the ``PyRuntime`` structure." +msgstr "" +"可以透過列舉載入的模組來檢查行程記憶體,以找到 Python 二進位檔案或 DLL。找到後,需要剖析其 PE " +"標頭以定位 ``PyRuntime`` 結構。" + +#: ../../howto/remote_debugging.rst:312 +msgid "" +"The PE format organizes code and data into sections. The ``PyRuntime`` " +"structure lives in a section named \"PyRuntim\" (truncated from " +"\"PyRuntime\" due to PE's 8-character name limit). The actual runtime " +"address calculation involves finding the module's base address from the " +"module entry, then locating our target section in the PE headers. The final " +"address is computed by combining the base address with the section's virtual " +"address from the PE section headers." +msgstr "" +"PE 格式將程式碼和資料組織成區段。``PyRuntime`` 結構位於名為 \"PyRuntim\" " +"的區段中(由於 PE 的 8 字元名稱限制,從 \"PyRuntime\" 截斷)。實際的 runtime " +"位址計算涉及從模組項目中找到模組的基底位址,然後在 PE 標頭中定位我們的目標區段。" +"最終位址是透過將基底位址與 PE 區段標頭中的區段虛擬位址組合來計算的。" + +#: ../../howto/remote_debugging.rst:319 +msgid "" +"Note that accessing another process's memory on Windows typically requires " +"appropriate privileges - either administrative access or the " +"``SeDebugPrivilege`` privilege granted to the debugging process." +msgstr "" +"請注意,在 Windows 上存取另一個行程的記憶體通常需要適當的權限 - 要麼是系統管理員存取權限" +",要麼是授予偵錯行程的 ``SeDebugPrivilege`` 權限。" + +#: ../../howto/remote_debugging.rst:325 +msgid "Reading _Py_DebugOffsets" +msgstr "讀取 _Py_DebugOffsets" + +#: ../../howto/remote_debugging.rst:327 +msgid "" +"Once the address of the ``PyRuntime`` structure has been determined, the " +"next step is to read the ``_Py_DebugOffsets`` structure located at the " +"beginning of the ``PyRuntime`` block." +msgstr "" +"一旦確定了 ``PyRuntime`` 結構的位址,下一步就是讀取位於 ``PyRuntime`` 區塊開頭的 " +"``_Py_DebugOffsets`` 結構。" + +#: ../../howto/remote_debugging.rst:331 +msgid "" +"This structure provides version-specific field offsets that are needed to " +"safely read interpreter and thread state memory. These offsets vary between " +"CPython versions and must be checked before use to ensure they are " +"compatible." +msgstr "" +"此結構提供了安全讀取直譯器和執行緒狀態記憶體所需的版本特定欄位偏移量。這些偏移量在不同的 CPython " +"版本之間有所不同,必須在使用前檢查以確保它們相容。" + +#: ../../howto/remote_debugging.rst:335 +msgid "To read and check the debug offsets, follow these steps:" +msgstr "要讀取並檢查偵錯偏移量,請按照以下步驟操作:" + +#: ../../howto/remote_debugging.rst:337 +msgid "" +"Read memory from the target process starting at the ``PyRuntime`` address, " +"covering the same number of bytes as the ``_Py_DebugOffsets`` structure. " +"This structure is located at the very start of the ``PyRuntime`` memory " +"block. Its layout is defined in CPython’s internal headers and stays the " +"same within a given minor version, but may change in major versions." +msgstr "" +"從目標行程中的 ``PyRuntime`` 位址開始讀取記憶體,涵蓋與 ``_Py_DebugOffsets`` 結構相同的位元組數。" +"此結構位於 ``PyRuntime`` 記憶體區塊的最開始處。" +"其佈局 (layout) 在 CPython 的內部標頭中定義,並在給定的次要版本中維持不變,但在主要版本中可能會更改。" + +#: ../../howto/remote_debugging.rst:343 +msgid "Check that the structure contains valid data:" +msgstr "檢查結構是否包含有效資料:" + +#: ../../howto/remote_debugging.rst:345 +msgid "The ``cookie`` field must match the expected debug marker." +msgstr "``cookie`` 欄位必須匹配預期的偵錯標記。" + +#: ../../howto/remote_debugging.rst:346 +msgid "" +"The ``version`` field must match the version of the Python interpreter used " +"by the debugger." +msgstr "``version`` 欄位必須匹配偵錯器使用的 Python 直譯器版本。" + +#: ../../howto/remote_debugging.rst:348 +msgid "" +"If either the debugger or the target process is using a pre-release version " +"(for example, an alpha, beta, or release candidate), the versions must match " +"exactly." +msgstr "如果偵錯器或目標行程使用的是預發行版本(例如 alpha、beta 或候選版本),版本必須完全匹配。" + +#: ../../howto/remote_debugging.rst:351 +msgid "" +"The ``free_threaded`` field must have the same value in both the debugger " +"and the target process." +msgstr "``free_threaded`` 欄位在偵錯器和目標行程中必須具有相同的值。" + +#: ../../howto/remote_debugging.rst:354 +msgid "" +"If the structure is valid, the offsets it contains can be used to locate " +"fields in memory. If any check fails, the debugger should stop the operation " +"to avoid reading memory in the wrong format." +msgstr "" +"如果結構有效,其中包含的偏移量可用於定位記憶體中的欄位。如果任何檢查失敗,偵錯器應停止操作" +"以避免以錯誤的格式讀取記憶體。" + +#: ../../howto/remote_debugging.rst:358 +msgid "" +"The following is an example implementation that reads and checks " +"``_Py_DebugOffsets``::" +msgstr "以下是一個讀取並檢查 ``_Py_DebugOffsets`` 的範例實作: ::" + +#: ../../howto/remote_debugging.rst:361 +msgid "" +"def read_debug_offsets(pid: int, py_runtime_addr: int) -> DebugOffsets:\n" +" # Step 1: Read memory from the target process at the PyRuntime address\n" +" data = read_process_memory(\n" +" pid, address=py_runtime_addr, size=DEBUG_OFFSETS_SIZE\n" +" )\n" +"\n" +" # Step 2: Deserialize the raw bytes into a _Py_DebugOffsets structure\n" +" debug_offsets = parse_debug_offsets(data)\n" +"\n" +" # Step 3: Validate the contents of the structure\n" +" if debug_offsets.cookie != EXPECTED_COOKIE:\n" +" raise RuntimeError(\"Invalid or missing debug cookie\")\n" +" if debug_offsets.version != LOCAL_PYTHON_VERSION:\n" +" raise RuntimeError(\n" +" \"Mismatch between caller and target Python versions\"\n" +" )\n" +" if debug_offsets.free_threaded != LOCAL_FREE_THREADED:\n" +" raise RuntimeError(\"Mismatch in free-threaded configuration\")\n" +"\n" +" return debug_offsets" +msgstr "" +"def read_debug_offsets(pid: int, py_runtime_addr: int) -> DebugOffsets:\n" +" # 步驟 1:在 PyRuntime 位址從目標行程讀取記憶體\n" +" data = read_process_memory(\n" +" pid, address=py_runtime_addr, size=DEBUG_OFFSETS_SIZE\n" +" )\n" +"\n" +" # 步驟 2:將原始位元組反序列化為 _Py_DebugOffsets 結構\n" +" debug_offsets = parse_debug_offsets(data)\n" +"\n" +" # 步驟 3:驗證結構的內容\n" +" if debug_offsets.cookie != EXPECTED_COOKIE:\n" +" raise RuntimeError(\"Invalid or missing debug cookie\")\n" +" if debug_offsets.version != LOCAL_PYTHON_VERSION:\n" +" raise RuntimeError(\n" +" \"Mismatch between caller and target Python versions\"\n" +" )\n" +" if debug_offsets.free_threaded != LOCAL_FREE_THREADED:\n" +" raise RuntimeError(\"Mismatch in free-threaded configuration\")\n" +"\n" +" return debug_offsets" + +#: ../../howto/remote_debugging.rst:386 +msgid "**Process suspension recommended**" +msgstr "**建議暫停行程**" + +#: ../../howto/remote_debugging.rst:388 +msgid "" +"To avoid race conditions and ensure memory consistency, it is strongly " +"recommended that the target process be suspended before performing any " +"operations that read or write internal interpreter state. The Python runtime " +"may concurrently mutate interpreter data structures—such as creating or " +"destroying threads—during normal execution. This can result in invalid " +"memory reads or writes." +msgstr "" +"為了避免競態條件 (race conditions) 並確保記憶體一致性,強烈建議在執行任何讀取或寫入" +"內部直譯器狀態的操作之前暫停目標行程。Python runtime 可能在正常執行期間同時變更直譯器" +"資料結構 - 例如建立或銷毀執行緒。這可能導致無效的記憶體讀取或寫入。" + +#: ../../howto/remote_debugging.rst:395 +msgid "" +"A debugger may suspend execution by attaching to the process with ``ptrace`` " +"or by sending a ``SIGSTOP`` signal. Execution should only be resumed after " +"debugger-side memory operations are complete." +msgstr "" +"偵錯器可以透過使用 ``ptrace`` 附加到行程或發送 ``SIGSTOP`` 訊號來暫停執行。只有在偵錯器" +"端的記憶體操作完成後才應恢復執行。" + +#: ../../howto/remote_debugging.rst:401 +msgid "" +"Some tools, such as profilers or sampling-based debuggers, may operate on a " +"running process without suspension. In such cases, tools must be explicitly " +"designed to handle partially updated or inconsistent memory. For most " +"debugger implementations, suspending the process remains the safest and most " +"robust approach." +msgstr "" +"一些工具,例如分析器 (profilers) 或基於取樣的偵錯器,可能在不暫停的情況下對正在執行的行程" +"進行操作。在這種情況下,工具必須明確設計為能夠處理部分更新或不一致的記憶體。對於大多數偵錯器" +"實作來說,暫停行程仍然是最安全可靠的方法。" + +#: ../../howto/remote_debugging.rst:409 +msgid "Locating the interpreter and thread state" +msgstr "定位直譯器和執行緒狀態" + +#: ../../howto/remote_debugging.rst:411 +msgid "" +"Before code can be injected and executed in a remote Python process, the " +"debugger must choose a thread in which to schedule execution. This is " +"necessary because the control fields used to perform remote code injection " +"are located in the ``_PyRemoteDebuggerSupport`` structure, which is embedded " +"in a ``PyThreadState`` object. These fields are modified by the debugger to " +"request execution of injected scripts." +msgstr "" +"在可以於遠端 Python 行程中注入並執行程式碼之前,偵錯器必須選擇一個用於排程執行的執行緒。" +"這是必要的,因為用於執行遠端程式碼注入的控制欄位位於 ``_PyRemoteDebuggerSupport`` " +"結構中,該結構嵌入在 ``PyThreadState`` 物件中。偵錯器會修改這些欄位以請求執行注入的腳本。" + +#: ../../howto/remote_debugging.rst:418 +msgid "" +"The ``PyThreadState`` structure represents a thread running inside a Python " +"interpreter. It maintains the thread’s evaluation context and contains the " +"fields required for debugger coordination. Locating a valid " +"``PyThreadState`` is therefore a key prerequisite for triggering execution " +"remotely." +msgstr "" +"``PyThreadState`` 結構代表在 Python 直譯器內執行的執行緒。它維護執行緒的求值情境 " +"(evaluation context),並包含偵錯器協調所需的欄位。因此,定位有效的 ``PyThreadState`` " +"是遠端觸發執行的關鍵前提。" + +#: ../../howto/remote_debugging.rst:423 +msgid "" +"A thread is typically selected based on its role or ID. In most cases, the " +"main thread is used, but some tools may target a specific thread by its " +"native thread ID. Once the target thread is chosen, the debugger must locate " +"both the interpreter and the associated thread state structures in memory." +msgstr "" +"通常根據執行緒的角色或 ID 來選擇執行緒。在大多數情況下會使用主執行緒,但某些工具可能會透過其原生執行緒 ID " +"來定位特定執行緒。一旦選擇了目標執行緒,偵錯器必須在記憶體中定位直譯器和相關的執行緒狀態結構。" + +#: ../../howto/remote_debugging.rst:428 +msgid "The relevant internal structures are defined as follows:" +msgstr "相關的內部結構定義如下:" + +#: ../../howto/remote_debugging.rst:430 +msgid "" +"``PyInterpreterState`` represents an isolated Python interpreter instance. " +"Each interpreter maintains its own set of imported modules, built-in state, " +"and thread state list. Although most Python applications use a single " +"interpreter, CPython supports multiple interpreters in the same process." +msgstr "" +"``PyInterpreterState`` 代表一個隔離的 Python 直譯器實例。每個直譯器維護自己的一組" +"已引入模組、內建狀態和執行緒狀態串列。雖然大多數 Python 應用程式使用單一直譯器,但 CPython " +"支援在同一行程中使用多個直譯器。" + +#: ../../howto/remote_debugging.rst:435 +msgid "" +"``PyThreadState`` represents a thread running within an interpreter. It " +"contains execution state and the control fields used by the debugger." +msgstr "``PyThreadState`` 代表在直譯器內運行的執行緒。它包含執行狀態和偵錯器使用的控制欄位。" + +#: ../../howto/remote_debugging.rst:438 +msgid "To locate a thread:" +msgstr "要定位執行緒:" + +#: ../../howto/remote_debugging.rst:440 +msgid "" +"Use the offset ``runtime_state.interpreters_head`` to obtain the address of " +"the first interpreter in the ``PyRuntime`` structure. This is the entry " +"point to the linked list of active interpreters." +msgstr "" +"使用偏移量 ``runtime_state.interpreters_head`` 來取得 ``PyRuntime`` " +"結構中第一個直譯器的位址。這是活動直譯器鏈結串列的進入點。" + +#: ../../howto/remote_debugging.rst:444 +msgid "" +"Use the offset ``interpreter_state.threads_main`` to access the main thread " +"state associated with the selected interpreter. This is typically the most " +"reliable thread to target." +msgstr "" +"使用偏移量 ``interpreter_state.threads_main`` 來存取與所選直譯器相關的主執行緒狀態。" +"這通常是最可靠的目標執行緒。" + +#: ../../howto/remote_debugging.rst:448 +msgid "" +"Optionally, use the offset ``interpreter_state.threads_head`` to iterate " +"through the linked list of all thread states. Each ``PyThreadState`` " +"structure contains a ``native_thread_id`` field, which may be compared to a " +"target thread ID to find a specific thread." +msgstr "" +"可選地使用偏移量 ``interpreter_state.threads_head`` 來遍歷所有執行緒狀態的鏈結串列。每個 " +"``PyThreadState`` 結構包含一個 ``native_thread_id`` 欄位,可以將其與目標執行緒 ID 進行比" +"較以找到特定執行緒。" + +#: ../../howto/remote_debugging.rst:453 +msgid "" +"Once a valid ``PyThreadState`` has been found, its address can be used in " +"later steps of the protocol, such as writing debugger control fields and " +"scheduling execution." +msgstr "" +"一旦找到有效的 ``PyThreadState``,其位址可以在協議的後續步驟中使用,例如寫入偵錯器控制欄位" +"和排程執行。" + +#: ../../howto/remote_debugging.rst:457 +msgid "" +"The following is an example implementation that locates the main thread " +"state::" +msgstr "以下是一個定位主執行緒狀態的範例實作: ::" + +#: ../../howto/remote_debugging.rst:459 +msgid "" +"def find_main_thread_state(\n" +" pid: int, py_runtime_addr: int, debug_offsets: DebugOffsets,\n" +") -> int:\n" +" # Step 1: Read interpreters_head from PyRuntime\n" +" interp_head_ptr = (\n" +" py_runtime_addr + debug_offsets.runtime_state.interpreters_head\n" +" )\n" +" interp_addr = read_pointer(pid, interp_head_ptr)\n" +" if interp_addr == 0:\n" +" raise RuntimeError(\"No interpreter found in the target process\")\n" +"\n" +" # Step 2: Read the threads_main pointer from the interpreter\n" +" threads_main_ptr = (\n" +" interp_addr + debug_offsets.interpreter_state.threads_main\n" +" )\n" +" thread_state_addr = read_pointer(pid, threads_main_ptr)\n" +" if thread_state_addr == 0:\n" +" raise RuntimeError(\"Main thread state is not available\")\n" +"\n" +" return thread_state_addr" +msgstr "" +"def find_main_thread_state(\n" +" pid: int, py_runtime_addr: int, debug_offsets: DebugOffsets,\n" +") -> int:\n" +" # 步驟 1:從 PyRuntime 讀取 interpreters_head\n" +" interp_head_ptr = (\n" +" py_runtime_addr + debug_offsets.runtime_state.interpreters_head\n" +" )\n" +" interp_addr = read_pointer(pid, interp_head_ptr)\n" +" if interp_addr == 0:\n" +" raise RuntimeError(\"No interpreter found in the target process\")\n" +"\n" +" # 步驟 2:從直譯器讀取 threads_main 指標\n" +" threads_main_ptr = (\n" +" interp_addr + debug_offsets.interpreter_state.threads_main\n" +" )\n" +" thread_state_addr = read_pointer(pid, threads_main_ptr)\n" +" if thread_state_addr == 0:\n" +" raise RuntimeError(\"Main thread state is not available\")\n" +"\n" +" return thread_state_addr" + +#: ../../howto/remote_debugging.rst:480 +msgid "" +"The following example demonstrates how to locate a thread by its native " +"thread ID::" +msgstr "以下範例示範如何透過原生執行緒 ID 來定位執行緒: ::" + +#: ../../howto/remote_debugging.rst:483 +msgid "" +"def find_thread_by_id(\n" +" pid: int,\n" +" interp_addr: int,\n" +" debug_offsets: DebugOffsets,\n" +" target_tid: int,\n" +") -> int:\n" +" # Start at threads_head and walk the linked list\n" +" thread_ptr = read_pointer(\n" +" pid,\n" +" interp_addr + debug_offsets.interpreter_state.threads_head\n" +" )\n" +"\n" +" while thread_ptr:\n" +" native_tid_ptr = (\n" +" thread_ptr + debug_offsets.thread_state.native_thread_id\n" +" )\n" +" native_tid = read_int(pid, native_tid_ptr)\n" +" if native_tid == target_tid:\n" +" return thread_ptr\n" +" thread_ptr = read_pointer(\n" +" pid,\n" +" thread_ptr + debug_offsets.thread_state.next\n" +" )\n" +"\n" +" raise RuntimeError(\"Thread with the given ID was not found\")" +msgstr "" +"def find_thread_by_id(\n" +" pid: int,\n" +" interp_addr: int,\n" +" debug_offsets: DebugOffsets,\n" +" target_tid: int,\n" +") -> int:\n" +" # 從 threads_head 開始並遍歷鏈結串列\n" +" thread_ptr = read_pointer(\n" +" pid,\n" +" interp_addr + debug_offsets.interpreter_state.threads_head\n" +" )\n" +"\n" +" while thread_ptr:\n" +" native_tid_ptr = (\n" +" thread_ptr + debug_offsets.thread_state.native_thread_id\n" +" )\n" +" native_tid = read_int(pid, native_tid_ptr)\n" +" if native_tid == target_tid:\n" +" return thread_ptr\n" +" thread_ptr = read_pointer(\n" +" pid,\n" +" thread_ptr + debug_offsets.thread_state.next\n" +" )\n" +"\n" +" raise RuntimeError(\"Thread with the given ID was not found\")" + +#: ../../howto/remote_debugging.rst:510 +msgid "" +"Once a valid thread state has been located, the debugger can proceed with " +"modifying its control fields and scheduling execution, as described in the " +"next section." +msgstr "一旦定位到有效的執行緒狀態,偵錯器就可以繼續修改其控制欄位並排程執行,如下一節所述。" + +#: ../../howto/remote_debugging.rst:515 +msgid "Writing control information" +msgstr "寫入控制資訊" + +#: ../../howto/remote_debugging.rst:517 +msgid "" +"Once a valid ``PyThreadState`` structure has been identified, the debugger " +"may modify control fields within it to schedule the execution of a specified " +"Python script. These control fields are checked periodically by the " +"interpreter, and when set correctly, they trigger the execution of remote " +"code at a safe point in the evaluation loop." +msgstr "" +"一旦識別出有效的 ``PyThreadState`` 結構,偵錯器就可以修改其中的控制欄位以排程執行指定的 Python " +"腳本。直譯器會定期檢查這些控制欄位,當正確設定時,它們會在求值迴圈中的安全點觸發遠端程式碼的執行。" + +#: ../../howto/remote_debugging.rst:523 +msgid "" +"Each ``PyThreadState`` contains a ``_PyRemoteDebuggerSupport`` structure " +"used for communication between the debugger and the interpreter. The " +"locations of its fields are defined by the ``_Py_DebugOffsets`` structure " +"and include the following:" +msgstr "" +"每個 ``PyThreadState`` 都包含一個 ``_PyRemoteDebuggerSupport`` 結構," +"能用於偵錯器和直譯器之間的通訊。其欄位的位置由 ``_Py_DebugOffsets`` 結構定義,包括以下內容:" + +#: ../../howto/remote_debugging.rst:528 +msgid "" +"``debugger_script_path``: A fixed-size buffer that holds the full path to a " +"Python source file (``.py``). This file must be accessible and readable by " +"the target process when execution is triggered." +msgstr "" +"``debugger_script_path``:一個固定大小的緩衝區,用於保存 Python " +"原始檔(``.py``)的完整路徑。觸發執行時,目標行程必須能夠存取和讀取此檔案。" + +#: ../../howto/remote_debugging.rst:532 +msgid "" +"``debugger_pending_call``: An integer flag. Setting this to ``1`` tells the " +"interpreter that a script is ready to be executed." +msgstr "``debugger_pending_call``:一個整數旗標。將其設定為 ``1`` 會告訴直譯器腳本已準備好執行。" + +#: ../../howto/remote_debugging.rst:535 +msgid "" +"``eval_breaker``: A field checked by the interpreter during execution. " +"Setting bit 5 (``_PY_EVAL_PLEASE_STOP_BIT``, value ``1U << 5``) in this " +"field causes the interpreter to pause and check for debugger activity." +msgstr "" +"``eval_breaker``:直譯器在執行期間檢查的欄位。在此欄位中設定位元 5(``_PY_EVAL_PLEASE_STOP_BIT``,值 " +"``1U << 5``)會導致直譯器暫停並檢查偵錯器活動。" + +#: ../../howto/remote_debugging.rst:539 +msgid "" +"To complete the injection, the debugger must perform the following steps:" +msgstr "要完成注入,偵錯器必須執行以下步驟:" + +#: ../../howto/remote_debugging.rst:541 +msgid "Write the full script path into the ``debugger_script_path`` buffer." +msgstr "將完整的腳本路徑寫入 ``debugger_script_path`` 緩衝區。" + +#: ../../howto/remote_debugging.rst:542 +msgid "Set ``debugger_pending_call`` to ``1``." +msgstr "將 ``debugger_pending_call`` 設定為 ``1``。" + +#: ../../howto/remote_debugging.rst:543 +msgid "" +"Read the current value of ``eval_breaker``, set bit 5 " +"(``_PY_EVAL_PLEASE_STOP_BIT``), and write the updated value back. This " +"signals the interpreter to check for debugger activity." +msgstr "" +"讀取 ``eval_breaker`` 目前的值,設定位元 5(``_PY_EVAL_PLEASE_STOP_BIT``)" +"並將更新後的值寫回。這會向直譯器發出檢查偵錯器活動的訊號。" + +#: ../../howto/remote_debugging.rst:549 +msgid "" +"def inject_script(\n" +" pid: int,\n" +" thread_state_addr: int,\n" +" debug_offsets: DebugOffsets,\n" +" script_path: str\n" +") -> None:\n" +" # Compute the base offset of _PyRemoteDebuggerSupport\n" +" support_base = (\n" +" thread_state_addr +\n" +" debug_offsets.debugger_support.remote_debugger_support\n" +" )\n" +"\n" +" # Step 1: Write the script path into debugger_script_path\n" +" script_path_ptr = (\n" +" support_base +\n" +" debug_offsets.debugger_support.debugger_script_path\n" +" )\n" +" write_string(pid, script_path_ptr, script_path)\n" +"\n" +" # Step 2: Set debugger_pending_call to 1\n" +" pending_ptr = (\n" +" support_base +\n" +" debug_offsets.debugger_support.debugger_pending_call\n" +" )\n" +" write_int(pid, pending_ptr, 1)\n" +"\n" +" # Step 3: Set _PY_EVAL_PLEASE_STOP_BIT (bit 5, value 1 << 5) in\n" +" # eval_breaker\n" +" eval_breaker_ptr = (\n" +" thread_state_addr +\n" +" debug_offsets.debugger_support.eval_breaker\n" +" )\n" +" breaker = read_int(pid, eval_breaker_ptr)\n" +" breaker |= (1 << 5)\n" +" write_int(pid, eval_breaker_ptr, breaker)" +msgstr "" +"def inject_script(\n" +" pid: int,\n" +" thread_state_addr: int,\n" +" debug_offsets: DebugOffsets,\n" +" script_path: str\n" +") -> None:\n" +" # 計算 _PyRemoteDebuggerSupport 的基底偏移量\n" +" support_base = (\n" +" thread_state_addr +\n" +" debug_offsets.debugger_support.remote_debugger_support\n" +" )\n" +"\n" +" # 步驟 1:將腳本路徑寫入 debugger_script_path\n" +" script_path_ptr = (\n" +" support_base +\n" +" debug_offsets.debugger_support.debugger_script_path\n" +" )\n" +" write_string(pid, script_path_ptr, script_path)\n" +"\n" +" # 步驟 2:將 debugger_pending_call 設定為 1\n" +" pending_ptr = (\n" +" support_base +\n" +" debug_offsets.debugger_support.debugger_pending_call\n" +" )\n" +" write_int(pid, pending_ptr, 1)\n" +"\n" +" # 步驟 3:在 eval_breaker 中設定 _PY_EVAL_PLEASE_STOP_BIT(位元 5,值為 1 << 5)\n" +" eval_breaker_ptr = (\n" +" thread_state_addr +\n" +" debug_offsets.debugger_support.eval_breaker\n" +" )\n" +" breaker = read_int(pid, eval_breaker_ptr)\n" +" breaker |= (1 << 5)\n" +" write_int(pid, eval_breaker_ptr, breaker)" + +#: ../../howto/remote_debugging.rst:586 +msgid "" +"Once these fields are set, the debugger may resume the process (if it was " +"suspended). The interpreter will process the request at the next safe " +"evaluation point, load the script from disk, and execute it." +msgstr "" +"一旦設定了這些欄位,偵錯器就可以恢復行程(如果它先被暫停了)。直譯器將在下一個安全執行點" +"處理請求、從磁碟載入腳本並執行它。" + +#: ../../howto/remote_debugging.rst:590 +msgid "" +"It is the responsibility of the debugger to ensure that the script file " +"remains present and accessible to the target process during execution." +msgstr "偵錯器有責任確保腳本檔案在執行期間仍然存在且可供目標行程存取。" + +#: ../../howto/remote_debugging.rst:595 +msgid "" +"Script execution is asynchronous. The script file cannot be deleted " +"immediately after injection. The debugger should wait until the injected " +"script has produced an observable effect before removing the file. This " +"effect depends on what the script is designed to do. For example, a debugger " +"might wait until the remote process connects back to a socket before " +"removing the script. Once such an effect is observed, it is safe to assume " +"the file is no longer needed." +msgstr "" +"腳本執行是非同步的。注入後不能立即刪除腳本檔案。偵錯器應等到注入的腳本產生可觀察的效果後再" +"刪除檔案。此效果取決於腳本被設計要執行的操作。例如,偵錯器可能會等到遠端行程連回通訊端後再刪" +"除腳本。一旦觀察到這種效果,就可以安全地假設不再需要該檔案。" + +#: ../../howto/remote_debugging.rst:604 +msgid "Summary" +msgstr "摘要" + +#: ../../howto/remote_debugging.rst:606 +msgid "To inject and execute a Python script in a remote process:" +msgstr "要在遠端行程中注入並執行 Python 腳本:" + +#: ../../howto/remote_debugging.rst:608 +msgid "Locate the ``PyRuntime`` structure in the target process’s memory." +msgstr "在目標行程的記憶體中定位 ``PyRuntime`` 結構。" + +#: ../../howto/remote_debugging.rst:609 +msgid "" +"Read and validate the ``_Py_DebugOffsets`` structure at the beginning of " +"``PyRuntime``." +msgstr "讀取並驗證 ``PyRuntime`` 開頭的 ``_Py_DebugOffsets`` 結構。" + +#: ../../howto/remote_debugging.rst:611 +msgid "Use the offsets to locate a valid ``PyThreadState``." +msgstr "使用偏移量來定位有效的 ``PyThreadState``。" + +#: ../../howto/remote_debugging.rst:612 +msgid "Write the path to a Python script into ``debugger_script_path``." +msgstr "將 Python 腳本的路徑寫入 ``debugger_script_path``。" + +#: ../../howto/remote_debugging.rst:613 +msgid "Set the ``debugger_pending_call`` flag to ``1``." +msgstr "將 ``debugger_pending_call`` 旗標設定為 ``1``。" + +#: ../../howto/remote_debugging.rst:614 +msgid "Set ``_PY_EVAL_PLEASE_STOP_BIT`` in the ``eval_breaker`` field." +msgstr "在 ``eval_breaker`` 欄位中設定 ``_PY_EVAL_PLEASE_STOP_BIT``。" + +#: ../../howto/remote_debugging.rst:615 +msgid "" +"Resume the process (if suspended). The script will execute at the next safe " +"evaluation point." +msgstr "恢復行程(如果已暫停)。腳本將在下一個安全執行點執行。" diff --git a/howto/sockets.po b/howto/sockets.po index 0d6717fa742..db933f29e56 100644 --- a/howto/sockets.po +++ b/howto/sockets.po @@ -1,12 +1,12 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.11\n" +"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: 2025-12-01 00:17+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-" @@ -30,7 +30,7 @@ msgstr "作者" msgid "Gordon McMillan" msgstr "Gordon McMillan" -#: ../../howto/sockets.rst:-1 +#: ../../howto/sockets.rst:10 msgid "Abstract" msgstr "摘要" @@ -211,8 +211,8 @@ msgid "" " (clientsocket, address) = serversocket.accept()\n" " # now do something with the clientsocket\n" " # in this case, we'll pretend this is a threaded server\n" -" ct = client_thread(clientsocket)\n" -" ct.run()" +" ct = make_client_thread(clientsocket)\n" +" ct.start()" msgstr "" #: ../../howto/sockets.rst:106 diff --git a/howto/sorting.po b/howto/sorting.po index dcdc529f4e5..7455a8b96f6 100644 --- a/howto/sorting.po +++ b/howto/sorting.po @@ -1,13 +1,13 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Ching-Lung Chuang, 2015 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"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: 2025-09-08 15:25+0800\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-" @@ -112,26 +112,31 @@ msgstr "鍵函式 (key functions)" #: ../../howto/sorting.rst:50 msgid "" -"Both :meth:`list.sort` and :func:`sorted` have a *key* parameter to specify " -"a function (or other callable) to be called on each list element prior to " -"making comparisons." +"The :meth:`list.sort` method and the " +"functions :func:`sorted`, :func:`min`, :func:`max`, :func:`heapq.nsmallest`, " +"and :func:`heapq.nlargest` have a *key* parameter to specify a function (or " +"other callable) to be called on each list element prior to making " +"comparisons." msgstr "" -":meth:`list.sort` 和 :func:`sorted` 都有一個參數 *key* 可以指定一個函式(或其" -"它可呼叫物件 (callable)),這個函式會在每個串列元素做比較前被呼叫。" - -#: ../../howto/sorting.rst:54 -msgid "For example, here's a case-insensitive string comparison:" -msgstr "例如這裡有一個不區分大小寫的字串比對:" +":meth:`list.sort` 方法和 :func:`sorted`、:func:`min`、:func:`max`、:func:`heapq.nsmallest` 及" +" :func:`heapq.nlargest` 函式都有一個參數 *key* 可以指定一個函式(或其" +"它可呼叫物件 (callable)),其會在每個串列元素做比較前被呼叫。" #: ../../howto/sorting.rst:56 msgid "" +"For example, here's a case-insensitive string comparison " +"using :meth:`str.casefold`:" +msgstr "例如使用 :meth:`str.casefold` 來做不區分大小寫的字串比對:" + +#: ../../howto/sorting.rst:59 +msgid "" ">>> sorted(\"This is a test string from Andrew\".split(), key=str.casefold)\n" "['a', 'Andrew', 'from', 'is', 'string', 'test', 'This']" msgstr "" ">>> sorted(\"This is a test string from Andrew\".split(), key=str.casefold)\n" "['a', 'Andrew', 'from', 'is', 'string', 'test', 'This']" -#: ../../howto/sorting.rst:61 +#: ../../howto/sorting.rst:64 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. " @@ -142,14 +147,14 @@ msgstr "" "傳一個用來排序的鍵。因為對每個輸入來說鍵函式只會被呼叫一次,所以這個做法是快" "速的。" -#: ../../howto/sorting.rst:66 +#: ../../howto/sorting.rst:69 msgid "" "A common pattern is to sort complex objects using some of the object's " "indices as keys. For example:" msgstr "" "一個常見的模式是在排序複雜物件的時候使用一部分物件的索引值當作鍵,例如:" -#: ../../howto/sorting.rst:69 +#: ../../howto/sorting.rst:72 msgid "" ">>> student_tuples = [\n" "... ('john', 'A', 15),\n" @@ -167,12 +172,12 @@ msgstr "" ">>> sorted(student_tuples, key=lambda student: student[2]) # 依照年齡排序\n" "[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]" -#: ../../howto/sorting.rst:79 +#: ../../howto/sorting.rst:82 msgid "" "The same technique works for objects with named attributes. For example:" msgstr "相同的做法也適用在有命名屬性的物件,例如:" -#: ../../howto/sorting.rst:81 +#: ../../howto/sorting.rst:84 msgid "" ">>> class Student:\n" "... def __init__(self, name, grade, age):\n" @@ -208,36 +213,37 @@ msgstr "" "序\n" "[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]" -#: ../../howto/sorting.rst:99 +#: ../../howto/sorting.rst:102 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:" -"`named tuple`." +"or they can be instances of :class:`~dataclasses.dataclass` or " +"a :term:`named tuple`." msgstr "" -"具有命名屬性的物件可以如上方的方式使用一個常規的類別建立,或是他們可以是 :" -"class:`~dataclasses.dataclass` 的實例或是一個 :term:`named tuple`。" +"具有命名屬性的物件可以如上方的方式使用一個常規的類別建立,或是他們可以" +"是 :class:`~dataclasses.dataclass` 的實例或是一個 :term:`named tuple`。" -#: ../../howto/sorting.rst:104 +#: ../../howto/sorting.rst:107 msgid "Operator Module Functions and Partial Function Evaluation" msgstr "Operator 模組函式以及部份函式 (partial function) 評估" -#: ../../howto/sorting.rst:106 +#: ../../howto/sorting.rst:109 msgid "" "The :term:`key function` patterns shown above are very common, so Python " "provides convenience functions to make accessor functions easier and faster. " -"The :mod:`operator` module has :func:`~operator.itemgetter`, :func:" -"`~operator.attrgetter`, and a :func:`~operator.methodcaller` function." +"The :mod:`operator` module " +"has :func:`~operator.itemgetter`, :func:`~operator.attrgetter`, and " +"a :func:`~operator.methodcaller` function." msgstr "" "上述的\\ :term:`鍵函式 `\\ 模式非常常見,所以 Python 提供了方便" -"的函式讓物件存取更簡單且快速。:mod:`operator` 模組裡有 :func:`~operator." -"itemgetter`、:func:`~operator.attrgetter` 及 :func:`~operator.methodcaller` " -"函式可以使用。" +"的函式讓物件存取更簡單且快速。:mod:`operator` 模組裡" +"有 :func:`~operator.itemgetter`、:func:`~operator.attrgetter` " +"及 :func:`~operator.methodcaller` 函式可以使用。" -#: ../../howto/sorting.rst:111 +#: ../../howto/sorting.rst:114 msgid "Using those functions, the above examples become simpler and faster:" msgstr "使用這些函式讓上面的範例變得更簡單且快速:" -#: ../../howto/sorting.rst:113 +#: ../../howto/sorting.rst:116 msgid "" ">>> from operator import itemgetter, attrgetter\n" "\n" @@ -255,14 +261,14 @@ msgstr "" ">>> sorted(student_objects, key=attrgetter('age'))\n" "[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]" -#: ../../howto/sorting.rst:123 +#: ../../howto/sorting.rst:126 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:126 +#: ../../howto/sorting.rst:129 msgid "" ">>> sorted(student_tuples, key=itemgetter(1,2))\n" "[('john', 'A', 15), ('dave', 'B', 10), ('jane', 'B', 12)]\n" @@ -276,18 +282,18 @@ msgstr "" ">>> sorted(student_objects, key=attrgetter('grade', 'age'))\n" "[('john', 'A', 15), ('dave', 'B', 10), ('jane', 'B', 12)]" -#: ../../howto/sorting.rst:134 +#: ../../howto/sorting.rst:137 msgid "" "The :mod:`functools` module provides another helpful tool for making key-" "functions. The :func:`~functools.partial` function can reduce the `arity " "`_ of a multi-argument function making " "it suitable for use as a key-function." msgstr "" -"模組 :mod:`functools` 提供了另一個製作鍵函式的好用工具。:func:`~functools." -"partial` 函式可以減少多引數函式的\\ `引數數目 `_,使其更適合作為鍵函式使用。" +"模組 :mod:`functools` 提供了另一個製作鍵函式的好用工" +"具。:func:`~functools.partial` 函式可以減少多引數函式的\\ `引數數目 `_,使其更適合作為鍵函式使用。" -#: ../../howto/sorting.rst:139 +#: ../../howto/sorting.rst:142 msgid "" ">>> from functools import partial\n" ">>> from unicodedata import normalize\n" @@ -311,11 +317,11 @@ msgstr "" ">>> sorted(names, key=partial(normalize, 'NFC'))\n" "['Abe', 'Eloise', 'Nubia', 'Núñez', 'Zeke', 'Zoë', 'Åbjørn', 'Élana']" -#: ../../howto/sorting.rst:153 +#: ../../howto/sorting.rst:156 msgid "Ascending and Descending" msgstr "升冪與降冪" -#: ../../howto/sorting.rst:155 +#: ../../howto/sorting.rst:158 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 " @@ -324,7 +330,7 @@ msgstr "" ":meth:`list.sort` 和 :func:`sorted` 都有一個 boolean 參數 *reverse* 用來表示" "是否要降冪排序。例如將學生資料依據 *age* 做降冪排序:" -#: ../../howto/sorting.rst:159 +#: ../../howto/sorting.rst:162 msgid "" ">>> sorted(student_tuples, key=itemgetter(2), reverse=True)\n" "[('john', 'A', 15), ('jane', 'B', 12), ('dave', 'B', 10)]\n" @@ -338,11 +344,11 @@ msgstr "" ">>> sorted(student_objects, key=attrgetter('age'), reverse=True)\n" "[('john', 'A', 15), ('jane', 'B', 12), ('dave', 'B', 10)]" -#: ../../howto/sorting.rst:168 +#: ../../howto/sorting.rst:171 msgid "Sort Stability and Complex Sorts" msgstr "排序穩定性與複合排序" -#: ../../howto/sorting.rst:170 +#: ../../howto/sorting.rst:173 msgid "" "Sorts are guaranteed to be `stable `_\\. That means that when multiple records have " @@ -352,7 +358,7 @@ msgstr "" "Sorting_algorithm#Stability>`_,意思是當有多筆資料有相同的鍵,它們會維持原來" "的順序。" -#: ../../howto/sorting.rst:174 +#: ../../howto/sorting.rst:177 msgid "" ">>> data = [('red', 1), ('blue', 1), ('red', 2), ('blue', 2)]\n" ">>> sorted(data, key=itemgetter(0))\n" @@ -362,7 +368,7 @@ msgstr "" ">>> sorted(data, key=itemgetter(0))\n" "[('blue', 1), ('blue', 2), ('red', 1), ('red', 2)]" -#: ../../howto/sorting.rst:180 +#: ../../howto/sorting.rst:183 msgid "" "Notice how the two records for *blue* retain their original order so that " "``('blue', 1)`` is guaranteed to precede ``('blue', 2)``." @@ -370,7 +376,7 @@ msgstr "" "可以注意到有兩筆資料的鍵都是 *blue*,它們會維持本來的順序,即 ``('blue', " "1)`` 保證在 ``('blue', 2)`` 前面。" -#: ../../howto/sorting.rst:183 +#: ../../howto/sorting.rst:186 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 " @@ -380,7 +386,7 @@ msgstr "" "做降冪排序再用 *age* 做升冪排序,你可以先用 *age* 排序一遍再用 *grade* 排序一" "遍:" -#: ../../howto/sorting.rst:187 +#: ../../howto/sorting.rst:190 msgid "" ">>> s = sorted(student_objects, key=attrgetter('age')) # sort on " "secondary key\n" @@ -393,7 +399,7 @@ msgstr "" "冪排序\n" "[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]" -#: ../../howto/sorting.rst:193 +#: ../../howto/sorting.rst:196 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." @@ -401,7 +407,7 @@ msgstr "" "這可以抽出一個包裝函式 (wrapper function),接受一個串列及多個欄位及升降冪的元" "組為引數,來對這個串列排序多遍。" -#: ../../howto/sorting.rst:196 +#: ../../howto/sorting.rst:199 msgid "" ">>> def multisort(xs, specs):\n" "... for key, reverse in reversed(specs):\n" @@ -419,7 +425,7 @@ msgstr "" ">>> multisort(list(student_objects), (('grade', True), ('age', False)))\n" "[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]" -#: ../../howto/sorting.rst:206 +#: ../../howto/sorting.rst:209 msgid "" "The `Timsort `_ algorithm used in " "Python does multiple sorts efficiently because it can take advantage of any " @@ -428,36 +434,36 @@ msgstr "" "Python 裡使用的 `Timsort `_ 演算法,因" "為能利用資料集裡已經有的順序,可以有效率地做多次排序。" -#: ../../howto/sorting.rst:211 +#: ../../howto/sorting.rst:214 msgid "Decorate-Sort-Undecorate" msgstr "裝飾-排序-移除裝飾 (decorate-sort-undecorate)" -#: ../../howto/sorting.rst:213 +#: ../../howto/sorting.rst:216 msgid "This idiom is called Decorate-Sort-Undecorate after its three steps:" msgstr "這個用語的來源是因為它做了以下三件事情:" -#: ../../howto/sorting.rst:215 +#: ../../howto/sorting.rst:218 msgid "" "First, the initial list is decorated with new values that control the sort " "order." msgstr "首先,原始串列會裝飾 (decorated) 上新的值用來控制排序的順序。" -#: ../../howto/sorting.rst:217 +#: ../../howto/sorting.rst:220 msgid "Second, the decorated list is sorted." msgstr "接下來,排序裝飾過的串列。" -#: ../../howto/sorting.rst:219 +#: ../../howto/sorting.rst:222 msgid "" "Finally, the decorations are removed, creating a list that contains only the " "initial values in the new order." msgstr "最後,裝飾會被移除,並以新的順序產生一個只包含原始值的串列。" -#: ../../howto/sorting.rst:222 +#: ../../howto/sorting.rst:225 msgid "" "For example, to sort the student data by *grade* using the DSU approach:" msgstr "例如用上面說的方式來以 *grade* 排序學生資料:" -#: ../../howto/sorting.rst:224 +#: ../../howto/sorting.rst:227 msgid "" ">>> decorated = [(student.grade, i, student) for i, student in " "enumerate(student_objects)]\n" @@ -471,7 +477,7 @@ msgstr "" ">>> [student for grade, i, student in decorated] # 移除裝飾\n" "[('john', 'A', 15), ('jane', 'B', 12), ('dave', 'B', 10)]" -#: ../../howto/sorting.rst:231 +#: ../../howto/sorting.rst:234 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, " @@ -480,7 +486,7 @@ msgstr "" "這個方式會有效是因為元組是依照字典順序 (lexicographically) 來比較,先比較第一" "個項目,如果一樣再比較第二個項目,並依此類推。" -#: ../../howto/sorting.rst:235 +#: ../../howto/sorting.rst:238 msgid "" "It is not strictly necessary in all cases to include the index *i* in the " "decorated list, but including it gives two benefits:" @@ -488,7 +494,7 @@ msgstr "" "在所有情況下都把索引 *i* 加入已裝飾的串列並不是絕對需要的,但這樣做會有兩個好" "處:" -#: ../../howto/sorting.rst:238 +#: ../../howto/sorting.rst:241 msgid "" "The sort is stable -- if two items have the same key, their order will be " "preserved in the sorted list." @@ -496,7 +502,7 @@ msgstr "" "排序會是穩定的 -- 如果兩個項目有相同的鍵,它們在排序好的串列中會保持原來的順" "序。" -#: ../../howto/sorting.rst:241 +#: ../../howto/sorting.rst:244 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 " @@ -506,33 +512,33 @@ msgstr "" "原始項目不需要是可以比較的,因為最多只會用到前兩個項目就能決定裝飾過的元組的" "順序。例如原始串列可以包含不能直接用來排序的複數。" -#: ../../howto/sorting.rst:246 +#: ../../howto/sorting.rst:249 msgid "" -"Another name for this idiom is `Schwartzian transform `_\\, after Randal L. Schwartz, who " -"popularized it among Perl programmers." +"Another name for this idiom is `Schwartzian transform `_\\, after Randal L. Schwartz, " +"who popularized it among Perl programmers." msgstr "" "這個用語的另一個名字是 `Schwartzian transform `_,是由於 Randal L. Schwartz 讓這個方法在 Perl 程式設" "計師間普及。" -#: ../../howto/sorting.rst:250 +#: ../../howto/sorting.rst:253 msgid "" "Now that Python sorting provides key-functions, this technique is not often " "needed." msgstr "而因為 Python 的排序提供了鍵函式,已經不太需要用到這個方法了。" -#: ../../howto/sorting.rst:253 +#: ../../howto/sorting.rst:256 msgid "Comparison Functions" msgstr "比較函式 (comparison functions)" -#: ../../howto/sorting.rst:255 +#: ../../howto/sorting.rst:258 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:258 +#: ../../howto/sorting.rst:261 msgid "" "For example, a `balance scale `_ compares two samples giving a " @@ -545,7 +551,7 @@ msgstr "" "重。同樣地,像是 ``cmp(a, b)`` 這樣的比較函式會回傳負數代表小於、0 代表輸入相" "同或正數代表大於。" -#: ../../howto/sorting.rst:265 +#: ../../howto/sorting.rst:268 msgid "" "It is common to encounter comparison functions when translating algorithms " "from other languages. Also, some libraries provide comparison functions as " @@ -555,35 +561,147 @@ msgstr "" "當從其它語言翻譯演算法的時候常看到比較函式。有些函式庫也會提供比較函式作為其 " "API 的一部份,例如 :func:`locale.strcoll` 就是一個比較函式。" -#: ../../howto/sorting.rst:269 +#: ../../howto/sorting.rst:272 msgid "" -"To accommodate those situations, Python provides :class:`functools." -"cmp_to_key` to wrap the comparison function to make it usable as a key " -"function::" +"To accommodate those situations, Python " +"provides :class:`functools.cmp_to_key` to wrap the comparison function to " +"make it usable as a key function::" msgstr "" "為了滿足這些情境,Python 提供 :class:`functools.cmp_to_key` 來包裝比較函式," "讓其可以當作鍵函式來使用: ::" -#: ../../howto/sorting.rst:273 +#: ../../howto/sorting.rst:276 msgid "sorted(words, key=cmp_to_key(strcoll)) # locale-aware sort order" msgstr "sorted(words, key=cmp_to_key(strcoll)) # 理解語系的排序順序" -#: ../../howto/sorting.rst:276 +#: ../../howto/sorting.rst:279 +msgid "Strategies For Unorderable Types and Values" +msgstr "" + +#: ../../howto/sorting.rst:281 +msgid "" +"A number of type and value issues can arise when sorting. Here are some " +"strategies that can help:" +msgstr "" + +#: ../../howto/sorting.rst:284 +msgid "Convert non-comparable input types to strings prior to sorting:" +msgstr "" + +#: ../../howto/sorting.rst:286 +msgid "" +">>> data = ['twelve', '11', 10]\n" +">>> sorted(map(str, data))\n" +"['10', '11', 'twelve']" +msgstr "" +">>> data = ['twelve', '11', 10]\n" +">>> sorted(map(str, data))\n" +"['10', '11', 'twelve']" + +#: ../../howto/sorting.rst:292 +msgid "" +"This is needed because most cross-type comparisons raise a :exc:`TypeError`." +msgstr "" + +#: ../../howto/sorting.rst:295 +msgid "Remove special values prior to sorting:" +msgstr "" + +#: ../../howto/sorting.rst:297 +msgid "" +">>> from math import isnan\n" +">>> from itertools import filterfalse\n" +">>> data = [3.3, float('nan'), 1.1, 2.2]\n" +">>> sorted(filterfalse(isnan, data))\n" +"[1.1, 2.2, 3.3]" +msgstr "" +">>> from math import isnan\n" +">>> from itertools import filterfalse\n" +">>> data = [3.3, float('nan'), 1.1, 2.2]\n" +">>> sorted(filterfalse(isnan, data))\n" +"[1.1, 2.2, 3.3]" + +#: ../../howto/sorting.rst:305 +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 +msgid "Likewise, ``None`` can be stripped from datasets as well:" +msgstr "" + +#: ../../howto/sorting.rst:311 +msgid "" +">>> data = [3.3, None, 1.1, 2.2]\n" +">>> sorted(x for x in data if x is not None)\n" +"[1.1, 2.2, 3.3]" +msgstr "" +">>> data = [3.3, None, 1.1, 2.2]\n" +">>> sorted(x for x in data if x is not None)\n" +"[1.1, 2.2, 3.3]" + +#: ../../howto/sorting.rst:317 +msgid "This is needed because ``None`` is not comparable to other types." +msgstr "" + +#: ../../howto/sorting.rst:319 +msgid "Convert mapping types into sorted item lists before sorting:" +msgstr "" + +#: ../../howto/sorting.rst:321 +msgid "" +">>> data = [{'a': 1}, {'b': 2}]\n" +">>> sorted(data, key=lambda d: sorted(d.items()))\n" +"[{'a': 1}, {'b': 2}]" +msgstr "" +">>> data = [{'a': 1}, {'b': 2}]\n" +">>> sorted(data, key=lambda d: sorted(d.items()))\n" +"[{'a': 1}, {'b': 2}]" + +#: ../../howto/sorting.rst:327 +msgid "" +"This is needed because dict-to-dict comparisons raise a :exc:`TypeError`." +msgstr "" + +#: ../../howto/sorting.rst:330 +msgid "Convert set types into sorted lists before sorting:" +msgstr "" + +#: ../../howto/sorting.rst:332 +msgid "" +">>> data = [{'a', 'b', 'c'}, {'b', 'c', 'd'}]\n" +">>> sorted(map(sorted, data))\n" +"[['a', 'b', 'c'], ['b', 'c', 'd']]" +msgstr "" +">>> data = [{'a', 'b', 'c'}, {'b', 'c', 'd'}]\n" +">>> sorted(map(sorted, data))\n" +"[['a', 'b', 'c'], ['b', 'c', 'd']]" + +#: ../../howto/sorting.rst:338 +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 msgid "Odds and Ends" msgstr "雜項說明" -#: ../../howto/sorting.rst:278 +#: ../../howto/sorting.rst:345 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 " -"\"alphabetical\" sort orderings can vary across cultures even if the " +"For locale aware sorting, use :func:`locale.strxfrm` for a key function " +"or :func:`locale.strcoll` for a comparison function. This is necessary " +"because \"alphabetical\" sort orderings can vary across cultures even if the " "underlying alphabet is the same." msgstr "" "要處理能理解本地語系 (locale aware) 的排序可以使用 :func:`locale.strxfrm` 當" "作鍵函式,或 :func:`locale.strcoll` 當作比較函式。這樣做是必要的,因為在不同" "文化中就算是相同的字母,按「字母順序」排序的結果也各不相同。" -#: ../../howto/sorting.rst:283 +#: ../../howto/sorting.rst:350 msgid "" "The *reverse* parameter still maintains sort stability (so that records with " "equal keys retain the original order). Interestingly, that effect can be " @@ -594,7 +712,7 @@ msgstr "" "是,不加這個參數也可以模擬這個效果,只要使用內建的 :func:`reversed` 函式兩" "次:" -#: ../../howto/sorting.rst:288 +#: ../../howto/sorting.rst:355 msgid "" ">>> data = [('red', 1), ('blue', 1), ('red', 2), ('blue', 2)]\n" ">>> standard_way = sorted(data, key=itemgetter(0), reverse=True)\n" @@ -612,16 +730,16 @@ msgstr "" ">>> standard_way\n" "[('red', 1), ('red', 2), ('blue', 1), ('blue', 2)]" -#: ../../howto/sorting.rst:297 +#: ../../howto/sorting.rst:364 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:" -"`~object.__lt__` method:" +"it is easy to add a standard sort order to a class by defining " +"an :meth:`~object.__lt__` method:" msgstr "" "排序時會使用 ``<`` 來比較兩個物件,因此要在類別裡面加入排序順序比較規則是簡單" "的,只要透過定義 :meth:`~object.__lt__` 方法:" -#: ../../howto/sorting.rst:301 +#: ../../howto/sorting.rst:368 msgid "" ">>> Student.__lt__ = lambda self, other: self.age < other.age\n" ">>> sorted(student_objects)\n" @@ -631,20 +749,21 @@ msgstr "" ">>> sorted(student_objects)\n" "[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]" -#: ../../howto/sorting.rst:307 +#: ../../howto/sorting.rst:374 msgid "" -"However, note that ``<`` can fall back to using :meth:`~object.__gt__` if :" -"meth:`~object.__lt__` is not implemented (see :func:`object.__lt__` for " +"However, note that ``<`` can fall back to using :meth:`~object.__gt__` " +"if :meth:`~object.__lt__` is not implemented (see :func:`object.__lt__` for " "details on the mechanics). To avoid surprises, :pep:`8` recommends that all " "six comparison methods be implemented. The :func:`~functools.total_ordering` " "decorator is provided to make that task easier." msgstr "" "然而,請注意,當 :meth:`~object.__lt__` 沒有被實作時,``<`` 可以回退 (fall " -"back) 使用 :meth:`~object.__gt__`\\ (有關技術上的細節資訊請看 :func:`object." -"__lt__` )。為了避免意外發生,:pep:`8` 建議所有六種的比較函式都需要被實作。裝" -"飾器 :func:`~functools.total_ordering` 被提供用來讓任務更為簡單。" +"back) 使用 :meth:`~object.__gt__`\\ (有關技術上的細節資訊請" +"看 :func:`object.__lt__` )。為了避免意外發生,:pep:`8` 建議所有六種的比較函" +"式都需要被實作。裝飾器 :func:`~functools.total_ordering` 被提供用來讓任務更為" +"簡單。" -#: ../../howto/sorting.rst:314 +#: ../../howto/sorting.rst:381 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 " @@ -654,7 +773,7 @@ msgstr "" "鍵函式不需要直接依賴用來排序的物件。鍵函式也可以存取外部資源,例如如果學生成" "績儲存在字典裡,它可以用來排序一個單獨的學生姓名串列:" -#: ../../howto/sorting.rst:319 +#: ../../howto/sorting.rst:386 msgid "" ">>> students = ['dave', 'john', 'jane']\n" ">>> newgrades = {'john': 'F', 'jane':'A', 'dave': 'C'}\n" @@ -666,11 +785,11 @@ msgstr "" ">>> sorted(students, key=newgrades.__getitem__)\n" "['jane', 'dave', 'john']" -#: ../../howto/sorting.rst:327 +#: ../../howto/sorting.rst:394 msgid "Partial Sorts" msgstr "部份排序" -#: ../../howto/sorting.rst:329 +#: ../../howto/sorting.rst:396 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:" @@ -678,7 +797,7 @@ msgstr "" "有些應用程式只需要排序部份的資料。基礎函式庫提供相較做完整排序更為輕鬆的多項" "工具:" -#: ../../howto/sorting.rst:332 +#: ../../howto/sorting.rst:399 msgid "" ":func:`min` and :func:`max` return the smallest and largest values, " "respectively. These functions make a single pass over the input data and " @@ -687,7 +806,7 @@ msgstr "" ":func:`min` 以及 :func:`max` 會分別回傳最小值及最大值。這些函式會將輸入資料進" "行一次傳遞且幾乎無須輔助記憶體。" -#: ../../howto/sorting.rst:336 +#: ../../howto/sorting.rst:403 msgid "" ":func:`heapq.nsmallest` and :func:`heapq.nlargest` return the *n* smallest " "and largest values, respectively. These functions make a single pass over " @@ -699,7 +818,7 @@ msgstr "" "最大值。這些函式會將資料進行一次傳遞且一次只會保留 *n* 個元素在記憶體中。對於" "相對於輸入數量較小的 *n* 個值,這些函式進行的比較比完整排序要少得多。" -#: ../../howto/sorting.rst:342 +#: ../../howto/sorting.rst:409 msgid "" ":func:`heapq.heappush` and :func:`heapq.heappop` create and maintain a " "partially sorted arrangement of data that keeps the smallest element at " diff --git a/howto/timerfd.po b/howto/timerfd.po index 31cd12792d7..cc60b1f9514 100644 --- a/howto/timerfd.po +++ b/howto/timerfd.po @@ -1,11 +1,11 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # Translators: # GitHub Copilot, 2025 # msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-23 07:52+0800\n" "PO-Revision-Date: 2024-12-19 10:00+0000\n" diff --git a/howto/unicode.po b/howto/unicode.po index 66eab41171e..2a9e35df0eb 100644 --- a/howto/unicode.po +++ b/howto/unicode.po @@ -1,13 +1,12 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-02-19 00:13+0000\n" +"POT-Creation-Date: 2025-11-25 00:13+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-" @@ -79,10 +78,10 @@ msgstr "" 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 " -"(about 1.1 million values, the `actual number assigned `_ is less than that). In the " -"standard and in this document, a code point is written using the notation " -"``U+265E`` to mean the character with value ``0x265e`` (9,822 in decimal)." +"(about 1.1 million values, the `actual number assigned `_ is less than that). In the standard and in " +"this document, a code point is written using the notation ``U+265E`` to mean " +"the character with value ``0x265e`` (9,822 in decimal)." msgstr "" #: ../../howto/unicode.rst:50 @@ -271,8 +270,8 @@ msgid "" "varies depending on the hardware on which the string was encoded." msgstr "" -#: ../../howto/unicode.rst:158 ../../howto/unicode.rst:514 -#: ../../howto/unicode.rst:735 +#: ../../howto/unicode.rst:158 ../../howto/unicode.rst:516 +#: ../../howto/unicode.rst:737 msgid "References" msgstr "" @@ -301,8 +300,8 @@ msgstr "" #: ../../howto/unicode.rst:173 msgid "" -"Another `good introductory article `_ was " "written by Joel Spolsky. If this introduction didn't make things clear to " "you, you should try reading this alternate article before continuing." @@ -473,10 +472,10 @@ msgstr "" #: ../../howto/unicode.rst:272 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 ``'strict'``, ``'ignore'``, and ``'replace'`` (which in this case " -"inserts a question mark instead of the unencodable character), there is also " +"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 " +"``'strict'``, ``'ignore'``, and ``'replace'`` (which in this case inserts a " +"question mark instead of the unencodable character), there is also " "``'xmlcharrefreplace'`` (inserts an XML character reference), " "``backslashreplace`` (inserts a ``\\uNNNN`` escape sequence) and " "``namereplace`` (inserts a ``\\N{...}`` escape sequence)." @@ -557,6 +556,12 @@ msgid "" ">>> [ord(c) for c in s]\n" "[97, 172, 4660, 8364, 32768]" msgstr "" +">>> s = \"a\\xac\\u1234\\u20ac\\U00008000\"\n" +"... # ^^^^ two-digit hex escape\n" +"... # ^^^^^^ four-digit Unicode escape\n" +"... # ^^^^^^^^^^ eight-digit Unicode escape\n" +">>> [ord(c) for c in s]\n" +"[97, 172, 4660, 8364, 32768]" #: ../../howto/unicode.rst:324 msgid "" @@ -612,11 +617,11 @@ msgid "" "as already mentioned. See also :pep:`263` for more information." msgstr "" -#: ../../howto/unicode.rst:356 +#: ../../howto/unicode.rst:358 msgid "Unicode Properties" msgstr "" -#: ../../howto/unicode.rst:358 +#: ../../howto/unicode.rst:360 msgid "" "The Unicode specification includes a database of information about code " "points. For each defined code point, the information includes the " @@ -626,13 +631,13 @@ msgid "" "related properties, such as how to use the code point in bidirectional text." msgstr "" -#: ../../howto/unicode.rst:366 +#: ../../howto/unicode.rst:368 msgid "" "The following program displays some information about several characters, " "and prints the numeric value of one particular character::" msgstr "" -#: ../../howto/unicode.rst:369 +#: ../../howto/unicode.rst:371 msgid "" "import unicodedata\n" "\n" @@ -646,11 +651,11 @@ msgid "" "print(unicodedata.numeric(u[1]))" msgstr "" -#: ../../howto/unicode.rst:380 +#: ../../howto/unicode.rst:382 msgid "When run, this prints:" msgstr "" -#: ../../howto/unicode.rst:382 +#: ../../howto/unicode.rst:384 msgid "" "0 00e9 Ll LATIN SMALL LETTER E WITH ACUTE\n" "1 0bf2 No TAMIL NUMBER ONE THOUSAND\n" @@ -666,7 +671,7 @@ msgstr "" "4 33af So SQUARE RAD OVER S SQUARED\n" "1000.0" -#: ../../howto/unicode.rst:391 +#: ../../howto/unicode.rst:393 msgid "" "The category codes are abbreviations describing the nature of the character. " "These are grouped into categories such as \"Letter\", \"Number\", " @@ -674,16 +679,16 @@ msgid "" "subcategories. To take the codes from the above output, ``'Ll'`` means " "'Letter, lowercase', ``'No'`` means \"Number, other\", ``'Mn'`` is \"Mark, " "nonspacing\", and ``'So'`` is \"Symbol, other\". See `the General Category " -"Values section of the Unicode Character Database documentation `_ for a list of " -"category codes." +"Values section of the Unicode Character Database documentation `_ for a list of category " +"codes." msgstr "" -#: ../../howto/unicode.rst:402 +#: ../../howto/unicode.rst:404 msgid "Comparing Strings" msgstr "" -#: ../../howto/unicode.rst:404 +#: ../../howto/unicode.rst:406 msgid "" "Unicode adds some complication to comparing strings, because the same set of " "characters can be represented by different sequences of code points. For " @@ -693,7 +698,7 @@ msgid "" "when printed, but one is a string of length 1 and the other is of length 2." msgstr "" -#: ../../howto/unicode.rst:412 +#: ../../howto/unicode.rst:414 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 " @@ -702,7 +707,7 @@ msgid "" "which becomes the pair of lowercase letters 'ss'." msgstr "" -#: ../../howto/unicode.rst:421 +#: ../../howto/unicode.rst:423 msgid "" ">>> street = 'Gürzenichstraße'\n" ">>> street.casefold()\n" @@ -712,17 +717,17 @@ msgstr "" ">>> street.casefold()\n" "'gürzenichstrasse'" -#: ../../howto/unicode.rst:425 +#: ../../howto/unicode.rst:427 msgid "" -"A second tool is the :mod:`unicodedata` " -"module's :func:`~unicodedata.normalize` function that converts strings to " -"one of several normal forms, where letters followed by a combining character " -"are replaced with single characters. :func:`~unicodedata.normalize` can be " -"used to perform string comparisons that won't falsely report inequality if " -"two strings use combining characters differently:" +"A second tool is the :mod:`unicodedata` module's :func:`~unicodedata." +"normalize` function that converts strings to one of several normal forms, " +"where letters followed by a combining character are replaced with single " +"characters. :func:`~unicodedata.normalize` can be used to perform string " +"comparisons that won't falsely report inequality if two strings use " +"combining characters differently:" msgstr "" -#: ../../howto/unicode.rst:434 +#: ../../howto/unicode.rst:436 msgid "" "import unicodedata\n" "\n" @@ -754,11 +759,11 @@ msgstr "" "print('length of second string=', len(multiple_chars))\n" "print(compare_strs(single_char, multiple_chars))" -#: ../../howto/unicode.rst:448 +#: ../../howto/unicode.rst:450 msgid "When run, this outputs:" msgstr "" -#: ../../howto/unicode.rst:450 +#: ../../howto/unicode.rst:452 msgid "" "$ python compare-strs.py\n" "length of first string= 1\n" @@ -770,18 +775,18 @@ msgstr "" "length of second string= 2\n" "True" -#: ../../howto/unicode.rst:457 +#: ../../howto/unicode.rst:459 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:461 +#: ../../howto/unicode.rst:463 msgid "The Unicode Standard also specifies how to do caseless comparisons::" msgstr "" -#: ../../howto/unicode.rst:463 +#: ../../howto/unicode.rst:465 msgid "" "import unicodedata\n" "\n" @@ -799,7 +804,7 @@ msgid "" "print(compare_caseless(single_char, multiple_chars))" msgstr "" -#: ../../howto/unicode.rst:477 +#: ../../howto/unicode.rst:479 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-" @@ -807,11 +812,11 @@ msgid "" "3.13 of the Unicode Standard for a discussion and an example.)" msgstr "" -#: ../../howto/unicode.rst:484 +#: ../../howto/unicode.rst:486 msgid "Unicode Regular Expressions" msgstr "" -#: ../../howto/unicode.rst:486 +#: ../../howto/unicode.rst:488 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 " @@ -821,13 +826,13 @@ msgid "" "in the ``'Nd'`` category." msgstr "" -#: ../../howto/unicode.rst:493 +#: ../../howto/unicode.rst:495 msgid "" "The string in this example has the number 57 written in both Thai and Arabic " "numerals::" msgstr "" -#: ../../howto/unicode.rst:496 +#: ../../howto/unicode.rst:498 msgid "" "import re\n" "p = re.compile(r'\\d+')\n" @@ -843,52 +848,51 @@ msgstr "" "m = p.search(s)\n" "print(repr(m.group()))" -#: ../../howto/unicode.rst:503 +#: ../../howto/unicode.rst:505 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:507 +#: ../../howto/unicode.rst:509 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:518 +#: ../../howto/unicode.rst:520 msgid "Some good alternative discussions of Python's Unicode support are:" msgstr "" -#: ../../howto/unicode.rst:520 +#: ../../howto/unicode.rst:522 msgid "" -"`Processing Text Files in Python 3 `_, " -"by Nick Coghlan." +"`Processing Text Files in Python 3 `_, by Nick Coghlan." msgstr "" -#: ../../howto/unicode.rst:521 +#: ../../howto/unicode.rst:523 msgid "" "`Pragmatic Unicode `_, a PyCon " "2012 presentation by Ned Batchelder." msgstr "" -#: ../../howto/unicode.rst:523 +#: ../../howto/unicode.rst:525 msgid "" -"The :class:`str` type is described in the Python library reference " -"at :ref:`textseq`." +"The :class:`str` type is described in the Python library reference at :ref:" +"`textseq`." msgstr "" -#: ../../howto/unicode.rst:526 +#: ../../howto/unicode.rst:528 msgid "The documentation for the :mod:`unicodedata` module." msgstr ":mod:`unicodedata` 模組的文件。" -#: ../../howto/unicode.rst:528 +#: ../../howto/unicode.rst:530 msgid "The documentation for the :mod:`codecs` module." msgstr ":mod:`codecs` 模組的文件。" -#: ../../howto/unicode.rst:530 +#: ../../howto/unicode.rst:532 msgid "" "Marc-André Lemburg gave `a presentation titled \"Python and Unicode\" (PDF " "slides) `_ at " @@ -897,18 +901,18 @@ msgid "" "``unicode`` and literals start with ``u``)." msgstr "" -#: ../../howto/unicode.rst:538 +#: ../../howto/unicode.rst:540 msgid "Reading and Writing Unicode Data" msgstr "" -#: ../../howto/unicode.rst:540 +#: ../../howto/unicode.rst:542 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:544 +#: ../../howto/unicode.rst:546 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 " @@ -917,7 +921,7 @@ msgid "" "valued columns and can return Unicode values from an SQL query." msgstr "" -#: ../../howto/unicode.rst:550 +#: ../../howto/unicode.rst:552 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 " @@ -926,7 +930,7 @@ msgid "" "recommended." msgstr "" -#: ../../howto/unicode.rst:555 +#: ../../howto/unicode.rst:557 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-" @@ -940,7 +944,7 @@ msgid "" "version in memory.)" msgstr "" -#: ../../howto/unicode.rst:565 +#: ../../howto/unicode.rst:567 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 " @@ -948,15 +952,15 @@ msgid "" "object that assumes the file's contents are in a specified encoding and " "accepts Unicode parameters for methods such as :meth:`~io.TextIOBase.read` " "and :meth:`~io.TextIOBase.write`. This works through :func:`open`\\'s " -"*encoding* and *errors* parameters which are interpreted just like those " -"in :meth:`str.encode` and :meth:`bytes.decode`." +"*encoding* and *errors* parameters which are interpreted just like those in :" +"meth:`str.encode` and :meth:`bytes.decode`." msgstr "" -#: ../../howto/unicode.rst:574 +#: ../../howto/unicode.rst:576 msgid "Reading Unicode from a file is therefore simple::" msgstr "" -#: ../../howto/unicode.rst:576 +#: ../../howto/unicode.rst:578 msgid "" "with open('unicode.txt', encoding='utf-8') as f:\n" " for line in f:\n" @@ -966,13 +970,13 @@ msgstr "" " for line in f:\n" " print(repr(line))" -#: ../../howto/unicode.rst:580 +#: ../../howto/unicode.rst:582 msgid "" "It's also possible to open files in update mode, allowing both reading and " "writing::" msgstr "" -#: ../../howto/unicode.rst:583 +#: ../../howto/unicode.rst:585 msgid "" "with open('test', encoding='utf-8', mode='w+') as f:\n" " f.write('\\u4500 blah blah blah\\n')\n" @@ -984,7 +988,7 @@ msgstr "" " f.seek(0)\n" " print(repr(f.readline()[:1]))" -#: ../../howto/unicode.rst:588 +#: ../../howto/unicode.rst:590 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 " @@ -997,7 +1001,7 @@ msgid "" "the BOM." msgstr "" -#: ../../howto/unicode.rst:597 +#: ../../howto/unicode.rst:599 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 " @@ -1006,11 +1010,11 @@ msgid "" "if present." msgstr "" -#: ../../howto/unicode.rst:604 +#: ../../howto/unicode.rst:606 msgid "Unicode filenames" msgstr "" -#: ../../howto/unicode.rst:606 +#: ../../howto/unicode.rst:608 msgid "" "Most of the operating systems in common use today support filenames that " "contain arbitrary Unicode characters. Usually this is implemented by " @@ -1023,7 +1027,7 @@ msgid "" "encoding is again UTF-8." msgstr "" -#: ../../howto/unicode.rst:616 +#: ../../howto/unicode.rst:618 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 " @@ -1032,7 +1036,7 @@ msgid "" "and it will be automatically converted to the right encoding for you::" msgstr "" -#: ../../howto/unicode.rst:622 +#: ../../howto/unicode.rst:624 msgid "" "filename = 'filename\\u4500abc'\n" "with open(filename, 'w') as f:\n" @@ -1042,13 +1046,13 @@ msgstr "" "with open(filename, 'w') as f:\n" " f.write('blah\\n')" -#: ../../howto/unicode.rst:626 +#: ../../howto/unicode.rst:628 msgid "" "Functions in the :mod:`os` module such as :func:`os.stat` will also accept " "Unicode filenames." msgstr "" -#: ../../howto/unicode.rst:629 +#: ../../howto/unicode.rst:631 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 " @@ -1061,7 +1065,7 @@ msgid "" "error handler>` is UTF-8, running the following program::" msgstr "" -#: ../../howto/unicode.rst:639 +#: ../../howto/unicode.rst:641 msgid "" "fn = 'filename\\u4500abc'\n" "f = open(fn, 'w')\n" @@ -1079,11 +1083,11 @@ msgstr "" "print(os.listdir(b'.'))\n" "print(os.listdir('.'))" -#: ../../howto/unicode.rst:647 +#: ../../howto/unicode.rst:649 msgid "will produce the following output:" msgstr "" -#: ../../howto/unicode.rst:649 +#: ../../howto/unicode.rst:651 msgid "" "$ python listdir-test.py\n" "[b'filename\\xe4\\x94\\x80abc', ...]\n" @@ -1093,13 +1097,13 @@ msgstr "" "[b'filename\\xe4\\x94\\x80abc', ...]\n" "['filename\\u4500abc', ...]" -#: ../../howto/unicode.rst:655 +#: ../../howto/unicode.rst:657 msgid "" "The first list contains UTF-8-encoded filenames, and the second list " "contains the Unicode versions." msgstr "" -#: ../../howto/unicode.rst:658 +#: ../../howto/unicode.rst:660 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 " @@ -1107,27 +1111,27 @@ msgid "" "now." msgstr "" -#: ../../howto/unicode.rst:665 +#: ../../howto/unicode.rst:667 msgid "Tips for Writing Unicode-aware Programs" msgstr "" -#: ../../howto/unicode.rst:667 +#: ../../howto/unicode.rst:669 msgid "" "This section provides some suggestions on writing software that deals with " "Unicode." msgstr "" -#: ../../howto/unicode.rst:670 +#: ../../howto/unicode.rst:672 msgid "The most important tip is:" msgstr "" -#: ../../howto/unicode.rst:672 +#: ../../howto/unicode.rst:674 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:675 +#: ../../howto/unicode.rst:677 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 " @@ -1136,7 +1140,7 @@ msgid "" "raised." msgstr "" -#: ../../howto/unicode.rst:680 +#: ../../howto/unicode.rst:682 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 " @@ -1148,24 +1152,24 @@ msgid "" "then choose a clever way to hide malicious text in the encoded bytestream." msgstr "" -#: ../../howto/unicode.rst:691 +#: ../../howto/unicode.rst:693 msgid "Converting Between File Encodings" msgstr "" -#: ../../howto/unicode.rst:693 +#: ../../howto/unicode.rst:695 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:697 +#: ../../howto/unicode.rst:699 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:701 +#: ../../howto/unicode.rst:703 msgid "" "new_f = codecs.StreamRecoder(f,\n" " # en/decoder: used by read() to encode its results and\n" @@ -1176,11 +1180,11 @@ msgid "" " codecs.getreader('latin-1'), codecs.getwriter('latin-1') )" msgstr "" -#: ../../howto/unicode.rst:711 +#: ../../howto/unicode.rst:713 msgid "Files in an Unknown Encoding" msgstr "" -#: ../../howto/unicode.rst:713 +#: ../../howto/unicode.rst:715 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 " @@ -1188,7 +1192,7 @@ msgid "" "``surrogateescape`` error handler::" msgstr "" -#: ../../howto/unicode.rst:718 +#: ../../howto/unicode.rst:720 msgid "" "with open(fname, 'r', encoding=\"ascii\", errors=\"surrogateescape\") as f:\n" " data = f.read()\n" @@ -1208,7 +1212,7 @@ msgstr "" " encoding=\"ascii\", errors=\"surrogateescape\") as f:\n" " f.write(data)" -#: ../../howto/unicode.rst:727 +#: ../../howto/unicode.rst:729 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 " @@ -1216,14 +1220,14 @@ msgid "" "error handler is used to encode the data and write it back out." msgstr "" -#: ../../howto/unicode.rst:737 +#: ../../howto/unicode.rst:739 msgid "" -"One section of `Mastering Python 3 Input/Output `_, a PyCon 2010 talk by David " +"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:741 +#: ../../howto/unicode.rst:743 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:754 +#: ../../howto/unicode.rst:756 msgid "Acknowledgements" msgstr "致謝" -#: ../../howto/unicode.rst:756 +#: ../../howto/unicode.rst:758 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:760 +#: ../../howto/unicode.rst:762 msgid "" "Thanks to the following people who have noted errors or offered suggestions " "on this article: Éric Araujo, Nicholas Bastin, Nick Coghlan, Marius " diff --git a/howto/urllib2.po b/howto/urllib2.po index c712f8230aa..540848cedb5 100644 --- a/howto/urllib2.po +++ b/howto/urllib2.po @@ -1,13 +1,13 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Phate , 2015 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"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: 2025-12-01 00:17+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-" @@ -35,6 +35,10 @@ msgstr "`Michael Foord `_" msgid "Introduction" msgstr "簡介" +#: ../../howto/urllib2.rst:13 +msgid "Related Articles" +msgstr "" + #: ../../howto/urllib2.rst:15 msgid "" "You may also find useful the following article on fetching web resources " @@ -44,10 +48,10 @@ msgstr "以下這些與 Python 有關的文章說不定能幫到你::" #: ../../howto/urllib2.rst:18 msgid "" "`Basic Authentication `_" +"voidspace.org.uk/python/articles/authentication.shtml>`__" msgstr "" "`Basic Authentication `_" +"voidspace.org.uk/python/articles/authentication.shtml>`__" #: ../../howto/urllib2.rst:20 msgid "A tutorial on *Basic Authentication*, with examples in Python." @@ -88,10 +92,10 @@ msgid "" "is supplementary to them." msgstr "" "一般情形下 *urlopen* 是非常容易使用的,但當你遇到錯誤或者較複雜的情況下,你可" -"能需要對超文本協定 (HyperText Transfer Protocol) 有一定的了解。最完整且具參考價" -"值的是 :rfc:`2616`,不過它是一份技術文件並不容易閱讀,以下的教學會提供足夠的 " -"HTTP 知識來幫助你使用 *urllib*。這份教學並非要取代 :mod:`urllib.request` 這份" -"文件,你還是會需要它。" +"能需要對超文本協定 (HyperText Transfer Protocol) 有一定的了解。最完整且具參考" +"價值的是 :rfc:`2616`,不過它是一份技術文件並不容易閱讀,以下的教學會提供足夠" +"的 HTTP 知識來幫助你使用 *urllib*。這份教學並非要取代 :mod:`urllib.request` " +"這份文件,你還是會需要它。" #: ../../howto/urllib2.rst:44 msgid "Fetching URLs" diff --git a/installing/index.po b/installing/index.po index eab5a621795..cef15e95ed7 100644 --- a/installing/index.po +++ b/installing/index.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -7,7 +7,7 @@ # Steven Hsu , 2021 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-03 11:11+0800\n" "PO-Revision-Date: 2022-06-27 09:37+0800\n" diff --git a/library/__future__.po b/library/__future__.po index 30cc1abfa56..57538c7c3f0 100644 --- a/library/__future__.po +++ b/library/__future__.po @@ -1,13 +1,13 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Matt Wang , 2023-2024 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-08-03 00:19+0000\n" +"POT-Creation-Date: 2025-09-08 15:25+0800\n" "PO-Revision-Date: 2024-02-06 02:12+0000\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -28,10 +28,11 @@ msgstr "**原始碼:**\\ :source:`Lib/__future__.py`" #: ../../library/__future__.rst:11 msgid "" -"Imports of the form ``from __future__ import feature`` are called :ref:" -"`future statements `. These are special-cased by the Python compiler " -"to allow the use of new Python features in modules containing the future " -"statement before the release in which the feature becomes standard." +"Imports of the form ``from __future__ import feature`` are " +"called :ref:`future statements `. These are special-cased by the " +"Python compiler to allow the use of new Python features in modules " +"containing the future statement before the release in which the feature " +"becomes standard." msgstr "" "``from __future__ import feature`` 形式的引入被稱為 :ref:`future 陳述式 " "`。這些是 Python 編譯器的特殊情況,允許在該功能成為標準版本之前在包" @@ -67,9 +68,9 @@ msgstr "" #: ../../library/__future__.rst:29 msgid "" "To ensure that :ref:`future statements ` run under releases prior to " -"Python 2.1 at least yield runtime exceptions (the import of :mod:" -"`__future__` will fail, because there was no module of that name prior to " -"2.1)." +"Python 2.1 at least yield runtime exceptions (the import " +"of :mod:`__future__` will fail, because there was no module of that name " +"prior to 2.1)." msgstr "" "確保 :ref:`future 陳述式 `\\ 在 Python 2.1 之前的版本中運行至少會產" "生 runtime 例外(\\ :mod:`__future__` 的引入將會失敗,因為 2.1 之前沒有該名稱" @@ -195,14 +196,16 @@ msgid "Never [1]_" msgstr "從未 [1]_" #: ../../library/__future__.rst:84 -msgid ":pep:`563`: *Postponed evaluation of annotations*" -msgstr ":pep:`563`: *推遲對註釋的求值 (Postponed evaluation of annotations)*" +msgid "" +":pep:`563`: *Postponed evaluation of annotations*, :pep:`649`: *Deferred " +"evaluation of annotations using descriptors*" +msgstr "" -#: ../../library/__future__.rst:92 +#: ../../library/__future__.rst:93 msgid "Each statement in :file:`__future__.py` is of the form::" msgstr ":file:`__future__.py` 中的每個陳述式的形式如下: ::" -#: ../../library/__future__.rst:94 +#: ../../library/__future__.rst:95 msgid "" "FeatureName = _Feature(OptionalRelease, MandatoryRelease,\n" " CompilerFlag)" @@ -210,15 +213,15 @@ msgstr "" "FeatureName = _Feature(OptionalRelease, MandatoryRelease,\n" " CompilerFlag)" -#: ../../library/__future__.rst:97 +#: ../../library/__future__.rst:98 msgid "" "where, normally, *OptionalRelease* is less than *MandatoryRelease*, and both " "are 5-tuples of the same form as :data:`sys.version_info`::" msgstr "" -"通常,*OptionalRelease* 會小於 *MandatoryRelease*,且兩者都是與 :data:`sys." -"version_info` 形式相同的 5 元組 (5-tuple): ::" +"通常,*OptionalRelease* 會小於 *MandatoryRelease*,且兩者都是" +"與 :data:`sys.version_info` 形式相同的 5 元組 (5-tuple): ::" -#: ../../library/__future__.rst:100 +#: ../../library/__future__.rst:101 msgid "" "(PY_MAJOR_VERSION, # the 2 in 2.1.0a3; an int\n" " PY_MINOR_VERSION, # the 1; an int\n" @@ -231,18 +234,18 @@ msgstr "" "(PY_MAJOR_VERSION, # 2.1.0a3 裡面的 2;為一整數\n" " PY_MINOR_VERSION, # 1;為一整數\n" " PY_MICRO_VERSION, # 0;為一整數\n" -" PY_RELEASE_LEVEL, # \"alpha\"、\"beta\"、\"candidate\" 或 \"final\"; " -";為一字串\n" +" PY_RELEASE_LEVEL, # \"alpha\"、\"beta\"、\"candidate\" 或 \"final\"; ;為一" +"字串\n" " PY_RELEASE_SERIAL # 3;為一整數\n" ")" -#: ../../library/__future__.rst:109 +#: ../../library/__future__.rst:110 msgid "" "*OptionalRelease* records the first release in which the feature was " "accepted." msgstr "*OptionalRelease* 記錄該功能首次發布時的 Python 版本。" -#: ../../library/__future__.rst:113 +#: ../../library/__future__.rst:114 msgid "" "In the case of a *MandatoryRelease* that has not yet occurred, " "*MandatoryRelease* predicts the release in which the feature will become " @@ -251,7 +254,7 @@ msgstr "" "如果 *MandatoryRelease* 尚未發布,*MandatoryRelease* 會預測該功能將成為該語言" "一部分的版本。" -#: ../../library/__future__.rst:117 +#: ../../library/__future__.rst:118 msgid "" "Else *MandatoryRelease* records when the feature became part of the " "language; in releases at or after that, modules no longer need a future " @@ -261,7 +264,7 @@ msgstr "" "否則 *MandatoryRelease* 會記錄該功能是何時成為語言的一部分;在該版本或之後的" "版本中,模組不再需要 future 聲明來使用相關功能,但可以繼續使用此種引入方式。" -#: ../../library/__future__.rst:121 +#: ../../library/__future__.rst:122 msgid "" "*MandatoryRelease* may also be ``None``, meaning that a planned feature got " "dropped or that it is not yet decided." @@ -269,47 +272,59 @@ msgstr "" "*MandatoryRelease* 也可能是 ``None``,這意味著計劃中的功能被丟棄或者仍未決" "定。" -#: ../../library/__future__.rst:126 +#: ../../library/__future__.rst:127 msgid "" "*CompilerFlag* is the (bitfield) flag that should be passed in the fourth " "argument to the built-in function :func:`compile` to enable the feature in " -"dynamically compiled code. This flag is stored in the :attr:`_Feature." -"compiler_flag` attribute on :class:`_Feature` instances." +"dynamically compiled code. This flag is stored in " +"the :attr:`_Feature.compiler_flag` attribute on :class:`_Feature` instances." msgstr "" "*CompilerFlag* 是(位元欄位 (bitfield))旗標,應在第四個引數中傳遞給內建函" -"式 :func:`compile` 以在動態編譯的程式碼中啟用該功能。此旗標儲存在 :class:" -"`_Feature` 實例上的 :attr:`_Feature.compiler_flag` 屬性中。" +"式 :func:`compile` 以在動態編譯的程式碼中啟用該功能。此旗標儲存" +"在 :class:`_Feature` 實例上的 :attr:`_Feature.compiler_flag` 屬性中。" -#: ../../library/__future__.rst:132 +#: ../../library/__future__.rst:133 msgid "" "``from __future__ import annotations`` was previously scheduled to become " -"mandatory in Python 3.10, but the Python Steering Council twice decided to " -"delay the change (`announcement for Python 3.10 `__; `announcement for Python 3.11 `__). No " -"final decision has been made yet. See also :pep:`563` and :pep:`649`." +"mandatory in Python 3.10, but the change was delayed and ultimately " +"canceled. This feature will eventually be deprecated and removed. " +"See :pep:`649` and :pep:`749`." msgstr "" -"之前原本計劃在 Python 3.10 中強制使用 ``from __future__ import " -"annotations``,但 Python 指導委員會 (Python Steering Council) 兩次決議推遲這" -"一變動(`Python 3.10 的公告 `__;`Python 3.11 的" -"公告 `__)。目前還尚未做出決定。另請參閱 :pep:" -"`563` 和 :pep:`649`。" -#: ../../library/__future__.rst:142 +#: ../../library/__future__.rst:141 msgid ":ref:`future`" msgstr ":ref:`future`" -#: ../../library/__future__.rst:143 +#: ../../library/__future__.rst:142 msgid "How the compiler treats future imports." msgstr "編譯器如何處理 future 引入。" -#: ../../library/__future__.rst:145 +#: ../../library/__future__.rst:144 msgid ":pep:`236` - Back to the __future__" msgstr ":pep:`236` - 回到 __future__" -#: ../../library/__future__.rst:146 +#: ../../library/__future__.rst:145 msgid "The original proposal for the __future__ mechanism." msgstr "__future__ 機制的原始提案。" + +#~ msgid ":pep:`563`: *Postponed evaluation of annotations*" +#~ msgstr "" +#~ ":pep:`563`: *推遲對註釋的求值 (Postponed evaluation of annotations)*" + +#~ msgid "" +#~ "``from __future__ import annotations`` was previously scheduled to become " +#~ "mandatory in Python 3.10, but the Python Steering Council twice decided " +#~ "to delay the change (`announcement for Python 3.10 `__; `announcement for Python 3.11 " +#~ "`__). No final decision has been made " +#~ "yet. See also :pep:`563` and :pep:`649`." +#~ msgstr "" +#~ "之前原本計劃在 Python 3.10 中強制使用 ``from __future__ import " +#~ "annotations``,但 Python 指導委員會 (Python Steering Council) 兩次決議推遲" +#~ "這一變動(`Python 3.10 的公告 `__;" +#~ "`Python 3.11 的公告 `__)。目前還尚未" +#~ "做出決定。另請參閱 :pep:`563` 和 :pep:`649`。" diff --git a/library/__main__.po b/library/__main__.po index ff81f21bf65..684307463a6 100644 --- a/library/__main__.po +++ b/library/__main__.po @@ -1,12 +1,12 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"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: 2025-09-08 15:25+0800\n" "PO-Revision-Date: 2023-12-21 14:49+0800\n" "Last-Translator: Liang-Bo Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -43,8 +43,8 @@ msgstr "在 Python 套件中的 ``__main__.py`` 檔案。" msgid "" "Both of these mechanisms are related to Python modules; how users interact " "with them and how they interact with each other. They are explained in " -"detail below. If you're new to Python modules, see the tutorial section :" -"ref:`tut-modules` for an introduction." +"detail below. If you're new to Python modules, see the tutorial " +"section :ref:`tut-modules` for an introduction." msgstr "" "這兩種機制都與 Python 模組有關;使用者如何與它們互動以及它們如何彼此互動。下" "面會詳細解釋它們。如果你不熟悉 Python 模組,請參閱教學章節 :ref:`tut-" @@ -145,8 +145,8 @@ msgstr "" #: ../../library/__main__.rst:67 msgid "" -"the Python module or package passed to the Python interpreter with the :" -"option:`-m` argument:" +"the Python module or package passed to the Python interpreter with " +"the :option:`-m` argument:" msgstr "使用 :option:`-m` 引數傳遞給 Python 直譯器的 Python 模組或套件:" #: ../../library/__main__.rst:70 @@ -334,9 +334,9 @@ msgstr "sys.exit(main())" #: ../../library/__main__.rst:175 msgid "" "Since the call to ``main`` is wrapped in :func:`sys.exit`, the expectation " -"is that your function will return some value acceptable as an input to :func:" -"`sys.exit`; typically, an integer or ``None`` (which is implicitly returned " -"if your function does not have a return statement)." +"is that your function will return some value acceptable as an input " +"to :func:`sys.exit`; typically, an integer or ``None`` (which is implicitly " +"returned if your function does not have a return statement)." msgstr "" "由於對 ``main`` 的呼叫包含在 :func:`sys.exit` 中,因此期望你的函式將傳回一些" "可接受作為 :func:`sys.exit` 輸入的值;通常來說,會是一個整數或 ``None``\\(如" @@ -357,14 +357,14 @@ msgid "" "In particular, be careful about returning strings from your ``main`` " "function. :func:`sys.exit` will interpret a string argument as a failure " "message, so your program will have an exit code of ``1``, indicating " -"failure, and the string will be written to :data:`sys.stderr`. The ``echo." -"py`` example from earlier exemplifies using the ``sys.exit(main())`` " +"failure, and the string will be written to :data:`sys.stderr`. The " +"``echo.py`` example from earlier exemplifies using the ``sys.exit(main())`` " "convention." msgstr "" "特別是,要謹慎處理從 ``main`` 函式回傳字串。:func:`sys.exit` 會將字串引數直譯" "為失敗訊息,因此你的程式將有一個表示失敗的結束代碼 ``1``,並且該字串將被寫" -"入 :data:`sys.stderr`。前面的 ``echo.py`` 範例使用慣例的 ``sys." -"exit(main())`` 進行示範。" +"入 :data:`sys.stderr`。前面的 ``echo.py`` 範例使用慣例的 " +"``sys.exit(main())`` 進行示範。" #: ../../library/__main__.rst:193 msgid "" @@ -486,8 +486,8 @@ msgstr "" #: ../../library/__main__.rst:254 msgid "" -"This won't work for ``__main__.py`` files in the root directory of a ``." -"zip`` file though. Hence, for consistency, a minimal ``__main__.py`` " +"This won't work for ``__main__.py`` files in the root directory of a " +"``.zip`` file though. Hence, for consistency, a minimal ``__main__.py`` " "without a ``__name__`` check is preferred." msgstr "" "但這對於 ``.zip`` 檔案根目錄中的 ``__main__.py`` 檔案不起作用。因此,為了保持" @@ -553,10 +553,7 @@ msgid "" " if not did_user_define_their_name():\n" " raise ValueError('Define the variable `my_name`!')\n" "\n" -" if '__file__' in dir(__main__):\n" -" print(__main__.my_name, \"found in file\", __main__.__file__)\n" -" else:\n" -" print(__main__.my_name)" +" print(__main__.my_name)" msgstr "" "# namely.py\n" "\n" @@ -569,16 +566,13 @@ msgstr "" " if not did_user_define_their_name():\n" " raise ValueError('Define the variable `my_name`!')\n" "\n" -" if '__file__' in dir(__main__):\n" -" print(__main__.my_name, \"found in file\", __main__.__file__)\n" -" else:\n" -" print(__main__.my_name)" +" print(__main__.my_name)" -#: ../../library/__main__.rst:300 +#: ../../library/__main__.rst:297 msgid "Example usage of this module could be as follows::" msgstr "該模組的範例用法如下: ::" -#: ../../library/__main__.rst:302 +#: ../../library/__main__.rst:299 msgid "" "# start.py\n" "\n" @@ -614,11 +608,11 @@ msgstr "" "if __name__ == \"__main__\":\n" " sys.exit(main())" -#: ../../library/__main__.rst:319 +#: ../../library/__main__.rst:316 msgid "Now, if we started our program, the result would look like this:" msgstr "現在,如果我們啟動程式,結果將如下所示:" -#: ../../library/__main__.rst:321 +#: ../../library/__main__.rst:318 msgid "" "$ python start.py\n" "Define the variable `my_name`!" @@ -626,7 +620,7 @@ msgstr "" "$ python start.py\n" "Define the variable `my_name`!" -#: ../../library/__main__.rst:326 +#: ../../library/__main__.rst:323 msgid "" "The exit code of the program would be 1, indicating an error. Uncommenting " "the line with ``my_name = \"Dinsdale\"`` fixes the program and now it exits " @@ -635,15 +629,15 @@ msgstr "" "程式的結束代碼將為 1,表示出現錯誤。取消註解 ``my_name = \"Dinsdale\"`` 而修" "復程式後,現在它以狀態碼 0 結束,表示成功:" -#: ../../library/__main__.rst:330 +#: ../../library/__main__.rst:327 msgid "" "$ python start.py\n" -"Dinsdale found in file /path/to/start.py" +"Dinsdale" msgstr "" "$ python start.py\n" -"Dinsdale found in file /path/to/start.py" +"Dinsdale" -#: ../../library/__main__.rst:335 +#: ../../library/__main__.rst:332 msgid "" "Note that importing ``__main__`` doesn't cause any issues with " "unintentionally running top-level code meant for script use which is put in " @@ -654,7 +648,7 @@ msgstr "" "__name__ == \"__main__\"`` 區塊的頂層程式碼(本來是給腳本使用的)而造成任何問" "題。為什麼這樣做會如預期運作?" -#: ../../library/__main__.rst:339 +#: ../../library/__main__.rst:336 msgid "" "Python inserts an empty ``__main__`` module in :data:`sys.modules` at " "interpreter startup, and populates it by running top-level code. In our " @@ -674,7 +668,7 @@ msgstr "" "文件中的\\ :ref:`關於 __main__ 的特別考量 `\\ 了解其工作" "原理的詳細資訊。" -#: ../../library/__main__.rst:348 +#: ../../library/__main__.rst:345 msgid "" "The Python REPL is another example of a \"top-level environment\", so " "anything defined in the REPL becomes part of the ``__main__`` scope::" @@ -682,7 +676,7 @@ msgstr "" "Python REPL 是「頂層環境」的另一個範例,因此 REPL 中定義的任何內容都成為 作域" "的一部分: ::" -#: ../../library/__main__.rst:351 +#: ../../library/__main__.rst:348 msgid "" ">>> import namely\n" ">>> namely.did_user_define_their_name()\n" @@ -710,16 +704,8 @@ msgstr "" ">>> namely.print_user_name()\n" "Jabberwocky" -#: ../../library/__main__.rst:364 -msgid "" -"Note that in this case the ``__main__`` scope doesn't contain a ``__file__`` " -"attribute as it's interactive." -msgstr "" -"請注意,在這種情況下, ``__main__`` 作用域不包含 ``__file__`` 屬性,因為它是" -"互動式的。" - -#: ../../library/__main__.rst:367 +#: ../../library/__main__.rst:361 msgid "" -"The ``__main__`` scope is used in the implementation of :mod:`pdb` and :mod:" -"`rlcompleter`." +"The ``__main__`` scope is used in the implementation of :mod:`pdb` " +"and :mod:`rlcompleter`." msgstr "``__main__`` 作用域用於 :mod:`pdb` 和 :mod:`rlcompleter` 的實作。" diff --git a/library/_thread.po b/library/_thread.po index 1f52f9ef12e..5df49d8c03e 100644 --- a/library/_thread.po +++ b/library/_thread.po @@ -1,12 +1,12 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-10-12 00:13+0000\n" +"POT-Creation-Date: 2025-09-08 15:25+0800\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-" @@ -32,8 +32,9 @@ msgid "" msgstr "" "這個模組提供了與多個執行緒(也稱為:dfn:`輕量級行程` 或 :dfn: `任務`)一起工作" "的低階原始物件 --- 多個控制執行緒分享其全域資料空間。為了處理同步問題,也提供" -"了簡單的鎖 (lock) 機制(也稱為:dfn:`互斥鎖` 或 :dfn:`二進位號誌`)。 :mod:" -"`threading` 模組提供了一個建立在這個模組之上的更易於使用和高階的執行緒 API。" +"了簡單的鎖 (lock) 機制(也稱為:dfn:`互斥鎖` 或 :dfn:`二進位號誌" +"`)。 :mod:`threading` 模組提供了一個建立在這個模組之上的更易於使用和高階的執" +"行緒 API。" #: ../../library/_thread.rst:26 msgid "This module used to be optional, it is now always available." @@ -62,7 +63,7 @@ msgid "" "The optional *kwargs* argument specifies a dictionary of keyword arguments." msgstr "" "開始一個新的執行緒並回傳其識別字 (identifier) 。該執行緒執行帶有引數列表 " -"*args*(必須是一個 tuple(元組))的函式 *function*。可選的 *kwargs* 引數指定" +"*args*\\ (必須是一個 tuple(元組))的函式 *function*。可選的 *kwargs* 引數指定" "一個關鍵字引數的字典。" #: ../../library/_thread.rst:50 @@ -71,10 +72,11 @@ msgstr "當函式回傳時,執行緒會靜默退出。" #: ../../library/_thread.rst:52 msgid "" -"When the function terminates with an unhandled exception, :func:`sys." -"unraisablehook` is called to handle the exception. The *object* attribute of " -"the hook argument is *function*. By default, a stack trace is printed and " -"then the thread exits (but other threads continue to run)." +"When the function terminates with an unhandled " +"exception, :func:`sys.unraisablehook` is called to handle the exception. The " +"*object* attribute of the hook argument is *function*. By default, a stack " +"trace is printed and then the thread exits (but other threads continue to " +"run)." msgstr "" "當函式因未處理的例外終止時,將呼叫 :func:`sys.unraisablehook` 來處理該例外。" "鉤子引數的 *object* 屬性是 *function*。預設情況下,會列印堆疊跟蹤,然後執行緒" @@ -112,16 +114,17 @@ msgid "" "If given, *signum* is the number of the signal to simulate. If *signum* is " "not given, :const:`signal.SIGINT` is simulated." msgstr "" -"如果提供了 *signum*,則模擬指定的訊號編號。如果未提供 *signum*,則模擬 :" -"const:`signal.SIGINT` 訊號。" +"如果提供了 *signum*,則模擬指定的訊號編號。如果未提供 *signum*,則模" +"擬 :const:`signal.SIGINT` 訊號。" #: ../../library/_thread.rst:75 msgid "" -"If the given signal isn't handled by Python (it was set to :const:`signal." -"SIG_DFL` or :const:`signal.SIG_IGN`), this function does nothing." +"If the given signal isn't handled by Python (it was set " +"to :const:`signal.SIG_DFL` or :const:`signal.SIG_IGN`), this function does " +"nothing." msgstr "" -"如果給定的訊號在 Python 中未被處理(即設置為 :const:`signal.SIG_DFL` 或 :" -"const:`signal.SIG_IGN`),此函式不做任何操作。" +"如果給定的訊號在 Python 中未被處理(即設置為 :const:`signal.SIG_DFL` " +"或 :const:`signal.SIG_IGN`),此函式不做任何操作。" #: ../../library/_thread.rst:79 msgid "The *signum* argument is added to customize the signal number." @@ -185,9 +188,9 @@ msgid "" "*size* argument specifies the stack size to be used for subsequently created " "threads, and must be 0 (use platform or configured default) or a positive " "integer value of at least 32,768 (32 KiB). If *size* is not specified, 0 is " -"used. If changing the thread stack size is unsupported, a :exc:" -"`RuntimeError` is raised. If the specified stack size is invalid, a :exc:" -"`ValueError` is raised and the stack size is unmodified. 32 KiB is " +"used. If changing the thread stack size is unsupported, " +"a :exc:`RuntimeError` is raised. If the specified stack size is invalid, " +"a :exc:`ValueError` is raised and the stack size is unmodified. 32 KiB is " "currently the minimum supported stack size value to guarantee sufficient " "stack space for the interpreter itself. Note that some platforms may have " "particular restrictions on values for the stack size, such as requiring a " @@ -200,12 +203,12 @@ msgstr "" "回傳在建立新執行緒時使用的執行緒堆疊大小。可選的 *size* 引數指定了隨後建立的" "執行緒要使用的堆疊大小,必須是 0(使用平台或配置的預設值)或至少 32,768(32 " "KiB)的正整數值。如果未指定 *size*,則使用 0。如果不支持更改執行緒堆疊大小," -"則會引發 :exc:`RuntimeError` 錯誤。如果指定的堆疊大小無效,則會引發 :exc:" -"`ValueError` 錯誤,並且堆疊大小不會被修改。目前,32 KiB 是保證解譯器本身具有" -"足夠堆疊空間所支持的最小堆疊大小值。請注意,某些平台對於堆疊大小的值可能有特" -"定的限制,例如要求最小堆疊大小 > 32 KiB,或要求按系統記憶體頁面大小的倍數進行" -"分配。應參考平台文件以取得更多訊息(4 KiB 頁面是比較普遍的;在缺乏更具體訊息" -"的情況下,建議使用 4096 的倍數作為堆疊大小)。" +"則會引發 :exc:`RuntimeError` 錯誤。如果指定的堆疊大小無效,則會引" +"發 :exc:`ValueError` 錯誤,並且堆疊大小不會被修改。目前,32 KiB 是保證直譯器" +"本身具有足夠堆疊空間所支持的最小堆疊大小值。請注意,某些平台對於堆疊大小的值" +"可能有特定的限制,例如要求最小堆疊大小 > 32 KiB,或要求按系統記憶體頁面大小的" +"倍數進行分配。應參考平台文件以取得更多訊息(4 KiB 頁面是比較普遍的;在缺乏更" +"具體訊息的情況下,建議使用 4096 的倍數作為堆疊大小)。" #: ../../library/_thread.rst:150 msgid "Unix platforms with POSIX threads support." @@ -269,26 +272,30 @@ msgstr "新增的 *timeout* 參數。" msgid "Lock acquires can now be interrupted by signals on POSIX." msgstr "現在取得鎖的操作可以被 POSIX 訊號中斷。" -#: ../../library/_thread.rst:193 +#: ../../library/_thread.rst:190 +msgid "Lock acquires can now be interrupted by signals on Windows." +msgstr "" + +#: ../../library/_thread.rst:196 msgid "" "Releases the lock. The lock must have been acquired earlier, but not " "necessarily by the same thread." msgstr "釋放鎖。鎖必須先前被取得,但不一定是由同一個執行緒取得的。" -#: ../../library/_thread.rst:199 +#: ../../library/_thread.rst:202 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:202 +#: ../../library/_thread.rst:205 msgid "" -"In addition to these methods, lock objects can also be used via the :keyword:" -"`with` statement, e.g.::" +"In addition to these methods, lock objects can also be used via " +"the :keyword:`with` statement, e.g.::" msgstr "除了這些方法之外,鎖物件還可以透過 :keyword:`with` 語句來使用,例如:" -#: ../../library/_thread.rst:205 +#: ../../library/_thread.rst:208 msgid "" "import _thread\n" "\n" @@ -304,41 +311,30 @@ msgstr "" "with a_lock:\n" " print(\"a_lock 在執行這裡時被鎖定\")" -#: ../../library/_thread.rst:212 +#: ../../library/_thread.rst:215 msgid "**Caveats:**" msgstr "**注意事項:**" -#: ../../library/_thread.rst:216 +#: ../../library/_thread.rst:219 msgid "" "Interrupts always go to the main thread (the :exc:`KeyboardInterrupt` " "exception will be received by that thread.)" msgstr "中斷總會跳到主執行緒(該執行緒將接收 :exc:`KeyboardInterrupt` 例外。)" -#: ../../library/_thread.rst:219 +#: ../../library/_thread.rst:222 msgid "" "Calling :func:`sys.exit` or raising the :exc:`SystemExit` exception is " "equivalent to calling :func:`_thread.exit`." msgstr "" -"呼叫 :func:`sys.exit` 函式或引發 :exc:`SystemExit` 例外等同於呼叫 :func:" -"`_thread.exit` 函式。" +"呼叫 :func:`sys.exit` 函式或引發 :exc:`SystemExit` 例外等同於呼" +"叫 :func:`_thread.exit` 函式。" -#: ../../library/_thread.rst:222 -msgid "" -"It is platform-dependent whether the :meth:`~threading.Lock.acquire` method " -"on a lock can be interrupted (so that the :exc:`KeyboardInterrupt` exception " -"will happen immediately, rather than only after the lock has been acquired " -"or the operation has timed out). It can be interrupted on POSIX, but not on " -"Windows." -msgstr "" -"鎖的 :meth:`~threading.Lock.acquire` 方法是否可以中斷(如此一來 :exc:" -"`KeyboardInterrupt` 例外會立即發生,而不是僅在取得鎖或操作逾時後)是取決於平" -"台的。在 POSIX 上可以中斷,但在 Windows 上則不行。" - -#: ../../library/_thread.rst:228 +#: ../../library/_thread.rst:225 msgid "" "When the main thread exits, it is system defined whether the other threads " -"survive. On most systems, they are killed without executing :keyword:" -"`try` ... :keyword:`finally` clauses or executing object destructors." +"survive. On most systems, they are killed without " +"executing :keyword:`try` ... :keyword:`finally` clauses or executing object " +"destructors." msgstr "" "當主執行緒退出時,其他執行緒是否保留是由系統決定的。在大多數系統上,它們將被" "終止,而不會執行 :keyword:`try` ... :keyword:`finally` 子句或執行物件的解構函" @@ -372,10 +368,21 @@ msgstr "threads(執行緒)" msgid "POSIX" msgstr "POSIX" -#: ../../library/_thread.rst:214 +#: ../../library/_thread.rst:217 msgid "module" msgstr "module(模組)" -#: ../../library/_thread.rst:214 +#: ../../library/_thread.rst:217 msgid "signal" msgstr "signal(訊號)" + +#~ msgid "" +#~ "It is platform-dependent whether the :meth:`~threading.Lock.acquire` " +#~ "method on a lock can be interrupted (so that the :exc:`KeyboardInterrupt` " +#~ "exception will happen immediately, rather than only after the lock has " +#~ "been acquired or the operation has timed out). It can be interrupted on " +#~ "POSIX, but not on Windows." +#~ msgstr "" +#~ "鎖的 :meth:`~threading.Lock.acquire` 方法是否可以中斷(如此一" +#~ "來 :exc:`KeyboardInterrupt` 例外會立即發生,而不是僅在取得鎖或操作逾時後)" +#~ "是取決於平台的。在 POSIX 上可以中斷,但在 Windows 上則不行。" diff --git a/library/abc.po b/library/abc.po index 9a2d736b8dc..8d089e46861 100644 --- a/library/abc.po +++ b/library/abc.po @@ -1,5 +1,4 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -7,7 +6,7 @@ # Matt Wang , 2022 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2025-02-27 00:15+0000\n" "PO-Revision-Date: 2022-11-16 03:29+0800\n" diff --git a/library/aifc.po b/library/aifc.po index 2cfcb0d41fc..a9e6d774606 100644 --- a/library/aifc.po +++ b/library/aifc.po @@ -1,10 +1,10 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # #, fuzzy msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-11-18 00:15+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" diff --git a/library/allos.po b/library/allos.po index 59c9cddfde1..eb96940124c 100644 --- a/library/allos.po +++ b/library/allos.po @@ -1,11 +1,11 @@ -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Matt Wang , 2022 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2018-06-26 18:54+0800\n" "PO-Revision-Date: 2022-02-15 17:54+0800\n" diff --git a/library/annotationlib.po b/library/annotationlib.po new file mode 100644 index 00000000000..1ec686c8a7d --- /dev/null +++ b/library/annotationlib.po @@ -0,0 +1,1029 @@ +# 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.14\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-10-22 00:14+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/annotationlib.rst:2 +msgid ":mod:`!annotationlib` --- Functionality for introspecting annotations" +msgstr ":mod:`!annotationlib` --- 用於自我檢查註釋的功能" + +#: ../../library/annotationlib.rst:9 +msgid "**Source code:** :source:`Lib/annotationlib.py`" +msgstr "**原始碼:** :source:`Lib/annotationlib.py`" + +#: ../../library/annotationlib.rst:18 +msgid "" +"The :mod:`!annotationlib` module provides tools for introspecting :term:" +"`annotations ` on modules, classes, and functions." +msgstr "" + +#: ../../library/annotationlib.rst:21 +msgid "" +"Annotations are :ref:`lazily evaluated ` and often contain " +"forward references to objects that are not yet defined when the annotation " +"is created. This module provides a set of low-level tools that can be used " +"to retrieve annotations in a reliable way, even in the presence of forward " +"references and other edge cases." +msgstr "" + +#: ../../library/annotationlib.rst:26 +msgid "" +"This module supports retrieving annotations in three main formats (see :" +"class:`Format`), each of which works best for different use cases:" +msgstr "" + +#: ../../library/annotationlib.rst:29 +msgid "" +":attr:`~Format.VALUE` evaluates the annotations and returns their value. " +"This is most straightforward to work with, but it may raise errors, for " +"example if the annotations contain references to undefined names." +msgstr "" + +#: ../../library/annotationlib.rst:32 +msgid "" +":attr:`~Format.FORWARDREF` returns :class:`ForwardRef` objects for " +"annotations that cannot be resolved, allowing you to inspect the annotations " +"without evaluating them. This is useful when you need to work with " +"annotations that may contain unresolved forward references." +msgstr "" + +#: ../../library/annotationlib.rst:36 +msgid "" +":attr:`~Format.STRING` returns the annotations as a string, similar to how " +"it would appear in the source file. This is useful for documentation " +"generators that want to display annotations in a readable way." +msgstr "" + +#: ../../library/annotationlib.rst:40 +msgid "" +"The :func:`get_annotations` function is the main entry point for retrieving " +"annotations. Given a function, class, or module, it returns an annotations " +"dictionary in the requested format. This module also provides functionality " +"for working directly with the :term:`annotate function` that is used to " +"evaluate annotations, such as :func:`get_annotate_from_class_namespace` and :" +"func:`call_annotate_function`, as well as the :func:`call_evaluate_function` " +"function for working with :term:`evaluate functions `." +msgstr "" + +#: ../../library/annotationlib.rst:51 +msgid "" +"Most functionality in this module can execute arbitrary code; see :ref:`the " +"security section ` for more information." +msgstr "" + +#: ../../library/annotationlib.rst:56 +msgid "" +":pep:`649` proposed the current model for how annotations work in Python." +msgstr "" + +#: ../../library/annotationlib.rst:58 +msgid "" +":pep:`749` expanded on various aspects of :pep:`649` and introduced the :mod:" +"`!annotationlib` module." +msgstr "" + +#: ../../library/annotationlib.rst:61 +msgid "" +":ref:`annotations-howto` provides best practices for working with " +"annotations." +msgstr "" + +#: ../../library/annotationlib.rst:64 +msgid "" +":pypi:`typing-extensions` provides a backport of :func:`get_annotations` " +"that works on earlier versions of Python." +msgstr "" + +#: ../../library/annotationlib.rst:68 +msgid "Annotation semantics" +msgstr "" + +#: ../../library/annotationlib.rst:70 +msgid "" +"The way annotations are evaluated has changed over the history of Python 3, " +"and currently still depends on a :ref:`future import `. There have " +"been execution models for annotations:" +msgstr "" + +#: ../../library/annotationlib.rst:74 +msgid "" +"*Stock semantics* (default in Python 3.0 through 3.13; see :pep:`3107` and :" +"pep:`526`): Annotations are evaluated eagerly, as they are encountered in " +"the source code." +msgstr "" + +#: ../../library/annotationlib.rst:77 +msgid "" +"*Stringified annotations* (used with ``from __future__ import annotations`` " +"in Python 3.7 and newer; see :pep:`563`): Annotations are stored as strings " +"only." +msgstr "" + +#: ../../library/annotationlib.rst:80 +msgid "" +"*Deferred evaluation* (default in Python 3.14 and newer; see :pep:`649` and :" +"pep:`749`): Annotations are evaluated lazily, only when they are accessed." +msgstr "" + +#: ../../library/annotationlib.rst:83 +msgid "As an example, consider the following program::" +msgstr "" + +#: ../../library/annotationlib.rst:85 +msgid "" +"def func(a: Cls) -> None:\n" +" print(a)\n" +"\n" +"class Cls: pass\n" +"\n" +"print(func.__annotations__)" +msgstr "" +"def func(a: Cls) -> None:\n" +" print(a)\n" +"\n" +"class Cls: pass\n" +"\n" +"print(func.__annotations__)" + +#: ../../library/annotationlib.rst:92 +msgid "This will behave as follows:" +msgstr "這會有以下行為:" + +#: ../../library/annotationlib.rst:94 +msgid "" +"Under stock semantics (Python 3.13 and earlier), it will throw a :exc:" +"`NameError` at the line where ``func`` is defined, because ``Cls`` is an " +"undefined name at that point." +msgstr "" + +#: ../../library/annotationlib.rst:97 +msgid "" +"Under stringified annotations (if ``from __future__ import annotations`` is " +"used), it will print ``{'a': 'Cls', 'return': 'None'}``." +msgstr "" + +#: ../../library/annotationlib.rst:99 +msgid "" +"Under deferred evaluation (Python 3.14 and later), it will print ``{'a': " +", 'return': None}``." +msgstr "" + +#: ../../library/annotationlib.rst:102 +msgid "" +"Stock semantics were used when function annotations were first introduced in " +"Python 3.0 (by :pep:`3107`) because this was the simplest, most obvious way " +"to implement annotations. The same execution model was used when variable " +"annotations were introduced in Python 3.6 (by :pep:`526`). However, stock " +"semantics caused problems when using annotations as type hints, such as a " +"need to refer to names that are not yet defined when the annotation is " +"encountered. In addition, there were performance problems with executing " +"annotations at module import time. Therefore, in Python 3.7, :pep:`563` " +"introduced the ability to store annotations as strings using the ``from " +"__future__ import annotations`` syntax. The plan at the time was to " +"eventually make this behavior the default, but a problem appeared: " +"stringified annotations are more difficult to process for those who " +"introspect annotations at runtime. An alternative proposal, :pep:`649`, " +"introduced the third execution model, deferred evaluation, and was " +"implemented in Python 3.14. Stringified annotations are still used if ``from " +"__future__ import annotations`` is present, but this behavior will " +"eventually be removed." +msgstr "" + +#: ../../library/annotationlib.rst:121 +msgid "Classes" +msgstr "" + +#: ../../library/annotationlib.rst:125 +msgid "" +"An :class:`~enum.IntEnum` describing the formats in which annotations can be " +"returned. Members of the enum, or their equivalent integer values, can be " +"passed to :func:`get_annotations` and other functions in this module, as " +"well as to :attr:`~object.__annotate__` functions." +msgstr "" + +#: ../../library/annotationlib.rst:133 +msgid "Values are the result of evaluating the annotation expressions." +msgstr "" + +#: ../../library/annotationlib.rst:138 +msgid "" +"Special value used to signal that an annotate function is being evaluated in " +"a special environment with fake globals. When passed this value, annotate " +"functions should either return the same value as for the :attr:`Format." +"VALUE` format, or raise :exc:`NotImplementedError` to signal that they do " +"not support execution in this environment. This format is only used " +"internally and should not be passed to the functions in this module." +msgstr "" + +#: ../../library/annotationlib.rst:149 +msgid "" +"Values are real annotation values (as per :attr:`Format.VALUE` format) for " +"defined values, and :class:`ForwardRef` proxies for undefined values. Real " +"objects may contain references to :class:`ForwardRef` proxy objects." +msgstr "" + +#: ../../library/annotationlib.rst:157 +msgid "" +"Values are the text string of the annotation as it appears in the source " +"code, up to modifications including, but not restricted to, whitespace " +"normalizations and constant values optimizations." +msgstr "" + +#: ../../library/annotationlib.rst:161 +msgid "" +"The exact values of these strings may change in future versions of Python." +msgstr "" + +#: ../../library/annotationlib.rst:167 +msgid "A proxy object for forward references in annotations." +msgstr "" + +#: ../../library/annotationlib.rst:169 +msgid "" +"Instances of this class are returned when the :attr:`~Format.FORWARDREF` " +"format is used and annotations contain a name that cannot be resolved. This " +"can happen when a forward reference is used in an annotation, such as when a " +"class is referenced before it is defined." +msgstr "" + +#: ../../library/annotationlib.rst:176 +msgid "" +"A string containing the code that was evaluated to produce the :class:" +"`~ForwardRef`. The string may not be exactly equivalent to the original " +"source." +msgstr "" + +#: ../../library/annotationlib.rst:182 +msgid "Evaluate the forward reference, returning its value." +msgstr "" + +#: ../../library/annotationlib.rst:184 +msgid "" +"If the *format* argument is :attr:`~Format.VALUE` (the default), this method " +"may throw an exception, such as :exc:`NameError`, if the forward reference " +"refers to a name that cannot be resolved. The arguments to this method can " +"be used to provide bindings for names that would otherwise be undefined. If " +"the *format* argument is :attr:`~Format.FORWARDREF`, the method will never " +"throw an exception, but may return a :class:`~ForwardRef` instance. For " +"example, if the forward reference object contains the code " +"``list[undefined]``, where ``undefined`` is a name that is not defined, " +"evaluating it with the :attr:`~Format.FORWARDREF` format will return " +"``list[ForwardRef('undefined')]``. If the *format* argument is :attr:" +"`~Format.STRING`, the method will return :attr:`~ForwardRef.__forward_arg__`." +msgstr "" + +#: ../../library/annotationlib.rst:196 +msgid "" +"The *owner* parameter provides the preferred mechanism for passing scope " +"information to this method. The owner of a :class:`~ForwardRef` is the " +"object that contains the annotation from which the :class:`~ForwardRef` " +"derives, such as a module object, type object, or function object." +msgstr "" + +#: ../../library/annotationlib.rst:201 +msgid "" +"The *globals*, *locals*, and *type_params* parameters provide a more precise " +"mechanism for influencing the names that are available when the :class:" +"`~ForwardRef` is evaluated. *globals* and *locals* are passed to :func:" +"`eval`, representing the global and local namespaces in which the name is " +"evaluated. The *type_params* parameter is relevant for objects created using " +"the native syntax for :ref:`generic classes ` and :ref:" +"`functions `. It is a tuple of :ref:`type parameters " +"` that are in scope while the forward reference is being " +"evaluated. For example, if evaluating a :class:`~ForwardRef` retrieved from " +"an annotation found in the class namespace of a generic class ``C``, " +"*type_params* should be set to ``C.__type_params__``." +msgstr "" + +#: ../../library/annotationlib.rst:212 +msgid "" +":class:`~ForwardRef` instances returned by :func:`get_annotations` retain " +"references to information about the scope they originated from, so calling " +"this method with no further arguments may be sufficient to evaluate such " +"objects. :class:`~ForwardRef` instances created by other means may not have " +"any information about their scope, so passing arguments to this method may " +"be necessary to evaluate them successfully." +msgstr "" + +#: ../../library/annotationlib.rst:219 +msgid "" +"If no *owner*, *globals*, *locals*, or *type_params* are provided and the :" +"class:`~ForwardRef` does not contain information about its origin, empty " +"globals and locals dictionaries are used." +msgstr "" + +#: ../../library/annotationlib.rst:227 +msgid "Functions" +msgstr "" + +#: ../../library/annotationlib.rst:231 +msgid "" +"Convert an annotations dict containing runtime values to a dict containing " +"only strings. If the values are not already strings, they are converted " +"using :func:`type_repr`. This is meant as a helper for user-provided " +"annotate functions that support the :attr:`~Format.STRING` format but do not " +"have access to the code creating the annotations." +msgstr "" + +#: ../../library/annotationlib.rst:238 +msgid "" +"For example, this is used to implement the :attr:`~Format.STRING` for :class:" +"`typing.TypedDict` classes created through the functional syntax:" +msgstr "" + +#: ../../library/annotationlib.rst:241 +msgid "" +">>> from typing import TypedDict\n" +">>> Movie = TypedDict(\"movie\", {\"name\": str, \"year\": int})\n" +">>> get_annotations(Movie, format=Format.STRING)\n" +"{'name': 'str', 'year': 'int'}" +msgstr "" +">>> from typing import TypedDict\n" +">>> Movie = TypedDict(\"movie\", {\"name\": str, \"year\": int})\n" +">>> get_annotations(Movie, format=Format.STRING)\n" +"{'name': 'str', 'year': 'int'}" + +#: ../../library/annotationlib.rst:252 +msgid "" +"Call the :term:`annotate function` *annotate* with the given *format*, a " +"member of the :class:`Format` enum, and return the annotations dictionary " +"produced by the function." +msgstr "" + +#: ../../library/annotationlib.rst:256 +msgid "" +"This helper function is required because annotate functions generated by the " +"compiler for functions, classes, and modules only support the :attr:`~Format." +"VALUE` format when called directly. To support other formats, this function " +"calls the annotate function in a special environment that allows it to " +"produce annotations in the other formats. This is a useful building block " +"when implementing functionality that needs to partially evaluate annotations " +"while a class is being constructed." +msgstr "" + +#: ../../library/annotationlib.rst:265 +msgid "" +"*owner* is the object that owns the annotation function, usually a function, " +"class, or module. If provided, it is used in the :attr:`~Format.FORWARDREF` " +"format to produce a :class:`ForwardRef` object that carries more information." +msgstr "" + +#: ../../library/annotationlib.rst:272 +msgid "" +":PEP:`PEP 649 <649#the-stringizer-and-the-fake-globals-environment>` " +"contains an explanation of the implementation technique used by this " +"function." +msgstr "" + +#: ../../library/annotationlib.rst:280 +msgid "" +"Call the :term:`evaluate function` *evaluate* with the given *format*, a " +"member of the :class:`Format` enum, and return the value produced by the " +"function. This is similar to :func:`call_annotate_function`, but the latter " +"always returns a dictionary mapping strings to annotations, while this " +"function returns a single value." +msgstr "" + +#: ../../library/annotationlib.rst:286 +msgid "" +"This is intended for use with the evaluate functions generated for lazily " +"evaluated elements related to type aliases and type parameters:" +msgstr "" + +#: ../../library/annotationlib.rst:289 +msgid ":meth:`typing.TypeAliasType.evaluate_value`, the value of type aliases" +msgstr "" + +#: ../../library/annotationlib.rst:290 +msgid ":meth:`typing.TypeVar.evaluate_bound`, the bound of type variables" +msgstr "" + +#: ../../library/annotationlib.rst:291 +msgid "" +":meth:`typing.TypeVar.evaluate_constraints`, the constraints of type " +"variables" +msgstr "" + +#: ../../library/annotationlib.rst:293 +msgid "" +":meth:`typing.TypeVar.evaluate_default`, the default value of type variables" +msgstr "" + +#: ../../library/annotationlib.rst:295 +msgid "" +":meth:`typing.ParamSpec.evaluate_default`, the default value of parameter " +"specifications" +msgstr "" + +#: ../../library/annotationlib.rst:297 +msgid "" +":meth:`typing.TypeVarTuple.evaluate_default`, the default value of type " +"variable tuples" +msgstr "" + +#: ../../library/annotationlib.rst:300 +msgid "" +"*owner* is the object that owns the evaluate function, such as the type " +"alias or type variable object." +msgstr "" + +#: ../../library/annotationlib.rst:303 +msgid "" +"*format* can be used to control the format in which the value is returned:" +msgstr "" + +#: ../../library/annotationlib.rst:305 +msgid "" +">>> type Alias = undefined\n" +">>> call_evaluate_function(Alias.evaluate_value, Format.VALUE)\n" +"Traceback (most recent call last):\n" +"...\n" +"NameError: name 'undefined' is not defined\n" +">>> call_evaluate_function(Alias.evaluate_value, Format.FORWARDREF)\n" +"ForwardRef('undefined')\n" +">>> call_evaluate_function(Alias.evaluate_value, Format.STRING)\n" +"'undefined'" +msgstr "" + +#: ../../library/annotationlib.rst:321 +msgid "" +"Retrieve the :term:`annotate function` from a class namespace dictionary " +"*namespace*. Return :const:`!None` if the namespace does not contain an " +"annotate function. This is primarily useful before the class has been fully " +"created (e.g., in a metaclass); after the class exists, the annotate " +"function can be retrieved with ``cls.__annotate__``. See :ref:`below " +"` for an example using this function in a metaclass." +msgstr "" + +#: ../../library/annotationlib.rst:331 +msgid "Compute the annotations dict for an object." +msgstr "" + +#: ../../library/annotationlib.rst:333 +msgid "" +"*obj* may be a callable, class, module, or other object with :attr:`~object." +"__annotate__` or :attr:`~object.__annotations__` attributes. Passing any " +"other object raises :exc:`TypeError`." +msgstr "" + +#: ../../library/annotationlib.rst:337 +msgid "" +"The *format* parameter controls the format in which annotations are " +"returned, and must be a member of the :class:`Format` enum or its integer " +"equivalent. The different formats work as follows:" +msgstr "" + +#: ../../library/annotationlib.rst:341 +msgid "" +"VALUE: :attr:`!object.__annotations__` is tried first; if that does not " +"exist, the :attr:`!object.__annotate__` function is called if it exists." +msgstr "" + +#: ../../library/annotationlib.rst:344 +msgid "" +"FORWARDREF: If :attr:`!object.__annotations__` exists and can be evaluated " +"successfully, it is used; otherwise, the :attr:`!object.__annotate__` " +"function is called. If it does not exist either, :attr:`!object." +"__annotations__` is tried again and any error from accessing it is re-raised." +msgstr "" + +#: ../../library/annotationlib.rst:349 +msgid "" +"When calling :attr:`!object.__annotate__` it is first called with :attr:" +"`~Format.FORWARDREF`. If this is not implemented, it will then check if :" +"attr:`~Format.VALUE_WITH_FAKE_GLOBALS` is supported and use that in the fake " +"globals environment. If neither of these formats are supported, it will fall " +"back to using :attr:`~Format.VALUE`. If :attr:`~Format.VALUE` fails, the " +"error from this call will be raised." +msgstr "" + +#: ../../library/annotationlib.rst:355 +msgid "" +"STRING: If :attr:`!object.__annotate__` exists, it is called first; " +"otherwise, :attr:`!object.__annotations__` is used and stringified using :" +"func:`annotations_to_string`." +msgstr "" + +#: ../../library/annotationlib.rst:359 +msgid "" +"When calling :attr:`!object.__annotate__` it is first called with :attr:" +"`~Format.STRING`. If this is not implemented, it will then check if :attr:" +"`~Format.VALUE_WITH_FAKE_GLOBALS` is supported and use that in the fake " +"globals environment. If neither of these formats are supported, it will fall " +"back to using :attr:`~Format.VALUE` with the result converted using :func:" +"`annotations_to_string`. If :attr:`~Format.VALUE` fails, the error from this " +"call will be raised." +msgstr "" + +#: ../../library/annotationlib.rst:366 +msgid "" +"Returns a dict. :func:`!get_annotations` returns a new dict every time it's " +"called; calling it twice on the same object will return two different but " +"equivalent dicts." +msgstr "" + +#: ../../library/annotationlib.rst:370 +msgid "This function handles several details for you:" +msgstr "" + +#: ../../library/annotationlib.rst:372 +msgid "" +"If *eval_str* is true, values of type :class:`!str` will be un-stringized " +"using :func:`eval`. This is intended for use with stringized annotations " +"(``from __future__ import annotations``). It is an error to set *eval_str* " +"to true with formats other than :attr:`Format.VALUE`." +msgstr "" + +#: ../../library/annotationlib.rst:377 +msgid "" +"If *obj* doesn't have an annotations dict, returns an empty dict. (Functions " +"and methods always have an annotations dict; classes, modules, and other " +"types of callables may not.)" +msgstr "" + +#: ../../library/annotationlib.rst:381 +msgid "" +"Ignores inherited annotations on classes, as well as annotations on " +"metaclasses. If a class doesn't have its own annotations dict, returns an " +"empty dict." +msgstr "" + +#: ../../library/annotationlib.rst:384 +msgid "" +"All accesses to object members and dict values are done using ``getattr()`` " +"and ``dict.get()`` for safety." +msgstr "" + +#: ../../library/annotationlib.rst:387 +msgid "" +"*eval_str* controls whether or not values of type :class:`!str` are replaced " +"with the result of calling :func:`eval` on those values:" +msgstr "" + +#: ../../library/annotationlib.rst:390 +msgid "" +"If eval_str is true, :func:`eval` is called on values of type :class:`!str`. " +"(Note that :func:`!get_annotations` doesn't catch exceptions; if :func:" +"`eval` raises an exception, it will unwind the stack past the :func:`!" +"get_annotations` call.)" +msgstr "" + +#: ../../library/annotationlib.rst:394 +msgid "" +"If *eval_str* is false (the default), values of type :class:`!str` are " +"unchanged." +msgstr "" + +#: ../../library/annotationlib.rst:397 +msgid "" +"*globals* and *locals* are passed in to :func:`eval`; see the documentation " +"for :func:`eval` for more information. If *globals* or *locals* is :const:`!" +"None`, this function may replace that value with a context-specific default, " +"contingent on ``type(obj)``:" +msgstr "" + +#: ../../library/annotationlib.rst:402 +msgid "If *obj* is a module, *globals* defaults to ``obj.__dict__``." +msgstr "如果 *obj* 是模組,則 *globals* 預設為 ``obj.__dict__``。" + +#: ../../library/annotationlib.rst:403 +msgid "" +"If *obj* is a class, *globals* defaults to ``sys.modules[obj.__module__]." +"__dict__`` and *locals* defaults to the *obj* class namespace." +msgstr "" + +#: ../../library/annotationlib.rst:406 +msgid "" +"If *obj* is a callable, *globals* defaults to :attr:`obj.__globals__ " +"`, although if *obj* is a wrapped function (using :" +"func:`functools.update_wrapper`) or a :class:`functools.partial` object, it " +"is unwrapped until a non-wrapped function is found." +msgstr "" + +#: ../../library/annotationlib.rst:412 +msgid "" +"Calling :func:`!get_annotations` is best practice for accessing the " +"annotations dict of any object. See :ref:`annotations-howto` for more " +"information on annotations best practices." +msgstr "" + +#: ../../library/annotationlib.rst:416 +msgid "" +">>> def f(a: int, b: str) -> float:\n" +"... pass\n" +">>> get_annotations(f)\n" +"{'a': , 'b': , 'return': }" +msgstr "" +">>> def f(a: int, b: str) -> float:\n" +"... pass\n" +">>> get_annotations(f)\n" +"{'a': , 'b': , 'return': }" + +#: ../../library/annotationlib.rst:427 +msgid "" +"Convert an arbitrary Python value to a format suitable for use by the :attr:" +"`~Format.STRING` format. This calls :func:`repr` for most objects, but has " +"special handling for some objects, such as type objects." +msgstr "" + +#: ../../library/annotationlib.rst:431 +msgid "" +"This is meant as a helper for user-provided annotate functions that support " +"the :attr:`~Format.STRING` format but do not have access to the code " +"creating the annotations. It can also be used to provide a user-friendly " +"string representation for other objects that contain values that are " +"commonly encountered in annotations." +msgstr "" + +#: ../../library/annotationlib.rst:441 +msgid "Recipes" +msgstr "" + +#: ../../library/annotationlib.rst:446 +msgid "Using annotations in a metaclass" +msgstr "" + +#: ../../library/annotationlib.rst:448 +msgid "" +"A :ref:`metaclass ` may want to inspect or even modify the " +"annotations in a class body during class creation. Doing so requires " +"retrieving annotations from the class namespace dictionary. For classes " +"created with ``from __future__ import annotations``, the annotations will be " +"in the ``__annotations__`` key of the dictionary. For other classes with " +"annotations, :func:`get_annotate_from_class_namespace` can be used to get " +"the annotate function, and :func:`call_annotate_function` can be used to " +"call it and retrieve the annotations. Using the :attr:`~Format.FORWARDREF` " +"format will usually be best, because this allows the annotations to refer to " +"names that cannot yet be resolved when the class is created." +msgstr "" + +#: ../../library/annotationlib.rst:459 +msgid "" +"To modify the annotations, it is best to create a wrapper annotate function " +"that calls the original annotate function, makes any necessary adjustments, " +"and returns the result." +msgstr "" + +#: ../../library/annotationlib.rst:463 +msgid "" +"Below is an example of a metaclass that filters out all :class:`typing." +"ClassVar` annotations from the class and puts them in a separate attribute:" +msgstr "" + +#: ../../library/annotationlib.rst:466 +msgid "" +"import annotationlib\n" +"import typing\n" +"\n" +"class ClassVarSeparator(type):\n" +" def __new__(mcls, name, bases, ns):\n" +" if \"__annotations__\" in ns: # from __future__ import annotations\n" +" annotations = ns[\"__annotations__\"]\n" +" classvar_keys = {\n" +" key for key, value in annotations.items()\n" +" # Use string comparison for simplicity; a more robust solution\n" +" # could use annotationlib.ForwardRef.evaluate\n" +" if value.startswith(\"ClassVar\")\n" +" }\n" +" classvars = {key: annotations[key] for key in classvar_keys}\n" +" ns[\"__annotations__\"] = {\n" +" key: value for key, value in annotations.items()\n" +" if key not in classvar_keys\n" +" }\n" +" wrapped_annotate = None\n" +" elif annotate := annotationlib.get_annotate_from_class_namespace(ns):\n" +" annotations = annotationlib.call_annotate_function(\n" +" annotate, format=annotationlib.Format.FORWARDREF\n" +" )\n" +" classvar_keys = {\n" +" key for key, value in annotations.items()\n" +" if typing.get_origin(value) is typing.ClassVar\n" +" }\n" +" classvars = {key: annotations[key] for key in classvar_keys}\n" +"\n" +" def wrapped_annotate(format):\n" +" annos = annotationlib.call_annotate_function(annotate, format, " +"owner=typ)\n" +" return {key: value for key, value in annos.items() if key not in " +"classvar_keys}\n" +"\n" +" else: # no annotations\n" +" classvars = {}\n" +" wrapped_annotate = None\n" +" typ = super().__new__(mcls, name, bases, ns)\n" +"\n" +" if wrapped_annotate is not None:\n" +" # Wrap the original __annotate__ with a wrapper that removes " +"ClassVars\n" +" typ.__annotate__ = wrapped_annotate\n" +" typ.classvars = classvars # Store the ClassVars in a separate " +"attribute\n" +" return typ" +msgstr "" + +#: ../../library/annotationlib.rst:514 +msgid "Limitations of the ``STRING`` format" +msgstr "``STRING`` 格式的限制" + +#: ../../library/annotationlib.rst:516 +msgid "" +"The :attr:`~Format.STRING` format is meant to approximate the source code of " +"the annotation, but the implementation strategy used means that it is not " +"always possible to recover the exact source code." +msgstr "" + +#: ../../library/annotationlib.rst:520 +msgid "" +"First, the stringifier of course cannot recover any information that is not " +"present in the compiled code, including comments, whitespace, " +"parenthesization, and operations that get simplified by the compiler." +msgstr "" + +#: ../../library/annotationlib.rst:524 +msgid "" +"Second, the stringifier can intercept almost all operations that involve " +"names looked up in some scope, but it cannot intercept operations that " +"operate fully on constants. As a corollary, this also means it is not safe " +"to request the ``STRING`` format on untrusted code: Python is powerful " +"enough that it is possible to achieve arbitrary code execution even with no " +"access to any globals or builtins. For example:" +msgstr "" + +#: ../../library/annotationlib.rst:530 +msgid "" +">>> def f(x: (1).__class__.__base__.__subclasses__()[-1].__init__." +"__builtins__[\"print\"](\"Hello world\")): pass\n" +"...\n" +">>> annotationlib.get_annotations(f, format=annotationlib.Format.STRING)\n" +"Hello world\n" +"{'x': 'None'}" +msgstr "" +">>> def f(x: (1).__class__.__base__.__subclasses__()[-1].__init__." +"__builtins__[\"print\"](\"Hello world\")): pass\n" +"...\n" +">>> annotationlib.get_annotations(f, format=annotationlib.Format.STRING)\n" +"Hello world\n" +"{'x': 'None'}" + +#: ../../library/annotationlib.rst:539 +msgid "" +"This particular example works as of the time of writing, but it relies on " +"implementation details and is not guaranteed to work in the future." +msgstr "" + +#: ../../library/annotationlib.rst:542 +msgid "" +"Among the different kinds of expressions that exist in Python, as " +"represented by the :mod:`ast` module, some expressions are supported, " +"meaning that the ``STRING`` format can generally recover the original source " +"code; others are unsupported, meaning that they may result in incorrect " +"output or an error." +msgstr "" + +#: ../../library/annotationlib.rst:547 +msgid "The following are supported (sometimes with caveats):" +msgstr "" + +#: ../../library/annotationlib.rst:549 +msgid ":class:`ast.BinOp`" +msgstr ":class:`ast.BinOp`" + +#: ../../library/annotationlib.rst:550 +msgid ":class:`ast.UnaryOp`" +msgstr ":class:`ast.UnaryOp`" + +#: ../../library/annotationlib.rst:552 +msgid "" +":class:`ast.Invert` (``~``), :class:`ast.UAdd` (``+``), and :class:`ast." +"USub` (``-``) are supported" +msgstr "" +":class:`ast.Invert` (``~``)、:class:`ast.UAdd` (``+``) 和 :class:`ast.USub` (``-``) 有被支援" + +#: ../../library/annotationlib.rst:553 +msgid ":class:`ast.Not` (``not``) is not supported" +msgstr ":class:`ast.Not` (``not``) 並不被支援" + +#: ../../library/annotationlib.rst:555 +msgid ":class:`ast.Dict` (except when using ``**`` unpacking)" +msgstr ":class:`ast.Dict`\\ (除了使用 ``**`` 解包的情況)" + +#: ../../library/annotationlib.rst:556 +msgid ":class:`ast.Set`" +msgstr ":class:`ast.Set`" + +#: ../../library/annotationlib.rst:557 +msgid ":class:`ast.Compare`" +msgstr ":class:`ast.Compare`" + +#: ../../library/annotationlib.rst:559 +msgid ":class:`ast.Eq` and :class:`ast.NotEq` are supported" +msgstr ":class:`ast.Eq` 和 :class:`ast.NotEq` 有被支援" + +#: ../../library/annotationlib.rst:560 +msgid "" +":class:`ast.Lt`, :class:`ast.LtE`, :class:`ast.Gt`, and :class:`ast.GtE` are " +"supported, but the operand may be flipped" +msgstr "" + +#: ../../library/annotationlib.rst:561 +msgid "" +":class:`ast.Is`, :class:`ast.IsNot`, :class:`ast.In`, and :class:`ast.NotIn` " +"are not supported" +msgstr "" + +#: ../../library/annotationlib.rst:563 +msgid ":class:`ast.Call` (except when using ``**`` unpacking)" +msgstr "" + +#: ../../library/annotationlib.rst:564 +msgid "" +":class:`ast.Constant` (though not the exact representation of the constant; " +"for example, escape sequences in strings are lost; hexadecimal numbers are " +"converted to decimal)" +msgstr "" + +#: ../../library/annotationlib.rst:566 +msgid ":class:`ast.Attribute` (assuming the value is not a constant)" +msgstr "" + +#: ../../library/annotationlib.rst:567 +msgid ":class:`ast.Subscript` (assuming the value is not a constant)" +msgstr "" + +#: ../../library/annotationlib.rst:568 +msgid ":class:`ast.Starred` (``*`` unpacking)" +msgstr "" + +#: ../../library/annotationlib.rst:569 +msgid ":class:`ast.Name`" +msgstr ":class:`ast.Name`" + +#: ../../library/annotationlib.rst:570 +msgid ":class:`ast.List`" +msgstr ":class:`ast.List`" + +#: ../../library/annotationlib.rst:571 +msgid ":class:`ast.Tuple`" +msgstr ":class:`ast.Tuple`" + +#: ../../library/annotationlib.rst:572 +msgid ":class:`ast.Slice`" +msgstr ":class:`ast.Slice`" + +#: ../../library/annotationlib.rst:574 +msgid "" +"The following are unsupported, but throw an informative error when " +"encountered by the stringifier:" +msgstr "" + +#: ../../library/annotationlib.rst:577 +msgid "" +":class:`ast.FormattedValue` (f-strings; error is not detected if conversion " +"specifiers like ``!r`` are used)" +msgstr "" + +#: ../../library/annotationlib.rst:579 +msgid ":class:`ast.JoinedStr` (f-strings)" +msgstr ":class:`ast.JoinedStr`\\ (f 字串)" + +#: ../../library/annotationlib.rst:581 +msgid "The following are unsupported and result in incorrect output:" +msgstr "以下是不支援的,並且會導致不正確的輸出:" + +#: ../../library/annotationlib.rst:583 +msgid ":class:`ast.BoolOp` (``and`` and ``or``)" +msgstr ":class:`ast.BoolOp`\\ (``and`` 和 ``or``)" + +#: ../../library/annotationlib.rst:584 +msgid ":class:`ast.IfExp`" +msgstr ":class:`ast.IfExp`" + +#: ../../library/annotationlib.rst:585 +msgid ":class:`ast.Lambda`" +msgstr ":class:`ast.Lambda`" + +#: ../../library/annotationlib.rst:586 +msgid ":class:`ast.ListComp`" +msgstr ":class:`ast.ListComp`" + +#: ../../library/annotationlib.rst:587 +msgid ":class:`ast.SetComp`" +msgstr ":class:`ast.SetComp`" + +#: ../../library/annotationlib.rst:588 +msgid ":class:`ast.DictComp`" +msgstr ":class:`ast.DictComp`" + +#: ../../library/annotationlib.rst:589 +msgid ":class:`ast.GeneratorExp`" +msgstr ":class:`ast.GeneratorExp`" + +#: ../../library/annotationlib.rst:591 +msgid "" +"The following are disallowed in annotation scopes and therefore not relevant:" +msgstr "" + +#: ../../library/annotationlib.rst:593 +msgid ":class:`ast.NamedExpr` (``:=``)" +msgstr ":class:`ast.NamedExpr` (``:=``)" + +#: ../../library/annotationlib.rst:594 +msgid ":class:`ast.Await`" +msgstr ":class:`ast.Await`" + +#: ../../library/annotationlib.rst:595 +msgid ":class:`ast.Yield`" +msgstr ":class:`ast.Yield`" + +#: ../../library/annotationlib.rst:596 +msgid ":class:`ast.YieldFrom`" +msgstr ":class:`ast.YieldFrom`" + +#: ../../library/annotationlib.rst:600 +msgid "Limitations of the ``FORWARDREF`` format" +msgstr "``FORWARDREF`` 格式的限制" + +#: ../../library/annotationlib.rst:602 +msgid "" +"The :attr:`~Format.FORWARDREF` format aims to produce real values as much as " +"possible, with anything that cannot be resolved replaced with :class:" +"`ForwardRef` objects. It is affected by broadly the same Limitations as the :" +"attr:`~Format.STRING` format: annotations that perform operations on " +"literals or that use unsupported expression types may raise exceptions when " +"evaluated using the :attr:`~Format.FORWARDREF` format." +msgstr "" + +#: ../../library/annotationlib.rst:609 +msgid "Below are a few examples of the behavior with unsupported expressions:" +msgstr "" + +#: ../../library/annotationlib.rst:611 +msgid "" +">>> from annotationlib import get_annotations, Format\n" +">>> def zerodiv(x: 1 / 0): ...\n" +">>> get_annotations(zerodiv, format=Format.STRING)\n" +"Traceback (most recent call last):\n" +" ...\n" +"ZeroDivisionError: division by zero\n" +">>> get_annotations(zerodiv, format=Format.FORWARDREF)\n" +"Traceback (most recent call last):\n" +" ...\n" +"ZeroDivisionError: division by zero\n" +">>> def ifexp(x: 1 if y else 0): ...\n" +">>> get_annotations(ifexp, format=Format.STRING)\n" +"{'x': '1'}" +msgstr "" +">>> from annotationlib import get_annotations, Format\n" +">>> def zerodiv(x: 1 / 0): ...\n" +">>> get_annotations(zerodiv, format=Format.STRING)\n" +"Traceback (most recent call last):\n" +" ...\n" +"ZeroDivisionError: division by zero\n" +">>> get_annotations(zerodiv, format=Format.FORWARDREF)\n" +"Traceback (most recent call last):\n" +" ...\n" +"ZeroDivisionError: division by zero\n" +">>> def ifexp(x: 1 if y else 0): ...\n" +">>> get_annotations(ifexp, format=Format.STRING)\n" +"{'x': '1'}" + +#: ../../library/annotationlib.rst:630 +msgid "Security implications of introspecting annotations" +msgstr "" + +#: ../../library/annotationlib.rst:632 +msgid "" +"Much of the functionality in this module involves executing code related to " +"annotations, which can then do arbitrary things. For example, :func:" +"`get_annotations` may call an arbitrary :term:`annotate function`, and :meth:" +"`ForwardRef.evaluate` may call :func:`eval` on an arbitrary string. Code " +"contained in an annotation might make arbitrary system calls, enter an " +"infinite loop, or perform any other operation. This is also true for any " +"access of the :attr:`~object.__annotations__` attribute, and for various " +"functions in the :mod:`typing` module that work with annotations, such as :" +"func:`typing.get_type_hints`." +msgstr "" + +#: ../../library/annotationlib.rst:641 +msgid "" +"Any security issue arising from this also applies immediately after " +"importing code that may contain untrusted annotations: importing code can " +"always cause arbitrary operations to be performed. However, it is unsafe to " +"accept strings or other input from an untrusted source and pass them to any " +"of the APIs for introspecting annotations, for example by editing an " +"``__annotations__`` dictionary or directly creating a :class:`ForwardRef` " +"object." +msgstr "" diff --git a/library/archiving.po b/library/archiving.po index c42e38f29a4..2051ce20cc8 100644 --- a/library/archiving.po +++ b/library/archiving.po @@ -1,14 +1,13 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Leon H., 2017 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-06-26 18:54+0800\n" +"POT-Creation-Date: 2025-09-08 15:25+0800\n" "PO-Revision-Date: 2023-02-18 14:22+0800\n" "Last-Translator: Leon H.\n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -27,10 +26,10 @@ msgstr "資料壓縮與保存" #: ../../library/archiving.rst:7 msgid "" "The modules described in this chapter support data compression with the " -"zlib, gzip, bzip2 and lzma algorithms, and the creation of ZIP- and tar-" -"format archives. See also :ref:`archiving-operations` provided by the :mod:" -"`shutil` module." +"zlib, gzip, bzip2, lzma, and zstd algorithms, and the creation of ZIP- and " +"tar-format archives. See also :ref:`archiving-operations` provided by " +"the :mod:`shutil` module." msgstr "" -"本章中描述的模組支援使用 zlib、gzip、bzip2 和 lzma 演算法進行資料壓縮,以及建" -"立 ZIP 和 tar 格式的存檔。另請參閱 :mod:`shutil` 模組提供的 :ref:`archiving-" +"本章中描述的模組支援使用 zlib、gzip、bzip2、lzma 和 zstd 演算法進行資料壓縮,以及" +"建立 ZIP 和 tar 格式的存檔。另請參閱 :mod:`shutil` 模組提供的 :ref:`archiving-" "operations`。" diff --git a/library/argparse.po b/library/argparse.po index 7c9a382be06..7e5b91a125d 100644 --- a/library/argparse.po +++ b/library/argparse.po @@ -1,12 +1,12 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-07-20 00:19+0000\n" +"POT-Creation-Date: 2025-12-01 00:17+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-" @@ -40,7 +40,7 @@ msgid "" "another defined option)." msgstr "" -#: ../../library/argparse.rst:-1 +#: ../../library/argparse.rst:28 msgid "Tutorial" msgstr "教學" @@ -125,131 +125,147 @@ msgstr "" msgid "ArgumentParser objects" msgstr "ArgumentParser 物件" -#: ../../library/argparse.rst:78 +#: ../../library/argparse.rst:79 msgid "" "Create a new :class:`ArgumentParser` object. All parameters should be passed " "as keyword arguments. Each parameter has its own more detailed description " "below, but in short they are:" msgstr "" -#: ../../library/argparse.rst:82 +#: ../../library/argparse.rst:83 msgid "" -"prog_ - The name of the program (default: ``os.path.basename(sys.argv[0])``)" -msgstr "prog_ - 程式的名稱(預設值:``os.path.basename(sys.argv[0])``)" +"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:85 +#: ../../library/argparse.rst:86 msgid "" "usage_ - The string describing the program usage (default: generated from " "arguments added to parser)" msgstr "usage_ - 描述程式用法的字串(預設值:從新增到剖析器的引數產生)" -#: ../../library/argparse.rst:88 +#: ../../library/argparse.rst:89 msgid "" "description_ - Text to display before the argument help (by default, no text)" msgstr "description_ - 引數說明之前要顯示的文字(預設值:無文字)" -#: ../../library/argparse.rst:91 +#: ../../library/argparse.rst:92 msgid "epilog_ - Text to display after the argument help (by default, no text)" msgstr "epilog_ - 引數說明之後要顯示的文字(預設值:無文字)" -#: ../../library/argparse.rst:93 +#: ../../library/argparse.rst:94 msgid "" "parents_ - A list of :class:`ArgumentParser` objects whose arguments should " "also be included" msgstr "parents_ - 一個 :class:`ArgumentParser` 物件的串列,其引數也應該被包含" -#: ../../library/argparse.rst:96 +#: ../../library/argparse.rst:97 msgid "formatter_class_ - A class for customizing the help output" msgstr "formatter_class_ - 用於自訂說明輸出的類別" -#: ../../library/argparse.rst:98 +#: ../../library/argparse.rst:99 msgid "" "prefix_chars_ - The set of characters that prefix optional arguments " "(default: '-')" msgstr "prefix_chars_ - 前綴可選引數的字元集合(預設值:'-')" -#: ../../library/argparse.rst:101 +#: ../../library/argparse.rst:102 msgid "" "fromfile_prefix_chars_ - The set of characters that prefix files from which " "additional arguments should be read (default: ``None``)" msgstr "" -#: ../../library/argparse.rst:104 +#: ../../library/argparse.rst:105 msgid "" "argument_default_ - The global default value for arguments (default: " "``None``)" msgstr "" -#: ../../library/argparse.rst:107 +#: ../../library/argparse.rst:108 msgid "" "conflict_handler_ - The strategy for resolving conflicting optionals " "(usually unnecessary)" msgstr "" -#: ../../library/argparse.rst:110 +#: ../../library/argparse.rst:111 msgid "" "add_help_ - Add a ``-h/--help`` option to the parser (default: ``True``)" msgstr "" -#: ../../library/argparse.rst:112 +#: ../../library/argparse.rst:113 msgid "" "allow_abbrev_ - Allows long options to be abbreviated if the abbreviation is " -"unambiguous. (default: ``True``)" +"unambiguous (default: ``True``)" msgstr "" -#: ../../library/argparse.rst:115 +#: ../../library/argparse.rst:116 msgid "" "exit_on_error_ - Determines whether or not :class:`!ArgumentParser` exits " "with error info when an error occurs. (default: ``True``)" msgstr "" -#: ../../library/argparse.rst:118 +#: ../../library/argparse.rst:119 +msgid "" +"suggest_on_error_ - Enables suggestions for mistyped argument choices and " +"subparser names (default: ``False``)" +msgstr "" + +#: ../../library/argparse.rst:122 +msgid "color_ - Allow color output (default: ``True``)" +msgstr "" + +#: ../../library/argparse.rst:124 msgid "*allow_abbrev* parameter was added." msgstr "新增 *allow_abbrev* 參數。" -#: ../../library/argparse.rst:121 +#: ../../library/argparse.rst:127 msgid "" "In previous versions, *allow_abbrev* also disabled grouping of short flags " "such as ``-vv`` to mean ``-v -v``." msgstr "" -#: ../../library/argparse.rst:125 +#: ../../library/argparse.rst:131 msgid "*exit_on_error* parameter was added." msgstr "新增 *exit_on_error* 參數。" -#: ../../library/argparse.rst:128 ../../library/argparse.rst:616 +#: ../../library/argparse.rst:134 +msgid "*suggest_on_error* and *color* parameters were added." +msgstr "新增 *suggest_on_error* 和 *color* 參數。" + +#: ../../library/argparse.rst:137 ../../library/argparse.rst:689 msgid "The following sections describe how each of these are used." msgstr "" -#: ../../library/argparse.rst:134 +#: ../../library/argparse.rst:143 msgid "prog" msgstr "prog" -#: ../../library/argparse.rst:137 +#: ../../library/argparse.rst:146 msgid "" "By default, :class:`ArgumentParser` calculates the name of the program to " "display in help messages depending on the way the Python interpreter was run:" msgstr "" -#: ../../library/argparse.rst:140 +#: ../../library/argparse.rst:149 msgid "" "The :func:`base name ` of ``sys.argv[0]`` if a file was " "passed as argument." msgstr "" -#: ../../library/argparse.rst:142 +#: ../../library/argparse.rst:151 msgid "" "The Python interpreter name followed by ``sys.argv[0]`` if a directory or a " "zipfile was passed as argument." msgstr "" -#: ../../library/argparse.rst:144 +#: ../../library/argparse.rst:153 msgid "" "The Python interpreter name followed by ``-m`` followed by the module or " "package name if the :option:`-m` option was used." msgstr "" -#: ../../library/argparse.rst:147 +#: ../../library/argparse.rst:156 msgid "" "This default is almost always desirable because it will make the help " "messages match the string that was used to invoke the program on the command " @@ -257,7 +273,7 @@ msgid "" "supplied using the ``prog=`` argument to :class:`ArgumentParser`::" msgstr "" -#: ../../library/argparse.rst:152 +#: ../../library/argparse.rst:161 msgid "" ">>> parser = argparse.ArgumentParser(prog='myprogram')\n" ">>> parser.print_help()\n" @@ -273,14 +289,14 @@ msgstr "" "options:\n" " -h, --help show this help message and exit" -#: ../../library/argparse.rst:159 +#: ../../library/argparse.rst:168 msgid "" -"Note that the program name, whether determined from ``sys.argv[0]`` or from " -"the ``prog=`` argument, is available to help messages using the ``%(prog)s`` " -"format specifier." +"Note that the program name, whether determined from ``sys.argv[0]``, from " +"the ``__main__`` module attributes or from the ``prog=`` argument, is " +"available to help messages using the ``%(prog)s`` format specifier." msgstr "" -#: ../../library/argparse.rst:165 +#: ../../library/argparse.rst:175 msgid "" ">>> parser = argparse.ArgumentParser(prog='myprogram')\n" ">>> parser.add_argument('--foo', help='foo of the %(prog)s program')\n" @@ -300,18 +316,24 @@ msgstr "" " -h, --help show this help message and exit\n" " --foo FOO foo of the myprogram program" -#: ../../library/argparse.rst:176 +#: ../../library/argparse.rst:184 +msgid "" +"The default ``prog`` value now reflects how ``__main__`` was actually " +"executed, rather than always being ``os.path.basename(sys.argv[0])``." +msgstr "" + +#: ../../library/argparse.rst:189 msgid "usage" msgstr "usage" -#: ../../library/argparse.rst:178 +#: ../../library/argparse.rst:191 msgid "" "By default, :class:`ArgumentParser` calculates the usage message from the " "arguments it contains. The default message can be overridden with the " "``usage=`` keyword argument::" msgstr "" -#: ../../library/argparse.rst:182 +#: ../../library/argparse.rst:195 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', usage='%(prog)s " "[options]')\n" @@ -341,17 +363,26 @@ msgstr "" " -h, --help show this help message and exit\n" " --foo [FOO] foo help" -#: ../../library/argparse.rst:195 +#: ../../library/argparse.rst:208 msgid "" "The ``%(prog)s`` format specifier is available to fill in the program name " "in your usage messages." msgstr "" -#: ../../library/argparse.rst:202 +#: ../../library/argparse.rst:211 +msgid "" +"When a custom usage message is specified for the main parser, you may also " +"want to consider passing the ``prog`` argument to :meth:`~ArgumentParser." +"add_subparsers` or the ``prog`` and the ``usage`` arguments to :meth:" +"`~_SubParsersAction.add_parser`, to ensure consistent command prefixes and " +"usage information across subparsers." +msgstr "" + +#: ../../library/argparse.rst:221 msgid "description" msgstr "description" -#: ../../library/argparse.rst:204 +#: ../../library/argparse.rst:223 msgid "" "Most calls to the :class:`ArgumentParser` constructor will use the " "``description=`` keyword argument. This argument gives a brief description " @@ -360,24 +391,24 @@ msgid "" "messages for the various arguments." msgstr "" -#: ../../library/argparse.rst:210 +#: ../../library/argparse.rst:229 msgid "" "By default, the description will be line-wrapped so that it fits within the " "given space. To change this behavior, see the formatter_class_ argument." msgstr "" -#: ../../library/argparse.rst:215 +#: ../../library/argparse.rst:234 msgid "epilog" msgstr "epilog" -#: ../../library/argparse.rst:217 +#: ../../library/argparse.rst:236 msgid "" "Some programs like to display additional description of the program after " "the description of the arguments. Such text can be specified using the " "``epilog=`` argument to :class:`ArgumentParser`::" msgstr "" -#: ../../library/argparse.rst:221 +#: ../../library/argparse.rst:240 msgid "" ">>> parser = argparse.ArgumentParser(\n" "... description='A foo that bars',\n" @@ -405,18 +436,18 @@ msgstr "" "\n" "And that's how you'd foo a bar" -#: ../../library/argparse.rst:234 +#: ../../library/argparse.rst:253 msgid "" "As with the description_ argument, the ``epilog=`` text is by default line-" "wrapped, but this behavior can be adjusted with the formatter_class_ " "argument to :class:`ArgumentParser`." msgstr "" -#: ../../library/argparse.rst:240 +#: ../../library/argparse.rst:259 msgid "parents" msgstr "parents" -#: ../../library/argparse.rst:242 +#: ../../library/argparse.rst:261 msgid "" "Sometimes, several parsers share a common set of arguments. Rather than " "repeating the definitions of these arguments, a single parser with all the " @@ -427,7 +458,7 @@ msgid "" "object being constructed::" msgstr "" -#: ../../library/argparse.rst:249 +#: ../../library/argparse.rst:268 msgid "" ">>> parent_parser = argparse.ArgumentParser(add_help=False)\n" ">>> parent_parser.add_argument('--parent', type=int)\n" @@ -455,32 +486,32 @@ msgstr "" ">>> bar_parser.parse_args(['--bar', 'YYY'])\n" "Namespace(bar='YYY', parent=None)" -#: ../../library/argparse.rst:262 +#: ../../library/argparse.rst:281 msgid "" "Note that most parent parsers will specify ``add_help=False``. Otherwise, " "the :class:`ArgumentParser` will see two ``-h/--help`` options (one in the " "parent and one in the child) and raise an error." msgstr "" -#: ../../library/argparse.rst:267 +#: ../../library/argparse.rst:286 msgid "" "You must fully initialize the parsers before passing them via ``parents=``. " "If you change the parent parsers after the child parser, those changes will " "not be reflected in the child." msgstr "" -#: ../../library/argparse.rst:275 +#: ../../library/argparse.rst:294 msgid "formatter_class" msgstr "formatter_class" -#: ../../library/argparse.rst:277 +#: ../../library/argparse.rst:296 msgid "" ":class:`ArgumentParser` objects allow the help formatting to be customized " "by specifying an alternate formatting class. Currently, there are four such " "classes:" msgstr "" -#: ../../library/argparse.rst:286 +#: ../../library/argparse.rst:305 msgid "" ":class:`RawDescriptionHelpFormatter` and :class:`RawTextHelpFormatter` give " "more control over how textual descriptions are displayed. By default, :class:" @@ -488,7 +519,7 @@ msgid "" "command-line help messages::" msgstr "" -#: ../../library/argparse.rst:291 +#: ../../library/argparse.rst:310 msgid "" ">>> parser = argparse.ArgumentParser(\n" "... prog='PROG',\n" @@ -511,15 +542,35 @@ msgid "" "words\n" "will be wrapped across a couple lines" msgstr "" +">>> parser = argparse.ArgumentParser(\n" +"... prog='PROG',\n" +"... description='''this description\n" +"... was indented weird\n" +"... but that is okay''',\n" +"... epilog='''\n" +"... likewise for this epilog whose whitespace will\n" +"... be cleaned up and whose words will be wrapped\n" +"... across a couple lines''')\n" +">>> parser.print_help()\n" +"usage: PROG [-h]\n" +"\n" +"this description was indented weird but that is okay\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +"\n" +"likewise for this epilog whose whitespace will be cleaned up and whose " +"words\n" +"will be wrapped across a couple lines" -#: ../../library/argparse.rst:311 +#: ../../library/argparse.rst:330 msgid "" "Passing :class:`RawDescriptionHelpFormatter` as ``formatter_class=`` " "indicates that description_ and epilog_ are already correctly formatted and " "should not be line-wrapped::" msgstr "" -#: ../../library/argparse.rst:315 +#: ../../library/argparse.rst:334 msgid "" ">>> parser = argparse.ArgumentParser(\n" "... prog='PROG',\n" @@ -565,7 +616,7 @@ msgstr "" "options:\n" " -h, --help show this help message and exit" -#: ../../library/argparse.rst:337 +#: ../../library/argparse.rst:356 msgid "" ":class:`RawTextHelpFormatter` maintains whitespace for all sorts of help " "text, including argument descriptions. However, multiple newlines are " @@ -573,13 +624,13 @@ msgid "" "between the newlines." msgstr "" -#: ../../library/argparse.rst:342 +#: ../../library/argparse.rst:361 msgid "" ":class:`ArgumentDefaultsHelpFormatter` automatically adds information about " "default values to each of the argument help messages::" msgstr "" -#: ../../library/argparse.rst:345 +#: ../../library/argparse.rst:364 msgid "" ">>> parser = argparse.ArgumentParser(\n" "... prog='PROG',\n" @@ -611,14 +662,14 @@ msgstr "" " -h, --help show this help message and exit\n" " --foo FOO FOO! (default: 42)" -#: ../../library/argparse.rst:360 +#: ../../library/argparse.rst:379 msgid "" ":class:`MetavarTypeHelpFormatter` uses the name of the type_ argument for " "each argument as the display name for its values (rather than using the " "dest_ as the regular formatter does)::" msgstr "" -#: ../../library/argparse.rst:364 +#: ../../library/argparse.rst:383 msgid "" ">>> parser = argparse.ArgumentParser(\n" "... prog='PROG',\n" @@ -650,11 +701,11 @@ msgstr "" " -h, --help show this help message and exit\n" " --foo int" -#: ../../library/argparse.rst:381 +#: ../../library/argparse.rst:400 msgid "prefix_chars" msgstr "prefix_chars" -#: ../../library/argparse.rst:383 +#: ../../library/argparse.rst:402 msgid "" "Most command-line options will use ``-`` as the prefix, e.g. ``-f/--foo``. " "Parsers that need to support different or additional prefix characters, e.g. " @@ -662,7 +713,7 @@ msgid "" "``prefix_chars=`` argument to the :class:`ArgumentParser` constructor::" msgstr "" -#: ../../library/argparse.rst:389 +#: ../../library/argparse.rst:408 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', prefix_chars='-+')\n" ">>> parser.add_argument('+f')\n" @@ -676,18 +727,18 @@ msgstr "" ">>> parser.parse_args('+f X ++bar Y'.split())\n" "Namespace(bar='Y', f='X')" -#: ../../library/argparse.rst:395 +#: ../../library/argparse.rst:414 msgid "" "The ``prefix_chars=`` argument defaults to ``'-'``. Supplying a set of " "characters that does not include ``-`` will cause ``-f/--foo`` options to be " "disallowed." msgstr "" -#: ../../library/argparse.rst:401 +#: ../../library/argparse.rst:420 msgid "fromfile_prefix_chars" msgstr "fromfile_prefix_chars" -#: ../../library/argparse.rst:403 +#: ../../library/argparse.rst:422 msgid "" "Sometimes, when dealing with a particularly long argument list, it may make " "sense to keep the list of arguments in a file rather than typing it out at " @@ -697,7 +748,7 @@ msgid "" "by the arguments they contain. For example::" msgstr "" -#: ../../library/argparse.rst:410 +#: ../../library/argparse.rst:429 msgid "" ">>> with open('args.txt', 'w', encoding=sys.getfilesystemencoding()) as fp:\n" "... fp.write('-f\\nbar')\n" @@ -715,7 +766,7 @@ msgstr "" ">>> parser.parse_args(['-f', 'foo', '@args.txt'])\n" "Namespace(f='bar')" -#: ../../library/argparse.rst:418 +#: ../../library/argparse.rst:437 msgid "" "Arguments read from a file must be one per line by default (but see also :" "meth:`~ArgumentParser.convert_arg_line_to_args`) and are treated as if they " @@ -725,26 +776,26 @@ msgid "" "f', 'bar']``." msgstr "" -#: ../../library/argparse.rst:426 +#: ../../library/argparse.rst:445 msgid "" "Empty lines are treated as empty strings (``''``), which are allowed as " "values but not as arguments. Empty lines that are read as arguments will " "result in an \"unrecognized arguments\" error." msgstr "" -#: ../../library/argparse.rst:430 +#: ../../library/argparse.rst:449 msgid "" ":class:`ArgumentParser` uses :term:`filesystem encoding and error handler` " "to read the file containing arguments." msgstr "" -#: ../../library/argparse.rst:433 +#: ../../library/argparse.rst:452 msgid "" "The ``fromfile_prefix_chars=`` argument defaults to ``None``, meaning that " "arguments will never be treated as file references." msgstr "" -#: ../../library/argparse.rst:436 +#: ../../library/argparse.rst:455 msgid "" ":class:`ArgumentParser` changed encoding and errors to read arguments files " "from default (e.g. :func:`locale.getpreferredencoding(False) >> parser = argparse.ArgumentParser(argument_default=argparse.SUPPRESS)\n" ">>> parser.add_argument('--foo')\n" @@ -787,22 +838,22 @@ msgstr "" ">>> parser.parse_args([])\n" "Namespace()" -#: ../../library/argparse.rst:466 +#: ../../library/argparse.rst:485 msgid "allow_abbrev" msgstr "allow_abbrev" -#: ../../library/argparse.rst:468 +#: ../../library/argparse.rst:487 msgid "" "Normally, when you pass an argument list to the :meth:`~ArgumentParser." "parse_args` method of an :class:`ArgumentParser`, it :ref:`recognizes " "abbreviations ` of long options." msgstr "" -#: ../../library/argparse.rst:472 +#: ../../library/argparse.rst:491 msgid "This feature can be disabled by setting ``allow_abbrev`` to ``False``::" msgstr "" -#: ../../library/argparse.rst:474 +#: ../../library/argparse.rst:493 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', allow_abbrev=False)\n" ">>> parser.add_argument('--foobar', action='store_true')\n" @@ -818,11 +869,11 @@ msgstr "" "usage: PROG [-h] [--foobar] [--foonley]\n" "PROG: error: unrecognized arguments: --foon" -#: ../../library/argparse.rst:485 +#: ../../library/argparse.rst:504 msgid "conflict_handler" msgstr "conflict_handler" -#: ../../library/argparse.rst:487 +#: ../../library/argparse.rst:506 msgid "" ":class:`ArgumentParser` objects do not allow two actions with the same " "option string. By default, :class:`ArgumentParser` objects raise an " @@ -830,7 +881,7 @@ msgid "" "that is already in use::" msgstr "" -#: ../../library/argparse.rst:492 +#: ../../library/argparse.rst:511 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-f', '--foo', help='old foo help')\n" @@ -846,7 +897,7 @@ msgstr "" " ..\n" "ArgumentError: argument --foo: conflicting option string(s): --foo" -#: ../../library/argparse.rst:499 +#: ../../library/argparse.rst:518 msgid "" "Sometimes (e.g. when using parents_) it may be useful to simply override any " "older arguments with the same option string. To get this behavior, the " @@ -854,7 +905,7 @@ msgid "" "of :class:`ArgumentParser`::" msgstr "" -#: ../../library/argparse.rst:504 +#: ../../library/argparse.rst:523 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', " "conflict_handler='resolve')\n" @@ -880,7 +931,7 @@ msgstr "" " -f FOO old foo help\n" " --foo FOO new foo help" -#: ../../library/argparse.rst:515 +#: ../../library/argparse.rst:534 msgid "" "Note that :class:`ArgumentParser` objects only remove an action if all of " "its option strings are overridden. So, in the example above, the old ``-f/--" @@ -888,25 +939,25 @@ msgid "" "option string was overridden." msgstr "" -#: ../../library/argparse.rst:522 +#: ../../library/argparse.rst:541 msgid "add_help" msgstr "add_help" -#: ../../library/argparse.rst:524 +#: ../../library/argparse.rst:543 msgid "" "By default, :class:`ArgumentParser` objects add an option which simply " "displays the parser's help message. If ``-h`` or ``--help`` is supplied at " "the command line, the :class:`!ArgumentParser` help will be printed." msgstr "" -#: ../../library/argparse.rst:528 +#: ../../library/argparse.rst:547 msgid "" "Occasionally, it may be useful to disable the addition of this help option. " "This can be achieved by passing ``False`` as the ``add_help=`` argument to :" "class:`ArgumentParser`::" msgstr "" -#: ../../library/argparse.rst:532 +#: ../../library/argparse.rst:551 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', add_help=False)\n" ">>> parser.add_argument('--foo', help='foo help')\n" @@ -924,7 +975,7 @@ msgstr "" "options:\n" " --foo FOO foo help" -#: ../../library/argparse.rst:540 +#: ../../library/argparse.rst:559 msgid "" "The help option is typically ``-h/--help``. The exception to this is if the " "``prefix_chars=`` is specified and does not include ``-``, in which case ``-" @@ -932,7 +983,7 @@ msgid "" "in ``prefix_chars`` is used to prefix the help options::" msgstr "" -#: ../../library/argparse.rst:546 +#: ../../library/argparse.rst:565 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', prefix_chars='+/')\n" ">>> parser.print_help()\n" @@ -948,24 +999,24 @@ msgstr "" "options:\n" " +h, ++help show this help message and exit" -#: ../../library/argparse.rst:555 +#: ../../library/argparse.rst:574 msgid "exit_on_error" msgstr "exit_on_error" -#: ../../library/argparse.rst:557 +#: ../../library/argparse.rst:576 msgid "" "Normally, when you pass an invalid argument list to the :meth:" "`~ArgumentParser.parse_args` method of an :class:`ArgumentParser`, it will " "print a *message* to :data:`sys.stderr` and exit with a status code of 2." msgstr "" -#: ../../library/argparse.rst:561 +#: ../../library/argparse.rst:580 msgid "" "If the user would like to catch errors manually, the feature can be enabled " "by setting ``exit_on_error`` to ``False``::" msgstr "" -#: ../../library/argparse.rst:564 +#: ../../library/argparse.rst:583 msgid "" ">>> parser = argparse.ArgumentParser(exit_on_error=False)\n" ">>> parser.add_argument('--integers', type=int)\n" @@ -991,81 +1042,174 @@ msgstr "" "...\n" "Catching an argumentError" -#: ../../library/argparse.rst:578 +#: ../../library/argparse.rst:596 +msgid "suggest_on_error" +msgstr "suggest_on_error" + +#: ../../library/argparse.rst:598 +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 "" + +#: ../../library/argparse.rst:602 +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 "" + +#: ../../library/argparse.rst:607 +msgid "" +">>> parser = argparse.ArgumentParser(description='Process some integers.',\n" +" suggest_on_error=True)\n" +">>> parser.add_argument('--action', choices=['sum', 'max'])\n" +">>> parser.add_argument('integers', metavar='N', type=int, nargs='+',\n" +"... help='an integer for the accumulator')\n" +">>> parser.parse_args(['--action', 'sumn', 1, 2, 3])\n" +"tester.py: error: argument --action: invalid choice: 'sumn', maybe you meant " +"'sum'? (choose from 'sum', 'max')" +msgstr "" +">>> parser = argparse.ArgumentParser(description='Process some integers.',\n" +" suggest_on_error=True)\n" +">>> parser.add_argument('--action', choices=['sum', 'max'])\n" +">>> parser.add_argument('integers', metavar='N', type=int, nargs='+',\n" +"... help='an integer for the accumulator')\n" +">>> parser.parse_args(['--action', 'sumn', 1, 2, 3])\n" +"tester.py: error: argument --action: invalid choice: 'sumn', maybe you meant " +"'sum'? (choose from 'sum', 'max')" + +#: ../../library/argparse.rst:615 +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 "" + +#: ../../library/argparse.rst:620 +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" + +#: ../../library/argparse.rst:627 +msgid "color" +msgstr "" + +#: ../../library/argparse.rst:629 +msgid "" +"By default, the help message is printed in color using `ANSI escape " +"sequences `__. If you want " +"plain text help messages, you can disable this :ref:`in your local " +"environment `, or in the argument parser itself " +"by setting ``color`` to ``False``::" +msgstr "" + +#: ../../library/argparse.rst:635 +msgid "" +">>> parser = argparse.ArgumentParser(description='Process some integers.',\n" +"... color=False)\n" +">>> parser.add_argument('--action', choices=['sum', 'max'])\n" +">>> parser.add_argument('integers', metavar='N', type=int, nargs='+',\n" +"... help='an integer for the accumulator')\n" +">>> parser.parse_args(['--help'])" +msgstr "" +">>> parser = argparse.ArgumentParser(description='Process some integers.',\n" +"... color=False)\n" +">>> parser.add_argument('--action', choices=['sum', 'max'])\n" +">>> parser.add_argument('integers', metavar='N', type=int, nargs='+',\n" +"... help='an integer for the accumulator')\n" +">>> parser.parse_args(['--help'])" + +#: ../../library/argparse.rst:642 +msgid "" +"Note that when ``color=True``, colored output depends on both environment " +"variables and terminal capabilities. However, if ``color=False``, colored " +"output is always disabled, even if environment variables like " +"``FORCE_COLOR`` are set." +msgstr "" + +#: ../../library/argparse.rst:651 msgid "The add_argument() method" msgstr "add_argument() 方法" -#: ../../library/argparse.rst:584 +#: ../../library/argparse.rst:657 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:" msgstr "" -#: ../../library/argparse.rst:587 +#: ../../library/argparse.rst:660 msgid "" "`name or flags`_ - Either a name or a list of option strings, e.g. ``'foo'`` " "or ``'-f', '--foo'``." msgstr "" -#: ../../library/argparse.rst:590 +#: ../../library/argparse.rst:663 msgid "" "action_ - The basic type of action to be taken when this argument is " "encountered at the command line." msgstr "" -#: ../../library/argparse.rst:593 +#: ../../library/argparse.rst:666 msgid "nargs_ - The number of command-line arguments that should be consumed." msgstr "" -#: ../../library/argparse.rst:595 +#: ../../library/argparse.rst:668 msgid "" "const_ - A constant value required by some action_ and nargs_ selections." msgstr "" -#: ../../library/argparse.rst:597 +#: ../../library/argparse.rst:670 msgid "" "default_ - The value produced if the argument is absent from the command " "line and if it is absent from the namespace object." msgstr "" -#: ../../library/argparse.rst:600 +#: ../../library/argparse.rst:673 msgid "" "type_ - The type to which the command-line argument should be converted." msgstr "" -#: ../../library/argparse.rst:602 +#: ../../library/argparse.rst:675 msgid "choices_ - A sequence of the allowable values for the argument." msgstr "" -#: ../../library/argparse.rst:604 +#: ../../library/argparse.rst:677 msgid "" "required_ - Whether or not the command-line option may be omitted (optionals " "only)." msgstr "" -#: ../../library/argparse.rst:607 +#: ../../library/argparse.rst:680 msgid "help_ - A brief description of what the argument does." msgstr "" -#: ../../library/argparse.rst:609 +#: ../../library/argparse.rst:682 msgid "metavar_ - A name for the argument in usage messages." msgstr "" -#: ../../library/argparse.rst:611 +#: ../../library/argparse.rst:684 msgid "" "dest_ - The name of the attribute to be added to the object returned by :" "meth:`parse_args`." msgstr "" -#: ../../library/argparse.rst:614 +#: ../../library/argparse.rst:687 msgid "deprecated_ - Whether or not use of the argument is deprecated." msgstr "" -#: ../../library/argparse.rst:622 +#: ../../library/argparse.rst:695 msgid "name or flags" msgstr "name or flags" -#: ../../library/argparse.rst:624 +#: ../../library/argparse.rst:697 msgid "" "The :meth:`~ArgumentParser.add_argument` method must know whether an " "optional argument, like ``-f`` or ``--foo``, or a positional argument, like " @@ -1074,30 +1218,30 @@ msgid "" "or a simple argument name." msgstr "" -#: ../../library/argparse.rst:630 +#: ../../library/argparse.rst:703 msgid "For example, an optional argument could be created like::" msgstr "" -#: ../../library/argparse.rst:632 +#: ../../library/argparse.rst:705 msgid ">>> parser.add_argument('-f', '--foo')" msgstr ">>> parser.add_argument('-f', '--foo')" -#: ../../library/argparse.rst:634 +#: ../../library/argparse.rst:707 msgid "while a positional argument could be created like::" msgstr "" -#: ../../library/argparse.rst:636 +#: ../../library/argparse.rst:709 msgid ">>> parser.add_argument('bar')" msgstr ">>> parser.add_argument('bar')" -#: ../../library/argparse.rst:638 +#: ../../library/argparse.rst:711 msgid "" "When :meth:`~ArgumentParser.parse_args` is called, optional arguments will " "be identified by the ``-`` prefix, and the remaining arguments will be " "assumed to be positional::" msgstr "" -#: ../../library/argparse.rst:642 +#: ../../library/argparse.rst:715 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-f', '--foo')\n" @@ -1121,11 +1265,45 @@ msgstr "" "usage: PROG [-h] [-f FOO] bar\n" "PROG: error: the following arguments are required: bar" -#: ../../library/argparse.rst:657 +#: ../../library/argparse.rst:726 +msgid "" +"By default, :mod:`!argparse` automatically handles the internal naming and " +"display names of arguments, simplifying the process without requiring " +"additional configuration. As such, you do not need to specify the dest_ and " +"metavar_ parameters. The dest_ parameter defaults to the argument name with " +"underscores ``_`` replacing hyphens ``-`` . The metavar_ parameter defaults " +"to the upper-cased name. For example::" +msgstr "" + +#: ../../library/argparse.rst:734 +msgid "" +">>> parser = argparse.ArgumentParser(prog='PROG')\n" +">>> parser.add_argument('--foo-bar')\n" +">>> parser.parse_args(['--foo-bar', 'FOO-BAR']\n" +"Namespace(foo_bar='FOO-BAR')\n" +">>> parser.print_help()\n" +"usage: [-h] [--foo-bar FOO-BAR]\n" +"\n" +"optional arguments:\n" +" -h, --help show this help message and exit\n" +" --foo-bar FOO-BAR" +msgstr "" +">>> parser = argparse.ArgumentParser(prog='PROG')\n" +">>> parser.add_argument('--foo-bar')\n" +">>> parser.parse_args(['--foo-bar', 'FOO-BAR']\n" +"Namespace(foo_bar='FOO-BAR')\n" +">>> parser.print_help()\n" +"usage: [-h] [--foo-bar FOO-BAR]\n" +"\n" +"optional arguments:\n" +" -h, --help show this help message and exit\n" +" --foo-bar FOO-BAR" + +#: ../../library/argparse.rst:749 msgid "action" msgstr "action" -#: ../../library/argparse.rst:659 +#: ../../library/argparse.rst:751 msgid "" ":class:`ArgumentParser` objects associate command-line arguments with " "actions. These actions can do just about anything with the command-line " @@ -1135,13 +1313,13 @@ msgid "" "be handled. The supplied actions are:" msgstr "" -#: ../../library/argparse.rst:665 +#: ../../library/argparse.rst:757 msgid "" "``'store'`` - This just stores the argument's value. This is the default " "action." msgstr "" -#: ../../library/argparse.rst:668 +#: ../../library/argparse.rst:760 msgid "" "``'store_const'`` - This stores the value specified by the const_ keyword " "argument; note that the const_ keyword argument defaults to ``None``. The " @@ -1149,7 +1327,7 @@ msgid "" "specify some sort of flag. For example::" msgstr "" -#: ../../library/argparse.rst:673 +#: ../../library/argparse.rst:765 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', action='store_const', const=42)\n" @@ -1161,15 +1339,14 @@ msgstr "" ">>> parser.parse_args(['--foo'])\n" "Namespace(foo=42)" -#: ../../library/argparse.rst:678 +#: ../../library/argparse.rst:770 msgid "" "``'store_true'`` and ``'store_false'`` - These are special cases of " -"``'store_const'`` used for storing the values ``True`` and ``False`` " -"respectively. In addition, they create default values of ``False`` and " -"``True`` respectively::" +"``'store_const'`` that respectively store the values ``True`` and ``False`` " +"with default values of ``False`` and ``True``::" msgstr "" -#: ../../library/argparse.rst:683 +#: ../../library/argparse.rst:775 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', action='store_true')\n" @@ -1185,37 +1362,36 @@ msgstr "" ">>> parser.parse_args('--foo --bar'.split())\n" "Namespace(foo=True, bar=False, baz=True)" -#: ../../library/argparse.rst:690 +#: ../../library/argparse.rst:782 msgid "" -"``'append'`` - This stores a list, and appends each argument value to the " -"list. It is useful to allow an option to be specified multiple times. If the " -"default value is non-empty, the default elements will be present in the " -"parsed value for the option, with any values from the command line appended " -"after those default values. Example usage::" +"``'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 " +"non-empty list, the parsed value will start with the default list's elements " +"and any values from the command line will be appended after those default " +"values. Example usage::" msgstr "" -#: ../../library/argparse.rst:696 +#: ../../library/argparse.rst:788 msgid "" ">>> parser = argparse.ArgumentParser()\n" -">>> parser.add_argument('--foo', action='append')\n" +">>> parser.add_argument('--foo', action='append', default=['0'])\n" ">>> parser.parse_args('--foo 1 --foo 2'.split())\n" -"Namespace(foo=['1', '2'])" +"Namespace(foo=['0', '1', '2'])" msgstr "" ">>> parser = argparse.ArgumentParser()\n" -">>> parser.add_argument('--foo', action='append')\n" +">>> parser.add_argument('--foo', action='append', default=['0'])\n" ">>> parser.parse_args('--foo 1 --foo 2'.split())\n" -"Namespace(foo=['1', '2'])" +"Namespace(foo=['0', '1', '2'])" -#: ../../library/argparse.rst:701 +#: ../../library/argparse.rst:793 msgid "" -"``'append_const'`` - This stores a list, and appends the value specified by " -"the const_ keyword argument to the list; note that the const_ keyword " -"argument defaults to ``None``. The ``'append_const'`` action is typically " -"useful when multiple arguments need to store constants to the same list. For " -"example::" +"``'append_const'`` - This appends the value specified by the const_ keyword " +"argument to a list; note that the const_ keyword argument defaults to " +"``None``. The ``'append_const'`` action is typically useful when multiple " +"arguments need to store constants to the same list. For example::" msgstr "" -#: ../../library/argparse.rst:707 +#: ../../library/argparse.rst:799 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--str', dest='types', action='append_const', " @@ -1233,16 +1409,16 @@ msgstr "" ">>> parser.parse_args('--str --int'.split())\n" "Namespace(types=[, ])" -#: ../../library/argparse.rst:713 +#: ../../library/argparse.rst:805 msgid "" -"``'extend'`` - This stores a list and appends each item from the multi-value " -"argument list to it. The ``'extend'`` action is typically used with the " -"nargs_ keyword argument value ``'+'`` or ``'*'``. Note that when nargs_ is " -"``None`` (the default) or ``'?'``, each character of the argument string " -"will be appended to the list. Example usage::" +"``'extend'`` - This appends each item from a multi-value argument to a list. " +"The ``'extend'`` action is typically used with the nargs_ keyword argument " +"value ``'+'`` or ``'*'``. Note that when nargs_ is ``None`` (the default) or " +"``'?'``, each character of the argument string will be appended to the list. " +"Example usage::" msgstr "" -#: ../../library/argparse.rst:721 +#: ../../library/argparse.rst:813 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument(\"--foo\", action=\"extend\", nargs=\"+\", " @@ -1258,25 +1434,29 @@ msgstr "" "\"f4\"])\n" "Namespace(foo=['f1', 'f2', 'f3', 'f4'])" -#: ../../library/argparse.rst:728 +#: ../../library/argparse.rst:820 msgid "" -"``'count'`` - This counts the number of times a keyword argument occurs. For " +"``'count'`` - This counts the number of times an argument occurs. For " "example, this is useful for increasing verbosity levels::" msgstr "" -#: ../../library/argparse.rst:731 +#: ../../library/argparse.rst:823 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--verbose', '-v', action='count', default=0)\n" ">>> parser.parse_args(['-vvv'])\n" "Namespace(verbose=3)" msgstr "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--verbose', '-v', action='count', default=0)\n" +">>> parser.parse_args(['-vvv'])\n" +"Namespace(verbose=3)" -#: ../../library/argparse.rst:736 +#: ../../library/argparse.rst:828 msgid "Note, the *default* will be ``None`` unless explicitly set to *0*." msgstr "" -#: ../../library/argparse.rst:738 +#: ../../library/argparse.rst:830 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 " @@ -1284,14 +1464,14 @@ msgid "" "output is created." msgstr "" -#: ../../library/argparse.rst:743 +#: ../../library/argparse.rst:835 msgid "" "``'version'`` - This expects a ``version=`` keyword argument in the :meth:" "`~ArgumentParser.add_argument` call, and prints version information and " "exits when invoked::" msgstr "" -#: ../../library/argparse.rst:747 +#: ../../library/argparse.rst:839 msgid "" ">>> import argparse\n" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" @@ -1307,7 +1487,7 @@ msgstr "" ">>> parser.parse_args(['--version'])\n" "PROG 2.0" -#: ../../library/argparse.rst:753 +#: ../../library/argparse.rst:845 msgid "" "You may also specify an arbitrary action by passing an :class:`Action` " "subclass (e.g. :class:`BooleanOptionalAction`) or other object that " @@ -1320,7 +1500,7 @@ msgstr "" "action(例如 ``'store'``、``'append'``、``'extend'`` 或 ``nargs`` 不為零的自" "定義 action)可以被用於位置引數。" -#: ../../library/argparse.rst:759 +#: ../../library/argparse.rst:851 msgid "" "The recommended way to create a custom action is to extend :class:`Action`, " "overriding the :meth:`!__call__` method and optionally the :meth:`!__init__` " @@ -1329,11 +1509,11 @@ msgid "" "their registered name." msgstr "" -#: ../../library/argparse.rst:764 +#: ../../library/argparse.rst:856 msgid "An example of a custom action::" msgstr "" -#: ../../library/argparse.rst:766 +#: ../../library/argparse.rst:858 msgid "" ">>> class FooAction(argparse.Action):\n" "... def __init__(self, option_strings, dest, nargs=None, **kwargs):\n" @@ -1353,16 +1533,33 @@ msgid "" ">>> args\n" "Namespace(bar='1', foo='2')" msgstr "" +">>> class FooAction(argparse.Action):\n" +"... def __init__(self, option_strings, dest, nargs=None, **kwargs):\n" +"... if nargs is not None:\n" +"... raise ValueError(\"nargs not allowed\")\n" +"... super().__init__(option_strings, dest, **kwargs)\n" +"... def __call__(self, parser, namespace, values, option_string=None):\n" +"... print('%r %r %r' % (namespace, values, option_string))\n" +"... setattr(namespace, self.dest, values)\n" +"...\n" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--foo', action=FooAction)\n" +">>> parser.add_argument('bar', action=FooAction)\n" +">>> args = parser.parse_args('1 --foo 2'.split())\n" +"Namespace(bar=None, foo=None) '1' None\n" +"Namespace(bar='1', foo=None) '2' '--foo'\n" +">>> args\n" +"Namespace(bar='1', foo='2')" -#: ../../library/argparse.rst:784 +#: ../../library/argparse.rst:876 msgid "For more details, see :class:`Action`." msgstr "更多詳情請見 :class:`Action`。" -#: ../../library/argparse.rst:790 +#: ../../library/argparse.rst:882 msgid "nargs" msgstr "nargs" -#: ../../library/argparse.rst:792 +#: ../../library/argparse.rst:884 msgid "" ":class:`ArgumentParser` objects usually associate a single command-line " "argument with a single action to be taken. The ``nargs`` keyword argument " @@ -1371,13 +1568,13 @@ msgid "" "are:" msgstr "" -#: ../../library/argparse.rst:797 +#: ../../library/argparse.rst:889 msgid "" "``N`` (an integer). ``N`` arguments from the command line will be gathered " "together into a list. For example::" msgstr "" -#: ../../library/argparse.rst:800 +#: ../../library/argparse.rst:892 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', nargs=2)\n" @@ -1391,13 +1588,13 @@ msgstr "" ">>> parser.parse_args('c --foo a b'.split())\n" "Namespace(bar=['c'], foo=['a', 'b'])" -#: ../../library/argparse.rst:806 +#: ../../library/argparse.rst:898 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." msgstr "" -#: ../../library/argparse.rst:811 +#: ../../library/argparse.rst:903 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 " @@ -1407,7 +1604,7 @@ msgid "" "produced. Some examples to illustrate this::" msgstr "" -#: ../../library/argparse.rst:818 +#: ../../library/argparse.rst:910 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', nargs='?', const='c', default='d')\n" @@ -1429,39 +1626,35 @@ msgstr "" ">>> parser.parse_args([])\n" "Namespace(bar='d', foo='d')" -#: ../../library/argparse.rst:828 +#: ../../library/argparse.rst:920 msgid "" "One of the more common uses of ``nargs='?'`` is to allow optional input and " "output files::" msgstr "" -#: ../../library/argparse.rst:831 +#: ../../library/argparse.rst:923 msgid "" ">>> parser = argparse.ArgumentParser()\n" -">>> parser.add_argument('infile', nargs='?', type=argparse.FileType('r'),\n" -"... default=sys.stdin)\n" -">>> parser.add_argument('outfile', nargs='?', type=argparse.FileType('w'),\n" -"... default=sys.stdout)\n" +">>> parser.add_argument('infile', nargs='?')\n" +">>> parser.add_argument('outfile', nargs='?')\n" ">>> parser.parse_args(['input.txt', 'output.txt'])\n" -"Namespace(infile=<_io.TextIOWrapper name='input.txt' encoding='UTF-8'>,\n" -" outfile=<_io.TextIOWrapper name='output.txt' encoding='UTF-8'>)\n" +"Namespace(infile='input.txt', outfile='output.txt')\n" +">>> parser.parse_args(['input.txt'])\n" +"Namespace(infile='input.txt', outfile=None)\n" ">>> parser.parse_args([])\n" -"Namespace(infile=<_io.TextIOWrapper name='' encoding='UTF-8'>,\n" -" outfile=<_io.TextIOWrapper name='' encoding='UTF-8'>)" +"Namespace(infile=None, outfile=None)" msgstr "" ">>> parser = argparse.ArgumentParser()\n" -">>> parser.add_argument('infile', nargs='?', type=argparse.FileType('r'),\n" -"... default=sys.stdin)\n" -">>> parser.add_argument('outfile', nargs='?', type=argparse.FileType('w'),\n" -"... default=sys.stdout)\n" +">>> parser.add_argument('infile', nargs='?')\n" +">>> parser.add_argument('outfile', nargs='?')\n" ">>> parser.parse_args(['input.txt', 'output.txt'])\n" -"Namespace(infile=<_io.TextIOWrapper name='input.txt' encoding='UTF-8'>,\n" -" outfile=<_io.TextIOWrapper name='output.txt' encoding='UTF-8'>)\n" +"Namespace(infile='input.txt', outfile='output.txt')\n" +">>> parser.parse_args(['input.txt'])\n" +"Namespace(infile='input.txt', outfile=None)\n" ">>> parser.parse_args([])\n" -"Namespace(infile=<_io.TextIOWrapper name='' encoding='UTF-8'>,\n" -" outfile=<_io.TextIOWrapper name='' encoding='UTF-8'>)" +"Namespace(infile=None, outfile=None)" -#: ../../library/argparse.rst:845 +#: ../../library/argparse.rst:935 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 " @@ -1469,7 +1662,7 @@ msgid "" "``nargs='*'`` is possible. For example::" msgstr "" -#: ../../library/argparse.rst:850 +#: ../../library/argparse.rst:940 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', nargs='*')\n" @@ -1485,14 +1678,14 @@ 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:859 +#: ../../library/argparse.rst:949 msgid "" "``'+'``. Just like ``'*'``, all command-line arguments present are gathered " "into a list. Additionally, an error message will be generated if there " "wasn't at least one command-line argument present. For example::" msgstr "" -#: ../../library/argparse.rst:863 +#: ../../library/argparse.rst:953 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('foo', nargs='+')\n" @@ -1510,7 +1703,7 @@ msgstr "" "usage: PROG [-h] foo [foo ...]\n" "PROG: error: the following arguments are required: foo" -#: ../../library/argparse.rst:871 +#: ../../library/argparse.rst:961 msgid "" "If the ``nargs`` keyword argument is not provided, the number of arguments " "consumed is determined by the action_. Generally this means a single " @@ -1519,11 +1712,11 @@ msgid "" "``'store_const'``) set ``nargs=0``." msgstr "" -#: ../../library/argparse.rst:881 +#: ../../library/argparse.rst:971 msgid "const" msgstr "const" -#: ../../library/argparse.rst:883 +#: ../../library/argparse.rst:973 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 " @@ -1531,7 +1724,7 @@ msgid "" "common uses of it are:" msgstr "" -#: ../../library/argparse.rst:887 +#: ../../library/argparse.rst:977 msgid "" "When :meth:`~ArgumentParser.add_argument` is called with " "``action='store_const'`` or ``action='append_const'``. These actions add " @@ -1541,27 +1734,27 @@ msgid "" "receive a default value of ``None``." msgstr "" -#: ../../library/argparse.rst:895 +#: ../../library/argparse.rst:985 msgid "" "When :meth:`~ArgumentParser.add_argument` is called with option strings " "(like ``-f`` or ``--foo``) and ``nargs='?'``. This creates an optional " "argument that can be followed by zero or one command-line arguments. When " "parsing the command line, if the option string is encountered with no " -"command-line argument following it, the value of ``const`` will be assumed " -"to be ``None`` instead. See the nargs_ description for examples." +"command-line argument following it, the value from ``const`` will be used. " +"See the nargs_ description for examples." msgstr "" -#: ../../library/argparse.rst:902 +#: ../../library/argparse.rst:992 msgid "" "``const=None`` by default, including when ``action='append_const'`` or " "``action='store_const'``." msgstr "" -#: ../../library/argparse.rst:909 +#: ../../library/argparse.rst:999 msgid "default" msgstr "default" -#: ../../library/argparse.rst:911 +#: ../../library/argparse.rst:1001 msgid "" "All optional arguments and some positional arguments may be omitted at the " "command line. The ``default`` keyword argument of :meth:`~ArgumentParser." @@ -1571,7 +1764,7 @@ msgid "" "command line::" msgstr "" -#: ../../library/argparse.rst:918 +#: ../../library/argparse.rst:1008 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', default=42)\n" @@ -1587,13 +1780,13 @@ msgstr "" ">>> parser.parse_args([])\n" "Namespace(foo=42)" -#: ../../library/argparse.rst:925 +#: ../../library/argparse.rst:1015 msgid "" "If the target namespace already has an attribute set, the action *default* " "will not overwrite it::" msgstr "" -#: ../../library/argparse.rst:928 +#: ../../library/argparse.rst:1018 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', default=42)\n" @@ -1605,7 +1798,7 @@ msgstr "" ">>> parser.parse_args([], namespace=argparse.Namespace(foo=101))\n" "Namespace(foo=101)" -#: ../../library/argparse.rst:933 +#: ../../library/argparse.rst:1023 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_ " @@ -1613,7 +1806,7 @@ msgid "" "`Namespace` return value. Otherwise, the parser uses the value as is::" msgstr "" -#: ../../library/argparse.rst:938 +#: ../../library/argparse.rst:1028 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--length', default='10', type=int)\n" @@ -1627,13 +1820,13 @@ msgstr "" ">>> parser.parse_args()\n" "Namespace(length=10, width=10.5)" -#: ../../library/argparse.rst:944 +#: ../../library/argparse.rst:1034 msgid "" "For positional arguments with nargs_ equal to ``?`` or ``*``, the " "``default`` value is used when no command-line argument was present::" msgstr "" -#: ../../library/argparse.rst:947 +#: ../../library/argparse.rst:1037 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('foo', nargs='?', default=42)\n" @@ -1649,20 +1842,20 @@ msgstr "" ">>> parser.parse_args([])\n" "Namespace(foo=42)" -#: ../../library/argparse.rst:954 +#: ../../library/argparse.rst:1044 msgid "" "For required_ arguments, the ``default`` value is ignored. For example, this " "applies to positional arguments with nargs_ values other than ``?`` or " "``*``, or optional arguments marked as ``required=True``." msgstr "" -#: ../../library/argparse.rst:958 +#: ../../library/argparse.rst:1048 msgid "" "Providing ``default=argparse.SUPPRESS`` causes no attribute to be added if " "the command-line argument was not present::" msgstr "" -#: ../../library/argparse.rst:961 +#: ../../library/argparse.rst:1051 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', default=argparse.SUPPRESS)\n" @@ -1678,11 +1871,11 @@ msgstr "" ">>> parser.parse_args(['--foo', '1'])\n" "Namespace(foo='1')" -#: ../../library/argparse.rst:972 +#: ../../library/argparse.rst:1062 msgid "type" msgstr "type" -#: ../../library/argparse.rst:974 +#: ../../library/argparse.rst:1064 msgid "" "By default, the parser reads command-line arguments in as simple strings. " "However, quite often the command-line string should instead be interpreted " @@ -1691,13 +1884,13 @@ msgid "" "checking and type conversions to be performed." msgstr "" -#: ../../library/argparse.rst:980 +#: ../../library/argparse.rst:1070 msgid "" "If the type_ keyword is used with the default_ keyword, the type converter " "is only applied if the default is a string." msgstr "" -#: ../../library/argparse.rst:983 +#: ../../library/argparse.rst:1073 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 " @@ -1706,11 +1899,11 @@ msgid "" "is displayed. Other exception types are not handled." msgstr "" -#: ../../library/argparse.rst:989 +#: ../../library/argparse.rst:1079 msgid "Common built-in types and functions can be used as type converters:" msgstr "" -#: ../../library/argparse.rst:991 +#: ../../library/argparse.rst:1081 msgid "" "import argparse\n" "import pathlib\n" @@ -1720,8 +1913,6 @@ msgid "" "parser.add_argument('distance', type=float)\n" "parser.add_argument('street', type=ascii)\n" "parser.add_argument('code_point', type=ord)\n" -"parser.add_argument('dest_file', type=argparse.FileType('w', " -"encoding='latin-1'))\n" "parser.add_argument('datapath', type=pathlib.Path)" msgstr "" "import argparse\n" @@ -1732,15 +1923,13 @@ msgstr "" "parser.add_argument('distance', type=float)\n" "parser.add_argument('street', type=ascii)\n" "parser.add_argument('code_point', type=ord)\n" -"parser.add_argument('dest_file', type=argparse.FileType('w', " -"encoding='latin-1'))\n" "parser.add_argument('datapath', type=pathlib.Path)" -#: ../../library/argparse.rst:1004 +#: ../../library/argparse.rst:1093 msgid "User defined functions can be used as well:" msgstr "" -#: ../../library/argparse.rst:1006 +#: ../../library/argparse.rst:1095 msgid "" ">>> def hyphenated(string):\n" "... return '-'.join([word[:4] for word in string.casefold().split()])\n" @@ -1758,14 +1947,14 @@ msgstr "" ">>> parser.parse_args(['\"The Tale of Two Cities\"'])\n" "Namespace(short_title='\"the-tale-of-two-citi')" -#: ../../library/argparse.rst:1016 +#: ../../library/argparse.rst:1105 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 " "``True``. This is usually not what is desired." msgstr "" -#: ../../library/argparse.rst:1020 +#: ../../library/argparse.rst:1109 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 " @@ -1773,7 +1962,7 @@ msgid "" "management should be done downstream after the arguments are parsed." msgstr "" -#: ../../library/argparse.rst:1025 +#: ../../library/argparse.rst:1114 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." @@ -1781,7 +1970,7 @@ msgid "" "exception would not be handled at all." msgstr "" -#: ../../library/argparse.rst:1030 +#: ../../library/argparse.rst:1119 msgid "" "Even :class:`~argparse.FileType` has its limitations for use with the " "``type`` keyword. If one argument uses :class:`~argparse.FileType` and then " @@ -1791,17 +1980,17 @@ msgid "" "files." msgstr "" -#: ../../library/argparse.rst:1037 +#: ../../library/argparse.rst:1126 msgid "" "For type checkers that simply check against a fixed set of values, consider " "using the choices_ keyword instead." msgstr "" -#: ../../library/argparse.rst:1044 +#: ../../library/argparse.rst:1133 msgid "choices" msgstr "choices" -#: ../../library/argparse.rst:1046 +#: ../../library/argparse.rst:1135 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* " @@ -1810,7 +1999,7 @@ msgid "" "be displayed if the argument was not one of the acceptable values::" msgstr "" -#: ../../library/argparse.rst:1052 +#: ../../library/argparse.rst:1141 msgid "" ">>> parser = argparse.ArgumentParser(prog='game.py')\n" ">>> parser.add_argument('move', choices=['rock', 'paper', 'scissors'])\n" @@ -1830,26 +2019,33 @@ msgstr "" "game.py: error: argument move: invalid choice: 'fire' (choose from 'rock',\n" "'paper', 'scissors')" -#: ../../library/argparse.rst:1061 -msgid "" -"Note that inclusion in the *choices* sequence is checked after any type_ " -"conversions have been performed, so the type of the objects in the *choices* " -"sequence should match the type_ specified." -msgstr "" - -#: ../../library/argparse.rst:1065 +#: ../../library/argparse.rst:1150 msgid "" "Any sequence can be passed as the *choices* value, so :class:`list` " "objects, :class:`tuple` objects, and custom sequences are all supported." msgstr "" -#: ../../library/argparse.rst:1068 +#: ../../library/argparse.rst:1153 msgid "" "Use of :class:`enum.Enum` is not recommended because it is difficult to " "control its appearance in usage, help, and error messages." msgstr "" -#: ../../library/argparse.rst:1071 +#: ../../library/argparse.rst:1156 +msgid "" +"Note that *choices* are checked after any type_ conversions have been " +"performed, so objects in *choices* should match the type_ specified. This " +"can make *choices* appear unfamiliar in usage, help, or error messages." +msgstr "" + +#: ../../library/argparse.rst:1161 +msgid "" +"To keep *choices* user-friendly, consider a custom type wrapper that " +"converts and formats values, or omit type_ and handle conversion in your " +"application code." +msgstr "" + +#: ../../library/argparse.rst:1165 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 " @@ -1857,11 +2053,11 @@ msgid "" "are many choices), just specify an explicit metavar_." msgstr "" -#: ../../library/argparse.rst:1080 +#: ../../library/argparse.rst:1174 msgid "required" msgstr "required" -#: ../../library/argparse.rst:1082 +#: ../../library/argparse.rst:1176 msgid "" "In general, the :mod:`!argparse` module assumes that flags like ``-f`` and " "``--bar`` indicate *optional* arguments, which can always be omitted at the " @@ -1869,7 +2065,7 @@ msgid "" "the ``required=`` keyword argument to :meth:`~ArgumentParser.add_argument`::" msgstr "" -#: ../../library/argparse.rst:1087 +#: ../../library/argparse.rst:1181 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', required=True)\n" @@ -1887,24 +2083,24 @@ msgstr "" "usage: [-h] --foo FOO\n" ": error: the following arguments are required: --foo" -#: ../../library/argparse.rst:1095 +#: ../../library/argparse.rst:1189 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 " "present at the command line." msgstr "" -#: ../../library/argparse.rst:1101 +#: ../../library/argparse.rst:1195 msgid "" "Required options are generally considered bad form because users expect " "*options* to be *optional*, and thus they should be avoided when possible." msgstr "" -#: ../../library/argparse.rst:1108 +#: ../../library/argparse.rst:1202 msgid "help" msgstr "help" -#: ../../library/argparse.rst:1110 +#: ../../library/argparse.rst:1204 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`` " @@ -1912,7 +2108,7 @@ msgid "" "each argument." msgstr "" -#: ../../library/argparse.rst:1115 +#: ../../library/argparse.rst:1209 msgid "" "The ``help`` strings can include various format specifiers to avoid " "repetition of things like the program name or the argument default_. The " @@ -1921,7 +2117,7 @@ msgid "" "``%(type)s``, etc.::" msgstr "" -#: ../../library/argparse.rst:1120 +#: ../../library/argparse.rst:1214 msgid "" ">>> parser = argparse.ArgumentParser(prog='frobble')\n" ">>> parser.add_argument('bar', nargs='?', type=int, default=42,\n" @@ -1947,19 +2143,19 @@ msgstr "" "options:\n" " -h, --help show this help message and exit" -#: ../../library/argparse.rst:1132 +#: ../../library/argparse.rst:1226 msgid "" "As the help string supports %-formatting, if you want a literal ``%`` to " "appear in the help string, you must escape it as ``%%``." msgstr "" -#: ../../library/argparse.rst:1135 +#: ../../library/argparse.rst:1229 msgid "" ":mod:`!argparse` supports silencing the help entry for certain options, by " "setting the ``help`` value to ``argparse.SUPPRESS``::" msgstr "" -#: ../../library/argparse.rst:1138 +#: ../../library/argparse.rst:1232 msgid "" ">>> parser = argparse.ArgumentParser(prog='frobble')\n" ">>> parser.add_argument('--foo', help=argparse.SUPPRESS)\n" @@ -1977,11 +2173,11 @@ msgstr "" "options:\n" " -h, --help show this help message and exit" -#: ../../library/argparse.rst:1150 +#: ../../library/argparse.rst:1244 msgid "metavar" msgstr "metavar" -#: ../../library/argparse.rst:1152 +#: ../../library/argparse.rst:1246 msgid "" "When :class:`ArgumentParser` generates help messages, it needs some way to " "refer to each expected argument. By default, :class:`!ArgumentParser` " @@ -1993,7 +2189,7 @@ msgid "" "command-line argument will be referred to as ``FOO``. An example::" msgstr "" -#: ../../library/argparse.rst:1161 +#: ../../library/argparse.rst:1255 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo')\n" @@ -2025,11 +2221,11 @@ msgstr "" " -h, --help show this help message and exit\n" " --foo FOO" -#: ../../library/argparse.rst:1176 +#: ../../library/argparse.rst:1270 msgid "An alternative name can be specified with ``metavar``::" msgstr "" -#: ../../library/argparse.rst:1178 +#: ../../library/argparse.rst:1272 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', metavar='YYY')\n" @@ -2061,21 +2257,21 @@ msgstr "" " -h, --help show this help message and exit\n" " --foo YYY" -#: ../../library/argparse.rst:1193 +#: ../../library/argparse.rst:1287 msgid "" "Note that ``metavar`` only changes the *displayed* name - the name of the " "attribute on the :meth:`~ArgumentParser.parse_args` object is still " "determined by the dest_ value." msgstr "" -#: ../../library/argparse.rst:1197 +#: ../../library/argparse.rst:1291 msgid "" "Different values of ``nargs`` may cause the metavar to be used multiple " "times. Providing a tuple to ``metavar`` specifies a different display for " "each of the arguments::" msgstr "" -#: ../../library/argparse.rst:1201 +#: ../../library/argparse.rst:1295 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-x', nargs=2)\n" @@ -2099,11 +2295,11 @@ msgstr "" " -x X X\n" " --foo bar baz" -#: ../../library/argparse.rst:1216 +#: ../../library/argparse.rst:1310 msgid "dest" msgstr "dest" -#: ../../library/argparse.rst:1218 +#: ../../library/argparse.rst:1312 msgid "" "Most :class:`ArgumentParser` actions add some value as an attribute of the " "object returned by :meth:`~ArgumentParser.parse_args`. The name of this " @@ -2113,7 +2309,7 @@ msgid "" "add_argument`::" msgstr "" -#: ../../library/argparse.rst:1225 +#: ../../library/argparse.rst:1319 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('bar')\n" @@ -2125,7 +2321,7 @@ msgstr "" ">>> parser.parse_args(['XXX'])\n" "Namespace(bar='XXX')" -#: ../../library/argparse.rst:1230 +#: ../../library/argparse.rst:1324 msgid "" "For optional argument actions, the value of ``dest`` is normally inferred " "from the option strings. :class:`ArgumentParser` generates the value of " @@ -2137,7 +2333,7 @@ msgid "" "below illustrate this behavior::" msgstr "" -#: ../../library/argparse.rst:1239 +#: ../../library/argparse.rst:1333 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('-f', '--foo-bar', '--foo')\n" @@ -2155,11 +2351,11 @@ msgstr "" ">>> parser.parse_args('--foo 1 -y 2'.split())\n" "Namespace(foo_bar='1', x='2')" -#: ../../library/argparse.rst:1247 +#: ../../library/argparse.rst:1341 msgid "``dest`` allows a custom attribute name to be provided::" msgstr "" -#: ../../library/argparse.rst:1249 +#: ../../library/argparse.rst:1343 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', dest='bar')\n" @@ -2171,11 +2367,11 @@ msgstr "" ">>> parser.parse_args('--foo XXX'.split())\n" "Namespace(bar='XXX')" -#: ../../library/argparse.rst:1258 +#: ../../library/argparse.rst:1352 msgid "deprecated" msgstr "deprecated" -#: ../../library/argparse.rst:1260 +#: ../../library/argparse.rst:1354 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 " @@ -2186,7 +2382,7 @@ msgid "" "will be printed to :data:`sys.stderr` when the argument is used::" msgstr "" -#: ../../library/argparse.rst:1270 +#: ../../library/argparse.rst:1364 msgid "" ">>> import argparse\n" ">>> parser = argparse.ArgumentParser(prog='snake.py')\n" @@ -2206,11 +2402,11 @@ msgstr "" "snake.py: warning: option '--legs' is deprecated\n" "Namespace(legs=4)" -#: ../../library/argparse.rst:1283 +#: ../../library/argparse.rst:1377 msgid "Action classes" msgstr "Action 類別" -#: ../../library/argparse.rst:1285 +#: ../../library/argparse.rst:1379 msgid "" ":class:`!Action` classes implement the Action API, a callable which returns " "a callable which processes arguments from the command-line. Any object which " @@ -2218,7 +2414,7 @@ msgid "" "`~ArgumentParser.add_argument`." msgstr "" -#: ../../library/argparse.rst:1294 +#: ../../library/argparse.rst:1388 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 " @@ -2227,7 +2423,7 @@ msgid "" "`ArgumentParser.add_argument` except for the ``action`` itself." msgstr "" -#: ../../library/argparse.rst:1300 +#: ../../library/argparse.rst:1394 msgid "" "Instances of :class:`!Action` (or return value of any callable to the " "``action`` parameter) should have attributes :attr:`!dest`, :attr:`!" @@ -2236,46 +2432,46 @@ msgid "" "is to call :meth:`!Action.__init__`." msgstr "" -#: ../../library/argparse.rst:1308 +#: ../../library/argparse.rst:1402 msgid "" ":class:`!Action` instances should be callable, so subclasses must override " "the :meth:`!__call__` method, which should accept four parameters:" msgstr "" -#: ../../library/argparse.rst:1311 +#: ../../library/argparse.rst:1405 msgid "" "*parser* - The :class:`ArgumentParser` object which contains this action." msgstr "" -#: ../../library/argparse.rst:1313 +#: ../../library/argparse.rst:1407 msgid "" "*namespace* - The :class:`Namespace` object that will be returned by :meth:" "`~ArgumentParser.parse_args`. Most actions add an attribute to this object " "using :func:`setattr`." msgstr "" -#: ../../library/argparse.rst:1317 +#: ../../library/argparse.rst:1411 msgid "" "*values* - The associated command-line arguments, with any type conversions " "applied. Type conversions are specified with the type_ keyword argument to :" "meth:`~ArgumentParser.add_argument`." msgstr "" -#: ../../library/argparse.rst:1321 +#: ../../library/argparse.rst:1415 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 " "associated with a positional argument." msgstr "" -#: ../../library/argparse.rst:1325 +#: ../../library/argparse.rst:1419 msgid "" "The :meth:`!__call__` method may perform arbitrary actions, but will " "typically set attributes on the ``namespace`` based on ``dest`` and " "``values``." msgstr "" -#: ../../library/argparse.rst:1330 +#: ../../library/argparse.rst:1424 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 " @@ -2283,7 +2479,7 @@ msgid "" "will be used." msgstr "" -#: ../../library/argparse.rst:1336 +#: ../../library/argparse.rst:1430 msgid "" "A subclass of :class:`Action` for handling boolean flags with positive and " "negative options. Adding a single argument such as ``--foo`` automatically " @@ -2291,7 +2487,7 @@ msgid "" "``False`` respectively::" msgstr "" -#: ../../library/argparse.rst:1341 +#: ../../library/argparse.rst:1435 msgid "" ">>> import argparse\n" ">>> parser = argparse.ArgumentParser()\n" @@ -2305,47 +2501,47 @@ msgstr "" ">>> parser.parse_args(['--no-foo'])\n" "Namespace(foo=False)" -#: ../../library/argparse.rst:1351 +#: ../../library/argparse.rst:1445 msgid "The parse_args() method" msgstr "parse_args() 方法" -#: ../../library/argparse.rst:1355 +#: ../../library/argparse.rst:1449 msgid "" "Convert argument strings to objects and assign them as attributes of the " "namespace. Return the populated namespace." msgstr "" -#: ../../library/argparse.rst:1358 +#: ../../library/argparse.rst:1452 msgid "" "Previous calls to :meth:`add_argument` determine exactly what objects are " "created and how they are assigned. See the documentation for :meth:`!" "add_argument` for details." msgstr "" -#: ../../library/argparse.rst:1362 +#: ../../library/argparse.rst:1456 msgid "" "args_ - List of strings to parse. The default is taken from :data:`sys." "argv`." msgstr "" -#: ../../library/argparse.rst:1365 +#: ../../library/argparse.rst:1459 msgid "" "namespace_ - An object to take the attributes. The default is a new empty :" "class:`Namespace` object." msgstr "" -#: ../../library/argparse.rst:1370 +#: ../../library/argparse.rst:1464 msgid "Option value syntax" msgstr "" -#: ../../library/argparse.rst:1372 +#: ../../library/argparse.rst:1466 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, " "the option and its value are passed as two separate arguments::" msgstr "" -#: ../../library/argparse.rst:1376 +#: ../../library/argparse.rst:1470 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-x')\n" @@ -2363,14 +2559,14 @@ msgstr "" ">>> parser.parse_args(['--foo', 'FOO'])\n" "Namespace(foo='FOO', x=None)" -#: ../../library/argparse.rst:1384 +#: ../../library/argparse.rst:1478 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 " "``=`` to separate them::" msgstr "" -#: ../../library/argparse.rst:1388 +#: ../../library/argparse.rst:1482 msgid "" ">>> parser.parse_args(['--foo=FOO'])\n" "Namespace(foo='FOO', x=None)" @@ -2378,13 +2574,13 @@ msgstr "" ">>> parser.parse_args(['--foo=FOO'])\n" "Namespace(foo='FOO', x=None)" -#: ../../library/argparse.rst:1391 +#: ../../library/argparse.rst:1485 msgid "" "For short options (options only one character long), the option and its " "value can be concatenated::" msgstr "" -#: ../../library/argparse.rst:1394 +#: ../../library/argparse.rst:1488 msgid "" ">>> parser.parse_args(['-xX'])\n" "Namespace(foo=None, x='X')" @@ -2392,13 +2588,13 @@ msgstr "" ">>> parser.parse_args(['-xX'])\n" "Namespace(foo=None, x='X')" -#: ../../library/argparse.rst:1397 +#: ../../library/argparse.rst:1491 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::" msgstr "" -#: ../../library/argparse.rst:1400 +#: ../../library/argparse.rst:1494 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-x', action='store_true')\n" @@ -2414,11 +2610,11 @@ msgstr "" ">>> parser.parse_args(['-xyzZ'])\n" "Namespace(x=True, y=True, z='Z')" -#: ../../library/argparse.rst:1409 +#: ../../library/argparse.rst:1503 msgid "Invalid arguments" msgstr "無效引數" -#: ../../library/argparse.rst:1411 +#: ../../library/argparse.rst:1505 msgid "" "While parsing the command line, :meth:`~ArgumentParser.parse_args` checks " "for a variety of errors, including ambiguous options, invalid types, invalid " @@ -2426,7 +2622,7 @@ msgid "" "an error, it exits and prints the error along with a usage message::" msgstr "" -#: ../../library/argparse.rst:1416 +#: ../../library/argparse.rst:1510 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('--foo', type=int)\n" @@ -2466,11 +2662,11 @@ msgstr "" "usage: PROG [-h] [--foo FOO] [bar]\n" "PROG: error: extra arguments found: badger" -#: ../../library/argparse.rst:1437 +#: ../../library/argparse.rst:1531 msgid "Arguments containing ``-``" msgstr "包含 ``-`` 的引數" -#: ../../library/argparse.rst:1439 +#: ../../library/argparse.rst:1533 msgid "" "The :meth:`~ArgumentParser.parse_args` method attempts to give errors " "whenever the user has clearly made a mistake, but some situations are " @@ -2482,7 +2678,7 @@ msgid "" "negative numbers::" msgstr "" -#: ../../library/argparse.rst:1447 +#: ../../library/argparse.rst:1541 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-x')\n" @@ -2515,7 +2711,7 @@ msgid "" "PROG: error: argument -1: expected one argument" msgstr "" -#: ../../library/argparse.rst:1477 +#: ../../library/argparse.rst:1571 msgid "" "If you have positional arguments that must begin with ``-`` and don't look " "like negative numbers, you can insert the pseudo-argument ``'--'`` which " @@ -2523,7 +2719,7 @@ msgid "" "positional argument::" msgstr "" -#: ../../library/argparse.rst:1482 +#: ../../library/argparse.rst:1576 msgid "" ">>> parser.parse_args(['--', '-f'])\n" "Namespace(foo='-f', one=None)" @@ -2531,24 +2727,24 @@ msgstr "" ">>> parser.parse_args(['--', '-f'])\n" "Namespace(foo='-f', one=None)" -#: ../../library/argparse.rst:1485 +#: ../../library/argparse.rst:1579 msgid "" "See also :ref:`the argparse howto on ambiguous arguments ` for more details." msgstr "" -#: ../../library/argparse.rst:1491 +#: ../../library/argparse.rst:1585 msgid "Argument abbreviations (prefix matching)" msgstr "引數縮寫 (前綴匹配)" -#: ../../library/argparse.rst:1493 +#: ../../library/argparse.rst:1587 msgid "" "The :meth:`~ArgumentParser.parse_args` method :ref:`by default " "` allows long options to be abbreviated to a prefix, if the " "abbreviation is unambiguous (the prefix matches a unique option)::" msgstr "" -#: ../../library/argparse.rst:1497 +#: ../../library/argparse.rst:1591 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-bacon')\n" @@ -2572,17 +2768,17 @@ msgstr "" "usage: PROG [-h] [-bacon BACON] [-badger BADGER]\n" "PROG: error: ambiguous option: -ba could match -badger, -bacon" -#: ../../library/argparse.rst:1508 +#: ../../library/argparse.rst:1602 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``." msgstr "" -#: ../../library/argparse.rst:1514 +#: ../../library/argparse.rst:1608 msgid "Beyond ``sys.argv``" -msgstr "" +msgstr "``sys.argv`` 之外" -#: ../../library/argparse.rst:1516 +#: ../../library/argparse.rst:1610 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 " @@ -2590,7 +2786,7 @@ msgid "" "useful for testing at the interactive prompt::" msgstr "" -#: ../../library/argparse.rst:1521 +#: ../../library/argparse.rst:1615 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument(\n" @@ -2616,24 +2812,24 @@ msgstr "" ">>> parser.parse_args(['1', '2', '3', '4', '--sum'])\n" "Namespace(accumulate=, integers=[1, 2, 3, 4])" -#: ../../library/argparse.rst:1536 +#: ../../library/argparse.rst:1630 msgid "The Namespace object" msgstr "命名空間物件" -#: ../../library/argparse.rst:1540 +#: ../../library/argparse.rst:1634 msgid "" "Simple class used by default by :meth:`~ArgumentParser.parse_args` to create " "an object holding attributes and return it." msgstr "" -#: ../../library/argparse.rst:1543 +#: ../../library/argparse.rst:1637 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 " "attributes, you can use the standard Python idiom, :func:`vars`::" msgstr "" -#: ../../library/argparse.rst:1547 +#: ../../library/argparse.rst:1641 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo')\n" @@ -2647,14 +2843,14 @@ msgstr "" ">>> vars(args)\n" "{'foo': 'BAR'}" -#: ../../library/argparse.rst:1553 +#: ../../library/argparse.rst:1647 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. " "This can be achieved by specifying the ``namespace=`` keyword argument::" msgstr "" -#: ../../library/argparse.rst:1557 +#: ../../library/argparse.rst:1651 msgid "" ">>> class C:\n" "... pass\n" @@ -2676,15 +2872,15 @@ msgstr "" ">>> c.foo\n" "'BAR'" -#: ../../library/argparse.rst:1569 +#: ../../library/argparse.rst:1663 msgid "Other utilities" msgstr "" -#: ../../library/argparse.rst:1572 +#: ../../library/argparse.rst:1666 msgid "Sub-commands" msgstr "子命令" -#: ../../library/argparse.rst:1579 +#: ../../library/argparse.rst:1673 msgid "" "Many programs split up their functionality into a number of subcommands, for " "example, the ``svn`` program can invoke subcommands like ``svn checkout``, " @@ -2699,69 +2895,69 @@ msgid "" "returns an :class:`!ArgumentParser` object that can be modified as usual." msgstr "" -#: ../../library/argparse.rst:1591 +#: ../../library/argparse.rst:1685 msgid "Description of parameters:" msgstr "參數的解釋:" -#: ../../library/argparse.rst:1593 +#: ../../library/argparse.rst:1687 msgid "" "*title* - title for the sub-parser group in help output; by default " "\"subcommands\" if description is provided, otherwise uses title for " "positional arguments" msgstr "" -#: ../../library/argparse.rst:1597 +#: ../../library/argparse.rst:1691 msgid "" "*description* - description for the sub-parser group in help output, by " "default ``None``" msgstr "" -#: ../../library/argparse.rst:1600 +#: ../../library/argparse.rst:1694 msgid "" "*prog* - usage information that will be displayed with sub-command help, by " "default the name of the program and any positional arguments before the " "subparser argument" msgstr "" -#: ../../library/argparse.rst:1604 +#: ../../library/argparse.rst:1698 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`)" msgstr "" -#: ../../library/argparse.rst:1607 +#: ../../library/argparse.rst:1701 msgid "" "action_ - the basic type of action to be taken when this argument is " "encountered at the command line" msgstr "" -#: ../../library/argparse.rst:1610 +#: ../../library/argparse.rst:1704 msgid "" "dest_ - name of the attribute under which sub-command name will be stored; " "by default ``None`` and no value is stored" msgstr "" -#: ../../library/argparse.rst:1613 +#: ../../library/argparse.rst:1707 msgid "" "required_ - Whether or not a subcommand must be provided, by default " "``False`` (added in 3.7)" msgstr "" -#: ../../library/argparse.rst:1616 +#: ../../library/argparse.rst:1710 msgid "help_ - help for sub-parser group in help output, by default ``None``" msgstr "" -#: ../../library/argparse.rst:1618 +#: ../../library/argparse.rst:1712 msgid "" "metavar_ - string presenting available subcommands in help; by default it is " "``None`` and presents subcommands in form {cmd1, cmd2, ..}" msgstr "" -#: ../../library/argparse.rst:1621 +#: ../../library/argparse.rst:1715 msgid "Some example usage::" msgstr "一些使用範例: ::" -#: ../../library/argparse.rst:1623 +#: ../../library/argparse.rst:1717 msgid "" ">>> # create the top-level parser\n" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" @@ -2784,7 +2980,7 @@ msgid "" "Namespace(baz='Z', foo=True)" msgstr "" -#: ../../library/argparse.rst:1642 +#: ../../library/argparse.rst:1736 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 " @@ -2794,7 +2990,7 @@ msgid "" "``baz`` attributes are present." msgstr "" -#: ../../library/argparse.rst:1649 +#: ../../library/argparse.rst:1743 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 " @@ -2803,7 +2999,7 @@ msgid "" "to :meth:`~_SubParsersAction.add_parser` as above.)" msgstr "" -#: ../../library/argparse.rst:1657 +#: ../../library/argparse.rst:1751 msgid "" ">>> parser.parse_args(['--help'])\n" "usage: PROG [-h] [--foo] {a,b} ...\n" @@ -2861,14 +3057,14 @@ msgstr "" " -h, --help show this help message and exit\n" " --baz {X,Y,Z} baz help" -#: ../../library/argparse.rst:1685 +#: ../../library/argparse.rst:1779 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::" msgstr "" -#: ../../library/argparse.rst:1689 +#: ../../library/argparse.rst:1783 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> subparsers = parser.add_subparsers(title='subcommands',\n" @@ -2904,7 +3100,7 @@ msgstr "" "\n" " {foo,bar} additional help" -#: ../../library/argparse.rst:1706 +#: ../../library/argparse.rst:1800 msgid "" "Furthermore, :meth:`~_SubParsersAction.add_parser` supports an additional " "*aliases* argument, which allows multiple strings to refer to the same " @@ -2912,7 +3108,7 @@ msgid "" "``checkout``::" msgstr "" -#: ../../library/argparse.rst:1711 +#: ../../library/argparse.rst:1805 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> subparsers = parser.add_subparsers()\n" @@ -2928,13 +3124,13 @@ msgstr "" ">>> parser.parse_args(['co', 'bar'])\n" "Namespace(foo='bar')" -#: ../../library/argparse.rst:1718 +#: ../../library/argparse.rst:1812 msgid "" ":meth:`~_SubParsersAction.add_parser` supports also an additional " "*deprecated* argument, which allows to deprecate the subparser." msgstr "" -#: ../../library/argparse.rst:1732 +#: ../../library/argparse.rst:1826 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 " @@ -2942,7 +3138,7 @@ msgid "" "example::" msgstr "" -#: ../../library/argparse.rst:1737 +#: ../../library/argparse.rst:1831 msgid "" ">>> # subcommand functions\n" ">>> def foo(args):\n" @@ -2977,7 +3173,7 @@ msgid "" "((XYZYX))" msgstr "" -#: ../../library/argparse.rst:1769 +#: ../../library/argparse.rst:1863 msgid "" "This way, you can let :meth:`parse_args` do the job of calling the " "appropriate function after argument parsing is complete. Associating " @@ -2987,7 +3183,7 @@ msgid "" "argument to the :meth:`add_subparsers` call will work::" msgstr "" -#: ../../library/argparse.rst:1776 +#: ../../library/argparse.rst:1870 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> subparsers = parser.add_subparsers(dest='subparser_name')\n" @@ -3007,15 +3203,21 @@ msgstr "" ">>> parser.parse_args(['2', 'frobble'])\n" "Namespace(subparser_name='2', y='frobble')" -#: ../../library/argparse.rst:1785 +#: ../../library/argparse.rst:1879 msgid "New *required* keyword-only parameter." msgstr "" -#: ../../library/argparse.rst:1790 +#: ../../library/argparse.rst:1882 +msgid "" +"Subparser's *prog* is no longer affected by a custom usage message in the " +"main parser." +msgstr "" + +#: ../../library/argparse.rst:1888 msgid "FileType objects" msgstr "FileType 物件" -#: ../../library/argparse.rst:1794 +#: ../../library/argparse.rst:1892 msgid "" "The :class:`FileType` factory creates objects that can be passed to the type " "argument of :meth:`ArgumentParser.add_argument`. Arguments that have :class:" @@ -3024,7 +3226,7 @@ msgid "" "the :func:`open` function for more details)::" msgstr "" -#: ../../library/argparse.rst:1800 +#: ../../library/argparse.rst:1898 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--raw', type=argparse.FileType('wb', 0))\n" @@ -3042,14 +3244,14 @@ msgstr "" "Namespace(out=<_io.TextIOWrapper name='file.txt' mode='w' encoding='UTF-8'>, " "raw=<_io.FileIO name='raw.dat' mode='wb'>)" -#: ../../library/argparse.rst:1806 +#: ../../library/argparse.rst:1904 msgid "" "FileType objects understand the pseudo-argument ``'-'`` and automatically " "convert this into :data:`sys.stdin` for readable :class:`FileType` objects " "and :data:`sys.stdout` for writable :class:`FileType` objects::" msgstr "" -#: ../../library/argparse.rst:1810 +#: ../../library/argparse.rst:1908 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('infile', type=argparse.FileType('r'))\n" @@ -3061,15 +3263,24 @@ msgstr "" ">>> parser.parse_args(['-'])\n" "Namespace(infile=<_io.TextIOWrapper name='' encoding='UTF-8'>)" -#: ../../library/argparse.rst:1815 +#: ../../library/argparse.rst:1915 +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 " +"clobber the output files. In this case, it would be better to wait until " +"after the parser has run and then use the :keyword:`with`-statement to " +"manage the files." +msgstr "" + +#: ../../library/argparse.rst:1921 msgid "Added the *encodings* and *errors* parameters." msgstr "" -#: ../../library/argparse.rst:1820 +#: ../../library/argparse.rst:1928 msgid "Argument groups" msgstr "" -#: ../../library/argparse.rst:1825 +#: ../../library/argparse.rst:1933 msgid "" "By default, :class:`ArgumentParser` groups command-line arguments into " "\"positional arguments\" and \"options\" when displaying help messages. When " @@ -3078,7 +3289,7 @@ msgid "" "method::" msgstr "" -#: ../../library/argparse.rst:1831 +#: ../../library/argparse.rst:1939 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', add_help=False)\n" ">>> group = parser.add_argument_group('group')\n" @@ -3102,7 +3313,7 @@ msgstr "" " bar bar help\n" " --foo FOO foo help" -#: ../../library/argparse.rst:1842 +#: ../../library/argparse.rst:1950 msgid "" "The :meth:`add_argument_group` method returns an argument group object which " "has an :meth:`~ArgumentParser.add_argument` method just like a regular :" @@ -3113,7 +3324,7 @@ msgid "" "this display::" msgstr "" -#: ../../library/argparse.rst:1850 +#: ../../library/argparse.rst:1958 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', add_help=False)\n" ">>> group1 = parser.add_argument_group('group1', 'group1 description')\n" @@ -3151,7 +3362,7 @@ msgstr "" "\n" " --bar BAR bar help" -#: ../../library/argparse.rst:1868 +#: ../../library/argparse.rst:1976 msgid "" "The optional, keyword-only parameters argument_default_ and " "conflict_handler_ allow for finer-grained control of the behavior of the " @@ -3160,32 +3371,35 @@ msgid "" "rather than the entire parser." msgstr "" -#: ../../library/argparse.rst:1873 +#: ../../library/argparse.rst:1981 msgid "" "Note that any arguments not in your user-defined groups will end up back in " "the usual \"positional arguments\" and \"optional arguments\" sections." msgstr "" -#: ../../library/argparse.rst:1876 +#: ../../library/argparse.rst:1984 msgid "" -"Calling :meth:`add_argument_group` on an argument group is deprecated. This " -"feature was never supported and does not always work correctly. The function " -"exists on the API by accident through inheritance and will be removed in the " -"future." +"Calling :meth:`add_argument_group` on an argument group now raises an " +"exception. This nesting was never supported, often failed to work correctly, " +"and was unintentionally exposed through inheritance." +msgstr "" + +#: ../../library/argparse.rst:1989 +msgid "Passing prefix_chars_ to :meth:`add_argument_group` is now deprecated." msgstr "" -#: ../../library/argparse.rst:1884 +#: ../../library/argparse.rst:1995 msgid "Mutual exclusion" msgstr "" -#: ../../library/argparse.rst:1888 +#: ../../library/argparse.rst:1999 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 " "command line::" msgstr "" -#: ../../library/argparse.rst:1892 +#: ../../library/argparse.rst:2003 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> group = parser.add_mutually_exclusive_group()\n" @@ -3211,14 +3425,14 @@ msgstr "" "usage: PROG [-h] [--foo | --bar]\n" "PROG: error: argument --bar: not allowed with argument --foo" -#: ../../library/argparse.rst:1904 +#: ../../library/argparse.rst:2015 msgid "" "The :meth:`add_mutually_exclusive_group` method also accepts a *required* " "argument, to indicate that at least one of the mutually exclusive arguments " "is required::" msgstr "" -#: ../../library/argparse.rst:1908 +#: ../../library/argparse.rst:2019 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> group = parser.add_mutually_exclusive_group(required=True)\n" @@ -3236,7 +3450,7 @@ msgstr "" "usage: PROG [-h] (--foo | --bar)\n" "PROG: error: one of the arguments --foo --bar is required" -#: ../../library/argparse.rst:1916 +#: ../../library/argparse.rst:2027 msgid "" "Note that currently mutually exclusive argument groups do not support the " "*title* and *description* arguments of :meth:`~ArgumentParser." @@ -3244,7 +3458,7 @@ msgid "" "argument group that has a title and description. For example::" msgstr "" -#: ../../library/argparse.rst:1922 +#: ../../library/argparse.rst:2033 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> group = parser.add_argument_group('Group title', 'Group description')\n" @@ -3280,19 +3494,19 @@ msgstr "" " --foo FOO foo help\n" " --bar BAR bar help" -#: ../../library/argparse.rst:1939 +#: ../../library/argparse.rst:2050 msgid "" "Calling :meth:`add_argument_group` or :meth:`add_mutually_exclusive_group` " -"on a mutually exclusive group is deprecated. These features were never " -"supported and do not always work correctly. The functions exist on the API " -"by accident through inheritance and will be removed in the future." +"on a mutually exclusive group now raises an exception. This nesting was " +"never supported, often failed to work correctly, and was unintentionally " +"exposed through inheritance." msgstr "" -#: ../../library/argparse.rst:1947 +#: ../../library/argparse.rst:2058 msgid "Parser defaults" msgstr "" -#: ../../library/argparse.rst:1951 +#: ../../library/argparse.rst:2062 msgid "" "Most of the time, the attributes of the object returned by :meth:" "`parse_args` will be fully determined by inspecting the command-line " @@ -3301,7 +3515,7 @@ msgid "" "command line to be added::" msgstr "" -#: ../../library/argparse.rst:1957 +#: ../../library/argparse.rst:2068 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('foo', type=int)\n" @@ -3315,12 +3529,15 @@ msgstr "" ">>> parser.parse_args(['736'])\n" "Namespace(bar=42, baz='badger', foo=736)" -#: ../../library/argparse.rst:1963 +#: ../../library/argparse.rst:2074 msgid "" -"Note that parser-level defaults always override argument-level defaults::" +"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 " +"are called for the same argument, the last default set for an argument is " +"used::" msgstr "" -#: ../../library/argparse.rst:1965 +#: ../../library/argparse.rst:2078 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', default='bar')\n" @@ -3334,20 +3551,20 @@ msgstr "" ">>> parser.parse_args([])\n" "Namespace(foo='spam')" -#: ../../library/argparse.rst:1971 +#: ../../library/argparse.rst:2084 msgid "" "Parser-level defaults can be particularly useful when working with multiple " "parsers. See the :meth:`~ArgumentParser.add_subparsers` method for an " "example of this type." msgstr "" -#: ../../library/argparse.rst:1977 +#: ../../library/argparse.rst:2090 msgid "" "Get the default value for a namespace attribute, as set by either :meth:" "`~ArgumentParser.add_argument` or by :meth:`~ArgumentParser.set_defaults`::" msgstr "" -#: ../../library/argparse.rst:1981 +#: ../../library/argparse.rst:2094 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', default='badger')\n" @@ -3359,54 +3576,54 @@ msgstr "" ">>> parser.get_default('foo')\n" "'badger'" -#: ../../library/argparse.rst:1988 +#: ../../library/argparse.rst:2101 msgid "Printing help" msgstr "印出幫助訊息" -#: ../../library/argparse.rst:1990 +#: ../../library/argparse.rst:2103 msgid "" "In most typical applications, :meth:`~ArgumentParser.parse_args` will take " "care of formatting and printing any usage or error messages. However, " "several formatting methods are available:" msgstr "" -#: ../../library/argparse.rst:1996 +#: ../../library/argparse.rst:2109 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 " "assumed." msgstr "" -#: ../../library/argparse.rst:2002 +#: ../../library/argparse.rst:2115 msgid "" "Print a help message, including the program usage and information about the " "arguments registered with the :class:`ArgumentParser`. If *file* is " "``None``, :data:`sys.stdout` is assumed." msgstr "" -#: ../../library/argparse.rst:2006 +#: ../../library/argparse.rst:2119 msgid "" "There are also variants of these methods that simply return a string instead " "of printing it:" msgstr "" -#: ../../library/argparse.rst:2011 +#: ../../library/argparse.rst:2124 msgid "" "Return a string containing a brief description of how the :class:" "`ArgumentParser` should be invoked on the command line." msgstr "" -#: ../../library/argparse.rst:2016 +#: ../../library/argparse.rst:2129 msgid "" "Return a string containing a help message, including the program usage and " "information about the arguments registered with the :class:`ArgumentParser`." msgstr "" -#: ../../library/argparse.rst:2021 +#: ../../library/argparse.rst:2134 msgid "Partial parsing" msgstr "" -#: ../../library/argparse.rst:2025 +#: ../../library/argparse.rst:2138 msgid "" "Sometimes a script only needs to handle a specific set of command-line " "arguments, leaving any unrecognized arguments for another script or program. " @@ -3414,7 +3631,7 @@ msgid "" "useful." msgstr "" -#: ../../library/argparse.rst:2030 +#: ../../library/argparse.rst:2143 msgid "" "This method works similarly to :meth:`~ArgumentParser.parse_args`, but it " "does not raise an error for extra, unrecognized arguments. Instead, it " @@ -3422,7 +3639,7 @@ msgid "" "populated namespace and the list of any unrecognized arguments." msgstr "" -#: ../../library/argparse.rst:2037 +#: ../../library/argparse.rst:2150 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', action='store_true')\n" @@ -3436,7 +3653,7 @@ msgstr "" ">>> parser.parse_known_args(['--foo', '--badger', 'BAR', 'spam'])\n" "(Namespace(bar='BAR', foo=True), ['--badger', 'spam'])" -#: ../../library/argparse.rst:2044 +#: ../../library/argparse.rst:2157 msgid "" ":ref:`Prefix matching ` rules apply to :meth:" "`~ArgumentParser.parse_known_args`. The parser may consume an option even if " @@ -3444,11 +3661,11 @@ msgid "" "remaining arguments list." msgstr "" -#: ../../library/argparse.rst:2051 +#: ../../library/argparse.rst:2164 msgid "Customizing file parsing" msgstr "" -#: ../../library/argparse.rst:2055 +#: ../../library/argparse.rst:2168 msgid "" "Arguments that are read from a file (see the *fromfile_prefix_chars* keyword " "argument to the :class:`ArgumentParser` constructor) are read one argument " @@ -3456,20 +3673,20 @@ msgid "" "reading." msgstr "" -#: ../../library/argparse.rst:2060 +#: ../../library/argparse.rst:2173 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. " "The method is called once per line read from the argument file, in order." msgstr "" -#: ../../library/argparse.rst:2064 +#: ../../library/argparse.rst:2177 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::" msgstr "" -#: ../../library/argparse.rst:2067 +#: ../../library/argparse.rst:2180 msgid "" "class MyArgumentParser(argparse.ArgumentParser):\n" " def convert_arg_line_to_args(self, arg_line):\n" @@ -3479,18 +3696,18 @@ msgstr "" " def convert_arg_line_to_args(self, arg_line):\n" " return arg_line.split()" -#: ../../library/argparse.rst:2073 +#: ../../library/argparse.rst:2186 msgid "Exiting methods" msgstr "" -#: ../../library/argparse.rst:2077 +#: ../../library/argparse.rst:2190 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 " "can override this method to handle these steps differently::" msgstr "" -#: ../../library/argparse.rst:2081 +#: ../../library/argparse.rst:2194 msgid "" "class ErrorCatchingArgumentParser(argparse.ArgumentParser):\n" " def exit(self, status=0, message=None):\n" @@ -3504,17 +3721,17 @@ msgstr "" " raise Exception(f'Exiting because of an error: {message}')\n" " exit(status)" -#: ../../library/argparse.rst:2089 +#: ../../library/argparse.rst:2202 msgid "" "This method prints a usage message, including the *message*, to :data:`sys." "stderr` and terminates the program with a status code of 2." msgstr "" -#: ../../library/argparse.rst:2094 +#: ../../library/argparse.rst:2207 msgid "Intermixed parsing" msgstr "" -#: ../../library/argparse.rst:2099 +#: ../../library/argparse.rst:2212 msgid "" "A number of Unix commands allow the user to intermix optional arguments with " "positional arguments. The :meth:`~ArgumentParser.parse_intermixed_args` " @@ -3522,7 +3739,7 @@ msgid "" "parsing style." msgstr "" -#: ../../library/argparse.rst:2104 +#: ../../library/argparse.rst:2217 msgid "" "These parsers do not support all the :mod:`!argparse` features, and will " "raise exceptions if unsupported features are used. In particular, " @@ -3530,7 +3747,7 @@ msgid "" "positionals are not supported." msgstr "" -#: ../../library/argparse.rst:2109 +#: ../../library/argparse.rst:2222 msgid "" "The following example shows the difference between :meth:`~ArgumentParser." "parse_known_args` and :meth:`~ArgumentParser.parse_intermixed_args`: the " @@ -3538,7 +3755,7 @@ msgid "" "collects all the positionals into ``rest``. ::" msgstr "" -#: ../../library/argparse.rst:2115 +#: ../../library/argparse.rst:2228 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo')\n" @@ -3558,7 +3775,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:2124 +#: ../../library/argparse.rst:2237 msgid "" ":meth:`~ArgumentParser.parse_known_intermixed_args` returns a two item tuple " "containing the populated namespace and the list of remaining argument " @@ -3566,11 +3783,11 @@ msgid "" "there are any remaining unparsed argument strings." msgstr "" -#: ../../library/argparse.rst:2133 +#: ../../library/argparse.rst:2246 msgid "Registering custom types or actions" msgstr "" -#: ../../library/argparse.rst:2137 +#: ../../library/argparse.rst:2250 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 " @@ -3578,7 +3795,7 @@ msgid "" "the type by their registered name instead of their callable name." msgstr "" -#: ../../library/argparse.rst:2142 +#: ../../library/argparse.rst:2255 msgid "" "The :meth:`!register` method accepts three arguments - a *registry_name*, " "specifying the internal registry where the object will be stored (e.g., " @@ -3586,12 +3803,12 @@ msgid "" "be registered, and object, the callable to be registered." msgstr "" -#: ../../library/argparse.rst:2147 +#: ../../library/argparse.rst:2260 msgid "" "The following example shows how to register a custom type with a parser::" msgstr "" -#: ../../library/argparse.rst:2149 +#: ../../library/argparse.rst:2262 msgid "" ">>> import argparse\n" ">>> parser = argparse.ArgumentParser()\n" @@ -3606,43 +3823,86 @@ msgid "" "usage: PROG [-h] [--foo FOO]\n" "PROG: error: argument --foo: invalid 'hexadecimal integer' value: '1.2'" msgstr "" +">>> import argparse\n" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.register('type', 'hexadecimal integer', lambda s: int(s, 16))\n" +">>> parser.add_argument('--foo', type='hexadecimal integer')\n" +"_StoreAction(option_strings=['--foo'], dest='foo', nargs=None, const=None, " +"default=None, type='hexadecimal integer', choices=None, required=False, " +"help=None, metavar=None, deprecated=False)\n" +">>> parser.parse_args(['--foo', '0xFA'])\n" +"Namespace(foo=250)\n" +">>> parser.parse_args(['--foo', '1.2'])\n" +"usage: PROG [-h] [--foo FOO]\n" +"PROG: error: argument --foo: invalid 'hexadecimal integer' value: '1.2'" -#: ../../library/argparse.rst:2161 +#: ../../library/argparse.rst:2274 msgid "Exceptions" msgstr "例外" -#: ../../library/argparse.rst:2165 +#: ../../library/argparse.rst:2278 msgid "An error from creating or using an argument (optional or positional)." msgstr "" -#: ../../library/argparse.rst:2167 +#: ../../library/argparse.rst:2280 msgid "" "The string value of this exception is the message, augmented with " "information about the argument that caused it." msgstr "" -#: ../../library/argparse.rst:2172 +#: ../../library/argparse.rst:2285 msgid "" "Raised when something goes wrong converting a command line string to a type." msgstr "" -#: ../../library/argparse.rst:2176 +#: ../../library/argparse.rst:2289 msgid "Guides and Tutorials" msgstr "" -#: ../../library/argparse.rst:809 +#: ../../library/argparse.rst:901 msgid "? (question mark)" msgstr "? (問號)" -#: ../../library/argparse.rst:809 ../../library/argparse.rst:843 -#: ../../library/argparse.rst:857 +#: ../../library/argparse.rst:901 ../../library/argparse.rst:933 +#: ../../library/argparse.rst:947 msgid "in argparse module" msgstr "於 argparse 模組中" -#: ../../library/argparse.rst:843 +#: ../../library/argparse.rst:933 msgid "* (asterisk)" msgstr "* (星號)" -#: ../../library/argparse.rst:857 +#: ../../library/argparse.rst:947 msgid "+ (plus)" msgstr "+ (加號)" + +#~ msgid "" +#~ ">>> parser = argparse.ArgumentParser()\n" +#~ ">>> parser.add_argument('infile', nargs='?', type=argparse." +#~ "FileType('r'),\n" +#~ "... default=sys.stdin)\n" +#~ ">>> parser.add_argument('outfile', nargs='?', type=argparse." +#~ "FileType('w'),\n" +#~ "... default=sys.stdout)\n" +#~ ">>> parser.parse_args(['input.txt', 'output.txt'])\n" +#~ "Namespace(infile=<_io.TextIOWrapper name='input.txt' encoding='UTF-8'>,\n" +#~ " outfile=<_io.TextIOWrapper name='output.txt' " +#~ "encoding='UTF-8'>)\n" +#~ ">>> parser.parse_args([])\n" +#~ "Namespace(infile=<_io.TextIOWrapper name='' encoding='UTF-8'>,\n" +#~ " outfile=<_io.TextIOWrapper name='' encoding='UTF-8'>)" +#~ msgstr "" +#~ ">>> parser = argparse.ArgumentParser()\n" +#~ ">>> parser.add_argument('infile', nargs='?', type=argparse." +#~ "FileType('r'),\n" +#~ "... default=sys.stdin)\n" +#~ ">>> parser.add_argument('outfile', nargs='?', type=argparse." +#~ "FileType('w'),\n" +#~ "... default=sys.stdout)\n" +#~ ">>> parser.parse_args(['input.txt', 'output.txt'])\n" +#~ "Namespace(infile=<_io.TextIOWrapper name='input.txt' encoding='UTF-8'>,\n" +#~ " outfile=<_io.TextIOWrapper name='output.txt' " +#~ "encoding='UTF-8'>)\n" +#~ ">>> parser.parse_args([])\n" +#~ "Namespace(infile=<_io.TextIOWrapper name='' encoding='UTF-8'>,\n" +#~ " outfile=<_io.TextIOWrapper name='' encoding='UTF-8'>)" diff --git a/library/array.po b/library/array.po index feccab889ac..a7880c1bdc0 100644 --- a/library/array.po +++ b/library/array.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -8,7 +8,7 @@ # Benson Chen , 2021 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2025-07-30 00:18+0000\n" "PO-Revision-Date: 2021-11-23 18:40+0800\n" diff --git a/library/ast.po b/library/ast.po index 5d46b5bc4c6..013311dd141 100644 --- a/library/ast.po +++ b/library/ast.po @@ -1,12 +1,12 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"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: 2025-10-24 00:14+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-" @@ -18,7 +18,7 @@ msgstr "" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/ast.rst:2 -msgid ":mod:`!ast` --- Abstract Syntax Trees" +msgid ":mod:`!ast` --- Abstract syntax trees" msgstr ":mod:`!ast` --- 抽象語法樹 (Abstract Syntax Trees)" #: ../../library/ast.rst:14 @@ -51,7 +51,7 @@ msgstr "" "函式將抽象語法樹編譯成 Python 程式碼物件。" #: ../../library/ast.rst:33 -msgid "Abstract Grammar" +msgid "Abstract grammar" msgstr "抽象文法 (Abstract Grammar)" #: ../../library/ast.rst:35 @@ -133,7 +133,7 @@ msgid "" " | UnaryOp(unaryop op, expr operand)\n" " | Lambda(arguments args, expr body)\n" " | IfExp(expr test, expr body, expr orelse)\n" -" | Dict(expr* keys, expr* values)\n" +" | Dict(expr?* keys, expr* values)\n" " | Set(expr* elts)\n" " | ListComp(expr elt, comprehension* generators)\n" " | SetComp(expr elt, comprehension* generators)\n" @@ -148,7 +148,10 @@ msgid "" " | Compare(expr left, cmpop* ops, expr* comparators)\n" " | Call(expr func, expr* args, keyword* keywords)\n" " | FormattedValue(expr value, int conversion, expr? format_spec)\n" +" | Interpolation(expr value, constant str, int conversion, expr? " +"format_spec)\n" " | JoinedStr(expr* values)\n" +" | TemplateStr(expr* values)\n" " | Constant(constant value, string? kind)\n" "\n" " -- the following expression can appear in assignment context\n" @@ -258,10 +261,10 @@ msgid "" "abstract: only instances of specific constructor nodes are ever created." msgstr "" "抽象文法中為每個左側符號定義了一個類別(例如 :class:`ast.stmt` 或 :class:" -"`ast.expr`\\ )。此外,也為每個右側的建構函式 (constructor) 定義了一個類別;" -"這些類別繼承自左側樹的類別。例如,:class:`ast.BinOp` 繼承自 :class:`ast." -"expr`。對於具有替代方案(即為「和 (sums)」)的生產規則,左側類別是抽象的:僅" -"有特定建構函式節點的實例會被建立。" +"`ast.expr`)。此外,也為每個右側的建構函式 (constructor) 定義了一個類別;這些" +"類別繼承自左側樹的類別。例如,:class:`ast.BinOp` 繼承自 :class:`ast.expr`。對" +"於具有替代方案(即為「和 (sums)」)的生產規則,左側類別是抽象的:僅有特定建構" +"函式節點的實例會被建立。" #: ../../library/ast.rst:64 msgid "" @@ -398,6 +401,12 @@ msgstr "以它們的值表示簡單索引,擴充切片 (slice) 則以元組 (t #: ../../library/ast.rst:139 msgid "" +"The :meth:`~object.__repr__` output of :class:`~ast.AST` nodes includes the " +"values of the node fields." +msgstr "" + +#: ../../library/ast.rst:144 +msgid "" "Old classes :class:`!ast.Num`, :class:`!ast.Str`, :class:`!ast.Bytes`, :" "class:`!ast.NameConstant` and :class:`!ast.Ellipsis` are still available, " "but they will be removed in future Python releases. In the meantime, " @@ -407,7 +416,7 @@ msgstr "" "ast.NameConstant` 和 :class:`!ast.Ellipsis` 仍然可用,但它們將在未來的 " "Python 釋出版本中移除。與此同時,實例化它們將回傳不同類別的實例。" -#: ../../library/ast.rst:146 +#: ../../library/ast.rst:151 msgid "" "Old classes :class:`!ast.Index` and :class:`!ast.ExtSlice` are still " "available, but they will be removed in future Python releases. In the " @@ -416,7 +425,7 @@ msgstr "" "舊的類別 :class:`!ast.Index` 和 :class:`!ast.ExtSlice` 仍然可用,但它們將在未" "來的 Python 版本中刪除。同時,實例化它們會回傳不同類別的實例。" -#: ../../library/ast.rst:153 +#: ../../library/ast.rst:158 msgid "" "Previous versions of Python allowed the creation of AST nodes that were " "missing required fields. Similarly, AST node constructors allowed arbitrary " @@ -428,7 +437,7 @@ msgstr "" "許將任意關鍵字引數設為 AST 節點的屬性,即使它們與 AST 節點的任何欄位都不匹" "配。此行為已被棄用,並將在 Python 3.15 中刪除。" -#: ../../library/ast.rst:160 +#: ../../library/ast.rst:165 msgid "" "The descriptions of the specific node classes displayed here were initially " "adapted from the fantastic `Green Tree Snakes `__ 專案和所有貢獻者那裡改編而來" "的。" -#: ../../library/ast.rst:169 +#: ../../library/ast.rst:174 msgid "Root nodes" msgstr "根節點" -#: ../../library/ast.rst:173 +#: ../../library/ast.rst:178 msgid "" "A Python module, as with :ref:`file input `. Node type generated " "by :func:`ast.parse` in the default ``\"exec\"`` *mode*." @@ -450,11 +459,11 @@ msgstr "" "一個 Python 模組,與\\ :ref:`檔案輸入 ` 一樣。由 :func:`ast." "parse` 在預設的 ``\"exec\"`` *mode* 下生成的節點型別。" -#: ../../library/ast.rst:176 +#: ../../library/ast.rst:181 msgid "``body`` is a :class:`list` of the module's :ref:`ast-statements`." msgstr "``body`` 是模組的\\ :ref:`ast-statements` 的一個 :class:`list`。" -#: ../../library/ast.rst:178 +#: ../../library/ast.rst:183 msgid "" "``type_ignores`` is a :class:`list` of the module's type ignore comments; " "see :func:`ast.parse` for more details." @@ -462,7 +471,7 @@ msgstr "" "``type_ignores`` 是模組的忽略型別註解的 :class:`list`;有關更多詳細資訊,請參" "閱 :func:`ast.parse`。" -#: ../../library/ast.rst:181 +#: ../../library/ast.rst:186 msgid "" ">>> print(ast.dump(ast.parse('x = 1'), indent=4))\n" "Module(\n" @@ -480,7 +489,7 @@ msgstr "" " Name(id='x', ctx=Store())],\n" " value=Constant(value=1))])" -#: ../../library/ast.rst:194 +#: ../../library/ast.rst:199 msgid "" "A single Python :ref:`expression input `. Node type " "generated by :func:`ast.parse` when *mode* is ``\"eval\"``." @@ -488,14 +497,14 @@ msgstr "" "單個 Python :ref:`運算式輸入 `。當 *mode* 是 ``\"eval\"`` " "時節點型別由 :func:`ast.parse` 生成。" -#: ../../library/ast.rst:197 +#: ../../library/ast.rst:202 msgid "" "``body`` is a single node, one of the :ref:`expression types `." msgstr "" "``body`` 是單個節點,是\\ :ref:`運算式型別 `\\ 的其中之一。" -#: ../../library/ast.rst:200 ../../library/ast.rst:270 +#: ../../library/ast.rst:205 ../../library/ast.rst:275 msgid "" ">>> print(ast.dump(ast.parse('123', mode='eval'), indent=4))\n" "Expression(\n" @@ -505,7 +514,7 @@ msgstr "" "Expression(\n" " body=Constant(value=123))" -#: ../../library/ast.rst:209 +#: ../../library/ast.rst:214 msgid "" "A single :ref:`interactive input `, like in :ref:`tut-interac`. " "Node type generated by :func:`ast.parse` when *mode* is ``\"single\"``." @@ -513,13 +522,13 @@ msgstr "" "單個\\ :ref:`互動式輸入 `,和\\ :ref:`tut-interac`\\ 中所述的相" "似。當 *mode* 是 ``\"single\"`` 時節點型別由 :func:`ast.parse` 生成。" -#: ../../library/ast.rst:212 +#: ../../library/ast.rst:217 msgid "``body`` is a :class:`list` of :ref:`statement nodes `." msgstr "" "``body`` 是\\ :ref:`陳述式節點 (statement nodes) ` 的 :class:" "`list`。" -#: ../../library/ast.rst:214 +#: ../../library/ast.rst:219 msgid "" ">>> print(ast.dump(ast.parse('x = 1; y = 2', mode='single'), indent=4))\n" "Interactive(\n" @@ -545,7 +554,7 @@ msgstr "" " Name(id='y', ctx=Store())],\n" " value=Constant(value=2))])" -#: ../../library/ast.rst:231 +#: ../../library/ast.rst:236 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 " @@ -554,11 +563,11 @@ msgstr "" "函式的舊式型別註解的表示法,因為 3.5 之前的 Python 版本不支援 :pep:`484` 註" "釋。當 *mode* 是 ``\"func_type\"`` 時節點型別由 :func:`ast.parse` 生成。" -#: ../../library/ast.rst:235 +#: ../../library/ast.rst:240 msgid "Such type comments would look like this::" msgstr "這種型別的註解看起來像這樣: ::" -#: ../../library/ast.rst:237 +#: ../../library/ast.rst:242 msgid "" "def sum_two_number(a, b):\n" " # type: (int, int) -> int\n" @@ -568,17 +577,17 @@ msgstr "" " # type: (int, int) -> int\n" " return a + b" -#: ../../library/ast.rst:241 +#: ../../library/ast.rst:246 msgid "" "``argtypes`` is a :class:`list` of :ref:`expression nodes `." msgstr "" "``argtypes`` 是\\ :ref:`運算式節點 `\\ 的 :class:`list`。" -#: ../../library/ast.rst:243 +#: ../../library/ast.rst:248 msgid "``returns`` is a single :ref:`expression node `." msgstr "``returns`` 是單個\\ :ref:`運算式節點 `。" -#: ../../library/ast.rst:245 +#: ../../library/ast.rst:250 msgid "" ">>> print(ast.dump(ast.parse('(int, str) -> List[int]', mode='func_type'), " "indent=4))\n" @@ -602,11 +611,11 @@ msgstr "" " slice=Name(id='int', ctx=Load()),\n" " ctx=Load()))" -#: ../../library/ast.rst:261 +#: ../../library/ast.rst:266 msgid "Literals" msgstr "文本 (Literals)" -#: ../../library/ast.rst:265 +#: ../../library/ast.rst:270 msgid "" "A constant value. The ``value`` attribute of the ``Constant`` literal " "contains the Python object it represents. The values represented can be " @@ -616,10 +625,10 @@ msgid "" msgstr "" "一個常數值。``Constant`` 文本的 ``value`` 屬性包含它所代表的 Python 物件。表" "示的值可以是 :class:`str`、:class:`bytes`、:class:`int`、:class:`float`、:" -"class:`complex` 和 :class:`bool` 的實例,以及常數 :data:`None` 和 :" -"data:`Ellipsis`。" +"class:`complex` 和 :class:`bool` 的實例,以及常數 :data:`None` 和 :data:" +"`Ellipsis`。" -#: ../../library/ast.rst:279 +#: ../../library/ast.rst:284 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 " @@ -629,33 +638,33 @@ msgstr "" "沒有其他內容,則可以隔離 (isolate) 該節點,否則它將出現在 :class:`JoinedStr` " "中。" -#: ../../library/ast.rst:283 +#: ../../library/ast.rst:288 msgid "" "``value`` is any expression node (such as a literal, a variable, or a " "function call)." msgstr "``value`` 為任何運算式節點(例如文字、變數或函式呼叫)。" -#: ../../library/ast.rst:285 +#: ../../library/ast.rst:290 ../../library/ast.rst:372 msgid "``conversion`` is an integer:" msgstr "``conversion`` 是一個整數:" -#: ../../library/ast.rst:287 +#: ../../library/ast.rst:292 msgid "-1: no formatting" msgstr "-1: 無格式化" -#: ../../library/ast.rst:288 -msgid "115: ``!s`` string formatting" -msgstr "115: ``!s`` 字串格式化" +#: ../../library/ast.rst:293 +msgid "97 (``ord('a')``): ``!a`` :func:`ASCII ` formatting" +msgstr "97 (``ord('a')``):``!a`` :func:`ASCII ` 格式化" -#: ../../library/ast.rst:289 -msgid "114: ``!r`` repr formatting" -msgstr "114:``!r`` 重複格式化化" +#: ../../library/ast.rst:294 +msgid "114 (``ord('r')``): ``!r`` :func:`repr` formatting" +msgstr "114 (``ord('r')``):``!r`` :func:`repr` 格式化" -#: ../../library/ast.rst:290 -msgid "97: ``!a`` ascii formatting" -msgstr "97: ``!a`` ascii 格式化" +#: ../../library/ast.rst:295 +msgid "115 (``ord('s')``): ``!s`` :func:`string ` formatting" +msgstr "115 (``ord('s')``):``!s`` :func:`string ` 格式化" -#: ../../library/ast.rst:292 +#: ../../library/ast.rst:297 msgid "" "``format_spec`` is a :class:`JoinedStr` node representing the formatting of " "the value, or ``None`` if no format was specified. Both ``conversion`` and " @@ -664,14 +673,14 @@ msgstr "" "``format_spec`` 是一個 :class:`JoinedStr` 節點,表示值的格式,若未指定格式則" "為 ``None``。``conversion`` 和 ``format_spec`` 可以同時設定。" -#: ../../library/ast.rst:299 +#: ../../library/ast.rst:304 msgid "" "An f-string, comprising a series of :class:`FormattedValue` and :class:" "`Constant` nodes." msgstr "" "一個 f 字串,包含一系列 :class:`FormattedValue` 和 :class:`Constant` 節點。" -#: ../../library/ast.rst:302 +#: ../../library/ast.rst:307 msgid "" ">>> print(ast.dump(ast.parse('f\"sin({a}) is {sin(a):.3}\"', mode='eval'), " "indent=4))\n" @@ -713,7 +722,108 @@ msgstr "" " values=[\n" " Constant(value='.3')]))]))" -#: ../../library/ast.rst:327 +#: ../../library/ast.rst:333 +msgid "" +"Node representing a template string literal, comprising a series of :class:" +"`Interpolation` and :class:`Constant` nodes. These nodes may be any order, " +"and do not need to be interleaved." +msgstr "" + +#: ../../library/ast.rst:337 +msgid "" +">>> expr = ast.parse('t\"{name} finished {place:ordinal}\"', mode='eval')\n" +">>> print(ast.dump(expr, indent=4))\n" +"Expression(\n" +" body=TemplateStr(\n" +" values=[\n" +" Interpolation(\n" +" value=Name(id='name', ctx=Load()),\n" +" str='name',\n" +" conversion=-1),\n" +" Constant(value=' finished '),\n" +" Interpolation(\n" +" value=Name(id='place', ctx=Load()),\n" +" str='place',\n" +" conversion=-1,\n" +" format_spec=JoinedStr(\n" +" values=[\n" +" Constant(value='ordinal')]))]))" +msgstr "" +">>> expr = ast.parse('t\"{name} finished {place:ordinal}\"', mode='eval')\n" +">>> print(ast.dump(expr, indent=4))\n" +"Expression(\n" +" body=TemplateStr(\n" +" values=[\n" +" Interpolation(\n" +" value=Name(id='name', ctx=Load()),\n" +" str='name',\n" +" conversion=-1),\n" +" Constant(value=' finished '),\n" +" Interpolation(\n" +" value=Name(id='place', ctx=Load()),\n" +" str='place',\n" +" conversion=-1,\n" +" format_spec=JoinedStr(\n" +" values=[\n" +" Constant(value='ordinal')]))]))" + +#: ../../library/ast.rst:361 +msgid "" +"Node representing a single interpolation field in a template string literal." +msgstr "" + +#: ../../library/ast.rst:363 +msgid "" +"``value`` is any expression node (such as a literal, a variable, or a " +"function call). This has the same meaning as ``FormattedValue.value``." +msgstr "" +"``value`` 為任何運算式節點(例如文字、變數或函式呼叫)。這和 " +"``FormattedValue.value`` 的意思相同。" + +#: ../../library/ast.rst:366 +msgid "" +"``str`` is a constant containing the text of the interpolation expression." +msgstr "" + +#: ../../library/ast.rst:368 +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 " +"code is identical to the original and is intended for code generation." +msgstr "" + +#: ../../library/ast.rst:374 +msgid "-1: no conversion" +msgstr "-1:無規範" + +#: ../../library/ast.rst:375 +msgid "97 (``ord('a')``): ``!a`` :func:`ASCII ` conversion" +msgstr "97 (``ord('a')``):``!a`` :func:`ASCII ` 轉換" + +#: ../../library/ast.rst:376 +msgid "114 (``ord('r')``): ``!r`` :func:`repr` conversion" +msgstr "114 (``ord('r')``):``!r`` :func:`repr` 轉換" + +#: ../../library/ast.rst:377 +msgid "115 (``ord('s')``): ``!s`` :func:`string ` conversion" +msgstr "115 (``ord('s')``):``!s`` :func:`string ` 轉換" + +#: ../../library/ast.rst:379 +msgid "This has the same meaning as ``FormattedValue.conversion``." +msgstr "這與 ``FormattedValue.conversion`` 的意思相同。" + +#: ../../library/ast.rst:380 +msgid "" +"``format_spec`` is a :class:`JoinedStr` node representing the formatting of " +"the value, or ``None`` if no format was specified. Both ``conversion`` and " +"``format_spec`` can be set at the same time. This has the same meaning as " +"``FormattedValue.format_spec``." +msgstr "" +"``format_spec`` 是一個 :class:`JoinedStr` 節點,表示值的格式,若未指定格式則" +"為 ``None``。``conversion`` 和 ``format_spec`` 可以同時設定。這與 " +"``FormattedValue.format_spec`` 的意思相同。" + +#: ../../library/ast.rst:389 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. " @@ -722,7 +832,7 @@ msgstr "" "串列或元組。``elts`` 保存表示元素的節點串列。如果容器是賦值目標(即 ``(x," "y)=something`` ),則 ``ctx`` 是 :class:`Store`,否則是 :class:`Load`。" -#: ../../library/ast.rst:331 +#: ../../library/ast.rst:393 msgid "" ">>> print(ast.dump(ast.parse('[1, 2, 3]', mode='eval'), indent=4))\n" "Expression(\n" @@ -758,11 +868,11 @@ msgstr "" " Constant(value=3)],\n" " ctx=Load()))" -#: ../../library/ast.rst:353 +#: ../../library/ast.rst:415 msgid "A set. ``elts`` holds a list of nodes representing the set's elements." msgstr "一個集合。``elts`` 保存表示集合之元素的節點串列。" -#: ../../library/ast.rst:355 +#: ../../library/ast.rst:417 msgid "" ">>> print(ast.dump(ast.parse('{1, 2, 3}', mode='eval'), indent=4))\n" "Expression(\n" @@ -780,7 +890,7 @@ msgstr "" " Constant(value=2),\n" " Constant(value=3)]))" -#: ../../library/ast.rst:368 +#: ../../library/ast.rst:430 msgid "" "A dictionary. ``keys`` and ``values`` hold lists of nodes representing the " "keys and the values respectively, in matching order (what would be returned " @@ -790,7 +900,7 @@ msgstr "" "節點串列(為呼叫 :code:`dictionary.keys()` 和 :code:`dictionary.values()` 時" "將回傳的內容)。" -#: ../../library/ast.rst:372 +#: ../../library/ast.rst:434 msgid "" "When doing dictionary unpacking using dictionary literals the expression to " "be expanded goes in the ``values`` list, with a ``None`` at the " @@ -799,7 +909,7 @@ msgstr "" "當使用字典文本進行字典解包 (unpack) 時,要擴充的運算式位於 ``values`` 串列" "中,在 ``keys`` 中的相應位置有一個 ``None``。" -#: ../../library/ast.rst:376 +#: ../../library/ast.rst:438 msgid "" ">>> print(ast.dump(ast.parse('{\"a\":1, **d}', mode='eval'), indent=4))\n" "Expression(\n" @@ -821,17 +931,17 @@ msgstr "" " Constant(value=1),\n" " Name(id='d', ctx=Load())]))" -#: ../../library/ast.rst:390 +#: ../../library/ast.rst:452 msgid "Variables" msgstr "變數" -#: ../../library/ast.rst:394 +#: ../../library/ast.rst:456 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:402 +#: ../../library/ast.rst:464 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 " @@ -840,7 +950,7 @@ msgstr "" "變數參照可用於載入變數的值、為其分配新值或刪除它。變數參照被賦予情境 " "(context) 來區分這些情況。" -#: ../../library/ast.rst:406 +#: ../../library/ast.rst:468 msgid "" ">>> print(ast.dump(ast.parse('a'), indent=4))\n" "Module(\n" @@ -884,7 +994,7 @@ msgstr "" " targets=[\n" " Name(id='a', ctx=Del())])])" -#: ../../library/ast.rst:432 +#: ../../library/ast.rst:494 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 " @@ -893,7 +1003,7 @@ msgstr "" "一個 ``*var`` 變數參照。``value`` 保存變數,通常是一個 :class:`Name` 節點。在" "使用 ``*args`` 建置 :class:`Call` 節點時必須使用此型別。" -#: ../../library/ast.rst:436 +#: ../../library/ast.rst:498 msgid "" ">>> print(ast.dump(ast.parse('a, *b = it'), indent=4))\n" "Module(\n" @@ -923,11 +1033,11 @@ msgstr "" " ctx=Store())],\n" " value=Name(id='it', ctx=Load()))])" -#: ../../library/ast.rst:456 +#: ../../library/ast.rst:518 msgid "Expressions" msgstr "運算式" -#: ../../library/ast.rst:460 +#: ../../library/ast.rst:522 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 " @@ -940,7 +1050,7 @@ msgstr "" "`Constant`、:class:`Name`、:class:`Lambda`、:class:`Yield` 或 :class:" "`YieldFrom`" -#: ../../library/ast.rst:465 +#: ../../library/ast.rst:527 msgid "" ">>> print(ast.dump(ast.parse('-a'), indent=4))\n" "Module(\n" @@ -958,14 +1068,14 @@ msgstr "" " op=USub(),\n" " operand=Name(id='a', ctx=Load())))])" -#: ../../library/ast.rst:478 +#: ../../library/ast.rst:540 msgid "" "A unary operation. ``op`` is the operator, and ``operand`` any expression " "node." msgstr "" "一元運算 (unary operation)。``op`` 是運算子,``operand`` 是任何運算式節點。" -#: ../../library/ast.rst:487 +#: ../../library/ast.rst:549 msgid "" "Unary operator tokens. :class:`Not` is the ``not`` keyword, :class:`Invert` " "is the ``~`` operator." @@ -973,7 +1083,7 @@ msgstr "" "一元運算子標記。 :class:`Not` 是 ``not`` 關鍵字、:class:`Invert` 是 ``~`` 運" "算子。" -#: ../../library/ast.rst:490 +#: ../../library/ast.rst:552 msgid "" ">>> print(ast.dump(ast.parse('not x', mode='eval'), indent=4))\n" "Expression(\n" @@ -987,7 +1097,7 @@ msgstr "" " op=Not(),\n" " operand=Name(id='x', ctx=Load())))" -#: ../../library/ast.rst:501 +#: ../../library/ast.rst:563 msgid "" "A binary operation (like addition or division). ``op`` is the operator, and " "``left`` and ``right`` are any expression nodes." @@ -995,7 +1105,7 @@ msgstr "" "二元運算 (binary operation)(如加法或除法)。 ``op`` 是運算子、``left`` 和 " "``right`` 是任意運算式節點。" -#: ../../library/ast.rst:504 +#: ../../library/ast.rst:566 msgid "" ">>> print(ast.dump(ast.parse('x + y', mode='eval'), indent=4))\n" "Expression(\n" @@ -1011,11 +1121,11 @@ msgstr "" " op=Add(),\n" " right=Name(id='y', ctx=Load())))" -#: ../../library/ast.rst:528 +#: ../../library/ast.rst:590 msgid "Binary operator tokens." msgstr "二元運算子 token。" -#: ../../library/ast.rst:533 +#: ../../library/ast.rst:595 msgid "" "A boolean operation, 'or' or 'and'. ``op`` is :class:`Or` or :class:`And`. " "``values`` are the values involved. Consecutive operations with the same " @@ -1023,14 +1133,14 @@ msgid "" "values." msgstr "" "布林運算 'or' 或 'and'。``op`` 是 :class:`Or` 或 :class:`And`。``values`` 是" -"有所涉及的值。使用同一運算子的連續操作(例如 ``a or b or c``\\ )會被折疊為具" -"有多個值的一個節點。" +"有所涉及的值。使用同一運算子的連續操作(例如 ``a or b or c``)會被折疊為具有" +"多個值的一個節點。" -#: ../../library/ast.rst:538 +#: ../../library/ast.rst:600 msgid "This doesn't include ``not``, which is a :class:`UnaryOp`." msgstr "這不包括 ``not``,它是一個 :class:`UnaryOp`。" -#: ../../library/ast.rst:540 +#: ../../library/ast.rst:602 msgid "" ">>> print(ast.dump(ast.parse('x or y', mode='eval'), indent=4))\n" "Expression(\n" @@ -1048,11 +1158,11 @@ msgstr "" " Name(id='x', ctx=Load()),\n" " Name(id='y', ctx=Load())]))" -#: ../../library/ast.rst:554 +#: ../../library/ast.rst:616 msgid "Boolean operator tokens." msgstr "布林運算子 token。" -#: ../../library/ast.rst:559 +#: ../../library/ast.rst:621 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 " @@ -1061,7 +1171,7 @@ msgstr "" "兩個或多個值的比較。``left`` 是比較中的第一個值、``ops`` 是運算子串列、" "``comparators`` 是要比較的第一個元素之後值的串列。" -#: ../../library/ast.rst:563 +#: ../../library/ast.rst:625 msgid "" ">>> print(ast.dump(ast.parse('1 <= a < 10', mode='eval'), indent=4))\n" "Expression(\n" @@ -1085,11 +1195,11 @@ msgstr "" " Name(id='a', ctx=Load()),\n" " Constant(value=10)]))" -#: ../../library/ast.rst:588 +#: ../../library/ast.rst:650 msgid "Comparison operator tokens." msgstr "比較運算子 token。" -#: ../../library/ast.rst:593 +#: ../../library/ast.rst:655 msgid "" "A function call. ``func`` is the function, which will often be a :class:" "`Name` or :class:`Attribute` object. Of the arguments:" @@ -1097,24 +1207,24 @@ msgstr "" "一個函式呼叫。``func`` 是該函式,通常是一個 :class:`Name` 或 :class:" "`Attribute` 物件。而在引數中:" -#: ../../library/ast.rst:596 +#: ../../library/ast.rst:658 msgid "``args`` holds a list of the arguments passed by position." msgstr "``args`` 保存按位置傳遞的引數串列。" -#: ../../library/ast.rst:597 +#: ../../library/ast.rst:659 msgid "" "``keywords`` holds a list of :class:`.keyword` objects representing " "arguments passed by keyword." msgstr "" "``keywords`` 保存一個 :class:`.keyword` 物件串列,表示透過關鍵字傳遞的引數。" -#: ../../library/ast.rst:600 +#: ../../library/ast.rst:662 msgid "" "The ``args`` and ``keywords`` arguments are optional and default to empty " "lists." msgstr "``args`` 和 ``keywords`` 引數是可選的,預設為空串列。" -#: ../../library/ast.rst:602 +#: ../../library/ast.rst:664 msgid "" ">>> print(ast.dump(ast.parse('func(a, b=c, *d, **e)', mode='eval'), " "indent=4))\n" @@ -1150,7 +1260,7 @@ msgstr "" " keyword(\n" " value=Name(id='e', ctx=Load()))]))" -#: ../../library/ast.rst:623 +#: ../../library/ast.rst:685 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." @@ -1158,7 +1268,7 @@ msgstr "" "函式呼叫或類別定義的關鍵字引數。``arg`` 是參數名稱的原始字串,``value`` 是要" "傳入的節點。" -#: ../../library/ast.rst:629 +#: ../../library/ast.rst:691 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." @@ -1166,7 +1276,7 @@ msgstr "" "像是 ``a if b else c`` 之類的運算式。每個欄位都保存一個節點,因此在以下範例" "中,所有三個都是 :class:`Name` 節點。" -#: ../../library/ast.rst:632 +#: ../../library/ast.rst:694 msgid "" ">>> print(ast.dump(ast.parse('a if b else c', mode='eval'), indent=4))\n" "Expression(\n" @@ -1182,7 +1292,7 @@ msgstr "" " body=Name(id='a', ctx=Load()),\n" " orelse=Name(id='c', ctx=Load())))" -#: ../../library/ast.rst:644 +#: ../../library/ast.rst:706 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 " @@ -1193,7 +1303,7 @@ msgstr "" "``attr`` 是一個屬性名稱的字串,``ctx`` 根據屬性的作用方式可能是 :class:" "`Load`、:class:`Store` 或 :class:`Del`。" -#: ../../library/ast.rst:649 +#: ../../library/ast.rst:711 msgid "" ">>> print(ast.dump(ast.parse('snake.colour', mode='eval'), indent=4))\n" "Expression(\n" @@ -1209,7 +1319,7 @@ msgstr "" " attr='colour',\n" " ctx=Load()))" -#: ../../library/ast.rst:661 +#: ../../library/ast.rst:723 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:" @@ -1220,7 +1330,7 @@ msgstr "" "運算子)產生。相對於 :class:`Assign` 節點之第一個引數可為多個節點,在這種情況" "下 ``target`` 和 ``value`` 都必須是單個節點。" -#: ../../library/ast.rst:666 +#: ../../library/ast.rst:728 msgid "" ">>> print(ast.dump(ast.parse('(x := 4)', mode='eval'), indent=4))\n" "Expression(\n" @@ -1234,11 +1344,11 @@ msgstr "" " target=Name(id='x', ctx=Store()),\n" " value=Constant(value=4)))" -#: ../../library/ast.rst:677 +#: ../../library/ast.rst:739 msgid "Subscripting" msgstr "下標 (Subscripting)" -#: ../../library/ast.rst:681 +#: ../../library/ast.rst:743 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 :" @@ -1250,7 +1360,7 @@ msgstr "" "下標執行的操作不同,``ctx`` 可以是 :class:`Load`、:class:`Store` 或 :class:" "`Del`。" -#: ../../library/ast.rst:687 +#: ../../library/ast.rst:749 msgid "" ">>> print(ast.dump(ast.parse('l[1:2, 3]', mode='eval'), indent=4))\n" "Expression(\n" @@ -1278,16 +1388,16 @@ msgstr "" " ctx=Load()),\n" " ctx=Load()))" -#: ../../library/ast.rst:705 +#: ../../library/ast.rst:767 msgid "" "Regular slicing (on the form ``lower:upper`` or ``lower:upper:step``). Can " "occur only inside the *slice* field of :class:`Subscript`, either directly " "or as an element of :class:`Tuple`." msgstr "" -"常規切片(形式為 ``lower:upper`` 或 ``lower:upper:step``\\ )。只能直接或者或" -"者作為 :class:`Tuple` 的元素出現在 :class:`Subscript` 的 *slice* 欄位內。" +"常規切片(形式為 ``lower:upper`` 或 ``lower:upper:step``)。只能直接或者或者" +"作為 :class:`Tuple` 的元素出現在 :class:`Subscript` 的 *slice* 欄位內。" -#: ../../library/ast.rst:709 +#: ../../library/ast.rst:771 msgid "" ">>> print(ast.dump(ast.parse('l[1:2]', mode='eval'), indent=4))\n" "Expression(\n" @@ -1307,24 +1417,24 @@ msgstr "" " upper=Constant(value=2)),\n" " ctx=Load()))" -#: ../../library/ast.rst:722 +#: ../../library/ast.rst:784 msgid "Comprehensions" msgstr "綜合運算式 (comprehensions)" -#: ../../library/ast.rst:729 +#: ../../library/ast.rst:791 msgid "" "List and set comprehensions, generator expressions, and dictionary " "comprehensions. ``elt`` (or ``key`` and ``value``) is a single node " "representing the part that will be evaluated for each item." msgstr "" "串列和集合綜合運算、生成器運算式和字典綜合運算。``elt``\\ (或 ``key`` 和 " -"``value``\\ )是單個節點,表示各個項目會被求值 (evaluate) 的部分。" +"``value``)是單個節點,表示各個項目會被求值 (evaluate) 的部分。" -#: ../../library/ast.rst:733 +#: ../../library/ast.rst:795 msgid "``generators`` is a list of :class:`comprehension` nodes." msgstr "``generators`` 是一個 :class:`comprehension` 節點的串列。" -#: ../../library/ast.rst:735 +#: ../../library/ast.rst:797 msgid "" ">>> print(ast.dump(\n" "... ast.parse('[x for x in numbers]', mode='eval'),\n" @@ -1408,7 +1518,7 @@ msgstr "" " iter=Name(id='numbers', ctx=Load()),\n" " is_async=0)]))" -#: ../../library/ast.rst:781 +#: ../../library/ast.rst:843 msgid "" "One ``for`` clause in a comprehension. ``target`` is the reference to use " "for each element - typically a :class:`Name` or :class:`Tuple` node. " @@ -1419,7 +1529,7 @@ msgstr "" "class:`Name` 或 :class:`Tuple` 節點。``iter`` 是要疊代的物件。``ifs`` 是測試" "運算式的串列:每個 ``for`` 子句可以有多個 ``ifs``。" -#: ../../library/ast.rst:786 +#: ../../library/ast.rst:848 msgid "" "``is_async`` indicates a comprehension is asynchronous (using an ``async " "for`` instead of ``for``). The value is an integer (0 or 1)." @@ -1427,7 +1537,7 @@ msgstr "" "``is_async`` 表示綜合運算式是非同步的(使用 ``async for`` 而不是 ``for`` )。" "該值為整數(0 或 1)。" -#: ../../library/ast.rst:789 +#: ../../library/ast.rst:851 msgid "" ">>> print(ast.dump(ast.parse('[ord(c) for line in file for c in line]', " "mode='eval'),\n" @@ -1545,17 +1655,17 @@ msgstr "" " iter=Name(id='soc', ctx=Load()),\n" " is_async=1)]))" -#: ../../library/ast.rst:851 +#: ../../library/ast.rst:913 msgid "Statements" msgstr "陳述式" -#: ../../library/ast.rst:855 +#: ../../library/ast.rst:917 msgid "" "An assignment. ``targets`` is a list of nodes, and ``value`` is a single " "node." msgstr "一個賦值。``targets`` 是節點串列,``value`` 是單個節點。" -#: ../../library/ast.rst:857 +#: ../../library/ast.rst:919 msgid "" "Multiple nodes in ``targets`` represents assigning the same value to each. " "Unpacking is represented by putting a :class:`Tuple` or :class:`List` within " @@ -1564,13 +1674,13 @@ msgstr "" "``targets`` 中的多個節點表示為每個節點分配相同的值。解包是透過在 ``targets`` " "中放置一個 :class:`Tuple` 或 :class:`List` 來表示的。" -#: ../../library/ast.rst:863 ../../library/ast.rst:1158 -#: ../../library/ast.rst:1352 ../../library/ast.rst:1918 +#: ../../library/ast.rst:925 ../../library/ast.rst:1220 +#: ../../library/ast.rst:1414 ../../library/ast.rst:1980 msgid "" "``type_comment`` is an optional string with the type annotation as a comment." msgstr "``type_comment`` 是一個可選字串,其中的註解為型別註釋。" -#: ../../library/ast.rst:865 +#: ../../library/ast.rst:927 msgid "" ">>> print(ast.dump(ast.parse('a = b = 1'), indent=4)) # Multiple assignment\n" "Module(\n" @@ -1614,7 +1724,7 @@ msgstr "" " ctx=Store())],\n" " value=Name(id='c', ctx=Load()))])" -#: ../../library/ast.rst:891 +#: ../../library/ast.rst:953 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`. " @@ -1625,7 +1735,7 @@ msgstr "" "`Attribute` 或 :class:`Subscript`。``annotation`` 是註釋,例如 :class:" "`Constant` 或 :class:`Name` 節點。``value`` 是單個可選節點。" -#: ../../library/ast.rst:896 +#: ../../library/ast.rst:958 msgid "" "``simple`` is always either 0 (indicating a \"complex\" target) or 1 " "(indicating a \"simple\" target). A \"simple\" target consists solely of a :" @@ -1638,7 +1748,7 @@ msgstr "" "被視為是複雜的。只有簡單目標會出現在模組和類別的 :attr:`~object." "__annotations__` 字典中。" -#: ../../library/ast.rst:902 +#: ../../library/ast.rst:964 msgid "" ">>> print(ast.dump(ast.parse('c: int'), indent=4))\n" "Module(\n" @@ -1722,7 +1832,7 @@ msgstr "" " annotation=Name(id='int', ctx=Load()),\n" " simple=0)])" -#: ../../library/ast.rst:946 +#: ../../library/ast.rst:1008 msgid "" "Augmented assignment, such as ``a += 1``. In the following example, " "``target`` is a :class:`Name` node for ``x`` (with the :class:`Store` " @@ -1733,7 +1843,7 @@ msgstr "" "是 ``x`` 的 :class:`Name` 節點(帶有 :class:`Store` 情境),``op`` 是 :class:" "`Add`,``value`` 是一個值為 1 的 :class:`Constant`。" -#: ../../library/ast.rst:951 +#: ../../library/ast.rst:1013 msgid "" "The ``target`` attribute cannot be of class :class:`Tuple` or :class:`List`, " "unlike the targets of :class:`Assign`." @@ -1741,7 +1851,7 @@ msgstr "" "與 :class:`Assign` 的目標不同,``target`` 屬性不能屬於 :class:`Tuple` 或 :" "class:`List` 類別。" -#: ../../library/ast.rst:954 +#: ../../library/ast.rst:1016 msgid "" ">>> print(ast.dump(ast.parse('x += 2'), indent=4))\n" "Module(\n" @@ -1759,7 +1869,7 @@ msgstr "" " op=Add(),\n" " value=Constant(value=2))])" -#: ../../library/ast.rst:967 +#: ../../library/ast.rst:1029 msgid "" "A ``raise`` statement. ``exc`` is the exception object to be raised, " "normally a :class:`Call` or :class:`Name`, or ``None`` for a standalone " @@ -1769,7 +1879,7 @@ msgstr "" "class:`Name`,若是獨立的 ``raise`` 則為 ``None``。``cause`` 是 ``raise x " "from y`` 中的可選部分 ``y``。" -#: ../../library/ast.rst:971 +#: ../../library/ast.rst:1033 msgid "" ">>> print(ast.dump(ast.parse('raise x from y'), indent=4))\n" "Module(\n" @@ -1785,7 +1895,7 @@ msgstr "" " exc=Name(id='x', ctx=Load()),\n" " cause=Name(id='y', ctx=Load()))])" -#: ../../library/ast.rst:983 +#: ../../library/ast.rst:1045 msgid "" "An assertion. ``test`` holds the condition, such as a :class:`Compare` node. " "``msg`` holds the failure message." @@ -1793,7 +1903,7 @@ msgstr "" "一個斷言 (assertion)。``test`` 保存條件,例如 :class:`Compare` 節點。``msg`` " "保存失敗訊息。" -#: ../../library/ast.rst:986 +#: ../../library/ast.rst:1048 msgid "" ">>> print(ast.dump(ast.parse('assert x,y'), indent=4))\n" "Module(\n" @@ -1809,7 +1919,7 @@ msgstr "" " test=Name(id='x', ctx=Load()),\n" " msg=Name(id='y', ctx=Load()))])" -#: ../../library/ast.rst:998 +#: ../../library/ast.rst:1060 msgid "" "Represents a ``del`` statement. ``targets`` is a list of nodes, such as :" "class:`Name`, :class:`Attribute` or :class:`Subscript` nodes." @@ -1817,7 +1927,7 @@ msgstr "" "代表一個 ``del`` 陳述式。``targets`` 是節點串列,例如 :class:`Name`、:class:" "`Attribute` 或 :class:`Subscript` 節點。" -#: ../../library/ast.rst:1001 +#: ../../library/ast.rst:1063 msgid "" ">>> print(ast.dump(ast.parse('del x,y,z'), indent=4))\n" "Module(\n" @@ -1837,11 +1947,11 @@ msgstr "" " Name(id='y', ctx=Del()),\n" " Name(id='z', ctx=Del())])])" -#: ../../library/ast.rst:1015 +#: ../../library/ast.rst:1077 msgid "A ``pass`` statement." msgstr "一個 ``pass`` 陳述式。" -#: ../../library/ast.rst:1017 +#: ../../library/ast.rst:1079 msgid "" ">>> print(ast.dump(ast.parse('pass'), indent=4))\n" "Module(\n" @@ -1853,7 +1963,7 @@ msgstr "" " body=[\n" " Pass()])" -#: ../../library/ast.rst:1027 +#: ../../library/ast.rst:1089 msgid "" "A :ref:`type alias ` created through the :keyword:`type` " "statement. ``name`` is the name of the alias, ``type_params`` is a list of :" @@ -1864,7 +1974,7 @@ msgstr "" "aliases>`。``name`` 是別名的名稱、``type_params`` 是\\ :ref:`型別參數 (type " "parameter) ` 的串列、``value`` 是型別別名的值。" -#: ../../library/ast.rst:1032 +#: ../../library/ast.rst:1094 msgid "" ">>> print(ast.dump(ast.parse('type Alias = int'), indent=4))\n" "Module(\n" @@ -1880,21 +1990,21 @@ msgstr "" " name=Name(id='Alias', ctx=Store()),\n" " value=Name(id='int', ctx=Load()))])" -#: ../../library/ast.rst:1043 +#: ../../library/ast.rst:1105 msgid "" "Other statements which are only applicable inside functions or loops are " "described in other sections." msgstr "其他僅適用於函式或迴圈內部的陳述式將在其他部分中描述。" -#: ../../library/ast.rst:1047 +#: ../../library/ast.rst:1109 msgid "Imports" msgstr "引入 (imports)" -#: ../../library/ast.rst:1051 +#: ../../library/ast.rst:1113 msgid "An import statement. ``names`` is a list of :class:`alias` nodes." msgstr "一個 import 陳述式。``names`` 是 :class:`alias` 節點的串列。" -#: ../../library/ast.rst:1053 +#: ../../library/ast.rst:1115 msgid "" ">>> print(ast.dump(ast.parse('import x,y,z'), indent=4))\n" "Module(\n" @@ -1914,7 +2024,7 @@ msgstr "" " alias(name='y'),\n" " alias(name='z')])])" -#: ../../library/ast.rst:1067 +#: ../../library/ast.rst:1129 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 . " @@ -1925,7 +2035,7 @@ msgstr "" "點 (dot),或者對於諸如 ``from . import foo`` 之類的陳述式則為 ``None``。" "``level`` 是一個整數,保存相對引入的級別(0 表示絕對引入)。" -#: ../../library/ast.rst:1072 +#: ../../library/ast.rst:1134 msgid "" ">>> print(ast.dump(ast.parse('from y import x,y,z'), indent=4))\n" "Module(\n" @@ -1949,7 +2059,7 @@ msgstr "" " alias(name='z')],\n" " level=0)])" -#: ../../library/ast.rst:1088 +#: ../../library/ast.rst:1150 msgid "" "Both parameters are raw strings of the names. ``asname`` can be ``None`` if " "the regular name is to be used." @@ -1957,7 +2067,7 @@ msgstr "" "這兩個參數都是名稱的原始字串。如果要使用常規名稱,``asname`` 可以為 " "``None``。" -#: ../../library/ast.rst:1091 +#: ../../library/ast.rst:1153 msgid "" ">>> print(ast.dump(ast.parse('from ..foo.bar import a as b, c'), indent=4))\n" "Module(\n" @@ -1979,17 +2089,17 @@ msgstr "" " alias(name='c')],\n" " level=2)])" -#: ../../library/ast.rst:1104 +#: ../../library/ast.rst:1166 msgid "Control flow" msgstr "流程控制" -#: ../../library/ast.rst:1107 +#: ../../library/ast.rst:1169 msgid "" "Optional clauses such as ``else`` are stored as an empty list if they're not " "present." msgstr "諸如 ``else`` 之類的可選子句如果不存在,則將被儲存為空串列。" -#: ../../library/ast.rst:1112 +#: ../../library/ast.rst:1174 msgid "" "An ``if`` statement. ``test`` holds a single node, such as a :class:" "`Compare` node. ``body`` and ``orelse`` each hold a list of nodes." @@ -1997,7 +2107,7 @@ msgstr "" "一個 ``if`` 陳述式。``test`` 保存單個節點,例如 :class:`Compare` 節點。" "``body`` 和 ``orelse`` 各自保存一個節點串列。" -#: ../../library/ast.rst:1115 +#: ../../library/ast.rst:1177 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 " @@ -2006,7 +2116,7 @@ msgstr "" "``elif`` 子句在 AST 中沒有特殊表示,而是在前一個子句的 ``orelse`` 部分中作為" "額外的 :class:`If` 節點出現。" -#: ../../library/ast.rst:1119 +#: ../../library/ast.rst:1181 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... if x:\n" @@ -2058,7 +2168,7 @@ msgstr "" " Expr(\n" " value=Constant(value=Ellipsis))])])])" -#: ../../library/ast.rst:1149 +#: ../../library/ast.rst:1211 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 :" @@ -2073,7 +2183,7 @@ msgstr "" "行的節點串列。如果迴圈正常完成,則執行 ``orelse`` 中的內容,而不是透過 " "``break`` 陳述式執行。" -#: ../../library/ast.rst:1160 +#: ../../library/ast.rst:1222 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... for x in y:\n" @@ -2111,13 +2221,13 @@ msgstr "" " Expr(\n" " value=Constant(value=Ellipsis))])])" -#: ../../library/ast.rst:1183 +#: ../../library/ast.rst:1245 msgid "" "A ``while`` loop. ``test`` holds the condition, such as a :class:`Compare` " "node." msgstr "一個 ``while`` 迴圈。``test`` 保存條件,例如 :class:`Compare` 節點。" -#: ../../library/ast.rst:1186 +#: ../../library/ast.rst:1248 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... while x:\n" @@ -2153,11 +2263,11 @@ msgstr "" " Expr(\n" " value=Constant(value=Ellipsis))])])" -#: ../../library/ast.rst:1209 +#: ../../library/ast.rst:1271 msgid "The ``break`` and ``continue`` statements." msgstr "``break`` 和 ``continue`` 陳述式。" -#: ../../library/ast.rst:1211 +#: ../../library/ast.rst:1273 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\\\n" "... for a in b:\n" @@ -2211,7 +2321,7 @@ msgstr "" " orelse=[\n" " Continue()])])])" -#: ../../library/ast.rst:1242 +#: ../../library/ast.rst:1304 msgid "" "``try`` blocks. All attributes are list of nodes to execute, except for " "``handlers``, which is a list of :class:`ExceptHandler` nodes." @@ -2219,7 +2329,7 @@ msgstr "" "``try`` 區塊。除 ``handlers`` 是 :class:`ExceptHandler` 節點的串列外,其他所" "有屬性都是要執行之節點的串列。" -#: ../../library/ast.rst:1245 +#: ../../library/ast.rst:1307 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... try:\n" @@ -2295,7 +2405,7 @@ msgstr "" " Expr(\n" " value=Constant(value=Ellipsis))])])" -#: ../../library/ast.rst:1287 +#: ../../library/ast.rst:1349 msgid "" "``try`` blocks which are followed by ``except*`` clauses. The attributes are " "the same as for :class:`Try` but the :class:`ExceptHandler` nodes in " @@ -2305,7 +2415,7 @@ msgstr "" "``handlers`` 中的 :class:`ExceptHandler` 節點被直譯 (interpret) 為 " "``except*`` 區塊而不是 ``except``。" -#: ../../library/ast.rst:1291 +#: ../../library/ast.rst:1353 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... try:\n" @@ -2345,7 +2455,7 @@ msgstr "" " Expr(\n" " value=Constant(value=Ellipsis))])])])" -#: ../../library/ast.rst:1316 +#: ../../library/ast.rst:1378 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:`` " @@ -2357,7 +2467,7 @@ msgstr "" "``name`` 是用於保存例外的名稱之原始字串,如果子句沒有 ``as foo`` ,則為 " "``None``。``body`` 是節點串列。" -#: ../../library/ast.rst:1321 +#: ../../library/ast.rst:1383 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\\\n" "... try:\n" @@ -2401,7 +2511,7 @@ msgstr "" " body=[\n" " Pass()])])])" -#: ../../library/ast.rst:1347 +#: ../../library/ast.rst:1409 msgid "" "A ``with`` block. ``items`` is a list of :class:`withitem` nodes " "representing the context managers, and ``body`` is the indented block inside " @@ -2410,7 +2520,7 @@ msgstr "" "一個 ``with`` 區塊。``items`` 是表示情境管理器的 :class:`withitem` 節點串列," "``body`` 是情境內的縮進區塊。" -#: ../../library/ast.rst:1357 +#: ../../library/ast.rst:1419 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:" @@ -2421,7 +2531,7 @@ msgstr "" "class:`Call` 節點。``Optional_vars`` 是 ``as foo`` 部分的 :class:`Name`、:" "class:`Tuple` 或 :class:`List`,或者如果不使用則為 ``None`` 。" -#: ../../library/ast.rst:1362 +#: ../../library/ast.rst:1424 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\\\n" "... with a as b, c as d:\n" @@ -2467,11 +2577,11 @@ msgstr "" " Name(id='b', ctx=Load()),\n" " Name(id='d', ctx=Load())]))])])" -#: ../../library/ast.rst:1388 +#: ../../library/ast.rst:1450 msgid "Pattern matching" msgstr "模式匹配 (pattern matching)" -#: ../../library/ast.rst:1393 +#: ../../library/ast.rst:1455 msgid "" "A ``match`` statement. ``subject`` holds the subject of the match (the " "object that is being matched against the cases) and ``cases`` contains an " @@ -2480,7 +2590,7 @@ msgstr "" "一個 ``match`` 陳述式。``subject`` 保存匹配的主題(與案例匹配的物件)," "``cases`` 包含具有不同案例的 :class:`match_case` 節點的可疊代物件。" -#: ../../library/ast.rst:1401 +#: ../../library/ast.rst:1463 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:" @@ -2491,13 +2601,13 @@ msgstr "" "請注意,為模式生成的 :class:`AST` 節點與為運算式生成的節點不同,即使它們共享" "相同的語法。" -#: ../../library/ast.rst:1406 +#: ../../library/ast.rst:1468 msgid "" "The ``guard`` attribute contains an expression that will be evaluated if the " "pattern matches the subject." msgstr "``guard`` 屬性包含一個運算式,如果模式與主題匹配,則將對該運算式求值。" -#: ../../library/ast.rst:1409 +#: ../../library/ast.rst:1471 msgid "" "``body`` contains a list of nodes to execute if the pattern matches and the " "result of evaluating the guard expression is true." @@ -2505,7 +2615,7 @@ msgstr "" "``body`` 包含一個節點串列,如果模式匹配並且為防護運算式 (guard expression) 的" "求值 (evaluate) 結果為真,則會執行該節點串列。" -#: ../../library/ast.rst:1412 +#: ../../library/ast.rst:1474 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... match x:\n" @@ -2571,7 +2681,7 @@ msgstr "" " Expr(\n" " value=Constant(value=Ellipsis))])])])" -#: ../../library/ast.rst:1450 +#: ../../library/ast.rst:1512 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 " @@ -2581,7 +2691,7 @@ msgstr "" "以相等性進行比較的匹配文本或值的模式。``value`` 是一個運算式節點。允許值節點" "受到匹配陳述式文件中所述的限制。如果匹配主題等於求出值,則此模式成功。" -#: ../../library/ast.rst:1455 +#: ../../library/ast.rst:1517 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... match x:\n" @@ -2617,7 +2727,7 @@ msgstr "" " Expr(\n" " value=Constant(value=Ellipsis))])])])" -#: ../../library/ast.rst:1478 +#: ../../library/ast.rst:1540 msgid "" "A match literal pattern that compares by identity. ``value`` is the " "singleton to be compared against: ``None``, ``True``, or ``False``. This " @@ -2627,7 +2737,7 @@ msgstr "" "``True`` 或 ``False`` 進行比較的單例 (singleton)。如果匹配主題是給定的常數," "則此模式成功。" -#: ../../library/ast.rst:1482 +#: ../../library/ast.rst:1544 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... match x:\n" @@ -2661,7 +2771,7 @@ msgstr "" " Expr(\n" " value=Constant(value=Ellipsis))])])])" -#: ../../library/ast.rst:1504 +#: ../../library/ast.rst:1566 msgid "" "A match sequence pattern. ``patterns`` contains the patterns to be matched " "against the subject elements if the subject is a sequence. Matches a " @@ -2671,7 +2781,7 @@ msgstr "" "匹配序列模式。如果主題是一個序列,``patterns`` 包含與主題元素匹配的模式。如果" "子模式之一是 ``MatchStar`` 節點,則匹配可變長度序列,否則匹配固定長度序列。" -#: ../../library/ast.rst:1509 +#: ../../library/ast.rst:1571 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... match x:\n" @@ -2715,7 +2825,7 @@ msgstr "" " Expr(\n" " value=Constant(value=Ellipsis))])])])" -#: ../../library/ast.rst:1536 +#: ../../library/ast.rst:1598 msgid "" "Matches the rest of the sequence in a variable length match sequence " "pattern. If ``name`` is not ``None``, a list containing the remaining " @@ -2725,7 +2835,7 @@ msgstr "" "以可變長度匹配序列模式匹配序列的其餘部分。如果 ``name`` 不是 ``None``,則如果" "整體序列模式成功,則包含其餘序列元素的串列將綁定到該名稱。" -#: ../../library/ast.rst:1540 +#: ../../library/ast.rst:1602 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... match x:\n" @@ -2789,7 +2899,7 @@ msgstr "" " Expr(\n" " value=Constant(value=Ellipsis))])])])" -#: ../../library/ast.rst:1577 +#: ../../library/ast.rst:1639 msgid "" "A match mapping pattern. ``keys`` is a sequence of expression nodes. " "``patterns`` is a corresponding sequence of pattern nodes. ``rest`` is an " @@ -2801,7 +2911,7 @@ msgstr "" "列。``rest`` 是一個可選名稱,可以指定它來捕獲剩餘的對映元素。允許的鍵運算式受" "到匹配陳述式文件中所述的限制。" -#: ../../library/ast.rst:1583 +#: ../../library/ast.rst:1645 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 " @@ -2813,7 +2923,7 @@ msgstr "" "應的子模式匹配,則此模式成功。如果 ``rest`` 不是 ``None``,則如果整體對映模式" "成功,則包含其餘對映元素的字典將綁定到該名稱。" -#: ../../library/ast.rst:1589 +#: ../../library/ast.rst:1651 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... match x:\n" @@ -2873,7 +2983,7 @@ msgstr "" " Expr(\n" " value=Constant(value=Ellipsis))])])])" -#: ../../library/ast.rst:1624 +#: ../../library/ast.rst:1686 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 " @@ -2888,7 +2998,7 @@ msgstr "" "``kwd_attrs`` 是要匹配的附加屬性序列(在類別模式中指定為關鍵字引數)," "``kwd_patterns`` 是相應的模式(在類別模式中指定為關鍵字的值)。" -#: ../../library/ast.rst:1631 +#: ../../library/ast.rst:1693 msgid "" "This pattern succeeds if the subject is an instance of the nominated class, " "all positional patterns match the corresponding class-defined attributes, " @@ -2897,7 +3007,7 @@ msgstr "" "如果主題是指定類別的實例,所有位置模式都與相應的類別定義屬性匹配,並且任何指" "定的關鍵字屬性與其相應模式匹配,則此模式成功。" -#: ../../library/ast.rst:1635 +#: ../../library/ast.rst:1697 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 " @@ -2906,7 +3016,7 @@ msgstr "" "注意:類別可以定義一個回傳 self 的特性 (property),以便將模式節點與正在匹配的" "實例進行匹配。一些內建型別也以這種方式匹配,如同匹配陳述式文件中所述。" -#: ../../library/ast.rst:1639 +#: ../../library/ast.rst:1701 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... match x:\n" @@ -2990,7 +3100,7 @@ msgstr "" " Expr(\n" " value=Constant(value=Ellipsis))])])])" -#: ../../library/ast.rst:1686 +#: ../../library/ast.rst:1748 msgid "" "A match \"as-pattern\", capture pattern or wildcard pattern. ``pattern`` " "contains the match pattern that the subject will be matched against. If the " @@ -3001,7 +3111,7 @@ msgstr "" "(wildcard pattern)。``pattern`` 包含主題將與之匹配的匹配模式。如果模式為 " "``None``,則該節點代表捕獲模式(即裸名 (bare name))並且始終會成功。" -#: ../../library/ast.rst:1691 +#: ../../library/ast.rst:1753 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`` " @@ -3010,7 +3120,7 @@ msgstr "" "``name`` 屬性包含模式成功時將綁定的名稱。如果 ``name`` 為 ``None``,則 " "``pattern`` 也必須為 ``None``,並且節點代表通配模式。" -#: ../../library/ast.rst:1695 +#: ../../library/ast.rst:1757 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... match x:\n" @@ -3066,7 +3176,7 @@ msgstr "" " Expr(\n" " value=Constant(value=Ellipsis))])])])" -#: ../../library/ast.rst:1728 +#: ../../library/ast.rst:1790 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 " @@ -3078,7 +3188,7 @@ msgstr "" "到成功為止,然後 or 模式就會被認為是成功的。如果沒有一個子模式成功,則 or 模" "式將失敗。 ``patterns`` 屬性包含將與主題進行匹配的匹配模式節點串列。" -#: ../../library/ast.rst:1734 +#: ../../library/ast.rst:1796 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... match x:\n" @@ -3122,17 +3232,17 @@ msgstr "" " Expr(\n" " value=Constant(value=Ellipsis))])])])" -#: ../../library/ast.rst:1761 +#: ../../library/ast.rst:1823 msgid "Type annotations" msgstr "" -#: ../../library/ast.rst:1765 +#: ../../library/ast.rst:1827 msgid "" "A ``# type: ignore`` comment located at *lineno*. *tag* is the optional tag " "specified by the form ``# type: ignore ``." msgstr "" -#: ../../library/ast.rst:1768 +#: ../../library/ast.rst:1830 msgid "" ">>> print(ast.dump(ast.parse('x = 1 # type: ignore', type_comments=True), " "indent=4))\n" @@ -3178,24 +3288,24 @@ msgstr "" " type_ignores=[\n" " TypeIgnore(lineno=1, tag='[assignment]')])" -#: ../../library/ast.rst:1791 +#: ../../library/ast.rst:1853 msgid "" ":class:`!TypeIgnore` nodes are not generated when the *type_comments* " "parameter is set to ``False`` (default). See :func:`ast.parse` for more " "details." msgstr "" -#: ../../library/ast.rst:1799 +#: ../../library/ast.rst:1861 msgid "Type parameters" msgstr "型別參數 (type parameters)" -#: ../../library/ast.rst:1801 +#: ../../library/ast.rst:1863 msgid "" ":ref:`Type parameters ` can exist on classes, functions, and " "type aliases." msgstr ":ref:`型別參數 `\\ 可以存在於類別、函式和型別別名上。" -#: ../../library/ast.rst:1806 +#: ../../library/ast.rst:1868 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:" @@ -3208,7 +3318,7 @@ msgstr "" "`Tuple`,它代表約束;否則它代表界限。``default_value`` 為預設值;如果 :class:" "`!TypeVar` 沒有預設值,那此屬性會被設為 ``None``。" -#: ../../library/ast.rst:1812 +#: ../../library/ast.rst:1874 msgid "" ">>> print(ast.dump(ast.parse(\"type Alias[T: int = bool] = list[T]\"), " "indent=4))\n" @@ -3242,12 +3352,12 @@ msgstr "" " slice=Name(id='T', ctx=Load()),\n" " ctx=Load()))])" -#: ../../library/ast.rst:1831 ../../library/ast.rst:1866 -#: ../../library/ast.rst:1898 +#: ../../library/ast.rst:1893 ../../library/ast.rst:1928 +#: ../../library/ast.rst:1960 msgid "Added the *default_value* parameter." msgstr "新增 *default_value* 參數。" -#: ../../library/ast.rst:1836 +#: ../../library/ast.rst:1898 msgid "" "A :class:`typing.ParamSpec`. ``name`` is the name of the parameter " "specification. ``default_value`` is the default value; if the :class:`!" @@ -3256,7 +3366,7 @@ msgstr "" "一個 :class:`typing.ParamSpec`。``name`` 是參數規範的名稱。``default_value`` " "是預設值;如果 :class:`!ParamSpec` 沒有預設值,則該屬性將設定為 ``None``。" -#: ../../library/ast.rst:1840 +#: ../../library/ast.rst:1902 msgid "" ">>> print(ast.dump(ast.parse(\"type Alias[**P = [int, str]] = Callable[P, " "int]\"), indent=4))\n" @@ -3304,7 +3414,7 @@ msgstr "" " ctx=Load()),\n" " ctx=Load()))])" -#: ../../library/ast.rst:1871 +#: ../../library/ast.rst:1933 msgid "" "A :class:`typing.TypeVarTuple`. ``name`` is the name of the type variable " "tuple. ``default_value`` is the default value; if the :class:`!TypeVarTuple` " @@ -3314,7 +3424,7 @@ msgstr "" "``default_value`` 為預設值;如果 :class:`!TypeVarTuple` 沒有預設值,那此屬性" "會被設為 ``None``。" -#: ../../library/ast.rst:1875 +#: ../../library/ast.rst:1937 msgid "" ">>> print(ast.dump(ast.parse(\"type Alias[*Ts = ()] = tuple[*Ts]\"), " "indent=4))\n" @@ -3356,27 +3466,27 @@ msgstr "" " ctx=Load()),\n" " ctx=Load()))])" -#: ../../library/ast.rst:1902 +#: ../../library/ast.rst:1964 msgid "Function and class definitions" msgstr "函式和類別定義" -#: ../../library/ast.rst:1906 +#: ../../library/ast.rst:1968 msgid "A function definition." msgstr "一個函式定義。" -#: ../../library/ast.rst:1908 +#: ../../library/ast.rst:1970 msgid "``name`` is a raw string of the function name." msgstr "``name`` 是函式名稱的原始字串。" -#: ../../library/ast.rst:1909 +#: ../../library/ast.rst:1971 msgid "``args`` is an :class:`arguments` node." msgstr "``args`` 是一個 :class:`arguments` 節點。" -#: ../../library/ast.rst:1910 +#: ../../library/ast.rst:1972 msgid "``body`` is the list of nodes inside the function." msgstr "``body`` 是函式內節點的串列。" -#: ../../library/ast.rst:1911 +#: ../../library/ast.rst:1973 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)." @@ -3384,20 +3494,20 @@ msgstr "" "``decorator_list`` 是要應用的裝飾器串列,在最外層者會被儲存在首位(即串列中首" "位將會是最後一個被應用的那個)。" -#: ../../library/ast.rst:1913 +#: ../../library/ast.rst:1975 msgid "``returns`` is the return annotation." msgstr "``returns`` 是回傳註釋。" -#: ../../library/ast.rst:1914 ../../library/ast.rst:2077 +#: ../../library/ast.rst:1976 ../../library/ast.rst:2139 msgid "``type_params`` is a list of :ref:`type parameters `." msgstr "``type_params`` 是\\ :ref:`型別參數 `\\ 的串列。" -#: ../../library/ast.rst:1920 ../../library/ast.rst:2104 -#: ../../library/ast.rst:2115 +#: ../../library/ast.rst:1982 ../../library/ast.rst:2166 +#: ../../library/ast.rst:2177 msgid "Added ``type_params``." msgstr "新增了 ``type_params``。" -#: ../../library/ast.rst:1926 +#: ../../library/ast.rst:1988 msgid "" "``lambda`` is a minimal function definition that can be used inside an " "expression. Unlike :class:`FunctionDef`, ``body`` holds a single node." @@ -3405,7 +3515,7 @@ msgstr "" "``lambda`` 是可以在運算式內使用的最小函式定義。與 :class:`FunctionDef` 不同," "``body`` 保存單個節點。" -#: ../../library/ast.rst:1929 +#: ../../library/ast.rst:1991 msgid "" ">>> print(ast.dump(ast.parse('lambda x,y: ...'), indent=4))\n" "Module(\n" @@ -3429,17 +3539,17 @@ msgstr "" " arg(arg='y')]),\n" " body=Constant(value=Ellipsis)))])" -#: ../../library/ast.rst:1945 +#: ../../library/ast.rst:2007 msgid "The arguments for a function." msgstr "函式的引數。" -#: ../../library/ast.rst:1947 +#: ../../library/ast.rst:2009 msgid "" "``posonlyargs``, ``args`` and ``kwonlyargs`` are lists of :class:`arg` nodes." msgstr "" "``posonlyargs``、``args`` 和 ``kwonlyargs`` 是 :class:`arg` 節點的串列。" -#: ../../library/ast.rst:1948 +#: ../../library/ast.rst:2010 msgid "" "``vararg`` and ``kwarg`` are single :class:`arg` nodes, referring to the " "``*args, **kwargs`` parameters." @@ -3447,7 +3557,7 @@ msgstr "" "``vararg`` 和 ``kwarg`` 是單個 :class:`arg` 節點,指的是 ``*args, **kwargs`` " "參數。" -#: ../../library/ast.rst:1950 +#: ../../library/ast.rst:2012 msgid "" "``kw_defaults`` is a list of default values for keyword-only arguments. If " "one is ``None``, the corresponding argument is required." @@ -3455,7 +3565,7 @@ msgstr "" "``kw_defaults`` 是僅限關鍵字引數的預設值串列。如果其中某個為 ``None``,則相應" "參數就會是必要的。" -#: ../../library/ast.rst:1952 +#: ../../library/ast.rst:2014 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 " @@ -3464,7 +3574,7 @@ msgstr "" "``defaults`` 是可以按位置傳遞的引數的預設值串列。如果預設值較少,則它們對應於" "最後 n 個引數。" -#: ../../library/ast.rst:1959 +#: ../../library/ast.rst:2021 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." @@ -3472,12 +3582,12 @@ msgstr "" "串列中的單個引數。``arg`` 是引數名稱的原始字串,``annotation`` 是它的註釋,例" "如 :class:`Name` 節點。" -#: ../../library/ast.rst:1964 +#: ../../library/ast.rst:2026 msgid "" "``type_comment`` is an optional string with the type annotation as a comment" msgstr "``type_comment`` 是一個可選字串,其註解為型別註釋" -#: ../../library/ast.rst:1966 +#: ../../library/ast.rst:2028 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\\\n" "... @decorator1\n" @@ -3551,11 +3661,11 @@ msgstr "" " Name(id='decorator2', ctx=Load())],\n" " returns=Constant(value='return annotation'))])" -#: ../../library/ast.rst:2006 +#: ../../library/ast.rst:2068 msgid "A ``return`` statement." msgstr "一個 ``return`` 陳述式。" -#: ../../library/ast.rst:2008 +#: ../../library/ast.rst:2070 msgid "" ">>> print(ast.dump(ast.parse('return 4'), indent=4))\n" "Module(\n" @@ -3569,7 +3679,7 @@ msgstr "" " Return(\n" " value=Constant(value=4))])" -#: ../../library/ast.rst:2020 +#: ../../library/ast.rst:2082 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 " @@ -3578,7 +3688,7 @@ msgstr "" "一個 ``yield`` 或 ``yield from`` 運算式。因為這些是運算式,所以如果不使用發送" "回來的值,則必須將它們包裝在 :class:`Expr` 節點中。" -#: ../../library/ast.rst:2023 +#: ../../library/ast.rst:2085 msgid "" ">>> print(ast.dump(ast.parse('yield x'), indent=4))\n" "Module(\n" @@ -3608,12 +3718,12 @@ msgstr "" " value=YieldFrom(\n" " value=Name(id='x', ctx=Load())))])" -#: ../../library/ast.rst:2043 +#: ../../library/ast.rst:2105 msgid "" "``global`` and ``nonlocal`` statements. ``names`` is a list of raw strings." msgstr "``global`` 和 ``nonlocal`` 陳述式。``names`` 是原始字串的串列。" -#: ../../library/ast.rst:2045 +#: ../../library/ast.rst:2107 msgid "" ">>> print(ast.dump(ast.parse('global x,y,z'), indent=4))\n" "Module(\n" @@ -3651,19 +3761,19 @@ msgstr "" " 'y',\n" " 'z'])])" -#: ../../library/ast.rst:2068 +#: ../../library/ast.rst:2130 msgid "A class definition." msgstr "一個類別定義。" -#: ../../library/ast.rst:2070 +#: ../../library/ast.rst:2132 msgid "``name`` is a raw string for the class name" msgstr "``name`` 是類別名稱的原始字串" -#: ../../library/ast.rst:2071 +#: ../../library/ast.rst:2133 msgid "``bases`` is a list of nodes for explicitly specified base classes." msgstr "``bases`` 是被顯式指定的基底類別節點串列。" -#: ../../library/ast.rst:2072 +#: ../../library/ast.rst:2134 msgid "" "``keywords`` is a list of :class:`.keyword` nodes, principally for " "'metaclass'. Other keywords will be passed to the metaclass, as per :pep:" @@ -3672,17 +3782,17 @@ msgstr "" "``keywords`` 是一個 :class:`.keyword` 節點的串列,主要用於 'metaclass'(元類" "別)。如 :pep:`3115` 所述,其他關鍵字將被傳遞到 metaclass。" -#: ../../library/ast.rst:2074 +#: ../../library/ast.rst:2136 msgid "" "``body`` is a list of nodes representing the code within the class " "definition." msgstr "``body`` 是表示類別定義中程式碼的節點串列。" -#: ../../library/ast.rst:2076 +#: ../../library/ast.rst:2138 msgid "``decorator_list`` is a list of nodes, as in :class:`FunctionDef`." msgstr "``decorator_list`` 是一個節點串列,如 :class:`FunctionDef` 中所示。" -#: ../../library/ast.rst:2079 +#: ../../library/ast.rst:2141 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\\\n" "... @decorator1\n" @@ -3730,17 +3840,17 @@ msgstr "" " Name(id='decorator1', ctx=Load()),\n" " Name(id='decorator2', ctx=Load())])])" -#: ../../library/ast.rst:2108 +#: ../../library/ast.rst:2170 msgid "Async and await" msgstr "async 和 await" -#: ../../library/ast.rst:2112 +#: ../../library/ast.rst:2174 msgid "" "An ``async def`` function definition. Has the same fields as :class:" "`FunctionDef`." msgstr "一個 ``async def`` 函式定義。與 :class:`FunctionDef` 具有相同的欄位。" -#: ../../library/ast.rst:2121 +#: ../../library/ast.rst:2183 msgid "" "An ``await`` expression. ``value`` is what it waits for. Only valid in the " "body of an :class:`AsyncFunctionDef`." @@ -3748,7 +3858,7 @@ msgstr "" "一個 ``await`` 運算式。``value`` 是它等待的東西。僅在 :class:" "`AsyncFunctionDef` 主體 (body) 中有效。" -#: ../../library/ast.rst:2124 +#: ../../library/ast.rst:2186 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\\\n" "... async def f():\n" @@ -3780,7 +3890,7 @@ msgstr "" " value=Call(\n" " func=Name(id='other_func', ctx=Load()))))])])" -#: ../../library/ast.rst:2145 +#: ../../library/ast.rst:2207 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 " @@ -3789,24 +3899,24 @@ msgstr "" "``async for`` 迴圈和 ``async with`` 情境管理器。它們分別具有與 :class:`For` " "和 :class:`With` 相同的欄位。僅在 :class:`AsyncFunctionDef` 主體中有效。" -#: ../../library/ast.rst:2150 +#: ../../library/ast.rst:2212 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." "boolop` and :class:`ast.expr_context`) on the returned tree will be " "singletons. Changes to one will be reflected in all other occurrences of the " -"same value (e.g. :class:`ast.Add`)." +"same value (for example, :class:`ast.Add`)." msgstr "" -"當字串被 :func:`ast.parse` 剖析時,回傳樹的運算子節點(\\ :class:`ast." -"operator`、:class:`ast.unaryop`、:class:`ast.cmpop`、:class: :class:`ast." -"boolop` 和 :class:`ast.expr_context`\\ )將是單例。對其中之一的更改將反映在所" -"有其他出現的相同值中(例如 :class:`ast.Add`\\ )。" +"當字串被 :func:`ast.parse` 剖析時,回傳樹的運算子節點(:class:`ast." +"operator`、:class:`ast.unaryop`、:class:`ast.cmpop`、:class:`ast.boolop` 和 :" +"class:`ast.expr_context` 的子類別)將是單例。對其中之一的更改將反映在所有其他" +"出現的相同值中(例如 :class:`ast.Add`)。" -#: ../../library/ast.rst:2158 -msgid ":mod:`ast` Helpers" +#: ../../library/ast.rst:2220 +msgid ":mod:`ast` helpers" msgstr ":mod:`ast` 輔助程式" -#: ../../library/ast.rst:2160 +#: ../../library/ast.rst:2222 msgid "" "Apart from the node classes, the :mod:`ast` module defines these utility " "functions and classes for traversing abstract syntax trees:" @@ -3814,7 +3924,7 @@ msgstr "" "除了節點類別之外,:mod:`ast` 模組還定義了這些用於遍歷 (traverse) 抽象語法樹的" "實用函式和類別:" -#: ../../library/ast.rst:2165 +#: ../../library/ast.rst:2227 msgid "" "Parse the source into an AST node. Equivalent to ``compile(source, " "filename, mode, flags=FLAGS_VALUE, optimize=optimize)``, where " @@ -3825,7 +3935,7 @@ msgstr "" "flags=FLAGS_VALUE, optimize=optimize)``,其中 ``FLAGS_VALUE`` 在 ``optimize " "<= 0`` 時為 ``ast.PyCF_ONLY_AST``,否則為 ``ast.PyCF_OPTIMIZED_AST``。" -#: ../../library/ast.rst:2170 +#: ../../library/ast.rst:2232 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 " @@ -3844,7 +3954,7 @@ msgstr "" "``None``。此外,``# type: ignore`` 註釋的位置將作為 :class:`Module` 的 " "``type_ignores`` 屬性回傳(否則它始終是一個空串列)。" -#: ../../library/ast.rst:2180 +#: ../../library/ast.rst:2242 msgid "" "In addition, if ``mode`` is ``'func_type'``, the input syntax is modified to " "correspond to :pep:`484` \"signature type comments\", e.g. ``(str, int) -> " @@ -3854,7 +3964,7 @@ msgstr "" "名型別註解 (signature type comments)」而被修改,例如 ``(str, int) -> " "List[str]``。" -#: ../../library/ast.rst:2184 +#: ../../library/ast.rst:2246 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 " @@ -3874,12 +3984,12 @@ msgstr "" "能保證剖析(或剖析的成功)與在與 ``feature_version`` 對應的 Python 版本上運行" "時相同。" -#: ../../library/ast.rst:2194 +#: ../../library/ast.rst:2256 msgid "" "If source contains a null character (``\\0``), :exc:`ValueError` is raised." msgstr "如果來源包含 null 字元 (``\\0``),則會引發 :exc:`ValueError`。" -#: ../../library/ast.rst:2197 +#: ../../library/ast.rst:2259 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 " @@ -3893,14 +4003,14 @@ msgstr "" "原始的 ``return 42`` 為 return 陳述式生成一個有效的 AST 節點,但它不能單獨編" "譯(它需要位於函式節點內)。" -#: ../../library/ast.rst:2204 +#: ../../library/ast.rst:2266 msgid "" "In particular, :func:`ast.parse` won't do any scoping checks, which the " "compilation step does." msgstr "" "特別是 :func:`ast.parse` 不會執行任何範圍檢查,而編譯步驟才會執行此操作。" -#: ../../library/ast.rst:2208 +#: ../../library/ast.rst:2270 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." @@ -3908,11 +4018,11 @@ msgstr "" "由於 Python AST 編譯器中的堆疊 (stack) 深度限制,太大或太複雜的字串可能會導" "致 Python 直譯器崩潰。" -#: ../../library/ast.rst:2212 +#: ../../library/ast.rst:2274 msgid "Added ``type_comments``, ``mode='func_type'`` and ``feature_version``." msgstr "新增 ``type_comments``、``mode='func_type'`` 與 ``feature_version``。" -#: ../../library/ast.rst:2215 +#: ../../library/ast.rst:2277 msgid "" "The minimum supported version for ``feature_version`` is now ``(3, 7)``. The " "``optimize`` argument was added." @@ -3920,7 +4030,7 @@ msgstr "" "``feature_version`` 的最低支援版本現在是 ``(3, 7)``。新增了 ``optimize`` 引" "數。" -#: ../../library/ast.rst:2222 +#: ../../library/ast.rst:2284 msgid "" "Unparse an :class:`ast.AST` object and generate a string with code that " "would produce an equivalent :class:`ast.AST` object if parsed back with :" @@ -3929,7 +4039,7 @@ msgstr "" "反剖析 :class:`ast.AST` 物件並生成一個帶有程式碼的字串,如果使用 :func:`ast." "parse` 剖析回來,該程式碼將生成等效的 :class:`ast.AST` 物件。" -#: ../../library/ast.rst:2227 +#: ../../library/ast.rst:2289 msgid "" "The produced code string will not necessarily be equal to the original code " "that generated the :class:`ast.AST` object (without any compiler " @@ -3938,13 +4048,13 @@ msgstr "" "生成的程式碼字串不一定等於生成 :class:`ast.AST` 物件的原始程式碼(沒有任何編" "譯器最佳化,例如常數元組/凍結集合)。" -#: ../../library/ast.rst:2232 +#: ../../library/ast.rst:2294 msgid "" "Trying to unparse a highly complex expression would result with :exc:" "`RecursionError`." msgstr "嘗試剖析高度複雜的運算式會導致 :exc:`RecursionError`。" -#: ../../library/ast.rst:2240 +#: ../../library/ast.rst:2302 msgid "" "Evaluate an expression node or a string containing only a Python literal or " "container display. The string or node provided may only consist of the " @@ -3955,7 +4065,7 @@ msgstr "" "能包含以下 Python 文本結構:字串、位元組、數字、元組、串列、字典、集合、布林" "值、``None`` 和 ``Ellipsis``。" -#: ../../library/ast.rst:2245 +#: ../../library/ast.rst:2307 msgid "" "This can be used for evaluating strings containing Python values without the " "need to parse the values oneself. It is not capable of evaluating " @@ -3964,7 +4074,7 @@ msgstr "" "這可用於為包含 Python 值的字串求值,而無需自己剖析這些值。它無法計算任意複雜" "的運算式,例如涉及運算子或索引。" -#: ../../library/ast.rst:2250 +#: ../../library/ast.rst:2312 msgid "" "This function had been documented as \"safe\" in the past without defining " "what that meant. That was misleading. This is specifically designed not to " @@ -3981,13 +4091,13 @@ msgstr "" "盡或 C 堆疊耗盡,從而導致行程崩潰。某些輸入也可能會出現 CPU 消耗過多而導致拒" "絕服務的情況。因此不建議在不受信任的資料上呼叫它。" -#: ../../library/ast.rst:2260 +#: ../../library/ast.rst:2322 msgid "" "It is possible to crash the Python interpreter due to stack depth " "limitations in Python's AST compiler." msgstr "由於 Python AST 編譯器的堆疊深度限制,Python 直譯器可能會崩潰。" -#: ../../library/ast.rst:2263 +#: ../../library/ast.rst:2325 msgid "" "It can raise :exc:`ValueError`, :exc:`TypeError`, :exc:`SyntaxError`, :exc:" "`MemoryError` and :exc:`RecursionError` depending on the malformed input." @@ -3995,19 +4105,19 @@ msgstr "" "它可能會引發 :exc:`ValueError`、:exc:`TypeError`、:exc:`SyntaxError`、:exc:" "`MemoryError` 和 :exc:`RecursionError`,具體取決於格式錯誤的輸入。" -#: ../../library/ast.rst:2267 +#: ../../library/ast.rst:2329 msgid "Now allows bytes and set literals." msgstr "現在允許位元組和集合文本 (set literal)。" -#: ../../library/ast.rst:2270 +#: ../../library/ast.rst:2332 msgid "Now supports creating empty sets with ``'set()'``." msgstr "現在支援使用 ``'set()'`` 建立空集合。" -#: ../../library/ast.rst:2273 +#: ../../library/ast.rst:2335 msgid "For string inputs, leading spaces and tabs are now stripped." msgstr "對於字串輸入,前導空格和定位字元 (tab) 現在已被去除。" -#: ../../library/ast.rst:2279 +#: ../../library/ast.rst:2341 msgid "" "Return the docstring of the given *node* (which must be a :class:" "`FunctionDef`, :class:`AsyncFunctionDef`, :class:`ClassDef`, or :class:" @@ -4019,11 +4129,11 @@ msgstr "" "件字串則為 ``None``。如果 *clean* 為 true,則使用 :func:`inspect.cleandoc` 清" "理文件字串的縮排。" -#: ../../library/ast.rst:2285 +#: ../../library/ast.rst:2347 msgid ":class:`AsyncFunctionDef` is now supported." msgstr "目前已支援 :class:`AsyncFunctionDef`。" -#: ../../library/ast.rst:2291 +#: ../../library/ast.rst:2353 msgid "" "Get source code segment of the *source* that generated *node*. If some " "location information (:attr:`~ast.AST.lineno`, :attr:`~ast.AST.end_lineno`, :" @@ -4032,9 +4142,9 @@ msgid "" msgstr "" "取得生成 *node* 的 *source* 的原始碼片段。如果某些位置資訊(:attr:`~ast.AST." "lineno`、:attr:`~ast.AST.end_lineno`、:attr:`~ast.AST.col_offset` 或 :attr:" -"`~ast.AST.end_col_offset`\\ )遺漏,則回傳 ``None``。" +"`~ast.AST.end_col_offset`)遺漏,則回傳 ``None``。" -#: ../../library/ast.rst:2295 +#: ../../library/ast.rst:2357 msgid "" "If *padded* is ``True``, the first line of a multi-line statement will be " "padded with spaces to match its original position." @@ -4042,7 +4152,7 @@ msgstr "" "如果 *padded* 為 ``True``,則多列陳述式的第一列將用空格填充 (padded) 以匹配其" "原始位置。" -#: ../../library/ast.rst:2303 +#: ../../library/ast.rst:2365 msgid "" "When you compile a node tree with :func:`compile`, the compiler expects :" "attr:`~ast.AST.lineno` and :attr:`~ast.AST.col_offset` attributes for every " @@ -4056,7 +4166,7 @@ msgstr "" "要存在。填入生成的節點相當繁瑣,因此該輔助工具透過將這些屬性設定為父節點的" "值,在尚未設定的地方遞迴地新增這些屬性。它從 *node* 開始遞迴地作用。" -#: ../../library/ast.rst:2312 +#: ../../library/ast.rst:2374 msgid "" "Increment the line number and end line number of each node in the tree " "starting at *node* by *n*. This is useful to \"move code\" to a different " @@ -4065,7 +4175,7 @@ msgstr "" "將樹中從 *node* 開始的每個節點的列號和結束列號增加 *n*。這對於「移動程式碼」" "到檔案中的不同位置很有用。" -#: ../../library/ast.rst:2319 +#: ../../library/ast.rst:2381 msgid "" "Copy source location (:attr:`~ast.AST.lineno`, :attr:`~ast.AST.col_offset`, :" "attr:`~ast.AST.end_lineno`, and :attr:`~ast.AST.end_col_offset`) from " @@ -4075,7 +4185,7 @@ msgstr "" "attr:`~ast.AST.end_lineno` 和 :attr:`~ast.AST.end_col_offset` )從 " "*old_node* 複製到 *new_node*,並回傳 *new_node* 。" -#: ../../library/ast.rst:2326 +#: ../../library/ast.rst:2388 msgid "" "Yield a tuple of ``(fieldname, value)`` for each field in ``node._fields`` " "that is present on *node*." @@ -4083,7 +4193,7 @@ msgstr "" "為 *node* 上存在的 ``node._fields`` 中的每個欄位生成一個 ``(fieldname, " "value)`` 元組。" -#: ../../library/ast.rst:2332 +#: ../../library/ast.rst:2394 msgid "" "Yield all direct child nodes of *node*, that is, all fields that are nodes " "and all items of fields that are lists of nodes." @@ -4091,7 +4201,7 @@ msgstr "" "生成 *node* 的所有直接子節點,即作為節點的所有欄位以及作為節點串列欄位的所有" "項目。" -#: ../../library/ast.rst:2338 +#: ../../library/ast.rst:2400 msgid "" "Recursively yield all descendant nodes in the tree starting at *node* " "(including *node* itself), in no specified order. This is useful if you " @@ -4100,7 +4210,7 @@ msgstr "" "遞迴地生成樹中從 *node* 開始的所有後代節點(包括 *node* 本身),不按指定順" "序。如果你只想就地修改節點而不關心情境,這非常有用。" -#: ../../library/ast.rst:2345 +#: ../../library/ast.rst:2407 msgid "" "A node visitor base class that walks the abstract syntax tree and calls a " "visitor function for every node found. This function may return a value " @@ -4109,13 +4219,13 @@ msgstr "" "節點瀏覽者基底類別,它遍歷抽象語法樹並為找到的每個節點呼叫瀏覽者函式。該函式" "可能會回傳一個由 :meth:`visit` 方法轉發的值。" -#: ../../library/ast.rst:2349 +#: ../../library/ast.rst:2411 msgid "" "This class is meant to be subclassed, with the subclass adding visitor " "methods." msgstr "這個類別應該被子類別化,子類別新增瀏覽者方法。" -#: ../../library/ast.rst:2354 +#: ../../library/ast.rst:2416 msgid "" "Visit a node. The default implementation calls the method called :samp:" "`self.visit_{classname}` where *classname* is the name of the node class, " @@ -4125,11 +4235,11 @@ msgstr "" "*classname* 是節點類別的名稱,或者在該方法不存在時呼叫 :meth:" "`generic_visit`。" -#: ../../library/ast.rst:2360 +#: ../../library/ast.rst:2422 msgid "This visitor calls :meth:`visit` on all children of the node." msgstr "該瀏覽者對該節點的所有子節點呼叫 :meth:`visit`。" -#: ../../library/ast.rst:2362 +#: ../../library/ast.rst:2424 msgid "" "Note that child nodes of nodes that have a custom visitor method won't be " "visited unless the visitor calls :meth:`generic_visit` or visits them itself." @@ -4137,11 +4247,11 @@ msgstr "" "請注意,除非瀏覽者呼叫 :meth:`generic_visit` 或瀏覽它們本身,否則不會瀏覽具有" "自定義瀏覽者方法的節點之子節點。" -#: ../../library/ast.rst:2368 +#: ../../library/ast.rst:2430 msgid "Handles all constant nodes." msgstr "處理所有常數節點。" -#: ../../library/ast.rst:2370 +#: ../../library/ast.rst:2432 msgid "" "Don't use the :class:`NodeVisitor` if you want to apply changes to nodes " "during traversal. For this a special visitor exists (:class:" @@ -4151,7 +4261,7 @@ msgstr "" "`NodeVisitor`。為此,有個允許修改的特殊遍歷瀏覽者工具 :class:" "`NodeTransformer`。" -#: ../../library/ast.rst:2376 +#: ../../library/ast.rst:2438 msgid "" "Methods :meth:`!visit_Num`, :meth:`!visit_Str`, :meth:`!visit_Bytes`, :meth:" "`!visit_NameConstant` and :meth:`!visit_Ellipsis` are deprecated now and " @@ -4162,13 +4272,13 @@ msgstr "" "visit_NameConstant` 和 :meth:`!visit_Ellipsis` 方法現已棄用,並且不會在未來的" "Python 版本中被呼叫。新增 :meth:`visit_Constant` 方法來處理所有常數節點。" -#: ../../library/ast.rst:2384 +#: ../../library/ast.rst:2446 msgid "" "A :class:`NodeVisitor` subclass that walks the abstract syntax tree and " "allows modification of nodes." msgstr "一個 :class:`NodeVisitor` 子類別,它會遍歷抽象語法樹並允許修改節點。" -#: ../../library/ast.rst:2387 +#: ../../library/ast.rst:2449 msgid "" "The :class:`NodeTransformer` will walk the AST and use the return value of " "the visitor methods to replace or remove the old node. If the return value " @@ -4180,7 +4290,7 @@ msgstr "" "點。如果瀏覽者方法的回傳值為 ``None``,則該節點將從其位置中刪除,否則將被替換" "為回傳值。回傳值可能是原始節點,在這種情況下不會發生替換。" -#: ../../library/ast.rst:2393 +#: ../../library/ast.rst:2455 msgid "" "Here is an example transformer that rewrites all occurrences of name lookups " "(``foo``) to ``data['foo']``::" @@ -4188,7 +4298,7 @@ msgstr "" "下面是一個示範用的 transformer,它將查找所有出現名稱 (``foo``) 並改寫為 " "``data['foo']``: ::" -#: ../../library/ast.rst:2396 +#: ../../library/ast.rst:2458 msgid "" "class RewriteName(NodeTransformer):\n" "\n" @@ -4208,7 +4318,7 @@ msgstr "" " ctx=node.ctx\n" " )" -#: ../../library/ast.rst:2405 +#: ../../library/ast.rst:2467 msgid "" "Keep in mind that if the node you're operating on has child nodes you must " "either transform the child nodes yourself or call the :meth:`~ast." @@ -4217,7 +4327,7 @@ msgstr "" "請記住,如果你正在操作的節點有子節點,你必須自己轉換子節點或先呼叫該節點的 :" "meth:`~ast.NodeVisitor.generic_visit` 方法。" -#: ../../library/ast.rst:2409 +#: ../../library/ast.rst:2471 msgid "" "For nodes that were part of a collection of statements (that applies to all " "statement nodes), the visitor may also return a list of nodes rather than " @@ -4226,7 +4336,7 @@ msgstr "" "對於屬於陳述式總集 (collection) 一部分的節點(適用於所有陳述式節點),瀏覽者" "還可以回傳節點串列,而不僅僅是單個節點。" -#: ../../library/ast.rst:2413 +#: ../../library/ast.rst:2475 msgid "" "If :class:`NodeTransformer` introduces new nodes (that weren't part of " "original tree) without giving them location information (such as :attr:`~ast." @@ -4234,10 +4344,10 @@ msgid "" "sub-tree to recalculate the location information::" msgstr "" "如果 :class:`NodeTransformer` 引進了新節點(不屬於原始樹的一部分),但沒有給" -"它們提供位置資訊(例如 :attr:`~ast.AST.lineno`\\ ),則應使用新的子樹呼叫 :" -"func:`fix_missing_locations` 以重新計算位置資訊: ::" +"它們提供位置資訊(例如 :attr:`~ast.AST.lineno`),則應使用新的子樹呼叫 :func:" +"`fix_missing_locations` 以重新計算位置資訊: ::" -#: ../../library/ast.rst:2418 +#: ../../library/ast.rst:2480 msgid "" "tree = ast.parse('foo', mode='eval')\n" "new_tree = fix_missing_locations(RewriteName().visit(tree))" @@ -4245,15 +4355,15 @@ msgstr "" "tree = ast.parse('foo', mode='eval')\n" "new_tree = fix_missing_locations(RewriteName().visit(tree))" -#: ../../library/ast.rst:2421 +#: ../../library/ast.rst:2483 msgid "Usually you use the transformer like this::" msgstr "你通常會像這樣使用 transformer: ::" -#: ../../library/ast.rst:2423 +#: ../../library/ast.rst:2485 msgid "node = YourTransformer().visit(node)" msgstr "node = YourTransformer().visit(node)" -#: ../../library/ast.rst:2428 +#: ../../library/ast.rst:2490 msgid "" "Return a formatted dump of the tree in *node*. This is mainly useful for " "debugging purposes. If *annotate_fields* is true (by default), the returned " @@ -4269,7 +4379,7 @@ msgstr "" "潔。預設情況下,不會傾印列號和行偏移量等屬性。如果需要,可以設定 " "*include_attributes* 為 true。" -#: ../../library/ast.rst:2436 +#: ../../library/ast.rst:2498 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 " @@ -4281,25 +4391,25 @@ msgstr "" "如果 *indent* 是非負整數或字串,那麼樹將使用該縮排級別來做漂亮印出 (pretty-" "print)。縮排級別 0、負數或 ``\"\"`` 只會插入換列符號 (newlines)。``None``\\ " "(預設值)代表選擇單列表示。使用正整數縮排可以在每個級別縮排相同數量的空格。" -"如果 *indent* 是一個字串(例如 ``\"\\t\"``\\ ),則該字串用於縮排每個級別。" +"如果 *indent* 是一個字串(例如 ``\"\\t\"``),則該字串用於縮排每個級別。" -#: ../../library/ast.rst:2443 +#: ../../library/ast.rst:2505 msgid "" "If *show_empty* is false (the default), optional empty lists will be omitted " "from the output. Optional ``None`` values are always omitted." msgstr "" -"如果 *show_empty* 為 false(預設值),則輸出中將省略可選的空串列。" -"可選的 ``None`` 值總是會被省略。" +"如果 *show_empty* 為 false(預設值),則輸出中將省略可選的空串列。可選的 " +"``None`` 值總是會被省略。" -#: ../../library/ast.rst:2447 +#: ../../library/ast.rst:2509 msgid "Added the *indent* option." msgstr "新增 *indent* 選項。" -#: ../../library/ast.rst:2450 +#: ../../library/ast.rst:2512 msgid "Added the *show_empty* option." msgstr "新增 *show_empty* 選項。" -#: ../../library/ast.rst:2453 +#: ../../library/ast.rst:2515 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\\\n" "... async def f():\n" @@ -4351,17 +4461,17 @@ msgstr "" " type_params=[])],\n" " type_ignores=[])" -#: ../../library/ast.rst:2484 -msgid "Compiler Flags" +#: ../../library/ast.rst:2546 +msgid "Compiler flags" msgstr "編譯器旗標" -#: ../../library/ast.rst:2486 +#: ../../library/ast.rst:2548 msgid "" "The following flags may be passed to :func:`compile` in order to change " "effects on the compilation of a program:" msgstr "可以將以下旗標傳遞給 :func:`compile` 以變更對程式的編譯效果:" -#: ../../library/ast.rst:2491 +#: ../../library/ast.rst:2553 msgid "" "Enables support for top-level ``await``, ``async for``, ``async with`` and " "async comprehensions." @@ -4369,13 +4479,13 @@ msgstr "" "啟用對最高階 ``await``、``async for``、``async with`` 和非同步綜合運算的支" "援。" -#: ../../library/ast.rst:2498 +#: ../../library/ast.rst:2560 msgid "" "Generates and returns an abstract syntax tree instead of returning a " "compiled code object." msgstr "生成並回傳抽象語法樹,而不是回傳已編譯的程式碼物件。" -#: ../../library/ast.rst:2503 +#: ../../library/ast.rst:2565 msgid "" "The returned AST is optimized according to the *optimize* argument in :func:" "`compile` or :func:`ast.parse`." @@ -4383,7 +4493,7 @@ msgstr "" "回傳的 AST 會根據 :func:`compile` 或 :func:`ast.parse` 中的 *optimize* 引數進" "行最佳化。" -#: ../../library/ast.rst:2510 +#: ../../library/ast.rst:2572 msgid "" "Enables support for :pep:`484` and :pep:`526` style type comments (``# type: " "``, ``# type: ignore ``)." @@ -4391,47 +4501,76 @@ msgstr "" "啟用對 :pep:`484` 和 :pep:`526` 樣式型別註釋的支援 (``# type: ``, ``# " "type: ignore ``)。" -#: ../../library/ast.rst:2519 -msgid "Command-Line Usage" +#: ../../library/ast.rst:2580 +msgid "Recursively compares two ASTs." +msgstr "" + +#: ../../library/ast.rst:2582 +msgid "" +"*compare_attributes* affects whether AST attributes are considered in the " +"comparison. If *compare_attributes* is ``False`` (default), then attributes " +"are ignored. Otherwise they must all be equal. This option is useful to " +"check whether the ASTs are structurally equal but differ in whitespace or " +"similar details. Attributes include line numbers and column offsets." +msgstr "" + +#: ../../library/ast.rst:2595 +msgid "Command-line usage" msgstr "命令列用法" -#: ../../library/ast.rst:2523 +#: ../../library/ast.rst:2599 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:2526 +#: ../../library/ast.rst:2602 msgid "python -m ast [-m ] [-a] [infile]" msgstr "python -m ast [-m ] [-a] [infile]" -#: ../../library/ast.rst:2530 +#: ../../library/ast.rst:2606 msgid "The following options are accepted:" msgstr "以下選項可被接受:" -#: ../../library/ast.rst:2536 +#: ../../library/ast.rst:2612 msgid "Show the help message and exit." msgstr "顯示幫助訊息並退出。" -#: ../../library/ast.rst:2541 +#: ../../library/ast.rst:2617 msgid "" "Specify what kind of code must be compiled, like the *mode* argument in :" "func:`parse`." msgstr "指定必須編譯哪種類型的程式碼,像是 :func:`parse` 中的 *mode* 引數。" -#: ../../library/ast.rst:2546 +#: ../../library/ast.rst:2622 msgid "Don't parse type comments." msgstr "不要剖析型別註解。" -#: ../../library/ast.rst:2550 +#: ../../library/ast.rst:2626 msgid "Include attributes such as line numbers and column offsets." msgstr "包括列號和行偏移量等屬性。" -#: ../../library/ast.rst:2555 +#: ../../library/ast.rst:2631 msgid "Indentation of nodes in AST (number of spaces)." msgstr "AST 中節點的縮進(空格數)。" -#: ../../library/ast.rst:2557 +#: ../../library/ast.rst:2635 +msgid "" +"Python version in the format 3.x (for example, 3.10). Defaults to the " +"current version of the interpreter." +msgstr "" + +#: ../../library/ast.rst:2643 +msgid "Optimization level for parser. Defaults to no optimization." +msgstr "" + +#: ../../library/ast.rst:2649 +msgid "" +"Show empty lists and fields that are ``None``. Defaults to not showing empty " +"objects." +msgstr "" + +#: ../../library/ast.rst:2655 msgid "" "If :file:`infile` is specified its contents are parsed to AST and dumped to " "stdout. Otherwise, the content is read from stdin." @@ -4439,7 +4578,7 @@ msgstr "" "如果指定了 :file:`infile`,則其內容將被剖析為 AST 並傾印 (dump) 到 stdout。否" "則會從 stdin 讀取內容。" -#: ../../library/ast.rst:2563 +#: ../../library/ast.rst:2661 msgid "" "`Green Tree Snakes `_, an external " "documentation resource, has good details on working with Python ASTs." @@ -4447,7 +4586,7 @@ msgstr "" "`Green Tree Snakes `_ 是一個外部文件" "資源,提供了有關使用 Python AST 的詳細資訊。" -#: ../../library/ast.rst:2566 +#: ../../library/ast.rst:2664 msgid "" "`ASTTokens `_ " "annotates Python ASTs with the positions of tokens and text in the source " @@ -4458,7 +4597,7 @@ msgstr "" "用生成它們的原始碼中的標記和文本的位置來註釋 Python AST。這對於進行原始碼轉換" "的工具很有幫助。" -#: ../../library/ast.rst:2571 +#: ../../library/ast.rst:2669 msgid "" "`leoAst.py `_ unifies the token-based and parse-tree-based views of python programs " @@ -4468,7 +4607,7 @@ msgstr "" "py>`_ 透過在 token 和 ast 節點之間插入雙向鏈結,統一了 python 程式的基於 " "token 和基於剖析樹的視圖。" -#: ../../library/ast.rst:2576 +#: ../../library/ast.rst:2674 msgid "" "`LibCST `_ parses code as a Concrete Syntax " "Tree that looks like an ast tree and keeps all formatting details. It's " @@ -4478,7 +4617,7 @@ msgstr "" "(Concrete Syntax Tree),看起來像 ast 樹並保留所有格式詳細資訊。它對於建置自動" "重構 (codemod) 應用程式和 linter 非常有用。" -#: ../../library/ast.rst:2581 +#: ../../library/ast.rst:2679 msgid "" "`Parso `_ is a Python parser that supports " "error recovery and round-trip parsing for different Python versions (in " diff --git a/library/asynchat.po b/library/asynchat.po index cd03892c966..465364123a9 100644 --- a/library/asynchat.po +++ b/library/asynchat.po @@ -1,10 +1,10 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # #, fuzzy msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-11-18 00:15+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" diff --git a/library/asyncio-api-index.po b/library/asyncio-api-index.po index dee0c33f50b..a58fb67be6f 100644 --- a/library/asyncio-api-index.po +++ b/library/asyncio-api-index.po @@ -1,11 +1,11 @@ -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Matt Wang , 2022 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2022-10-31 08:13+0000\n" "PO-Revision-Date: 2022-01-27 21:25+0800\n" diff --git a/library/asyncio-dev.po b/library/asyncio-dev.po index ca430f72257..df22955bfb3 100644 --- a/library/asyncio-dev.po +++ b/library/asyncio-dev.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -6,9 +6,9 @@ # Matt Wang , 2022 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"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: 2025-09-08 15:25+0800\n" "PO-Revision-Date: 2023-02-18 14:17+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -75,12 +75,12 @@ msgstr "除了啟用除錯模式外,還要考慮:" #: ../../library/asyncio-dev.rst:36 msgid "" -"setting the log level of the :ref:`asyncio logger ` to :py:" -"const:`logging.DEBUG`, for example the following snippet of code can be run " -"at startup of the application::" +"setting the log level of the :ref:`asyncio logger ` " +"to :py:const:`logging.DEBUG`, for example the following snippet of code can " +"be run at startup of the application::" msgstr "" -"將 :ref:`asyncio logger(日誌記錄器) `\\ 的日誌級别設置為 :" -"py:const:`logging.DEBUG`,例如下面的程式片段可以在應用程式啟動時運行: ::" +"將 :ref:`asyncio logger(日誌記錄器) `\\ 的日誌級别設置" +"為 :py:const:`logging.DEBUG`,例如下面的程式片段可以在應用程式啟動時運行: ::" #: ../../library/asyncio-dev.rst:40 msgid "logging.basicConfig(level=logging.DEBUG)" @@ -92,8 +92,8 @@ msgid "" "warnings. One way of doing that is by using the :option:`-W` ``default`` " "command line option." msgstr "" -"配置 :mod:`warnings` 模組以顯示 :exc:`ResourceWarning` 警告。一種方法是使用 :" -"option:`-W` ``default`` 命令列選項。" +"配置 :mod:`warnings` 模組以顯示 :exc:`ResourceWarning` 警告。一種方法是使" +"用 :option:`-W` ``default`` 命令列選項。" #: ../../library/asyncio-dev.rst:47 msgid "When the debug mode is enabled:" @@ -101,13 +101,13 @@ msgstr "啟用除錯模式時:" #: ../../library/asyncio-dev.rst:49 msgid "" -"Many non-threadsafe asyncio APIs (such as :meth:`loop.call_soon` and :meth:" -"`loop.call_at` methods) raise an exception if they are called from a wrong " -"thread." +"Many non-threadsafe asyncio APIs (such as :meth:`loop.call_soon` " +"and :meth:`loop.call_at` methods) raise an exception if they are called from " +"a wrong thread." msgstr "" -"許多非執行緒安全 (non-threadsafe) 的 asyncio APIs(例如 :meth:`loop." -"call_soon` 和 :meth:`loop.call_at` 方法),如果從錯誤的執行緒呼叫就會引發例" -"外。" +"許多非執行緒安全 (non-threadsafe) 的 asyncio APIs(例" +"如 :meth:`loop.call_soon` 和 :meth:`loop.call_at` 方法),如果從錯誤的執行緒" +"呼叫就會引發例外。" #: ../../library/asyncio-dev.rst:53 msgid "" @@ -119,13 +119,13 @@ msgstr "" #: ../../library/asyncio-dev.rst:56 msgid "" -"Callbacks taking longer than 100 milliseconds are logged. The :attr:`loop." -"slow_callback_duration` attribute can be used to set the minimum execution " -"duration in seconds that is considered \"slow\"." +"Callbacks taking longer than 100 milliseconds are logged. " +"The :attr:`loop.slow_callback_duration` attribute can be used to set the " +"minimum execution duration in seconds that is considered \"slow\"." msgstr "" -"執行時間超過 100 毫秒的回呼 (callback) 將會被記錄於日誌。屬性 :attr:`loop." -"slow_callback_duration` 可用於設定以秒為單位的最小執行持續時間,超過這個值執" -"行時間就會被視為\"緩慢\"。" +"執行時間超過 100 毫秒的回呼 (callback) 將會被記錄於日誌。屬" +"性 :attr:`loop.slow_callback_duration` 可用於設定以秒為單位的最小執行持續時" +"間,超過這個值執行時間就會被視為\"緩慢\"。" #: ../../library/asyncio-dev.rst:64 msgid "Concurrency and Multithreading" @@ -146,11 +146,11 @@ msgstr "" #: ../../library/asyncio-dev.rst:72 msgid "" -"To schedule a :term:`callback` from another OS thread, the :meth:`loop." -"call_soon_threadsafe` method should be used. Example::" +"To schedule a :term:`callback` from another OS thread, " +"the :meth:`loop.call_soon_threadsafe` method should be used. Example::" msgstr "" -"要從不同的 OS 執行緒為一個 :term:`callback` 排程,應該使用 :meth:`loop." -"call_soon_threadsafe` 方法。例如: ::" +"要從不同的 OS 執行緒為一個 :term:`callback` 排程,應該使" +"用 :meth:`loop.call_soon_threadsafe` 方法。例如: ::" #: ../../library/asyncio-dev.rst:75 msgid "loop.call_soon_threadsafe(callback, *args)" @@ -173,13 +173,13 @@ msgstr "loop.call_soon_threadsafe(fut.cancel)" #: ../../library/asyncio-dev.rst:85 msgid "" -"To schedule a coroutine object from a different OS thread, the :func:" -"`run_coroutine_threadsafe` function should be used. It returns a :class:" -"`concurrent.futures.Future` to access the result::" +"To schedule a coroutine object from a different OS thread, " +"the :func:`run_coroutine_threadsafe` function should be used. It returns " +"a :class:`concurrent.futures.Future` to access the result::" msgstr "" -"要從不同的 OS 執行緒為一個協程物件排程,應該使用 :func:" -"`run_coroutine_threadsafe` 函式。它會回傳一個 :class:`concurrent.futures." -"Future` 以存取結果: ::" +"要從不同的 OS 執行緒為一個協程物件排程,應該使" +"用 :func:`run_coroutine_threadsafe` 函式。它會回傳一" +"個 :class:`concurrent.futures.Future` 以存取結果: ::" #: ../../library/asyncio-dev.rst:89 msgid "" @@ -199,40 +199,43 @@ msgstr "為了能夠處理訊號,事件迴圈必須於主執行緒中運行。 #: ../../library/asyncio-dev.rst:101 msgid "" -"The :meth:`loop.run_in_executor` method can be used with a :class:" -"`concurrent.futures.ThreadPoolExecutor` to execute blocking code in a " -"different OS thread without blocking the OS thread that the event loop runs " -"in." +"The :meth:`loop.run_in_executor` method can be used with " +"a :class:`concurrent.futures.ThreadPoolExecutor` " +"or :class:`~concurrent.futures.InterpreterPoolExecutor` to execute blocking " +"code in a different OS thread without blocking the OS thread that the event " +"loop runs in." msgstr "" -":meth:`loop.run_in_executor` 方法可以和 :class:`concurrent.futures." -"ThreadPoolExecutor` 一起使用,這能夠在作業系統上另一個不同的執行緒中執行阻塞" -"程式,且避免阻塞執行事件迴圈的執行緒。" +":meth:`loop.run_in_executor` 方法可以" +"和 :class:`concurrent.futures.ThreadPoolExecutor` 或 " +":class:`~concurrent.futures.InterpreterPoolExecutor` 一起使用,這能夠在作業系統" +"上另一個不同的執行緒中執行阻塞程式,且避免阻塞執行事件迴圈的執行緒。" -#: ../../library/asyncio-dev.rst:106 +#: ../../library/asyncio-dev.rst:107 msgid "" "There is currently no way to schedule coroutines or callbacks directly from " -"a different process (such as one started with :mod:`multiprocessing`). The :" -"ref:`asyncio-event-loop-methods` section lists APIs that can read from pipes " -"and watch file descriptors without blocking the event loop. In addition, " -"asyncio's :ref:`Subprocess ` APIs provide a way to start " -"a process and communicate with it from the event loop. Lastly, the " -"aforementioned :meth:`loop.run_in_executor` method can also be used with a :" -"class:`concurrent.futures.ProcessPoolExecutor` to execute code in a " +"a different process (such as one started with :mod:`multiprocessing`). " +"The :ref:`asyncio-event-loop-methods` section lists APIs that can read from " +"pipes and watch file descriptors without blocking the event loop. In " +"addition, asyncio's :ref:`Subprocess ` APIs provide a " +"way to start a process and communicate with it from the event loop. Lastly, " +"the aforementioned :meth:`loop.run_in_executor` method can also be used with " +"a :class:`concurrent.futures.ProcessPoolExecutor` to execute code in a " "different process." msgstr "" "目前沒有什麼辦法能直接從另一個行程(例如透過 :mod:`multiprocessing` 啟動的程" "序)來為協程或回呼排程。:ref:`asyncio-event-loop-methods`\\ 小節列出了可以從 " "pipes(管道)讀取並監視 file descriptor(檔案描述器)而不會阻塞事件迴圈的 " "API。此外,asyncio 的\\ :ref:`子行程 ` API 提供了一種啟動" -"行程並從事件迴圈與其通訊的辦法。最後,之前提到的 :meth:`loop." -"run_in_executor` 方法也可和 :class:`concurrent.futures.ProcessPoolExecutor` " -"搭配使用,以在另一個行程中執行程式。" +"行程並從事件迴圈與其通訊的辦法。最後,之前提到" +"的 :meth:`loop.run_in_executor` 方法也可" +"和 :class:`concurrent.futures.ProcessPoolExecutor` 搭配使用,以在另一個行程中" +"執行程式。" -#: ../../library/asyncio-dev.rst:120 +#: ../../library/asyncio-dev.rst:121 msgid "Running Blocking Code" msgstr "執行阻塞的程式" -#: ../../library/asyncio-dev.rst:122 +#: ../../library/asyncio-dev.rst:123 msgid "" "Blocking (CPU-bound) code should not be called directly. For example, if a " "function performs a CPU-intensive calculation for 1 second, all concurrent " @@ -241,21 +244,22 @@ msgstr "" "不應該直接呼叫阻塞(CPU 密集型)程式。例如一個執行 1 秒 CPU 密集型計算的函" "式,那麼所有並行非同步 Tasks 和 IO 操作都會被延遲 1 秒。" -#: ../../library/asyncio-dev.rst:127 +#: ../../library/asyncio-dev.rst:128 msgid "" -"An executor can be used to run a task in a different thread or even in a " -"different process to avoid blocking the OS thread with the event loop. See " -"the :meth:`loop.run_in_executor` method for more details." +"An executor can be used to run a task in a different thread, including in a " +"different interpreter, or even in a different process to avoid blocking the " +"OS thread with the event loop. See the :meth:`loop.run_in_executor` method " +"for more details." msgstr "" -"一個 executor(執行器)可以被用來在不同的執行緒、或甚至不同的行程中執行任務," -"以避免使用事件迴圈阻塞 OS 執行緒。詳情請見 :meth:`loop.run_in_executor` 方" +"一個 executor(執行器)可以被用來在不同的執行緒(包含不同直譯器)、或甚至不同的行程中執行任務," +"以避免事件迴圈阻塞了 OS 執行緒。詳情請見 :meth:`loop.run_in_executor` 方" "法。" -#: ../../library/asyncio-dev.rst:136 +#: ../../library/asyncio-dev.rst:138 msgid "Logging" msgstr "日誌記錄" -#: ../../library/asyncio-dev.rst:138 +#: ../../library/asyncio-dev.rst:140 msgid "" "asyncio uses the :mod:`logging` module and all logging is performed via the " "``\"asyncio\"`` logger." @@ -263,40 +267,40 @@ msgstr "" "asyncio 使用 :mod:`logging` 模組,所有日誌記錄都是透過 ``\"asyncio\"`` " "logger 執行的。" -#: ../../library/asyncio-dev.rst:141 +#: ../../library/asyncio-dev.rst:143 msgid "" "The default log level is :py:const:`logging.INFO`, which can be easily " "adjusted::" msgstr "日誌級別被預設為 :py:const:`logging.INFO`,它可以很容易地被調整: ::" -#: ../../library/asyncio-dev.rst:144 +#: ../../library/asyncio-dev.rst:146 msgid "logging.getLogger(\"asyncio\").setLevel(logging.WARNING)" msgstr "logging.getLogger(\"asyncio\").setLevel(logging.WARNING)" -#: ../../library/asyncio-dev.rst:147 +#: ../../library/asyncio-dev.rst:149 msgid "" "Network logging can block the event loop. It is recommended to use a " -"separate thread for handling logs or use non-blocking IO. For example, see :" -"ref:`blocking-handlers`." +"separate thread for handling logs or use non-blocking IO. For example, " +"see :ref:`blocking-handlers`." msgstr "" "網路日誌記錄可能會阻塞事件迴圈。建議使用獨立的執行緒來處理日誌或使用非阻塞 " "IO,範例請參見 :ref:`blocking-handlers`。" -#: ../../library/asyncio-dev.rst:155 +#: ../../library/asyncio-dev.rst:157 msgid "Detect never-awaited coroutines" msgstr "偵測從未被等待的 (never-awaited) 協程" -#: ../../library/asyncio-dev.rst:157 +#: ../../library/asyncio-dev.rst:159 msgid "" "When a coroutine function is called, but not awaited (e.g. ``coro()`` " -"instead of ``await coro()``) or the coroutine is not scheduled with :meth:" -"`asyncio.create_task`, asyncio will emit a :exc:`RuntimeWarning`::" +"instead of ``await coro()``) or the coroutine is not scheduled " +"with :meth:`asyncio.create_task`, asyncio will emit a :exc:`RuntimeWarning`::" msgstr "" "當協程函式被呼叫而不是被等待時(即執行 ``coro()`` 而不是 ``await coro()``)或" -"者協程沒有透過 :meth:`asyncio.create_task` 被排程,asyncio 將會發出 :exc:" -"`RuntimeWarning`: ::" +"者協程沒有透過 :meth:`asyncio.create_task` 被排程,asyncio 將會發" +"出 :exc:`RuntimeWarning`: ::" -#: ../../library/asyncio-dev.rst:162 +#: ../../library/asyncio-dev.rst:164 msgid "" "import asyncio\n" "\n" @@ -308,12 +312,21 @@ msgid "" "\n" "asyncio.run(main())" msgstr "" +"import asyncio\n" +"\n" +"async def test():\n" +" print(\"never scheduled\")\n" +"\n" +"async def main():\n" +" test()\n" +"\n" +"asyncio.run(main())" -#: ../../library/asyncio-dev.rst:172 ../../library/asyncio-dev.rst:217 +#: ../../library/asyncio-dev.rst:174 ../../library/asyncio-dev.rst:219 msgid "Output::" msgstr "輸出: ::" -#: ../../library/asyncio-dev.rst:174 +#: ../../library/asyncio-dev.rst:176 msgid "" "test.py:7: RuntimeWarning: coroutine 'test' was never awaited\n" " test()" @@ -321,11 +334,11 @@ msgstr "" "test.py:7: RuntimeWarning: coroutine 'test' was never awaited\n" " test()" -#: ../../library/asyncio-dev.rst:177 ../../library/asyncio-dev.rst:233 +#: ../../library/asyncio-dev.rst:179 ../../library/asyncio-dev.rst:235 msgid "Output in debug mode::" msgstr "除錯模式中的輸出: ::" -#: ../../library/asyncio-dev.rst:179 +#: ../../library/asyncio-dev.rst:181 msgid "" "test.py:7: RuntimeWarning: coroutine 'test' was never awaited\n" "Coroutine created at (most recent call last)\n" @@ -349,14 +362,14 @@ msgstr "" " test()\n" " test()" -#: ../../library/asyncio-dev.rst:190 +#: ../../library/asyncio-dev.rst:192 msgid "" -"The usual fix is to either await the coroutine or call the :meth:`asyncio." -"create_task` function::" +"The usual fix is to either await the coroutine or call " +"the :meth:`asyncio.create_task` function::" msgstr "" "常用的修復方法是去等待協程或者呼叫 :meth:`asyncio.create_task` 函式: ::" -#: ../../library/asyncio-dev.rst:193 +#: ../../library/asyncio-dev.rst:195 msgid "" "async def main():\n" " await test()" @@ -364,11 +377,11 @@ msgstr "" "async def main():\n" " await test()" -#: ../../library/asyncio-dev.rst:198 +#: ../../library/asyncio-dev.rst:200 msgid "Detect never-retrieved exceptions" msgstr "偵測從未被取得的 (never-retrieved) 例外" -#: ../../library/asyncio-dev.rst:200 +#: ../../library/asyncio-dev.rst:202 msgid "" "If a :meth:`Future.set_exception` is called but the Future object is never " "awaited on, the exception would never be propagated to the user code. In " @@ -379,11 +392,11 @@ msgstr "" "傳播 (propagate) 到使用者程式。在這種情況下,當 Future 物件被垃圾回收 " "(garbage collected) 時,asyncio 將發出一則日誌訊息。" -#: ../../library/asyncio-dev.rst:205 +#: ../../library/asyncio-dev.rst:207 msgid "Example of an unhandled exception::" msgstr "未處理例外的例子: ::" -#: ../../library/asyncio-dev.rst:207 +#: ../../library/asyncio-dev.rst:209 msgid "" "import asyncio\n" "\n" @@ -405,7 +418,7 @@ msgstr "" "\n" "asyncio.run(main())" -#: ../../library/asyncio-dev.rst:219 +#: ../../library/asyncio-dev.rst:221 msgid "" "Task exception was never retrieved\n" "future: \n" @@ -425,7 +438,7 @@ msgstr "" " raise Exception(\"not consumed\")\n" "Exception: not consumed" -#: ../../library/asyncio-dev.rst:228 +#: ../../library/asyncio-dev.rst:230 msgid "" ":ref:`Enable the debug mode ` to get the traceback where " "the task was created::" @@ -433,11 +446,11 @@ msgstr "" ":ref:`啟用除錯模式 `\\ 以取得任務建立處的追蹤資訊 " "(traceback): ::" -#: ../../library/asyncio-dev.rst:231 +#: ../../library/asyncio-dev.rst:233 msgid "asyncio.run(main(), debug=True)" msgstr "asyncio.run(main(), debug=True)" -#: ../../library/asyncio-dev.rst:235 +#: ../../library/asyncio-dev.rst:237 msgid "" "Task exception was never retrieved\n" "future: \n" diff --git a/library/asyncio-eventloop.po b/library/asyncio-eventloop.po index 76a0099f80e..9bcbd1cff0c 100644 --- a/library/asyncio-eventloop.po +++ b/library/asyncio-eventloop.po @@ -1,12 +1,12 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-08-20 00:15+0000\n" +"POT-Creation-Date: 2025-11-07 00:14+0000\n" "PO-Revision-Date: 2022-02-20 12:36+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -117,22 +117,26 @@ msgstr "" "函式手動建立和關閉事件迴圈。" #: ../../library/asyncio-eventloop.rst:62 +msgid "Raises a :exc:`RuntimeError` if there is no current event loop." +msgstr "如果沒有目前的事件迴圈,則引發 :exc:`RuntimeError`。" + +#: ../../library/asyncio-eventloop.rst:67 msgid "" -"Deprecation warning is emitted if there is no current event loop. In some " -"future Python release this will become an error." +"The :mod:`!asyncio` policy system is deprecated and will be removed in " +"Python 3.16; from there on, this function will return the current running " +"event loop if present else it will return the loop set by :func:" +"`set_event_loop`." msgstr "" -"如果沒有目前事件迴圈,則會發出棄用警告。在未來的某個 Python 發行版中,這將變" -"成錯誤。" -#: ../../library/asyncio-eventloop.rst:68 +#: ../../library/asyncio-eventloop.rst:74 msgid "Set *loop* as the current event loop for the current OS thread." msgstr "將 *loop* 設置為目前 OS 執行緒的目前事件迴圈。" -#: ../../library/asyncio-eventloop.rst:72 +#: ../../library/asyncio-eventloop.rst:78 msgid "Create and return a new event loop object." msgstr "建立並回傳新的事件迴圈物件。" -#: ../../library/asyncio-eventloop.rst:74 +#: ../../library/asyncio-eventloop.rst:80 msgid "" "Note that the behaviour of :func:`get_event_loop`, :func:`set_event_loop`, " "and :func:`new_event_loop` functions can be altered by :ref:`setting a " @@ -142,22 +146,22 @@ msgstr "" "`new_event_loop` 函式的行為可以透過\\ :ref:`設定自訂事件迴圈策略 `\\ 進行調整。" -#: ../../library/asyncio-eventloop.rst:80 +#: ../../library/asyncio-eventloop.rst:86 msgid "Contents" msgstr "目錄" -#: ../../library/asyncio-eventloop.rst:81 +#: ../../library/asyncio-eventloop.rst:87 msgid "This documentation page contains the following sections:" msgstr "本頁文件包含以下章節:" -#: ../../library/asyncio-eventloop.rst:83 +#: ../../library/asyncio-eventloop.rst:89 msgid "" "The `Event Loop Methods`_ section is the reference documentation of the " "event loop APIs;" msgstr "" "`事件迴圈方法 `_\\ 章節是事件迴圈 API 們的參照文件;" -#: ../../library/asyncio-eventloop.rst:86 +#: ../../library/asyncio-eventloop.rst:92 msgid "" "The `Callback Handles`_ section documents the :class:`Handle` and :class:" "`TimerHandle` instances which are returned from scheduling methods such as :" @@ -167,7 +171,7 @@ msgstr "" "call_soon` 和 :meth:`loop.call_later`)回傳的 :class:`Handle` 和 :class:" "`TimerHandle` 實例;" -#: ../../library/asyncio-eventloop.rst:90 +#: ../../library/asyncio-eventloop.rst:96 msgid "" "The `Server Objects`_ section documents types returned from event loop " "methods like :meth:`loop.create_server`;" @@ -175,7 +179,7 @@ msgstr "" "`Server 物件 `_\\ 章節記錄了從事件迴圈方法(如 :meth:`loop." "create_server`)回傳的資料型別;" -#: ../../library/asyncio-eventloop.rst:93 +#: ../../library/asyncio-eventloop.rst:99 msgid "" "The `Event Loop Implementations`_ section documents the :class:" "`SelectorEventLoop` and :class:`ProactorEventLoop` classes;" @@ -183,28 +187,28 @@ msgstr "" "`事件迴圈實作 `_\\ 章節記錄了 :class:" "`SelectorEventLoop` 和 :class:`ProactorEventLoop` 類別;" -#: ../../library/asyncio-eventloop.rst:96 +#: ../../library/asyncio-eventloop.rst:102 msgid "" "The `Examples`_ section showcases how to work with some event loop APIs." msgstr "`範例 `_\\ 章節展示了如何使用一些事件迴圈 API。" -#: ../../library/asyncio-eventloop.rst:103 +#: ../../library/asyncio-eventloop.rst:109 msgid "Event Loop Methods" msgstr "事件迴圈方法" -#: ../../library/asyncio-eventloop.rst:105 +#: ../../library/asyncio-eventloop.rst:111 msgid "Event loops have **low-level** APIs for the following:" msgstr "事件迴圈提供以下\\ **低階** API:" -#: ../../library/asyncio-eventloop.rst:113 +#: ../../library/asyncio-eventloop.rst:119 msgid "Running and stopping the loop" msgstr "啟動和停止迴圈" -#: ../../library/asyncio-eventloop.rst:117 +#: ../../library/asyncio-eventloop.rst:123 msgid "Run until the *future* (an instance of :class:`Future`) has completed." msgstr "運行直到 *future* (一個 :class:`Future` 實例)完成。" -#: ../../library/asyncio-eventloop.rst:120 +#: ../../library/asyncio-eventloop.rst:126 msgid "" "If the argument is a :ref:`coroutine object ` it is implicitly " "scheduled to run as a :class:`asyncio.Task`." @@ -212,15 +216,15 @@ msgstr "" "如果引數是\\ :ref:`協程物件 `,則它將被隱式排程為 :class:`asyncio." "Task` 運行。" -#: ../../library/asyncio-eventloop.rst:123 +#: ../../library/asyncio-eventloop.rst:129 msgid "Return the Future's result or raise its exception." msgstr "回傳 Future 的結果或引發其例外。" -#: ../../library/asyncio-eventloop.rst:127 +#: ../../library/asyncio-eventloop.rst:133 msgid "Run the event loop until :meth:`stop` is called." msgstr "運行事件迴圈直到 :meth:`stop` 被呼叫。" -#: ../../library/asyncio-eventloop.rst:129 +#: ../../library/asyncio-eventloop.rst:135 msgid "" "If :meth:`stop` is called before :meth:`run_forever` is called, the loop " "will poll the I/O selector once with a timeout of zero, run all callbacks " @@ -231,7 +235,7 @@ msgstr "" "方式輪詢 I/O 選擇器,運行所有回應 I/O 事件(以及已經排程的事件)的回呼,然後" "退出。" -#: ../../library/asyncio-eventloop.rst:134 +#: ../../library/asyncio-eventloop.rst:140 msgid "" "If :meth:`stop` is called while :meth:`run_forever` is running, the loop " "will run the current batch of callbacks and then exit. Note that new " @@ -243,41 +247,41 @@ msgstr "" "呼函式,然後退出。請注意,由回呼函式排程的新回呼在此情況下不會運行;而是在下" "次呼叫 :meth:`run_forever` 或 :meth:`run_until_complete` 時運行。" -#: ../../library/asyncio-eventloop.rst:142 +#: ../../library/asyncio-eventloop.rst:148 msgid "Stop the event loop." msgstr "停止事件迴圈。" -#: ../../library/asyncio-eventloop.rst:146 +#: ../../library/asyncio-eventloop.rst:152 msgid "Return ``True`` if the event loop is currently running." msgstr "如果事件迴圈目前正在運行,則回傳 ``True``。" -#: ../../library/asyncio-eventloop.rst:150 +#: ../../library/asyncio-eventloop.rst:156 msgid "Return ``True`` if the event loop was closed." msgstr "如果事件迴圈已關閉,則回傳 ``True``。" -#: ../../library/asyncio-eventloop.rst:154 +#: ../../library/asyncio-eventloop.rst:160 msgid "Close the event loop." msgstr "關閉事件迴圈。" -#: ../../library/asyncio-eventloop.rst:156 +#: ../../library/asyncio-eventloop.rst:162 msgid "" "The loop must not be running when this function is called. Any pending " "callbacks will be discarded." msgstr "不得於迴圈運行中呼叫此函式。將丟棄任何待處理的回呼。" -#: ../../library/asyncio-eventloop.rst:159 +#: ../../library/asyncio-eventloop.rst:165 msgid "" "This method clears all queues and shuts down the executor, but does not wait " "for the executor to finish." msgstr "此方法清除所有佇列並關閉執行器,但不等待執行器完成。" -#: ../../library/asyncio-eventloop.rst:162 +#: ../../library/asyncio-eventloop.rst:168 msgid "" "This method is idempotent and irreversible. No other methods should be " "called after the event loop is closed." msgstr "此方法是冪等且不可逆的。在事件迴圈關閉後不應呼叫其他方法。" -#: ../../library/asyncio-eventloop.rst:168 +#: ../../library/asyncio-eventloop.rst:174 msgid "" "Schedule all currently open :term:`asynchronous generator` objects to close " "with an :meth:`~agen.aclose` call. After calling this method, the event " @@ -288,19 +292,19 @@ msgstr "" "用 :meth:`~agen.aclose` 呼叫來關閉。呼叫此方法後,如果疊代新的非同步產生器," "事件迴圈將發出警告。應該使用此方法可靠地完成所有已排程的非同步產生器。" -#: ../../library/asyncio-eventloop.rst:174 +#: ../../library/asyncio-eventloop.rst:180 msgid "" "Note that there is no need to call this function when :func:`asyncio.run` is " "used." msgstr "請注意,使用 :func:`asyncio.run` 時不需要呼叫此函式。" -#: ../../library/asyncio-eventloop.rst:177 -#: ../../library/asyncio-eventloop.rst:1338 -#: ../../library/asyncio-eventloop.rst:1787 +#: ../../library/asyncio-eventloop.rst:183 +#: ../../library/asyncio-eventloop.rst:1354 +#: ../../library/asyncio-eventloop.rst:1816 msgid "Example::" msgstr "範例: ::" -#: ../../library/asyncio-eventloop.rst:179 +#: ../../library/asyncio-eventloop.rst:185 msgid "" "try:\n" " loop.run_forever()\n" @@ -314,7 +318,7 @@ msgstr "" " loop.run_until_complete(loop.shutdown_asyncgens())\n" " loop.close()" -#: ../../library/asyncio-eventloop.rst:190 +#: ../../library/asyncio-eventloop.rst:196 msgid "" "Schedule the closure of the default executor and wait for it to join all of " "the threads in the :class:`~concurrent.futures.ThreadPoolExecutor`. Once " @@ -325,7 +329,7 @@ msgstr "" "ThreadPoolExecutor` 中的所有執行緒。一旦呼叫了此方法,使用預設執行器與 :meth:" "`loop.run_in_executor` 將引發 :exc:`RuntimeError`。" -#: ../../library/asyncio-eventloop.rst:196 +#: ../../library/asyncio-eventloop.rst:202 msgid "" "The *timeout* parameter specifies the amount of time (in :class:`float` " "seconds) the executor will be given to finish joining. With the default, " @@ -334,7 +338,7 @@ msgstr "" "*timeout* 參數指定執行器完成加入所需的時間(以 :class:`float` 秒為單位)。預" "設情況下為 ``None``,不會限制執行器所花費的時間。" -#: ../../library/asyncio-eventloop.rst:201 +#: ../../library/asyncio-eventloop.rst:207 msgid "" "If the *timeout* is reached, a :exc:`RuntimeWarning` is emitted and the " "default executor is terminated without waiting for its threads to finish " @@ -343,7 +347,7 @@ msgstr "" "如果達到 *timeout*,將發出 :exc:`RuntimeWarning` 警告,預設執行器將立即終止," "不等待其執行緒完成加入。" -#: ../../library/asyncio-eventloop.rst:207 +#: ../../library/asyncio-eventloop.rst:213 msgid "" "Do not call this method when using :func:`asyncio.run`, as the latter " "handles default executor shutdown automatically." @@ -351,34 +355,34 @@ msgstr "" "使用 :func:`asyncio.run` 時請勿呼叫此方法,因為後者會自動處理預設執行器的關" "閉。" -#: ../../library/asyncio-eventloop.rst:212 +#: ../../library/asyncio-eventloop.rst:218 msgid "Added the *timeout* parameter." msgstr "加入 *timeout* 參數。" -#: ../../library/asyncio-eventloop.rst:216 +#: ../../library/asyncio-eventloop.rst:222 msgid "Scheduling callbacks" msgstr "排程回呼函式" -#: ../../library/asyncio-eventloop.rst:220 +#: ../../library/asyncio-eventloop.rst:226 msgid "" "Schedule the *callback* :term:`callback` to be called with *args* arguments " "at the next iteration of the event loop." msgstr "" "在事件迴圈的下一次疊代中排程以 *args* 引數呼叫 *callback* :term:`callback`。" -#: ../../library/asyncio-eventloop.rst:223 +#: ../../library/asyncio-eventloop.rst:229 msgid "" "Return an instance of :class:`asyncio.Handle`, which can be used later to " "cancel the callback." msgstr "回傳 :class:`asyncio.Handle` 的實例,稍後可以用於取消回呼函式。" -#: ../../library/asyncio-eventloop.rst:226 +#: ../../library/asyncio-eventloop.rst:232 msgid "" "Callbacks are called in the order in which they are registered. Each " "callback will be called exactly once." msgstr "回呼函式按照其註冊的順序呼叫。每個回呼函式將被呼叫恰好一次。" -#: ../../library/asyncio-eventloop.rst:229 +#: ../../library/asyncio-eventloop.rst:235 msgid "" "The optional keyword-only *context* argument specifies a custom :class:" "`contextvars.Context` for the *callback* to run in. Callbacks use the " @@ -387,11 +391,11 @@ msgstr "" "選用的僅限關鍵字引數 *context* 指定了要給 *callback* 執行的自定義 :class:" "`contextvars.Context`。當未提供 *context* 時,回呼函式使用目前情境。" -#: ../../library/asyncio-eventloop.rst:233 +#: ../../library/asyncio-eventloop.rst:239 msgid "Unlike :meth:`call_soon_threadsafe`, this method is not thread-safe." msgstr "與 :meth:`call_soon_threadsafe` 不同,此方法不是執行緒安全的。" -#: ../../library/asyncio-eventloop.rst:237 +#: ../../library/asyncio-eventloop.rst:243 msgid "" "A thread-safe variant of :meth:`call_soon`. When scheduling callbacks from " "another thread, this function *must* be used, since :meth:`call_soon` is not " @@ -400,14 +404,14 @@ msgstr "" "這是 :meth:`call_soon` 的執行緒安全變體。當從另一個執行緒排程回呼函式時,*必" "須*\\ 使用此函式,因為 :meth:`call_soon` 不是執行緒安全的。" -#: ../../library/asyncio-eventloop.rst:241 +#: ../../library/asyncio-eventloop.rst:247 msgid "" "This function is safe to be called from a reentrant context or signal " "handler, however, it is not safe or fruitful to use the returned handle in " "such contexts." msgstr "" -#: ../../library/asyncio-eventloop.rst:244 +#: ../../library/asyncio-eventloop.rst:250 msgid "" "Raises :exc:`RuntimeError` if called on a loop that's been closed. This can " "happen on a secondary thread when the main application is shutting down." @@ -415,21 +419,21 @@ msgstr "" "如果在已關閉的迴圈上呼叫,則引發 :exc:`RuntimeError`。在主應用程式關閉時,這" "可能發生在次要執行緒上。" -#: ../../library/asyncio-eventloop.rst:248 +#: ../../library/asyncio-eventloop.rst:254 msgid "" "See the :ref:`concurrency and multithreading ` " "section of the documentation." msgstr "請參閱文件的\\ :ref:`並行和多執行緒 `\\ 部分。" -#: ../../library/asyncio-eventloop.rst:251 -#: ../../library/asyncio-eventloop.rst:307 -#: ../../library/asyncio-eventloop.rst:333 +#: ../../library/asyncio-eventloop.rst:257 +#: ../../library/asyncio-eventloop.rst:313 +#: ../../library/asyncio-eventloop.rst:339 msgid "" "The *context* keyword-only parameter was added. See :pep:`567` for more " "details." msgstr "新增了 *context* 僅限關鍵字參數。詳細資訊請參閱 :pep:`567`。" -#: ../../library/asyncio-eventloop.rst:259 +#: ../../library/asyncio-eventloop.rst:265 msgid "" "Most :mod:`asyncio` scheduling functions don't allow passing keyword " "arguments. To do that, use :func:`functools.partial`::" @@ -437,7 +441,7 @@ msgstr "" "大多數 :mod:`asyncio` 排程函式不允許傳遞關鍵字引數。要傳遞關鍵字引數,請使" "用 :func:`functools.partial`: ::" -#: ../../library/asyncio-eventloop.rst:262 +#: ../../library/asyncio-eventloop.rst:268 msgid "" "# will schedule \"print(\"Hello\", flush=True)\"\n" "loop.call_soon(\n" @@ -447,7 +451,7 @@ msgstr "" "loop.call_soon(\n" " functools.partial(print, \"Hello\", flush=True))" -#: ../../library/asyncio-eventloop.rst:266 +#: ../../library/asyncio-eventloop.rst:272 msgid "" "Using partial objects is usually more convenient than using lambdas, as " "asyncio can render partial objects better in debug and error messages." @@ -455,11 +459,11 @@ msgstr "" "通常使用 partial 物件比使用 lambda 更方便,因為 asyncio 可以在除錯和錯誤訊息" "中更好地呈現 partial 物件。" -#: ../../library/asyncio-eventloop.rst:274 +#: ../../library/asyncio-eventloop.rst:280 msgid "Scheduling delayed callbacks" msgstr "排程延遲的回呼函式" -#: ../../library/asyncio-eventloop.rst:276 +#: ../../library/asyncio-eventloop.rst:282 msgid "" "Event loop provides mechanisms to schedule callback functions to be called " "at some point in the future. Event loop uses monotonic clocks to track time." @@ -467,20 +471,20 @@ msgstr "" "事件迴圈提供為回呼函式排程在將來某個時間點才呼叫的機制。事件迴圈使用了單調時" "鐘來追蹤時間。" -#: ../../library/asyncio-eventloop.rst:283 +#: ../../library/asyncio-eventloop.rst:289 msgid "" "Schedule *callback* to be called after the given *delay* number of seconds " "(can be either an int or a float)." msgstr "排程 *callback* 在給定的 *delay* 秒數後呼叫(可以是整數或浮點數)。" -#: ../../library/asyncio-eventloop.rst:286 -#: ../../library/asyncio-eventloop.rst:324 +#: ../../library/asyncio-eventloop.rst:292 +#: ../../library/asyncio-eventloop.rst:330 msgid "" "An instance of :class:`asyncio.TimerHandle` is returned which can be used to " "cancel the callback." msgstr "回傳 :class:`asyncio.TimerHandle` 的實例,可用於取消回呼函式。" -#: ../../library/asyncio-eventloop.rst:289 +#: ../../library/asyncio-eventloop.rst:295 msgid "" "*callback* will be called exactly once. If two callbacks are scheduled for " "exactly the same time, the order in which they are called is undefined." @@ -488,7 +492,7 @@ msgstr "" "*callback* 將只被呼叫恰好一次。如果有兩個回呼函式被排程在完全相同的時間,則其" "呼叫順序是不定的。" -#: ../../library/asyncio-eventloop.rst:293 +#: ../../library/asyncio-eventloop.rst:299 msgid "" "The optional positional *args* will be passed to the callback when it is " "called. If you want the callback to be called with keyword arguments use :" @@ -497,7 +501,7 @@ msgstr "" "可選的位置引數 *args* 將在呼叫回呼函式時傳遞。如果要使用關鍵字引數呼叫回呼函" "數,請使用 :func:`functools.partial`。" -#: ../../library/asyncio-eventloop.rst:297 +#: ../../library/asyncio-eventloop.rst:303 msgid "" "An optional keyword-only *context* argument allows specifying a custom :" "class:`contextvars.Context` for the *callback* to run in. The current " @@ -506,14 +510,14 @@ msgstr "" "可選的僅限關鍵字 *context* 引數允許為 *callback* 指定自定義的 :class:" "`contextvars.Context` 以提供運行。當未提供 *context* 時,將使用目前情境。" -#: ../../library/asyncio-eventloop.rst:303 +#: ../../library/asyncio-eventloop.rst:309 msgid "" "For performance, callbacks scheduled with :meth:`loop.call_later` may run up " "to one clock-resolution early (see ``time.get_clock_info('monotonic')." "resolution``)." msgstr "" -#: ../../library/asyncio-eventloop.rst:311 +#: ../../library/asyncio-eventloop.rst:317 msgid "" "In Python 3.7 and earlier with the default event loop implementation, the " "*delay* could not exceed one day. This has been fixed in Python 3.8." @@ -521,7 +525,7 @@ msgstr "" "在 Python 3.7 及更早版本中,使用預設事件迴圈實作時,*delay* 不能超過一天。這" "在 Python 3.8 中已經修復。" -#: ../../library/asyncio-eventloop.rst:318 +#: ../../library/asyncio-eventloop.rst:324 msgid "" "Schedule *callback* to be called at the given absolute timestamp *when* (an " "int or a float), using the same time reference as :meth:`loop.time`." @@ -529,18 +533,18 @@ msgstr "" "排程 *callback* 在給定的絕對時間戳 *when* (整數或浮點數)處呼叫,使用與 :" "meth:`loop.time` 相同的時間參照。" -#: ../../library/asyncio-eventloop.rst:322 +#: ../../library/asyncio-eventloop.rst:328 msgid "This method's behavior is the same as :meth:`call_later`." msgstr "此方法的行為與 :meth:`call_later` 相同。" -#: ../../library/asyncio-eventloop.rst:329 +#: ../../library/asyncio-eventloop.rst:335 msgid "" "For performance, callbacks scheduled with :meth:`loop.call_at` may run up to " "one clock-resolution early (see ``time.get_clock_info('monotonic')." "resolution``)." msgstr "" -#: ../../library/asyncio-eventloop.rst:337 +#: ../../library/asyncio-eventloop.rst:343 msgid "" "In Python 3.7 and earlier with the default event loop implementation, the " "difference between *when* and the current time could not exceed one day. " @@ -549,13 +553,13 @@ msgstr "" "在 Python 3.7 及更早版本中,使用預設事件迴圈實作時,*when* 和目前時間之間的差" "值不能超過一天。這在 Python 3.8 中已經修復。" -#: ../../library/asyncio-eventloop.rst:344 +#: ../../library/asyncio-eventloop.rst:350 msgid "" "Return the current time, as a :class:`float` value, according to the event " "loop's internal monotonic clock." msgstr "根據事件迴圈的內部單調時鐘,回傳目前時間,以 :class:`float` 值表示。" -#: ../../library/asyncio-eventloop.rst:348 +#: ../../library/asyncio-eventloop.rst:354 msgid "" "In Python 3.7 and earlier timeouts (relative *delay* or absolute *when*) " "should not exceed one day. This has been fixed in Python 3.8." @@ -563,19 +567,19 @@ msgstr "" "在 Python 3.7 及更早版本中,超時(相對 *delay* 或絕對 *when*)不應超過一天。" "這在 Python 3.8 中已經修復。" -#: ../../library/asyncio-eventloop.rst:354 +#: ../../library/asyncio-eventloop.rst:360 msgid "The :func:`asyncio.sleep` function." msgstr "函式 :func:`asyncio.sleep`。" -#: ../../library/asyncio-eventloop.rst:358 +#: ../../library/asyncio-eventloop.rst:364 msgid "Creating Futures and Tasks" msgstr "建立 Futures 和 Tasks" -#: ../../library/asyncio-eventloop.rst:362 +#: ../../library/asyncio-eventloop.rst:368 msgid "Create an :class:`asyncio.Future` object attached to the event loop." msgstr "建立附加到事件迴圈的 :class:`asyncio.Future` 物件。" -#: ../../library/asyncio-eventloop.rst:364 +#: ../../library/asyncio-eventloop.rst:370 msgid "" "This is the preferred way to create Futures in asyncio. This lets third-" "party event loops provide alternative implementations of the Future object " @@ -584,13 +588,13 @@ msgstr "" "這是在 asyncio 中建立 Futures 的首選方式。這允許第三方事件迴圈提供 Future 物" "件的替代實作(具有更好的性能或儀器計測表現)。" -#: ../../library/asyncio-eventloop.rst:372 +#: ../../library/asyncio-eventloop.rst:378 msgid "" "Schedule the execution of :ref:`coroutine ` *coro*. Return a :" "class:`Task` object." msgstr "排程執行\\ :ref:`協程 ` *coro*。回傳 :class:`Task` 物件。" -#: ../../library/asyncio-eventloop.rst:375 +#: ../../library/asyncio-eventloop.rst:381 msgid "" "Third-party event loops can use their own subclass of :class:`Task` for " "interoperability. In this case, the result type is a subclass of :class:" @@ -599,15 +603,14 @@ msgstr "" "第三方事件迴圈可以使用其自己的 :class:`Task` 子類別以實現互操作性" "(interoperability)。在這種情況下,結果類型是 :class:`Task` 的子類別。" -#: ../../library/asyncio-eventloop.rst:379 +#: ../../library/asyncio-eventloop.rst:385 msgid "" "The full function signature is largely the same as that of the :class:`Task` " "constructor (or factory) - all of the keyword arguments to this function are " -"passed through to that interface, except *name*, or *context* if it is " -"``None``." +"passed through to that interface." msgstr "" -#: ../../library/asyncio-eventloop.rst:384 +#: ../../library/asyncio-eventloop.rst:389 msgid "" "If the *name* argument is provided and not ``None``, it is set as the name " "of the task using :meth:`Task.set_name`." @@ -615,7 +618,7 @@ msgstr "" "如果提供了 *name* 引數且不為 ``None``,則將其設置為任務的名稱,使用 :meth:" "`Task.set_name`。" -#: ../../library/asyncio-eventloop.rst:387 +#: ../../library/asyncio-eventloop.rst:392 msgid "" "An optional keyword-only *context* argument allows specifying a custom :" "class:`contextvars.Context` for the *coro* to run in. The current context " @@ -625,32 +628,46 @@ msgstr "" "`contextvars.Context` 以提供運行。當未提供 *context* 時,將建立目前情境的副" "本。" -#: ../../library/asyncio-eventloop.rst:391 +#: ../../library/asyncio-eventloop.rst:396 +msgid "" +"An optional keyword-only *eager_start* argument allows specifying if the " +"task should execute eagerly during the call to create_task, or be scheduled " +"later. If *eager_start* is not passed the mode set by :meth:`loop." +"set_task_factory` will be used." +msgstr "" + +#: ../../library/asyncio-eventloop.rst:401 msgid "Added the *name* parameter." msgstr "加入 *name* 參數。" -#: ../../library/asyncio-eventloop.rst:394 +#: ../../library/asyncio-eventloop.rst:404 msgid "Added the *context* parameter." msgstr "加入 *context* 參數。" -#: ../../library/asyncio-eventloop.rst:397 +#: ../../library/asyncio-eventloop.rst:407 msgid "" "Added ``kwargs`` which passes on arbitrary extra parameters, including " "``name`` and ``context``." msgstr "" -#: ../../library/asyncio-eventloop.rst:400 +#: ../../library/asyncio-eventloop.rst:410 msgid "" "Rolled back the change that passes on *name* and *context* (if it is None), " "while still passing on other arbitrary keyword arguments (to avoid breaking " "backwards compatibility with 3.13.3)." msgstr "" -#: ../../library/asyncio-eventloop.rst:406 +#: ../../library/asyncio-eventloop.rst:414 +msgid "" +"All *kwargs* are now passed on. The *eager_start* parameter works with eager " +"task factories." +msgstr "" + +#: ../../library/asyncio-eventloop.rst:419 msgid "Set a task factory that will be used by :meth:`loop.create_task`." msgstr "設置將由 :meth:`loop.create_task` 使用的任務工廠。" -#: ../../library/asyncio-eventloop.rst:409 +#: ../../library/asyncio-eventloop.rst:422 msgid "" "If *factory* is ``None`` the default task factory will be set. Otherwise, " "*factory* must be a *callable* with the signature matching ``(loop, coro, " @@ -663,46 +680,52 @@ msgstr "" "迴圈的參照、*coro* 是一個協程物件。該可呼叫物件必須傳遞所有 *kwargs* 並回傳一" "個與 :class:`asyncio.Task` 相容的物件。" -#: ../../library/asyncio-eventloop.rst:415 +#: ../../library/asyncio-eventloop.rst:428 msgid "Required that all *kwargs* are passed on to :class:`asyncio.Task`." msgstr "" -#: ../../library/asyncio-eventloop.rst:418 +#: ../../library/asyncio-eventloop.rst:431 msgid "" "*name* is no longer passed to task factories. *context* is no longer passed " "to task factories if it is ``None``." msgstr "" -#: ../../library/asyncio-eventloop.rst:424 +#: ../../library/asyncio-eventloop.rst:435 +msgid "" +"*name* and *context* are now unconditionally passed on to task factories " +"again." +msgstr "" + +#: ../../library/asyncio-eventloop.rst:440 msgid "Return a task factory or ``None`` if the default one is in use." msgstr "回傳任務工廠,如果使用預設任務工廠則回傳 ``None``。" -#: ../../library/asyncio-eventloop.rst:428 +#: ../../library/asyncio-eventloop.rst:444 msgid "Opening network connections" msgstr "打開網路連線" -#: ../../library/asyncio-eventloop.rst:440 +#: ../../library/asyncio-eventloop.rst:456 msgid "" "Open a streaming transport connection to a given address specified by *host* " "and *port*." msgstr "打開以 *host* 和 *port* 指定之給定地址的串流傳輸連線。" -#: ../../library/asyncio-eventloop.rst:443 +#: ../../library/asyncio-eventloop.rst:459 msgid "" "The socket family can be either :py:const:`~socket.AF_INET` or :py:const:" "`~socket.AF_INET6` depending on *host* (or the *family* argument, if " "provided)." msgstr "" -"根據 *host*(或提供的 *family* 引數)的情況,socket 家族可以是 :py:const:" +"根據 *host*\\ (或提供的 *family* 引數)的情況,socket 家族可以是 :py:const:" "`~socket.AF_INET` 或 :py:const:`~socket.AF_INET6`。" -#: ../../library/asyncio-eventloop.rst:447 +#: ../../library/asyncio-eventloop.rst:463 msgid "The socket type will be :py:const:`~socket.SOCK_STREAM`." msgstr "Socket 類型將為 :py:const:`~socket.SOCK_STREAM`。" -#: ../../library/asyncio-eventloop.rst:449 -#: ../../library/asyncio-eventloop.rst:1248 -#: ../../library/asyncio-eventloop.rst:1265 +#: ../../library/asyncio-eventloop.rst:465 +#: ../../library/asyncio-eventloop.rst:1264 +#: ../../library/asyncio-eventloop.rst:1281 msgid "" "*protocol_factory* must be a callable returning an :ref:`asyncio protocol " "` implementation." @@ -710,24 +733,24 @@ msgstr "" "*protocol_factory* 必須是一個回傳 :ref:`asyncio protocol ` " "實作的可呼叫函式。" -#: ../../library/asyncio-eventloop.rst:452 +#: ../../library/asyncio-eventloop.rst:468 msgid "" "This method will try to establish the connection in the background. When " "successful, it returns a ``(transport, protocol)`` pair." msgstr "" "此方法將嘗試在背景建立連線。成功時,它將回傳一對 ``(transport, protocol)``。" -#: ../../library/asyncio-eventloop.rst:455 +#: ../../library/asyncio-eventloop.rst:471 msgid "The chronological synopsis of the underlying operation is as follows:" msgstr "底層操作的時間軸簡介如下:" -#: ../../library/asyncio-eventloop.rst:457 +#: ../../library/asyncio-eventloop.rst:473 msgid "" "The connection is established and a :ref:`transport ` is " "created for it." msgstr "建立連線並為其建立\\ :ref:`傳輸 `。" -#: ../../library/asyncio-eventloop.rst:460 +#: ../../library/asyncio-eventloop.rst:476 msgid "" "*protocol_factory* is called without arguments and is expected to return a :" "ref:`protocol ` instance." @@ -735,7 +758,7 @@ msgstr "" "*protocol_factory* 在無引數的情況下被呼叫,並且預計回傳一個 :ref:`協定 " "` 實例。" -#: ../../library/asyncio-eventloop.rst:463 +#: ../../library/asyncio-eventloop.rst:479 msgid "" "The protocol instance is coupled with the transport by calling its :meth:" "`~BaseProtocol.connection_made` method." @@ -743,21 +766,21 @@ msgstr "" "通過呼叫其 :meth:`~BaseProtocol.connection_made` 方法,將協定實例與傳輸連線在" "一起。" -#: ../../library/asyncio-eventloop.rst:466 +#: ../../library/asyncio-eventloop.rst:482 msgid "A ``(transport, protocol)`` tuple is returned on success." msgstr "成功時回傳一個 ``(transport, protocol)`` 元組。" -#: ../../library/asyncio-eventloop.rst:468 +#: ../../library/asyncio-eventloop.rst:484 msgid "" "The created transport is an implementation-dependent bidirectional stream." msgstr "建立的傳輸是一個依賴實作的雙向串流。" -#: ../../library/asyncio-eventloop.rst:471 -#: ../../library/asyncio-eventloop.rst:604 +#: ../../library/asyncio-eventloop.rst:487 +#: ../../library/asyncio-eventloop.rst:620 msgid "Other arguments:" msgstr "其他引數:" -#: ../../library/asyncio-eventloop.rst:473 +#: ../../library/asyncio-eventloop.rst:489 msgid "" "*ssl*: if given and not false, a SSL/TLS transport is created (by default a " "plain TCP transport is created). If *ssl* is a :class:`ssl.SSLContext` " @@ -769,11 +792,11 @@ msgstr "" "果 *ssl* 為 :class:`ssl.SSLContext` 物件,則使用該情境來建立傳輸;如果 *ssl* " "為 :const:`True`,則使用 :func:`ssl.create_default_context` 回傳的預設情境。" -#: ../../library/asyncio-eventloop.rst:479 +#: ../../library/asyncio-eventloop.rst:495 msgid ":ref:`SSL/TLS security considerations `" msgstr ":ref:`SSL/TLS 安全考量 `" -#: ../../library/asyncio-eventloop.rst:481 +#: ../../library/asyncio-eventloop.rst:497 msgid "" "*server_hostname* sets or overrides the hostname that the target server's " "certificate will be matched against. Should only be passed if *ssl* is not " @@ -788,7 +811,7 @@ msgstr "" "預設值,必須傳遞 *server_hostname* 的值。若 *server_hostname* 為空字串,將停" "用主機名稱匹配(這是一個嚴重的安全風險,可能導致中間人攻擊)。" -#: ../../library/asyncio-eventloop.rst:489 +#: ../../library/asyncio-eventloop.rst:505 msgid "" "*family*, *proto*, *flags* are the optional address family, protocol and " "flags to be passed through to getaddrinfo() for *host* resolution. If given, " @@ -799,7 +822,7 @@ msgstr "" "getaddrinfo() 進行 *host* 解析。若有給定這些應該都是相應 :mod:`socket` 模組常" "數的整數。" -#: ../../library/asyncio-eventloop.rst:494 +#: ../../library/asyncio-eventloop.rst:510 msgid "" "*happy_eyeballs_delay*, if given, enables Happy Eyeballs for this " "connection. It should be a floating-point number representing the amount of " @@ -813,7 +836,7 @@ msgstr "" "`8305` 中定義的「連線嘗試延遲」。RFC 建議的合理預設值為 ``0.25`` 秒(250 毫" "秒)。" -#: ../../library/asyncio-eventloop.rst:502 +#: ../../library/asyncio-eventloop.rst:518 msgid "" "*interleave* controls address reordering when a host name resolves to " "multiple IP addresses. If ``0`` or unspecified, no reordering is done, and " @@ -829,7 +852,7 @@ msgstr "" "族計數」。如果未指定 *happy_eyeballs_delay*,則預設值為 ``0``,如果指定則為 " "``1``。" -#: ../../library/asyncio-eventloop.rst:511 +#: ../../library/asyncio-eventloop.rst:527 msgid "" "*sock*, if given, should be an existing, already connected :class:`socket." "socket` object to be used by the transport. If *sock* is given, none of " @@ -840,9 +863,9 @@ msgstr "" "輸使用。如果提供了 *sock*,則不應指定 *host*、*port*、*family*、*proto*、" "*flags*、*happy_eyeballs_delay*、*interleave* 和 *local_addr* 中的任何一項。" -#: ../../library/asyncio-eventloop.rst:519 -#: ../../library/asyncio-eventloop.rst:641 -#: ../../library/asyncio-eventloop.rst:889 +#: ../../library/asyncio-eventloop.rst:535 +#: ../../library/asyncio-eventloop.rst:657 +#: ../../library/asyncio-eventloop.rst:905 msgid "" "The *sock* argument transfers ownership of the socket to the transport " "created. To close the socket, call the transport's :meth:`~asyncio." @@ -851,7 +874,7 @@ msgstr "" "引數 *sock* 將 socket 所有權轉移給所建立的傳輸 socket,請呼叫傳輸的 :meth:" "`~asyncio.BaseTransport.close` 方法。" -#: ../../library/asyncio-eventloop.rst:523 +#: ../../library/asyncio-eventloop.rst:539 msgid "" "*local_addr*, if given, is a ``(local_host, local_port)`` tuple used to bind " "the socket locally. The *local_host* and *local_port* are looked up using " @@ -861,8 +884,8 @@ msgstr "" "地綁定 socket。將使用 ``getaddrinfo()`` 查找 *local_host* 和 *local_port*,方" "式類似於 *host* 和 *port*。" -#: ../../library/asyncio-eventloop.rst:527 -#: ../../library/asyncio-eventloop.rst:985 +#: ../../library/asyncio-eventloop.rst:543 +#: ../../library/asyncio-eventloop.rst:1001 msgid "" "*ssl_handshake_timeout* is (for a TLS connection) the time in seconds to " "wait for the TLS handshake to complete before aborting the connection. " @@ -872,10 +895,10 @@ msgstr "" "在那之前若未完成則會中斷連線。如果為 ``None`` (預設值),則會等待 ``60.0`` " "秒。" -#: ../../library/asyncio-eventloop.rst:531 -#: ../../library/asyncio-eventloop.rst:796 -#: ../../library/asyncio-eventloop.rst:900 -#: ../../library/asyncio-eventloop.rst:989 +#: ../../library/asyncio-eventloop.rst:547 +#: ../../library/asyncio-eventloop.rst:812 +#: ../../library/asyncio-eventloop.rst:916 +#: ../../library/asyncio-eventloop.rst:1005 msgid "" "*ssl_shutdown_timeout* is the time in seconds to wait for the SSL shutdown " "to complete before aborting the connection. ``30.0`` seconds if ``None`` " @@ -884,7 +907,7 @@ msgstr "" "*ssl_shutdown_timeout* 是等待 SSL 關閉完成以前中斷連線的時間,以秒為單位。如" "果為 ``None`` (預設值),則會等待 ``30.0`` 秒。" -#: ../../library/asyncio-eventloop.rst:535 +#: ../../library/asyncio-eventloop.rst:551 msgid "" "*all_errors* determines what exceptions are raised when a connection cannot " "be created. By default, only a single ``Exception`` is raised: the first " @@ -898,12 +921,12 @@ msgstr "" "包含所有錯誤訊息的單一 ``OSError``。當 ``all_errors`` 為 ``True`` 時,將引發" "包含所有例外的 ``ExceptionGroup`` (即使只有一個例外)。" -#: ../../library/asyncio-eventloop.rst:545 -#: ../../library/asyncio-eventloop.rst:808 +#: ../../library/asyncio-eventloop.rst:561 +#: ../../library/asyncio-eventloop.rst:824 msgid "Added support for SSL/TLS in :class:`ProactorEventLoop`." msgstr "新增 :class:`ProactorEventLoop` 中的 SSL/TLS 支援。" -#: ../../library/asyncio-eventloop.rst:549 +#: ../../library/asyncio-eventloop.rst:565 msgid "" "The socket option :ref:`socket.TCP_NODELAY ` is set " "by default for all TCP connections." @@ -911,16 +934,16 @@ msgstr "" "所有 TCP 連線都預設有 :ref:`socket.TCP_NODELAY ` " "socket 選項。" -#: ../../library/asyncio-eventloop.rst:554 -#: ../../library/asyncio-eventloop.rst:910 +#: ../../library/asyncio-eventloop.rst:570 +#: ../../library/asyncio-eventloop.rst:926 msgid "Added the *ssl_handshake_timeout* parameter." msgstr "增加 *ssl_handshake_timeout* 參數。" -#: ../../library/asyncio-eventloop.rst:558 +#: ../../library/asyncio-eventloop.rst:574 msgid "Added the *happy_eyeballs_delay* and *interleave* parameters." msgstr "加入 *happy_eyeballs_delay* 和 *interleave* 參數。" -#: ../../library/asyncio-eventloop.rst:560 +#: ../../library/asyncio-eventloop.rst:576 msgid "" "Happy Eyeballs Algorithm: Success with Dual-Stack Hosts. When a server's " "IPv4 path and protocol are working, but the server's IPv6 path and protocol " @@ -936,24 +959,24 @@ msgstr "" "用戶端的使用者體驗變差。本文件具體說明了減少此用戶可見延遲的演算法要求並提供" "了一種演算法。" -#: ../../library/asyncio-eventloop.rst:569 +#: ../../library/asyncio-eventloop.rst:585 msgid "For more information: https://datatracker.ietf.org/doc/html/rfc6555" msgstr "更多資訊請見: https://datatracker.ietf.org/doc/html/rfc6555" -#: ../../library/asyncio-eventloop.rst:573 -#: ../../library/asyncio-eventloop.rst:705 -#: ../../library/asyncio-eventloop.rst:822 -#: ../../library/asyncio-eventloop.rst:862 -#: ../../library/asyncio-eventloop.rst:914 -#: ../../library/asyncio-eventloop.rst:997 +#: ../../library/asyncio-eventloop.rst:589 +#: ../../library/asyncio-eventloop.rst:721 +#: ../../library/asyncio-eventloop.rst:838 +#: ../../library/asyncio-eventloop.rst:878 +#: ../../library/asyncio-eventloop.rst:930 +#: ../../library/asyncio-eventloop.rst:1013 msgid "Added the *ssl_shutdown_timeout* parameter." msgstr "增加 *ssl_shutdown_timeout* 參數。" -#: ../../library/asyncio-eventloop.rst:575 +#: ../../library/asyncio-eventloop.rst:591 msgid "*all_errors* was added." msgstr "已新增 *all_errors*。" -#: ../../library/asyncio-eventloop.rst:580 +#: ../../library/asyncio-eventloop.rst:596 msgid "" "The :func:`open_connection` function is a high-level alternative API. It " "returns a pair of (:class:`StreamReader`, :class:`StreamWriter`) that can be " @@ -962,11 +985,11 @@ msgstr "" "函式 :func:`open_connection` 是高階的替代 API。它回傳一對 (:class:" "`StreamReader`, :class:`StreamWriter`) 可直接在 async/await 程式碼中使用。" -#: ../../library/asyncio-eventloop.rst:591 +#: ../../library/asyncio-eventloop.rst:607 msgid "Create a datagram connection." msgstr "建立一個資料報連線。" -#: ../../library/asyncio-eventloop.rst:593 +#: ../../library/asyncio-eventloop.rst:609 msgid "" "The socket family can be either :py:const:`~socket.AF_INET`, :py:const:" "`~socket.AF_INET6`, or :py:const:`~socket.AF_UNIX`, depending on *host* (or " @@ -976,13 +999,13 @@ msgstr "" "或 :py:const:`~socket.AF_UNIX`,視乎 *host*\\ (或提供的 *family* 引數)而" "定。" -#: ../../library/asyncio-eventloop.rst:597 +#: ../../library/asyncio-eventloop.rst:613 msgid "The socket type will be :py:const:`~socket.SOCK_DGRAM`." msgstr "Socket 類型將為 :py:const:`~socket.SOCK_DGRAM`。" -#: ../../library/asyncio-eventloop.rst:599 -#: ../../library/asyncio-eventloop.rst:732 -#: ../../library/asyncio-eventloop.rst:881 +#: ../../library/asyncio-eventloop.rst:615 +#: ../../library/asyncio-eventloop.rst:748 +#: ../../library/asyncio-eventloop.rst:897 msgid "" "*protocol_factory* must be a callable returning a :ref:`protocol ` implementation." @@ -990,12 +1013,12 @@ msgstr "" "*protocol_factory* 必須是可呼叫的函式,回傳 :ref:`protocol ` 實作。" -#: ../../library/asyncio-eventloop.rst:602 -#: ../../library/asyncio-eventloop.rst:687 +#: ../../library/asyncio-eventloop.rst:618 +#: ../../library/asyncio-eventloop.rst:703 msgid "A tuple of ``(transport, protocol)`` is returned on success." msgstr "成功時回傳 ``(transport, protocol)`` 元組。" -#: ../../library/asyncio-eventloop.rst:606 +#: ../../library/asyncio-eventloop.rst:622 msgid "" "*local_addr*, if given, is a ``(local_host, local_port)`` tuple used to bind " "the socket locally. The *local_host* and *local_port* are looked up using :" @@ -1004,13 +1027,13 @@ msgstr "" "*local_addr*,如果提供,是一個 ``(local_host, local_port)`` 元組,用於在本地" "綁定 socket。*local_host* 和 *local_port* 使用 :meth:`getaddrinfo` 來查找。" -#: ../../library/asyncio-eventloop.rst:612 +#: ../../library/asyncio-eventloop.rst:628 msgid "" "On Windows, when using the proactor event loop with ``local_addr=None``, an :" "exc:`OSError` with :attr:`!errno.WSAEINVAL` will be raised when running it." msgstr "" -#: ../../library/asyncio-eventloop.rst:616 +#: ../../library/asyncio-eventloop.rst:632 msgid "" "*remote_addr*, if given, is a ``(remote_host, remote_port)`` tuple used to " "connect the socket to a remote address. The *remote_host* and *remote_port* " @@ -1020,7 +1043,7 @@ msgstr "" "socket 連線到遠端位址。 *remote_host* 和 *remote_port* 使用 :meth:" "`getaddrinfo` 來查找。" -#: ../../library/asyncio-eventloop.rst:620 +#: ../../library/asyncio-eventloop.rst:636 msgid "" "*family*, *proto*, *flags* are the optional address family, protocol and " "flags to be passed through to :meth:`getaddrinfo` for *host* resolution. If " @@ -1031,7 +1054,7 @@ msgstr "" "的可選地址家族、協定和旗標。如果提供,這些應該都是來自相應的 :mod:`socket` 模" "組常數的整數。" -#: ../../library/asyncio-eventloop.rst:625 +#: ../../library/asyncio-eventloop.rst:641 msgid "" "*reuse_port* tells the kernel to allow this endpoint to be bound to the same " "port as other existing endpoints are bound to, so long as they all set this " @@ -1041,15 +1064,15 @@ msgid "" msgstr "" "*reuse_port* 告訴核心允許將此端點綁定到與其他現有端點相同的埠,只要它們在建立" "時都設定了此旗標。此選項不受 Windows 和某些 Unix 系統支援。如果未定義 :py:" -"const:`~socket.SO_REUSEPORT` 常數,則不支援此功能。" +"const:`socket.SO_REUSEPORT ` 常數,則不支援此功能。" -#: ../../library/asyncio-eventloop.rst:631 +#: ../../library/asyncio-eventloop.rst:647 msgid "" "*allow_broadcast* tells the kernel to allow this endpoint to send messages " "to the broadcast address." msgstr "*allow_broadcast* 告訴核心允許此端點向廣播位址發送訊息。" -#: ../../library/asyncio-eventloop.rst:634 +#: ../../library/asyncio-eventloop.rst:650 msgid "" "*sock* can optionally be specified in order to use a preexisting, already " "connected, :class:`socket.socket` object to be used by the transport. If " @@ -1060,7 +1083,7 @@ msgstr "" "供傳輸使用。如果指定,*local_addr* 和 *remote_addr* 應省略(必須是 :const:" "`None`\\ )。" -#: ../../library/asyncio-eventloop.rst:645 +#: ../../library/asyncio-eventloop.rst:661 msgid "" "See :ref:`UDP echo client protocol ` and :" "ref:`UDP echo server protocol ` examples." @@ -1068,7 +1091,7 @@ msgstr "" "請參閱 :ref:`UDP 回應用戶端協定 ` 和 :ref:" "`UDP 回應伺服器協定 ` 範例。" -#: ../../library/asyncio-eventloop.rst:648 +#: ../../library/asyncio-eventloop.rst:664 msgid "" "The *family*, *proto*, *flags*, *reuse_address*, *reuse_port*, " "*allow_broadcast*, and *sock* parameters were added." @@ -1076,20 +1099,20 @@ msgstr "" "新增 *family*、*proto*、*flags*、*reuse_address*、*reuse_port*、" "*allow_broadcast* 和 *sock* 參數。" -#: ../../library/asyncio-eventloop.rst:652 +#: ../../library/asyncio-eventloop.rst:668 msgid "Added support for Windows." msgstr "新增對於 Windows 的支援。" -#: ../../library/asyncio-eventloop.rst:655 +#: ../../library/asyncio-eventloop.rst:671 msgid "" "The *reuse_address* parameter is no longer supported, as using :ref:`socket." "SO_REUSEADDR ` poses a significant security concern " "for UDP. Explicitly passing ``reuse_address=True`` will raise an exception." msgstr "" -"不再支援 *reuse_address* 參數,因為使用 :py:const:`~sockets.SO_REUSEADDR` 對" +"不再支援 *reuse_address* 參數,因為使用 :py:const:`~socket.SO_REUSEADDR ` 對" "於 UDP 存有重大的安全疑慮。明確傳遞 ``reuse_address=True`` 將引發例外。" -#: ../../library/asyncio-eventloop.rst:661 +#: ../../library/asyncio-eventloop.rst:677 msgid "" "When multiple processes with differing UIDs assign sockets to an identical " "UDP socket address with ``SO_REUSEADDR``, incoming packets can become " @@ -1098,7 +1121,7 @@ msgstr "" "當具有不同 UID 的多個行程使用 ``SO_REUSEADDR`` 將 socket 分配給相同的 UDP " "socket 地址時,傳入的封包可能會在 socket 之間隨機分佈。" -#: ../../library/asyncio-eventloop.rst:665 +#: ../../library/asyncio-eventloop.rst:681 msgid "" "For supported platforms, *reuse_port* can be used as a replacement for " "similar functionality. With *reuse_port*, :ref:`socket.SO_REUSEPORT `,該選項明確禁止具" "有不同 UID 的行程將 socket 分配給相同的 socket 地址。" -#: ../../library/asyncio-eventloop.rst:672 +#: ../../library/asyncio-eventloop.rst:688 msgid "" "The *reuse_address* parameter, disabled since Python 3.8.1, 3.7.6 and " "3.6.10, has been entirely removed." msgstr "" "自 Python 3.9.0、3.8.1、3.7.6 和 3.6.10 起,已完全移除 *reuse_address* 參數。" -#: ../../library/asyncio-eventloop.rst:682 +#: ../../library/asyncio-eventloop.rst:698 msgid "Create a Unix connection." msgstr "建立一個 Unix 連線。" -#: ../../library/asyncio-eventloop.rst:684 +#: ../../library/asyncio-eventloop.rst:700 msgid "" "The socket family will be :py:const:`~socket.AF_UNIX`; socket type will be :" "py:const:`~socket.SOCK_STREAM`." @@ -1128,7 +1152,7 @@ msgstr "" "Socket 家族將為 :py:const:`~socket.AF_UNIX`;socket 類型將為 :py:const:" "`~socket.SOCK_STREAM`。" -#: ../../library/asyncio-eventloop.rst:689 +#: ../../library/asyncio-eventloop.rst:705 msgid "" "*path* is the name of a Unix domain socket and is required, unless a *sock* " "parameter is specified. Abstract Unix sockets, :class:`str`, :class:" @@ -1137,22 +1161,22 @@ msgstr "" "*path* 是 Unix 域 socket 的名稱,除非指定 *sock* 參數,否則為必填。支援抽象 " "Unix sockets、:class:`str`、:class:`bytes` 和 :class:`~pathlib.Path` 路徑。" -#: ../../library/asyncio-eventloop.rst:694 +#: ../../library/asyncio-eventloop.rst:710 msgid "" "See the documentation of the :meth:`loop.create_connection` method for " "information about arguments to this method." msgstr "" "有關此方法的引數資訊,請參閱 :meth:`loop.create_connection` 方法的文件。" -#: ../../library/asyncio-eventloop.rst:697 -#: ../../library/asyncio-eventloop.rst:853 -#: ../../library/asyncio-eventloop.rst:1318 -#: ../../library/asyncio-eventloop.rst:1858 -#: ../../library/asyncio-eventloop.rst:1865 +#: ../../library/asyncio-eventloop.rst:713 +#: ../../library/asyncio-eventloop.rst:869 +#: ../../library/asyncio-eventloop.rst:1334 +#: ../../library/asyncio-eventloop.rst:1886 +#: ../../library/asyncio-eventloop.rst:1893 msgid "Availability" msgstr "可用性" -#: ../../library/asyncio-eventloop.rst:699 +#: ../../library/asyncio-eventloop.rst:715 msgid "" "Added the *ssl_handshake_timeout* parameter. The *path* parameter can now be " "a :term:`path-like object`." @@ -1160,11 +1184,11 @@ msgstr "" "新增 *ssl_handshake_timeout* 參數。*path* 參數現在可以是 :term:`path-like " "object`。" -#: ../../library/asyncio-eventloop.rst:709 +#: ../../library/asyncio-eventloop.rst:725 msgid "Creating network servers" msgstr "建立網路伺服器" -#: ../../library/asyncio-eventloop.rst:725 +#: ../../library/asyncio-eventloop.rst:741 msgid "" "Create a TCP server (socket type :const:`~socket.SOCK_STREAM`) listening on " "*port* of the *host* address." @@ -1172,33 +1196,33 @@ msgstr "" "建立一個 TCP 伺服器(socket 類型 :const:`~socket.SOCK_STREAM`\\ ),監聽 " "*host* 位址的 *port*。" -#: ../../library/asyncio-eventloop.rst:728 +#: ../../library/asyncio-eventloop.rst:744 msgid "Returns a :class:`Server` object." msgstr "回傳一個 :class:`Server` 物件。" -#: ../../library/asyncio-eventloop.rst:730 +#: ../../library/asyncio-eventloop.rst:746 msgid "Arguments:" msgstr "引數:" -#: ../../library/asyncio-eventloop.rst:735 +#: ../../library/asyncio-eventloop.rst:751 msgid "" "The *host* parameter can be set to several types which determine where the " "server would be listening:" msgstr "可以將 *host* 參數設為幾種類型,以確定伺服器將監聽的位置:" -#: ../../library/asyncio-eventloop.rst:738 +#: ../../library/asyncio-eventloop.rst:754 msgid "" "If *host* is a string, the TCP server is bound to a single network interface " "specified by *host*." msgstr "如果 *host* 是字串,則 TCP 伺服器綁定到由 *host* 指定的單個網路介面。" -#: ../../library/asyncio-eventloop.rst:741 +#: ../../library/asyncio-eventloop.rst:757 msgid "" "If *host* is a sequence of strings, the TCP server is bound to all network " "interfaces specified by the sequence." msgstr "如果 *host* 是字串序列,則 TCP 伺服器綁定到序列指定的所有網路介面。" -#: ../../library/asyncio-eventloop.rst:744 +#: ../../library/asyncio-eventloop.rst:760 msgid "" "If *host* is an empty string or ``None``, all interfaces are assumed and a " "list of multiple sockets will be returned (most likely one for IPv4 and " @@ -1207,7 +1231,7 @@ msgstr "" "若 *host* 是空字串或 ``None``,則所有介面都被假定並回傳多個 socket 的清單(可" "能一個用於 IPv4,另一個用於 IPv6)。" -#: ../../library/asyncio-eventloop.rst:748 +#: ../../library/asyncio-eventloop.rst:764 msgid "" "The *port* parameter can be set to specify which port the server should " "listen on. If ``0`` or ``None`` (the default), a random unused port will be " @@ -1218,7 +1242,7 @@ msgstr "" "設值),將隨機選擇一個未使用的埠(請注意,如果 *host* 解析為多個網路介面,將" "為每個介面隨機選擇不同的隨機埠)。" -#: ../../library/asyncio-eventloop.rst:753 +#: ../../library/asyncio-eventloop.rst:769 msgid "" "*family* can be set to either :const:`socket.AF_INET` or :const:`~socket." "AF_INET6` to force the socket to use IPv4 or IPv6. If not set, the *family* " @@ -1228,11 +1252,11 @@ msgstr "" "制使用 IPv4 或 IPv6。如果未設定,*family* 將從主機名稱決定(預設為 :const:" "`~socket.AF_UNSPEC`\\ )。" -#: ../../library/asyncio-eventloop.rst:758 +#: ../../library/asyncio-eventloop.rst:774 msgid "*flags* is a bitmask for :meth:`getaddrinfo`." msgstr "*flags* 是 :meth:`getaddrinfo` 的位元遮罩。" -#: ../../library/asyncio-eventloop.rst:760 +#: ../../library/asyncio-eventloop.rst:776 msgid "" "*sock* can optionally be specified in order to use a preexisting socket " "object. If specified, *host* and *port* must not be specified." @@ -1240,7 +1264,7 @@ msgstr "" "可以可選地指定 *sock* 以使用現有的 socket 物件。如果指定了,*host* 和 *port* " "不能指定。" -#: ../../library/asyncio-eventloop.rst:765 +#: ../../library/asyncio-eventloop.rst:781 msgid "" "The *sock* argument transfers ownership of the socket to the server created. " "To close the socket, call the server's :meth:`~asyncio.Server.close` method." @@ -1248,7 +1272,7 @@ msgstr "" "*sock* 引數將 socket 的所有權轉移給建立的伺服器。要關閉 socket,請呼叫伺服器" "的 :meth:`~asyncio.Server.close` 方法。" -#: ../../library/asyncio-eventloop.rst:769 +#: ../../library/asyncio-eventloop.rst:785 msgid "" "*backlog* is the maximum number of queued connections passed to :meth:" "`~socket.socket.listen` (defaults to 100)." @@ -1256,14 +1280,14 @@ msgstr "" "*backlog* 是傳遞給 :meth:`~socket.socket.listen` 的最大佇列連線數(預設為 " "100)。" -#: ../../library/asyncio-eventloop.rst:772 +#: ../../library/asyncio-eventloop.rst:788 msgid "" "*ssl* can be set to an :class:`~ssl.SSLContext` instance to enable TLS over " "the accepted connections." msgstr "" "*ssl* 可以設定為 :class:`~ssl.SSLContext` 實例以在接受的連線上啟用 TLS。" -#: ../../library/asyncio-eventloop.rst:775 +#: ../../library/asyncio-eventloop.rst:791 msgid "" "*reuse_address* tells the kernel to reuse a local socket in ``TIME_WAIT`` " "state, without waiting for its natural timeout to expire. If not specified " @@ -1272,7 +1296,7 @@ msgstr "" "*reuse_address* 告訴內核重用 ``TIME_WAIT`` 狀態下的本地 socket,而不等待其自" "然超時過期。如果未指定,在 Unix 上將自動設置為 ``True``。" -#: ../../library/asyncio-eventloop.rst:780 +#: ../../library/asyncio-eventloop.rst:796 msgid "" "*reuse_port* tells the kernel to allow this endpoint to be bound to the same " "port as other existing endpoints are bound to, so long as they all set this " @@ -1281,17 +1305,17 @@ msgstr "" "*reuse_port* 告訴內核允許此端點繫結到與其他現有端點繫結的相同埠,只要它們在建" "立時都設置了此旗標。此選項在旗標 Windows 上不受支援。" -#: ../../library/asyncio-eventloop.rst:785 +#: ../../library/asyncio-eventloop.rst:801 msgid "" "*keep_alive* set to ``True`` keeps connections active by enabling the " "periodic transmission of messages." msgstr "將 *keep_alive* 設為 ``True`` 透過啟用定期的訊息傳輸來保持連線活躍。" -#: ../../library/asyncio-eventloop.rst:790 +#: ../../library/asyncio-eventloop.rst:806 msgid "Added the *keep_alive* parameter." msgstr "加入 *keep_alive* 參數。" -#: ../../library/asyncio-eventloop.rst:792 +#: ../../library/asyncio-eventloop.rst:808 msgid "" "*ssl_handshake_timeout* is (for a TLS server) the time in seconds to wait " "for the TLS handshake to complete before aborting the connection. ``60.0`` " @@ -1300,7 +1324,7 @@ msgstr "" "(對於 TLS 伺服器)\\ *ssl_handshake_timeout* 是在中斷連線之前等待 TLS 握手完" "成的時間(以秒為單位)。如果為 ``None``\\ (預設),則為 ``60.0`` 秒。" -#: ../../library/asyncio-eventloop.rst:800 +#: ../../library/asyncio-eventloop.rst:816 msgid "" "*start_serving* set to ``True`` (the default) causes the created server to " "start accepting connections immediately. When set to ``False``, the user " @@ -1311,11 +1335,11 @@ msgstr "" "接。當設置為 ``False`` 時,用戶應該等待 :meth:`Server.start_serving` 或 :" "meth:`Server.serve_forever` 來使伺服器開始接受連線。" -#: ../../library/asyncio-eventloop.rst:812 +#: ../../library/asyncio-eventloop.rst:828 msgid "The *host* parameter can be a sequence of strings." msgstr "*host* 參數可以是字串序列。" -#: ../../library/asyncio-eventloop.rst:816 +#: ../../library/asyncio-eventloop.rst:832 msgid "" "Added *ssl_handshake_timeout* and *start_serving* parameters. The socket " "option :ref:`socket.TCP_NODELAY ` is set by default " @@ -1324,7 +1348,7 @@ msgstr "" "新增 *ssl_handshake_timeout* 與 *start_serving* 參數。所有 TCP 連線都預設有 :" "ref:`socket.TCP_NODELAY ` socket 選項。" -#: ../../library/asyncio-eventloop.rst:826 +#: ../../library/asyncio-eventloop.rst:842 msgid "" "The :func:`start_server` function is a higher-level alternative API that " "returns a pair of :class:`StreamReader` and :class:`StreamWriter` that can " @@ -1333,7 +1357,7 @@ msgstr "" ":func:`start_server` 函式是一個更高階的替代 API,它回傳一對 :class:" "`StreamReader` 和 :class:`StreamWriter`,可以在 async/await 程式碼中使用。" -#: ../../library/asyncio-eventloop.rst:838 +#: ../../library/asyncio-eventloop.rst:854 msgid "" "Similar to :meth:`loop.create_server` but works with the :py:const:`~socket." "AF_UNIX` socket family." @@ -1341,7 +1365,7 @@ msgstr "" "類似 :meth:`loop.create_server`,但適用於 :py:const:`~socket.AF_UNIX` socket " "家族。" -#: ../../library/asyncio-eventloop.rst:841 +#: ../../library/asyncio-eventloop.rst:857 msgid "" "*path* is the name of a Unix domain socket, and is required, unless a *sock* " "argument is provided. Abstract Unix sockets, :class:`str`, :class:`bytes`, " @@ -1351,7 +1375,7 @@ msgstr "" "象 Unix sockets、:class:`str`、:class:`bytes` 和 :class:`~pathlib.Path` 路" "徑。" -#: ../../library/asyncio-eventloop.rst:846 +#: ../../library/asyncio-eventloop.rst:862 msgid "" "If *cleanup_socket* is true then the Unix socket will automatically be " "removed from the filesystem when the server is closed, unless the socket has " @@ -1360,13 +1384,13 @@ msgstr "" "如果 *cleanup_socket* 為真,則 Unix socket 將在伺服器關閉時自動從檔案系統中刪" "除,除非在建立伺服器後替換了 socket。" -#: ../../library/asyncio-eventloop.rst:850 +#: ../../library/asyncio-eventloop.rst:866 msgid "" "See the documentation of the :meth:`loop.create_server` method for " "information about arguments to this method." msgstr "有關此方法的引數資訊,請參閱 :meth:`loop.create_server` 方法的文件。" -#: ../../library/asyncio-eventloop.rst:857 +#: ../../library/asyncio-eventloop.rst:873 msgid "" "Added the *ssl_handshake_timeout* and *start_serving* parameters. The *path* " "parameter can now be a :class:`~pathlib.Path` object." @@ -1374,26 +1398,26 @@ msgstr "" "新增 *ssl_handshake_timeout* 與 *start_serving* 參數。*path* 參數現在可為一" "個 :class:`~pathlib.Path` 物件。" -#: ../../library/asyncio-eventloop.rst:866 +#: ../../library/asyncio-eventloop.rst:882 msgid "Added the *cleanup_socket* parameter." msgstr "加入 *cleanup_socket* 參數。" -#: ../../library/asyncio-eventloop.rst:874 +#: ../../library/asyncio-eventloop.rst:890 msgid "Wrap an already accepted connection into a transport/protocol pair." msgstr "將已接受的連線包裝成傳輸層/協定對。" -#: ../../library/asyncio-eventloop.rst:876 +#: ../../library/asyncio-eventloop.rst:892 msgid "" "This method can be used by servers that accept connections outside of " "asyncio but that use asyncio to handle them." msgstr "此方法可以由在 asyncio 外接受連線但使用 asyncio 處理連線的伺服器使用。" -#: ../../library/asyncio-eventloop.rst:879 -#: ../../library/asyncio-eventloop.rst:971 +#: ../../library/asyncio-eventloop.rst:895 +#: ../../library/asyncio-eventloop.rst:987 msgid "Parameters:" msgstr "參數:" -#: ../../library/asyncio-eventloop.rst:884 +#: ../../library/asyncio-eventloop.rst:900 msgid "" "*sock* is a preexisting socket object returned from :meth:`socket.accept " "`." @@ -1401,13 +1425,13 @@ msgstr "" "*sock* 是從 :meth:`socket.accept ` 回傳的預先存在的 " "socket 物件。" -#: ../../library/asyncio-eventloop.rst:893 +#: ../../library/asyncio-eventloop.rst:909 msgid "" "*ssl* can be set to an :class:`~ssl.SSLContext` to enable SSL over the " "accepted connections." msgstr "*ssl* 可以設置為 :class:`~ssl.SSLContext` 以在已接受的連線上啟用 SSL。" -#: ../../library/asyncio-eventloop.rst:896 +#: ../../library/asyncio-eventloop.rst:912 msgid "" "*ssl_handshake_timeout* is (for an SSL connection) the time in seconds to " "wait for the SSL handshake to complete before aborting the connection. " @@ -1416,29 +1440,29 @@ msgstr "" "(對於 SSL 連線)\\ *ssl_handshake_timeout* 是在中斷連線之前等待 SSL 握手完成" "的時間(以秒為單位)。如果為 ``None``\\ (預設),則為 ``60.0`` 秒。" -#: ../../library/asyncio-eventloop.rst:904 +#: ../../library/asyncio-eventloop.rst:920 msgid "Returns a ``(transport, protocol)`` pair." msgstr "回傳 ``(transport, protocol)`` 對。" -#: ../../library/asyncio-eventloop.rst:918 +#: ../../library/asyncio-eventloop.rst:934 msgid "Transferring files" msgstr "傳輸檔案" -#: ../../library/asyncio-eventloop.rst:924 +#: ../../library/asyncio-eventloop.rst:940 msgid "" "Send a *file* over a *transport*. Return the total number of bytes sent." msgstr "通過 *transport* 發送 *file*。回傳發送的總位元組數。" -#: ../../library/asyncio-eventloop.rst:927 +#: ../../library/asyncio-eventloop.rst:943 msgid "The method uses high-performance :meth:`os.sendfile` if available." msgstr "如果可用,該方法使用高性能 :meth:`os.sendfile`。" -#: ../../library/asyncio-eventloop.rst:929 +#: ../../library/asyncio-eventloop.rst:945 msgid "*file* must be a regular file object opened in binary mode." msgstr "*file* 必須是以二進位模式打開的常規檔案物件。" -#: ../../library/asyncio-eventloop.rst:931 -#: ../../library/asyncio-eventloop.rst:1192 +#: ../../library/asyncio-eventloop.rst:947 +#: ../../library/asyncio-eventloop.rst:1208 msgid "" "*offset* tells from where to start reading the file. If specified, *count* " "is the total number of bytes to transmit as opposed to sending the file " @@ -1450,7 +1474,7 @@ msgstr "" "不是發送檔案直到達到 EOF。即使此方法引發錯誤時,檔案位置也始終更新,可以使" "用 :meth:`file.tell() ` 取得實際發送的位元組數。" -#: ../../library/asyncio-eventloop.rst:938 +#: ../../library/asyncio-eventloop.rst:954 msgid "" "*fallback* set to ``True`` makes asyncio to manually read and send the file " "when the platform does not support the sendfile system call (e.g. Windows or " @@ -1459,7 +1483,7 @@ msgstr "" "將 *fallback* 設置為 ``True`` 會使 asyncio 在平台不支援 sendfile 系統呼叫時" "(例如 Windows 或 Unix 上的 SSL socket)手動讀取和發送檔案。" -#: ../../library/asyncio-eventloop.rst:942 +#: ../../library/asyncio-eventloop.rst:958 msgid "" "Raise :exc:`SendfileNotAvailableError` if the system does not support the " "*sendfile* syscall and *fallback* is ``False``." @@ -1467,15 +1491,15 @@ msgstr "" "如果系統不支援 *sendfile* 系統呼叫且 *fallback* 為 ``False``,則引發 :exc:" "`SendfileNotAvailableError`。" -#: ../../library/asyncio-eventloop.rst:949 +#: ../../library/asyncio-eventloop.rst:965 msgid "TLS Upgrade" msgstr "TLS 升級" -#: ../../library/asyncio-eventloop.rst:957 +#: ../../library/asyncio-eventloop.rst:973 msgid "Upgrade an existing transport-based connection to TLS." msgstr "將基於傳輸的現有連線升級到 TLS。" -#: ../../library/asyncio-eventloop.rst:959 +#: ../../library/asyncio-eventloop.rst:975 msgid "" "Create a TLS coder/decoder instance and insert it between the *transport* " "and the *protocol*. The coder/decoder implements both *transport*-facing " @@ -1484,7 +1508,7 @@ msgstr "" "建立 TLS 編解碼器實例並在 *transport* 和 *protocol* 之間插入它。編解碼器既實" "作了對於 *transport* 的協定,也實作了對於 *protocol* 的傳輸。" -#: ../../library/asyncio-eventloop.rst:963 +#: ../../library/asyncio-eventloop.rst:979 msgid "" "Return the created two-interface instance. After *await*, the *protocol* " "must stop using the original *transport* and communicate with the returned " @@ -1495,13 +1519,13 @@ msgstr "" "*transport*,僅與回傳的物件通信,因為編碼器快取了 *protocol* 端的資料,並且" "與 *transport* 間歇性地交換額外的 TLS session 封包。" -#: ../../library/asyncio-eventloop.rst:968 +#: ../../library/asyncio-eventloop.rst:984 msgid "" "In some situations (e.g. when the passed transport is already closing) this " "may return ``None``." msgstr "在某些情況下(例如傳入的傳輸已經關閉),此函式可能回傳 ``None``。" -#: ../../library/asyncio-eventloop.rst:973 +#: ../../library/asyncio-eventloop.rst:989 msgid "" "*transport* and *protocol* instances that methods like :meth:`~loop." "create_server` and :meth:`~loop.create_connection` return." @@ -1509,11 +1533,11 @@ msgstr "" "*transport* 和 *protocol* 實例,由像 :meth:`~loop.create_server` 和 :meth:" "`~loop.create_connection` 等方法回傳。" -#: ../../library/asyncio-eventloop.rst:977 +#: ../../library/asyncio-eventloop.rst:993 msgid "*sslcontext*: a configured instance of :class:`~ssl.SSLContext`." msgstr "*sslcontext*:配置好的 :class:`~ssl.SSLContext` 實例。" -#: ../../library/asyncio-eventloop.rst:979 +#: ../../library/asyncio-eventloop.rst:995 msgid "" "*server_side* pass ``True`` when a server-side connection is being upgraded " "(like the one created by :meth:`~loop.create_server`)." @@ -1521,17 +1545,17 @@ msgstr "" "當升級伺服器端連線時(像由 :meth:`~loop.create_server` 建立的那樣)傳遞 " "``True``。" -#: ../../library/asyncio-eventloop.rst:982 +#: ../../library/asyncio-eventloop.rst:998 msgid "" "*server_hostname*: sets or overrides the host name that the target server's " "certificate will be matched against." msgstr "*server_hostname*:設置或覆蓋將用於匹配目標伺服器憑證的主機名。" -#: ../../library/asyncio-eventloop.rst:1002 +#: ../../library/asyncio-eventloop.rst:1018 msgid "Watching file descriptors" msgstr "監視檔案描述器" -#: ../../library/asyncio-eventloop.rst:1006 +#: ../../library/asyncio-eventloop.rst:1022 msgid "" "Start monitoring the *fd* file descriptor for read availability and invoke " "*callback* with the specified arguments once *fd* is available for reading." @@ -1539,14 +1563,14 @@ msgstr "" "開始監視 *fd* 檔案描述器的讀取可用性,一但 *fd* 可讀取,使用指定引數叫用 " "*callback*。" -#: ../../library/asyncio-eventloop.rst:1010 -#: ../../library/asyncio-eventloop.rst:1024 +#: ../../library/asyncio-eventloop.rst:1026 +#: ../../library/asyncio-eventloop.rst:1040 msgid "" "Any preexisting callback registered for *fd* is cancelled and replaced by " "*callback*." msgstr "任何預先存在、為 *fd* 註冊的回呼函式將被取消並替換為 *callback*。" -#: ../../library/asyncio-eventloop.rst:1015 +#: ../../library/asyncio-eventloop.rst:1031 msgid "" "Stop monitoring the *fd* file descriptor for read availability. Returns " "``True`` if *fd* was previously being monitored for reads." @@ -1554,7 +1578,7 @@ msgstr "" "停止監視 *fd* 檔案描述器的讀取可用性。如果 *fd* 之前正在監視讀取,則回傳 " "``True``。" -#: ../../library/asyncio-eventloop.rst:1020 +#: ../../library/asyncio-eventloop.rst:1036 msgid "" "Start monitoring the *fd* file descriptor for write availability and invoke " "*callback* with the specified arguments once *fd* is available for writing." @@ -1562,8 +1586,8 @@ msgstr "" "開始監視 *fd* 檔案描述器的寫入可用性,一旦 *fd* 可寫入,使用指定引數叫用 " "*callback*。" -#: ../../library/asyncio-eventloop.rst:1027 -#: ../../library/asyncio-eventloop.rst:1305 +#: ../../library/asyncio-eventloop.rst:1043 +#: ../../library/asyncio-eventloop.rst:1321 msgid "" "Use :func:`functools.partial` :ref:`to pass keyword arguments ` to *callback*." @@ -1571,7 +1595,7 @@ msgstr "" "使用 :func:`functools.partial` 向 *callback* :ref:`傳送關鍵字引數 `。" -#: ../../library/asyncio-eventloop.rst:1032 +#: ../../library/asyncio-eventloop.rst:1048 msgid "" "Stop monitoring the *fd* file descriptor for write availability. Returns " "``True`` if *fd* was previously being monitored for writes." @@ -1579,7 +1603,7 @@ msgstr "" "停止監視 *fd* 檔案描述器的寫入可用性。如果 *fd* 之前正在監視寫入,則回傳 " "``True``。" -#: ../../library/asyncio-eventloop.rst:1035 +#: ../../library/asyncio-eventloop.rst:1051 msgid "" "See also :ref:`Platform Support ` section for some " "limitations of these methods." @@ -1587,11 +1611,11 @@ msgstr "" "另請參閱\\ :ref:`平台支援 `\\ 部分以了解這些方法的" "一些限制。" -#: ../../library/asyncio-eventloop.rst:1040 +#: ../../library/asyncio-eventloop.rst:1056 msgid "Working with socket objects directly" msgstr "直接使用 socket 物件" -#: ../../library/asyncio-eventloop.rst:1042 +#: ../../library/asyncio-eventloop.rst:1058 msgid "" "In general, protocol implementations that use transport-based APIs such as :" "meth:`loop.create_connection` and :meth:`loop.create_server` are faster than " @@ -1603,7 +1627,7 @@ msgstr "" "`loop.create_server`)的協定實作比直接使用 socket 的實作更快。然而在某些情況" "下性能不是關鍵,直接使用 :class:`~socket.socket` 物件更方便。" -#: ../../library/asyncio-eventloop.rst:1052 +#: ../../library/asyncio-eventloop.rst:1068 msgid "" "Receive up to *nbytes* from *sock*. Asynchronous version of :meth:`socket." "recv() `." @@ -1611,23 +1635,23 @@ msgstr "" "從 *sock* 接收最多 *nbytes*。:meth:`socket.recv() ` 的非" "同步版本。" -#: ../../library/asyncio-eventloop.rst:1055 +#: ../../library/asyncio-eventloop.rst:1071 msgid "Return the received data as a bytes object." msgstr "將接收到的資料作為 bytes 物件回傳。" -#: ../../library/asyncio-eventloop.rst:1057 -#: ../../library/asyncio-eventloop.rst:1072 -#: ../../library/asyncio-eventloop.rst:1084 -#: ../../library/asyncio-eventloop.rst:1097 +#: ../../library/asyncio-eventloop.rst:1073 +#: ../../library/asyncio-eventloop.rst:1088 +#: ../../library/asyncio-eventloop.rst:1100 #: ../../library/asyncio-eventloop.rst:1113 #: ../../library/asyncio-eventloop.rst:1129 -#: ../../library/asyncio-eventloop.rst:1140 -#: ../../library/asyncio-eventloop.rst:1167 -#: ../../library/asyncio-eventloop.rst:1206 +#: ../../library/asyncio-eventloop.rst:1145 +#: ../../library/asyncio-eventloop.rst:1156 +#: ../../library/asyncio-eventloop.rst:1183 +#: ../../library/asyncio-eventloop.rst:1222 msgid "*sock* must be a non-blocking socket." msgstr "*sock* 必須是非阻塞 socket。" -#: ../../library/asyncio-eventloop.rst:1059 +#: ../../library/asyncio-eventloop.rst:1075 msgid "" "Even though this method was always documented as a coroutine method, " "releases before Python 3.7 returned a :class:`Future`. Since Python 3.7 this " @@ -1636,7 +1660,7 @@ msgstr "" "儘管此方法一直記錄為協程方法,但 Python 3.7 之前的版本回傳 :class:`Future`。" "自 Python 3.7 起,這是 ``async def`` 方法。" -#: ../../library/asyncio-eventloop.rst:1067 +#: ../../library/asyncio-eventloop.rst:1083 msgid "" "Receive data from *sock* into the *buf* buffer. Modeled after the blocking :" "meth:`socket.recv_into() ` method." @@ -1644,11 +1668,11 @@ msgstr "" "從 *sock* 接收資料到 *buf* 緩衝區。仿照阻塞 :meth:`socket.recv_into() " "` 方法。" -#: ../../library/asyncio-eventloop.rst:1070 +#: ../../library/asyncio-eventloop.rst:1086 msgid "Return the number of bytes written to the buffer." msgstr "回傳寫入緩衝區位元組的數目。" -#: ../../library/asyncio-eventloop.rst:1079 +#: ../../library/asyncio-eventloop.rst:1095 msgid "" "Receive a datagram of up to *bufsize* from *sock*. Asynchronous version of :" "meth:`socket.recvfrom() `." @@ -1656,11 +1680,11 @@ msgstr "" "從 *sock* 接收最多 *bufsize* 大小的資料單元。:meth:`socket.recvfrom() " "` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1082 +#: ../../library/asyncio-eventloop.rst:1098 msgid "Return a tuple of (received data, remote address)." msgstr "回傳一個元組 (received data, remote address)。" -#: ../../library/asyncio-eventloop.rst:1091 +#: ../../library/asyncio-eventloop.rst:1107 msgid "" "Receive a datagram of up to *nbytes* from *sock* into *buf*. Asynchronous " "version of :meth:`socket.recvfrom_into() `." @@ -1668,11 +1692,11 @@ msgstr "" "從 *sock* 接收最多 *nbytes* 大小的資料單元到 *buf*。:meth:`socket." "recvfrom_into() ` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1095 +#: ../../library/asyncio-eventloop.rst:1111 msgid "Return a tuple of (number of bytes received, remote address)." msgstr "回傳一個元組 (number of bytes received, remote address)。" -#: ../../library/asyncio-eventloop.rst:1104 +#: ../../library/asyncio-eventloop.rst:1120 msgid "" "Send *data* to the *sock* socket. Asynchronous version of :meth:`socket." "sendall() `." @@ -1680,7 +1704,7 @@ msgstr "" "將 *data* 發送到 *sock* socket。:meth:`socket.sendall() ` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1107 +#: ../../library/asyncio-eventloop.rst:1123 msgid "" "This method continues to send to the socket until either all data in *data* " "has been sent or an error occurs. ``None`` is returned on success. On " @@ -1692,8 +1716,8 @@ msgstr "" "回傳 ``None``。錯誤時引發例外。此外,沒有辦法確定接收端成功處理了多少資料(如" "果有的話)。" -#: ../../library/asyncio-eventloop.rst:1115 -#: ../../library/asyncio-eventloop.rst:1169 +#: ../../library/asyncio-eventloop.rst:1131 +#: ../../library/asyncio-eventloop.rst:1185 msgid "" "Even though the method was always documented as a coroutine method, before " "Python 3.7 it returned a :class:`Future`. Since Python 3.7, this is an " @@ -1702,7 +1726,7 @@ msgstr "" "儘管該方法一直被記錄為協程方法,但在 Python 3.7 之前它回傳 :class:`Future`。" "從 Python 3.7 開始,這是一個 ``async def`` 方法。" -#: ../../library/asyncio-eventloop.rst:1123 +#: ../../library/asyncio-eventloop.rst:1139 msgid "" "Send a datagram from *sock* to *address*. Asynchronous version of :meth:" "`socket.sendto() `." @@ -1710,20 +1734,20 @@ msgstr "" "從 *sock* 向 *address* 發送一個資料單元。:meth:`socket.sendto() ` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1127 +#: ../../library/asyncio-eventloop.rst:1143 msgid "Return the number of bytes sent." msgstr "回傳發送的位元組數。" -#: ../../library/asyncio-eventloop.rst:1136 +#: ../../library/asyncio-eventloop.rst:1152 msgid "Connect *sock* to a remote socket at *address*." msgstr "將 *sock* 連線到位於 *address* 的遠端 socket。" -#: ../../library/asyncio-eventloop.rst:1138 +#: ../../library/asyncio-eventloop.rst:1154 msgid "" "Asynchronous version of :meth:`socket.connect() `." msgstr ":meth:`socket.connect() ` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1142 +#: ../../library/asyncio-eventloop.rst:1158 msgid "" "``address`` no longer needs to be resolved. ``sock_connect`` will try to " "check if the *address* is already resolved by calling :func:`socket." @@ -1734,7 +1758,7 @@ msgstr "" "inet_pton` 檢查 *address* 是否已解析。如果沒有,將使用 :meth:`loop." "getaddrinfo` 解析 *address*。" -#: ../../library/asyncio-eventloop.rst:1151 +#: ../../library/asyncio-eventloop.rst:1167 msgid "" ":meth:`loop.create_connection` and :func:`asyncio.open_connection() " "`." @@ -1742,7 +1766,7 @@ msgstr "" ":meth:`loop.create_connection` 和 :func:`asyncio.open_connection() " "`。" -#: ../../library/asyncio-eventloop.rst:1158 +#: ../../library/asyncio-eventloop.rst:1174 msgid "" "Accept a connection. Modeled after the blocking :meth:`socket.accept() " "` method." @@ -1750,7 +1774,7 @@ msgstr "" "接受一個連線。模擬阻塞的 :meth:`socket.accept() ` 方" "法。" -#: ../../library/asyncio-eventloop.rst:1161 +#: ../../library/asyncio-eventloop.rst:1177 msgid "" "The socket must be bound to an address and listening for connections. The " "return value is a pair ``(conn, address)`` where *conn* is a *new* socket " @@ -1761,34 +1785,34 @@ msgstr "" "中 *conn* 是一個 *新* socket 物件,可在連線上發送和接收資料,*address* 是連接" "另一端對應的 socket 地址。" -#: ../../library/asyncio-eventloop.rst:1176 +#: ../../library/asyncio-eventloop.rst:1192 msgid ":meth:`loop.create_server` and :func:`start_server`." msgstr ":meth:`loop.create_server` 和 :func:`start_server`。" -#: ../../library/asyncio-eventloop.rst:1182 +#: ../../library/asyncio-eventloop.rst:1198 msgid "" "Send a file using high-performance :mod:`os.sendfile` if possible. Return " "the total number of bytes sent." msgstr "" "如果可行,使用高性能 :mod:`os.sendfile` 發送檔案。回傳發送的總位元組數。" -#: ../../library/asyncio-eventloop.rst:1185 +#: ../../library/asyncio-eventloop.rst:1201 msgid "" "Asynchronous version of :meth:`socket.sendfile() `." msgstr ":meth:`socket.sendfile() ` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1187 +#: ../../library/asyncio-eventloop.rst:1203 msgid "" "*sock* must be a non-blocking :const:`socket.SOCK_STREAM` :class:`~socket." "socket`." msgstr "" "*sock* 必須是非阻塞的 :const:`socket.SOCK_STREAM` :class:`~socket.socket`。" -#: ../../library/asyncio-eventloop.rst:1190 +#: ../../library/asyncio-eventloop.rst:1206 msgid "*file* must be a regular file object open in binary mode." msgstr "*file* 必須是以二進位模式打開的常規檔案物件。" -#: ../../library/asyncio-eventloop.rst:1199 +#: ../../library/asyncio-eventloop.rst:1215 msgid "" "*fallback*, when set to ``True``, makes asyncio manually read and send the " "file when the platform does not support the sendfile syscall (e.g. Windows " @@ -1797,7 +1821,7 @@ msgstr "" "當設置為 ``True`` 時,*fallback* 使 asyncio 在平台不支援 sendfile 系統呼叫時" "(例如 Windows 或 Unix 上的 SSL socket)手動讀取和發送檔案。" -#: ../../library/asyncio-eventloop.rst:1203 +#: ../../library/asyncio-eventloop.rst:1219 msgid "" "Raise :exc:`SendfileNotAvailableError` if the system does not support " "*sendfile* syscall and *fallback* is ``False``." @@ -1805,19 +1829,19 @@ msgstr "" "如果系統不支援 *sendfile* 系統呼叫且 *fallback* 為 ``False``,引發 :exc:" "`SendfileNotAvailableError`。" -#: ../../library/asyncio-eventloop.rst:1212 +#: ../../library/asyncio-eventloop.rst:1228 msgid "DNS" msgstr "DNS" -#: ../../library/asyncio-eventloop.rst:1218 +#: ../../library/asyncio-eventloop.rst:1234 msgid "Asynchronous version of :meth:`socket.getaddrinfo`." msgstr ":meth:`socket.getaddrinfo` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1223 +#: ../../library/asyncio-eventloop.rst:1239 msgid "Asynchronous version of :meth:`socket.getnameinfo`." msgstr ":meth:`socket.getnameinfo` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1226 +#: ../../library/asyncio-eventloop.rst:1242 msgid "" "Both *getaddrinfo* and *getnameinfo* internally utilize their synchronous " "versions through the loop's default thread pool executor. When this executor " @@ -1827,7 +1851,7 @@ msgid "" "executor with a larger number of workers." msgstr "" -#: ../../library/asyncio-eventloop.rst:1233 +#: ../../library/asyncio-eventloop.rst:1249 msgid "" "Both *getaddrinfo* and *getnameinfo* methods were always documented to " "return a coroutine, but prior to Python 3.7 they were, in fact, returning :" @@ -1838,19 +1862,19 @@ msgstr "" "它們實際上回傳 :class:`asyncio.Future` 物件。從 Python 3.7 開始,兩個方法都是" "協程。" -#: ../../library/asyncio-eventloop.rst:1241 +#: ../../library/asyncio-eventloop.rst:1257 msgid "Working with pipes" msgstr "使用管道" -#: ../../library/asyncio-eventloop.rst:1246 +#: ../../library/asyncio-eventloop.rst:1262 msgid "Register the read end of *pipe* in the event loop." msgstr "在事件迴圈中註冊 *pipe* 的讀取端。" -#: ../../library/asyncio-eventloop.rst:1251 +#: ../../library/asyncio-eventloop.rst:1267 msgid "*pipe* is a :term:`file-like object `." msgstr "*pipe* 是 :term:`類檔案物件 `。" -#: ../../library/asyncio-eventloop.rst:1253 +#: ../../library/asyncio-eventloop.rst:1269 msgid "" "Return pair ``(transport, protocol)``, where *transport* supports the :class:" "`ReadTransport` interface and *protocol* is an object instantiated by the " @@ -1859,22 +1883,22 @@ msgstr "" "回傳 ``(transport, protocol)`` 對,其中 *transport* 支援 :class:" "`ReadTransport` 介面,*protocol* 是由 *protocol_factory* 實例化的物件。" -#: ../../library/asyncio-eventloop.rst:1257 -#: ../../library/asyncio-eventloop.rst:1274 +#: ../../library/asyncio-eventloop.rst:1273 +#: ../../library/asyncio-eventloop.rst:1290 msgid "" "With :class:`SelectorEventLoop` event loop, the *pipe* is set to non-" "blocking mode." msgstr "使用 :class:`SelectorEventLoop` 事件迴圈時,*pipe* 設置為非阻塞模式。" -#: ../../library/asyncio-eventloop.rst:1263 +#: ../../library/asyncio-eventloop.rst:1279 msgid "Register the write end of *pipe* in the event loop." msgstr "在事件迴圈中註冊 *pipe* 的寫入端。" -#: ../../library/asyncio-eventloop.rst:1268 +#: ../../library/asyncio-eventloop.rst:1284 msgid "*pipe* is :term:`file-like object `." msgstr "*pipe* 是 :term:`file-like object `。" -#: ../../library/asyncio-eventloop.rst:1270 +#: ../../library/asyncio-eventloop.rst:1286 msgid "" "Return pair ``(transport, protocol)``, where *transport* supports :class:" "`WriteTransport` interface and *protocol* is an object instantiated by the " @@ -1883,7 +1907,7 @@ msgstr "" "回傳 ``(transport, protocol)`` 對,其中 *transport* 支援 :class:" "`WriteTransport` 介面,*protocol* 是由 *protocol_factory* 實例化的物件。" -#: ../../library/asyncio-eventloop.rst:1279 +#: ../../library/asyncio-eventloop.rst:1295 msgid "" ":class:`SelectorEventLoop` does not support the above methods on Windows. " "Use :class:`ProactorEventLoop` instead for Windows." @@ -1891,20 +1915,20 @@ msgstr "" ":class:`SelectorEventLoop` 在 Windows 上不支援上述方法。對於 Windows 請使用 :" "class:`ProactorEventLoop`。" -#: ../../library/asyncio-eventloop.rst:1284 +#: ../../library/asyncio-eventloop.rst:1300 msgid "" "The :meth:`loop.subprocess_exec` and :meth:`loop.subprocess_shell` methods." msgstr ":meth:`loop.subprocess_exec` 和 :meth:`loop.subprocess_shell` 方法。" -#: ../../library/asyncio-eventloop.rst:1289 +#: ../../library/asyncio-eventloop.rst:1305 msgid "Unix signals" msgstr "Unix 訊號" -#: ../../library/asyncio-eventloop.rst:1295 +#: ../../library/asyncio-eventloop.rst:1311 msgid "Set *callback* as the handler for the *signum* signal." msgstr "將 *callback* 設置為 *signum* 訊號的處理程式。" -#: ../../library/asyncio-eventloop.rst:1297 +#: ../../library/asyncio-eventloop.rst:1313 msgid "" "The callback will be invoked by *loop*, along with other queued callbacks " "and runnable coroutines of that event loop. Unlike signal handlers " @@ -1915,7 +1939,7 @@ msgstr "" "用 :func:`signal.signal` 註冊的訊號處理程式不同,使用此函式註冊的回呼允許與事" "件迴圈進行互動。" -#: ../../library/asyncio-eventloop.rst:1302 +#: ../../library/asyncio-eventloop.rst:1318 msgid "" "Raise :exc:`ValueError` if the signal number is invalid or uncatchable. " "Raise :exc:`RuntimeError` if there is a problem setting up the handler." @@ -1923,16 +1947,16 @@ msgstr "" "如果訊號號無效或不可捕獲,引發 :exc:`ValueError`。如果設定處理程序有問題,拋" "出 :exc:`RuntimeError`。" -#: ../../library/asyncio-eventloop.rst:1308 +#: ../../library/asyncio-eventloop.rst:1324 msgid "" "Like :func:`signal.signal`, this function must be invoked in the main thread." msgstr "像 :func:`signal.signal` 一樣,此函式必須在主執行緒中叫用。" -#: ../../library/asyncio-eventloop.rst:1313 +#: ../../library/asyncio-eventloop.rst:1329 msgid "Remove the handler for the *sig* signal." msgstr "移除 *sig* 訊號的處理程式。" -#: ../../library/asyncio-eventloop.rst:1315 +#: ../../library/asyncio-eventloop.rst:1331 msgid "" "Return ``True`` if the signal handler was removed, or ``False`` if no " "handler was set for the given signal." @@ -1940,19 +1964,19 @@ msgstr "" "如果訊號處理程式被移除,回傳 ``True``;如果給定訊號沒有設置處理程式,回傳 " "``False``。" -#: ../../library/asyncio-eventloop.rst:1322 +#: ../../library/asyncio-eventloop.rst:1338 msgid "The :mod:`signal` module." msgstr ":mod:`signal` 模組。" -#: ../../library/asyncio-eventloop.rst:1326 +#: ../../library/asyncio-eventloop.rst:1342 msgid "Executing code in thread or process pools" msgstr "在執行緒池或行程池中執行程式碼" -#: ../../library/asyncio-eventloop.rst:1330 +#: ../../library/asyncio-eventloop.rst:1346 msgid "Arrange for *func* to be called in the specified executor." msgstr "安排在指定的執行器中呼叫 *func*。" -#: ../../library/asyncio-eventloop.rst:1332 +#: ../../library/asyncio-eventloop.rst:1348 msgid "" "The *executor* argument should be an :class:`concurrent.futures.Executor` " "instance. The default executor is used if *executor* is ``None``. The " @@ -1961,7 +1985,7 @@ msgid "" "and used by :func:`run_in_executor` if needed." msgstr "" -#: ../../library/asyncio-eventloop.rst:1340 +#: ../../library/asyncio-eventloop.rst:1356 msgid "" "import asyncio\n" "import concurrent.futures\n" @@ -2000,11 +2024,17 @@ msgid "" " pool, cpu_bound)\n" " print('custom process pool', result)\n" "\n" +" # 4. Run in a custom interpreter pool:\n" +" with concurrent.futures.InterpreterPoolExecutor() as pool:\n" +" result = await loop.run_in_executor(\n" +" pool, cpu_bound)\n" +" print('custom interpreter pool', result)\n" +"\n" "if __name__ == '__main__':\n" " asyncio.run(main())" msgstr "" -#: ../../library/asyncio-eventloop.rst:1380 +#: ../../library/asyncio-eventloop.rst:1402 msgid "" "Note that the entry point guard (``if __name__ == '__main__'``) is required " "for option 3 due to the peculiarities of :mod:`multiprocessing`, which is " @@ -2016,11 +2046,11 @@ msgstr "" "== '__main__'``\\ )。請參閱\\ :ref:`主模組的安全引入 `。" -#: ../../library/asyncio-eventloop.rst:1385 +#: ../../library/asyncio-eventloop.rst:1407 msgid "This method returns a :class:`asyncio.Future` object." msgstr "此方法回傳 :class:`asyncio.Future` 物件。" -#: ../../library/asyncio-eventloop.rst:1387 +#: ../../library/asyncio-eventloop.rst:1409 msgid "" "Use :func:`functools.partial` :ref:`to pass keyword arguments ` to *func*." @@ -2028,7 +2058,7 @@ msgstr "" "使用 :func:`functools.partial` 將來\\ :ref:`關鍵字引數傳遞 `\\ 給 *func*。" -#: ../../library/asyncio-eventloop.rst:1390 +#: ../../library/asyncio-eventloop.rst:1412 msgid "" ":meth:`loop.run_in_executor` no longer configures the ``max_workers`` of the " "thread pool executor it creates, instead leaving it up to the thread pool " @@ -2039,35 +2069,37 @@ msgstr "" "``max_workers``,而是讓執行緒池執行器(\\ :class:`~concurrent.futures." "ThreadPoolExecutor`)設定預設值。" -#: ../../library/asyncio-eventloop.rst:1399 +#: ../../library/asyncio-eventloop.rst:1421 msgid "" "Set *executor* as the default executor used by :meth:`run_in_executor`. " "*executor* must be an instance of :class:`~concurrent.futures." -"ThreadPoolExecutor`." +"ThreadPoolExecutor`, which includes :class:`~concurrent.futures." +"InterpreterPoolExecutor`." msgstr "" "將 *executor* 設置為 :meth:`run_in_executor` 使用的預設執行器。*executor* 必" -"須是 :class:`~concurrent.futures.ThreadPoolExecutor` 的實例。" +"須是 :class:`~concurrent.futures.ThreadPoolExecutor`\\ (也包含 :class:" +"`~concurrent.futures.InterpreterPoolExecutor`)的實例。" -#: ../../library/asyncio-eventloop.rst:1403 +#: ../../library/asyncio-eventloop.rst:1426 msgid "" "*executor* must be an instance of :class:`~concurrent.futures." "ThreadPoolExecutor`." msgstr "" "*executor* 必須是 :class:`~concurrent.futures.ThreadPoolExecutor` 的實例。" -#: ../../library/asyncio-eventloop.rst:1409 +#: ../../library/asyncio-eventloop.rst:1432 msgid "Error Handling API" msgstr "錯誤處理 API" -#: ../../library/asyncio-eventloop.rst:1411 +#: ../../library/asyncio-eventloop.rst:1434 msgid "Allows customizing how exceptions are handled in the event loop." msgstr "允許自定義事件迴圈中的例外處理方式。" -#: ../../library/asyncio-eventloop.rst:1415 +#: ../../library/asyncio-eventloop.rst:1438 msgid "Set *handler* as the new event loop exception handler." msgstr "將 *handler* 設定為新的事件迴圈例外處理程式。" -#: ../../library/asyncio-eventloop.rst:1417 +#: ../../library/asyncio-eventloop.rst:1440 msgid "" "If *handler* is ``None``, the default exception handler will be set. " "Otherwise, *handler* must be a callable with the signature matching ``(loop, " @@ -2080,7 +2112,7 @@ msgstr "" "圈的,``context`` 是包含例外詳細資訊的 ``dict`` 物件(有關情境的詳細資訊,請" "參閱 :meth:`call_exception_handler` 文件)。" -#: ../../library/asyncio-eventloop.rst:1425 +#: ../../library/asyncio-eventloop.rst:1448 msgid "" "If the handler is called on behalf of a :class:`~asyncio.Task` or :class:" "`~asyncio.Handle`, it is run in the :class:`contextvars.Context` of that " @@ -2089,7 +2121,7 @@ msgstr "" "如果代表 :class:`~asyncio.Task` 或 :class:`~asyncio.Handle` 呼叫處理程式,它" "將在該任務或回呼處理程式的 :class:`contextvars.Context` 中運行。" -#: ../../library/asyncio-eventloop.rst:1431 +#: ../../library/asyncio-eventloop.rst:1454 msgid "" "The handler may be called in the :class:`~contextvars.Context` of the task " "or handle where the exception originated." @@ -2097,18 +2129,18 @@ msgstr "" "處理程式可能在引發例外的任務或處理程式的 :class:`~contextvars.Context` 中被呼" "叫。" -#: ../../library/asyncio-eventloop.rst:1436 +#: ../../library/asyncio-eventloop.rst:1459 msgid "" "Return the current exception handler, or ``None`` if no custom exception " "handler was set." msgstr "" "回傳目前的例外處理程式,如果未設置自定義例外處理程式,則回傳 ``None``。" -#: ../../library/asyncio-eventloop.rst:1443 +#: ../../library/asyncio-eventloop.rst:1466 msgid "Default exception handler." msgstr "預設例外處理程式。" -#: ../../library/asyncio-eventloop.rst:1445 +#: ../../library/asyncio-eventloop.rst:1468 msgid "" "This is called when an exception occurs and no exception handler is set. " "This can be called by a custom exception handler that wants to defer to the " @@ -2117,17 +2149,17 @@ msgstr "" "當發生例外且未設置例外處理程式時呼叫此函式。自定義例外處理程式可以呼叫此函式" "以轉由預設處理程式處理。" -#: ../../library/asyncio-eventloop.rst:1449 +#: ../../library/asyncio-eventloop.rst:1472 msgid "" "*context* parameter has the same meaning as in :meth:" "`call_exception_handler`." msgstr "*context* 參數與 :meth:`call_exception_handler` 中的意思相同。" -#: ../../library/asyncio-eventloop.rst:1454 +#: ../../library/asyncio-eventloop.rst:1477 msgid "Call the current event loop exception handler." msgstr "呼叫目前事件迴圈例外處理程式。" -#: ../../library/asyncio-eventloop.rst:1456 +#: ../../library/asyncio-eventloop.rst:1479 msgid "" "*context* is a ``dict`` object containing the following keys (new keys may " "be introduced in future Python versions):" @@ -2135,55 +2167,55 @@ msgstr "" "*context* 是一個包含以下鍵的 ``dict`` 物件(未來的 Python 版本中可能會引入新" "的鍵):" -#: ../../library/asyncio-eventloop.rst:1459 +#: ../../library/asyncio-eventloop.rst:1482 msgid "'message': Error message;" msgstr "'message':錯誤訊息;" -#: ../../library/asyncio-eventloop.rst:1460 +#: ../../library/asyncio-eventloop.rst:1483 msgid "'exception' (optional): Exception object;" msgstr "'exception'(可選):例外物件;" -#: ../../library/asyncio-eventloop.rst:1461 +#: ../../library/asyncio-eventloop.rst:1484 msgid "'future' (optional): :class:`asyncio.Future` instance;" msgstr "'future'(可選): :class:`asyncio.Future` 實例;" -#: ../../library/asyncio-eventloop.rst:1462 +#: ../../library/asyncio-eventloop.rst:1485 msgid "'task' (optional): :class:`asyncio.Task` instance;" msgstr "'task'(可選): :class:`asyncio.Task` 實例;" -#: ../../library/asyncio-eventloop.rst:1463 +#: ../../library/asyncio-eventloop.rst:1486 msgid "'handle' (optional): :class:`asyncio.Handle` instance;" msgstr "'handle'(可選): :class:`asyncio.Handle` 實例;" -#: ../../library/asyncio-eventloop.rst:1464 +#: ../../library/asyncio-eventloop.rst:1487 msgid "'protocol' (optional): :ref:`Protocol ` instance;" msgstr "'protocol'(可選): :ref:`Protocol ` 實例;" -#: ../../library/asyncio-eventloop.rst:1465 +#: ../../library/asyncio-eventloop.rst:1488 msgid "'transport' (optional): :ref:`Transport ` instance;" msgstr "'transport'(可選): :ref:`Transport ` 實例;" -#: ../../library/asyncio-eventloop.rst:1466 +#: ../../library/asyncio-eventloop.rst:1489 msgid "'socket' (optional): :class:`socket.socket` instance;" msgstr "'socket'(可選): :class:`socket.socket` 實例;" -#: ../../library/asyncio-eventloop.rst:1467 +#: ../../library/asyncio-eventloop.rst:1490 msgid "'source_traceback' (optional): Traceback of the source;" msgstr "" -#: ../../library/asyncio-eventloop.rst:1468 +#: ../../library/asyncio-eventloop.rst:1491 msgid "'handle_traceback' (optional): Traceback of the handle;" msgstr "" -#: ../../library/asyncio-eventloop.rst:1469 +#: ../../library/asyncio-eventloop.rst:1492 msgid "'asyncgen' (optional): Asynchronous generator that caused" msgstr "'asyncgen'(可選): 非同步產生器引發" -#: ../../library/asyncio-eventloop.rst:1470 +#: ../../library/asyncio-eventloop.rst:1493 msgid "the exception." msgstr "例外。" -#: ../../library/asyncio-eventloop.rst:1474 +#: ../../library/asyncio-eventloop.rst:1497 msgid "" "This method should not be overloaded in subclassed event loops. For custom " "exception handling, use the :meth:`set_exception_handler` method." @@ -2191,15 +2223,15 @@ msgstr "" "此方法不應在子類別事件迴圈中被覆寫。為了自定義例外處理,請使用 :meth:" "`set_exception_handler` 方法。" -#: ../../library/asyncio-eventloop.rst:1479 +#: ../../library/asyncio-eventloop.rst:1502 msgid "Enabling debug mode" msgstr "啟用除錯模式" -#: ../../library/asyncio-eventloop.rst:1483 +#: ../../library/asyncio-eventloop.rst:1506 msgid "Get the debug mode (:class:`bool`) of the event loop." msgstr "取得事件迴圈的除錯模式(\\ :class:`bool`\\ )。" -#: ../../library/asyncio-eventloop.rst:1485 +#: ../../library/asyncio-eventloop.rst:1508 msgid "" "The default value is ``True`` if the environment variable :envvar:" "`PYTHONASYNCIODEBUG` is set to a non-empty string, ``False`` otherwise." @@ -2207,17 +2239,17 @@ msgstr "" "如果環境變數 :envvar:`PYTHONASYNCIODEBUG` 被設定為非空字串,則預設值為 " "``True``,否則為 ``False``。" -#: ../../library/asyncio-eventloop.rst:1491 +#: ../../library/asyncio-eventloop.rst:1514 msgid "Set the debug mode of the event loop." msgstr "設定事件迴圈的除錯模式。" -#: ../../library/asyncio-eventloop.rst:1495 +#: ../../library/asyncio-eventloop.rst:1518 msgid "" "The new :ref:`Python Development Mode ` can now also be used to " "enable the debug mode." msgstr "現在也可以使用新的 :ref:`Python 開發模式 ` 啟用除錯模式。" -#: ../../library/asyncio-eventloop.rst:1500 +#: ../../library/asyncio-eventloop.rst:1523 msgid "" "This attribute can be used to set the minimum execution duration in seconds " "that is considered \"slow\". When debug mode is enabled, \"slow\" callbacks " @@ -2226,19 +2258,19 @@ msgstr "" "此屬性可用於設定被視為\"慢\"的最短執行時間(以秒為單位)。啟用偵錯模式" "後,\"慢\"回呼將被記錄。" -#: ../../library/asyncio-eventloop.rst:1504 +#: ../../library/asyncio-eventloop.rst:1527 msgid "Default value is 100 milliseconds." msgstr "預設值為 100 毫秒" -#: ../../library/asyncio-eventloop.rst:1508 +#: ../../library/asyncio-eventloop.rst:1531 msgid "The :ref:`debug mode of asyncio `." msgstr ":ref:`asyncio 的除錯模式 `。" -#: ../../library/asyncio-eventloop.rst:1512 +#: ../../library/asyncio-eventloop.rst:1535 msgid "Running Subprocesses" msgstr "運行子行程" -#: ../../library/asyncio-eventloop.rst:1514 +#: ../../library/asyncio-eventloop.rst:1537 msgid "" "Methods described in this subsections are low-level. In regular async/await " "code consider using the high-level :func:`asyncio.create_subprocess_shell` " @@ -2248,7 +2280,7 @@ msgstr "" "func:`asyncio.create_subprocess_shell` 和 :func:`asyncio." "create_subprocess_exec` 輔助功能而不是。" -#: ../../library/asyncio-eventloop.rst:1521 +#: ../../library/asyncio-eventloop.rst:1544 msgid "" "On Windows, the default event loop :class:`ProactorEventLoop` supports " "subprocesses, whereas :class:`SelectorEventLoop` does not. See :ref:" @@ -2258,26 +2290,26 @@ msgstr "" "`SelectorEventLoop` 不支援。詳細資訊請參見 :ref:`Windows 上對於子行程的支援 " "`。" -#: ../../library/asyncio-eventloop.rst:1533 +#: ../../library/asyncio-eventloop.rst:1556 msgid "" "Create a subprocess from one or more string arguments specified by *args*." msgstr "從 *args* 指定的一個或多個字串引數建立子行程。" -#: ../../library/asyncio-eventloop.rst:1536 +#: ../../library/asyncio-eventloop.rst:1559 msgid "*args* must be a list of strings represented by:" msgstr "*args* 必須是由以下項表示的字串串列:" -#: ../../library/asyncio-eventloop.rst:1538 +#: ../../library/asyncio-eventloop.rst:1561 msgid ":class:`str`;" msgstr ":class:`str`;" -#: ../../library/asyncio-eventloop.rst:1539 +#: ../../library/asyncio-eventloop.rst:1562 msgid "" "or :class:`bytes`, encoded to the :ref:`filesystem encoding `." msgstr "或 :class:`bytes`,編碼為 :ref:`檔案系統編碼 `。" -#: ../../library/asyncio-eventloop.rst:1542 +#: ../../library/asyncio-eventloop.rst:1565 msgid "" "The first string specifies the program executable, and the remaining strings " "specify the arguments. Together, string arguments form the ``argv`` of the " @@ -2286,7 +2318,7 @@ msgstr "" "第一個字串指定程序可執行檔案,其餘字串指定引數。字串引數一起組成程序的 " "``argv``。" -#: ../../library/asyncio-eventloop.rst:1546 +#: ../../library/asyncio-eventloop.rst:1569 msgid "" "This is similar to the standard library :class:`subprocess.Popen` class " "called with ``shell=False`` and the list of strings passed as the first " @@ -2297,7 +2329,7 @@ msgstr "" "字串串列作為第一個引數傳遞;然而,:class:`~subprocess.Popen` 接受單個字串串列" "引數,*subprocess_exec* 接受多個字串引數。" -#: ../../library/asyncio-eventloop.rst:1552 +#: ../../library/asyncio-eventloop.rst:1575 msgid "" "The *protocol_factory* must be a callable returning a subclass of the :class:" "`asyncio.SubprocessProtocol` class." @@ -2305,67 +2337,67 @@ msgstr "" "*protocol_factory* 必須是回傳 :class:`asyncio.SubprocessProtocol` 子類別的可" "呼叫物件。" -#: ../../library/asyncio-eventloop.rst:1555 +#: ../../library/asyncio-eventloop.rst:1578 msgid "Other parameters:" msgstr "其他參數:" -#: ../../library/asyncio-eventloop.rst:1557 +#: ../../library/asyncio-eventloop.rst:1580 msgid "*stdin* can be any of these:" msgstr "*stdin* 可以是以下任意一個:" -#: ../../library/asyncio-eventloop.rst:1559 -#: ../../library/asyncio-eventloop.rst:1570 -#: ../../library/asyncio-eventloop.rst:1580 +#: ../../library/asyncio-eventloop.rst:1582 +#: ../../library/asyncio-eventloop.rst:1593 +#: ../../library/asyncio-eventloop.rst:1603 msgid "a file-like object" msgstr "類檔案物件" -#: ../../library/asyncio-eventloop.rst:1560 +#: ../../library/asyncio-eventloop.rst:1583 msgid "" "an existing file descriptor (a positive integer), for example those created " "with :meth:`os.pipe`" msgstr "現有的檔案描述器(正整數),例如用 :meth:`os.pipe` 建立的" -#: ../../library/asyncio-eventloop.rst:1561 -#: ../../library/asyncio-eventloop.rst:1571 -#: ../../library/asyncio-eventloop.rst:1581 +#: ../../library/asyncio-eventloop.rst:1584 +#: ../../library/asyncio-eventloop.rst:1594 +#: ../../library/asyncio-eventloop.rst:1604 msgid "" "the :const:`subprocess.PIPE` constant (default) which will create a new pipe " "and connect it," msgstr ":const:`subprocess.PIPE` 常數(預設),它將建立一個新的管道並連線," -#: ../../library/asyncio-eventloop.rst:1563 -#: ../../library/asyncio-eventloop.rst:1573 -#: ../../library/asyncio-eventloop.rst:1583 +#: ../../library/asyncio-eventloop.rst:1586 +#: ../../library/asyncio-eventloop.rst:1596 +#: ../../library/asyncio-eventloop.rst:1606 msgid "" "the value ``None`` which will make the subprocess inherit the file " "descriptor from this process" msgstr "值 ``None`` 將使子行程從此行程繼承檔案描述器" -#: ../../library/asyncio-eventloop.rst:1565 -#: ../../library/asyncio-eventloop.rst:1575 -#: ../../library/asyncio-eventloop.rst:1585 +#: ../../library/asyncio-eventloop.rst:1588 +#: ../../library/asyncio-eventloop.rst:1598 +#: ../../library/asyncio-eventloop.rst:1608 msgid "" "the :const:`subprocess.DEVNULL` constant which indicates that the special :" "data:`os.devnull` file will be used" msgstr "" ":const:`subprocess.DEVNULL` 常數,表示將使用特殊的 :data:`os.devnull` 檔案" -#: ../../library/asyncio-eventloop.rst:1568 +#: ../../library/asyncio-eventloop.rst:1591 msgid "*stdout* can be any of these:" msgstr "*stdout* 可以是以下任意一個:" -#: ../../library/asyncio-eventloop.rst:1578 +#: ../../library/asyncio-eventloop.rst:1601 msgid "*stderr* can be any of these:" msgstr "*stderr* 可以是以下任意一個:" -#: ../../library/asyncio-eventloop.rst:1587 +#: ../../library/asyncio-eventloop.rst:1610 msgid "" "the :const:`subprocess.STDOUT` constant which will connect the standard " "error stream to the process' standard output stream" msgstr "" ":const:`subprocess.STDOUT` 常數,它將標準錯誤串流連線到行程的標準輸出串流" -#: ../../library/asyncio-eventloop.rst:1590 +#: ../../library/asyncio-eventloop.rst:1613 msgid "" "All other keyword arguments are passed to :class:`subprocess.Popen` without " "interpretation, except for *bufsize*, *universal_newlines*, *shell*, *text*, " @@ -2375,7 +2407,7 @@ msgstr "" "*bufsize*、*universal_newlines*、*shell*、*text*、*encoding* 和 *errors* 除" "外,這些不應該指定。" -#: ../../library/asyncio-eventloop.rst:1595 +#: ../../library/asyncio-eventloop.rst:1618 msgid "" "The ``asyncio`` subprocess API does not support decoding the streams as " "text. :func:`bytes.decode` can be used to convert the bytes returned from " @@ -2384,7 +2416,7 @@ msgstr "" "``asyncio`` 子行程 API 不支援將串流解碼為文本。可以使用 :func:`bytes.decode` " "將從串流回傳的位元組轉換為文本。" -#: ../../library/asyncio-eventloop.rst:1599 +#: ../../library/asyncio-eventloop.rst:1622 msgid "" "If a file-like object passed as *stdin*, *stdout* or *stderr* represents a " "pipe, then the other side of this pipe should be registered with :meth:" @@ -2395,13 +2427,13 @@ msgstr "" "端應該使用 :meth:`~loop.connect_write_pipe` 或 :meth:`~loop." "connect_read_pipe` 註冊到事件迴圈中。" -#: ../../library/asyncio-eventloop.rst:1604 +#: ../../library/asyncio-eventloop.rst:1627 msgid "" "See the constructor of the :class:`subprocess.Popen` class for documentation " "on other arguments." msgstr "有關其他引數的文件,請參閱 :class:`subprocess.Popen` 類別的建構函式。" -#: ../../library/asyncio-eventloop.rst:1607 +#: ../../library/asyncio-eventloop.rst:1630 msgid "" "Returns a pair of ``(transport, protocol)``, where *transport* conforms to " "the :class:`asyncio.SubprocessTransport` base class and *protocol* is an " @@ -2411,7 +2443,14 @@ msgstr "" "SubprocessTransport` 基底類別,*protocol* 是由 *protocol_factory* 實例化的物" "件。" -#: ../../library/asyncio-eventloop.rst:1616 +#: ../../library/asyncio-eventloop.rst:1634 +#: ../../library/asyncio-eventloop.rst:1660 +msgid "" +"If the transport is closed or is garbage collected, the child process is " +"killed if it is still running." +msgstr "" + +#: ../../library/asyncio-eventloop.rst:1642 msgid "" "Create a subprocess from *cmd*, which can be a :class:`str` or a :class:" "`bytes` string encoded to the :ref:`filesystem encoding ` 的 :class:`bytes` 字串。" -#: ../../library/asyncio-eventloop.rst:1621 +#: ../../library/asyncio-eventloop.rst:1647 msgid "" "This is similar to the standard library :class:`subprocess.Popen` class " "called with ``shell=True``." @@ -2428,7 +2467,7 @@ msgstr "" "這類似於標準函式庫中的 :class:`subprocess.Popen` 類別,使用 ``shell=True`` 呼" "叫。" -#: ../../library/asyncio-eventloop.rst:1624 +#: ../../library/asyncio-eventloop.rst:1650 msgid "" "The *protocol_factory* must be a callable returning a subclass of the :class:" "`SubprocessProtocol` class." @@ -2436,13 +2475,13 @@ msgstr "" "*protocol_factory* 必須是回傳 :class:`SubprocessProtocol` 子類別的可呼叫物" "件。" -#: ../../library/asyncio-eventloop.rst:1627 +#: ../../library/asyncio-eventloop.rst:1653 msgid "" "See :meth:`~loop.subprocess_exec` for more details about the remaining " "arguments." msgstr "有關其餘引數的更多詳細資訊,請參閱 :meth:`~loop.subprocess_exec`。" -#: ../../library/asyncio-eventloop.rst:1630 +#: ../../library/asyncio-eventloop.rst:1656 msgid "" "Returns a pair of ``(transport, protocol)``, where *transport* conforms to " "the :class:`SubprocessTransport` base class and *protocol* is an object " @@ -2452,7 +2491,7 @@ msgstr "" "`SubprocessTransport` 基底類別,而 *protocol* 是由 *protocol_factory* 實例化" "的物件。" -#: ../../library/asyncio-eventloop.rst:1635 +#: ../../library/asyncio-eventloop.rst:1664 msgid "" "It is the application's responsibility to ensure that all whitespace and " "special characters are quoted appropriately to avoid `shell injection " @@ -2465,11 +2504,11 @@ msgstr "" "wikipedia.org/wiki/Shell_injection#Shell_injection>`_\\ 風險。可以使用 :func:" "`shlex.quote` 函式來正確跳脫用於構建 shell 命令的字串中的空白和特殊字元。" -#: ../../library/asyncio-eventloop.rst:1644 +#: ../../library/asyncio-eventloop.rst:1673 msgid "Callback Handles" msgstr "回呼處理" -#: ../../library/asyncio-eventloop.rst:1648 +#: ../../library/asyncio-eventloop.rst:1677 msgid "" "A callback wrapper object returned by :meth:`loop.call_soon`, :meth:`loop." "call_soon_threadsafe`." @@ -2477,46 +2516,46 @@ msgstr "" "由 :meth:`loop.call_soon` 和 :meth:`loop.call_soon_threadsafe` 回傳的回呼包裝" "器。" -#: ../../library/asyncio-eventloop.rst:1653 +#: ../../library/asyncio-eventloop.rst:1682 msgid "" "Return the :class:`contextvars.Context` object associated with the handle." msgstr "回傳與處理相關聯的 :class:`contextvars.Context` 物件。" -#: ../../library/asyncio-eventloop.rst:1660 +#: ../../library/asyncio-eventloop.rst:1689 msgid "" "Cancel the callback. If the callback has already been canceled or executed, " "this method has no effect." msgstr "取消回呼。如果回呼已被取消或執行,此方法將不起作用。" -#: ../../library/asyncio-eventloop.rst:1665 +#: ../../library/asyncio-eventloop.rst:1694 msgid "Return ``True`` if the callback was cancelled." msgstr "如果回呼已被取消,回傳 ``True``。" -#: ../../library/asyncio-eventloop.rst:1671 +#: ../../library/asyncio-eventloop.rst:1700 msgid "" "A callback wrapper object returned by :meth:`loop.call_later`, and :meth:" "`loop.call_at`." msgstr "由 :meth:`loop.call_later` 和 :meth:`loop.call_at` 回傳的回呼包裝器。" -#: ../../library/asyncio-eventloop.rst:1674 +#: ../../library/asyncio-eventloop.rst:1703 msgid "This class is a subclass of :class:`Handle`." msgstr "這個類別是 :class:`Handle` 的子類別。" -#: ../../library/asyncio-eventloop.rst:1678 +#: ../../library/asyncio-eventloop.rst:1707 msgid "Return a scheduled callback time as :class:`float` seconds." msgstr "回傳預定的回呼時間,以 :class:`float` 秒為單位。" -#: ../../library/asyncio-eventloop.rst:1680 +#: ../../library/asyncio-eventloop.rst:1709 msgid "" "The time is an absolute timestamp, using the same time reference as :meth:" "`loop.time`." msgstr "時間是一個絕對的時間戳,使用與 :meth:`loop.time` 相同的時間參照。" -#: ../../library/asyncio-eventloop.rst:1687 +#: ../../library/asyncio-eventloop.rst:1716 msgid "Server Objects" msgstr "Server 物件" -#: ../../library/asyncio-eventloop.rst:1689 +#: ../../library/asyncio-eventloop.rst:1718 msgid "" "Server objects are created by :meth:`loop.create_server`, :meth:`loop." "create_unix_server`, :func:`start_server`, and :func:`start_unix_server` " @@ -2526,11 +2565,11 @@ msgstr "" "create_unix_server`、:func:`start_server` 和 :func:`start_unix_server` 函式所" "建立。" -#: ../../library/asyncio-eventloop.rst:1693 +#: ../../library/asyncio-eventloop.rst:1722 msgid "Do not instantiate the :class:`Server` class directly." msgstr "請勿直接實例化 :class:`Server` 類別。" -#: ../../library/asyncio-eventloop.rst:1697 +#: ../../library/asyncio-eventloop.rst:1726 msgid "" "*Server* objects are asynchronous context managers. When used in an ``async " "with`` statement, it's guaranteed that the Server object is closed and not " @@ -2539,7 +2578,7 @@ msgstr "" "*Server* 物件是非同步情境管理器。當在 ``async with`` 陳述中使用時,可以保證在" "完成 ``async with`` 陳述時,Server 物件將會關閉並停止接受新的連線: ::" -#: ../../library/asyncio-eventloop.rst:1702 +#: ../../library/asyncio-eventloop.rst:1731 msgid "" "srv = await loop.create_server(...)\n" "\n" @@ -2555,84 +2594,84 @@ msgstr "" "\n" "# 此時 srv 已關閉,不再接受新的連線。" -#: ../../library/asyncio-eventloop.rst:1710 +#: ../../library/asyncio-eventloop.rst:1739 msgid "Server object is an asynchronous context manager since Python 3.7." msgstr "自 Python 3.7 起,Server 物件是非同步情境管理器。" -#: ../../library/asyncio-eventloop.rst:1713 +#: ../../library/asyncio-eventloop.rst:1742 msgid "" "This class was exposed publicly as ``asyncio.Server`` in Python 3.9.11, " "3.10.3 and 3.11." msgstr "" "此類別在 Python 3.9.11、3.10.3 和 3.11 中以 ``asyncio.Server`` 的形式被公開。" -#: ../../library/asyncio-eventloop.rst:1718 +#: ../../library/asyncio-eventloop.rst:1747 msgid "" "Stop serving: close listening sockets and set the :attr:`sockets` attribute " "to ``None``." msgstr "停止服務:關閉監聽的 sockets 並將 :attr:`sockets` 屬性設為 ``None``。" -#: ../../library/asyncio-eventloop.rst:1721 +#: ../../library/asyncio-eventloop.rst:1750 msgid "" "The sockets that represent existing incoming client connections are left " "open." msgstr "代表現有傳入用戶端連線的 sockets 仍然保持開啟。" -#: ../../library/asyncio-eventloop.rst:1724 +#: ../../library/asyncio-eventloop.rst:1753 msgid "" "The server is closed asynchronously; use the :meth:`wait_closed` coroutine " "to wait until the server is closed (and no more connections are active)." msgstr "" -"伺服器以非同步方式關閉;使用 :meth:`wait_close` 協程等待伺服器關閉(不再有活" +"伺服器以非同步方式關閉;使用 :meth:`wait_closed` 協程等待伺服器關閉(不再有活" "躍連線)。" -#: ../../library/asyncio-eventloop.rst:1730 +#: ../../library/asyncio-eventloop.rst:1759 msgid "Close all existing incoming client connections." msgstr "關閉所有現有的傳入用戶端連線。" -#: ../../library/asyncio-eventloop.rst:1732 +#: ../../library/asyncio-eventloop.rst:1761 msgid "" "Calls :meth:`~asyncio.BaseTransport.close` on all associated transports." msgstr "在所有關聯的傳輸上呼叫 :meth:`~asyncio.BaseTransport.close`。" -#: ../../library/asyncio-eventloop.rst:1735 +#: ../../library/asyncio-eventloop.rst:1764 msgid "" ":meth:`close` should be called before :meth:`close_clients` when closing the " "server to avoid races with new clients connecting." msgstr "" -#: ../../library/asyncio-eventloop.rst:1742 +#: ../../library/asyncio-eventloop.rst:1771 msgid "" "Close all existing incoming client connections immediately, without waiting " "for pending operations to complete." msgstr "立即關閉所有現有的傳入用戶端連線,而不等待待定操作完成。" -#: ../../library/asyncio-eventloop.rst:1745 +#: ../../library/asyncio-eventloop.rst:1774 msgid "" "Calls :meth:`~asyncio.WriteTransport.abort` on all associated transports." -msgstr "在所有關聯的傳輸上呼叫 :meth:`~asyncio.BaseTransport.close`。" +msgstr "在所有關聯的傳輸上呼叫 :meth:`~asyncio.WriteTransport.abort`。" -#: ../../library/asyncio-eventloop.rst:1748 +#: ../../library/asyncio-eventloop.rst:1777 msgid "" ":meth:`close` should be called before :meth:`abort_clients` when closing the " "server to avoid races with new clients connecting." msgstr "" -#: ../../library/asyncio-eventloop.rst:1755 +#: ../../library/asyncio-eventloop.rst:1784 msgid "Return the event loop associated with the server object." msgstr "回傳與伺服器物件關聯的事件迴圈。" -#: ../../library/asyncio-eventloop.rst:1762 +#: ../../library/asyncio-eventloop.rst:1791 msgid "Start accepting connections." msgstr "開始接受連線。" -#: ../../library/asyncio-eventloop.rst:1764 +#: ../../library/asyncio-eventloop.rst:1793 msgid "" "This method is idempotent, so it can be called when the server is already " "serving." msgstr "此方法是幂等的,因此可以在伺服器已經運行時呼叫。" -#: ../../library/asyncio-eventloop.rst:1767 +#: ../../library/asyncio-eventloop.rst:1796 msgid "" "The *start_serving* keyword-only parameter to :meth:`loop.create_server` " "and :meth:`asyncio.start_server` allows creating a Server object that is not " @@ -2645,14 +2684,14 @@ msgstr "" "種情況下,可以使用 ``Server.start_serving()`` 或 :meth:`Server." "serve_forever` 來使 Server 開始接受連線。" -#: ../../library/asyncio-eventloop.rst:1779 +#: ../../library/asyncio-eventloop.rst:1808 msgid "" "Start accepting connections until the coroutine is cancelled. Cancellation " "of ``serve_forever`` task causes the server to be closed." msgstr "" "開始接受連線,直到協程被取消。取消 ``serve_forever`` 任務會導致伺服器關閉。" -#: ../../library/asyncio-eventloop.rst:1783 +#: ../../library/asyncio-eventloop.rst:1812 msgid "" "This method can be called if the server is already accepting connections. " "Only one ``serve_forever`` task can exist per one *Server* object." @@ -2660,7 +2699,7 @@ msgstr "" "如果伺服器已經接受連線,則可以呼叫此方法。每個 *Server* 物件只能存在一個 " "``serve_forever`` 任務。" -#: ../../library/asyncio-eventloop.rst:1789 +#: ../../library/asyncio-eventloop.rst:1818 msgid "" "async def client_connected(reader, writer):\n" " # Communicate with the client with\n" @@ -2686,24 +2725,24 @@ msgstr "" "\n" "asyncio.run(main('127.0.0.1', 0))" -#: ../../library/asyncio-eventloop.rst:1805 +#: ../../library/asyncio-eventloop.rst:1834 msgid "Return ``True`` if the server is accepting new connections." msgstr "如果伺服器正在接受新連線,則回傳 ``True``。" -#: ../../library/asyncio-eventloop.rst:1812 +#: ../../library/asyncio-eventloop.rst:1841 msgid "" "Wait until the :meth:`close` method completes and all active connections " "have finished." msgstr "等待 :meth:`close` 方法完成且所有活動連線都已結束。" -#: ../../library/asyncio-eventloop.rst:1817 +#: ../../library/asyncio-eventloop.rst:1846 msgid "" "List of socket-like objects, ``asyncio.trsock.TransportSocket``, which the " "server is listening on." msgstr "" "伺服器正在監聽的類似 socket 的物件串列,``asyncio.trsock.TransportSocket``。" -#: ../../library/asyncio-eventloop.rst:1820 +#: ../../library/asyncio-eventloop.rst:1849 msgid "" "Prior to Python 3.7 ``Server.sockets`` used to return an internal list of " "server sockets directly. In 3.7 a copy of that list is returned." @@ -2711,11 +2750,11 @@ msgstr "" "在 Python 3.7 之前,``Server.sockets`` 曾經直接回傳內部伺服器 sockets 的串" "列。在 3.7 中回傳了該串列的副本。" -#: ../../library/asyncio-eventloop.rst:1830 +#: ../../library/asyncio-eventloop.rst:1859 msgid "Event Loop Implementations" msgstr "事件迴圈實作" -#: ../../library/asyncio-eventloop.rst:1832 +#: ../../library/asyncio-eventloop.rst:1861 msgid "" "asyncio ships with two different event loop implementations: :class:" "`SelectorEventLoop` and :class:`ProactorEventLoop`." @@ -2723,17 +2762,17 @@ msgstr "" "asyncio 內附兩個不同的事件迴圈實作::class:`SelectorEventLoop` 和 :class:" "`ProactorEventLoop`。" -#: ../../library/asyncio-eventloop.rst:1835 +#: ../../library/asyncio-eventloop.rst:1864 msgid "By default asyncio is configured to use :class:`EventLoop`." msgstr "預設情況下,asyncio 被配置為要使用 :class:`EventLoop`。" -#: ../../library/asyncio-eventloop.rst:1840 +#: ../../library/asyncio-eventloop.rst:1869 msgid "" "A subclass of :class:`AbstractEventLoop` based on the :mod:`selectors` " "module." msgstr "基於 :mod:`selectors` 模組的一個 :class:`AbstractEventLoop` 子類別。" -#: ../../library/asyncio-eventloop.rst:1843 +#: ../../library/asyncio-eventloop.rst:1872 msgid "" "Uses the most efficient *selector* available for the given platform. It is " "also possible to manually configure the exact selector implementation to be " @@ -2742,29 +2781,20 @@ msgstr "" "使用特定平台上最有效的 *selector*。也可以手動配置要使用的確切 selector 實" "作: ::" -#: ../../library/asyncio-eventloop.rst:1847 +#: ../../library/asyncio-eventloop.rst:1876 msgid "" "import asyncio\n" "import selectors\n" "\n" -"class MyPolicy(asyncio.DefaultEventLoopPolicy):\n" -" def new_event_loop(self):\n" -" selector = selectors.SelectSelector()\n" -" return asyncio.SelectorEventLoop(selector)\n" +"async def main():\n" +" ...\n" "\n" -"asyncio.set_event_loop_policy(MyPolicy())" +"loop_factory = lambda: asyncio.SelectorEventLoop(selectors." +"SelectSelector())\n" +"asyncio.run(main(), loop_factory=loop_factory)" msgstr "" -"import asyncio\n" -"import selectors\n" -"\n" -"class MyPolicy(asyncio.DefaultEventLoopPolicy):\n" -" def new_event_loop(self):\n" -" selector = selectors.SelectSelector()\n" -" return asyncio.SelectorEventLoop(selector)\n" -"\n" -"asyncio.set_event_loop_policy(MyPolicy())" -#: ../../library/asyncio-eventloop.rst:1863 +#: ../../library/asyncio-eventloop.rst:1891 msgid "" "A subclass of :class:`AbstractEventLoop` for Windows that uses \"I/O " "Completion Ports\" (IOCP)." @@ -2772,7 +2802,7 @@ msgstr "" "用於 Windows 的 :class:`AbstractEventLoop` 子類別,使用「I/O 完成埠 (IOCP, I/" "O Completion Ports)」。" -#: ../../library/asyncio-eventloop.rst:1869 +#: ../../library/asyncio-eventloop.rst:1897 msgid "" "`MSDN documentation on I/O Completion Ports `_." @@ -2780,13 +2810,13 @@ msgstr "" "`I/O 完成埠的 MSDN 文件 `_。" -#: ../../library/asyncio-eventloop.rst:1874 +#: ../../library/asyncio-eventloop.rst:1902 msgid "" "An alias to the most efficient available subclass of :class:" "`AbstractEventLoop` for the given platform." msgstr "" -#: ../../library/asyncio-eventloop.rst:1877 +#: ../../library/asyncio-eventloop.rst:1905 msgid "" "It is an alias to :class:`SelectorEventLoop` on Unix and :class:" "`ProactorEventLoop` on Windows." @@ -2794,11 +2824,11 @@ msgstr "" "在 Unix 上是 :class:`SelectorEventLoop` 的別名,在 Windows 上是 :class:" "`ProactorEventLoop` 的別名。" -#: ../../library/asyncio-eventloop.rst:1883 +#: ../../library/asyncio-eventloop.rst:1911 msgid "Abstract base class for asyncio-compliant event loops." msgstr "為符合 asyncio 標準的事件迴圈的抽象基礎類別。" -#: ../../library/asyncio-eventloop.rst:1885 +#: ../../library/asyncio-eventloop.rst:1913 msgid "" "The :ref:`asyncio-event-loop-methods` section lists all methods that an " "alternative implementation of ``AbstractEventLoop`` should have defined." @@ -2806,11 +2836,11 @@ msgstr "" ":ref:`asyncio-event-loop-methods` 部分列出了替代 ``AbstractEventLoop`` 實作應" "該定義的所有方法。" -#: ../../library/asyncio-eventloop.rst:1891 +#: ../../library/asyncio-eventloop.rst:1919 msgid "Examples" msgstr "範例" -#: ../../library/asyncio-eventloop.rst:1893 +#: ../../library/asyncio-eventloop.rst:1921 msgid "" "Note that all examples in this section **purposefully** show how to use the " "low-level event loop APIs, such as :meth:`loop.run_forever` and :meth:`loop." @@ -2821,11 +2851,11 @@ msgstr "" "`loop.run_forever` 和 :meth:`loop.call_soon`。現代 asyncio 應用程式很少需要這" "種方式撰寫;請考慮使用高階的函式,如 :func:`asyncio.run`。" -#: ../../library/asyncio-eventloop.rst:1903 +#: ../../library/asyncio-eventloop.rst:1931 msgid "Hello World with call_soon()" msgstr "使用 call_soon() 的 Hello World 範例" -#: ../../library/asyncio-eventloop.rst:1905 +#: ../../library/asyncio-eventloop.rst:1933 msgid "" "An example using the :meth:`loop.call_soon` method to schedule a callback. " "The callback displays ``\"Hello World\"`` and then stops the event loop::" @@ -2833,7 +2863,7 @@ msgstr "" "使用 :meth:`loop.call_soon` 方法排程回呼的範例。回呼會顯示 ``\"Hello " "World\"``,然後停止事件迴圈: ::" -#: ../../library/asyncio-eventloop.rst:1909 +#: ../../library/asyncio-eventloop.rst:1937 msgid "" "import asyncio\n" "\n" @@ -2871,18 +2901,18 @@ msgstr "" "finally:\n" " loop.close()" -#: ../../library/asyncio-eventloop.rst:1929 +#: ../../library/asyncio-eventloop.rst:1957 msgid "" "A similar :ref:`Hello World ` example created with a coroutine " "and the :func:`run` function." msgstr "" "使用協程和 :func:`run` 函式建立的類似 :ref:`Hello World ` 範例。" -#: ../../library/asyncio-eventloop.rst:1936 +#: ../../library/asyncio-eventloop.rst:1964 msgid "Display the current date with call_later()" msgstr "使用 call_later() 顯示目前日期" -#: ../../library/asyncio-eventloop.rst:1938 +#: ../../library/asyncio-eventloop.rst:1966 msgid "" "An example of a callback displaying the current date every second. The " "callback uses the :meth:`loop.call_later` method to reschedule itself after " @@ -2891,7 +2921,7 @@ msgstr "" "一個回呼的範例,每秒顯示目前日期。回呼使用 :meth:`loop.call_later` 方法在 5 " "秒後重新排程自己,然後停止事件迴圈: ::" -#: ../../library/asyncio-eventloop.rst:1942 +#: ../../library/asyncio-eventloop.rst:1970 msgid "" "import asyncio\n" "import datetime\n" @@ -2937,7 +2967,7 @@ msgstr "" "finally:\n" " loop.close()" -#: ../../library/asyncio-eventloop.rst:1966 +#: ../../library/asyncio-eventloop.rst:1994 msgid "" "A similar :ref:`current date ` example created with a " "coroutine and the :func:`run` function." @@ -2945,11 +2975,11 @@ msgstr "" "使用協程和 :func:`run` 函式建立的類似 :ref:`current date " "` 範例。" -#: ../../library/asyncio-eventloop.rst:1973 +#: ../../library/asyncio-eventloop.rst:2001 msgid "Watch a file descriptor for read events" msgstr "監聽檔案描述器以進行讀取事件" -#: ../../library/asyncio-eventloop.rst:1975 +#: ../../library/asyncio-eventloop.rst:2003 msgid "" "Wait until a file descriptor received some data using the :meth:`loop." "add_reader` method and then close the event loop::" @@ -2957,7 +2987,7 @@ msgstr "" "使用 :meth:`loop.add_reader` 方法等待檔案描述器接收到某些資料,然後關閉事件迴" "圈: ::" -#: ../../library/asyncio-eventloop.rst:1978 +#: ../../library/asyncio-eventloop.rst:2006 msgid "" "import asyncio\n" "from socket import socketpair\n" @@ -3025,7 +3055,7 @@ msgstr "" " wsock.close()\n" " loop.close()" -#: ../../library/asyncio-eventloop.rst:2013 +#: ../../library/asyncio-eventloop.rst:2041 msgid "" "A similar :ref:`example ` using " "transports, protocols, and the :meth:`loop.create_connection` method." @@ -3033,7 +3063,7 @@ msgstr "" "使用傳輸、協定和 :meth:`loop.create_connection` 方法的類似 :ref:`範例 " "`。" -#: ../../library/asyncio-eventloop.rst:2017 +#: ../../library/asyncio-eventloop.rst:2045 msgid "" "Another similar :ref:`example ` " "using the high-level :func:`asyncio.open_connection` function and streams." @@ -3041,23 +3071,23 @@ msgstr "" "另一個使用高階 :func:`asyncio.open_connection` 函式和串流的類似 :ref:`範例 " "`。" -#: ../../library/asyncio-eventloop.rst:2025 +#: ../../library/asyncio-eventloop.rst:2053 msgid "Set signal handlers for SIGINT and SIGTERM" msgstr "設定 SIGINT 和 SIGTERM 的訊號處理程式" -#: ../../library/asyncio-eventloop.rst:2027 +#: ../../library/asyncio-eventloop.rst:2055 msgid "(This ``signals`` example only works on Unix.)" msgstr "(此 ``signals`` 範例僅在 Unix 上運作。)" -#: ../../library/asyncio-eventloop.rst:2029 +#: ../../library/asyncio-eventloop.rst:2057 msgid "" "Register handlers for signals :const:`~signal.SIGINT` and :const:`~signal." "SIGTERM` using the :meth:`loop.add_signal_handler` method::" msgstr "" -"使用 :meth:`loop.add_signal_handler` 方法註冊訊號 :py:data:`SIGINT` 和 :py:" -"data:`SIGTERM` 的處理程式: ::" +"使用 :meth:`loop.add_signal_handler` 方法註冊訊號 :const:`~signal.SIGINT` 和 :const:`~signal." +"SIGTERM` 的處理程式: ::" -#: ../../library/asyncio-eventloop.rst:2032 +#: ../../library/asyncio-eventloop.rst:2060 msgid "" "import asyncio\n" "import functools\n" @@ -3106,3 +3136,31 @@ msgstr "" "print(f\"pid {os.getpid()}: send SIGINT or SIGTERM to exit.\")\n" "\n" "asyncio.run(main())" + +#~ msgid "" +#~ "Deprecation warning is emitted if there is no current event loop. In some " +#~ "future Python release this will become an error." +#~ msgstr "" +#~ "如果沒有目前事件迴圈,則會發出棄用警告。在未來的某個 Python 發行版中,這將" +#~ "變成錯誤。" + +#~ msgid "" +#~ "import asyncio\n" +#~ "import selectors\n" +#~ "\n" +#~ "class MyPolicy(asyncio.DefaultEventLoopPolicy):\n" +#~ " def new_event_loop(self):\n" +#~ " selector = selectors.SelectSelector()\n" +#~ " return asyncio.SelectorEventLoop(selector)\n" +#~ "\n" +#~ "asyncio.set_event_loop_policy(MyPolicy())" +#~ msgstr "" +#~ "import asyncio\n" +#~ "import selectors\n" +#~ "\n" +#~ "class MyPolicy(asyncio.DefaultEventLoopPolicy):\n" +#~ " def new_event_loop(self):\n" +#~ " selector = selectors.SelectSelector()\n" +#~ " return asyncio.SelectorEventLoop(selector)\n" +#~ "\n" +#~ "asyncio.set_event_loop_policy(MyPolicy())" diff --git a/library/asyncio-exceptions.po b/library/asyncio-exceptions.po index e08327656e2..ddcb5a4f752 100644 --- a/library/asyncio-exceptions.po +++ b/library/asyncio-exceptions.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -6,7 +6,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2023-07-06 00:19+0000\n" "PO-Revision-Date: 2022-01-31 21:41+0800\n" diff --git a/library/asyncio-extending.po b/library/asyncio-extending.po index f7a1ab412f2..1f8b54e078e 100644 --- a/library/asyncio-extending.po +++ b/library/asyncio-extending.po @@ -1,11 +1,11 @@ -# Copyright (C) 2001-2022, Python Software Foundation +# 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.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2023-07-29 10:36+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" diff --git a/library/asyncio-future.po b/library/asyncio-future.po index 4d8e563a853..c2812e4b70e 100644 --- a/library/asyncio-future.po +++ b/library/asyncio-future.po @@ -1,13 +1,13 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Matt Wang , 2022 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-08-10 00:19+0000\n" +"POT-Creation-Date: 2025-09-08 15:25+0800\n" "PO-Revision-Date: 2022-01-25 01:29+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -72,9 +72,9 @@ msgstr "" #: ../../library/asyncio-future.rst:42 msgid "" -"a :class:`Task` object wrapping *obj*, if *obj* is a coroutine (:func:" -"`iscoroutine` is used for the test); in this case the coroutine will be " -"scheduled by ``ensure_future()``." +"a :class:`Task` object wrapping *obj*, if *obj* is a coroutine " +"(:func:`iscoroutine` is used for the test); in this case the coroutine will " +"be scheduled by ``ensure_future()``." msgstr "" "包裝 (wrap) 了 *obj* 的 :class:`Task` 物件,如果 *obj* 是一個協程 " "(coroutine) (可以用 :func:`iscoroutine` 來進行檢查);在此情況下該協程將透過 " @@ -82,11 +82,11 @@ msgstr "" #: ../../library/asyncio-future.rst:47 msgid "" -"a :class:`Task` object that would await on *obj*, if *obj* is an awaitable (:" -"func:`inspect.isawaitable` is used for the test.)" +"a :class:`Task` object that would await on *obj*, if *obj* is an awaitable " +"(:func:`inspect.isawaitable` is used for the test.)" msgstr "" -"一個會等待 *obj* 的 :class:`Task` 物件,*obj* 須為一個可等待物件(\\ :func:" -"`inspect.isawaitable` 用於測試。)" +"一個會等待 *obj* 的 :class:`Task` 物件,*obj* 須為一個可等待物件" +"(\\ :func:`inspect.isawaitable` 用於測試。)" #: ../../library/asyncio-future.rst:50 msgid "If *obj* is neither of the above a :exc:`TypeError` is raised." @@ -94,21 +94,23 @@ msgstr "如果 *obj* 不是上述物件的話會引發一個 :exc:`TypeError` #: ../../library/asyncio-future.rst:54 msgid "" -"See also the :func:`create_task` function which is the preferred way for " -"creating new Tasks." -msgstr "請見 :func:`create_task` 函式,它是建立新 Task 的推薦方法。" - -#: ../../library/asyncio-future.rst:57 -msgid "" "Save a reference to the result of this function, to avoid a task " "disappearing mid-execution." msgstr "將參照 (reference) 儲存至此函式的結果,用以防止任務在執行中消失。" -#: ../../library/asyncio-future.rst:60 +#: ../../library/asyncio-future.rst:57 +msgid "" +"See also the :func:`create_task` function which is the preferred way for " +"creating new tasks or use :class:`asyncio.TaskGroup` which keeps reference " +"to the task internally." +msgstr "請見 :func:`create_task` 函式,它是建立新 Task 的推薦方法。或者使用 " +":class:`asyncio.TaskGroup`,它會在內部保留對 Task 的參照。" + +#: ../../library/asyncio-future.rst:61 msgid "The function accepts any :term:`awaitable` object." msgstr "這個函式接受任意 :term:`awaitable` 物件。" -#: ../../library/asyncio-future.rst:63 +#: ../../library/asyncio-future.rst:64 msgid "" "Deprecation warning is emitted if *obj* is not a Future-like object and " "*loop* is not specified and there is no running event loop." @@ -116,15 +118,15 @@ msgstr "" "如果 *obj* 不是類 Future 物件且 *loop* 並未被指定,同時沒有正在執行的事件迴" "圈 (event loop),則會發出棄用警告。" -#: ../../library/asyncio-future.rst:70 +#: ../../library/asyncio-future.rst:71 msgid "" -"Wrap a :class:`concurrent.futures.Future` object in a :class:`asyncio." -"Future` object." +"Wrap a :class:`concurrent.futures.Future` object in " +"a :class:`asyncio.Future` object." msgstr "" "將一個 :class:`concurrent.futures.Future` 物件包裝到 :class:`asyncio.Future` " "物件中。" -#: ../../library/asyncio-future.rst:73 +#: ../../library/asyncio-future.rst:74 msgid "" "Deprecation warning is emitted if *future* is not a Future-like object and " "*loop* is not specified and there is no running event loop." @@ -132,18 +134,18 @@ msgstr "" "如果 *future* 不是類 Future 物件且 *loop* 未被指定,同時沒有正在執行的事件迴" "圈,則會發出棄用警告。" -#: ../../library/asyncio-future.rst:80 +#: ../../library/asyncio-future.rst:81 msgid "Future Object" msgstr "Future 物件" -#: ../../library/asyncio-future.rst:84 +#: ../../library/asyncio-future.rst:85 msgid "" "A Future represents an eventual result of an asynchronous operation. Not " "thread-safe." msgstr "" "一個 Future 代表一個非同步運算的最終結果。並不支援執行緒安全 (thread-safe)。" -#: ../../library/asyncio-future.rst:87 +#: ../../library/asyncio-future.rst:88 msgid "" "Future is an :term:`awaitable` object. Coroutines can await on Future " "objects until they either have a result or an exception set, or until they " @@ -152,42 +154,43 @@ msgstr "" "Future 是一個 :term:`awaitable` 物件。協程可以等待 Future 物件直到它們有結果" "或例外被設置、或者被取消。一個 Future 可被多次等待而結果都會是相同的。" -#: ../../library/asyncio-future.rst:92 +#: ../../library/asyncio-future.rst:93 msgid "" "Typically Futures are used to enable low-level callback-based code (e.g. in " "protocols implemented using asyncio :ref:`transports `) to interoperate with high-level async/await code." msgstr "" -"Future 通常用於讓低階基於回呼的程式(例如在協定實作中使用 asyncio :ref:" -"`transports `\\ )能夠與高階 async/await 程式互" -"動。" +"Future 通常用於讓低階基於回呼的程式(例如在協定實作中使用 " +"asyncio :ref:`transports `\\ )能夠與高階 " +"async/await 程式互動。" -#: ../../library/asyncio-future.rst:97 +#: ../../library/asyncio-future.rst:98 msgid "" "The rule of thumb is to never expose Future objects in user-facing APIs, and " -"the recommended way to create a Future object is to call :meth:`loop." -"create_future`. This way alternative event loop implementations can inject " -"their own optimized implementations of a Future object." +"the recommended way to create a Future object is to " +"call :meth:`loop.create_future`. This way alternative event loop " +"implementations can inject their own optimized implementations of a Future " +"object." msgstr "" -"經驗法則為永遠不要在提供給使用者的 API 中公開 Future 物件,同時建議使用 :" -"meth:`loop.create_future` 來建立 Future 物件。如此一來,不同實作的事件迴圈可" -"以注入自己最佳化實作的 Future 物件。" +"經驗法則為永遠不要在提供給使用者的 API 中公開 Future 物件,同時建議使" +"用 :meth:`loop.create_future` 來建立 Future 物件。如此一來,不同實作的事件迴" +"圈可以注入自己最佳化實作的 Future 物件。" -#: ../../library/asyncio-future.rst:103 +#: ../../library/asyncio-future.rst:104 msgid "Added support for the :mod:`contextvars` module." msgstr "加入對 :mod:`contextvars` 模組的支援。" -#: ../../library/asyncio-future.rst:106 +#: ../../library/asyncio-future.rst:107 msgid "" "Deprecation warning is emitted if *loop* is not specified and there is no " "running event loop." msgstr "如果未指定 *loop* 並且沒有正在執行的事件迴圈則會發出棄用警告。" -#: ../../library/asyncio-future.rst:112 +#: ../../library/asyncio-future.rst:113 msgid "Return the result of the Future." msgstr "回傳 Future 的結果。" -#: ../../library/asyncio-future.rst:114 +#: ../../library/asyncio-future.rst:115 msgid "" "If the Future is *done* and has a result set by the :meth:`set_result` " "method, the result value is returned." @@ -195,66 +198,66 @@ msgstr "" "如果 Future 狀態為 *done*\\ (完成),並擁有 :meth:`set_result` 方法設定的一" "個結果,則回傳該結果之值。" -#: ../../library/asyncio-future.rst:117 +#: ../../library/asyncio-future.rst:118 msgid "" -"If the Future is *done* and has an exception set by the :meth:" -"`set_exception` method, this method raises the exception." +"If the Future is *done* and has an exception set by " +"the :meth:`set_exception` method, this method raises the exception." msgstr "" "如果 Future 狀態為 *done*,並擁有 :meth:`set_exception` 方法設定的一個例外," "那麼這個方法會引發該例外。" -#: ../../library/asyncio-future.rst:120 ../../library/asyncio-future.rst:208 +#: ../../library/asyncio-future.rst:121 ../../library/asyncio-future.rst:209 msgid "" -"If the Future has been *cancelled*, this method raises a :exc:" -"`CancelledError` exception." +"If the Future has been *cancelled*, this method raises " +"a :exc:`CancelledError` exception." msgstr "" -"如果 Future 已被 *cancelled*\\ (取消),此方法會引發一個 :exc:" -"`CancelledError` 例外。" +"如果 Future 已被 *cancelled*\\ (取消),此方法會引發一" +"個 :exc:`CancelledError` 例外。" -#: ../../library/asyncio-future.rst:123 +#: ../../library/asyncio-future.rst:124 msgid "" -"If the Future's result isn't yet available, this method raises an :exc:" -"`InvalidStateError` exception." +"If the Future's result isn't yet available, this method raises " +"an :exc:`InvalidStateError` exception." msgstr "" "如果 Future 的結果還不可用,此方法會引發一個 :exc:`InvalidStateError` 例外。" -#: ../../library/asyncio-future.rst:128 +#: ../../library/asyncio-future.rst:129 msgid "Mark the Future as *done* and set its result." msgstr "將 Future 標記為 *done* 並設定其結果。" -#: ../../library/asyncio-future.rst:130 ../../library/asyncio-future.rst:137 +#: ../../library/asyncio-future.rst:131 ../../library/asyncio-future.rst:138 msgid "" "Raises an :exc:`InvalidStateError` error if the Future is already *done*." msgstr "如果 Future 已經 *done* 則引發一個 :exc:`InvalidStateError` 錯誤。" -#: ../../library/asyncio-future.rst:135 +#: ../../library/asyncio-future.rst:136 msgid "Mark the Future as *done* and set an exception." msgstr "將 Future 標記為 *done* 並設定一個例外。" -#: ../../library/asyncio-future.rst:142 +#: ../../library/asyncio-future.rst:143 msgid "Return ``True`` if the Future is *done*." msgstr "如果 Future 已為 *done* 則回傳 ``True``。" -#: ../../library/asyncio-future.rst:144 +#: ../../library/asyncio-future.rst:145 msgid "" "A Future is *done* if it was *cancelled* or if it has a result or an " "exception set with :meth:`set_result` or :meth:`set_exception` calls." msgstr "" -"如果 Future 有被 *cancelled*、:meth:`set_result` 有被呼叫來為其設定結果、或 :" -"meth:`set_exception` 有被呼叫為其設定例外,那麼它就是 *done*。" +"如果 Future 有被 *cancelled*、:meth:`set_result` 有被呼叫來為其設定結果、" +"或 :meth:`set_exception` 有被呼叫為其設定例外,那麼它就是 *done*。" -#: ../../library/asyncio-future.rst:150 +#: ../../library/asyncio-future.rst:151 msgid "Return ``True`` if the Future was *cancelled*." msgstr "如果 Future 已經被 *cancelled* 則回傳 ``True``。" -#: ../../library/asyncio-future.rst:152 +#: ../../library/asyncio-future.rst:153 msgid "" "The method is usually used to check if a Future is not *cancelled* before " "setting a result or an exception for it::" msgstr "" "這個方法通常在為 Future 設定結果或例外前用來確認它還沒被 *cancelled*: ::" -#: ../../library/asyncio-future.rst:155 +#: ../../library/asyncio-future.rst:156 msgid "" "if not fut.cancelled():\n" " fut.set_result(42)" @@ -262,15 +265,15 @@ msgstr "" "if not fut.cancelled():\n" " fut.set_result(42)" -#: ../../library/asyncio-future.rst:160 +#: ../../library/asyncio-future.rst:161 msgid "Add a callback to be run when the Future is *done*." msgstr "新增一個在 Future 為 *done* 時執行的回呼函式。" -#: ../../library/asyncio-future.rst:162 +#: ../../library/asyncio-future.rst:163 msgid "The *callback* is called with the Future object as its only argument." msgstr "呼叫 *callback* 並附帶做為唯一引數的 Future 物件。" -#: ../../library/asyncio-future.rst:165 +#: ../../library/asyncio-future.rst:166 msgid "" "If the Future is already *done* when this method is called, the callback is " "scheduled with :meth:`loop.call_soon`." @@ -278,49 +281,50 @@ msgstr "" "如果呼叫這個方法時 Future 已經為 *done*,回呼函式會被 :meth:`loop.call_soon` " "排程。" -#: ../../library/asyncio-future.rst:168 +#: ../../library/asyncio-future.rst:169 msgid "" -"An optional keyword-only *context* argument allows specifying a custom :" -"class:`contextvars.Context` for the *callback* to run in. The current " -"context is used when no *context* is provided." +"An optional keyword-only *context* argument allows specifying a " +"custom :class:`contextvars.Context` for the *callback* to run in. The " +"current context is used when no *context* is provided." msgstr "" -"可選僅限關鍵字引數 *context* 用來指定一個讓 *callback* 執行於其中的客製化 :" -"class:`contextvars.Context` 物件。如果沒有提供 *context*,則使用目前情境。" +"可選僅限關鍵字引數 *context* 用來指定一個讓 *callback* 執行於其中的客製" +"化 :class:`contextvars.Context` 物件。如果沒有提供 *context*,則使用目前情" +"境。" -#: ../../library/asyncio-future.rst:172 +#: ../../library/asyncio-future.rst:173 msgid "" -":func:`functools.partial` can be used to pass parameters to the callback, e." -"g.::" +":func:`functools.partial` can be used to pass parameters to the callback, " +"e.g.::" msgstr "可以用 :func:`functools.partial` 傳遞引數給回呼函式,例如: ::" -#: ../../library/asyncio-future.rst:175 +#: ../../library/asyncio-future.rst:176 msgid "" "# Call 'print(\"Future:\", fut)' when \"fut\" is done.\n" "fut.add_done_callback(\n" " functools.partial(print, \"Future:\"))" msgstr "" -#: ../../library/asyncio-future.rst:179 +#: ../../library/asyncio-future.rst:180 msgid "" "The *context* keyword-only parameter was added. See :pep:`567` for more " "details." msgstr "加入僅限關鍵字參數 *context*。更多細節請參閱 :pep:`567`。" -#: ../../library/asyncio-future.rst:185 +#: ../../library/asyncio-future.rst:186 msgid "Remove *callback* from the callbacks list." msgstr "從回呼列表中移除 *callback*。" -#: ../../library/asyncio-future.rst:187 +#: ../../library/asyncio-future.rst:188 msgid "" "Returns the number of callbacks removed, which is typically 1, unless a " "callback was added more than once." msgstr "回傳被移除的回呼函式數量,通常為 1,除非一個回呼函式被多次加入。" -#: ../../library/asyncio-future.rst:192 +#: ../../library/asyncio-future.rst:193 msgid "Cancel the Future and schedule callbacks." msgstr "取消 Future 並為回呼函式排程。" -#: ../../library/asyncio-future.rst:194 +#: ../../library/asyncio-future.rst:195 msgid "" "If the Future is already *done* or *cancelled*, return ``False``. Otherwise, " "change the Future's state to *cancelled*, schedule the callbacks, and return " @@ -329,33 +333,33 @@ msgstr "" "如果 Future 已經是 *done* 或 *cancelled*,回傳 ``False``。否則將 Future 狀態" "改為 *cancelled* 並在為回呼函式排程後回傳 ``True``。" -#: ../../library/asyncio-future.rst:198 +#: ../../library/asyncio-future.rst:199 msgid "Added the *msg* parameter." msgstr "新增 *msg* 參數。" -#: ../../library/asyncio-future.rst:203 +#: ../../library/asyncio-future.rst:204 msgid "Return the exception that was set on this Future." msgstr "回傳被設定於此 Future 的例外。" -#: ../../library/asyncio-future.rst:205 +#: ../../library/asyncio-future.rst:206 msgid "" "The exception (or ``None`` if no exception was set) is returned only if the " "Future is *done*." msgstr "" "只有 Future 在 *done* 時才回傳例外(如果沒有設定例外則回傳 ``None``\\ )。" -#: ../../library/asyncio-future.rst:211 +#: ../../library/asyncio-future.rst:212 msgid "" -"If the Future isn't *done* yet, this method raises an :exc:" -"`InvalidStateError` exception." +"If the Future isn't *done* yet, this method raises " +"an :exc:`InvalidStateError` exception." msgstr "" "如果 Future 還不為 *done*,此方法會引發一個 :exc:`InvalidStateError` 例外。" -#: ../../library/asyncio-future.rst:216 +#: ../../library/asyncio-future.rst:217 msgid "Return the event loop the Future object is bound to." msgstr "回傳已被 Future 物件繫結 (bind) 的事件迴圈。" -#: ../../library/asyncio-future.rst:223 +#: ../../library/asyncio-future.rst:224 msgid "" "This example creates a Future object, creates and schedules an asynchronous " "Task to set result for the Future, and waits until the Future has a result::" @@ -363,7 +367,7 @@ msgstr "" "這個例子建立一個 Future 物件,建立一個非同步 Task 並為其排程以設定 Future 結" "果,然後等待 Future 結果出現: ::" -#: ../../library/asyncio-future.rst:227 +#: ../../library/asyncio-future.rst:228 msgid "" "async def set_after(fut, delay, value):\n" " # Sleep for *delay* seconds.\n" @@ -394,7 +398,7 @@ msgid "" "asyncio.run(main())" msgstr "" -#: ../../library/asyncio-future.rst:258 +#: ../../library/asyncio-future.rst:259 msgid "" "The Future object was designed to mimic :class:`concurrent.futures.Future`. " "Key differences include:" @@ -402,7 +406,7 @@ msgstr "" "該 Future 物件是為了模仿 :class:`concurrent.futures.Future` 而設計。主要差異" "包含:" -#: ../../library/asyncio-future.rst:261 +#: ../../library/asyncio-future.rst:262 msgid "" "unlike asyncio Futures, :class:`concurrent.futures.Future` instances cannot " "be awaited." @@ -410,7 +414,7 @@ msgstr "" "與 asyncio 的 Future 不同,:class:`concurrent.futures.Future` 實例不可被等" "待。" -#: ../../library/asyncio-future.rst:264 +#: ../../library/asyncio-future.rst:265 msgid "" ":meth:`asyncio.Future.result` and :meth:`asyncio.Future.exception` do not " "accept the *timeout* argument." @@ -418,15 +422,16 @@ msgstr "" ":meth:`asyncio.Future.result` 和 :meth:`asyncio.Future.exception` 不接受 " "*timeout* 引數。" -#: ../../library/asyncio-future.rst:267 +#: ../../library/asyncio-future.rst:268 msgid "" -":meth:`asyncio.Future.result` and :meth:`asyncio.Future.exception` raise an :" -"exc:`InvalidStateError` exception when the Future is not *done*." +":meth:`asyncio.Future.result` and :meth:`asyncio.Future.exception` raise " +"an :exc:`InvalidStateError` exception when the Future is not *done*." msgstr "" -"Future 不為 *done* 時 :meth:`asyncio.Future.result` 和 :meth:`asyncio.Future." -"exception` 會引發一個 :exc:`InvalidStateError` 例外。" +"Future 不為 *done* 時 :meth:`asyncio.Future.result` " +"和 :meth:`asyncio.Future.exception` 會引發一個 :exc:`InvalidStateError` 例" +"外。" -#: ../../library/asyncio-future.rst:271 +#: ../../library/asyncio-future.rst:272 msgid "" "Callbacks registered with :meth:`asyncio.Future.add_done_callback` are not " "called immediately. They are scheduled with :meth:`loop.call_soon` instead." @@ -434,18 +439,18 @@ msgstr "" "使用 :meth:`asyncio.Future.add_done_callback` 註冊的回呼函式不會立即呼叫,而" "是被 :meth:`loop.call_soon` 排程。" -#: ../../library/asyncio-future.rst:275 +#: ../../library/asyncio-future.rst:276 msgid "" "asyncio Future is not compatible with the :func:`concurrent.futures.wait` " "and :func:`concurrent.futures.as_completed` functions." msgstr "" -"asyncio Future 不能與 :func:`concurrent.futures.wait` 和 :func:`concurrent." -"futures.as_completed` 函式相容。" +"asyncio Future 不能與 :func:`concurrent.futures.wait` " +"和 :func:`concurrent.futures.as_completed` 函式相容。" -#: ../../library/asyncio-future.rst:279 +#: ../../library/asyncio-future.rst:280 msgid "" -":meth:`asyncio.Future.cancel` accepts an optional ``msg`` argument, but :" -"meth:`concurrent.futures.Future.cancel` does not." +":meth:`asyncio.Future.cancel` accepts an optional ``msg`` argument, " +"but :meth:`concurrent.futures.Future.cancel` does not." msgstr "" -":meth:`asyncio.Future.cancel` 接受一個可選的 ``msg`` 引數,但 :func:" -"`concurrent.futures.Future.cancel` 無此引數。" +":meth:`asyncio.Future.cancel` 接受一個可選的 ``msg`` 引數," +"但 :func:`concurrent.futures.Future.cancel` 無此引數。" diff --git a/library/asyncio-graph.po b/library/asyncio-graph.po new file mode 100644 index 00000000000..59b3e1cfb8d --- /dev/null +++ b/library/asyncio-graph.po @@ -0,0 +1,219 @@ +# 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.14\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-09-08 15:25+0800\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/asyncio-graph.rst:8 +msgid "Call Graph Introspection" +msgstr "" + +#: ../../library/asyncio-graph.rst:10 +msgid "**Source code:** :source:`Lib/asyncio/graph.py`" +msgstr "**原始碼:**\\ :source:`Lib/asyncio/graph.py`" + +#: ../../library/asyncio-graph.rst:14 +msgid "" +"asyncio has powerful runtime call graph introspection utilities to trace the " +"entire call graph of a running *coroutine* or *task*, or a suspended " +"*future*. These utilities and the underlying machinery can be used from " +"within a Python program or by external profilers and debuggers." +msgstr "" + +#: ../../library/asyncio-graph.rst:25 +msgid "" +"Print the async call graph for the current task or the " +"provided :class:`Task` or :class:`Future`." +msgstr "" + +#: ../../library/asyncio-graph.rst:28 +msgid "" +"This function prints entries starting from the top frame and going down " +"towards the invocation point." +msgstr "" + +#: ../../library/asyncio-graph.rst:31 +msgid "" +"The function receives an optional *future* argument. If not passed, the " +"current running task will be used." +msgstr "" + +#: ../../library/asyncio-graph.rst:34 ../../library/asyncio-graph.rst:93 +msgid "" +"If the function is called on *the current task*, the optional keyword-only " +"*depth* argument can be used to skip the specified number of frames from top " +"of the stack." +msgstr "" + +#: ../../library/asyncio-graph.rst:38 +msgid "" +"If the optional keyword-only *limit* argument is provided, each call stack " +"in the resulting graph is truncated to include at most ``abs(limit)`` " +"entries. If *limit* is positive, the entries left are the closest to the " +"invocation point. If *limit* is negative, the topmost entries are left. If " +"*limit* is omitted or ``None``, all entries are present. If *limit* is " +"``0``, the call stack is not printed at all, only \"awaited by\" information " +"is printed." +msgstr "" + +#: ../../library/asyncio-graph.rst:46 +msgid "" +"If *file* is omitted or ``None``, the function will print " +"to :data:`sys.stdout`." +msgstr "" + +#: ../../library/asyncio-graph.rst:49 +msgid "**Example:**" +msgstr "**範例:**" + +#: ../../library/asyncio-graph.rst:51 +msgid "The following Python code:" +msgstr "以下 Python 程式碼:" + +#: ../../library/asyncio-graph.rst:53 +msgid "" +"import asyncio\n" +"\n" +"async def test():\n" +" asyncio.print_call_graph()\n" +"\n" +"async def main():\n" +" async with asyncio.TaskGroup() as g:\n" +" g.create_task(test(), name='test')\n" +"\n" +"asyncio.run(main())" +msgstr "" +"import asyncio\n" +"\n" +"async def test():\n" +" asyncio.print_call_graph()\n" +"\n" +"async def main():\n" +" async with asyncio.TaskGroup() as g:\n" +" g.create_task(test(), name='test')\n" +"\n" +"asyncio.run(main())" + +#: ../../library/asyncio-graph.rst:66 +msgid "will print::" +msgstr "會印出: ::" + +#: ../../library/asyncio-graph.rst:68 +msgid "" +"* Task(name='test', id=0x1039f0fe0)\n" +"+ Call stack:\n" +"| File 't2.py', line 4, in async test()\n" +"+ Awaited by:\n" +" * Task(name='Task-1', id=0x103a5e060)\n" +" + Call stack:\n" +" | File 'taskgroups.py', line 107, in async TaskGroup.__aexit__()\n" +" | File 't2.py', line 7, in async main()" +msgstr "" +"* Task(name='test', id=0x1039f0fe0)\n" +"+ Call stack:\n" +"| File 't2.py', line 4, in async test()\n" +"+ Awaited by:\n" +" * Task(name='Task-1', id=0x103a5e060)\n" +" + Call stack:\n" +" | File 'taskgroups.py', line 107, in async TaskGroup.__aexit__()\n" +" | File 't2.py', line 7, in async main()" + +#: ../../library/asyncio-graph.rst:79 +msgid "" +"Like :func:`print_call_graph`, but returns a string. If *future* is ``None`` " +"and there's no current task, the function returns an empty string." +msgstr "" + +#: ../../library/asyncio-graph.rst:86 +msgid "" +"Capture the async call graph for the current task or the " +"provided :class:`Task` or :class:`Future`." +msgstr "" + +#: ../../library/asyncio-graph.rst:89 +msgid "" +"The function receives an optional *future* argument. If not passed, the " +"current running task will be used. If there's no current task, the function " +"returns ``None``." +msgstr "" + +#: ../../library/asyncio-graph.rst:97 +msgid "Returns a ``FutureCallGraph`` data class object:" +msgstr "會回傳一個 ``FutureCallGraph`` 資料類別物件:" + +#: ../../library/asyncio-graph.rst:99 +msgid "``FutureCallGraph(future, call_stack, awaited_by)``" +msgstr "``FutureCallGraph(future, call_stack, awaited_by)``" + +#: ../../library/asyncio-graph.rst:101 +msgid "" +"Where *future* is a reference to a :class:`Future` or a :class:`Task` (or " +"their subclasses.)" +msgstr "" + +#: ../../library/asyncio-graph.rst:104 +msgid "``call_stack`` is a tuple of ``FrameCallGraphEntry`` objects." +msgstr "``call_stack`` 是一個由 ``FrameCallGraphEntry`` 物件組成的元組。" + +#: ../../library/asyncio-graph.rst:106 +msgid "``awaited_by`` is a tuple of ``FutureCallGraph`` objects." +msgstr "``awaited_by`` 是一個由 ``FutureCallGraph`` 物件組成的元組。" + +#: ../../library/asyncio-graph.rst:108 +msgid "``FrameCallGraphEntry(frame)``" +msgstr "``FrameCallGraphEntry(frame)``" + +#: ../../library/asyncio-graph.rst:110 +msgid "" +"Where *frame* is a frame object of a regular Python function in the call " +"stack." +msgstr "" + +#: ../../library/asyncio-graph.rst:115 +msgid "Low level utility functions" +msgstr "低階工具函式" + +#: ../../library/asyncio-graph.rst:117 +msgid "" +"To introspect an async call graph asyncio requires cooperation from control " +"flow structures, such as :func:`shield` or :class:`TaskGroup`. Any time an " +"intermediate :class:`Future` object with low-level APIs " +"like :meth:`Future.add_done_callback() ` " +"is involved, the following two functions should be used to inform asyncio " +"about how exactly such intermediate future objects are connected with the " +"tasks they wrap or control." +msgstr "" + +#: ../../library/asyncio-graph.rst:128 +msgid "Record that *future* is awaited on by *waiter*." +msgstr "" + +#: ../../library/asyncio-graph.rst:130 ../../library/asyncio-graph.rst:143 +msgid "" +"Both *future* and *waiter* must be instances of :class:`Future` " +"or :class:`Task` or their subclasses, otherwise the call would have no " +"effect." +msgstr "" + +#: ../../library/asyncio-graph.rst:134 +msgid "" +"A call to ``future_add_to_awaited_by()`` must be followed by an eventual " +"call to the :func:`future_discard_from_awaited_by` function with the same " +"arguments." +msgstr "" + +#: ../../library/asyncio-graph.rst:141 +msgid "Record that *future* is no longer awaited on by *waiter*." +msgstr "" diff --git a/library/asyncio-llapi-index.po b/library/asyncio-llapi-index.po index 22a41d34ecc..6ddd9f538cd 100644 --- a/library/asyncio-llapi-index.po +++ b/library/asyncio-llapi-index.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2023, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -6,9 +6,9 @@ # msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-10-11 17:13+0000\n" +"POT-Creation-Date: 2025-09-08 15:25+0800\n" "PO-Revision-Date: 2023-10-12 11:27+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -199,8 +199,8 @@ msgid "Invoke a callback *at* the given time." msgstr "在給定時間\\ *當下*\\ 呼叫回呼函式。" #: ../../library/asyncio-llapi-index.rst:99 -msgid "Thread/Process Pool" -msgstr "執行緒 (Thread)/行程池 (Process Pool)" +msgid "Thread/Interpreter/Process Pool" +msgstr "執行緒 (Thread)/直譯器 (Interpreter)/行程池 (Process Pool)" #: ../../library/asyncio-llapi-index.rst:104 msgid "``await`` :meth:`loop.run_in_executor`" @@ -649,12 +649,13 @@ msgstr "回傳目前協定。" #: ../../library/asyncio-llapi-index.rst:314 msgid "" "Transports that can receive data (TCP and Unix connections, pipes, etc). " -"Returned from methods like :meth:`loop.create_connection`, :meth:`loop." -"create_unix_connection`, :meth:`loop.connect_read_pipe`, etc:" +"Returned from methods " +"like :meth:`loop.create_connection`, :meth:`loop.create_unix_connection`, :meth:`loop.connect_read_pipe`, " +"etc:" msgstr "" -"可以接收資料(TCP 和 Unix 連線、pipe 等)的傳輸。它由 :meth:`loop." -"create_connection`、:meth:`loop.create_unix_connection`、:meth:`loop." -"connect_read_pipe` 等方法回傳:" +"可以接收資料(TCP 和 Unix 連線、pipe 等)的傳輸。它" +"由 :meth:`loop.create_connection`、:meth:`loop.create_unix_connection`、:meth:`loop.connect_read_pipe` " +"等方法回傳:" #: ../../library/asyncio-llapi-index.rst:319 msgid "Read Transports" @@ -687,12 +688,13 @@ msgstr "繼續接收。" #: ../../library/asyncio-llapi-index.rst:334 msgid "" "Transports that can Send data (TCP and Unix connections, pipes, etc). " -"Returned from methods like :meth:`loop.create_connection`, :meth:`loop." -"create_unix_connection`, :meth:`loop.connect_write_pipe`, etc:" +"Returned from methods " +"like :meth:`loop.create_connection`, :meth:`loop.create_unix_connection`, :meth:`loop.connect_write_pipe`, " +"etc:" msgstr "" -"可以傳送資料(TCP 和 Unix 連線、pipe 等)的傳輸。它由 :meth:`loop." -"create_connection`、:meth:`loop.create_unix_connection`、:meth:`loop." -"connect_write_pipe` 等方法回傳:" +"可以傳送資料(TCP 和 Unix 連線、pipe 等)的傳輸。它" +"由 :meth:`loop.create_connection`、:meth:`loop.create_unix_connection`、:meth:`loop.connect_write_pipe` " +"等方法回傳:" #: ../../library/asyncio-llapi-index.rst:339 msgid "Write Transports" @@ -741,11 +743,11 @@ msgstr "立即關閉傳輸。" #: ../../library/asyncio-llapi-index.rst:359 msgid "" -":meth:`transport.get_write_buffer_size() `" +":meth:`transport.get_write_buffer_size() " +"`" msgstr "" -":meth:`transport.get_write_buffer_size() `" +":meth:`transport.get_write_buffer_size() " +"`" #: ../../library/asyncio-llapi-index.rst:361 msgid "Return the current size of the output buffer." @@ -753,11 +755,11 @@ msgstr "回傳目前輸出緩衝區的大小。" #: ../../library/asyncio-llapi-index.rst:363 msgid "" -":meth:`transport.get_write_buffer_limits() `" +":meth:`transport.get_write_buffer_limits() " +"`" msgstr "" -":meth:`transport.get_write_buffer_limits() `" +":meth:`transport.get_write_buffer_limits() " +"`" #: ../../library/asyncio-llapi-index.rst:365 msgid "Return high and low water marks for write flow control." @@ -767,11 +769,11 @@ msgstr "" #: ../../library/asyncio-llapi-index.rst:367 msgid "" -":meth:`transport.set_write_buffer_limits() `" +":meth:`transport.set_write_buffer_limits() " +"`" msgstr "" -":meth:`transport.set_write_buffer_limits() `" +":meth:`transport.set_write_buffer_limits() " +"`" #: ../../library/asyncio-llapi-index.rst:369 msgid "Set new high and low water marks for write flow control." @@ -799,11 +801,11 @@ msgstr ":meth:`transport.abort() `" #: ../../library/asyncio-llapi-index.rst:386 msgid "" -"Low-level transport abstraction over subprocesses. Returned by :meth:`loop." -"subprocess_exec` and :meth:`loop.subprocess_shell`:" +"Low-level transport abstraction over subprocesses. Returned " +"by :meth:`loop.subprocess_exec` and :meth:`loop.subprocess_shell`:" msgstr "" -"基於子行程的低階傳輸抽象,它會由 :meth:`loop.subprocess_exec` 和 :meth:`loop." -"subprocess_shell` 所回傳:" +"基於子行程的低階傳輸抽象,它會由 :meth:`loop.subprocess_exec` " +"和 :meth:`loop.subprocess_shell` 所回傳:" #: ../../library/asyncio-llapi-index.rst:390 msgid "Subprocess Transports" @@ -819,11 +821,11 @@ msgstr "回傳子行程的行程 id。" #: ../../library/asyncio-llapi-index.rst:398 msgid "" -":meth:`transport.get_pipe_transport() `" +":meth:`transport.get_pipe_transport() " +"`" msgstr "" -":meth:`transport.get_pipe_transport() `" +":meth:`transport.get_pipe_transport() " +"`" #: ../../library/asyncio-llapi-index.rst:400 msgid "" @@ -1012,9 +1014,9 @@ msgstr "" #: ../../library/asyncio-llapi-index.rst:497 msgid "" -"Called when the child process has exited. It can be called before :meth:" -"`~SubprocessProtocol.pipe_data_received` and :meth:`~SubprocessProtocol." -"pipe_connection_lost` methods." +"Called when the child process has exited. It can be called " +"before :meth:`~SubprocessProtocol.pipe_data_received` " +"and :meth:`~SubprocessProtocol.pipe_connection_lost` methods." msgstr "" "在子行程退出時呼叫。它可以在 :meth:`~SubprocessProtocol.pipe_data_received` " "和 :meth:`~SubprocessProtocol.pipe_connection_lost` 方法之前呼叫。" @@ -1025,9 +1027,9 @@ msgstr "事件迴圈 Policies" #: ../../library/asyncio-llapi-index.rst:505 msgid "" -"Policies is a low-level mechanism to alter the behavior of functions like :" -"func:`asyncio.get_event_loop`. See also the main :ref:`policies section " -"` for more details." +"Policies is a low-level mechanism to alter the behavior of functions " +"like :func:`asyncio.get_event_loop`. See also the main :ref:`policies " +"section ` for more details." msgstr "" "Policy 是改變 :func:`asyncio.get_event_loop` 這類函式行為的一個低階機制。更多" "細節請見 :ref:`Policy 相關段落 `。" diff --git a/library/asyncio-platforms.po b/library/asyncio-platforms.po index cc9f8570c66..781b0afe801 100644 --- a/library/asyncio-platforms.po +++ b/library/asyncio-platforms.po @@ -1,5 +1,4 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # FIRST AUTHOR , YEAR. # @@ -8,9 +7,9 @@ # msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"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: 2025-09-08 15:25+0800\n" "PO-Revision-Date: 2022-01-17 11:37+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -70,17 +69,17 @@ msgid "" ":meth:`loop.create_unix_connection` and :meth:`loop.create_unix_server` are " "not supported. The :const:`socket.AF_UNIX` socket family is specific to Unix." msgstr "" -"不支援 :meth:`loop.create_unix_connection` 和 :meth:`loop." -"create_unix_server`。:const:`socket.AF_UNIX` socket 系列常數僅限於 Unix 上使" -"用。" +"不支援 :meth:`loop.create_unix_connection` " +"和 :meth:`loop.create_unix_server`。:const:`socket.AF_UNIX` socket 系列常數僅" +"限於 Unix 上使用。" #: ../../library/asyncio-platforms.rst:42 msgid "" ":meth:`loop.add_signal_handler` and :meth:`loop.remove_signal_handler` are " "not supported." msgstr "" -"不支援 :meth:`loop.add_signal_handler` 和 :meth:`loop." -"remove_signal_handler`。" +"不支援 :meth:`loop.add_signal_handler` " +"和 :meth:`loop.remove_signal_handler`。" #: ../../library/asyncio-platforms.rst:45 msgid ":class:`SelectorEventLoop` has the following limitations:" @@ -104,21 +103,21 @@ msgstr "" #: ../../library/asyncio-platforms.rst:53 msgid "" -"Pipes are not supported, so the :meth:`loop.connect_read_pipe` and :meth:" -"`loop.connect_write_pipe` methods are not implemented." +"Pipes are not supported, so the :meth:`loop.connect_read_pipe` " +"and :meth:`loop.connect_write_pipe` methods are not implemented." msgstr "" -"因為不支援 pipe,所以 :meth:`loop.connect_read_pipe` 和 :meth:`loop." -"connect_write_pipe` method 沒有被實作出來。" +"因為不支援 pipe,所以 :meth:`loop.connect_read_pipe` " +"和 :meth:`loop.connect_write_pipe` method 沒有被實作出來。" #: ../../library/asyncio-platforms.rst:56 msgid "" -":ref:`Subprocesses ` are not supported, i.e. :meth:`loop." -"subprocess_exec` and :meth:`loop.subprocess_shell` methods are not " -"implemented." +":ref:`Subprocesses ` are not supported, " +"i.e. :meth:`loop.subprocess_exec` and :meth:`loop.subprocess_shell` methods " +"are not implemented." msgstr "" -"不支援\\ :ref:`子行程 (subprocess) `,也就是說 :meth:" -"`loop.subprocess_exec` 和 :meth:`loop.subprocess_shell` method 沒有被實作出" -"來。" +"不支援\\ :ref:`子行程 (subprocess) `,也就是" +"說 :meth:`loop.subprocess_exec` 和 :meth:`loop.subprocess_shell` method 沒有" +"被實作出來。" #: ../../library/asyncio-platforms.rst:60 msgid ":class:`ProactorEventLoop` has the following limitations:" @@ -150,46 +149,37 @@ msgid "" "On Windows, the default event loop :class:`ProactorEventLoop` supports " "subprocesses, whereas :class:`SelectorEventLoop` does not." msgstr "" -"在 Windows 上,預設的事件迴圈 :class:`ProactorEventLoop` 支援子行程,而 :" -"class:`SelectorEventLoop` 則不支援。" +"在 Windows 上,預設的事件迴圈 :class:`ProactorEventLoop` 支援子行程," +"而 :class:`SelectorEventLoop` 則不支援。" -#: ../../library/asyncio-platforms.rst:80 -msgid "" -"The :meth:`policy.set_child_watcher() ` function is also not supported, as :class:" -"`ProactorEventLoop` has a different mechanism to watch child processes." -msgstr "" -"也不支援 :meth:`policy.set_child_watcher() ` 函式,:class:`ProactorEventLoop` 在監視子行程上有不同的機" -"制。" - -#: ../../library/asyncio-platforms.rst:87 +#: ../../library/asyncio-platforms.rst:82 msgid "macOS" msgstr "macOS" -#: ../../library/asyncio-platforms.rst:89 +#: ../../library/asyncio-platforms.rst:84 msgid "Modern macOS versions are fully supported." msgstr "完整支援現在普遍流行的 macOS 版本。" -#: ../../library/asyncio-platforms.rst:92 +#: ../../library/asyncio-platforms.rst:87 msgid "macOS <= 10.8" msgstr "macOS <= 10.8" -#: ../../library/asyncio-platforms.rst:93 +#: ../../library/asyncio-platforms.rst:88 msgid "" -"On macOS 10.6, 10.7 and 10.8, the default event loop uses :class:`selectors." -"KqueueSelector`, which does not support character devices on these " -"versions. The :class:`SelectorEventLoop` can be manually configured to use :" -"class:`~selectors.SelectSelector` or :class:`~selectors.PollSelector` to " -"support character devices on these older versions of macOS. Example::" +"On macOS 10.6, 10.7 and 10.8, the default event loop " +"uses :class:`selectors.KqueueSelector`, which does not support character " +"devices on these versions. The :class:`SelectorEventLoop` can be manually " +"configured to use :class:`~selectors.SelectSelector` " +"or :class:`~selectors.PollSelector` to support character devices on these " +"older versions of macOS. Example::" msgstr "" -"在 macOS 10.6、10.7 和 10.8 上,預設的事件迴圈是使用 :class:`selectors." -"KqueueSelector`,在這些版本上它並不支援字元裝置 (character device)。可以手工" -"設置 :class:`SelectorEventLoop` 來使用 :class:`~selectors.SelectSelector` " -"或 :class:`~selectors.PollSelector` 以在這些舊版 macOS 上支援字元裝置。例" -"如: ::" +"在 macOS 10.6、10.7 和 10.8 上,預設的事件迴圈是使" +"用 :class:`selectors.KqueueSelector`,在這些版本上它並不支援字元裝置 " +"(character device)。可以手工設置 :class:`SelectorEventLoop` 來使" +"用 :class:`~selectors.SelectSelector` 或 :class:`~selectors.PollSelector` 以" +"在這些舊版 macOS 上支援字元裝置。例如: ::" -#: ../../library/asyncio-platforms.rst:100 +#: ../../library/asyncio-platforms.rst:95 msgid "" "import asyncio\n" "import selectors\n" diff --git a/library/asyncio-policy.po b/library/asyncio-policy.po index 41fd70c5a6f..e954684ad8d 100644 --- a/library/asyncio-policy.po +++ b/library/asyncio-policy.po @@ -1,14 +1,13 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# 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.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-10-11 00:13+0000\n" +"POT-Creation-Date: 2025-09-08 15:25+0800\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,371 +21,190 @@ msgstr "" msgid "Policies" msgstr "" -#: ../../library/asyncio-policy.rst:10 +#: ../../library/asyncio-policy.rst:12 msgid "" -"An event loop policy is a global object used to get and set the current :ref:" -"`event loop `, as well as create new event loops. The " -"default policy can be :ref:`replaced ` with :ref:" -"`built-in alternatives ` to use different event loop " -"implementations, or substituted by a :ref:`custom policy ` that can override these behaviors." +"Policies are deprecated and will be removed in Python 3.16. Users are " +"encouraged to use the :func:`asyncio.run` function or " +"the :class:`asyncio.Runner` with *loop_factory* to use the desired loop " +"implementation." msgstr "" -#: ../../library/asyncio-policy.rst:19 +#: ../../library/asyncio-policy.rst:18 +msgid "" +"An event loop policy is a global object used to get and set the " +"current :ref:`event loop `, as well as create new event " +"loops. The default policy can be :ref:`replaced ` " +"with :ref:`built-in alternatives ` to use different " +"event loop implementations, or substituted by a :ref:`custom policy ` that can override these behaviors." +msgstr "" + +#: ../../library/asyncio-policy.rst:27 msgid "" "The :ref:`policy object ` gets and sets a separate " "event loop per *context*. This is per-thread by default, though custom " "policies could define *context* differently." msgstr "" -#: ../../library/asyncio-policy.rst:24 +#: ../../library/asyncio-policy.rst:32 msgid "" -"Custom event loop policies can control the behavior of :func:" -"`get_event_loop`, :func:`set_event_loop`, and :func:`new_event_loop`." +"Custom event loop policies can control the behavior " +"of :func:`get_event_loop`, :func:`set_event_loop`, " +"and :func:`new_event_loop`." msgstr "" -#: ../../library/asyncio-policy.rst:27 +#: ../../library/asyncio-policy.rst:35 msgid "" -"Policy objects should implement the APIs defined in the :class:" -"`AbstractEventLoopPolicy` abstract base class." +"Policy objects should implement the APIs defined in " +"the :class:`AbstractEventLoopPolicy` abstract base class." msgstr "" -#: ../../library/asyncio-policy.rst:34 +#: ../../library/asyncio-policy.rst:42 msgid "Getting and Setting the Policy" msgstr "" -#: ../../library/asyncio-policy.rst:36 +#: ../../library/asyncio-policy.rst:44 msgid "" "The following functions can be used to get and set the policy for the " "current process:" msgstr "" -#: ../../library/asyncio-policy.rst:41 +#: ../../library/asyncio-policy.rst:49 msgid "Return the current process-wide policy." msgstr "" -#: ../../library/asyncio-policy.rst:45 +#: ../../library/asyncio-policy.rst:51 +msgid "" +"The :func:`get_event_loop_policy` function is deprecated and will be removed " +"in Python 3.16." +msgstr "" + +#: ../../library/asyncio-policy.rst:57 msgid "Set the current process-wide policy to *policy*." msgstr "" -#: ../../library/asyncio-policy.rst:47 +#: ../../library/asyncio-policy.rst:59 msgid "If *policy* is set to ``None``, the default policy is restored." msgstr "" -#: ../../library/asyncio-policy.rst:53 +#: ../../library/asyncio-policy.rst:61 +msgid "" +"The :func:`set_event_loop_policy` function is deprecated and will be removed " +"in Python 3.16." +msgstr "" + +#: ../../library/asyncio-policy.rst:69 msgid "Policy Objects" msgstr "" -#: ../../library/asyncio-policy.rst:55 +#: ../../library/asyncio-policy.rst:71 msgid "The abstract event loop policy base class is defined as follows:" msgstr "" -#: ../../library/asyncio-policy.rst:59 +#: ../../library/asyncio-policy.rst:75 msgid "An abstract base class for asyncio policies." msgstr "" -#: ../../library/asyncio-policy.rst:63 +#: ../../library/asyncio-policy.rst:79 msgid "Get the event loop for the current context." msgstr "" -#: ../../library/asyncio-policy.rst:65 +#: ../../library/asyncio-policy.rst:81 msgid "" "Return an event loop object implementing the :class:`AbstractEventLoop` " "interface." msgstr "" -#: ../../library/asyncio-policy.rst:68 ../../library/asyncio-policy.rst:80 +#: ../../library/asyncio-policy.rst:84 ../../library/asyncio-policy.rst:96 msgid "This method should never return ``None``." msgstr "" -#: ../../library/asyncio-policy.rst:74 +#: ../../library/asyncio-policy.rst:90 msgid "Set the event loop for the current context to *loop*." msgstr "" -#: ../../library/asyncio-policy.rst:78 +#: ../../library/asyncio-policy.rst:94 msgid "Create and return a new event loop object." msgstr "" -#: ../../library/asyncio-policy.rst:84 -msgid "Get a child process watcher object." -msgstr "" - -#: ../../library/asyncio-policy.rst:86 +#: ../../library/asyncio-policy.rst:98 msgid "" -"Return a watcher object implementing the :class:`AbstractChildWatcher` " -"interface." -msgstr "" - -#: ../../library/asyncio-policy.rst:89 ../../library/asyncio-policy.rst:97 -msgid "This function is Unix specific." +"The :class:`AbstractEventLoopPolicy` class is deprecated and will be removed " +"in Python 3.16." msgstr "" -#: ../../library/asyncio-policy.rst:95 -msgid "Set the current child process watcher to *watcher*." -msgstr "" - -#: ../../library/asyncio-policy.rst:104 +#: ../../library/asyncio-policy.rst:105 msgid "asyncio ships with the following built-in policies:" msgstr "" -#: ../../library/asyncio-policy.rst:109 +#: ../../library/asyncio-policy.rst:110 msgid "" -"The default asyncio policy. Uses :class:`SelectorEventLoop` on Unix and :" -"class:`ProactorEventLoop` on Windows." +"The default asyncio policy. Uses :class:`SelectorEventLoop` on Unix " +"and :class:`ProactorEventLoop` on Windows." msgstr "" -#: ../../library/asyncio-policy.rst:112 +#: ../../library/asyncio-policy.rst:113 msgid "" "There is no need to install the default policy manually. asyncio is " "configured to use the default policy automatically." msgstr "" -#: ../../library/asyncio-policy.rst:117 +#: ../../library/asyncio-policy.rst:118 msgid "On Windows, :class:`ProactorEventLoop` is now used by default." msgstr "" -#: ../../library/asyncio-policy.rst:119 +#: ../../library/asyncio-policy.rst:120 +msgid "" +"The :meth:`get_event_loop` method of the default asyncio policy now raises " +"a :exc:`RuntimeError` if there is no set event loop." +msgstr "" + +#: ../../library/asyncio-policy.rst:124 msgid "" -"The :meth:`get_event_loop` method of the default asyncio policy now emits a :" -"exc:`DeprecationWarning` if there is no current event loop set and it " -"decides to create one. In some future Python release this will become an " -"error." +"The :class:`DefaultEventLoopPolicy` class is deprecated and will be removed " +"in Python 3.16." msgstr "" -#: ../../library/asyncio-policy.rst:128 +#: ../../library/asyncio-policy.rst:131 msgid "" "An alternative event loop policy that uses the :class:`SelectorEventLoop` " "event loop implementation." msgstr "" -#: ../../library/asyncio-policy.rst:131 ../../library/asyncio-policy.rst:139 +#: ../../library/asyncio-policy.rst:134 ../../library/asyncio-policy.rst:146 msgid "Availability" msgstr "可用性" #: ../../library/asyncio-policy.rst:136 msgid "" -"An alternative event loop policy that uses the :class:`ProactorEventLoop` " -"event loop implementation." -msgstr "" - -#: ../../library/asyncio-policy.rst:145 -msgid "Process Watchers" -msgstr "" - -#: ../../library/asyncio-policy.rst:147 -msgid "" -"A process watcher allows customization of how an event loop monitors child " -"processes on Unix. Specifically, the event loop needs to know when a child " -"process has exited." -msgstr "" - -#: ../../library/asyncio-policy.rst:151 -msgid "" -"In asyncio, child processes are created with :func:`create_subprocess_exec` " -"and :meth:`loop.subprocess_exec` functions." -msgstr "" - -#: ../../library/asyncio-policy.rst:155 -msgid "" -"asyncio defines the :class:`AbstractChildWatcher` abstract base class, which " -"child watchers should implement, and has four different implementations: :" -"class:`ThreadedChildWatcher` (configured to be used by default), :class:" -"`MultiLoopChildWatcher`, :class:`SafeChildWatcher`, and :class:" -"`FastChildWatcher`." -msgstr "" - -#: ../../library/asyncio-policy.rst:161 -msgid "" -"See also the :ref:`Subprocess and Threads ` " -"section." -msgstr "" - -#: ../../library/asyncio-policy.rst:164 -msgid "" -"The following two functions can be used to customize the child process " -"watcher implementation used by the asyncio event loop:" -msgstr "" - -#: ../../library/asyncio-policy.rst:169 -msgid "Return the current child watcher for the current policy." -msgstr "" - -#: ../../library/asyncio-policy.rst:175 -msgid "" -"Set the current child watcher to *watcher* for the current policy. " -"*watcher* must implement methods defined in the :class:" -"`AbstractChildWatcher` base class." -msgstr "" - -#: ../../library/asyncio-policy.rst:182 -msgid "" -"Third-party event loops implementations might not support custom child " -"watchers. For such event loops, using :func:`set_child_watcher` might be " -"prohibited or have no effect." -msgstr "" - -#: ../../library/asyncio-policy.rst:190 -msgid "Register a new child handler." -msgstr "" - -#: ../../library/asyncio-policy.rst:192 -msgid "" -"Arrange for ``callback(pid, returncode, *args)`` to be called when a process " -"with PID equal to *pid* terminates. Specifying another callback for the " -"same process replaces the previous handler." -msgstr "" - -#: ../../library/asyncio-policy.rst:197 -msgid "The *callback* callable must be thread-safe." -msgstr "" - -#: ../../library/asyncio-policy.rst:201 -msgid "Removes the handler for process with PID equal to *pid*." -msgstr "" - -#: ../../library/asyncio-policy.rst:203 -msgid "" -"The function returns ``True`` if the handler was successfully removed, " -"``False`` if there was nothing to remove." -msgstr "" - -#: ../../library/asyncio-policy.rst:208 -msgid "Attach the watcher to an event loop." -msgstr "" - -#: ../../library/asyncio-policy.rst:210 -msgid "" -"If the watcher was previously attached to an event loop, then it is first " -"detached before attaching to the new loop." -msgstr "" - -#: ../../library/asyncio-policy.rst:213 -msgid "Note: loop may be ``None``." -msgstr "" - -#: ../../library/asyncio-policy.rst:217 -msgid "Return ``True`` if the watcher is ready to use." -msgstr "" - -#: ../../library/asyncio-policy.rst:219 -msgid "" -"Spawning a subprocess with *inactive* current child watcher raises :exc:" -"`RuntimeError`." -msgstr "" - -#: ../../library/asyncio-policy.rst:226 -msgid "Close the watcher." -msgstr "" - -#: ../../library/asyncio-policy.rst:228 -msgid "" -"This method has to be called to ensure that underlying resources are cleaned-" -"up." -msgstr "" - -#: ../../library/asyncio-policy.rst:236 -msgid "" -"This implementation starts a new waiting thread for every subprocess spawn." -msgstr "" - -#: ../../library/asyncio-policy.rst:238 -msgid "" -"It works reliably even when the asyncio event loop is run in a non-main OS " -"thread." -msgstr "" - -#: ../../library/asyncio-policy.rst:240 -msgid "" -"There is no noticeable overhead when handling a big number of children " -"(*O*\\ (1) each time a child terminates), but starting a thread per process " -"requires extra memory." -msgstr "" - -#: ../../library/asyncio-policy.rst:243 -msgid "This watcher is used by default." -msgstr "" - -#: ../../library/asyncio-policy.rst:249 -msgid "" -"This implementation registers a :py:data:`SIGCHLD` signal handler on " -"instantiation. That can break third-party code that installs a custom " -"handler for :py:data:`SIGCHLD` signal." -msgstr "" - -#: ../../library/asyncio-policy.rst:253 ../../library/asyncio-policy.rst:273 -msgid "" -"The watcher avoids disrupting other code spawning processes by polling every " -"process explicitly on a :py:data:`SIGCHLD` signal." -msgstr "" - -#: ../../library/asyncio-policy.rst:256 -msgid "" -"There is no limitation for running subprocesses from different threads once " -"the watcher is installed." -msgstr "" - -#: ../../library/asyncio-policy.rst:259 -msgid "" -"The solution is safe but it has a significant overhead when handling a big " -"number of processes (*O*\\ (*n*) each time a :py:data:`SIGCHLD` is received)." +"The :class:`WindowsSelectorEventLoopPolicy` class is deprecated and will be " +"removed in Python 3.16." msgstr "" -#: ../../library/asyncio-policy.rst:269 +#: ../../library/asyncio-policy.rst:143 msgid "" -"This implementation uses active event loop from the main thread to handle :" -"py:data:`SIGCHLD` signal. If the main thread has no running event loop " -"another thread cannot spawn a subprocess (:exc:`RuntimeError` is raised)." -msgstr "" - -#: ../../library/asyncio-policy.rst:276 -msgid "" -"This solution is as safe as :class:`MultiLoopChildWatcher` and has the same " -"*O*\\ (*n*) complexity but requires a running event loop in the main thread " -"to work." -msgstr "" - -#: ../../library/asyncio-policy.rst:283 -msgid "" -"This implementation reaps every terminated processes by calling ``os." -"waitpid(-1)`` directly, possibly breaking other code spawning processes and " -"waiting for their termination." -msgstr "" - -#: ../../library/asyncio-policy.rst:287 -msgid "" -"There is no noticeable overhead when handling a big number of children " -"(*O*\\ (1) each time a child terminates)." -msgstr "" - -#: ../../library/asyncio-policy.rst:290 -msgid "" -"This solution requires a running event loop in the main thread to work, as :" -"class:`SafeChildWatcher`." +"An alternative event loop policy that uses the :class:`ProactorEventLoop` " +"event loop implementation." msgstr "" -#: ../../library/asyncio-policy.rst:297 +#: ../../library/asyncio-policy.rst:148 msgid "" -"This implementation polls process file descriptors (pidfds) to await child " -"process termination. In some respects, :class:`PidfdChildWatcher` is a " -"\"Goldilocks\" child watcher implementation. It doesn't require signals or " -"threads, doesn't interfere with any processes launched outside the event " -"loop, and scales linearly with the number of subprocesses launched by the " -"event loop. The main disadvantage is that pidfds are specific to Linux, and " -"only work on recent (5.3+) kernels." +"The :class:`WindowsProactorEventLoopPolicy` class is deprecated and will be " +"removed in Python 3.16." msgstr "" -#: ../../library/asyncio-policy.rst:311 +#: ../../library/asyncio-policy.rst:156 msgid "Custom Policies" msgstr "" -#: ../../library/asyncio-policy.rst:313 +#: ../../library/asyncio-policy.rst:158 msgid "" -"To implement a new event loop policy, it is recommended to subclass :class:" -"`DefaultEventLoopPolicy` and override the methods for which custom behavior " -"is wanted, e.g.::" +"To implement a new event loop policy, it is recommended to " +"subclass :class:`DefaultEventLoopPolicy` and override the methods for which " +"custom behavior is wanted, e.g.::" msgstr "" -#: ../../library/asyncio-policy.rst:317 +#: ../../library/asyncio-policy.rst:162 msgid "" "class MyEventLoopPolicy(asyncio.DefaultEventLoopPolicy):\n" "\n" diff --git a/library/asyncio-protocol.po b/library/asyncio-protocol.po index 9b98f921a4d..a8034290eb5 100644 --- a/library/asyncio-protocol.po +++ b/library/asyncio-protocol.po @@ -1,11 +1,10 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2025-08-17 00:18+0000\n" "PO-Revision-Date: 2018-05-23 14:39+0000\n" diff --git a/library/asyncio-queue.po b/library/asyncio-queue.po index c12c90e6e04..322f1d87fb3 100644 --- a/library/asyncio-queue.po +++ b/library/asyncio-queue.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -6,9 +6,9 @@ # Matt Wang , 2022 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-07-26 00:17+0000\n" +"POT-Creation-Date: 2025-11-07 00:14+0000\n" "PO-Revision-Date: 2022-02-20 18:34+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" diff --git a/library/asyncio-runner.po b/library/asyncio-runner.po index edf75f6778e..6ae58e897cf 100644 --- a/library/asyncio-runner.po +++ b/library/asyncio-runner.po @@ -1,13 +1,13 @@ -# Copyright (C) 2001-2022, Python Software Foundation +# 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.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-09-08 15:25+0800\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-" @@ -43,24 +43,28 @@ msgid "Running an asyncio Program" msgstr "運行一個 asyncio 程式" #: ../../library/asyncio-runner.rst:27 -msgid "Execute the :term:`coroutine` *coro* and return the result." -msgstr "執行\\ :term:`協程 (coroutine) ` *coro* 並回傳結果。" +msgid "Execute *coro* in an asyncio event loop and return the result." +msgstr "在 asyncio 事件迴圈中執行 *coro* 並回傳結果。" -#: ../../library/asyncio-runner.rst:29 +#: ../../library/asyncio-runner.rst:29 ../../library/asyncio-runner.rst:121 +msgid "The argument can be any awaitable object." +msgstr "該引數可以是任何可等待物件 (awaitable object)。" + +#: ../../library/asyncio-runner.rst:31 msgid "" -"This function runs the passed coroutine, taking care of managing the asyncio " -"event loop, *finalizing asynchronous generators*, and closing the executor." +"This function runs the awaitable, taking care of managing the asyncio event " +"loop, *finalizing asynchronous generators*, and closing the executor." msgstr "" -"這個函式負責運行被傳入的協程、管理 asyncio 的事件迴圈、*終結非同步產生器*,以" +"這個函式負責運行被傳入的可等待物件、管理 asyncio 的事件迴圈、*終結非同步產生器*\\ 以" "及關閉執行器。" -#: ../../library/asyncio-runner.rst:33 ../../library/asyncio-runner.rst:115 +#: ../../library/asyncio-runner.rst:35 ../../library/asyncio-runner.rst:131 msgid "" "This function cannot be called when another asyncio event loop is running in " "the same thread." msgstr "當另一個非同步事件迴圈在同一執行緒中執行時,無法呼叫此函式。" -#: ../../library/asyncio-runner.rst:36 ../../library/asyncio-runner.rst:85 +#: ../../library/asyncio-runner.rst:38 ../../library/asyncio-runner.rst:97 msgid "" "If *debug* is ``True``, the event loop will be run in debug mode. ``False`` " "disables debug mode explicitly. ``None`` is used to respect the " @@ -70,7 +74,7 @@ msgstr "" "式。``None`` 則會優先使用\\ :ref:`除錯模式 `\\ 的全域設" "定。" -#: ../../library/asyncio-runner.rst:40 +#: ../../library/asyncio-runner.rst:42 msgid "" "If *loop_factory* is not ``None``, it is used to create a new event loop; " "otherwise :func:`asyncio.new_event_loop` is used. The loop is closed at the " @@ -86,18 +90,18 @@ msgstr "" "設定事件迴圈時而不是使用 policies(政策)。傳遞 :class:`asyncio.EventLoop` 可" "以讓 asyncio 在沒有政策系統的情況下運行。" -#: ../../library/asyncio-runner.rst:48 +#: ../../library/asyncio-runner.rst:50 msgid "" "The executor is given a timeout duration of 5 minutes to shutdown. If the " "executor hasn't finished within that duration, a warning is emitted and the " "executor is closed." msgstr "" -#: ../../library/asyncio-runner.rst:52 +#: ../../library/asyncio-runner.rst:54 msgid "Example::" msgstr "範例: ::" -#: ../../library/asyncio-runner.rst:54 +#: ../../library/asyncio-runner.rst:56 msgid "" "async def main():\n" " await asyncio.sleep(1)\n" @@ -111,36 +115,47 @@ msgstr "" "\n" "asyncio.run(main())" -#: ../../library/asyncio-runner.rst:62 +#: ../../library/asyncio-runner.rst:64 msgid "Updated to use :meth:`loop.shutdown_default_executor`." msgstr "" -#: ../../library/asyncio-runner.rst:67 +#: ../../library/asyncio-runner.rst:69 msgid "" "*debug* is ``None`` by default to respect the global debug mode settings." msgstr "" -#: ../../library/asyncio-runner.rst:71 +#: ../../library/asyncio-runner.rst:73 msgid "Added *loop_factory* parameter." msgstr "新增 *loop_factory* 參數。" -#: ../../library/asyncio-runner.rst:75 +#: ../../library/asyncio-runner.rst:77 ../../library/asyncio-runner.rst:136 +msgid "*coro* can be any awaitable object." +msgstr "" + +#: ../../library/asyncio-runner.rst:81 +msgid "" +"The :mod:`!asyncio` policy system is deprecated and will be removed in " +"Python 3.16; from there on, an explicit *loop_factory* is needed to " +"configure the event loop." +msgstr "" + +#: ../../library/asyncio-runner.rst:87 msgid "Runner context manager" msgstr "" -#: ../../library/asyncio-runner.rst:79 +#: ../../library/asyncio-runner.rst:91 msgid "" "A context manager that simplifies *multiple* async function calls in the " "same context." msgstr "" -#: ../../library/asyncio-runner.rst:82 +#: ../../library/asyncio-runner.rst:94 msgid "" "Sometimes several top-level async functions should be called in the " "same :ref:`event loop ` and :class:`contextvars.Context`." msgstr "" -#: ../../library/asyncio-runner.rst:89 +#: ../../library/asyncio-runner.rst:101 msgid "" "*loop_factory* could be used for overriding the loop creation. It is the " "responsibility of the *loop_factory* to set the created loop as the current " @@ -148,13 +163,13 @@ msgid "" "event loop with :func:`asyncio.set_event_loop` if *loop_factory* is ``None``." msgstr "" -#: ../../library/asyncio-runner.rst:94 +#: ../../library/asyncio-runner.rst:106 msgid "" "Basically, :func:`asyncio.run` example can be rewritten with the runner " "usage::" msgstr "" -#: ../../library/asyncio-runner.rst:96 +#: ../../library/asyncio-runner.rst:108 msgid "" "async def main():\n" " await asyncio.sleep(1)\n" @@ -170,52 +185,56 @@ msgstr "" "with asyncio.Runner() as runner:\n" " runner.run(main())" -#: ../../library/asyncio-runner.rst:107 -msgid "Run a :term:`coroutine ` *coro* in the embedded loop." +#: ../../library/asyncio-runner.rst:119 +msgid "Execute *coro* in the embedded event loop." msgstr "" -#: ../../library/asyncio-runner.rst:109 -msgid "Return the coroutine's result or raise its exception." +#: ../../library/asyncio-runner.rst:123 +msgid "If the argument is a coroutine, it is wrapped in a Task." msgstr "" -#: ../../library/asyncio-runner.rst:111 +#: ../../library/asyncio-runner.rst:125 msgid "" "An optional keyword-only *context* argument allows specifying a " -"custom :class:`contextvars.Context` for the *coro* to run in. The runner's " -"default context is used if ``None``." +"custom :class:`contextvars.Context` for the code to run in. The runner's " +"default context is used if context is ``None``." msgstr "" -#: ../../library/asyncio-runner.rst:120 +#: ../../library/asyncio-runner.rst:129 +msgid "Returns the awaitable's result or raises an exception." +msgstr "" + +#: ../../library/asyncio-runner.rst:140 msgid "Close the runner." msgstr "" -#: ../../library/asyncio-runner.rst:122 +#: ../../library/asyncio-runner.rst:142 msgid "" "Finalize asynchronous generators, shutdown default executor, close the event " "loop and release embedded :class:`contextvars.Context`." msgstr "" -#: ../../library/asyncio-runner.rst:127 +#: ../../library/asyncio-runner.rst:147 msgid "Return the event loop associated with the runner instance." msgstr "" -#: ../../library/asyncio-runner.rst:131 +#: ../../library/asyncio-runner.rst:151 msgid "" ":class:`Runner` uses the lazy initialization strategy, its constructor " "doesn't initialize underlying low-level structures." msgstr "" -#: ../../library/asyncio-runner.rst:134 +#: ../../library/asyncio-runner.rst:154 msgid "" "Embedded *loop* and *context* are created at the :keyword:`with` body " "entering or the first call of :meth:`run` or :meth:`get_loop`." msgstr "" -#: ../../library/asyncio-runner.rst:139 +#: ../../library/asyncio-runner.rst:159 msgid "Handling Keyboard Interruption" msgstr "" -#: ../../library/asyncio-runner.rst:143 +#: ../../library/asyncio-runner.rst:163 msgid "" "When :const:`signal.SIGINT` is raised by :kbd:`Ctrl-" "C`, :exc:`KeyboardInterrupt` exception is raised in the main thread by " @@ -223,26 +242,26 @@ msgid "" "interrupt asyncio internals and can hang the program from exiting." msgstr "" -#: ../../library/asyncio-runner.rst:148 +#: ../../library/asyncio-runner.rst:168 msgid "" "To mitigate this issue, :mod:`asyncio` handles :const:`signal.SIGINT` as " "follows:" msgstr "" -#: ../../library/asyncio-runner.rst:150 +#: ../../library/asyncio-runner.rst:170 msgid "" ":meth:`asyncio.Runner.run` installs a custom :const:`signal.SIGINT` handler " "before any user code is executed and removes it when exiting from the " "function." msgstr "" -#: ../../library/asyncio-runner.rst:152 +#: ../../library/asyncio-runner.rst:172 msgid "" "The :class:`~asyncio.Runner` creates the main task for the passed coroutine " "for its execution." msgstr "" -#: ../../library/asyncio-runner.rst:154 +#: ../../library/asyncio-runner.rst:174 msgid "" "When :const:`signal.SIGINT` is raised by :kbd:`Ctrl-C`, the custom signal " "handler cancels the main task by calling :meth:`asyncio.Task.cancel` which " @@ -252,7 +271,7 @@ msgid "" "cancelled, :meth:`asyncio.Runner.run` raises :exc:`KeyboardInterrupt`." msgstr "" -#: ../../library/asyncio-runner.rst:160 +#: ../../library/asyncio-runner.rst:180 msgid "" "A user could write a tight loop which cannot be interrupted " "by :meth:`asyncio.Task.cancel`, in which case the second " diff --git a/library/asyncio-stream.po b/library/asyncio-stream.po index 07e98be812c..064b1899443 100644 --- a/library/asyncio-stream.po +++ b/library/asyncio-stream.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -6,9 +6,9 @@ # Matt Wang , 2022-2024 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-08-19 00:16+0000\n" +"POT-Creation-Date: 2025-10-05 00:16+0000\n" "PO-Revision-Date: 2022-10-31 16:28+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -42,7 +42,7 @@ msgstr "" msgid "Here is an example of a TCP echo client written using asyncio streams::" msgstr "這是一個使用 asyncio 串流編寫的 TCP echo 用戶端範例: ::" -#: ../../library/asyncio-stream.rst:22 ../../library/asyncio-stream.rst:440 +#: ../../library/asyncio-stream.rst:22 ../../library/asyncio-stream.rst:441 msgid "" "import asyncio\n" "\n" @@ -146,7 +146,7 @@ msgstr "移除 *loop* 參數。" #: ../../library/asyncio-stream.rst:87 ../../library/asyncio-stream.rst:131 #: ../../library/asyncio-stream.rst:167 ../../library/asyncio-stream.rst:202 -#: ../../library/asyncio-stream.rst:407 +#: ../../library/asyncio-stream.rst:408 msgid "Added the *ssl_shutdown_timeout* parameter." msgstr "新增 *ssl_shutdown_timeout* 參數。" @@ -409,11 +409,17 @@ msgstr "" "此方法會嘗試立即將 *data* 寫入到底層的 socket。如果失敗,資料會被放到內部寫入" "緩衝中排隊等待 (queue),直到它可被發送。" -#: ../../library/asyncio-stream.rst:319 ../../library/asyncio-stream.rst:334 +#: ../../library/asyncio-stream.rst:319 +msgid "" +"The *data* buffer should be a bytes, bytearray, or C-contiguous one-" +"dimensional memoryview object." +msgstr "" + +#: ../../library/asyncio-stream.rst:322 ../../library/asyncio-stream.rst:335 msgid "The method should be used along with the ``drain()`` method::" msgstr "此方法應當與 ``drain()`` 方法一起使用: ::" -#: ../../library/asyncio-stream.rst:321 +#: ../../library/asyncio-stream.rst:324 msgid "" "stream.write(data)\n" "await stream.drain()" @@ -421,13 +427,7 @@ msgstr "" "stream.write(data)\n" "await stream.drain()" -#: ../../library/asyncio-stream.rst:325 -msgid "" -"The *data* buffer should be a C contiguous one-dimensional :term:`bytes-like " -"object `." -msgstr "" - -#: ../../library/asyncio-stream.rst:329 +#: ../../library/asyncio-stream.rst:330 msgid "" "The method writes a list (or any iterable) of bytes to the underlying socket " "immediately. If that fails, the data is queued in an internal write buffer " @@ -436,7 +436,7 @@ msgstr "" "此方法會立即嘗試將一個位元組 list(或任何可疊代物件 (iterable))寫入到底層的 " "socket。如果失敗,資料會被放到內部寫入緩衝中排隊等待,直到它可被發送。" -#: ../../library/asyncio-stream.rst:336 +#: ../../library/asyncio-stream.rst:337 msgid "" "stream.writelines(lines)\n" "await stream.drain()" @@ -444,17 +444,17 @@ msgstr "" "stream.writelines(lines)\n" "await stream.drain()" -#: ../../library/asyncio-stream.rst:341 +#: ../../library/asyncio-stream.rst:342 msgid "The method closes the stream and the underlying socket." msgstr "此方法會關閉串流以及底層的 socket。" -#: ../../library/asyncio-stream.rst:343 +#: ../../library/asyncio-stream.rst:344 msgid "" "The method should be used, though not mandatory, along with the " "``wait_closed()`` method::" msgstr "此方法應與 ``wait_closed()`` 方法一起使用,但並非強制: ::" -#: ../../library/asyncio-stream.rst:346 +#: ../../library/asyncio-stream.rst:347 msgid "" "stream.close()\n" "await stream.wait_closed()" @@ -462,7 +462,7 @@ msgstr "" "stream.close()\n" "await stream.wait_closed()" -#: ../../library/asyncio-stream.rst:351 +#: ../../library/asyncio-stream.rst:352 msgid "" "Return ``True`` if the underlying transport supports the :meth:`write_eof` " "method, ``False`` otherwise." @@ -470,26 +470,26 @@ msgstr "" "如果底層的傳輸支援 :meth:`write_eof` 方法就回傳 ``True``,否則回傳 " "``False``。" -#: ../../library/asyncio-stream.rst:356 +#: ../../library/asyncio-stream.rst:357 msgid "" "Close the write end of the stream after the buffered write data is flushed." msgstr "在已緩衝的寫入資料被清理 (flush) 後關閉串流的寫入端。" -#: ../../library/asyncio-stream.rst:361 +#: ../../library/asyncio-stream.rst:362 msgid "Return the underlying asyncio transport." msgstr "回傳底層的 asyncio 傳輸。" -#: ../../library/asyncio-stream.rst:365 +#: ../../library/asyncio-stream.rst:366 msgid "" "Access optional transport information; see :meth:`BaseTransport." "get_extra_info` for details." msgstr "存取可選的傳輸資訊;詳情請見 :meth:`BaseTransport.get_extra_info`。" -#: ../../library/asyncio-stream.rst:371 +#: ../../library/asyncio-stream.rst:372 msgid "Wait until it is appropriate to resume writing to the stream. Example::" msgstr "等待直到可以繼續寫入到串流。範例: ::" -#: ../../library/asyncio-stream.rst:374 +#: ../../library/asyncio-stream.rst:375 msgid "" "writer.write(data)\n" "await writer.drain()" @@ -497,7 +497,7 @@ msgstr "" "writer.write(data)\n" "await writer.drain()" -#: ../../library/asyncio-stream.rst:377 +#: ../../library/asyncio-stream.rst:378 msgid "" "This is a flow control method that interacts with the underlying IO write " "buffer. When the size of the buffer reaches the high watermark, *drain()* " @@ -509,48 +509,48 @@ msgstr "" "(high watermark) 時,*drain()* 會阻塞直到緩衝區大小減少至最低標記位 (low " "watermark) 以便繼續寫入。當沒有要等待的資料時,:meth:`drain` 會立即回傳。" -#: ../../library/asyncio-stream.rst:388 +#: ../../library/asyncio-stream.rst:389 msgid "Upgrade an existing stream-based connection to TLS." msgstr "將現有的基於串流的連線升級到 TLS。" -#: ../../library/asyncio-stream.rst:390 +#: ../../library/asyncio-stream.rst:391 msgid "Parameters:" msgstr "參數:" -#: ../../library/asyncio-stream.rst:392 +#: ../../library/asyncio-stream.rst:393 msgid "*sslcontext*: a configured instance of :class:`~ssl.SSLContext`." msgstr "*sslcontext*:一個 :class:`~ssl.SSLContext` 的已配置實例。" -#: ../../library/asyncio-stream.rst:394 +#: ../../library/asyncio-stream.rst:395 msgid "" "*server_hostname*: sets or overrides the host name that the target server's " "certificate will be matched against." msgstr "*server_hostname*:設定或覆寫將會被目標伺服器憑證比對的主機名稱。" -#: ../../library/asyncio-stream.rst:397 +#: ../../library/asyncio-stream.rst:398 msgid "" "*ssl_handshake_timeout* is the time in seconds to wait for the TLS handshake " "to complete before aborting the connection. ``60.0`` seconds if ``None`` " "(default)." msgstr "" -#: ../../library/asyncio-stream.rst:401 +#: ../../library/asyncio-stream.rst:402 msgid "" "*ssl_shutdown_timeout* is the time in seconds to wait for the SSL shutdown " "to complete before aborting the connection. ``30.0`` seconds if ``None`` " "(default)." msgstr "" -#: ../../library/asyncio-stream.rst:413 +#: ../../library/asyncio-stream.rst:414 msgid "" "Return ``True`` if the stream is closed or in the process of being closed." msgstr "如果串流已被關閉或正在被關閉則回傳 ``True``。" -#: ../../library/asyncio-stream.rst:421 +#: ../../library/asyncio-stream.rst:422 msgid "Wait until the stream is closed." msgstr "等待直到串流被關閉。" -#: ../../library/asyncio-stream.rst:423 +#: ../../library/asyncio-stream.rst:424 msgid "" "Should be called after :meth:`close` to wait until the underlying connection " "is closed, ensuring that all data has been flushed before e.g. exiting the " @@ -559,19 +559,19 @@ msgstr "" "應當在 :meth:`close` 之後才被呼叫,這會持續等待直到底層的連線被關閉,以確保在" "這之前(例如在程式退出前)所有資料都已經被清空" -#: ../../library/asyncio-stream.rst:431 +#: ../../library/asyncio-stream.rst:432 msgid "Examples" msgstr "範例" -#: ../../library/asyncio-stream.rst:436 +#: ../../library/asyncio-stream.rst:437 msgid "TCP echo client using streams" msgstr "使用串流的 TCP echo 用戶端" -#: ../../library/asyncio-stream.rst:438 +#: ../../library/asyncio-stream.rst:439 msgid "TCP echo client using the :func:`asyncio.open_connection` function::" msgstr "使用 :func:`asyncio.open_connection` 函式的 TCP echo 用戶端: ::" -#: ../../library/asyncio-stream.rst:462 +#: ../../library/asyncio-stream.rst:463 msgid "" "The :ref:`TCP echo client protocol " "` example uses the low-level :meth:" @@ -580,15 +580,15 @@ msgstr "" "使用低階 :meth:`loop.create_connection` 方法的 :ref:`TCP echo 用戶端協定 " "`\\ 範例。" -#: ../../library/asyncio-stream.rst:469 +#: ../../library/asyncio-stream.rst:470 msgid "TCP echo server using streams" msgstr "使用串流的 TCP echo 伺服器" -#: ../../library/asyncio-stream.rst:471 +#: ../../library/asyncio-stream.rst:472 msgid "TCP echo server using the :func:`asyncio.start_server` function::" msgstr "TCP echo 伺服器使用 :func:`asyncio.start_server` 函式: ::" -#: ../../library/asyncio-stream.rst:473 +#: ../../library/asyncio-stream.rst:474 msgid "" "import asyncio\n" "\n" @@ -648,7 +648,7 @@ msgstr "" "\n" "asyncio.run(main())" -#: ../../library/asyncio-stream.rst:505 +#: ../../library/asyncio-stream.rst:506 msgid "" "The :ref:`TCP echo server protocol " "` example uses the :meth:`loop." @@ -657,16 +657,16 @@ msgstr "" "使用 :meth:`loop.create_server` 方法的 :ref:`TCP echo 伺服器協定 " "` 範例。" -#: ../../library/asyncio-stream.rst:510 +#: ../../library/asyncio-stream.rst:511 msgid "Get HTTP headers" msgstr "取得 HTTP 標頭" -#: ../../library/asyncio-stream.rst:512 +#: ../../library/asyncio-stream.rst:513 msgid "" "Simple example querying HTTP headers of the URL passed on the command line::" msgstr "查詢自命令列傳入之 URL 所帶有 HTTP 標頭的簡單範例: ::" -#: ../../library/asyncio-stream.rst:514 +#: ../../library/asyncio-stream.rst:515 msgid "" "import asyncio\n" "import urllib.parse\n" @@ -705,34 +705,34 @@ msgid "" "asyncio.run(print_http_headers(url))" msgstr "" -#: ../../library/asyncio-stream.rst:551 +#: ../../library/asyncio-stream.rst:552 msgid "Usage::" msgstr "用法: ::" -#: ../../library/asyncio-stream.rst:553 +#: ../../library/asyncio-stream.rst:554 msgid "python example.py http://example.com/path/page.html" msgstr "python example.py http://example.com/path/page.html" -#: ../../library/asyncio-stream.rst:555 +#: ../../library/asyncio-stream.rst:556 msgid "or with HTTPS::" msgstr "或使用 HTTPS: ::" -#: ../../library/asyncio-stream.rst:557 +#: ../../library/asyncio-stream.rst:558 msgid "python example.py https://example.com/path/page.html" msgstr "python example.py https://example.com/path/page.html" -#: ../../library/asyncio-stream.rst:563 +#: ../../library/asyncio-stream.rst:564 msgid "Register an open socket to wait for data using streams" msgstr "註冊一個使用串流來等待資料的開放 socket" -#: ../../library/asyncio-stream.rst:565 +#: ../../library/asyncio-stream.rst:566 msgid "" "Coroutine waiting until a socket receives data using the :func:" "`open_connection` function::" msgstr "" "等待直到 socket 透過使用 :func:`open_connection` 函式接收到資料的協程: ::" -#: ../../library/asyncio-stream.rst:568 +#: ../../library/asyncio-stream.rst:569 msgid "" "import asyncio\n" "import socket\n" @@ -765,7 +765,7 @@ msgid "" "asyncio.run(wait_for_data())" msgstr "" -#: ../../library/asyncio-stream.rst:600 +#: ../../library/asyncio-stream.rst:601 msgid "" "The :ref:`register an open socket to wait for data using a protocol " "` example uses a low-level protocol and " @@ -775,7 +775,7 @@ msgstr "" "`\\ 範例中,有使用了低階協定以及 :meth:" "`loop.create_connection` 方法。" -#: ../../library/asyncio-stream.rst:604 +#: ../../library/asyncio-stream.rst:605 msgid "" "The :ref:`watch a file descriptor for read events " "` example uses the low-level :meth:`loop." diff --git a/library/asyncio-subprocess.po b/library/asyncio-subprocess.po index 8669d045c3d..aec812b1ee5 100644 --- a/library/asyncio-subprocess.po +++ b/library/asyncio-subprocess.po @@ -1,14 +1,13 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Leon H., 2017 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-03-12 00:14+0000\n" +"POT-Creation-Date: 2025-11-07 00:14+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-" @@ -83,7 +82,7 @@ msgstr "" #: ../../library/asyncio-subprocess.rst:40 msgid "will print::" -msgstr "" +msgstr "會印出: ::" #: ../../library/asyncio-subprocess.rst:42 msgid "" @@ -129,10 +128,10 @@ msgstr "建立子行程" #: ../../library/asyncio-subprocess.rst:68 msgid "Create a subprocess." -msgstr "" +msgstr "建立一個子行程。" #: ../../library/asyncio-subprocess.rst:70 -#: ../../library/asyncio-subprocess.rst:89 +#: ../../library/asyncio-subprocess.rst:92 msgid "" "The *limit* argument sets the buffer limit for :class:`StreamReader` " "wrappers for :attr:`~asyncio.subprocess.Process.stdout` and :attr:`~asyncio." @@ -141,9 +140,9 @@ msgid "" msgstr "" #: ../../library/asyncio-subprocess.rst:74 -#: ../../library/asyncio-subprocess.rst:93 +#: ../../library/asyncio-subprocess.rst:96 msgid "Return a :class:`~asyncio.subprocess.Process` instance." -msgstr "" +msgstr "回傳一個 :class:`~asyncio.subprocess.Process` 實例。" #: ../../library/asyncio-subprocess.rst:76 msgid "" @@ -151,20 +150,27 @@ msgid "" msgstr "" #: ../../library/asyncio-subprocess.rst:79 -#: ../../library/asyncio-subprocess.rst:107 -msgid "Removed the *loop* parameter." +#: ../../library/asyncio-subprocess.rst:101 +msgid "" +"If the process object is garbage collected while the process is still " +"running, the child process will be killed." msgstr "" -#: ../../library/asyncio-subprocess.rst:87 +#: ../../library/asyncio-subprocess.rst:82 +#: ../../library/asyncio-subprocess.rst:113 +msgid "Removed the *loop* parameter." +msgstr "移除了 *loop* 參數。" + +#: ../../library/asyncio-subprocess.rst:90 msgid "Run the *cmd* shell command." -msgstr "" +msgstr "執行 *cmd* shell 命令。" -#: ../../library/asyncio-subprocess.rst:95 +#: ../../library/asyncio-subprocess.rst:98 msgid "" "See the documentation of :meth:`loop.subprocess_shell` for other parameters." msgstr "" -#: ../../library/asyncio-subprocess.rst:100 +#: ../../library/asyncio-subprocess.rst:106 msgid "" "It is the application's responsibility to ensure that all whitespace and " "special characters are quoted appropriately to avoid `shell injection " @@ -174,14 +180,14 @@ msgid "" "be used to construct shell commands." msgstr "" -#: ../../library/asyncio-subprocess.rst:112 +#: ../../library/asyncio-subprocess.rst:118 msgid "" "Subprocesses are available for Windows if a :class:`ProactorEventLoop` is " "used. See :ref:`Subprocess Support on Windows ` " "for details." msgstr "" -#: ../../library/asyncio-subprocess.rst:118 +#: ../../library/asyncio-subprocess.rst:124 msgid "" "asyncio also has the following *low-level* APIs to work with subprocesses: :" "meth:`loop.subprocess_exec`, :meth:`loop.subprocess_shell`, :meth:`loop." @@ -190,22 +196,22 @@ msgid "" "Protocols `." msgstr "" -#: ../../library/asyncio-subprocess.rst:126 +#: ../../library/asyncio-subprocess.rst:132 msgid "Constants" msgstr "常數" -#: ../../library/asyncio-subprocess.rst:131 +#: ../../library/asyncio-subprocess.rst:137 msgid "Can be passed to the *stdin*, *stdout* or *stderr* parameters." msgstr "" -#: ../../library/asyncio-subprocess.rst:133 +#: ../../library/asyncio-subprocess.rst:139 msgid "" "If *PIPE* is passed to *stdin* argument, the :attr:`Process.stdin ` attribute will point to a :class:`~asyncio." "StreamWriter` instance." msgstr "" -#: ../../library/asyncio-subprocess.rst:137 +#: ../../library/asyncio-subprocess.rst:143 msgid "" "If *PIPE* is passed to *stdout* or *stderr* arguments, the :attr:`Process." "stdout ` and :attr:`Process.stderr " @@ -213,24 +219,24 @@ msgid "" "`~asyncio.StreamReader` instances." msgstr "" -#: ../../library/asyncio-subprocess.rst:145 +#: ../../library/asyncio-subprocess.rst:151 msgid "" "Special value that can be used as the *stderr* argument and indicates that " "standard error should be redirected into standard output." msgstr "" -#: ../../library/asyncio-subprocess.rst:151 +#: ../../library/asyncio-subprocess.rst:157 msgid "" "Special value that can be used as the *stdin*, *stdout* or *stderr* argument " "to process creation functions. It indicates that the special file :data:`os." "devnull` will be used for the corresponding subprocess stream." msgstr "" -#: ../../library/asyncio-subprocess.rst:157 +#: ../../library/asyncio-subprocess.rst:163 msgid "Interacting with Subprocesses" -msgstr "" +msgstr "與子行程互動" -#: ../../library/asyncio-subprocess.rst:159 +#: ../../library/asyncio-subprocess.rst:165 msgid "" "Both :func:`create_subprocess_exec` and :func:`create_subprocess_shell` " "functions return instances of the *Process* class. *Process* is a high-" @@ -238,62 +244,62 @@ msgid "" "their completion." msgstr "" -#: ../../library/asyncio-subprocess.rst:167 +#: ../../library/asyncio-subprocess.rst:173 msgid "" "An object that wraps OS processes created by the :func:`~asyncio." "create_subprocess_exec` and :func:`~asyncio.create_subprocess_shell` " "functions." msgstr "" -#: ../../library/asyncio-subprocess.rst:171 +#: ../../library/asyncio-subprocess.rst:177 msgid "" "This class is designed to have a similar API to the :class:`subprocess." "Popen` class, but there are some notable differences:" msgstr "" -#: ../../library/asyncio-subprocess.rst:175 +#: ../../library/asyncio-subprocess.rst:181 msgid "" "unlike Popen, Process instances do not have an equivalent to the :meth:" "`~subprocess.Popen.poll` method;" msgstr "" -#: ../../library/asyncio-subprocess.rst:178 +#: ../../library/asyncio-subprocess.rst:184 msgid "" "the :meth:`~asyncio.subprocess.Process.communicate` and :meth:`~asyncio." "subprocess.Process.wait` methods don't have a *timeout* parameter: use the :" "func:`~asyncio.wait_for` function;" msgstr "" -#: ../../library/asyncio-subprocess.rst:182 +#: ../../library/asyncio-subprocess.rst:188 msgid "" "the :meth:`Process.wait() ` method is " "asynchronous, whereas :meth:`subprocess.Popen.wait` method is implemented as " "a blocking busy loop;" msgstr "" -#: ../../library/asyncio-subprocess.rst:186 +#: ../../library/asyncio-subprocess.rst:192 msgid "the *universal_newlines* parameter is not supported." msgstr "" -#: ../../library/asyncio-subprocess.rst:188 +#: ../../library/asyncio-subprocess.rst:194 msgid "This class is :ref:`not thread safe `." msgstr "" -#: ../../library/asyncio-subprocess.rst:190 +#: ../../library/asyncio-subprocess.rst:196 msgid "" "See also the :ref:`Subprocess and Threads ` " "section." msgstr "" -#: ../../library/asyncio-subprocess.rst:196 +#: ../../library/asyncio-subprocess.rst:202 msgid "Wait for the child process to terminate." msgstr "" -#: ../../library/asyncio-subprocess.rst:198 +#: ../../library/asyncio-subprocess.rst:204 msgid "Set and return the :attr:`returncode` attribute." msgstr "" -#: ../../library/asyncio-subprocess.rst:202 +#: ../../library/asyncio-subprocess.rst:208 msgid "" "This method can deadlock when using ``stdout=PIPE`` or ``stderr=PIPE`` and " "the child process generates so much output that it blocks waiting for the OS " @@ -301,37 +307,37 @@ msgid "" "using pipes to avoid this condition." msgstr "" -#: ../../library/asyncio-subprocess.rst:211 +#: ../../library/asyncio-subprocess.rst:217 msgid "Interact with process:" msgstr "" -#: ../../library/asyncio-subprocess.rst:213 +#: ../../library/asyncio-subprocess.rst:219 msgid "send data to *stdin* (if *input* is not ``None``);" msgstr "" -#: ../../library/asyncio-subprocess.rst:214 +#: ../../library/asyncio-subprocess.rst:220 msgid "closes *stdin*;" -msgstr "" +msgstr "關閉 *stdin*;" -#: ../../library/asyncio-subprocess.rst:215 +#: ../../library/asyncio-subprocess.rst:221 msgid "read data from *stdout* and *stderr*, until EOF is reached;" -msgstr "" +msgstr "從 *stdout* 和 *stderr* 讀取資料,直到 EOF;" -#: ../../library/asyncio-subprocess.rst:216 +#: ../../library/asyncio-subprocess.rst:222 msgid "wait for process to terminate." -msgstr "" +msgstr "等待行程終止。" -#: ../../library/asyncio-subprocess.rst:218 +#: ../../library/asyncio-subprocess.rst:224 msgid "" "The optional *input* argument is the data (:class:`bytes` object) that will " "be sent to the child process." msgstr "" -#: ../../library/asyncio-subprocess.rst:221 +#: ../../library/asyncio-subprocess.rst:227 msgid "Return a tuple ``(stdout_data, stderr_data)``." -msgstr "" +msgstr "回傳一個 ``(stdout_data, stderr_data)`` 元組。" -#: ../../library/asyncio-subprocess.rst:223 +#: ../../library/asyncio-subprocess.rst:229 msgid "" "If either :exc:`BrokenPipeError` or :exc:`ConnectionResetError` exception is " "raised when writing *input* into *stdin*, the exception is ignored. This " @@ -339,7 +345,7 @@ msgid "" "*stdin*." msgstr "" -#: ../../library/asyncio-subprocess.rst:228 +#: ../../library/asyncio-subprocess.rst:234 msgid "" "If it is desired to send data to the process' *stdin*, the process needs to " "be created with ``stdin=PIPE``. Similarly, to get anything other than " @@ -347,76 +353,76 @@ msgid "" "``stdout=PIPE`` and/or ``stderr=PIPE`` arguments." msgstr "" -#: ../../library/asyncio-subprocess.rst:234 +#: ../../library/asyncio-subprocess.rst:240 msgid "" "Note, that the data read is buffered in memory, so do not use this method if " "the data size is large or unlimited." msgstr "" -#: ../../library/asyncio-subprocess.rst:239 +#: ../../library/asyncio-subprocess.rst:245 msgid "*stdin* gets closed when ``input=None`` too." msgstr "" -#: ../../library/asyncio-subprocess.rst:243 +#: ../../library/asyncio-subprocess.rst:249 msgid "Sends the signal *signal* to the child process." msgstr "" -#: ../../library/asyncio-subprocess.rst:247 +#: ../../library/asyncio-subprocess.rst:253 msgid "" "On Windows, :py:const:`~signal.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/asyncio-subprocess.rst:254 +#: ../../library/asyncio-subprocess.rst:260 msgid "Stop the child process." msgstr "" -#: ../../library/asyncio-subprocess.rst:256 +#: ../../library/asyncio-subprocess.rst:262 msgid "" "On POSIX systems this method sends :py:const:`~signal.SIGTERM` to the child " "process." msgstr "" -#: ../../library/asyncio-subprocess.rst:259 +#: ../../library/asyncio-subprocess.rst:265 msgid "" "On Windows the Win32 API function :c:func:`!TerminateProcess` is called to " "stop the child process." msgstr "" -#: ../../library/asyncio-subprocess.rst:264 +#: ../../library/asyncio-subprocess.rst:270 msgid "Kill the child process." msgstr "" -#: ../../library/asyncio-subprocess.rst:266 +#: ../../library/asyncio-subprocess.rst:272 msgid "" "On POSIX systems this method sends :py:data:`~signal.SIGKILL` to the child " "process." msgstr "" -#: ../../library/asyncio-subprocess.rst:269 +#: ../../library/asyncio-subprocess.rst:275 msgid "On Windows this method is an alias for :meth:`terminate`." msgstr "" -#: ../../library/asyncio-subprocess.rst:273 +#: ../../library/asyncio-subprocess.rst:279 msgid "" "Standard input stream (:class:`~asyncio.StreamWriter`) or ``None`` if the " "process was created with ``stdin=None``." msgstr "" -#: ../../library/asyncio-subprocess.rst:278 +#: ../../library/asyncio-subprocess.rst:284 msgid "" "Standard output stream (:class:`~asyncio.StreamReader`) or ``None`` if the " "process was created with ``stdout=None``." msgstr "" -#: ../../library/asyncio-subprocess.rst:283 +#: ../../library/asyncio-subprocess.rst:289 msgid "" "Standard error stream (:class:`~asyncio.StreamReader`) or ``None`` if the " "process was created with ``stderr=None``." msgstr "" -#: ../../library/asyncio-subprocess.rst:288 +#: ../../library/asyncio-subprocess.rst:294 msgid "" "Use the :meth:`communicate` method rather than :attr:`process.stdin.write() " "`, :attr:`await process.stdout.read() ` or :attr:`await " @@ -424,94 +430,76 @@ msgid "" "pausing reading or writing and blocking the child process." msgstr "" -#: ../../library/asyncio-subprocess.rst:297 +#: ../../library/asyncio-subprocess.rst:303 msgid "Process identification number (PID)." msgstr "" -#: ../../library/asyncio-subprocess.rst:299 +#: ../../library/asyncio-subprocess.rst:305 msgid "" "Note that for processes created by the :func:`~asyncio." "create_subprocess_shell` function, this attribute is the PID of the spawned " "shell." msgstr "" -#: ../../library/asyncio-subprocess.rst:304 +#: ../../library/asyncio-subprocess.rst:310 msgid "Return code of the process when it exits." msgstr "" -#: ../../library/asyncio-subprocess.rst:306 +#: ../../library/asyncio-subprocess.rst:312 msgid "A ``None`` value indicates that the process has not terminated yet." msgstr "" -#: ../../library/asyncio-subprocess.rst:308 +#: ../../library/asyncio-subprocess.rst:314 msgid "" "A negative value ``-N`` indicates that the child was terminated by signal " "``N`` (POSIX only)." msgstr "" -#: ../../library/asyncio-subprocess.rst:315 +#: ../../library/asyncio-subprocess.rst:321 msgid "Subprocess and Threads" -msgstr "子行程與線程" +msgstr "子行程與執行緒" -#: ../../library/asyncio-subprocess.rst:317 +#: ../../library/asyncio-subprocess.rst:323 msgid "" "Standard asyncio event loop supports running subprocesses from different " "threads by default." msgstr "" -#: ../../library/asyncio-subprocess.rst:320 +#: ../../library/asyncio-subprocess.rst:326 msgid "" "On Windows subprocesses are provided by :class:`ProactorEventLoop` only " "(default), :class:`SelectorEventLoop` has no subprocess support." msgstr "" -#: ../../library/asyncio-subprocess.rst:323 -msgid "" -"On UNIX *child watchers* are used for subprocess finish waiting, see :ref:" -"`asyncio-watchers` for more info." -msgstr "" - #: ../../library/asyncio-subprocess.rst:329 msgid "" -"UNIX switched to use :class:`ThreadedChildWatcher` for spawning subprocesses " -"from different threads without any limitation." -msgstr "" - -#: ../../library/asyncio-subprocess.rst:332 -msgid "" -"Spawning a subprocess with *inactive* current child watcher raises :exc:" -"`RuntimeError`." -msgstr "" - -#: ../../library/asyncio-subprocess.rst:335 -msgid "" "Note that alternative event loop implementations might have own limitations; " "please refer to their documentation." msgstr "" -#: ../../library/asyncio-subprocess.rst:340 +#: ../../library/asyncio-subprocess.rst:334 msgid "" "The :ref:`Concurrency and multithreading in asyncio ` section." msgstr "" -#: ../../library/asyncio-subprocess.rst:345 +#: ../../library/asyncio-subprocess.rst:339 msgid "Examples" msgstr "範例" -#: ../../library/asyncio-subprocess.rst:347 +#: ../../library/asyncio-subprocess.rst:341 msgid "" "An example using the :class:`~asyncio.subprocess.Process` class to control a " "subprocess and the :class:`StreamReader` class to read from its standard " "output." msgstr "" -#: ../../library/asyncio-subprocess.rst:353 +#: ../../library/asyncio-subprocess.rst:347 msgid "" "The subprocess is created by the :func:`create_subprocess_exec` function::" msgstr "" -#: ../../library/asyncio-subprocess.rst:356 +#: ../../library/asyncio-subprocess.rst:350 msgid "" "import asyncio\n" "import sys\n" @@ -537,7 +525,7 @@ msgid "" "print(f\"Current date: {date}\")" msgstr "" -#: ../../library/asyncio-subprocess.rst:380 +#: ../../library/asyncio-subprocess.rst:374 msgid "" "See also the :ref:`same example ` written " "using low-level APIs." diff --git a/library/asyncio-sync.po b/library/asyncio-sync.po index cee3fe67891..4d524fee3b0 100644 --- a/library/asyncio-sync.po +++ b/library/asyncio-sync.po @@ -1,10 +1,10 @@ -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2025-08-17 00:18+0000\n" "PO-Revision-Date: 2022-02-09 19:27+0800\n" diff --git a/library/asyncio-task.po b/library/asyncio-task.po index 07925812b0f..061f1ca20a3 100644 --- a/library/asyncio-task.po +++ b/library/asyncio-task.po @@ -1,12 +1,12 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-08-10 00:19+0000\n" +"POT-Creation-Date: 2025-09-08 15:25+0800\n" "PO-Revision-Date: 2018-05-23 14:39+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -199,8 +199,8 @@ msgstr "" #: ../../library/asyncio-task.rst:110 msgid "" -"The :class:`asyncio.TaskGroup` class provides a more modern alternative to :" -"func:`create_task`. Using this API, the last example becomes::" +"The :class:`asyncio.TaskGroup` class provides a more modern alternative " +"to :func:`create_task`. Using this API, the last example becomes::" msgstr "" #: ../../library/asyncio-task.rst:114 @@ -234,8 +234,8 @@ msgstr "" #: ../../library/asyncio-task.rst:139 msgid "" -"We say that an object is an **awaitable** object if it can be used in an :" -"keyword:`await` expression. Many asyncio APIs are designed to accept " +"We say that an object is an **awaitable** object if it can be used in " +"an :keyword:`await` expression. Many asyncio APIs are designed to accept " "awaitables." msgstr "" @@ -295,8 +295,9 @@ msgstr "" #: ../../library/asyncio-task.rst:183 msgid "" -"When a coroutine is wrapped into a *Task* with functions like :func:`asyncio." -"create_task` the coroutine is automatically scheduled to run soon::" +"When a coroutine is wrapped into a *Task* with functions " +"like :func:`asyncio.create_task` the coroutine is automatically scheduled to " +"run soon::" msgstr "" #: ../../library/asyncio-task.rst:187 @@ -366,8 +367,8 @@ msgstr "" #: ../../library/asyncio-task.rst:230 msgid "" -"A good example of a low-level function that returns a Future object is :meth:" -"`loop.run_in_executor`." +"A good example of a low-level function that returns a Future object " +"is :meth:`loop.run_in_executor`." msgstr "" #: ../../library/asyncio-task.rst:235 @@ -386,31 +387,41 @@ msgstr "" #: ../../library/asyncio-task.rst:246 msgid "" -"If *name* is not ``None``, it is set as the name of the task using :meth:" -"`Task.set_name`." +"The full function signature is largely the same as that of the :class:`Task` " +"constructor (or factory) - all of the keyword arguments to this function are " +"passed through to that interface." msgstr "" -#: ../../library/asyncio-task.rst:249 +#: ../../library/asyncio-task.rst:250 msgid "" -"An optional keyword-only *context* argument allows specifying a custom :" -"class:`contextvars.Context` for the *coro* to run in. The current context " -"copy is created when no *context* is provided." +"An optional keyword-only *context* argument allows specifying a " +"custom :class:`contextvars.Context` for the *coro* to run in. The current " +"context copy is created when no *context* is provided." msgstr "" -#: ../../library/asyncio-task.rst:253 +#: ../../library/asyncio-task.rst:254 msgid "" -"The task is executed in the loop returned by :func:`get_running_loop`, :exc:" -"`RuntimeError` is raised if there is no running loop in current thread." +"An optional keyword-only *eager_start* argument allows specifying if the " +"task should execute eagerly during the call to create_task, or be scheduled " +"later. If *eager_start* is not passed the mode set " +"by :meth:`loop.set_task_factory` will be used." msgstr "" #: ../../library/asyncio-task.rst:259 msgid "" +"The task is executed in the loop returned " +"by :func:`get_running_loop`, :exc:`RuntimeError` is raised if there is no " +"running loop in current thread." +msgstr "" + +#: ../../library/asyncio-task.rst:265 +msgid "" ":meth:`asyncio.TaskGroup.create_task` is a new alternative leveraging " "structural concurrency; it allows for waiting for a group of related tasks " "with strong safety guarantees." msgstr "" -#: ../../library/asyncio-task.rst:265 +#: ../../library/asyncio-task.rst:271 msgid "" "Save a reference to the result of this function, to avoid a task " "disappearing mid-execution. The event loop only keeps weak references to " @@ -419,7 +430,7 @@ msgid "" "tasks, gather them in a collection::" msgstr "" -#: ../../library/asyncio-task.rst:272 +#: ../../library/asyncio-task.rst:278 msgid "" "background_tasks = set()\n" "\n" @@ -435,90 +446,106 @@ msgid "" " task.add_done_callback(background_tasks.discard)" msgstr "" -#: ../../library/asyncio-task.rst:287 ../../library/asyncio-task.rst:1193 +#: ../../library/asyncio-task.rst:293 ../../library/asyncio-task.rst:1251 msgid "Added the *name* parameter." msgstr "新增 *name* 參數。" -#: ../../library/asyncio-task.rst:290 ../../library/asyncio-task.rst:1200 +#: ../../library/asyncio-task.rst:296 ../../library/asyncio-task.rst:1258 msgid "Added the *context* parameter." msgstr "新增 *context* 參數。" -#: ../../library/asyncio-task.rst:295 +#: ../../library/asyncio-task.rst:299 +msgid "Added the *eager_start* parameter by passing on all *kwargs*." +msgstr "" + +#: ../../library/asyncio-task.rst:304 msgid "Task Cancellation" msgstr "" -#: ../../library/asyncio-task.rst:297 +#: ../../library/asyncio-task.rst:306 msgid "" -"Tasks can easily and safely be cancelled. When a task is cancelled, :exc:" -"`asyncio.CancelledError` will be raised in the task at the next opportunity." +"Tasks can easily and safely be cancelled. When a task is " +"cancelled, :exc:`asyncio.CancelledError` will be raised in the task at the " +"next opportunity." msgstr "" -#: ../../library/asyncio-task.rst:301 +#: ../../library/asyncio-task.rst:310 msgid "" "It is recommended that coroutines use ``try/finally`` blocks to robustly " "perform clean-up logic. In case :exc:`asyncio.CancelledError` is explicitly " -"caught, it should generally be propagated when clean-up is complete. :exc:" -"`asyncio.CancelledError` directly subclasses :exc:`BaseException` so most " -"code will not need to be aware of it." +"caught, it should generally be propagated when clean-up is " +"complete. :exc:`asyncio.CancelledError` directly " +"subclasses :exc:`BaseException` so most code will not need to be aware of it." msgstr "" -#: ../../library/asyncio-task.rst:307 +#: ../../library/asyncio-task.rst:316 msgid "" -"The asyncio components that enable structured concurrency, like :class:" -"`asyncio.TaskGroup` and :func:`asyncio.timeout`, are implemented using " -"cancellation internally and might misbehave if a coroutine swallows :exc:" -"`asyncio.CancelledError`. Similarly, user code should not generally call :" -"meth:`uncancel `. However, in cases when suppressing :" -"exc:`asyncio.CancelledError` is truly desired, it is necessary to also call " -"``uncancel()`` to completely remove the cancellation state." +"The asyncio components that enable structured concurrency, " +"like :class:`asyncio.TaskGroup` and :func:`asyncio.timeout`, are implemented " +"using cancellation internally and might misbehave if a coroutine " +"swallows :exc:`asyncio.CancelledError`. Similarly, user code should not " +"generally call :meth:`uncancel `. However, in cases " +"when suppressing :exc:`asyncio.CancelledError` is truly desired, it is " +"necessary to also call ``uncancel()`` to completely remove the cancellation " +"state." msgstr "" -#: ../../library/asyncio-task.rst:319 +#: ../../library/asyncio-task.rst:328 msgid "Task Groups" msgstr "" -#: ../../library/asyncio-task.rst:321 +#: ../../library/asyncio-task.rst:330 msgid "" "Task groups combine a task creation API with a convenient and reliable way " "to wait for all tasks in the group to finish." msgstr "" -#: ../../library/asyncio-task.rst:326 +#: ../../library/asyncio-task.rst:335 msgid "" "An :ref:`asynchronous context manager ` holding a " "group of tasks. Tasks can be added to the group using :meth:`create_task`. " "All tasks are awaited when the context manager exits." msgstr "" -#: ../../library/asyncio-task.rst:335 +#: ../../library/asyncio-task.rst:344 msgid "" -"Create a task in this task group. The signature matches that of :func:" -"`asyncio.create_task`. If the task group is inactive (e.g. not yet entered, " -"already finished, or in the process of shutting down), we will close the " -"given ``coro``." +"Create a task in this task group. The signature matches that " +"of :func:`asyncio.create_task`. If the task group is inactive (e.g. not yet " +"entered, already finished, or in the process of shutting down), we will " +"close the given ``coro``." msgstr "" -#: ../../library/asyncio-task.rst:343 +#: ../../library/asyncio-task.rst:352 msgid "Close the given coroutine if the task group is not active." msgstr "" -#: ../../library/asyncio-task.rst:345 ../../library/asyncio-task.rst:551 -#: ../../library/asyncio-task.rst:724 ../../library/asyncio-task.rst:782 -#: ../../library/asyncio-task.rst:808 ../../library/asyncio-task.rst:849 +#: ../../library/asyncio-task.rst:356 +msgid "Passes on all *kwargs* to :meth:`loop.create_task`" +msgstr "" + +#: ../../library/asyncio-task.rst:358 ../../library/asyncio-task.rst:564 +#: ../../library/asyncio-task.rst:737 ../../library/asyncio-task.rst:795 +#: ../../library/asyncio-task.rst:821 ../../library/asyncio-task.rst:862 msgid "Example::" msgstr "範例: ::" -#: ../../library/asyncio-task.rst:347 +#: ../../library/asyncio-task.rst:360 msgid "" "async def main():\n" " async with asyncio.TaskGroup() as tg:\n" " task1 = tg.create_task(some_coro(...))\n" " task2 = tg.create_task(another_coro(...))\n" -" print(f\"Both tasks have completed now: {task1.result()}, {task2." -"result()}\")" +" print(f\"Both tasks have completed now: {task1.result()}, " +"{task2.result()}\")" msgstr "" +"async def main():\n" +" async with asyncio.TaskGroup() as tg:\n" +" task1 = tg.create_task(some_coro(...))\n" +" task2 = tg.create_task(another_coro(...))\n" +" print(f\"Both tasks have completed now: {task1.result()}, " +"{task2.result()}\")" -#: ../../library/asyncio-task.rst:353 +#: ../../library/asyncio-task.rst:366 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 " @@ -527,19 +554,19 @@ msgid "" "block is exited, no new tasks may be added to the group." msgstr "" -#: ../../library/asyncio-task.rst:360 +#: ../../library/asyncio-task.rst:373 msgid "" "The first time any of the tasks belonging to the group fails with an " "exception other than :exc:`asyncio.CancelledError`, the remaining tasks in " "the group are cancelled. No further tasks can then be added to the group. At " -"this point, if the body of the ``async with`` statement is still active (i." -"e., :meth:`~object.__aexit__` hasn't been called yet), the task directly " -"containing the ``async with`` statement is also cancelled. The resulting :" -"exc:`asyncio.CancelledError` will interrupt an ``await``, but it will not " -"bubble out of the containing ``async with`` statement." +"this point, if the body of the ``async with`` statement is still active " +"(i.e., :meth:`~object.__aexit__` hasn't been called yet), the task directly " +"containing the ``async with`` statement is also cancelled. The " +"resulting :exc:`asyncio.CancelledError` will interrupt an ``await``, but it " +"will not bubble out of the containing ``async with`` statement." msgstr "" -#: ../../library/asyncio-task.rst:370 +#: ../../library/asyncio-task.rst:383 msgid "" "Once all tasks have finished, if any tasks have failed with an exception " "other than :exc:`asyncio.CancelledError`, those exceptions are combined in " @@ -547,28 +574,29 @@ msgid "" "their documentation) which is then raised." msgstr "" -#: ../../library/asyncio-task.rst:377 +#: ../../library/asyncio-task.rst:390 msgid "" -"Two base exceptions are treated specially: If any task fails with :exc:" -"`KeyboardInterrupt` or :exc:`SystemExit`, the task group still cancels the " -"remaining tasks and waits for them, but then the initial :exc:" -"`KeyboardInterrupt` or :exc:`SystemExit` is re-raised instead of :exc:" -"`ExceptionGroup` or :exc:`BaseExceptionGroup`." +"Two base exceptions are treated specially: If any task fails " +"with :exc:`KeyboardInterrupt` or :exc:`SystemExit`, the task group still " +"cancels the remaining tasks and waits for them, but then the " +"initial :exc:`KeyboardInterrupt` or :exc:`SystemExit` is re-raised instead " +"of :exc:`ExceptionGroup` or :exc:`BaseExceptionGroup`." msgstr "" -#: ../../library/asyncio-task.rst:383 +#: ../../library/asyncio-task.rst:396 msgid "" -"If the body of the ``async with`` statement exits with an exception (so :" -"meth:`~object.__aexit__` is called with an exception set), this is treated " -"the same as if one of the tasks failed: the remaining tasks are cancelled " -"and then waited for, and non-cancellation exceptions are grouped into an " -"exception group and raised. The exception passed into :meth:`~object." -"__aexit__`, unless it is :exc:`asyncio.CancelledError`, is also included in " -"the exception group. The same special case is made for :exc:" -"`KeyboardInterrupt` and :exc:`SystemExit` as in the previous paragraph." +"If the body of the ``async with`` statement exits with an exception " +"(so :meth:`~object.__aexit__` is called with an exception set), this is " +"treated the same as if one of the tasks failed: the remaining tasks are " +"cancelled and then waited for, and non-cancellation exceptions are grouped " +"into an exception group and raised. The exception passed " +"into :meth:`~object.__aexit__`, unless it is :exc:`asyncio.CancelledError`, " +"is also included in the exception group. The same special case is made " +"for :exc:`KeyboardInterrupt` and :exc:`SystemExit` as in the previous " +"paragraph." msgstr "" -#: ../../library/asyncio-task.rst:395 +#: ../../library/asyncio-task.rst:408 msgid "" "Task groups are careful not to mix up the internal cancellation used to " "\"wake up\" their :meth:`~object.__aexit__` with cancellation requests for " @@ -579,38 +607,39 @@ msgid "" "receive another cancellation and process its own exceptions." msgstr "" -#: ../../library/asyncio-task.rst:403 +#: ../../library/asyncio-task.rst:416 msgid "" "In the case where a task group is cancelled externally and also must raise " -"an :exc:`ExceptionGroup`, it will call the parent task's :meth:`~asyncio." -"Task.cancel` method. This ensures that a :exc:`asyncio.CancelledError` will " -"be raised at the next :keyword:`await`, so the cancellation is not lost." +"an :exc:`ExceptionGroup`, it will call the parent " +"task's :meth:`~asyncio.Task.cancel` method. This ensures that " +"a :exc:`asyncio.CancelledError` will be raised at the next :keyword:`await`, " +"so the cancellation is not lost." msgstr "" -#: ../../library/asyncio-task.rst:409 +#: ../../library/asyncio-task.rst:422 msgid "" -"Task groups preserve the cancellation count reported by :meth:`asyncio.Task." -"cancelling`." +"Task groups preserve the cancellation count reported " +"by :meth:`asyncio.Task.cancelling`." msgstr "" -#: ../../library/asyncio-task.rst:414 +#: ../../library/asyncio-task.rst:427 msgid "" "Improved handling of simultaneous internal and external cancellations and " "correct preservation of cancellation counts." msgstr "" -#: ../../library/asyncio-task.rst:418 +#: ../../library/asyncio-task.rst:431 msgid "Terminating a Task Group" msgstr "" -#: ../../library/asyncio-task.rst:420 +#: ../../library/asyncio-task.rst:433 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:424 +#: ../../library/asyncio-task.rst:437 msgid "" "import asyncio\n" "from asyncio import TaskGroup\n" @@ -643,49 +672,52 @@ msgid "" "asyncio.run(main())" msgstr "" -#: ../../library/asyncio-task.rst:456 +#: ../../library/asyncio-task.rst:469 msgid "Expected output:" msgstr "預期的輸出: ::" -#: ../../library/asyncio-task.rst:458 +#: ../../library/asyncio-task.rst:471 msgid "" "Task 1: start\n" "Task 2: start\n" "Task 1: done" msgstr "" +"Task 1: start\n" +"Task 2: start\n" +"Task 1: done" -#: ../../library/asyncio-task.rst:465 +#: ../../library/asyncio-task.rst:478 msgid "Sleeping" msgstr "" -#: ../../library/asyncio-task.rst:470 +#: ../../library/asyncio-task.rst:483 msgid "Block for *delay* seconds." msgstr "" -#: ../../library/asyncio-task.rst:472 +#: ../../library/asyncio-task.rst:485 msgid "" "If *result* is provided, it is returned to the caller when the coroutine " "completes." msgstr "" -#: ../../library/asyncio-task.rst:475 +#: ../../library/asyncio-task.rst:488 msgid "" "``sleep()`` always suspends the current task, allowing other tasks to run." msgstr "" -#: ../../library/asyncio-task.rst:478 +#: ../../library/asyncio-task.rst:491 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:484 +#: ../../library/asyncio-task.rst:497 msgid "" "Example of coroutine displaying the current date every second for 5 seconds::" msgstr "" -#: ../../library/asyncio-task.rst:487 +#: ../../library/asyncio-task.rst:500 msgid "" "import asyncio\n" "import datetime\n" @@ -715,40 +747,40 @@ msgstr "" "\n" "asyncio.run(display_date())" -#: ../../library/asyncio-task.rst:502 ../../library/asyncio-task.rst:600 -#: ../../library/asyncio-task.rst:699 ../../library/asyncio-task.rst:874 -#: ../../library/asyncio-task.rst:929 ../../library/asyncio-task.rst:986 +#: ../../library/asyncio-task.rst:515 ../../library/asyncio-task.rst:613 +#: ../../library/asyncio-task.rst:712 ../../library/asyncio-task.rst:887 +#: ../../library/asyncio-task.rst:942 ../../library/asyncio-task.rst:999 msgid "Removed the *loop* parameter." msgstr "移除 *loop* 參數。" -#: ../../library/asyncio-task.rst:505 +#: ../../library/asyncio-task.rst:518 msgid "Raises :exc:`ValueError` if *delay* is :data:`~math.nan`." -msgstr "" +msgstr "如果 *delay* 是 :data:`~math.nan`,則引發 :exc:`ValueError`。" -#: ../../library/asyncio-task.rst:510 +#: ../../library/asyncio-task.rst:523 msgid "Running Tasks Concurrently" msgstr "" -#: ../../library/asyncio-task.rst:514 +#: ../../library/asyncio-task.rst:527 msgid "" "Run :ref:`awaitable objects ` in the *aws* sequence " "*concurrently*." msgstr "" -#: ../../library/asyncio-task.rst:517 +#: ../../library/asyncio-task.rst:530 msgid "" "If any awaitable in *aws* is a coroutine, it is automatically scheduled as a " "Task." msgstr "" -#: ../../library/asyncio-task.rst:520 +#: ../../library/asyncio-task.rst:533 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:524 +#: ../../library/asyncio-task.rst:537 msgid "" "If *return_exceptions* is ``False`` (default), the first raised exception is " "immediately propagated to the task that awaits on ``gather()``. Other " @@ -756,19 +788,19 @@ msgid "" "run." msgstr "" -#: ../../library/asyncio-task.rst:529 +#: ../../library/asyncio-task.rst:542 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:532 +#: ../../library/asyncio-task.rst:545 msgid "" "If ``gather()`` is *cancelled*, all submitted awaitables (that have not " "completed yet) are also *cancelled*." msgstr "" -#: ../../library/asyncio-task.rst:535 +#: ../../library/asyncio-task.rst:548 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** " @@ -776,7 +808,7 @@ msgid "" "submitted Task/Future to cause other Tasks/Futures to be cancelled." msgstr "" -#: ../../library/asyncio-task.rst:542 +#: ../../library/asyncio-task.rst:555 msgid "" "A new alternative to create and run tasks concurrently and wait for their " "completion is :class:`asyncio.TaskGroup`. *TaskGroup* provides stronger " @@ -786,7 +818,7 @@ msgid "" "tasks)." msgstr "" -#: ../../library/asyncio-task.rst:553 +#: ../../library/asyncio-task.rst:566 msgid "" "import asyncio\n" "\n" @@ -825,7 +857,7 @@ msgid "" "# [2, 6, 24]" msgstr "" -#: ../../library/asyncio-task.rst:589 +#: ../../library/asyncio-task.rst:602 msgid "" "If *return_exceptions* is false, cancelling gather() after it has been " "marked done won't cancel any submitted awaitables. For instance, gather can " @@ -834,44 +866,44 @@ msgid "" "the awaitables) from gather won't cancel any other awaitables." msgstr "" -#: ../../library/asyncio-task.rst:596 +#: ../../library/asyncio-task.rst:609 msgid "" "If the *gather* itself is cancelled, the cancellation is propagated " "regardless of *return_exceptions*." msgstr "" -#: ../../library/asyncio-task.rst:603 +#: ../../library/asyncio-task.rst:616 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:612 +#: ../../library/asyncio-task.rst:625 msgid "Eager Task Factory" msgstr "" -#: ../../library/asyncio-task.rst:616 +#: ../../library/asyncio-task.rst:629 msgid "A task factory for eager task execution." msgstr "" -#: ../../library/asyncio-task.rst:618 +#: ../../library/asyncio-task.rst:631 msgid "" -"When using this factory (via :meth:`loop.set_task_factory(asyncio." -"eager_task_factory) `), coroutines begin execution " -"synchronously during :class:`Task` construction. Tasks are only scheduled on " -"the event loop if they block. This can be a performance improvement as the " -"overhead of loop scheduling is avoided for coroutines that complete " -"synchronously." +"When using this factory " +"(via :meth:`loop.set_task_factory(asyncio.eager_task_factory) " +"`), coroutines begin execution synchronously " +"during :class:`Task` construction. Tasks are only scheduled on the event " +"loop if they block. This can be a performance improvement as the overhead of " +"loop scheduling is avoided for coroutines that complete synchronously." msgstr "" -#: ../../library/asyncio-task.rst:624 +#: ../../library/asyncio-task.rst:637 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:629 +#: ../../library/asyncio-task.rst:642 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 " @@ -880,46 +912,46 @@ msgid "" "the application's task execution order is likely to change." msgstr "" -#: ../../library/asyncio-task.rst:640 +#: ../../library/asyncio-task.rst:653 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:644 +#: ../../library/asyncio-task.rst:657 msgid "" "*custom_task_constructor* must be a *callable* with the signature matching " -"the signature of :class:`Task.__init__ `. The callable must return a :" -"class:`asyncio.Task`-compatible object." +"the signature of :class:`Task.__init__ `. The callable must return " +"a :class:`asyncio.Task`-compatible object." msgstr "" -#: ../../library/asyncio-task.rst:648 +#: ../../library/asyncio-task.rst:661 msgid "" "This function returns a *callable* intended to be used as a task factory of " -"an event loop via :meth:`loop.set_task_factory(factory) `)." +"an event loop via :meth:`loop.set_task_factory(factory) " +"`)." msgstr "" -#: ../../library/asyncio-task.rst:655 +#: ../../library/asyncio-task.rst:668 msgid "Shielding From Cancellation" msgstr "" -#: ../../library/asyncio-task.rst:659 +#: ../../library/asyncio-task.rst:672 msgid "" -"Protect an :ref:`awaitable object ` from being :meth:" -"`cancelled `." +"Protect an :ref:`awaitable object ` from " +"being :meth:`cancelled `." msgstr "" -#: ../../library/asyncio-task.rst:662 ../../library/asyncio-task.rst:829 +#: ../../library/asyncio-task.rst:675 ../../library/asyncio-task.rst:842 msgid "If *aw* is a coroutine it is automatically scheduled as a Task." msgstr "" -#: ../../library/asyncio-task.rst:664 +#: ../../library/asyncio-task.rst:677 msgid "The statement::" msgstr "" -#: ../../library/asyncio-task.rst:666 +#: ../../library/asyncio-task.rst:679 msgid "" "task = asyncio.create_task(something())\n" "res = await shield(task)" @@ -927,37 +959,37 @@ msgstr "" "task = asyncio.create_task(something())\n" "res = await shield(task)" -#: ../../library/asyncio-task.rst:669 +#: ../../library/asyncio-task.rst:682 msgid "is equivalent to::" msgstr "" -#: ../../library/asyncio-task.rst:671 +#: ../../library/asyncio-task.rst:684 msgid "res = await something()" msgstr "res = await something()" -#: ../../library/asyncio-task.rst:673 +#: ../../library/asyncio-task.rst:686 msgid "" "*except* that if the coroutine containing it is cancelled, the Task running " "in ``something()`` is not cancelled. From the point of view of " "``something()``, the cancellation did not happen. Although its caller is " -"still cancelled, so the \"await\" expression still raises a :exc:" -"`CancelledError`." +"still cancelled, so the \"await\" expression still raises " +"a :exc:`CancelledError`." msgstr "" -#: ../../library/asyncio-task.rst:679 +#: ../../library/asyncio-task.rst:692 msgid "" "If ``something()`` is cancelled by other means (i.e. from within itself) " "that would also cancel ``shield()``." msgstr "" -#: ../../library/asyncio-task.rst:682 +#: ../../library/asyncio-task.rst:695 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:686 +#: ../../library/asyncio-task.rst:699 msgid "" "task = asyncio.create_task(something())\n" "try:\n" @@ -971,7 +1003,7 @@ msgstr "" "except CancelledError:\n" " res = None" -#: ../../library/asyncio-task.rst:694 +#: ../../library/asyncio-task.rst:707 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 " @@ -979,36 +1011,36 @@ msgid "" "any time, even before it's done." msgstr "" -#: ../../library/asyncio-task.rst:702 +#: ../../library/asyncio-task.rst:715 msgid "" "Deprecation warning is emitted if *aw* is not Future-like object and there " "is no running event loop." msgstr "" -#: ../../library/asyncio-task.rst:708 +#: ../../library/asyncio-task.rst:721 msgid "Timeouts" msgstr "" -#: ../../library/asyncio-task.rst:712 +#: ../../library/asyncio-task.rst:725 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:716 +#: ../../library/asyncio-task.rst:729 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:721 +#: ../../library/asyncio-task.rst:734 msgid "" -"In either case, the context manager can be rescheduled after creation using :" -"meth:`Timeout.reschedule`." +"In either case, the context manager can be rescheduled after creation " +"using :meth:`Timeout.reschedule`." msgstr "" -#: ../../library/asyncio-task.rst:726 +#: ../../library/asyncio-task.rst:739 msgid "" "async def main():\n" " async with asyncio.timeout(10):\n" @@ -1018,26 +1050,26 @@ msgstr "" " async with asyncio.timeout(10):\n" " await long_running_task()" -#: ../../library/asyncio-task.rst:730 +#: ../../library/asyncio-task.rst:743 msgid "" "If ``long_running_task`` takes more than 10 seconds to complete, the context " -"manager will cancel the current task and handle the resulting :exc:`asyncio." -"CancelledError` internally, transforming it into a :exc:`TimeoutError` which " -"can be caught and handled." +"manager will cancel the current task and handle the " +"resulting :exc:`asyncio.CancelledError` internally, transforming it into " +"a :exc:`TimeoutError` which can be caught and handled." msgstr "" -#: ../../library/asyncio-task.rst:737 +#: ../../library/asyncio-task.rst:750 msgid "" -"The :func:`asyncio.timeout` context manager is what transforms the :exc:" -"`asyncio.CancelledError` into a :exc:`TimeoutError`, which means the :exc:" -"`TimeoutError` can only be caught *outside* of the context manager." +"The :func:`asyncio.timeout` context manager is what transforms " +"the :exc:`asyncio.CancelledError` into a :exc:`TimeoutError`, which means " +"the :exc:`TimeoutError` can only be caught *outside* of the context manager." msgstr "" -#: ../../library/asyncio-task.rst:742 +#: ../../library/asyncio-task.rst:755 msgid "Example of catching :exc:`TimeoutError`::" msgstr "" -#: ../../library/asyncio-task.rst:744 +#: ../../library/asyncio-task.rst:757 msgid "" "async def main():\n" " try:\n" @@ -1049,48 +1081,48 @@ msgid "" " print(\"This statement will run regardless.\")" msgstr "" -#: ../../library/asyncio-task.rst:753 +#: ../../library/asyncio-task.rst:766 msgid "" "The context manager produced by :func:`asyncio.timeout` can be rescheduled " "to a different deadline and inspected." msgstr "" -#: ../../library/asyncio-task.rst:758 +#: ../../library/asyncio-task.rst:771 msgid "" "An :ref:`asynchronous context manager ` for " "cancelling overdue coroutines." msgstr "" -#: ../../library/asyncio-task.rst:761 +#: ../../library/asyncio-task.rst:774 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:764 +#: ../../library/asyncio-task.rst:777 msgid "If ``when`` is ``None``, the timeout will never trigger." msgstr "" -#: ../../library/asyncio-task.rst:765 +#: ../../library/asyncio-task.rst:778 msgid "" "If ``when < loop.time()``, the timeout will trigger on the next iteration of " "the event loop." msgstr "" -#: ../../library/asyncio-task.rst:770 +#: ../../library/asyncio-task.rst:783 msgid "" "Return the current deadline, or ``None`` if the current deadline is not set." msgstr "" -#: ../../library/asyncio-task.rst:775 +#: ../../library/asyncio-task.rst:788 msgid "Reschedule the timeout." msgstr "" -#: ../../library/asyncio-task.rst:779 +#: ../../library/asyncio-task.rst:792 msgid "Return whether the context manager has exceeded its deadline (expired)." msgstr "" -#: ../../library/asyncio-task.rst:784 +#: ../../library/asyncio-task.rst:797 msgid "" "async def main():\n" " try:\n" @@ -1108,17 +1140,17 @@ msgid "" " print(\"Looks like we haven't finished on time.\")" msgstr "" -#: ../../library/asyncio-task.rst:799 +#: ../../library/asyncio-task.rst:812 msgid "Timeout context managers can be safely nested." msgstr "" -#: ../../library/asyncio-task.rst:805 +#: ../../library/asyncio-task.rst:818 msgid "" "Similar to :func:`asyncio.timeout`, except *when* is the absolute time to " "stop waiting, or ``None``." msgstr "" -#: ../../library/asyncio-task.rst:810 +#: ../../library/asyncio-task.rst:823 msgid "" "async def main():\n" " loop = get_running_loop()\n" @@ -1132,41 +1164,41 @@ msgid "" " print(\"This statement will run regardless.\")" msgstr "" -#: ../../library/asyncio-task.rst:826 +#: ../../library/asyncio-task.rst:839 msgid "" "Wait for the *aw* :ref:`awaitable ` to complete with a " "timeout." msgstr "" -#: ../../library/asyncio-task.rst:831 +#: ../../library/asyncio-task.rst:844 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:835 +#: ../../library/asyncio-task.rst:848 msgid "" "If a timeout occurs, it cancels the task and raises :exc:`TimeoutError`." msgstr "" -#: ../../library/asyncio-task.rst:838 +#: ../../library/asyncio-task.rst:851 msgid "" -"To avoid the task :meth:`cancellation `, wrap it in :func:" -"`shield`." +"To avoid the task :meth:`cancellation `, wrap it " +"in :func:`shield`." msgstr "" -#: ../../library/asyncio-task.rst:841 +#: ../../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:845 +#: ../../library/asyncio-task.rst:858 msgid "If the wait is cancelled, the future *aw* is also cancelled." msgstr "" -#: ../../library/asyncio-task.rst:851 +#: ../../library/asyncio-task.rst:864 msgid "" "async def eternity():\n" " # Sleep for one hour\n" @@ -1187,116 +1219,116 @@ msgid "" "# timeout!" msgstr "" -#: ../../library/asyncio-task.rst:869 +#: ../../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:877 +#: ../../library/asyncio-task.rst:890 msgid "Raises :exc:`TimeoutError` instead of :exc:`asyncio.TimeoutError`." msgstr "引發 :exc:`TimeoutError` 而不是 :exc:`asyncio.TimeoutError`。" -#: ../../library/asyncio-task.rst:882 +#: ../../library/asyncio-task.rst:895 msgid "Waiting Primitives" msgstr "" -#: ../../library/asyncio-task.rst:887 +#: ../../library/asyncio-task.rst:900 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:891 +#: ../../library/asyncio-task.rst:904 msgid "The *aws* iterable must not be empty." msgstr "" -#: ../../library/asyncio-task.rst:893 +#: ../../library/asyncio-task.rst:906 msgid "Returns two sets of Tasks/Futures: ``(done, pending)``." msgstr "" -#: ../../library/asyncio-task.rst:895 +#: ../../library/asyncio-task.rst:908 msgid "Usage::" msgstr "用法: ::" -#: ../../library/asyncio-task.rst:897 +#: ../../library/asyncio-task.rst:910 msgid "done, pending = await asyncio.wait(aws)" msgstr "done, pending = await asyncio.wait(aws)" -#: ../../library/asyncio-task.rst:899 +#: ../../library/asyncio-task.rst:912 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:902 +#: ../../library/asyncio-task.rst:915 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:906 +#: ../../library/asyncio-task.rst:919 msgid "" "*return_when* indicates when this function should return. It must be one of " "the following constants:" msgstr "" -#: ../../library/asyncio-task.rst:912 +#: ../../library/asyncio-task.rst:925 msgid "Constant" msgstr "常數" -#: ../../library/asyncio-task.rst:913 +#: ../../library/asyncio-task.rst:926 msgid "Description" msgstr "描述" -#: ../../library/asyncio-task.rst:916 +#: ../../library/asyncio-task.rst:929 msgid "The function will return when any future finishes or is cancelled." msgstr "" -#: ../../library/asyncio-task.rst:919 +#: ../../library/asyncio-task.rst:932 msgid "" "The function will return when any future finishes by raising an exception. " -"If no future raises an exception then it is equivalent to :const:" -"`ALL_COMPLETED`." +"If no future raises an exception then it is equivalent " +"to :const:`ALL_COMPLETED`." msgstr "" -#: ../../library/asyncio-task.rst:924 +#: ../../library/asyncio-task.rst:937 msgid "The function will return when all futures finish or are cancelled." msgstr "" -#: ../../library/asyncio-task.rst:926 +#: ../../library/asyncio-task.rst:939 msgid "" "Unlike :func:`~asyncio.wait_for`, ``wait()`` does not cancel the futures " "when a timeout occurs." msgstr "" -#: ../../library/asyncio-task.rst:932 +#: ../../library/asyncio-task.rst:945 msgid "Passing coroutine objects to ``wait()`` directly is forbidden." msgstr "" -#: ../../library/asyncio-task.rst:935 ../../library/asyncio-task.rst:993 +#: ../../library/asyncio-task.rst:948 ../../library/asyncio-task.rst:1006 msgid "Added support for generators yielding tasks." msgstr "" -#: ../../library/asyncio-task.rst:941 +#: ../../library/asyncio-task.rst:954 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:945 +#: ../../library/asyncio-task.rst:958 msgid "" -"The object returned by ``as_completed()`` can be iterated as an :term:" -"`asynchronous iterator` or a plain :term:`iterator`. When asynchronous " -"iteration is used, the originally-supplied awaitables are yielded if they " -"are tasks or futures. This makes it easy to correlate previously-scheduled " -"tasks with their results. Example::" +"The object returned by ``as_completed()`` can be iterated as " +"an :term:`asynchronous iterator` or a plain :term:`iterator`. When " +"asynchronous iteration is used, the originally-supplied awaitables are " +"yielded if they are tasks or futures. This makes it easy to correlate " +"previously-scheduled tasks with their results. Example::" msgstr "" -#: ../../library/asyncio-task.rst:951 +#: ../../library/asyncio-task.rst:964 msgid "" "ipv4_connect = create_task(open_connection(\"127.0.0.1\", 80))\n" "ipv6_connect = create_task(open_connection(\"::1\", 80))\n" @@ -1313,20 +1345,20 @@ msgid "" " print(\"IPv4 connection established.\")" msgstr "" -#: ../../library/asyncio-task.rst:965 +#: ../../library/asyncio-task.rst:978 msgid "" "During asynchronous iteration, implicitly-created tasks will be yielded for " "supplied awaitables that aren't tasks or futures." msgstr "" -#: ../../library/asyncio-task.rst:968 +#: ../../library/asyncio-task.rst:981 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:972 +#: ../../library/asyncio-task.rst:985 msgid "" "ipv4_connect = create_task(open_connection(\"127.0.0.1\", 80))\n" "ipv6_connect = create_task(open_connection(\"::1\", 80))\n" @@ -1339,34 +1371,34 @@ msgid "" " reader, writer = await next_connect" msgstr "" -#: ../../library/asyncio-task.rst:982 +#: ../../library/asyncio-task.rst:995 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:989 +#: ../../library/asyncio-task.rst:1002 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:996 +#: ../../library/asyncio-task.rst:1009 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:1002 +#: ../../library/asyncio-task.rst:1015 msgid "Running in Threads" msgstr "" -#: ../../library/asyncio-task.rst:1007 +#: ../../library/asyncio-task.rst:1020 msgid "Asynchronously run function *func* in a separate thread." msgstr "" -#: ../../library/asyncio-task.rst:1009 +#: ../../library/asyncio-task.rst:1022 msgid "" "Any \\*args and \\*\\*kwargs supplied for this function are directly passed " "to *func*. Also, the current :class:`contextvars.Context` is propagated, " @@ -1374,19 +1406,19 @@ msgid "" "separate thread." msgstr "" -#: ../../library/asyncio-task.rst:1014 +#: ../../library/asyncio-task.rst:1027 msgid "" "Return a coroutine that can be awaited to get the eventual result of *func*." msgstr "" -#: ../../library/asyncio-task.rst:1016 +#: ../../library/asyncio-task.rst:1029 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:1020 +#: ../../library/asyncio-task.rst:1033 msgid "" "def blocking_io():\n" " print(f\"start blocking_io at {time.strftime('%X')}\")\n" @@ -1415,7 +1447,7 @@ msgid "" "# finished main at 19:50:54" msgstr "" -#: ../../library/asyncio-task.rst:1046 +#: ../../library/asyncio-task.rst:1059 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. " @@ -1423,7 +1455,7 @@ msgid "" "thread without blocking the event loop." msgstr "" -#: ../../library/asyncio-task.rst:1053 +#: ../../library/asyncio-task.rst:1066 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 " @@ -1431,45 +1463,97 @@ msgid "" "``asyncio.to_thread()`` can also be used for CPU-bound functions." msgstr "" -#: ../../library/asyncio-task.rst:1062 +#: ../../library/asyncio-task.rst:1075 msgid "Scheduling From Other Threads" msgstr "" -#: ../../library/asyncio-task.rst:1066 +#: ../../library/asyncio-task.rst:1079 msgid "Submit a coroutine to the given event loop. Thread-safe." msgstr "" -#: ../../library/asyncio-task.rst:1068 +#: ../../library/asyncio-task.rst:1081 msgid "" "Return a :class:`concurrent.futures.Future` to wait for the result from " "another OS thread." msgstr "" -#: ../../library/asyncio-task.rst:1071 +#: ../../library/asyncio-task.rst:1084 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:1074 +#: ../../library/asyncio-task.rst:1087 msgid "" -"# Create a coroutine\n" -"coro = asyncio.sleep(1, result=3)\n" +"def in_thread(loop: asyncio.AbstractEventLoop) -> None:\n" +" # Run some blocking IO\n" +" pathlib.Path(\"example.txt\").write_text(\"hello world\", " +"encoding=\"utf8\")\n" "\n" -"# Submit the coroutine to a given loop\n" -"future = asyncio.run_coroutine_threadsafe(coro, loop)\n" +" # Create a coroutine\n" +" coro = asyncio.sleep(1, result=3)\n" "\n" -"# Wait for the result with an optional timeout argument\n" -"assert future.result(timeout) == 3" +" # Submit the coroutine to a given loop\n" +" future = asyncio.run_coroutine_threadsafe(coro, loop)\n" +"\n" +" # Wait for the result with an optional timeout argument\n" +" assert future.result(timeout=2) == 3\n" +"\n" +"async def amain() -> None:\n" +" # Get the running loop\n" +" loop = asyncio.get_running_loop()\n" +"\n" +" # Run something in a thread\n" +" await asyncio.to_thread(in_thread, loop)" +msgstr "" + +#: ../../library/asyncio-task.rst:1107 +msgid "It's also possible to run the other way around. Example::" msgstr "" -#: ../../library/asyncio-task.rst:1083 +#: ../../library/asyncio-task.rst:1109 +msgid "" +"@contextlib.contextmanager\n" +"def loop_in_thread() -> Generator[asyncio.AbstractEventLoop]:\n" +" loop_fut = concurrent.futures.Future[asyncio.AbstractEventLoop]()\n" +" stop_event = asyncio.Event()\n" +"\n" +" async def main() -> None:\n" +" loop_fut.set_result(asyncio.get_running_loop())\n" +" await stop_event.wait()\n" +"\n" +" with concurrent.futures.ThreadPoolExecutor(1) as tpe:\n" +" complete_fut = tpe.submit(asyncio.run, main())\n" +" for fut in concurrent.futures.as_completed((loop_fut, " +"complete_fut)):\n" +" if fut is loop_fut:\n" +" loop = loop_fut.result()\n" +" try:\n" +" yield loop\n" +" finally:\n" +" loop.call_soon_threadsafe(stop_event.set)\n" +" else:\n" +" fut.result()\n" +"\n" +"# Create a loop in another thread\n" +"with loop_in_thread() as loop:\n" +" # Create a coroutine\n" +" coro = asyncio.sleep(1, result=3)\n" +"\n" +" # Submit the coroutine to a given loop\n" +" future = asyncio.run_coroutine_threadsafe(coro, loop)\n" +"\n" +" # Wait for the result with an optional timeout argument\n" +" assert future.result(timeout=2) == 3" +msgstr "" + +#: ../../library/asyncio-task.rst:1141 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:1087 +#: ../../library/asyncio-task.rst:1145 msgid "" "try:\n" " result = future.result(timeout)\n" @@ -1482,59 +1566,59 @@ msgid "" " print(f'The coroutine returned: {result!r}')" msgstr "" -#: ../../library/asyncio-task.rst:1097 +#: ../../library/asyncio-task.rst:1155 msgid "" "See the :ref:`concurrency and multithreading ` " "section of the documentation." msgstr "" -#: ../../library/asyncio-task.rst:1100 +#: ../../library/asyncio-task.rst:1158 msgid "" "Unlike other asyncio functions this function requires the *loop* argument to " "be passed explicitly." msgstr "" -#: ../../library/asyncio-task.rst:1107 +#: ../../library/asyncio-task.rst:1165 msgid "Introspection" msgstr "" -#: ../../library/asyncio-task.rst:1112 +#: ../../library/asyncio-task.rst:1170 msgid "" "Return the currently running :class:`Task` instance, or ``None`` if no task " "is running." msgstr "" -#: ../../library/asyncio-task.rst:1115 +#: ../../library/asyncio-task.rst:1173 msgid "" "If *loop* is ``None`` :func:`get_running_loop` is used to get the current " "loop." msgstr "" -#: ../../library/asyncio-task.rst:1123 +#: ../../library/asyncio-task.rst:1181 msgid "Return a set of not yet finished :class:`Task` objects run by the loop." msgstr "" -#: ../../library/asyncio-task.rst:1126 +#: ../../library/asyncio-task.rst:1184 msgid "" "If *loop* is ``None``, :func:`get_running_loop` is used for getting current " "loop." msgstr "" -#: ../../library/asyncio-task.rst:1134 +#: ../../library/asyncio-task.rst:1192 msgid "Return ``True`` if *obj* is a coroutine object." msgstr "" -#: ../../library/asyncio-task.rst:1141 +#: ../../library/asyncio-task.rst:1199 msgid "Task Object" msgstr "Task 物件" -#: ../../library/asyncio-task.rst:1145 +#: ../../library/asyncio-task.rst:1203 msgid "" "A :class:`Future-like ` object that runs a Python :ref:`coroutine " "`. Not thread-safe." msgstr "" -#: ../../library/asyncio-task.rst:1148 +#: ../../library/asyncio-task.rst:1206 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 " @@ -1542,21 +1626,21 @@ msgid "" "wrapped coroutine resumes." msgstr "" -#: ../../library/asyncio-task.rst:1154 +#: ../../library/asyncio-task.rst:1212 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:1159 +#: ../../library/asyncio-task.rst:1217 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:1164 +#: ../../library/asyncio-task.rst:1222 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 " @@ -1564,28 +1648,28 @@ msgid "" "cancellation, the Future object will be cancelled." msgstr "" -#: ../../library/asyncio-task.rst:1169 +#: ../../library/asyncio-task.rst:1227 msgid "" ":meth:`cancelled` can be used to check if the Task was cancelled. The method " -"returns ``True`` if the wrapped coroutine did not suppress the :exc:" -"`CancelledError` exception and was actually cancelled." +"returns ``True`` if the wrapped coroutine did not suppress " +"the :exc:`CancelledError` exception and was actually cancelled." msgstr "" -#: ../../library/asyncio-task.rst:1174 +#: ../../library/asyncio-task.rst:1232 msgid "" -":class:`asyncio.Task` inherits from :class:`Future` all of its APIs except :" -"meth:`Future.set_result` and :meth:`Future.set_exception`." +":class:`asyncio.Task` inherits from :class:`Future` all of its APIs " +"except :meth:`Future.set_result` and :meth:`Future.set_exception`." msgstr "" -#: ../../library/asyncio-task.rst:1178 +#: ../../library/asyncio-task.rst:1236 msgid "" -"An optional keyword-only *context* argument allows specifying a custom :" -"class:`contextvars.Context` for the *coro* to run in. If no *context* is " -"provided, the Task copies the current context and later runs its coroutine " -"in the copied context." +"An optional keyword-only *context* argument allows specifying a " +"custom :class:`contextvars.Context` for the *coro* to run in. If no " +"*context* is provided, the Task copies the current context and later runs " +"its coroutine in the copied context." msgstr "" -#: ../../library/asyncio-task.rst:1183 +#: ../../library/asyncio-task.rst:1241 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 " @@ -1595,96 +1679,96 @@ msgid "" "eagerly and will skip scheduling to the event loop." msgstr "" -#: ../../library/asyncio-task.rst:1190 +#: ../../library/asyncio-task.rst:1248 msgid "Added support for the :mod:`contextvars` module." msgstr "新增對 :mod:`contextvars` 模組的支援。" -#: ../../library/asyncio-task.rst:1196 +#: ../../library/asyncio-task.rst:1254 msgid "" "Deprecation warning is emitted if *loop* is not specified and there is no " "running event loop." msgstr "" -#: ../../library/asyncio-task.rst:1203 +#: ../../library/asyncio-task.rst:1261 msgid "Added the *eager_start* parameter." msgstr "新增 *eager_start* 參數。" -#: ../../library/asyncio-task.rst:1208 +#: ../../library/asyncio-task.rst:1266 msgid "Return ``True`` if the Task is *done*." msgstr "" -#: ../../library/asyncio-task.rst:1210 +#: ../../library/asyncio-task.rst:1268 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:1215 +#: ../../library/asyncio-task.rst:1273 msgid "Return the result of the Task." msgstr "" -#: ../../library/asyncio-task.rst:1217 +#: ../../library/asyncio-task.rst:1275 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:1221 ../../library/asyncio-task.rst:1235 +#: ../../library/asyncio-task.rst:1279 ../../library/asyncio-task.rst:1293 msgid "" "If the Task has been *cancelled*, this method raises a :exc:`CancelledError` " "exception." msgstr "" -#: ../../library/asyncio-task.rst:1224 +#: ../../library/asyncio-task.rst:1282 msgid "" -"If the Task's result isn't yet available, this method raises an :exc:" -"`InvalidStateError` exception." +"If the Task's result isn't yet available, this method raises " +"an :exc:`InvalidStateError` exception." msgstr "" -#: ../../library/asyncio-task.rst:1229 +#: ../../library/asyncio-task.rst:1287 msgid "Return the exception of the Task." msgstr "" -#: ../../library/asyncio-task.rst:1231 +#: ../../library/asyncio-task.rst:1289 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:1238 +#: ../../library/asyncio-task.rst:1296 msgid "" "If the Task isn't *done* yet, this method raises an :exc:`InvalidStateError` " "exception." msgstr "" -#: ../../library/asyncio-task.rst:1243 +#: ../../library/asyncio-task.rst:1301 msgid "Add a callback to be run when the Task is *done*." msgstr "" -#: ../../library/asyncio-task.rst:1245 ../../library/asyncio-task.rst:1254 +#: ../../library/asyncio-task.rst:1303 ../../library/asyncio-task.rst:1312 msgid "This method should only be used in low-level callback-based code." msgstr "" -#: ../../library/asyncio-task.rst:1247 +#: ../../library/asyncio-task.rst:1305 msgid "" "See the documentation of :meth:`Future.add_done_callback` for more details." msgstr "" -#: ../../library/asyncio-task.rst:1252 +#: ../../library/asyncio-task.rst:1310 msgid "Remove *callback* from the callbacks list." msgstr "" -#: ../../library/asyncio-task.rst:1256 +#: ../../library/asyncio-task.rst:1314 msgid "" "See the documentation of :meth:`Future.remove_done_callback` for more " "details." msgstr "" -#: ../../library/asyncio-task.rst:1261 +#: ../../library/asyncio-task.rst:1319 msgid "Return the list of stack frames for this Task." msgstr "" -#: ../../library/asyncio-task.rst:1263 +#: ../../library/asyncio-task.rst:1321 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, " @@ -1692,15 +1776,15 @@ msgid "" "this returns the list of traceback frames." msgstr "" -#: ../../library/asyncio-task.rst:1269 +#: ../../library/asyncio-task.rst:1327 msgid "The frames are always ordered from oldest to newest." msgstr "" -#: ../../library/asyncio-task.rst:1271 +#: ../../library/asyncio-task.rst:1329 msgid "Only one stack frame is returned for a suspended coroutine." msgstr "" -#: ../../library/asyncio-task.rst:1273 +#: ../../library/asyncio-task.rst:1331 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 " @@ -1709,113 +1793,113 @@ msgid "" "are returned. (This matches the behavior of the traceback module.)" msgstr "" -#: ../../library/asyncio-task.rst:1282 +#: ../../library/asyncio-task.rst:1340 msgid "Print the stack or traceback for this Task." msgstr "" -#: ../../library/asyncio-task.rst:1284 +#: ../../library/asyncio-task.rst:1342 msgid "" "This produces output similar to that of the traceback module for the frames " "retrieved by :meth:`get_stack`." msgstr "" -#: ../../library/asyncio-task.rst:1287 +#: ../../library/asyncio-task.rst:1345 msgid "The *limit* argument is passed to :meth:`get_stack` directly." msgstr "" -#: ../../library/asyncio-task.rst:1289 +#: ../../library/asyncio-task.rst:1347 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:1294 +#: ../../library/asyncio-task.rst:1352 msgid "Return the coroutine object wrapped by the :class:`Task`." msgstr "" -#: ../../library/asyncio-task.rst:1298 +#: ../../library/asyncio-task.rst:1356 msgid "" "This will return ``None`` for Tasks which have already completed eagerly. " "See the :ref:`Eager Task Factory `." msgstr "" -#: ../../library/asyncio-task.rst:1305 +#: ../../library/asyncio-task.rst:1363 msgid "Newly added eager task execution means result may be ``None``." msgstr "" -#: ../../library/asyncio-task.rst:1309 +#: ../../library/asyncio-task.rst:1367 msgid "" "Return the :class:`contextvars.Context` object associated with the task." msgstr "" -#: ../../library/asyncio-task.rst:1316 +#: ../../library/asyncio-task.rst:1374 msgid "Return the name of the Task." msgstr "" -#: ../../library/asyncio-task.rst:1318 +#: ../../library/asyncio-task.rst:1376 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:1326 +#: ../../library/asyncio-task.rst:1384 msgid "Set the name of the Task." msgstr "" -#: ../../library/asyncio-task.rst:1328 +#: ../../library/asyncio-task.rst:1386 msgid "" "The *value* argument can be any object, which is then converted to a string." msgstr "" -#: ../../library/asyncio-task.rst:1331 +#: ../../library/asyncio-task.rst:1389 msgid "" -"In the default Task implementation, the name will be visible in the :func:" -"`repr` output of a task object." +"In the default Task implementation, the name will be visible in " +"the :func:`repr` output of a task object." msgstr "" -#: ../../library/asyncio-task.rst:1338 +#: ../../library/asyncio-task.rst:1396 msgid "Request the Task to be cancelled." msgstr "" -#: ../../library/asyncio-task.rst:1340 +#: ../../library/asyncio-task.rst:1398 msgid "" "If the Task is already *done* or *cancelled*, return ``False``, otherwise, " "return ``True``." msgstr "" -#: ../../library/asyncio-task.rst:1343 +#: ../../library/asyncio-task.rst:1401 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:1346 +#: ../../library/asyncio-task.rst:1404 msgid "" "The coroutine then has a chance to clean up or even deny the request by " "suppressing the exception with a :keyword:`try` ... ... ``except " -"CancelledError`` ... :keyword:`finally` block. Therefore, unlike :meth:" -"`Future.cancel`, :meth:`Task.cancel` does not guarantee that the Task will " -"be cancelled, although suppressing cancellation completely is not common and " -"is actively discouraged. Should the coroutine nevertheless decide to " -"suppress the cancellation, it needs to call :meth:`Task.uncancel` in " -"addition to catching the exception." +"CancelledError`` ... :keyword:`finally` block. Therefore, " +"unlike :meth:`Future.cancel`, :meth:`Task.cancel` does not guarantee that " +"the Task will be cancelled, although suppressing cancellation completely is " +"not common and is actively discouraged. Should the coroutine nevertheless " +"decide to suppress the cancellation, it needs to call :meth:`Task.uncancel` " +"in addition to catching the exception." msgstr "" -#: ../../library/asyncio-task.rst:1356 +#: ../../library/asyncio-task.rst:1414 msgid "Added the *msg* parameter." msgstr "新增 *msg* 參數。" -#: ../../library/asyncio-task.rst:1359 +#: ../../library/asyncio-task.rst:1417 msgid "The ``msg`` parameter is propagated from cancelled task to its awaiter." msgstr "" -#: ../../library/asyncio-task.rst:1364 +#: ../../library/asyncio-task.rst:1422 msgid "" "The following example illustrates how coroutines can intercept the " "cancellation request::" msgstr "" -#: ../../library/asyncio-task.rst:1367 +#: ../../library/asyncio-task.rst:1425 msgid "" "async def cancel_me():\n" " print('cancel_me(): before sleep')\n" @@ -1852,41 +1936,41 @@ msgid "" "# main(): cancel_me is cancelled now" msgstr "" -#: ../../library/asyncio-task.rst:1403 +#: ../../library/asyncio-task.rst:1461 msgid "Return ``True`` if the Task is *cancelled*." msgstr "" -#: ../../library/asyncio-task.rst:1405 +#: ../../library/asyncio-task.rst:1463 msgid "" -"The Task is *cancelled* when the cancellation was requested with :meth:" -"`cancel` and the wrapped coroutine propagated the :exc:`CancelledError` " -"exception thrown into it." +"The Task is *cancelled* when the cancellation was requested " +"with :meth:`cancel` and the wrapped coroutine propagated " +"the :exc:`CancelledError` exception thrown into it." msgstr "" -#: ../../library/asyncio-task.rst:1411 +#: ../../library/asyncio-task.rst:1469 msgid "Decrement the count of cancellation requests to this Task." msgstr "" -#: ../../library/asyncio-task.rst:1413 +#: ../../library/asyncio-task.rst:1471 msgid "Returns the remaining number of cancellation requests." msgstr "" -#: ../../library/asyncio-task.rst:1415 +#: ../../library/asyncio-task.rst:1473 msgid "" -"Note that once execution of a cancelled task completed, further calls to :" -"meth:`uncancel` are ineffective." +"Note that once execution of a cancelled task completed, further calls " +"to :meth:`uncancel` are ineffective." msgstr "" -#: ../../library/asyncio-task.rst:1420 +#: ../../library/asyncio-task.rst:1478 msgid "" "This method is used by asyncio's internals and isn't expected to be used by " "end-user code. In particular, if a Task gets successfully uncancelled, this " -"allows for elements of structured concurrency like :ref:`taskgroups` and :" -"func:`asyncio.timeout` to continue running, isolating cancellation to the " -"respective structured block. For example::" +"allows for elements of structured concurrency like :ref:`taskgroups` " +"and :func:`asyncio.timeout` to continue running, isolating cancellation to " +"the respective structured block. For example::" msgstr "" -#: ../../library/asyncio-task.rst:1427 +#: ../../library/asyncio-task.rst:1485 msgid "" "async def make_request_with_timeout():\n" " try:\n" @@ -1900,42 +1984,42 @@ msgid "" " await unrelated_code()" msgstr "" -#: ../../library/asyncio-task.rst:1438 +#: ../../library/asyncio-task.rst:1496 msgid "" "While the block with ``make_request()`` and ``make_another_request()`` might " "get cancelled due to the timeout, ``unrelated_code()`` should continue " -"running even in case of the timeout. This is implemented with :meth:" -"`uncancel`. :class:`TaskGroup` context managers use :func:`uncancel` in a " -"similar fashion." +"running even in case of the timeout. This is implemented " +"with :meth:`uncancel`. :class:`TaskGroup` context managers " +"use :func:`uncancel` in a similar fashion." msgstr "" -#: ../../library/asyncio-task.rst:1444 +#: ../../library/asyncio-task.rst:1502 msgid "" -"If end-user code is, for some reason, suppressing cancellation by catching :" -"exc:`CancelledError`, it needs to call this method to remove the " +"If end-user code is, for some reason, suppressing cancellation by " +"catching :exc:`CancelledError`, it needs to call this method to remove the " "cancellation state." msgstr "" -#: ../../library/asyncio-task.rst:1448 +#: ../../library/asyncio-task.rst:1506 msgid "" "When this method decrements the cancellation count to zero, the method " -"checks if a previous :meth:`cancel` call had arranged for :exc:" -"`CancelledError` to be thrown into the task. If it hasn't been thrown yet, " -"that arrangement will be rescinded (by resetting the internal " +"checks if a previous :meth:`cancel` call had arranged " +"for :exc:`CancelledError` to be thrown into the task. If it hasn't been " +"thrown yet, that arrangement will be rescinded (by resetting the internal " "``_must_cancel`` flag)." msgstr "" -#: ../../library/asyncio-task.rst:1454 +#: ../../library/asyncio-task.rst:1512 msgid "Changed to rescind pending cancellation requests upon reaching zero." msgstr "" -#: ../../library/asyncio-task.rst:1459 +#: ../../library/asyncio-task.rst:1517 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:1463 +#: ../../library/asyncio-task.rst:1521 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 " @@ -1944,7 +2028,7 @@ msgid "" "to zero." msgstr "" -#: ../../library/asyncio-task.rst:1469 +#: ../../library/asyncio-task.rst:1527 msgid "" "This method is used by asyncio's internals and isn't expected to be used by " "end-user code. See :meth:`uncancel` for more details." diff --git a/library/asyncio.po b/library/asyncio.po index 980b7572151..79c9d8f5e17 100644 --- a/library/asyncio.po +++ b/library/asyncio.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -8,9 +8,9 @@ # Weilin Du, 2025 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-08-10 00:19+0000\n" +"POT-Creation-Date: 2025-12-01 00:17+0000\n" "PO-Revision-Date: 2025-07-06 17:13+0800\n" "Last-Translator: Weilin Du\n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -21,15 +21,15 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../library/asyncio.rst:96 +#: ../../library/asyncio.rst:100 msgid "High-level APIs" msgstr "高階 API" -#: ../../library/asyncio.rst:108 +#: ../../library/asyncio.rst:113 msgid "Low-level APIs" msgstr "低階 API" -#: ../../library/asyncio.rst:119 +#: ../../library/asyncio.rst:124 msgid "Guides and Tutorials" msgstr "指南與教學" @@ -37,7 +37,7 @@ msgstr "指南與教學" msgid ":mod:`!asyncio` --- Asynchronous I/O" msgstr ":mod:`!asyncio` --- 非同步 I/O" -#: ../../library/asyncio.rst:-1 +#: ../../library/asyncio.rst:9 msgid "Hello World!" msgstr "Hello World!" @@ -200,15 +200,22 @@ msgstr "" #: ../../library/asyncio.rst:82 msgid "" +"This REPL provides limited compatibility with :envvar:`PYTHON_BASIC_REPL`. " +"It is recommended that the default REPL is used for full functionality and " +"the latest features." +msgstr "" + +#: ../../library/asyncio.rst:86 +msgid "" "Raises an :ref:`auditing event ` ``cpython.run_stdin`` with no " "arguments." msgstr "產生一個 :ref:`稽核事件 ` ``cpython.run_stdin`` 且沒有引數。" -#: ../../library/asyncio.rst:84 +#: ../../library/asyncio.rst:88 msgid "(also 3.11.10, 3.10.15, 3.9.20, and 3.8.20) Emits audit events." msgstr "(也包括 3.11.10、3.10.15、3.9.20 及 3.8.20)發出稽核事件。" -#: ../../library/asyncio.rst:87 +#: ../../library/asyncio.rst:91 msgid "" "Uses PyREPL if possible, in which case :envvar:`PYTHONSTARTUP` is also " "executed. Emits audit events." @@ -216,10 +223,10 @@ msgstr "" "可能的話使用 PyREPL,在這種情況下 :envvar:`PYTHONSTARTUP` 也會被執行。發出稽" "核事件。" -#: ../../library/asyncio.rst:95 +#: ../../library/asyncio.rst:99 msgid "Reference" msgstr "參閱" -#: ../../library/asyncio.rst:128 +#: ../../library/asyncio.rst:133 msgid "The source code for asyncio can be found in :source:`Lib/asyncio/`." msgstr "asyncio 的原始碼可以在 :source:`Lib/asyncio/` 中找到。" diff --git a/library/asyncore.po b/library/asyncore.po index 98419d8bc42..39efa7aab0b 100644 --- a/library/asyncore.po +++ b/library/asyncore.po @@ -1,10 +1,10 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # #, fuzzy msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-11-18 00:15+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" diff --git a/library/atexit.po b/library/atexit.po index d671623db51..2ad3f8cf563 100644 --- a/library/atexit.po +++ b/library/atexit.po @@ -1,11 +1,11 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Matt Wang , 2024 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-03 11:11+0800\n" "PO-Revision-Date: 2016-01-31 07:13+0000\n" @@ -214,6 +214,14 @@ msgid "" "# or:\n" "atexit.register(goodbye, adjective='nice', name='Donny')" msgstr "" +"def goodbye(name, adjective):\n" +" print('Goodbye %s, it was %s to meet you.' % (name, adjective))\n" +"\n" +"import atexit\n" +"\n" +"atexit.register(goodbye, 'Donny', 'nice')\n" +"# 或是:\n" +"atexit.register(goodbye, adjective='nice', name='Donny')" #: ../../library/atexit.rst:119 msgid "Usage as a :term:`decorator`::" @@ -227,6 +235,11 @@ msgid "" "def goodbye():\n" " print('You are now leaving the Python sector.')" msgstr "" +"import atexit\n" +"\n" +"@atexit.register\n" +"def goodbye():\n" +" print('You are now leaving the Python sector.')" #: ../../library/atexit.rst:127 msgid "This only works with functions that can be called without arguments." diff --git a/library/audioop.po b/library/audioop.po index 7e17882da92..9fd2a98adb8 100644 --- a/library/audioop.po +++ b/library/audioop.po @@ -1,10 +1,10 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # #, fuzzy msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-11-18 00:15+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" diff --git a/library/audit_events.po b/library/audit_events.po index 46114bbe005..215970aa6e1 100644 --- a/library/audit_events.po +++ b/library/audit_events.po @@ -1,13 +1,12 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # FIRST AUTHOR , YEAR. # msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-06 00:03+0000\n" +"POT-Creation-Date: 2025-09-08 15:25+0800\n" "PO-Revision-Date: 2021-12-06 21:50+0800\n" "Last-Translator: Jordan Su \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -24,13 +23,13 @@ msgstr "稽核事件表" #: ../../library/audit_events.rst:8 msgid "" -"This table contains all events raised by :func:`sys.audit` or :c:func:" -"`PySys_Audit` calls throughout the CPython runtime and the standard " -"library. These calls were added in 3.8 or later (see :pep:`578`)." +"This table contains all events raised by :func:`sys.audit` " +"or :c:func:`PySys_Audit` calls throughout the CPython runtime and the " +"standard library. These calls were added in 3.8 or later (see :pep:`578`)." msgstr "" -"這張表包含了所有在 CPython 運行環境 (runtime) 與標準函式庫對於 :func:`sys." -"audit` 或 :c:func:`PySys_Audit` 的呼叫所觸發的事件。這些呼叫是在 3.8 或更新的" -"版本中被新增(請見 :pep:`578`\\ )。" +"這張表包含了所有在 CPython 運行環境 (runtime) 與標準函式庫對" +"於 :func:`sys.audit` 或 :c:func:`PySys_Audit` 的呼叫所觸發的事件。這些呼叫是" +"在 3.8 或更新的版本中被新增(請見 :pep:`578`\\ )。" #: ../../library/audit_events.rst:12 msgid "" @@ -120,13 +119,25 @@ msgid "``handle``, ``exit_code``" msgstr "``handle``, ``exit_code``" #: ../../library/audit_events.rst:46 +msgid "_posixsubprocess.fork_exec" +msgstr "_posixsubprocess.fork_exec" + +#: ../../library/audit_events.rst:46 +msgid "``exec_list``, ``args``, ``env``" +msgstr "``exec_list``, ``args``, ``env``" + +#: ../../library/audit_events.rst:48 msgid "ctypes.PyObj_FromPtr" msgstr "ctypes.PyObj_FromPtr" -#: ../../library/audit_events.rst:46 +#: ../../library/audit_events.rst:48 msgid "``obj``" msgstr "``obj``" +#: ../../library/audit_events.rst:51 +msgid "The ``_posixsubprocess.fork_exec`` internal audit event." +msgstr "內部稽核事件 ``_posixsubprocess.fork_exec``。" + #: ../../library/audit_events.rst:3 msgid "audit events" msgstr "audit events(稽核事件)" diff --git a/library/base64.po b/library/base64.po index 59e5ded526a..9af6ca2344b 100644 --- a/library/base64.po +++ b/library/base64.po @@ -1,12 +1,11 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Inndy, 2016 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2018-05-23 14:39+0000\n" @@ -267,7 +266,7 @@ msgid "" "Similar to :func:`b32decode` but uses the Extended Hex Alphabet, as defined " "in :rfc:`4648`." msgstr "" -"類似於 :func:`b32encode`,但使用在 :rfc:`4648` 中定義的擴展十六進位字母表。" +"類似於 :func:`b32decode`,但使用在 :rfc:`4648` 中定義的擴展十六進位字母表。" #: ../../library/base64.rst:160 msgid "" diff --git a/library/bdb.po b/library/bdb.po index c188b1f1025..37f55c0b11b 100644 --- a/library/bdb.po +++ b/library/bdb.po @@ -1,13 +1,12 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-09-08 15:25+0800\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-" @@ -61,10 +60,10 @@ msgstr "" #: ../../library/bdb.rst:33 msgid "" "When creating a breakpoint, its associated :attr:`file name ` should " -"be in canonical form. If a :attr:`funcname` is defined, a breakpoint :attr:" -"`hit ` will be counted when the first line of that function is " -"executed. A :attr:`conditional ` breakpoint always counts a :attr:" -"`hit `." +"be in canonical form. If a :attr:`funcname` is defined, a " +"breakpoint :attr:`hit ` will be counted when the first line of that " +"function is executed. A :attr:`conditional ` breakpoint always counts " +"a :attr:`hit `." msgstr "" #: ../../library/bdb.rst:39 @@ -158,8 +157,8 @@ msgstr "" #: ../../library/bdb.rst:110 msgid "" -"Dictionary of :class:`Breakpoint` instances indexed by (:attr:`file`, :attr:" -"`line`) tuples." +"Dictionary of :class:`Breakpoint` instances indexed by " +"(:attr:`file`, :attr:`line`) tuples." msgstr "" #: ../../library/bdb.rst:115 @@ -177,8 +176,8 @@ msgstr "" #: ../../library/bdb.rst:125 msgid "" "This class takes care of the details of the trace facility; a derived class " -"should implement user interaction. The standard debugger class (:class:`pdb." -"Pdb`) is an example." +"should implement user interaction. The standard debugger class " +"(:class:`pdb.Pdb`) is an example." msgstr "" #: ../../library/bdb.rst:129 @@ -191,287 +190,316 @@ msgid "" msgstr "" #: ../../library/bdb.rst:135 +msgid "" +"The *backend* argument specifies the backend to use for :class:`Bdb`. It can " +"be either ``'settrace'`` or ``'monitoring'``. ``'settrace'`` " +"uses :func:`sys.settrace` which has the best backward compatibility. The " +"``'monitoring'`` backend uses the new :mod:`sys.monitoring` that was " +"introduced in Python 3.12, which can be much more efficient because it can " +"disable unused events. We are trying to keep the exact interfaces for both " +"backends, but there are some differences. The debugger developers are " +"encouraged to use the ``'monitoring'`` backend to achieve better performance." +msgstr "" + +#: ../../library/bdb.rst:145 msgid "Added the *skip* parameter." msgstr "新增 *skip* 引數。" -#: ../../library/bdb.rst:138 +#: ../../library/bdb.rst:148 +msgid "Added the *backend* parameter." +msgstr "新增 *backend* 參數。" + +#: ../../library/bdb.rst:151 msgid "" "The following methods of :class:`Bdb` normally don't need to be overridden." msgstr "" -#: ../../library/bdb.rst:142 +#: ../../library/bdb.rst:155 msgid "Return canonical form of *filename*." msgstr "" -#: ../../library/bdb.rst:144 +#: ../../library/bdb.rst:157 msgid "" -"For real file names, the canonical form is an operating-system-dependent, :" -"func:`case-normalized ` :func:`absolute path `. A *filename* with angle brackets, such as ``\"\"`` " -"generated in interactive mode, is returned unchanged." +"For real file names, the canonical form is an operating-system-" +"dependent, :func:`case-normalized ` :func:`absolute path " +"`. A *filename* with angle brackets, such as " +"``\"\"`` generated in interactive mode, is returned unchanged." msgstr "" -#: ../../library/bdb.rst:151 +#: ../../library/bdb.rst:164 +msgid "" +"Start tracing. For ``'settrace'`` backend, this method is equivalent to " +"``sys.settrace(self.trace_dispatch)``" +msgstr "" + +#: ../../library/bdb.rst:171 +msgid "" +"Stop tracing. For ``'settrace'`` backend, this method is equivalent to " +"``sys.settrace(None)``" +msgstr "" + +#: ../../library/bdb.rst:178 msgid "" -"Set the :attr:`!botframe`, :attr:`!stopframe`, :attr:`!returnframe` and :" -"attr:`quitting ` attributes with values ready to start " +"Set the :attr:`!botframe`, :attr:`!stopframe`, :attr:`!returnframe` " +"and :attr:`quitting ` attributes with values ready to start " "debugging." msgstr "" -#: ../../library/bdb.rst:156 +#: ../../library/bdb.rst:183 msgid "" "This function is installed as the trace function of debugged frames. Its " "return value is the new trace function (in most cases, that is, itself)." msgstr "" -#: ../../library/bdb.rst:159 +#: ../../library/bdb.rst:186 msgid "" "The default implementation decides how to dispatch a frame, depending on the " "type of event (passed as a string) that is about to be executed. *event* can " "be one of the following:" msgstr "" -#: ../../library/bdb.rst:163 +#: ../../library/bdb.rst:190 msgid "``\"line\"``: A new line of code is going to be executed." msgstr "" -#: ../../library/bdb.rst:164 +#: ../../library/bdb.rst:191 msgid "" "``\"call\"``: A function is about to be called, or another code block " "entered." msgstr "" -#: ../../library/bdb.rst:166 +#: ../../library/bdb.rst:193 msgid "``\"return\"``: A function or other code block is about to return." msgstr "" -#: ../../library/bdb.rst:167 +#: ../../library/bdb.rst:194 msgid "``\"exception\"``: An exception has occurred." msgstr "" -#: ../../library/bdb.rst:168 +#: ../../library/bdb.rst:195 msgid "``\"c_call\"``: A C function is about to be called." msgstr "" -#: ../../library/bdb.rst:169 +#: ../../library/bdb.rst:196 msgid "``\"c_return\"``: A C function has returned." msgstr "" -#: ../../library/bdb.rst:170 +#: ../../library/bdb.rst:197 msgid "``\"c_exception\"``: A C function has raised an exception." msgstr "" -#: ../../library/bdb.rst:172 +#: ../../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:175 +#: ../../library/bdb.rst:202 msgid "The *arg* parameter depends on the previous event." msgstr "" -#: ../../library/bdb.rst:177 +#: ../../library/bdb.rst:204 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`." +"trace function. For more information on code and frame objects, refer " +"to :ref:`types`." msgstr "" -#: ../../library/bdb.rst:183 +#: ../../library/bdb.rst:210 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:" -"`BdbQuit` exception if the :attr:`quitting ` flag is set " -"(which can be set from :meth:`user_line`). Return a reference to the :meth:" -"`trace_dispatch` method for further tracing in that scope." +"If the debugger should stop on the current line, invoke " +"the :meth:`user_line` method (which should be overridden in subclasses). " +"Raise a :exc:`BdbQuit` exception if the :attr:`quitting ` " +"flag is set (which can be set from :meth:`user_line`). Return a reference " +"to the :meth:`trace_dispatch` method for further tracing in that scope." msgstr "" -#: ../../library/bdb.rst:191 +#: ../../library/bdb.rst:218 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:" -"`BdbQuit` exception if the :attr:`quitting ` flag is set " -"(which can be set from :meth:`user_call`). Return a reference to the :meth:" -"`trace_dispatch` method for further tracing in that scope." +"If the debugger should stop on this function call, invoke " +"the :meth:`user_call` method (which should be overridden in subclasses). " +"Raise a :exc:`BdbQuit` exception if the :attr:`quitting ` " +"flag is set (which can be set from :meth:`user_call`). Return a reference " +"to the :meth:`trace_dispatch` method for further tracing in that scope." msgstr "" -#: ../../library/bdb.rst:199 +#: ../../library/bdb.rst:226 msgid "" -"If the debugger should stop on this function return, invoke the :meth:" -"`user_return` method (which should be overridden in subclasses). Raise a :" -"exc:`BdbQuit` exception if the :attr:`quitting ` flag is set " -"(which can be set from :meth:`user_return`). Return a reference to the :" -"meth:`trace_dispatch` method for further tracing in that scope." +"If the debugger should stop on this function return, invoke " +"the :meth:`user_return` method (which should be overridden in subclasses). " +"Raise a :exc:`BdbQuit` exception if the :attr:`quitting ` " +"flag is set (which can be set from :meth:`user_return`). Return a reference " +"to the :meth:`trace_dispatch` method for further tracing in that scope." msgstr "" -#: ../../library/bdb.rst:207 +#: ../../library/bdb.rst:234 msgid "" -"If the debugger should stop at this exception, invokes the :meth:" -"`user_exception` method (which should be overridden in subclasses). Raise a :" -"exc:`BdbQuit` exception if the :attr:`quitting ` flag is set " -"(which can be set from :meth:`user_exception`). Return a reference to the :" -"meth:`trace_dispatch` method for further tracing in that scope." +"If the debugger should stop at this exception, invokes " +"the :meth:`user_exception` method (which should be overridden in " +"subclasses). Raise a :exc:`BdbQuit` exception if the :attr:`quitting " +"` flag is set (which can be set from :meth:`user_exception`). " +"Return a reference to the :meth:`trace_dispatch` method for further tracing " +"in that scope." msgstr "" -#: ../../library/bdb.rst:213 +#: ../../library/bdb.rst:240 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:218 +#: ../../library/bdb.rst:245 msgid "Return ``True`` if *module_name* matches any skip pattern." msgstr "" -#: ../../library/bdb.rst:222 +#: ../../library/bdb.rst:249 msgid "Return ``True`` if *frame* is below the starting frame in the stack." msgstr "" -#: ../../library/bdb.rst:226 +#: ../../library/bdb.rst:253 msgid "Return ``True`` if there is an effective breakpoint for this line." msgstr "" -#: ../../library/bdb.rst:228 +#: ../../library/bdb.rst:255 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:233 +#: ../../library/bdb.rst:260 msgid "Return ``True`` if any breakpoint exists for *frame*'s filename." msgstr "" -#: ../../library/bdb.rst:235 +#: ../../library/bdb.rst:262 msgid "" "Derived classes should override these methods to gain control over debugger " "operation." msgstr "" -#: ../../library/bdb.rst:240 +#: ../../library/bdb.rst:267 msgid "" "Called from :meth:`dispatch_call` if a break might stop inside the called " "function." msgstr "" -#: ../../library/bdb.rst:243 +#: ../../library/bdb.rst:270 msgid "" "*argument_list* is not used anymore and will always be ``None``. The " "argument is kept for backwards compatibility." msgstr "" -#: ../../library/bdb.rst:248 +#: ../../library/bdb.rst:275 msgid "" -"Called from :meth:`dispatch_line` when either :meth:`stop_here` or :meth:" -"`break_here` returns ``True``." +"Called from :meth:`dispatch_line` when either :meth:`stop_here` " +"or :meth:`break_here` returns ``True``." msgstr "" -#: ../../library/bdb.rst:253 +#: ../../library/bdb.rst:280 msgid "" "Called from :meth:`dispatch_return` when :meth:`stop_here` returns ``True``." msgstr "" -#: ../../library/bdb.rst:257 +#: ../../library/bdb.rst:284 msgid "" "Called from :meth:`dispatch_exception` when :meth:`stop_here` returns " "``True``." msgstr "" -#: ../../library/bdb.rst:262 +#: ../../library/bdb.rst:289 msgid "Handle how a breakpoint must be removed when it is a temporary one." msgstr "" -#: ../../library/bdb.rst:264 +#: ../../library/bdb.rst:291 msgid "This method must be implemented by derived classes." msgstr "" -#: ../../library/bdb.rst:267 +#: ../../library/bdb.rst:294 msgid "" "Derived classes and clients can call the following methods to affect the " "stepping state." msgstr "" -#: ../../library/bdb.rst:272 +#: ../../library/bdb.rst:299 msgid "Stop after one line of code." msgstr "" -#: ../../library/bdb.rst:276 +#: ../../library/bdb.rst:303 msgid "Stop on the next line in or below the given frame." msgstr "" -#: ../../library/bdb.rst:280 +#: ../../library/bdb.rst:307 msgid "Stop when returning from the given frame." msgstr "" -#: ../../library/bdb.rst:284 +#: ../../library/bdb.rst:311 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:289 +#: ../../library/bdb.rst:316 msgid "" "Start debugging from *frame*. If *frame* is not specified, debugging starts " "from caller's frame." msgstr "" -#: ../../library/bdb.rst:292 +#: ../../library/bdb.rst:319 msgid "" ":func:`set_trace` will enter the debugger immediately, rather than on the " "next line of code to be executed." msgstr "" -#: ../../library/bdb.rst:298 +#: ../../library/bdb.rst:325 msgid "" "Stop only at breakpoints or when finished. If there are no breakpoints, set " "the system trace function to ``None``." msgstr "" -#: ../../library/bdb.rst:305 +#: ../../library/bdb.rst:332 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:309 +#: ../../library/bdb.rst:336 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:315 +#: ../../library/bdb.rst:342 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:321 +#: ../../library/bdb.rst:348 msgid "" "Delete the breakpoints in *filename* and *lineno*. If none were set, return " "an error message." msgstr "" -#: ../../library/bdb.rst:326 +#: ../../library/bdb.rst:353 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." +"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:332 +#: ../../library/bdb.rst:359 msgid "" "Delete all breakpoints in *filename*. If none were set, return an error " "message." msgstr "" -#: ../../library/bdb.rst:337 +#: ../../library/bdb.rst:364 msgid "" "Delete all existing breakpoints. If none were set, return an error message." msgstr "" -#: ../../library/bdb.rst:342 +#: ../../library/bdb.rst:369 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 " @@ -479,138 +507,161 @@ msgid "" "raised." msgstr "" -#: ../../library/bdb.rst:351 +#: ../../library/bdb.rst:378 msgid "Return ``True`` if there is a breakpoint for *lineno* in *filename*." msgstr "" -#: ../../library/bdb.rst:355 +#: ../../library/bdb.rst:382 msgid "" "Return all breakpoints for *lineno* in *filename*, or an empty list if none " "are set." msgstr "" -#: ../../library/bdb.rst:360 +#: ../../library/bdb.rst:387 msgid "Return all breakpoints in *filename*, or an empty list if none are set." msgstr "" -#: ../../library/bdb.rst:364 +#: ../../library/bdb.rst:391 msgid "Return all breakpoints that are set." msgstr "" -#: ../../library/bdb.rst:367 +#: ../../library/bdb.rst:394 +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 +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 +msgid "" +"Restart all the disabled events. This function is automatically called in " +"``dispatch_*`` methods after ``user_*`` methods are called. If the " +"``dispatch_*`` methods are not overridden, the disabled events will be " +"restarted after each user interaction." +msgstr "" + +#: ../../library/bdb.rst:416 msgid "" "Derived classes and clients can call the following methods to get a data " "structure representing a stack trace." msgstr "" -#: ../../library/bdb.rst:372 +#: ../../library/bdb.rst:421 msgid "Return a list of (frame, lineno) tuples in a stack trace, and a size." msgstr "" -#: ../../library/bdb.rst:374 +#: ../../library/bdb.rst:423 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:379 +#: ../../library/bdb.rst:428 msgid "" "Return a string with information about a stack entry, which is a ``(frame, " "lineno)`` tuple. The return string contains:" msgstr "" -#: ../../library/bdb.rst:382 +#: ../../library/bdb.rst:431 msgid "The canonical filename which contains the frame." msgstr "" -#: ../../library/bdb.rst:383 +#: ../../library/bdb.rst:432 msgid "The function name or ``\"\"``." msgstr "函式名稱或 ``\"\"``。" -#: ../../library/bdb.rst:384 +#: ../../library/bdb.rst:433 msgid "The input arguments." msgstr "輸入引數。" -#: ../../library/bdb.rst:385 +#: ../../library/bdb.rst:434 msgid "The return value." msgstr "回傳值。" -#: ../../library/bdb.rst:386 +#: ../../library/bdb.rst:435 msgid "The line of code (if it exists)." msgstr "" -#: ../../library/bdb.rst:389 +#: ../../library/bdb.rst:438 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:394 +#: ../../library/bdb.rst:443 msgid "" "Debug a statement executed via the :func:`exec` function. *globals* " "defaults to :attr:`!__main__.__dict__`, *locals* defaults to *globals*." msgstr "" -#: ../../library/bdb.rst:399 +#: ../../library/bdb.rst:448 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:404 +#: ../../library/bdb.rst:453 msgid "For backwards compatibility. Calls the :meth:`run` method." msgstr "" -#: ../../library/bdb.rst:408 +#: ../../library/bdb.rst:457 msgid "Debug a single function call, and return its result." msgstr "" -#: ../../library/bdb.rst:411 +#: ../../library/bdb.rst:460 msgid "Finally, the module defines the following functions:" msgstr "最後,這個模組定義了以下函式:" -#: ../../library/bdb.rst:415 +#: ../../library/bdb.rst:464 msgid "" -"Return ``True`` if we should break here, depending on the way the :class:" -"`Breakpoint` *b* was set." +"Return ``True`` if we should break here, depending on the way " +"the :class:`Breakpoint` *b* was set." msgstr "" -#: ../../library/bdb.rst:418 +#: ../../library/bdb.rst:467 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 :" -"attr:`function name `, we have to check we are in " -"the right *frame* (the right function) and if we are on its first executable " -"line." +"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 :attr:`function name `, we have to " +"check we are in the right *frame* (the right function) and if we are on its " +"first executable line." msgstr "" -#: ../../library/bdb.rst:427 +#: ../../library/bdb.rst:476 msgid "" "Return ``(active breakpoint, delete temporary flag)`` or ``(None, None)`` as " "the breakpoint to act upon." msgstr "" -#: ../../library/bdb.rst:430 +#: ../../library/bdb.rst:479 msgid "" -"The *active breakpoint* is the first entry in :attr:`bplist ` for the (:attr:`file `, :attr:`line `) (which must exist) that is :attr:`enabled `, for which :func:`checkfuncname` is true, and that has neither a " +"The *active breakpoint* is the first entry in :attr:`bplist " +"` for the (:attr:`file " +"`, :attr:`line `) (which must " +"exist) that is :attr:`enabled `, for " +"which :func:`checkfuncname` is true, and that has neither a " "false :attr:`condition ` nor positive :attr:`ignore " "` count. The *flag*, meaning that a temporary " -"breakpoint should be deleted, is ``False`` only when the :attr:`cond ` cannot be evaluated (in which case, :attr:`ignore ` count is ignored)." +"breakpoint should be deleted, is ``False`` only when the :attr:`cond " +"` cannot be evaluated (in which case, :attr:`ignore " +"` count is ignored)." msgstr "" -#: ../../library/bdb.rst:441 +#: ../../library/bdb.rst:490 msgid "If no such entry exists, then ``(None, None)`` is returned." msgstr "" -#: ../../library/bdb.rst:446 +#: ../../library/bdb.rst:495 msgid "Start debugging with a :class:`Bdb` instance from caller's frame." msgstr "" -#: ../../library/bdb.rst:303 +#: ../../library/bdb.rst:330 msgid "quitting (bdb.Bdb attribute)" msgstr "" diff --git a/library/binary.po b/library/binary.po index 5c36e1bf9ce..2b91220f39f 100644 --- a/library/binary.po +++ b/library/binary.po @@ -1,11 +1,10 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2018-06-26 18:54+0800\n" "PO-Revision-Date: 2015-12-09 17:51+0000\n" diff --git a/library/binascii.po b/library/binascii.po index 48302802ab3..4cae1df2e34 100644 --- a/library/binascii.po +++ b/library/binascii.po @@ -1,11 +1,10 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-23 07:52+0800\n" "PO-Revision-Date: 2018-05-23 14:39+0000\n" diff --git a/library/bisect.po b/library/bisect.po index 1f1e756f261..e18d196ae0a 100644 --- a/library/bisect.po +++ b/library/bisect.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -8,9 +8,9 @@ # Matt Wang , 2022 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-07-31 00:16+0000\n" +"POT-Creation-Date: 2025-09-08 15:25+0800\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-" @@ -46,10 +46,10 @@ 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 " "specific value, the functions in this module are designed to locate an " -"insertion point. Accordingly, the functions never call an :meth:`~object." -"__eq__` method to determine whether a value has been found. Instead, the " -"functions only call the :meth:`~object.__lt__` method and will return an " -"insertion point between values in an array." +"insertion point. Accordingly, the functions never call " +"an :meth:`~object.__eq__` method to determine whether a value has been " +"found. Instead, the functions only call the :meth:`~object.__lt__` method " +"and will return an insertion point between values in an array." msgstr "" "這個模組被稱為 :mod:`bisect` 是因為它使用基本二分演算法來完成其工作。不像其它" "搜尋特定值的二分法工具,本模組中的函式旨在定位插入點。因此,這些函式永遠不會" @@ -81,8 +81,8 @@ msgid "" msgstr "" "在 *a* 當中找到一個位置,讓 *x* 插入後 *a* 仍然是排序好的。參數 *lo* 和 *hi* " "用來指定 list 中應該被考慮的子區間,預設是考慮整個 list 。如果 *a* 裡面已經" -"有 *x* 出現,插入的位置會在所有 *x* 的前面(左邊)。回傳值可以被當作 ``list." -"insert()`` 的第一個參數,但列表 *a* 必須先排序過。" +"有 *x* 出現,插入的位置會在所有 *x* 的前面(左邊)。回傳值可以被當作 " +"``list.insert()`` 的第一個參數,但列表 *a* 必須先排序過。" #: ../../library/bisect.rst:51 msgid "" @@ -142,10 +142,10 @@ msgstr "將元素 *x* 插入 list *a*,並維持順序。" #: ../../library/bisect.rst:85 msgid "" "This function first runs :py:func:`~bisect.bisect_left` to locate an " -"insertion point. Next, it runs the :meth:`!insert` method on *a* to insert " -"*x* at the appropriate position to maintain sort order." +"insertion point. Next, it runs the :meth:`~sequence.insert` method on *a* to " +"insert *x* at the appropriate position to maintain sort order." msgstr "" -"此函式先使用 :py:func:`~bisect.bisect_left` 搜尋插入位置,接著用 :meth:`!" +"此函式先使用 :py:func:`~bisect.bisect_left` 搜尋插入位置,接著用 :meth:`~sequence." "insert` 於 *a* 以將 *x* 插入,並維持添加元素後的順序。" #: ../../library/bisect.rst:89 ../../library/bisect.rst:109 @@ -173,10 +173,10 @@ msgstr "" #: ../../library/bisect.rst:105 msgid "" "This function first runs :py:func:`~bisect.bisect_right` to locate an " -"insertion point. Next, it runs the :meth:`!insert` method on *a* to insert " -"*x* at the appropriate position to maintain sort order." +"insertion point. Next, it runs the :meth:`~sequence.insert` method on *a* to " +"insert *x* at the appropriate position to maintain sort order." msgstr "" -"此函式先使用 :py:func:`~bisect.bisect_right` 搜尋插入位置,接著用 :meth:`!" +"此函式先使用 :py:func:`~bisect.bisect_right` 搜尋插入位置,接著用 :meth:`~sequence." "insert` 於 *a* 以將 *x* 插入,並維持添加元素後的順序。" #: ../../library/bisect.rst:120 @@ -212,10 +212,10 @@ 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, " "the key function may be called again and again on the same array elements. " -"If the key function isn't fast, consider wrapping it with :py:func:" -"`functools.cache` to avoid duplicate computations. Alternatively, consider " -"searching an array of precomputed keys to locate the insertion point (as " -"shown in the examples section below)." +"If the key function isn't fast, consider wrapping it " +"with :py:func:`functools.cache` to avoid duplicate computations. " +"Alternatively, consider searching an array of precomputed keys to locate the " +"insertion point (as shown in the examples section below)." msgstr "" "搜尋函式為無狀態的 (stateless),且鍵函式會在使用過後被丟棄。因此,如果搜尋函" "式被使用於迴圈當中,鍵函式會不斷被重複呼叫於相同的 list 元素。如果鍵函式執行" @@ -370,6 +370,35 @@ msgid "" " Movie(name='Aliens', released=1986, director='Cameron'),\n" " Movie(name='Titanic', released=1997, director='Cameron')]" msgstr "" +">>> from collections import namedtuple\n" +">>> from operator import attrgetter\n" +">>> from bisect import bisect, insort\n" +">>> from pprint import pprint\n" +"\n" +">>> Movie = namedtuple('Movie', ('name', 'released', 'director'))\n" +"\n" +">>> movies = [\n" +"... Movie('Jaws', 1975, 'Spielberg'),\n" +"... Movie('Titanic', 1997, 'Cameron'),\n" +"... Movie('The Birds', 1963, 'Hitchcock'),\n" +"... Movie('Aliens', 1986, 'Cameron')\n" +"... ]\n" +"\n" +">>> # 找到 1960 年後上映的第一部電影\n" +">>> by_year = attrgetter('released')\n" +">>> movies.sort(key=by_year)\n" +">>> movies[bisect(movies, 1960, key=by_year)]\n" +"Movie(name='The Birds', released=1963, director='Hitchcock')\n" +"\n" +">>> # 插入一部電影並保持排序\n" +">>> romance = Movie('Love Story', 1970, 'Hiller')\n" +">>> insort(movies, romance, key=by_year)\n" +">>> pprint(movies)\n" +"[Movie(name='The Birds', released=1963, director='Hitchcock'),\n" +" Movie(name='Love Story', released=1970, director='Hiller'),\n" +" Movie(name='Jaws', released=1975, director='Spielberg'),\n" +" Movie(name='Aliens', released=1986, director='Cameron'),\n" +" Movie(name='Titanic', released=1997, director='Cameron')]" #: ../../library/bisect.rst:247 msgid "" diff --git a/library/builtins.po b/library/builtins.po index ab36c9d83d1..77bd54a9de8 100644 --- a/library/builtins.po +++ b/library/builtins.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -6,7 +6,7 @@ # Matt Wang , 2022-2024 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-10-22 00:13+0000\n" "PO-Revision-Date: 2022-02-15 20:55+0800\n" diff --git a/library/bz2.po b/library/bz2.po index f0ec58fb6a9..b676e2bdcaf 100644 --- a/library/bz2.po +++ b/library/bz2.po @@ -1,13 +1,12 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-11-10 16:45+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-" @@ -54,37 +53,45 @@ msgid "" "(de)compression." msgstr "" -#: ../../library/bz2.rst:30 +#: ../../includes/optional-module.rst:1 +msgid "" +"This is an :term:`optional module`. If it is missing from your copy of " +"CPython, look for documentation from your distributor (that is, whoever " +"provided Python to you). If you are the distributor, see :ref:`optional-" +"module-requirements`." +msgstr "" + +#: ../../library/bz2.rst:32 msgid "(De)compression of files" msgstr "" -#: ../../library/bz2.rst:34 +#: ../../library/bz2.rst:36 msgid "" "Open a bzip2-compressed file in binary or text mode, returning a :term:`file " "object`." msgstr "" -#: ../../library/bz2.rst:37 +#: ../../library/bz2.rst:39 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:41 +#: ../../library/bz2.rst:43 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:45 +#: ../../library/bz2.rst:47 msgid "" "The *compresslevel* argument is an integer from 1 to 9, as for the :class:" "`BZ2File` constructor." msgstr "" -#: ../../library/bz2.rst:48 +#: ../../library/bz2.rst:50 msgid "" "For binary mode, this function is equivalent to the :class:`BZ2File` " "constructor: ``BZ2File(filename, mode, compresslevel=compresslevel)``. In " @@ -92,33 +99,33 @@ msgid "" "provided." msgstr "" -#: ../../library/bz2.rst:53 +#: ../../library/bz2.rst:55 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:59 ../../library/bz2.rst:175 +#: ../../library/bz2.rst:61 ../../library/bz2.rst:177 msgid "The ``'x'`` (exclusive creation) mode was added." msgstr "" -#: ../../library/bz2.rst:62 ../../library/bz2.rst:182 +#: ../../library/bz2.rst:64 ../../library/bz2.rst:184 msgid "Accepts a :term:`path-like object`." msgstr "" -#: ../../library/bz2.rst:68 +#: ../../library/bz2.rst:70 msgid "Open a bzip2-compressed file in binary mode." msgstr "" -#: ../../library/bz2.rst:70 +#: ../../library/bz2.rst:72 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:74 +#: ../../library/bz2.rst:76 msgid "" "The *mode* argument can be either ``'r'`` for reading (default), ``'w'`` for " "overwriting, ``'x'`` for exclusive creation, or ``'a'`` for appending. These " @@ -126,44 +133,44 @@ msgid "" "respectively." msgstr "" -#: ../../library/bz2.rst:79 +#: ../../library/bz2.rst:81 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:82 +#: ../../library/bz2.rst:84 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:86 +#: ../../library/bz2.rst:88 msgid "" "If *mode* is ``'r'``, the input file may be the concatenation of multiple " "compressed streams." msgstr "" -#: ../../library/bz2.rst:89 +#: ../../library/bz2.rst:91 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:94 +#: ../../library/bz2.rst:96 msgid ":class:`BZ2File` also provides the following methods and attributes:" msgstr ":class:`BZ2File` 也提供了以下方法和屬性:" -#: ../../library/bz2.rst:98 +#: ../../library/bz2.rst:100 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:102 +#: ../../library/bz2.rst:104 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 " @@ -171,138 +178,138 @@ msgid "" "*filename*)." msgstr "" -#: ../../library/bz2.rst:111 +#: ../../library/bz2.rst:113 msgid "Return the file descriptor for the underlying file." msgstr "" -#: ../../library/bz2.rst:117 +#: ../../library/bz2.rst:119 msgid "Return whether the file was opened for reading." msgstr "" -#: ../../library/bz2.rst:123 +#: ../../library/bz2.rst:125 msgid "Return whether the file supports seeking." msgstr "" -#: ../../library/bz2.rst:129 +#: ../../library/bz2.rst:131 msgid "Return whether the file was opened for writing." msgstr "" -#: ../../library/bz2.rst:135 +#: ../../library/bz2.rst:137 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:139 +#: ../../library/bz2.rst:141 msgid "Returns ``b''`` if the file is at EOF." msgstr "" -#: ../../library/bz2.rst:145 +#: ../../library/bz2.rst:147 msgid "Read bytes into *b*." msgstr "" -#: ../../library/bz2.rst:147 +#: ../../library/bz2.rst:149 msgid "Returns the number of bytes read (0 for EOF)." msgstr "" -#: ../../library/bz2.rst:153 +#: ../../library/bz2.rst:155 msgid "``'rb'`` for reading and ``'wb'`` for writing." msgstr "" -#: ../../library/bz2.rst:159 +#: ../../library/bz2.rst:161 msgid "" "The bzip2 file name. Equivalent to the :attr:`~io.FileIO.name` attribute of " "the underlying :term:`file object`." msgstr "" -#: ../../library/bz2.rst:165 +#: ../../library/bz2.rst:167 msgid "Support for the :keyword:`with` statement was added." msgstr "" -#: ../../library/bz2.rst:168 +#: ../../library/bz2.rst:170 msgid "" "Support was added for *filename* being a :term:`file object` instead of an " "actual filename." msgstr "" -#: ../../library/bz2.rst:172 +#: ../../library/bz2.rst:174 msgid "" "The ``'a'`` (append) mode was added, along with support for reading multi-" "stream files." msgstr "" -#: ../../library/bz2.rst:178 +#: ../../library/bz2.rst:180 msgid "" "The :meth:`~io.BufferedIOBase.read` method now accepts an argument of " "``None``." msgstr "" -#: ../../library/bz2.rst:185 +#: ../../library/bz2.rst:187 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:190 +#: ../../library/bz2.rst:192 msgid "The *compresslevel* parameter became keyword-only." msgstr "" -#: ../../library/bz2.rst:192 +#: ../../library/bz2.rst:194 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:199 +#: ../../library/bz2.rst:201 msgid "Incremental (de)compression" msgstr "" -#: ../../library/bz2.rst:203 +#: ../../library/bz2.rst:205 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:207 ../../library/bz2.rst:295 +#: ../../library/bz2.rst:209 ../../library/bz2.rst:297 msgid "" "*compresslevel*, if given, must be an integer between ``1`` and ``9``. The " "default is ``9``." msgstr "" -#: ../../library/bz2.rst:212 +#: ../../library/bz2.rst:214 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:215 +#: ../../library/bz2.rst:217 msgid "" "When you have finished providing data to the compressor, call the :meth:" "`flush` method to finish the compression process." msgstr "" -#: ../../library/bz2.rst:221 +#: ../../library/bz2.rst:223 msgid "" "Finish the compression process. Returns the compressed data left in internal " "buffers." msgstr "" -#: ../../library/bz2.rst:224 +#: ../../library/bz2.rst:226 msgid "" "The compressor object may not be used after this method has been called." msgstr "" -#: ../../library/bz2.rst:229 +#: ../../library/bz2.rst:231 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:234 +#: ../../library/bz2.rst:236 msgid "" "This class does not transparently handle inputs containing multiple " "compressed streams, unlike :func:`decompress` and :class:`BZ2File`. If you " @@ -310,7 +317,7 @@ msgid "" "must use a new decompressor for each stream." msgstr "" -#: ../../library/bz2.rst:241 +#: ../../library/bz2.rst:243 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 " @@ -318,7 +325,7 @@ msgid "" "output of any previous calls to :meth:`decompress`." msgstr "" -#: ../../library/bz2.rst:247 +#: ../../library/bz2.rst:249 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 " @@ -327,99 +334,99 @@ msgid "" "``b''`` to obtain more of the output." msgstr "" -#: ../../library/bz2.rst:254 +#: ../../library/bz2.rst:256 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:259 +#: ../../library/bz2.rst:261 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:263 +#: ../../library/bz2.rst:265 msgid "Added the *max_length* parameter." msgstr "新增 *max_length* 參數。" -#: ../../library/bz2.rst:268 +#: ../../library/bz2.rst:270 msgid "``True`` if the end-of-stream marker has been reached." msgstr "" -#: ../../library/bz2.rst:275 +#: ../../library/bz2.rst:277 msgid "Data found after the end of the compressed stream." msgstr "" -#: ../../library/bz2.rst:277 +#: ../../library/bz2.rst:279 msgid "" "If this attribute is accessed before the end of the stream has been reached, " "its value will be ``b''``." msgstr "" -#: ../../library/bz2.rst:282 +#: ../../library/bz2.rst:284 msgid "" "``False`` if the :meth:`.decompress` method can provide more decompressed " "data before requiring new uncompressed input." msgstr "" -#: ../../library/bz2.rst:289 +#: ../../library/bz2.rst:291 msgid "One-shot (de)compression" msgstr "" -#: ../../library/bz2.rst:293 +#: ../../library/bz2.rst:295 msgid "Compress *data*, a :term:`bytes-like object `." msgstr "" -#: ../../library/bz2.rst:298 +#: ../../library/bz2.rst:300 msgid "For incremental compression, use a :class:`BZ2Compressor` instead." msgstr "" -#: ../../library/bz2.rst:303 +#: ../../library/bz2.rst:305 msgid "Decompress *data*, a :term:`bytes-like object `." msgstr "" -#: ../../library/bz2.rst:305 +#: ../../library/bz2.rst:307 msgid "" "If *data* is the concatenation of multiple compressed streams, decompress " "all of the streams." msgstr "" -#: ../../library/bz2.rst:308 +#: ../../library/bz2.rst:310 msgid "For incremental decompression, use a :class:`BZ2Decompressor` instead." msgstr "" -#: ../../library/bz2.rst:310 +#: ../../library/bz2.rst:312 msgid "Support for multi-stream inputs was added." msgstr "" -#: ../../library/bz2.rst:316 +#: ../../library/bz2.rst:318 msgid "Examples of usage" msgstr "用法範例" -#: ../../library/bz2.rst:318 +#: ../../library/bz2.rst:320 msgid "Below are some examples of typical usage of the :mod:`bz2` module." msgstr "" -#: ../../library/bz2.rst:320 +#: ../../library/bz2.rst:322 msgid "" "Using :func:`compress` and :func:`decompress` to demonstrate round-trip " "compression:" msgstr "" -#: ../../library/bz2.rst:338 +#: ../../library/bz2.rst:340 msgid "Using :class:`BZ2Compressor` for incremental compression:" msgstr "" -#: ../../library/bz2.rst:356 +#: ../../library/bz2.rst:358 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:360 +#: ../../library/bz2.rst:362 msgid "Writing and reading a bzip2-compressed file in binary mode:" msgstr "" diff --git a/library/calendar.po b/library/calendar.po index 59c409fce58..1a974b314f1 100644 --- a/library/calendar.po +++ b/library/calendar.po @@ -1,12 +1,12 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-01-08 00:13+0000\n" +"POT-Creation-Date: 2025-09-08 15:25+0800\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-" @@ -246,21 +246,21 @@ msgid "" "the :meth:`setfirstweekday` method." msgstr "" -#: ../../library/calendar.rst:178 +#: ../../library/calendar.rst:179 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:184 +#: ../../library/calendar.rst:186 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:190 +#: ../../library/calendar.rst:193 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 " @@ -272,7 +272,7 @@ msgstr "" "度。如果給定 *l*,它會指定每一週使用的行數。這個日曆會依據在建構函式中指定或" "者透過 :meth:`setfirstweekday` 方法設定的一週的第一天來輸出。" -#: ../../library/calendar.rst:198 +#: ../../library/calendar.rst:202 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 " @@ -280,11 +280,11 @@ msgid "" "to be formatted respectively." msgstr "" -#: ../../library/calendar.rst:205 +#: ../../library/calendar.rst:210 msgid "Print a month's calendar as returned by :meth:`formatmonth`." msgstr "印出一個月份的日曆,內容和 :meth:`formatmonth` 回傳的一樣。" -#: ../../library/calendar.rst:210 +#: ../../library/calendar.rst:215 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 " @@ -298,20 +298,20 @@ msgstr "" "者透過 :meth:`setfirstweekday` 方法設定的一週的第一天來輸出。最早可以產生日曆" "的年份會依據平台而不同。" -#: ../../library/calendar.rst:220 +#: ../../library/calendar.rst:225 msgid "" "Print the calendar for an entire year as returned by :meth:`formatyear`." msgstr "印出一整年的日曆,內容和 :meth:`formatyear` 回傳的一樣。" -#: ../../library/calendar.rst:225 +#: ../../library/calendar.rst:230 msgid "This class can be used to generate HTML calendars." msgstr "這個類別用來產生 HTML 日曆。" -#: ../../library/calendar.rst:228 +#: ../../library/calendar.rst:233 msgid ":class:`!HTMLCalendar` instances have the following methods:" msgstr ":class:`!HTMLCalendar` 實例有以下方法:" -#: ../../library/calendar.rst:232 +#: ../../library/calendar.rst:237 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." @@ -319,14 +319,14 @@ msgstr "" "以 HTML 表格的形式回傳一個月份的日曆。如果 *withyear* 是 true 則標題會包含年" "份,否則只會有月份名稱。" -#: ../../library/calendar.rst:239 +#: ../../library/calendar.rst:244 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:245 +#: ../../library/calendar.rst:250 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 " @@ -338,7 +338,7 @@ msgstr "" "月。*css* 是要使用的 CSS (cascading style sheet) 名稱,可以給 :const:`None` " "表示不使用任何 CSS。*encoding* 指定輸出使用的編碼(預設使用系統預設編碼)。" -#: ../../library/calendar.rst:254 +#: ../../library/calendar.rst:259 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." @@ -346,28 +346,28 @@ msgstr "" "以 HTML 表列的形式回傳一個月份的名稱。如果 *withyear* 是 true 則該列會包含年" "份,否則只會有月份名稱。" -#: ../../library/calendar.rst:259 +#: ../../library/calendar.rst:264 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:264 +#: ../../library/calendar.rst:269 msgid "" "A list of CSS classes used for each weekday. The default class list is::" msgstr "對應一週每一天 CSS 類別的串列。預設的串列內容為: ::" -#: ../../library/calendar.rst:266 +#: ../../library/calendar.rst:271 msgid "" "cssclasses = [\"mon\", \"tue\", \"wed\", \"thu\", \"fri\", \"sat\", \"sun\"]" msgstr "" "cssclasses = [\"mon\", \"tue\", \"wed\", \"thu\", \"fri\", \"sat\", \"sun\"]" -#: ../../library/calendar.rst:268 +#: ../../library/calendar.rst:273 msgid "more styles can be added for each day::" msgstr "可以針對每一天增加更多樣式: ::" -#: ../../library/calendar.rst:270 +#: ../../library/calendar.rst:275 msgid "" "cssclasses = [\"mon text-bold\", \"tue\", \"wed\", \"thu\", \"fri\", " "\"sat\", \"sun red\"]" @@ -375,15 +375,15 @@ msgstr "" "cssclasses = [\"mon text-bold\", \"tue\", \"wed\", \"thu\", \"fri\", " "\"sat\", \"sun red\"]" -#: ../../library/calendar.rst:272 +#: ../../library/calendar.rst:277 msgid "Note that the length of this list must be seven items." msgstr "注意這個串列的長度必須是七個項目。" -#: ../../library/calendar.rst:277 +#: ../../library/calendar.rst:282 msgid "The CSS class for a weekday occurring in the previous or coming month." msgstr "跟當月為同一週且屬於前一個或下一個月份的日期使用的 CSS 類別。" -#: ../../library/calendar.rst:284 +#: ../../library/calendar.rst:289 msgid "" "A list of CSS classes used for weekday names in the header row. The default " "is the same as :attr:`cssclasses`." @@ -391,7 +391,7 @@ msgstr "" "在標題列中一週每一天名稱的 CSS 類別的串列。預設內容和 :attr:`cssclasses` 相" "同。" -#: ../../library/calendar.rst:292 +#: ../../library/calendar.rst:297 msgid "" "The month's head CSS class (used by :meth:`formatmonthname`). The default " "value is ``\"month\"``." @@ -399,7 +399,7 @@ msgstr "" "月份標題的 CSS 類別(由 :meth:`formatmonthname` 所使用),預設值是 " "``\"month\"``。" -#: ../../library/calendar.rst:300 +#: ../../library/calendar.rst:305 msgid "" "The CSS class for the whole month's table (used by :meth:`formatmonth`). The " "default value is ``\"month\"``." @@ -407,14 +407,14 @@ msgstr "" "整個月份表格的 CSS 類別(由 :meth:`formatmonth` 所使用),預設值是 " "``\"month\"``。" -#: ../../library/calendar.rst:308 +#: ../../library/calendar.rst:313 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:316 +#: ../../library/calendar.rst:321 msgid "" "The CSS class for the table head for the whole year (used " "by :meth:`formatyear`). The default value is ``\"year\"``." @@ -422,7 +422,7 @@ msgstr "" "整年表格標題的 CSS 類別(由 :meth:`formatyear` 所使用),預設值是 " "``\"year\"``。" -#: ../../library/calendar.rst:322 +#: ../../library/calendar.rst:327 msgid "" "Note that although the naming for the above described class attributes is " "singular (e.g. ``cssclass_month`` ``cssclass_noday``), one can replace the " @@ -432,15 +432,15 @@ msgstr "" "``cssclass_noday``),你可以使用多個以空格隔開的 CSS 類別取代單一 CSS 類別," "例如: ::" -#: ../../library/calendar.rst:326 +#: ../../library/calendar.rst:331 msgid "\"text-bold text-red\"" msgstr "\"text-bold text-red\"" -#: ../../library/calendar.rst:328 +#: ../../library/calendar.rst:333 msgid "Here is an example how :class:`!HTMLCalendar` can be customized::" msgstr "以下是客製化 :class:`!HTMLCalendar` 的範例: ::" -#: ../../library/calendar.rst:330 +#: ../../library/calendar.rst:335 msgid "" "class CustomHTMLCal(calendar.HTMLCalendar):\n" " cssclasses = [style + \" text-nowrap\" for style in\n" @@ -456,7 +456,7 @@ msgstr "" " cssclass_month = \"text-center month\"\n" " cssclass_year = \"text-italic lead\"" -#: ../../library/calendar.rst:340 +#: ../../library/calendar.rst:345 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." @@ -464,7 +464,7 @@ msgstr "" ":class:`TextCalendar` 的子類別,可以在建構函式傳入語系名稱,它會回傳指定語系" "的月份及一週每一天的名稱。" -#: ../../library/calendar.rst:346 +#: ../../library/calendar.rst:351 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." @@ -472,7 +472,7 @@ msgstr "" ":class:`HTMLCalendar` 的子類別,可以在建構函式傳入語系名稱,它會回傳指定語系" "的月份及一週每一天的名稱。" -#: ../../library/calendar.rst:352 +#: ../../library/calendar.rst:357 msgid "" "The constructor, :meth:`!formatweekday` and :meth:`!formatmonthname` methods " "of these two classes temporarily change the ``LC_TIME`` locale to the given " @@ -483,11 +483,11 @@ msgstr "" "會把 ``LC_TIME`` 語系暫時改成給定的 *locale*。因為目前的語系是屬於整個行程 " "(process-wide) 的設定,它們不是執行緒安全的。" -#: ../../library/calendar.rst:358 +#: ../../library/calendar.rst:363 msgid "For simple text calendars this module provides the following functions." msgstr "這個模組提供以下函式給單純的文字日曆使用。" -#: ../../library/calendar.rst:362 +#: ../../library/calendar.rst:367 msgid "" "Sets the weekday (``0`` is Monday, ``6`` is Sunday) to start each week. The " "values :const:`MONDAY`, :const:`TUESDAY`, :const:`WEDNESDAY`, :const:`THURSDAY`, :const:`FRIDAY`, :const:`SATURDAY`, " @@ -498,7 +498,7 @@ msgstr "" "供 :const:`MONDAY`、:const:`TUESDAY`、:const:`WEDNESDAY`、:const:`THURSDAY`、:const:`FRIDAY`、:const:`SATURDAY` " "及 :const:`SUNDAY` 可以方便設定。例如設定一週的第一天為週日: ::" -#: ../../library/calendar.rst:367 +#: ../../library/calendar.rst:372 msgid "" "import calendar\n" "calendar.setfirstweekday(calendar.SUNDAY)" @@ -506,27 +506,27 @@ msgstr "" "import calendar\n" "calendar.setfirstweekday(calendar.SUNDAY)" -#: ../../library/calendar.rst:373 +#: ../../library/calendar.rst:378 msgid "Returns the current setting for the weekday to start each week." msgstr "回傳目前設定的一週的第一天。" -#: ../../library/calendar.rst:378 +#: ../../library/calendar.rst:383 msgid "" "Returns :const:`True` if *year* is a leap year, otherwise :const:`False`." msgstr "如果 *year* 是閏年回傳 :const:`True`,否則回傳 :const:`False`。" -#: ../../library/calendar.rst:383 +#: ../../library/calendar.rst:388 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:386 +#: ../../library/calendar.rst:391 msgid "This function works for ranges spanning a century change." msgstr "這個函式也適用在跨越世紀的時間範圍。" -#: ../../library/calendar.rst:391 +#: ../../library/calendar.rst:396 msgid "" "Returns the day of the week (``0`` is Monday) for *year* (``1970``--...), " "*month* (``1``--``12``), *day* (``1``--``31``)." @@ -534,19 +534,19 @@ msgstr "" "回傳 *year* 年 (``1970``--...) *month* 月 (``1``--``12``) *day* 日 (``1``--" "``31``) 是週幾(``0`` 是星期一)。" -#: ../../library/calendar.rst:397 +#: ../../library/calendar.rst:402 msgid "" "Return a header containing abbreviated weekday names. *n* specifies the " "width in characters for one weekday." msgstr "回傳包含一週每一天的名稱縮寫的標題。*n* 指定每一天的字元寬度。" -#: ../../library/calendar.rst:403 +#: ../../library/calendar.rst:408 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:409 +#: ../../library/calendar.rst:414 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 " @@ -555,11 +555,11 @@ msgstr "" "回傳代表一個月份日曆的矩陣。每一列為一週;該月以外的日期以 0 表示。每一週以週" "一開始,除非有使用 :func:`setfirstweekday` 改變設定。" -#: ../../library/calendar.rst:416 +#: ../../library/calendar.rst:421 msgid "Prints a month's calendar as returned by :func:`month`." msgstr "印出一個月份的日曆,跟 :func:`month` 回傳的內容一樣。" -#: ../../library/calendar.rst:421 +#: ../../library/calendar.rst:426 msgid "" "Returns a month's calendar in a multi-line string using " "the :meth:`~TextCalendar.formatmonth` of the :class:`TextCalendar` class." @@ -567,12 +567,12 @@ msgstr "" "以多行字串的形式回傳一個月的日曆,使用 :class:`TextCalendar` 類別" "的 :meth:`~TextCalendar.formatmonth`。" -#: ../../library/calendar.rst:427 +#: ../../library/calendar.rst:432 msgid "" "Prints the calendar for an entire year as returned by :func:`calendar`." msgstr "印出一整年的日曆,跟 :func:`calendar` 回傳的內容一樣。" -#: ../../library/calendar.rst:432 +#: ../../library/calendar.rst:437 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." @@ -580,7 +580,7 @@ msgstr "" "以多行字串回傳三欄形式的一整年日曆,使用 :class:`TextCalendar` 類別" "的 :meth:`~TextCalendar.formatyear`。" -#: ../../library/calendar.rst:438 +#: ../../library/calendar.rst:443 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 " @@ -593,29 +593,29 @@ msgstr "" "1970 開始及 POSIX 編碼。事實上,:func:`time.gmtime` 和 :func:`timegm` 是彼此" "相反的。" -#: ../../library/calendar.rst:445 +#: ../../library/calendar.rst:450 msgid "The :mod:`calendar` module exports the following data attributes:" msgstr ":mod:`calendar` 模組匯出以下資料屬性:" -#: ../../library/calendar.rst:449 +#: ../../library/calendar.rst:454 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:459 +#: ../../library/calendar.rst:464 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:474 +#: ../../library/calendar.rst:479 msgid "" "Aliases for the days of the week, where ``MONDAY`` is ``0`` and ``SUNDAY`` " "is ``6``." msgstr "一週每一天的別名,其中 ``MONDAY`` 是 ``0`` 而 ``SUNDAY`` 是 ``6``。" -#: ../../library/calendar.rst:482 +#: ../../library/calendar.rst:487 msgid "" "Enumeration defining days of the week as integer constants. The members of " "this enumeration are exported to the module scope as :data:`MONDAY` " @@ -624,7 +624,7 @@ msgstr "" "將一週中的幾天定義為整數常數的列舉。此列舉的成員將作為 :data:`MONDAY` " "到 :data:`SUNDAY` 匯出到模組作用域。" -#: ../../library/calendar.rst:491 +#: ../../library/calendar.rst:496 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 " @@ -633,7 +633,7 @@ msgstr "" "以目前語系來表示的一年每個月份名稱的序列。它按照一般慣例以數字 1 代表一月,因" "此它的長度為 13,而 ``month_name[0]`` 是空字串。" -#: ../../library/calendar.rst:502 +#: ../../library/calendar.rst:507 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,14 +642,14 @@ msgstr "" "以目前語系來表示的一年每個月份縮寫名稱的序列。它按照一般慣例以數字 1 代表一" "月,因此它的長度為 13,而 ``month_abbr[0]`` 是空字串。" -#: ../../library/calendar.rst:523 +#: ../../library/calendar.rst:528 msgid "" "Aliases for the months of the year, where ``JANUARY`` is ``1`` and " "``DECEMBER`` is ``12``." msgstr "" "一年內每個月的別名,其中 ``JANUARY`` 是 ``1`` 而 ``DECEMBER`` 是 ``12``。" -#: ../../library/calendar.rst:531 +#: ../../library/calendar.rst:536 msgid "" "Enumeration defining months of the year as integer constants. The members of " "this enumeration are exported to the module scope as :data:`JANUARY` " @@ -658,61 +658,61 @@ msgstr "" "將一年中的月份定義為整數常數的列舉。此列舉的成員將作為 :data:`JANUARY` " "到 :data:`DECEMBER` 匯出到模組作用域。" -#: ../../library/calendar.rst:538 +#: ../../library/calendar.rst:543 msgid "The :mod:`calendar` module defines the following exceptions:" msgstr ":mod:`calendar` 模組定義了以下例外:" -#: ../../library/calendar.rst:542 +#: ../../library/calendar.rst:547 msgid "" "A subclass of :exc:`ValueError`, raised when the given month number is " "outside of the range 1-12 (inclusive)." msgstr "" ":exc:`ValueError` 的子類別,當給定的月份數字超出 1-12 範圍(含)時引發。" -#: ../../library/calendar.rst:547 +#: ../../library/calendar.rst:552 msgid "The invalid month number." msgstr "無效的月份號。" -#: ../../library/calendar.rst:552 +#: ../../library/calendar.rst:557 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:557 +#: ../../library/calendar.rst:562 msgid "The invalid weekday number." msgstr "無效的週幾編號。" -#: ../../library/calendar.rst:562 +#: ../../library/calendar.rst:567 msgid "Module :mod:`datetime`" msgstr ":mod:`datetime` 模組" -#: ../../library/calendar.rst:563 +#: ../../library/calendar.rst:568 msgid "" "Object-oriented interface to dates and times with similar functionality to " "the :mod:`time` module." msgstr "日期與時間的物件導向介面,和 :mod:`time` 模組有相似的功能。" -#: ../../library/calendar.rst:566 +#: ../../library/calendar.rst:571 msgid "Module :mod:`time`" msgstr ":mod:`time` 模組" -#: ../../library/calendar.rst:567 +#: ../../library/calendar.rst:572 msgid "Low-level time related functions." msgstr "底層的時間相關函式。" -#: ../../library/calendar.rst:573 -msgid "Command-Line Usage" +#: ../../library/calendar.rst:578 +msgid "Command-line usage" msgstr "命令列用法" -#: ../../library/calendar.rst:577 +#: ../../library/calendar.rst:582 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:580 +#: ../../library/calendar.rst:585 msgid "" "python -m calendar [-h] [-L LOCALE] [-e ENCODING] [-t {text,html}]\n" " [-w WIDTH] [-l LINES] [-s SPACING] [-m MONTHS] [-c CSS]\n" @@ -722,11 +722,11 @@ msgstr "" " [-w WIDTH] [-l LINES] [-s SPACING] [-m MONTHS] [-c CSS]\n" " [-f FIRST_WEEKDAY] [year] [month]" -#: ../../library/calendar.rst:587 +#: ../../library/calendar.rst:592 msgid "For example, to print a calendar for the year 2000:" msgstr "例如,要列印 2000 年的日曆:" -#: ../../library/calendar.rst:589 +#: ../../library/calendar.rst:594 msgid "" "$ python -m calendar 2000\n" " 2000\n" @@ -804,40 +804,40 @@ 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:630 +#: ../../library/calendar.rst:635 msgid "The following options are accepted:" msgstr "接受以下選項:" -#: ../../library/calendar.rst:637 +#: ../../library/calendar.rst:642 msgid "Show the help message and exit." msgstr "顯示幫助訊息並退出。" -#: ../../library/calendar.rst:642 +#: ../../library/calendar.rst:647 msgid "The locale to use for month and weekday names. Defaults to English." msgstr "用於月份和週幾名稱的語系。預設為英語。" -#: ../../library/calendar.rst:648 +#: ../../library/calendar.rst:653 msgid "" "The encoding to use for output. :option:`--encoding` is required " "if :option:`--locale` is set." msgstr "" "用於輸出的編碼。如有設定 :option:`--locale` 則必須給定 :option:`--encoding`。" -#: ../../library/calendar.rst:654 +#: ../../library/calendar.rst:659 msgid "Print the calendar to the terminal as text, or as an HTML document." msgstr "將日曆以文字或 HTML 文件的形式印出到終端機。" -#: ../../library/calendar.rst:660 +#: ../../library/calendar.rst:665 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:668 +#: ../../library/calendar.rst:673 msgid "The year to print the calendar for. Defaults to the current year." msgstr "印出日曆的年份。預設為目前年份。" -#: ../../library/calendar.rst:674 +#: ../../library/calendar.rst:679 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 " @@ -846,11 +846,11 @@ msgstr "" "要列印日曆的指定 :option:`year` 的月份。必須是 1 到 12 之間的數字,並且只能在" "文字模式下使用。預設列印全年日曆。" -#: ../../library/calendar.rst:680 +#: ../../library/calendar.rst:685 msgid "*Text-mode options:*" msgstr "*文字模式選項:*" -#: ../../library/calendar.rst:684 +#: ../../library/calendar.rst:689 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." @@ -858,7 +858,7 @@ msgstr "" "終端機行中日期行的寬度。日期印出在行的中央。任何小於 2 的值都會被忽略。預設" "為 2。" -#: ../../library/calendar.rst:692 +#: ../../library/calendar.rst:697 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." @@ -866,21 +866,27 @@ msgstr "" "終端機列中每週的列數。日期印出時頂部會對齊。任何小於 1 的值都會被忽略。預設" "為 1。" -#: ../../library/calendar.rst:700 +#: ../../library/calendar.rst:705 msgid "" "The space between months in columns. Any value lower than 2 is ignored. " "Defaults to 6." msgstr "行中月份之間的間距。任何小於 2 的值都會被忽略。預設為 6。" -#: ../../library/calendar.rst:707 +#: ../../library/calendar.rst:712 msgid "The number of months printed per row. Defaults to 3." msgstr "每列印出的月份數量。預設為 3。" -#: ../../library/calendar.rst:711 +#: ../../library/calendar.rst:715 +msgid "" +"By default, today's date is highlighted in color and can be :ref:`controlled " +"using environment variables `." +msgstr "" + +#: ../../library/calendar.rst:719 msgid "*HTML-mode options:*" msgstr "*HTML 模式選項:*" -#: ../../library/calendar.rst:715 +#: ../../library/calendar.rst:723 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/cgi.po b/library/cgi.po index 5333d176a08..0731e1b5017 100644 --- a/library/cgi.po +++ b/library/cgi.po @@ -1,10 +1,10 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # #, fuzzy msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-11-18 00:15+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" diff --git a/library/cgitb.po b/library/cgitb.po index bc357c01bae..2e8508be52f 100644 --- a/library/cgitb.po +++ b/library/cgitb.po @@ -1,10 +1,10 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # #, fuzzy msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-11-18 00:15+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" diff --git a/library/chunk.po b/library/chunk.po index 981361eca29..2a720ed4241 100644 --- a/library/chunk.po +++ b/library/chunk.po @@ -1,10 +1,10 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # #, fuzzy msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-11-18 00:15+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" diff --git a/library/cmath.po b/library/cmath.po index 6d410bc6c96..1106996067f 100644 --- a/library/cmath.po +++ b/library/cmath.po @@ -1,12 +1,12 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-04-07 00:15+0000\n" +"POT-Creation-Date: 2025-10-15 00:16+0000\n" "PO-Revision-Date: 2024-03-14 09:26+0800\n" "Last-Translator: Enkai Huang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -33,9 +33,9 @@ msgid "" "result of the conversion." msgstr "" "本模組提供一些適用於複數的數學函式。本模組中的函式接受整數、浮點數或複數作為" -"引數。它們也接受任何具有 :meth:`~object.__complex__` " -"或 :meth:`~object.__float__` 方法的 Python 物件:這些方法分別用於將物件轉換為" -"複數或浮點數,然後再將函式應用於轉換後的結果。" +"引數。它們也接受任何具有 :meth:`~object.__complex__` 或 :meth:`~object." +"__float__` 方法的 Python 物件:這些方法分別用於將物件轉換為複數或浮點數,然後" +"再將函式應用於轉換後的結果。" #: ../../library/cmath.rst:18 msgid "" @@ -56,34 +56,33 @@ msgstr "" #: ../../library/cmath.rst:26 msgid "" "For example, the :func:`cmath.sqrt` function has a branch cut along the " -"negative real axis. An argument of ``complex(-2.0, -0.0)`` is treated as " -"though it lies *below* the branch cut, and so gives a result on the negative " -"imaginary axis::" +"negative real axis. An argument of ``-2-0j`` is treated as though it lies " +"*below* the branch cut, and so gives a result on the negative imaginary " +"axis::" msgstr "" -"例如 :func:`cmath.sqrt` 函式具有一條沿負實軸的分枝切割。 引數 " -"``complex(-2.0, -0.0)`` 被視為位於分枝切割 *下方* 處理,因此給出的結果在負虛" -"軸上: ::" +"例如 :func:`cmath.sqrt` 函式具有一條沿負實軸的分枝切割。 引數 ``-2-0j`` 被視" +"為位於分枝切割 *下方* 處理,因此給出的結果在負虛軸上: ::" #: ../../library/cmath.rst:31 msgid "" -">>> cmath.sqrt(complex(-2.0, -0.0))\n" +">>> cmath.sqrt(-2-0j)\n" "-1.4142135623730951j" msgstr "" -">>> cmath.sqrt(complex(-2.0, -0.0))\n" +">>> cmath.sqrt(-2-0j)\n" "-1.4142135623730951j" #: ../../library/cmath.rst:34 msgid "" -"But an argument of ``complex(-2.0, 0.0)`` is treated as though it lies above " -"the branch cut::" -msgstr "但是引數 ``complex(-2.0, 0.0)`` 會被當成位於分枝切割上方處理: ::" +"But an argument of ``-2+0j`` is treated as though it lies above the branch " +"cut::" +msgstr "但是引數 ``-2+0j`` 會被當成位於分枝切割上方處理: ::" #: ../../library/cmath.rst:37 msgid "" -">>> cmath.sqrt(complex(-2.0, 0.0))\n" +">>> cmath.sqrt(-2+0j)\n" "1.4142135623730951j" msgstr "" -">>> cmath.sqrt(complex(-2.0, 0.0))\n" +">>> cmath.sqrt(-2+0j)\n" "1.4142135623730951j" #: ../../library/cmath.rst:42 @@ -357,8 +356,8 @@ msgstr "轉換到極座標和從極座標做轉換" #: ../../library/cmath.rst:95 msgid "" "A Python complex number ``z`` is stored internally using *rectangular* or " -"*Cartesian* coordinates. It is completely determined by its *real part* " -"``z.real`` and its *imaginary part* ``z.imag``." +"*Cartesian* coordinates. It is completely determined by its *real part* ``z." +"real`` and its *imaginary part* ``z.imag``." msgstr "" "Python 複數 ``z`` 是用 *直角坐標* 或 *笛卡爾坐標* 儲存在內部的。它完全是由其 " "*實部* ``z.real`` 和 *虛部* ``z.imag`` 所決定。" @@ -392,19 +391,19 @@ msgid "" msgstr "" "以浮點數的形式回傳 *z* 的相位角(也稱為 *z* 的 *引數* )。``phase(z)`` 等價" "於 ``math.atan2(z.imag, z.real)``。結果將位於 [-\\ *π*, *π*] 的範圍內,且此操" -"作的分枝切割將位於負實軸上。結果的符號會與 ``z.imag`` 的符號相同,即使 " -"``z.imag`` 為零: ::" +"作的分枝切割將位於負實軸上。結果的符號會與 ``z.imag`` 的符號相同,即使 ``z." +"imag`` 為零: ::" #: ../../library/cmath.rst:117 msgid "" -">>> phase(complex(-1.0, 0.0))\n" +">>> phase(-1+0j)\n" "3.141592653589793\n" -">>> phase(complex(-1.0, -0.0))\n" +">>> phase(-1-0j)\n" "-3.141592653589793" msgstr "" -">>> phase(complex(-1.0, 0.0))\n" +">>> phase(-1+0j)\n" "3.141592653589793\n" -">>> phase(complex(-1.0, -0.0))\n" +">>> phase(-1-0j)\n" "-3.141592653589793" #: ../../library/cmath.rst:125 @@ -413,8 +412,8 @@ msgid "" "the built-in :func:`abs` function. There is no separate :mod:`cmath` module " "function for this operation." msgstr "" -"複數 *z* 的絕對值可以使用內建的 :func:`abs` 函式計算。沒有單獨" -"的 :mod:`cmath` 模組函式適用於此操作。" +"複數 *z* 的絕對值可以使用內建的 :func:`abs` 函式計算。沒有單獨的 :mod:" +"`cmath` 模組函式適用於此操作。" #: ../../library/cmath.rst:132 msgid "" @@ -454,8 +453,8 @@ msgstr "" #: ../../library/cmath.rst:162 msgid "" -"Return the base-10 logarithm of *z*. This has the same branch cut " -"as :func:`log`." +"Return the base-10 logarithm of *z*. This has the same branch cut as :func:" +"`log`." msgstr "回傳 *z* 以 10 為底的對數。它與 :func:`log` 具有相同的分枝切割。" #: ../../library/cmath.rst:168 @@ -647,8 +646,8 @@ msgstr "實部為零和虛部為正無窮的複數。相當於 ``complex(0.0, fl #: ../../library/cmath.rst:340 msgid "" "A floating-point \"not a number\" (NaN) value. Equivalent to " -"``float('nan')``." -msgstr "浮點「非數字」 (NaN) 值。相當於 ``float('nan')``。" +"``float('nan')``. See also :data:`math.nan`." +msgstr "浮點「非數字」 (NaN) 值。相當於 ``float('nan')``。另請參閱 :data:`math.nan`。" #: ../../library/cmath.rst:348 msgid "" @@ -662,16 +661,15 @@ msgid "" "in module :mod:`math`. The reason for having two modules is that some users " "aren't interested in complex numbers, and perhaps don't even know what they " "are. They would rather have ``math.sqrt(-1)`` raise an exception than " -"return a complex number. Also note that the functions defined " -"in :mod:`cmath` always return a complex number, even if the answer can be " -"expressed as a real number (in which case the complex number has an " -"imaginary part of zero)." +"return a complex number. Also note that the functions defined in :mod:" +"`cmath` always return a complex number, even if the answer can be expressed " +"as a real number (in which case the complex number has an imaginary part of " +"zero)." msgstr "" "請注意,函式的選擇與模組 :mod:`math` 的類似,但並不完全相同。擁有兩個模組的原" -"因是有些用戶對複數不感興趣,甚至根本就不知道它們是什麼。他們寧願讓 " -"``math.sqrt(-1)`` 引發異常,也不願它回傳複數。另請注意, :mod:`cmath` 中所定" -"義的函式始終都會回傳複數,即使答案可以表示為實數(在這種情況下,複數的虛部為" -"零)。" +"因是有些用戶對複數不感興趣,甚至根本就不知道它們是什麼。他們寧願讓 ``math." +"sqrt(-1)`` 引發異常,也不願它回傳複數。另請注意, :mod:`cmath` 中所定義的函式" +"始終都會回傳複數,即使答案可以表示為實數(在這種情況下,複數的虛部為零)。" #: ../../library/cmath.rst:364 msgid "" diff --git a/library/cmd.po b/library/cmd.po index 347b67d8923..219ddb51b8a 100644 --- a/library/cmd.po +++ b/library/cmd.po @@ -1,12 +1,11 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Dr-XYZ , 2025 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-23 07:52+0800\n" "PO-Revision-Date: 2025-05-19 20:25+0800\n" diff --git a/library/cmdline.po b/library/cmdline.po index aea947803ea..0c92f34f261 100644 --- a/library/cmdline.po +++ b/library/cmdline.po @@ -1,13 +1,13 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Matt Wang , 2023 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-05-04 00:16+0000\n" +"POT-Creation-Date: 2025-11-18 00:15+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-" @@ -17,218 +17,214 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: ../../library/cmdline.rst:3 +#: ../../library/cmdline.rst:5 msgid "Modules command-line interface (CLI)" msgstr "模組命令列介面" -#: ../../library/cmdline.rst:5 +#: ../../library/cmdline.rst:7 msgid "The following modules have a command-line interface." msgstr "以下模組具有命令列介面。" -#: ../../library/cmdline.rst:7 +#: ../../library/cmdline.rst:9 msgid ":ref:`ast `" msgstr ":ref:`ast `" -#: ../../library/cmdline.rst:8 +#: ../../library/cmdline.rst:10 msgid ":ref:`asyncio `" msgstr ":ref:`asyncio `" -#: ../../library/cmdline.rst:9 +#: ../../library/cmdline.rst:11 msgid ":mod:`base64`" msgstr ":mod:`base64`" -#: ../../library/cmdline.rst:10 +#: ../../library/cmdline.rst:12 msgid ":ref:`calendar `" msgstr ":ref:`calendar `" -#: ../../library/cmdline.rst:11 +#: ../../library/cmdline.rst:13 msgid ":mod:`code`" msgstr ":mod:`code`" -#: ../../library/cmdline.rst:12 +#: ../../library/cmdline.rst:14 msgid ":ref:`compileall `" msgstr ":ref:`compileall `" -#: ../../library/cmdline.rst:13 +#: ../../library/cmdline.rst:15 msgid ":mod:`cProfile`: see :ref:`profile `" msgstr ":mod:`cProfile`: 請見 :ref:`profile `" -#: ../../library/cmdline.rst:14 -msgid ":ref:`difflib `" -msgstr ":ref:`difflib `" - -#: ../../library/cmdline.rst:15 +#: ../../library/cmdline.rst:16 msgid ":ref:`dis `" msgstr ":ref:`dis `" -#: ../../library/cmdline.rst:16 +#: ../../library/cmdline.rst:17 msgid ":ref:`doctest `" msgstr ":ref:`doctest `" -#: ../../library/cmdline.rst:17 +#: ../../library/cmdline.rst:18 msgid ":mod:`!encodings.rot_13`" msgstr ":mod:`!encodings.rot_13`" -#: ../../library/cmdline.rst:18 -msgid ":mod:`ensurepip`" -msgstr ":mod:`ensurepip`" - #: ../../library/cmdline.rst:19 +msgid ":ref:`ensurepip `" +msgstr ":ref:`ensurepip `" + +#: ../../library/cmdline.rst:20 msgid ":mod:`filecmp`" msgstr ":mod:`filecmp`" -#: ../../library/cmdline.rst:20 +#: ../../library/cmdline.rst:21 msgid ":mod:`fileinput`" msgstr ":mod:`fileinput`" -#: ../../library/cmdline.rst:21 +#: ../../library/cmdline.rst:22 msgid ":mod:`ftplib`" msgstr ":mod:`ftplib`" -#: ../../library/cmdline.rst:22 +#: ../../library/cmdline.rst:23 msgid ":ref:`gzip `" msgstr ":ref:`gzip `" -#: ../../library/cmdline.rst:23 +#: ../../library/cmdline.rst:24 msgid ":ref:`http.server `" msgstr ":ref:`http.server `" -#: ../../library/cmdline.rst:24 -msgid ":mod:`!idlelib`" -msgstr ":mod:`!idlelib`" - #: ../../library/cmdline.rst:25 -msgid ":ref:`inspect `" -msgstr ":ref:`inspect `" +msgid ":ref:`idlelib `" +msgstr ":ref:`idlelib `" #: ../../library/cmdline.rst:26 -msgid ":ref:`json.tool `" -msgstr ":ref:`json.tool `" +msgid ":ref:`inspect `" +msgstr ":ref:`inspect `" #: ../../library/cmdline.rst:27 -msgid ":mod:`mimetypes`" -msgstr ":mod:`mimetypes`" +msgid ":ref:`json `" +msgstr ":ref:`json `" #: ../../library/cmdline.rst:28 -msgid ":mod:`pdb`" -msgstr ":mod:`pdb`" +msgid ":ref:`mimetypes `" +msgstr ":ref:`mimetypes `" #: ../../library/cmdline.rst:29 -msgid ":mod:`pickle`" -msgstr ":mod:`pickle`" +msgid ":ref:`pdb `" +msgstr ":ref:`pdb `" #: ../../library/cmdline.rst:30 +msgid ":ref:`pickle `" +msgstr ":ref:`pickle `" + +#: ../../library/cmdline.rst:31 msgid ":ref:`pickletools `" msgstr ":ref:`pickletools `" -#: ../../library/cmdline.rst:31 +#: ../../library/cmdline.rst:32 msgid ":ref:`platform `" msgstr ":ref:`platform `" -#: ../../library/cmdline.rst:32 +#: ../../library/cmdline.rst:33 msgid ":mod:`poplib`" msgstr ":mod:`poplib`" -#: ../../library/cmdline.rst:33 +#: ../../library/cmdline.rst:34 msgid ":ref:`profile `" msgstr ":ref:`profile `" -#: ../../library/cmdline.rst:34 +#: ../../library/cmdline.rst:35 msgid ":mod:`pstats`" msgstr ":mod:`pstats`" -#: ../../library/cmdline.rst:35 +#: ../../library/cmdline.rst:36 msgid ":ref:`py_compile `" msgstr ":ref:`py_compile `" -#: ../../library/cmdline.rst:36 +#: ../../library/cmdline.rst:37 msgid ":mod:`pyclbr`" msgstr ":mod:`pyclbr`" -#: ../../library/cmdline.rst:37 +#: ../../library/cmdline.rst:38 msgid ":mod:`pydoc`" msgstr ":mod:`pydoc`" -#: ../../library/cmdline.rst:38 +#: ../../library/cmdline.rst:39 msgid ":mod:`quopri`" msgstr ":mod:`quopri`" -#: ../../library/cmdline.rst:39 +#: ../../library/cmdline.rst:40 msgid ":ref:`random `" msgstr ":ref:`random `" -#: ../../library/cmdline.rst:40 +#: ../../library/cmdline.rst:41 msgid ":mod:`runpy`" msgstr ":mod:`runpy`" -#: ../../library/cmdline.rst:41 +#: ../../library/cmdline.rst:42 msgid ":ref:`site `" msgstr ":ref:`site `" -#: ../../library/cmdline.rst:42 +#: ../../library/cmdline.rst:43 msgid ":ref:`sqlite3 `" msgstr ":ref:`sqlite3 `" -#: ../../library/cmdline.rst:43 +#: ../../library/cmdline.rst:44 msgid ":ref:`symtable `" msgstr ":ref:`symtable `" -#: ../../library/cmdline.rst:44 +#: ../../library/cmdline.rst:45 msgid ":ref:`sysconfig `" msgstr ":ref:`sysconfig `" -#: ../../library/cmdline.rst:45 +#: ../../library/cmdline.rst:46 msgid ":mod:`tabnanny`" msgstr ":mod:`tabnanny`" -#: ../../library/cmdline.rst:46 +#: ../../library/cmdline.rst:47 msgid ":ref:`tarfile `" msgstr ":ref:`tarfile `" -#: ../../library/cmdline.rst:47 +#: ../../library/cmdline.rst:48 msgid ":mod:`!this`" msgstr ":mod:`!this`" -#: ../../library/cmdline.rst:48 +#: ../../library/cmdline.rst:49 msgid ":ref:`timeit `" msgstr ":ref:`timeit `" -#: ../../library/cmdline.rst:49 +#: ../../library/cmdline.rst:50 msgid ":ref:`tokenize `" msgstr ":ref:`tokenize `" -#: ../../library/cmdline.rst:50 +#: ../../library/cmdline.rst:51 msgid ":ref:`trace `" msgstr ":ref:`trace `" -#: ../../library/cmdline.rst:51 +#: ../../library/cmdline.rst:52 msgid ":mod:`turtledemo`" msgstr ":mod:`turtledemo`" -#: ../../library/cmdline.rst:52 +#: ../../library/cmdline.rst:53 msgid ":ref:`unittest `" msgstr ":ref:`unittest `" -#: ../../library/cmdline.rst:53 +#: ../../library/cmdline.rst:54 msgid ":ref:`uuid `" msgstr ":ref:`uuid `" -#: ../../library/cmdline.rst:54 -msgid ":mod:`venv`" -msgstr ":mod:`venv`" - #: ../../library/cmdline.rst:55 -msgid ":mod:`webbrowser`" -msgstr ":mod:`webbrowser`" +msgid ":ref:`venv `" +msgstr ":ref:`venv `" #: ../../library/cmdline.rst:56 +msgid ":ref:`webbrowser `" +msgstr ":ref:`webbrowser `" + +#: ../../library/cmdline.rst:57 msgid ":ref:`zipapp `" msgstr ":ref:`zipapp `" -#: ../../library/cmdline.rst:57 +#: ../../library/cmdline.rst:58 msgid ":ref:`zipfile `" msgstr ":ref:`zipfile `" -#: ../../library/cmdline.rst:59 +#: ../../library/cmdline.rst:60 msgid "See also the :ref:`Python command-line interface `." msgstr "另請見 :ref:`Python 命令列介面 `。" diff --git a/library/cmdlinelibs.po b/library/cmdlinelibs.po index 7cce8dba348..ffd411006fa 100644 --- a/library/cmdlinelibs.po +++ b/library/cmdlinelibs.po @@ -1,11 +1,11 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# 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.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2025-08-16 00:16+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" diff --git a/library/code.po b/library/code.po index 108750d7908..ab57c96d384 100644 --- a/library/code.po +++ b/library/code.po @@ -1,13 +1,13 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Matt Wang , 2025 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"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: 2025-09-08 15:25+0800\n" "PO-Revision-Date: 2025-07-13 14:40+0000\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -32,8 +32,8 @@ msgid "" "in Python. Two classes and convenience functions are included which can be " "used to build applications which provide an interactive interpreter prompt." msgstr "" -"``code`` 模組提供在 Python 中實作讀取-求值-印出迴圈(read-eval-print loops)的" -"設施。包含兩個類別和便利函式,可用於建立提供互動式直譯器提示的應用程式。" +"``code`` 模組提供在 Python 中實作讀取-求值-印出迴圈(read-eval-print loops)" +"的設施。包含兩個類別和便利函式,可用於建立提供互動式直譯器提示的應用程式。" #: ../../library/code.rst:18 msgid "" @@ -65,8 +65,8 @@ msgid "" "Closely emulate the behavior of the interactive Python interpreter. This " "class builds on :class:`InteractiveInterpreter` and adds prompting using the " "familiar ``sys.ps1`` and ``sys.ps2``, and input buffering. If *local_exit* " -"is true, ``exit()`` and ``quit()`` in the console will not raise :exc:" -"`SystemExit`, but instead return to the calling code." +"is true, ``exit()`` and ``quit()`` in the console will not " +"raise :exc:`SystemExit`, but instead return to the calling code." msgstr "" "近似地模擬出互動式 Python 直譯器的行為。這個類別建立" "在 :class:`InteractiveInterpreter` 的基礎上,並加入使用熟悉的 ``sys.ps1`` 和 " @@ -84,9 +84,9 @@ msgid "" "the :meth:`InteractiveConsole.raw_input` method, if provided. If *local* is " "provided, it is passed to the :class:`InteractiveConsole` constructor for " "use as the default namespace for the interpreter loop. If *local_exit* is " -"provided, it is passed to the :class:`InteractiveConsole` constructor. The :" -"meth:`~InteractiveConsole.interact` method of the instance is then run with " -"*banner* and *exitmsg* passed as the banner and exit message to use, if " +"provided, it is passed to the :class:`InteractiveConsole` constructor. " +"The :meth:`~InteractiveConsole.interact` method of the instance is then run " +"with *banner* and *exitmsg* passed as the banner and exit message to use, if " "provided. The console object is discarded after use." msgstr "" "執行 read-eval-print 迴圈的便利函式。這會建立一" @@ -102,7 +102,7 @@ msgstr "" msgid "Added *exitmsg* parameter." msgstr "新增 *exitmsg* 參數。" -#: ../../library/code.rst:57 +#: ../../library/code.rst:63 msgid "" "This function is useful for programs that want to emulate Python's " "interpreter main loop (a.k.a. the read-eval-print loop). The tricky part is " @@ -156,10 +156,10 @@ msgstr "" #: ../../library/code.rst:94 msgid "" -"The input is incorrect; :func:`compile_command` raised an exception (:exc:" -"`SyntaxError` or :exc:`OverflowError`). A syntax traceback will be printed " -"by calling the :meth:`showsyntaxerror` method. :meth:`runsource` returns " -"``False``." +"The input is incorrect; :func:`compile_command` raised an exception " +"(:exc:`SyntaxError` or :exc:`OverflowError`). A syntax traceback will be " +"printed by calling the :meth:`showsyntaxerror` method. :meth:`runsource` " +"returns ``False``." msgstr "" "輸入不正確;:func:`compile_command` 會引發例外(:exc:`SyntaxError` " "或 :exc:`OverflowError`)。語法回溯 (syntax traceback) 會透過呼" @@ -184,23 +184,17 @@ msgstr "" "叫 :meth:`runcode` 執行(它也會處理執行時的例外,除 :exc:`SystemExit` 以" "外)。:meth:`runsource` 會回傳 ``False``。" -#: ../../library/code.rst:100 +#: ../../library/code.rst:106 msgid "" "The return value can be used to decide whether to use ``sys.ps1`` or " "``sys.ps2`` to prompt the next line." msgstr "回傳值可用來決定是使用 ``sys.ps1`` 還是 ``sys.ps2`` 以提示下一列。" -#: ../../library/code.rst:106 -msgid "" -"The return value can be used to decide whether to use ``sys.ps1`` or ``sys." -"ps2`` to prompt the next line." -msgstr "回傳值可用來決定是使用 ``sys.ps1`` 還是 ``sys.ps2`` 以提示下一列。" - #: ../../library/code.rst:112 msgid "" "Execute a code object. When an exception occurs, :meth:`showtraceback` is " -"called to display a traceback. All exceptions are caught except :exc:" -"`SystemExit`, which is allowed to propagate." +"called to display a traceback. All exceptions are caught " +"except :exc:`SystemExit`, which is allowed to propagate." msgstr "" "執行程式碼物件。當例外發生時,會呼叫 :meth:`showtraceback` 來顯示回溯。除" "了 :exc:`SystemExit` 允許繼續傳播之外,所有的例外都會被捕獲。" @@ -214,7 +208,7 @@ msgstr "" "關於 :exc:`KeyboardInterrupt` 的注意事項:此例外可能發生在此程式碼的其他地" "方,而且不一定會被捕獲到。呼叫者應該準備好處理它。" -#: ../../library/code.rst:117 +#: ../../library/code.rst:123 msgid "" "Display the syntax error that just occurred. This does not display a stack " "trace because there isn't one for syntax errors. If *filename* is given, it " @@ -222,11 +216,12 @@ msgid "" "Python's parser, because it always uses ``''`` when reading from a " "string. The output is written by the :meth:`write` method." msgstr "" -"顯示剛剛發生的語法錯誤。這不會顯示堆疊追蹤 (stack trace),因為語法錯誤沒有堆疊追蹤。" -"如果給出 *filename*,它會被塞入例外,而不是 Python 剖析器提供的預設檔案名稱,因為它" -"從字串讀取時總是使用 ``''``。輸出會由 :meth:`write` 方法寫入。" +"顯示剛剛發生的語法錯誤。這不會顯示堆疊追蹤 (stack trace),因為語法錯誤沒有堆" +"疊追蹤。如果給出 *filename*,它會被塞入例外,而不是 Python 剖析器提供的預設檔" +"案名稱,因為它從字串讀取時總是使用 ``''``。輸出會由 :meth:`write` 方" +"法寫入。" -#: ../../library/code.rst:126 +#: ../../library/code.rst:132 msgid "" "Display the exception that just occurred. We remove the first stack item " "because it is within the interpreter object implementation. The output is " @@ -235,7 +230,7 @@ msgstr "" "顯示剛剛發生的例外。我們移除第一個堆疊項目,因為它在直譯器物件的實作範圍內。" "輸出由 :meth:`write` 方法寫入。" -#: ../../library/code.rst:130 +#: ../../library/code.rst:136 msgid "" "The full chained traceback is displayed instead of just the primary " "traceback." @@ -254,16 +249,16 @@ msgstr "" msgid "Interactive Console Objects" msgstr "互動式控制台物件" -#: ../../library/code.rst:145 +#: ../../library/code.rst:151 msgid "" -"The :class:`InteractiveConsole` class is a subclass of :class:" -"`InteractiveInterpreter`, and so offers all the methods of the interpreter " -"objects as well as the following additions." +"The :class:`InteractiveConsole` class is a subclass " +"of :class:`InteractiveInterpreter`, and so offers all the methods of the " +"interpreter objects as well as the following additions." msgstr "" ":class:`InteractiveConsole` 類別是 :class:`InteractiveInterpreter` 的子類別," "因此提供了所有直譯器物件的方法以及下列新增的功能。" -#: ../../library/code.rst:152 +#: ../../library/code.rst:158 msgid "" "Closely emulate the interactive Python console. The optional *banner* " "argument specify the banner to print before the first interaction; by " @@ -273,10 +268,10 @@ msgid "" "close!)." msgstr "" "近似地模擬互動式 Python 控制台。可選的 *banner* 引數指定在第一次互動之前要印" -"出的横幅;預設會印出類似標準 Python 直譯器所列印的横幅,接著是控制台物" -"件在括弧中的類別名稱 (以免與真正的直譯器混淆 -- 因為它是如此接近!)。" +"出的横幅;預設會印出類似標準 Python 直譯器所列印的横幅,接著是控制台物件在括" +"弧中的類別名稱 (以免與真正的直譯器混淆 -- 因為它是如此接近!)。" -#: ../../library/code.rst:158 +#: ../../library/code.rst:164 msgid "" "The optional *exitmsg* argument specifies an exit message printed when " "exiting. Pass the empty string to suppress the exit message. If *exitmsg* is " @@ -293,7 +288,7 @@ msgstr "若要抑制印出任何橫幅,請傳入空字串。" msgid "Print an exit message when exiting." msgstr "退出時印出退出訊息。" -#: ../../library/code.rst:171 +#: ../../library/code.rst:177 msgid "" "Push a line of source text to the interpreter. The line should not have a " "trailing newline; it may have internal newlines. The line is appended to a " @@ -305,24 +300,25 @@ msgid "" "is required, ``False`` if the line was dealt with in some way (this is the " "same as :meth:`!runsource`)." msgstr "" -"推送一行原始文字到直譯器。這一行不應該有尾部換行符號;它可能有內部換行符號。這行文字" -"會被附加到緩衝區,並且直譯器的 :meth:`~InteractiveInterpreter.runsource` 方法" -"會被呼叫,並以緩衝區的串接內容做為原始碼。如果這表示命令已執行或無效,緩衝區" -"會被重設;否則,命令會不完整,且緩衝區會保持該行被附加後的樣子。如果需要更多的輸" -"入,回傳值是 ``True``,如果該行已經以某種方式處理,回傳值是 ``False``\\ (這" -"與 :meth:`!runsource` 相同)。" - -#: ../../library/code.rst:183 +"推送一行原始文字到直譯器。這一行不應該有尾部換行符號;它可能有內部換行符號。" +"這行文字會被附加到緩衝區,並且直譯器" +"的 :meth:`~InteractiveInterpreter.runsource` 方法會被呼叫,並以緩衝區的串接內" +"容做為原始碼。如果這表示命令已執行或無效,緩衝區會被重設;否則,命令會不完" +"整,且緩衝區會保持該行被附加後的樣子。如果需要更多的輸入,回傳值是 ``True``," +"如果該行已經以某種方式處理,回傳值是 ``False``\\ (這與 :meth:`!runsource` 相" +"同)。" + +#: ../../library/code.rst:189 msgid "Remove any unhandled source text from the input buffer." msgstr "從輸入緩衝區移除任何未處理的原始文字。" -#: ../../library/code.rst:188 +#: ../../library/code.rst:194 msgid "" "Write a prompt and read a line. The returned line does not include the " -"trailing newline. When the user enters the EOF key sequence, :exc:" -"`EOFError` is raised. The base implementation reads from ``sys.stdin``; a " -"subclass may replace this with a different implementation." +"trailing newline. When the user enters the EOF key " +"sequence, :exc:`EOFError` is raised. The base implementation reads from " +"``sys.stdin``; a subclass may replace this with a different implementation." msgstr "" -"寫入一個提示並讀取一行。回傳的行不包括尾部的換行符號。當使用者輸入 EOF 鍵序時," -"會引發 :exc:`EOFError`。基底實作會從 ``sys.stdin`` 讀取;子類別可以用不同的實作" -"替代。" +"寫入一個提示並讀取一行。回傳的行不包括尾部的換行符號。當使用者輸入 EOF 鍵序" +"時,會引發 :exc:`EOFError`。基底實作會從 ``sys.stdin`` 讀取;子類別可以用不同" +"的實作替代。" diff --git a/library/codecs.po b/library/codecs.po index 0316e8e6121..f1d8d60966f 100644 --- a/library/codecs.po +++ b/library/codecs.po @@ -1,12 +1,12 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-08-06 00:17+0000\n" +"POT-Creation-Date: 2025-12-01 00:17+0000\n" "PO-Revision-Date: 2018-05-23 14:40+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -260,14 +260,18 @@ msgstr "" msgid "The ``'U'`` mode has been removed." msgstr "已移除 ``'U'`` 模式。" -#: ../../library/codecs.rst:222 +#: ../../library/codecs.rst:221 +msgid ":func:`codecs.open` has been superseded by :func:`open`." +msgstr "" + +#: ../../library/codecs.rst:226 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:226 +#: ../../library/codecs.rst:230 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 " @@ -275,18 +279,18 @@ msgid "" "*file_encoding*, and the result is encoded using *data_encoding*." msgstr "" -#: ../../library/codecs.rst:232 +#: ../../library/codecs.rst:236 msgid "If *file_encoding* is not given, it defaults to *data_encoding*." msgstr "" -#: ../../library/codecs.rst:234 +#: ../../library/codecs.rst:238 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:241 +#: ../../library/codecs.rst:245 msgid "" "Uses an incremental encoder to iteratively encode the input provided by " "*iterator*. *iterator* must yield :class:`str` objects. This function is a :" @@ -294,14 +298,14 @@ msgid "" "argument) is passed through to the incremental encoder." msgstr "" -#: ../../library/codecs.rst:246 +#: ../../library/codecs.rst:250 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:253 +#: ../../library/codecs.rst:257 msgid "" "Uses an incremental decoder to iteratively decode the input provided by " "*iterator*. *iterator* must yield :class:`bytes` objects. This function is " @@ -309,7 +313,7 @@ msgid "" "argument) is passed through to the incremental decoder." msgstr "" -#: ../../library/codecs.rst:258 +#: ../../library/codecs.rst:262 msgid "" "This function requires that the codec accept :class:`bytes` objects to " "decode. Therefore it does not support text-to-text encoders such as " @@ -317,18 +321,18 @@ msgid "" "`iterencode`." msgstr "" -#: ../../library/codecs.rst:266 +#: ../../library/codecs.rst:270 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:270 +#: ../../library/codecs.rst:274 msgid "The *errors* argument is ignored." msgstr "忽略 *errors* 引數。" -#: ../../library/codecs.rst:272 +#: ../../library/codecs.rst:276 msgid "" ">>> codecs.readbuffer_encode(b\"Zito\")\n" "(b'Zito', 4)" @@ -336,13 +340,13 @@ msgstr "" ">>> codecs.readbuffer_encode(b\"Zito\")\n" "(b'Zito', 4)" -#: ../../library/codecs.rst:278 +#: ../../library/codecs.rst:282 msgid "" "The module also provides the following constants which are useful for " "reading and writing to platform dependent files:" msgstr "" -#: ../../library/codecs.rst:293 +#: ../../library/codecs.rst:297 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 " @@ -354,18 +358,18 @@ msgid "" "represent the BOM in UTF-8 and UTF-32 encodings." msgstr "" -#: ../../library/codecs.rst:307 +#: ../../library/codecs.rst:311 msgid "Codec Base Classes" msgstr "" -#: ../../library/codecs.rst:309 +#: ../../library/codecs.rst:313 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:313 +#: ../../library/codecs.rst:317 msgid "" "Each codec has to define four interfaces to make it usable as codec in " "Python: stateless encoder, stateless decoder, stream reader and stream " @@ -374,69 +378,69 @@ msgid "" "how the codec will handle encoding and decoding errors." msgstr "" -#: ../../library/codecs.rst:324 +#: ../../library/codecs.rst:328 msgid "Error Handlers" msgstr "" -#: ../../library/codecs.rst:326 +#: ../../library/codecs.rst:330 msgid "" "To simplify and standardize error handling, codecs may implement different " "error handling schemes by accepting the *errors* string argument:" msgstr "" -#: ../../library/codecs.rst:346 +#: ../../library/codecs.rst:350 msgid "" "The following error handlers can be used with all Python :ref:`standard-" "encodings` codecs:" msgstr "" -#: ../../library/codecs.rst:352 ../../library/codecs.rst:395 -#: ../../library/codecs.rst:415 +#: ../../library/codecs.rst:356 ../../library/codecs.rst:399 +#: ../../library/codecs.rst:419 msgid "Value" msgstr "" -#: ../../library/codecs.rst:352 ../../library/codecs.rst:395 -#: ../../library/codecs.rst:415 ../../library/codecs.rst:1360 -#: ../../library/codecs.rst:1432 ../../library/codecs.rst:1517 +#: ../../library/codecs.rst:356 ../../library/codecs.rst:399 +#: ../../library/codecs.rst:419 ../../library/codecs.rst:1376 +#: ../../library/codecs.rst:1448 ../../library/codecs.rst:1533 msgid "Meaning" msgstr "含義" -#: ../../library/codecs.rst:354 +#: ../../library/codecs.rst:358 msgid "``'strict'``" msgstr "``'strict'``" -#: ../../library/codecs.rst:354 +#: ../../library/codecs.rst:358 msgid "" "Raise :exc:`UnicodeError` (or a subclass), this is the default. Implemented " "in :func:`strict_errors`." msgstr "" -#: ../../library/codecs.rst:358 +#: ../../library/codecs.rst:362 msgid "``'ignore'``" msgstr "``'ignore'``" -#: ../../library/codecs.rst:358 +#: ../../library/codecs.rst:362 msgid "" "Ignore the malformed data and continue without further notice. Implemented " "in :func:`ignore_errors`." msgstr "" -#: ../../library/codecs.rst:362 +#: ../../library/codecs.rst:366 msgid "``'replace'``" msgstr "``'replace'``" -#: ../../library/codecs.rst:362 +#: ../../library/codecs.rst:366 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:368 +#: ../../library/codecs.rst:372 msgid "``'backslashreplace'``" msgstr "``'backslashreplace'``" -#: ../../library/codecs.rst:368 +#: ../../library/codecs.rst:372 msgid "" "Replace with backslashed escape sequences. On encoding, use hexadecimal form " "of Unicode code point with formats :samp:`\\\\x{hh}` :samp:`\\\\u{xxxx}` :" @@ -444,11 +448,11 @@ msgid "" "format :samp:`\\\\x{hh}`. Implemented in :func:`backslashreplace_errors`." msgstr "" -#: ../../library/codecs.rst:377 +#: ../../library/codecs.rst:381 msgid "``'surrogateescape'``" msgstr "``'surrogateescape'``" -#: ../../library/codecs.rst:377 +#: ../../library/codecs.rst:381 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 " @@ -456,92 +460,92 @@ msgid "" "data. (See :pep:`383` for more.)" msgstr "" -#: ../../library/codecs.rst:391 +#: ../../library/codecs.rst:395 msgid "" "The following error handlers are only applicable to encoding (within :term:" "`text encodings `):" msgstr "" -#: ../../library/codecs.rst:397 +#: ../../library/codecs.rst:401 msgid "``'xmlcharrefreplace'``" msgstr "``'xmlcharrefreplace'``" -#: ../../library/codecs.rst:397 +#: ../../library/codecs.rst:401 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:403 +#: ../../library/codecs.rst:407 msgid "``'namereplace'``" msgstr "``'namereplace'``" -#: ../../library/codecs.rst:403 +#: ../../library/codecs.rst:407 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:412 +#: ../../library/codecs.rst:416 msgid "" "In addition, the following error handler is specific to the given codecs:" msgstr "" -#: ../../library/codecs.rst:13 ../../library/codecs.rst:415 +#: ../../library/codecs.rst:13 ../../library/codecs.rst:419 msgid "Codecs" msgstr "" -#: ../../library/codecs.rst:417 +#: ../../library/codecs.rst:421 msgid "``'surrogatepass'``" msgstr "``'surrogatepass'``" -#: ../../library/codecs.rst:417 +#: ../../library/codecs.rst:421 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:417 +#: ../../library/codecs.rst:421 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:424 +#: ../../library/codecs.rst:428 msgid "The ``'surrogateescape'`` and ``'surrogatepass'`` error handlers." msgstr "" -#: ../../library/codecs.rst:427 +#: ../../library/codecs.rst:431 msgid "" "The ``'surrogatepass'`` error handler now works with utf-16\\* and utf-32\\* " "codecs." msgstr "" -#: ../../library/codecs.rst:431 +#: ../../library/codecs.rst:435 msgid "The ``'namereplace'`` error handler." msgstr "" -#: ../../library/codecs.rst:434 +#: ../../library/codecs.rst:438 msgid "" "The ``'backslashreplace'`` error handler now works with decoding and " "translating." msgstr "" -#: ../../library/codecs.rst:438 +#: ../../library/codecs.rst:442 msgid "" "The set of allowed values can be extended by registering a new named error " "handler:" msgstr "" -#: ../../library/codecs.rst:443 +#: ../../library/codecs.rst:447 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:447 +#: ../../library/codecs.rst:451 msgid "" "For encoding, *error_handler* will be called with a :exc:" "`UnicodeEncodeError` instance, which contains information about the location " @@ -556,66 +560,66 @@ msgid "" "position is out of bound an :exc:`IndexError` will be raised." msgstr "" -#: ../../library/codecs.rst:459 +#: ../../library/codecs.rst:463 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:464 +#: ../../library/codecs.rst:468 msgid "" "Previously registered error handlers (including the standard error handlers) " "can be looked up by name:" msgstr "" -#: ../../library/codecs.rst:469 +#: ../../library/codecs.rst:473 msgid "Return the error handler previously registered under the name *name*." msgstr "" -#: ../../library/codecs.rst:471 +#: ../../library/codecs.rst:475 msgid "Raises a :exc:`LookupError` in case the handler cannot be found." msgstr "" -#: ../../library/codecs.rst:473 +#: ../../library/codecs.rst:477 msgid "" "The following standard error handlers are also made available as module " "level functions:" msgstr "" -#: ../../library/codecs.rst:478 +#: ../../library/codecs.rst:482 msgid "Implements the ``'strict'`` error handling." msgstr "" -#: ../../library/codecs.rst:480 +#: ../../library/codecs.rst:484 msgid "Each encoding or decoding error raises a :exc:`UnicodeError`." msgstr "" -#: ../../library/codecs.rst:485 +#: ../../library/codecs.rst:489 msgid "Implements the ``'ignore'`` error handling." msgstr "" -#: ../../library/codecs.rst:487 +#: ../../library/codecs.rst:491 msgid "" "Malformed data is ignored; encoding or decoding is continued without further " "notice." msgstr "" -#: ../../library/codecs.rst:493 +#: ../../library/codecs.rst:497 msgid "Implements the ``'replace'`` error handling." msgstr "" -#: ../../library/codecs.rst:495 +#: ../../library/codecs.rst:499 msgid "" "Substitutes ``?`` (ASCII character) for encoding errors or ``�`` (U+FFFD, " "the official REPLACEMENT CHARACTER) for decoding errors." msgstr "" -#: ../../library/codecs.rst:501 +#: ../../library/codecs.rst:505 msgid "Implements the ``'backslashreplace'`` error handling." msgstr "" -#: ../../library/codecs.rst:503 +#: ../../library/codecs.rst:507 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}" @@ -623,30 +627,30 @@ msgid "" "hexadecimal form of byte value with format :samp:`\\\\x{hh}`." msgstr "" -#: ../../library/codecs.rst:509 +#: ../../library/codecs.rst:513 msgid "Works with decoding and translating." msgstr "" -#: ../../library/codecs.rst:515 +#: ../../library/codecs.rst:519 msgid "" "Implements the ``'xmlcharrefreplace'`` error handling (for encoding within :" "term:`text encoding` only)." msgstr "" -#: ../../library/codecs.rst:518 +#: ../../library/codecs.rst:522 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:525 +#: ../../library/codecs.rst:529 msgid "" "Implements the ``'namereplace'`` error handling (for encoding within :term:" "`text encoding` only)." msgstr "" -#: ../../library/codecs.rst:528 +#: ../../library/codecs.rst:532 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 " @@ -654,17 +658,17 @@ msgid "" "will be converted to byte sequence ``\\N{LATIN SMALL LETTER SHARP S}`` ." msgstr "" -#: ../../library/codecs.rst:539 +#: ../../library/codecs.rst:543 msgid "Stateless Encoding and Decoding" msgstr "" -#: ../../library/codecs.rst:541 +#: ../../library/codecs.rst:545 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:549 +#: ../../library/codecs.rst:553 msgid "" "Encodes the object *input* and returns a tuple (output object, length " "consumed). For instance, :term:`text encoding` converts a string object to a " @@ -672,26 +676,26 @@ msgid "" "``iso-8859-1``)." msgstr "" -#: ../../library/codecs.rst:554 ../../library/codecs.rst:576 +#: ../../library/codecs.rst:558 ../../library/codecs.rst:580 msgid "" "The *errors* argument defines the error handling to apply. It defaults to " "``'strict'`` handling." msgstr "" -#: ../../library/codecs.rst:557 +#: ../../library/codecs.rst:561 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:561 +#: ../../library/codecs.rst:565 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:567 +#: ../../library/codecs.rst:571 msgid "" "Decodes the object *input* and returns a tuple (output object, length " "consumed). For instance, for a :term:`text encoding`, decoding converts a " @@ -699,31 +703,31 @@ msgid "" "object." msgstr "" -#: ../../library/codecs.rst:572 +#: ../../library/codecs.rst:576 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:579 +#: ../../library/codecs.rst:583 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:583 +#: ../../library/codecs.rst:587 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:588 +#: ../../library/codecs.rst:592 msgid "Incremental Encoding and Decoding" msgstr "" -#: ../../library/codecs.rst:590 +#: ../../library/codecs.rst:594 msgid "" "The :class:`IncrementalEncoder` and :class:`IncrementalDecoder` classes " "provide the basic interface for incremental encoding and decoding. Encoding/" @@ -734,7 +738,7 @@ msgid "" "during method calls." msgstr "" -#: ../../library/codecs.rst:598 +#: ../../library/codecs.rst:602 msgid "" "The joined output of calls to the :meth:`~IncrementalEncoder.encode`/:meth:" "`~IncrementalDecoder.decode` method is the same as if all the single inputs " @@ -742,36 +746,36 @@ msgid "" "encoder/decoder." msgstr "" -#: ../../library/codecs.rst:607 +#: ../../library/codecs.rst:611 msgid "IncrementalEncoder Objects" msgstr "IncrementalEncoder 物件" -#: ../../library/codecs.rst:609 +#: ../../library/codecs.rst:613 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:616 +#: ../../library/codecs.rst:620 msgid "Constructor for an :class:`IncrementalEncoder` instance." msgstr ":class:`IncrementalEncoder` 的建構函式。" -#: ../../library/codecs.rst:618 +#: ../../library/codecs.rst:622 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:622 +#: ../../library/codecs.rst:626 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:626 +#: ../../library/codecs.rst:630 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 " @@ -779,21 +783,21 @@ msgid "" "`IncrementalEncoder` object." msgstr "" -#: ../../library/codecs.rst:634 +#: ../../library/codecs.rst:638 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:641 +#: ../../library/codecs.rst:645 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:648 +#: ../../library/codecs.rst:652 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 " @@ -802,42 +806,42 @@ msgid "" "into an integer.)" msgstr "" -#: ../../library/codecs.rst:657 +#: ../../library/codecs.rst:661 msgid "" "Set the state of the encoder to *state*. *state* must be an encoder state " "returned by :meth:`getstate`." msgstr "" -#: ../../library/codecs.rst:664 +#: ../../library/codecs.rst:668 msgid "IncrementalDecoder Objects" msgstr "IncrementalDecoder 物件" -#: ../../library/codecs.rst:666 +#: ../../library/codecs.rst:670 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:673 +#: ../../library/codecs.rst:677 msgid "Constructor for an :class:`IncrementalDecoder` instance." msgstr ":class:`IncrementalDecoder` 的建構函式。" -#: ../../library/codecs.rst:675 +#: ../../library/codecs.rst:679 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:679 +#: ../../library/codecs.rst:683 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:683 +#: ../../library/codecs.rst:687 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 " @@ -845,7 +849,7 @@ msgid "" "`IncrementalDecoder` object." msgstr "" -#: ../../library/codecs.rst:691 +#: ../../library/codecs.rst:695 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:" @@ -856,11 +860,11 @@ msgid "" "(which might raise an exception)." msgstr "" -#: ../../library/codecs.rst:702 +#: ../../library/codecs.rst:706 msgid "Reset the decoder to the initial state." msgstr "將解碼器重設到初始狀態。" -#: ../../library/codecs.rst:707 +#: ../../library/codecs.rst:711 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. " @@ -875,59 +879,59 @@ msgid "" "bytes of the resulting string into an integer.)" msgstr "" -#: ../../library/codecs.rst:722 +#: ../../library/codecs.rst:726 msgid "" "Set the state of the decoder to *state*. *state* must be a decoder state " "returned by :meth:`getstate`." msgstr "" -#: ../../library/codecs.rst:727 +#: ../../library/codecs.rst:731 msgid "Stream Encoding and Decoding" msgstr "串流編碼和解碼" -#: ../../library/codecs.rst:730 +#: ../../library/codecs.rst:734 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:738 +#: ../../library/codecs.rst:742 msgid "StreamWriter Objects" msgstr "StreamWriter 物件" -#: ../../library/codecs.rst:740 +#: ../../library/codecs.rst:744 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:747 +#: ../../library/codecs.rst:751 msgid "Constructor for a :class:`StreamWriter` instance." msgstr ":class:`StreamWriter` 的建構函式。" -#: ../../library/codecs.rst:749 +#: ../../library/codecs.rst:753 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:753 +#: ../../library/codecs.rst:757 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:756 +#: ../../library/codecs.rst:760 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:760 +#: ../../library/codecs.rst:764 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 " @@ -935,70 +939,70 @@ msgid "" "object." msgstr "" -#: ../../library/codecs.rst:766 +#: ../../library/codecs.rst:770 msgid "Writes the object's contents encoded to the stream." msgstr "" -#: ../../library/codecs.rst:771 +#: ../../library/codecs.rst:775 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:779 ../../library/codecs.rst:874 +#: ../../library/codecs.rst:783 ../../library/codecs.rst:878 msgid "Resets the codec buffers used for keeping internal state." msgstr "" -#: ../../library/codecs.rst:781 +#: ../../library/codecs.rst:785 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:786 +#: ../../library/codecs.rst:790 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:793 +#: ../../library/codecs.rst:797 msgid "StreamReader Objects" msgstr "StreamReader 物件" -#: ../../library/codecs.rst:795 +#: ../../library/codecs.rst:799 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:802 +#: ../../library/codecs.rst:806 msgid "Constructor for a :class:`StreamReader` instance." msgstr ":class:`StreamReader` 的建構函式。" -#: ../../library/codecs.rst:804 +#: ../../library/codecs.rst:808 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:808 +#: ../../library/codecs.rst:812 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:811 +#: ../../library/codecs.rst:815 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:815 +#: ../../library/codecs.rst:819 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 " @@ -1006,24 +1010,24 @@ msgid "" "object." msgstr "" -#: ../../library/codecs.rst:819 +#: ../../library/codecs.rst:823 msgid "" "The set of allowed values for the *errors* argument can be extended with :" "func:`register_error`." msgstr "" -#: ../../library/codecs.rst:825 +#: ../../library/codecs.rst:829 msgid "Decodes data from the stream and returns the resulting object." msgstr "" -#: ../../library/codecs.rst:827 +#: ../../library/codecs.rst:831 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:832 +#: ../../library/codecs.rst:836 msgid "" "The *size* argument indicates the approximate maximum number of encoded " "bytes or code points to read for decoding. The decoder can modify this " @@ -1032,13 +1036,13 @@ msgid "" "huge files in one step." msgstr "" -#: ../../library/codecs.rst:839 +#: ../../library/codecs.rst:843 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:843 +#: ../../library/codecs.rst:847 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 " @@ -1046,68 +1050,68 @@ msgid "" "the stream, these should be read too." msgstr "" -#: ../../library/codecs.rst:851 +#: ../../library/codecs.rst:855 msgid "Read one line from the input stream and return the decoded data." msgstr "" -#: ../../library/codecs.rst:853 +#: ../../library/codecs.rst:857 msgid "" "*size*, if given, is passed as size argument to the stream's :meth:`read` " "method." msgstr "" -#: ../../library/codecs.rst:856 +#: ../../library/codecs.rst:860 msgid "" "If *keepends* is false line-endings will be stripped from the lines returned." msgstr "" -#: ../../library/codecs.rst:862 +#: ../../library/codecs.rst:866 msgid "" "Read all lines available on the input stream and return them as a list of " "lines." msgstr "" -#: ../../library/codecs.rst:865 +#: ../../library/codecs.rst:869 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:868 +#: ../../library/codecs.rst:872 msgid "" "*sizehint*, if given, is passed as the *size* argument to the stream's :meth:" "`read` method." msgstr "" -#: ../../library/codecs.rst:876 +#: ../../library/codecs.rst:880 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:880 +#: ../../library/codecs.rst:884 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:886 +#: ../../library/codecs.rst:890 msgid "StreamReaderWriter Objects" msgstr "StreamReaderWriter 物件" -#: ../../library/codecs.rst:888 +#: ../../library/codecs.rst:892 msgid "" "The :class:`StreamReaderWriter` is a convenience class that allows wrapping " "streams which work in both read and write modes." msgstr "" -#: ../../library/codecs.rst:891 ../../library/codecs.rst:915 +#: ../../library/codecs.rst:895 ../../library/codecs.rst:919 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:897 +#: ../../library/codecs.rst:901 msgid "" "Creates a :class:`StreamReaderWriter` instance. *stream* must be a file-like " "object. *Reader* and *Writer* must be factory functions or classes providing " @@ -1116,24 +1120,24 @@ msgid "" "writers." msgstr "" -#: ../../library/codecs.rst:902 +#: ../../library/codecs.rst:906 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:910 +#: ../../library/codecs.rst:914 msgid "StreamRecoder Objects" msgstr "StreamRecoder 物件" -#: ../../library/codecs.rst:912 +#: ../../library/codecs.rst:916 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:921 +#: ../../library/codecs.rst:925 msgid "" "Creates a :class:`StreamRecoder` instance which implements a two-way " "conversion: *encode* and *decode* work on the frontend — the data visible to " @@ -1141,17 +1145,17 @@ msgid "" "while *Reader* and *Writer* work on the backend — the data in *stream*." msgstr "" -#: ../../library/codecs.rst:927 +#: ../../library/codecs.rst:931 msgid "" "You can use these objects to do transparent transcodings, e.g., from Latin-1 " "to UTF-8 and back." msgstr "" -#: ../../library/codecs.rst:930 +#: ../../library/codecs.rst:934 msgid "The *stream* argument must be a file-like object." msgstr "*stream* 引數必須是類檔案物件。" -#: ../../library/codecs.rst:932 +#: ../../library/codecs.rst:936 msgid "" "The *encode* and *decode* arguments must adhere to the :class:`Codec` " "interface. *Reader* and *Writer* must be factory functions or classes " @@ -1159,24 +1163,24 @@ msgid "" "interface respectively." msgstr "" -#: ../../library/codecs.rst:937 +#: ../../library/codecs.rst:941 msgid "" "Error handling is done in the same way as defined for the stream readers and " "writers." msgstr "" -#: ../../library/codecs.rst:941 +#: ../../library/codecs.rst:945 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:949 +#: ../../library/codecs.rst:953 msgid "Encodings and Unicode" msgstr "編碼和 Unicode" -#: ../../library/codecs.rst:951 +#: ../../library/codecs.rst:955 msgid "" "Strings are stored internally as sequences of code points in range " "``U+0000``--``U+10FFFF``. (See :pep:`393` for more details about the " @@ -1188,7 +1192,7 @@ msgid "" "which are collectivity referred to as :term:`text encodings `." msgstr "" -#: ../../library/codecs.rst:961 +#: ../../library/codecs.rst:965 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 " @@ -1199,7 +1203,7 @@ msgid "" "position 3: ordinal not in range(256)``." msgstr "" -#: ../../library/codecs.rst:969 +#: ../../library/codecs.rst:973 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 " @@ -1209,37 +1213,45 @@ msgid "" "that shows you which character is mapped to which byte value." msgstr "" -#: ../../library/codecs.rst:976 +#: ../../library/codecs.rst:980 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 " "Unicode code point, is to store each code point as four consecutive bytes. " "There are two possibilities: store the bytes in big endian or in little " "endian order. These two encodings are called ``UTF-32-BE`` and ``UTF-32-LE`` " -"respectively. Their disadvantage is that if e.g. you use ``UTF-32-BE`` on a " -"little endian machine you will always have to swap bytes on encoding and " -"decoding. ``UTF-32`` avoids this problem: bytes will always be in natural " -"endianness. When these bytes are read by a CPU with a different endianness, " -"then bytes have to be swapped though. To be able to detect the endianness of " -"a ``UTF-16`` or ``UTF-32`` byte sequence, there's the so called BOM (\"Byte " -"Order Mark\"). This is the Unicode character ``U+FEFF``. This character can " -"be prepended to every ``UTF-16`` or ``UTF-32`` byte sequence. The byte " -"swapped version of this character (``0xFFFE``) is an illegal character that " -"may not appear in a Unicode text. So when the first character in a " -"``UTF-16`` or ``UTF-32`` byte sequence appears to be a ``U+FFFE`` the bytes " -"have to be swapped on decoding. 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 word to be split. It can e.g. be used to give " -"hints to a ligature algorithm. With Unicode 4.0 using ``U+FEFF`` as a ``ZERO " -"WIDTH NO-BREAK SPACE`` has been deprecated (with ``U+2060`` (``WORD " -"JOINER``) assuming this role). Nevertheless Unicode software still must be " -"able to handle ``U+FEFF`` in both roles: as a BOM it's a device to determine " -"the storage layout of the encoded bytes, and vanishes once the byte sequence " -"has been decoded into a string; as a ``ZERO WIDTH NO-BREAK SPACE`` it's a " -"normal character that will be decoded like any other." -msgstr "" - -#: ../../library/codecs.rst:1002 +"respectively. Their disadvantage is that if, for example, you use ``UTF-32-" +"BE`` on a little endian machine you will always have to swap bytes on " +"encoding and decoding. Python's ``UTF-16`` and ``UTF-32`` codecs avoid this " +"problem by using the platform's native byte order when no BOM is present. " +"Python follows prevailing platform practice, so native-endian data round-" +"trips without redundant byte swapping, even though the Unicode Standard " +"defaults to big-endian when the byte order is unspecified. When these bytes " +"are read by a CPU with a different endianness, the bytes have to be swapped. " +"To be able to detect the endianness of a ``UTF-16`` or ``UTF-32`` byte " +"sequence, a BOM (\"Byte Order Mark\") is used. This is the Unicode character " +"``U+FEFF``. This character can be prepended to every ``UTF-16`` or " +"``UTF-32`` byte sequence. The byte swapped version of this character " +"(``0xFFFE``) is an illegal character that may not appear in a Unicode text. " +"When the first character of a ``UTF-16`` or ``UTF-32`` byte sequence is " +"``U+FFFE``, the bytes have to be swapped on decoding." +msgstr "" + +#: ../../library/codecs.rst:1001 +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 " +"word to be split. It can e.g. be used to give hints to a ligature algorithm. " +"With Unicode 4.0 using ``U+FEFF`` as a ``ZERO WIDTH NO-BREAK SPACE`` has " +"been deprecated (with ``U+2060`` (``WORD JOINER``) assuming this role). " +"Nevertheless Unicode software still must be able to handle ``U+FEFF`` in " +"both roles: as a BOM it's a device to determine the storage layout of the " +"encoded bytes, and vanishes once the byte sequence has been decoded into a " +"string; as a ``ZERO WIDTH NO-BREAK SPACE`` it's a normal character that will " +"be decoded like any other." +msgstr "" + +#: ../../library/codecs.rst:1011 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 " @@ -1250,59 +1262,59 @@ msgid "" "which when concatenated give the Unicode character):" msgstr "" -#: ../../library/codecs.rst:1011 +#: ../../library/codecs.rst:1020 msgid "Range" msgstr "" -#: ../../library/codecs.rst:1011 +#: ../../library/codecs.rst:1020 msgid "Encoding" msgstr "" -#: ../../library/codecs.rst:1013 +#: ../../library/codecs.rst:1022 msgid "``U-00000000`` ... ``U-0000007F``" msgstr "``U-00000000`` ... ``U-0000007F``" -#: ../../library/codecs.rst:1013 +#: ../../library/codecs.rst:1022 msgid "0xxxxxxx" msgstr "0xxxxxxx" -#: ../../library/codecs.rst:1015 +#: ../../library/codecs.rst:1024 msgid "``U-00000080`` ... ``U-000007FF``" msgstr "``U-00000080`` ... ``U-000007FF``" -#: ../../library/codecs.rst:1015 +#: ../../library/codecs.rst:1024 msgid "110xxxxx 10xxxxxx" msgstr "110xxxxx 10xxxxxx" -#: ../../library/codecs.rst:1017 +#: ../../library/codecs.rst:1026 msgid "``U-00000800`` ... ``U-0000FFFF``" msgstr "``U-00000800`` ... ``U-0000FFFF``" -#: ../../library/codecs.rst:1017 +#: ../../library/codecs.rst:1026 msgid "1110xxxx 10xxxxxx 10xxxxxx" msgstr "1110xxxx 10xxxxxx 10xxxxxx" -#: ../../library/codecs.rst:1019 +#: ../../library/codecs.rst:1028 msgid "``U-00010000`` ... ``U-0010FFFF``" msgstr "``U-00010000`` ... ``U-0010FFFF``" -#: ../../library/codecs.rst:1019 +#: ../../library/codecs.rst:1028 msgid "11110xxx 10xxxxxx 10xxxxxx 10xxxxxx" msgstr "11110xxx 10xxxxxx 10xxxxxx 10xxxxxx" -#: ../../library/codecs.rst:1022 +#: ../../library/codecs.rst:1031 msgid "" "The least significant bit of the Unicode character is the rightmost x bit." msgstr "" -#: ../../library/codecs.rst:1024 +#: ../../library/codecs.rst:1033 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:1028 +#: ../../library/codecs.rst:1037 msgid "" "Without external information it's impossible to reliably determine which " "encoding was used for encoding a string. Each charmap encoding can decode " @@ -1316,19 +1328,19 @@ msgid "" "charmap encoded file starts with these byte values (which would e.g. map to" msgstr "" -#: ../../library/codecs.rst:0 +#: ../../library/codecs.rst:1049 msgid "LATIN SMALL LETTER I WITH DIAERESIS" msgstr "" -#: ../../library/codecs.rst:0 +#: ../../library/codecs.rst:1050 msgid "RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK" msgstr "" -#: ../../library/codecs.rst:0 +#: ../../library/codecs.rst:1051 msgid "INVERTED QUESTION MARK" msgstr "" -#: ../../library/codecs.rst:1044 +#: ../../library/codecs.rst:1053 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 " @@ -1340,11 +1352,11 @@ msgid "" "the use of the BOM is discouraged and should generally be avoided." msgstr "" -#: ../../library/codecs.rst:1057 +#: ../../library/codecs.rst:1066 msgid "Standard Encodings" msgstr "標準編碼" -#: ../../library/codecs.rst:1059 +#: ../../library/codecs.rst:1068 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 " @@ -1357,13 +1369,20 @@ msgid "" "``'utf-8'`` is a valid alias for the ``'utf_8'`` codec." msgstr "" -#: ../../library/codecs.rst:1071 +#: ../../library/codecs.rst:1080 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:1076 +#: ../../library/codecs.rst:1083 +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 " +"platforms." +msgstr "" + +#: ../../library/codecs.rst:1089 msgid "" "Some common encodings can bypass the codecs lookup machinery to improve " "performance. These optimization opportunities are only recognized by CPython " @@ -1373,11 +1392,11 @@ msgid "" "Using alternative aliases for these encodings may result in slower execution." msgstr "" -#: ../../library/codecs.rst:1084 +#: ../../library/codecs.rst:1097 msgid "Optimization opportunity recognized for us-ascii." msgstr "" -#: ../../library/codecs.rst:1087 +#: ../../library/codecs.rst:1100 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 " @@ -1385,504 +1404,504 @@ msgid "" "languages in particular, the following variants typically exist:" msgstr "" -#: ../../library/codecs.rst:1092 +#: ../../library/codecs.rst:1105 msgid "an ISO 8859 codeset" msgstr "" -#: ../../library/codecs.rst:1094 +#: ../../library/codecs.rst:1107 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:1097 +#: ../../library/codecs.rst:1110 msgid "an IBM EBCDIC code page" msgstr "" -#: ../../library/codecs.rst:1099 +#: ../../library/codecs.rst:1112 msgid "an IBM PC code page, which is ASCII compatible" msgstr "" -#: ../../library/codecs.rst:1104 ../../library/codecs.rst:1360 -#: ../../library/codecs.rst:1432 ../../library/codecs.rst:1517 +#: ../../library/codecs.rst:1117 ../../library/codecs.rst:1376 +#: ../../library/codecs.rst:1448 ../../library/codecs.rst:1533 msgid "Codec" msgstr "" -#: ../../library/codecs.rst:1104 ../../library/codecs.rst:1360 -#: ../../library/codecs.rst:1432 ../../library/codecs.rst:1517 +#: ../../library/codecs.rst:1117 ../../library/codecs.rst:1376 +#: ../../library/codecs.rst:1448 ../../library/codecs.rst:1533 msgid "Aliases" msgstr "" -#: ../../library/codecs.rst:1104 +#: ../../library/codecs.rst:1117 msgid "Languages" msgstr "語言" -#: ../../library/codecs.rst:1106 +#: ../../library/codecs.rst:1119 msgid "ascii" msgstr "ascii" -#: ../../library/codecs.rst:1106 +#: ../../library/codecs.rst:1119 msgid "646, us-ascii" msgstr "646, us-ascii" -#: ../../library/codecs.rst:1106 ../../library/codecs.rst:1112 -#: ../../library/codecs.rst:1120 +#: ../../library/codecs.rst:1119 ../../library/codecs.rst:1125 +#: ../../library/codecs.rst:1133 msgid "English" msgstr "英文" -#: ../../library/codecs.rst:1108 +#: ../../library/codecs.rst:1121 msgid "big5" msgstr "big5" -#: ../../library/codecs.rst:1108 +#: ../../library/codecs.rst:1121 msgid "big5-tw, csbig5" msgstr "big5-tw, csbig5" -#: ../../library/codecs.rst:1108 ../../library/codecs.rst:1110 -#: ../../library/codecs.rst:1169 +#: ../../library/codecs.rst:1121 ../../library/codecs.rst:1123 +#: ../../library/codecs.rst:1182 msgid "Traditional Chinese" msgstr "繁體中文" -#: ../../library/codecs.rst:1110 +#: ../../library/codecs.rst:1123 msgid "big5hkscs" msgstr "big5hkscs" -#: ../../library/codecs.rst:1110 +#: ../../library/codecs.rst:1123 msgid "big5-hkscs, hkscs" msgstr "big5-hkscs, hkscs" -#: ../../library/codecs.rst:1112 +#: ../../library/codecs.rst:1125 msgid "cp037" msgstr "cp037" -#: ../../library/codecs.rst:1112 +#: ../../library/codecs.rst:1125 msgid "IBM037, IBM039" msgstr "IBM037, IBM039" -#: ../../library/codecs.rst:1114 +#: ../../library/codecs.rst:1127 msgid "cp273" msgstr "cp273" -#: ../../library/codecs.rst:1114 +#: ../../library/codecs.rst:1127 msgid "273, IBM273, csIBM273" msgstr "273, IBM273, csIBM273" -#: ../../library/codecs.rst:1114 +#: ../../library/codecs.rst:1127 msgid "German" msgstr "德文" -#: ../../library/codecs.rst:1118 +#: ../../library/codecs.rst:1131 msgid "cp424" msgstr "cp424" -#: ../../library/codecs.rst:1118 +#: ../../library/codecs.rst:1131 msgid "EBCDIC-CP-HE, IBM424" msgstr "EBCDIC-CP-HE, IBM424" -#: ../../library/codecs.rst:1118 ../../library/codecs.rst:1138 -#: ../../library/codecs.rst:1148 ../../library/codecs.rst:1192 -#: ../../library/codecs.rst:1255 +#: ../../library/codecs.rst:1131 ../../library/codecs.rst:1151 +#: ../../library/codecs.rst:1161 ../../library/codecs.rst:1205 +#: ../../library/codecs.rst:1268 msgid "Hebrew" msgstr "希伯來文" -#: ../../library/codecs.rst:1120 +#: ../../library/codecs.rst:1133 msgid "cp437" msgstr "cp437" -#: ../../library/codecs.rst:1120 +#: ../../library/codecs.rst:1133 msgid "437, IBM437" msgstr "437, IBM437" -#: ../../library/codecs.rst:1122 +#: ../../library/codecs.rst:1135 msgid "cp500" msgstr "cp500" -#: ../../library/codecs.rst:1122 +#: ../../library/codecs.rst:1135 msgid "EBCDIC-CP-BE, EBCDIC-CP-CH, IBM500" msgstr "EBCDIC-CP-BE, EBCDIC-CP-CH, IBM500" -#: ../../library/codecs.rst:1122 ../../library/codecs.rst:1131 -#: ../../library/codecs.rst:1142 ../../library/codecs.rst:1179 -#: ../../library/codecs.rst:1186 ../../library/codecs.rst:1239 -#: ../../library/codecs.rst:1267 ../../library/codecs.rst:1295 +#: ../../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 msgid "Western Europe" msgstr "" -#: ../../library/codecs.rst:1125 +#: ../../library/codecs.rst:1138 msgid "cp720" msgstr "cp720" -#: ../../library/codecs.rst:1125 ../../library/codecs.rst:1152 -#: ../../library/codecs.rst:1194 ../../library/codecs.rst:1251 +#: ../../library/codecs.rst:1138 ../../library/codecs.rst:1165 +#: ../../library/codecs.rst:1207 ../../library/codecs.rst:1264 msgid "Arabic" msgstr "阿拉伯文" -#: ../../library/codecs.rst:1127 +#: ../../library/codecs.rst:1140 msgid "cp737" msgstr "cp737" -#: ../../library/codecs.rst:1127 ../../library/codecs.rst:1158 -#: ../../library/codecs.rst:1162 ../../library/codecs.rst:1188 -#: ../../library/codecs.rst:1253 ../../library/codecs.rst:1288 +#: ../../library/codecs.rst:1140 ../../library/codecs.rst:1171 +#: ../../library/codecs.rst:1175 ../../library/codecs.rst:1201 +#: ../../library/codecs.rst:1266 ../../library/codecs.rst:1301 msgid "Greek" msgstr "希臘文" -#: ../../library/codecs.rst:1129 +#: ../../library/codecs.rst:1142 msgid "cp775" msgstr "cp775" -#: ../../library/codecs.rst:1129 +#: ../../library/codecs.rst:1142 msgid "IBM775" msgstr "IBM775" -#: ../../library/codecs.rst:1129 ../../library/codecs.rst:1196 -#: ../../library/codecs.rst:1263 +#: ../../library/codecs.rst:1142 ../../library/codecs.rst:1209 +#: ../../library/codecs.rst:1276 msgid "Baltic languages" msgstr "" -#: ../../library/codecs.rst:1131 +#: ../../library/codecs.rst:1144 msgid "cp850" msgstr "cp850" -#: ../../library/codecs.rst:1131 +#: ../../library/codecs.rst:1144 msgid "850, IBM850" msgstr "850, IBM850" -#: ../../library/codecs.rst:1133 +#: ../../library/codecs.rst:1146 msgid "cp852" msgstr "cp852" -#: ../../library/codecs.rst:1133 +#: ../../library/codecs.rst:1146 msgid "852, IBM852" msgstr "852, IBM852" -#: ../../library/codecs.rst:1133 ../../library/codecs.rst:1181 -#: ../../library/codecs.rst:1242 ../../library/codecs.rst:1292 +#: ../../library/codecs.rst:1146 ../../library/codecs.rst:1194 +#: ../../library/codecs.rst:1255 ../../library/codecs.rst:1305 msgid "Central and Eastern Europe" msgstr "" -#: ../../library/codecs.rst:1135 +#: ../../library/codecs.rst:1148 msgid "cp855" msgstr "cp855" -#: ../../library/codecs.rst:1135 +#: ../../library/codecs.rst:1148 msgid "855, IBM855" msgstr "855, IBM855" -#: ../../library/codecs.rst:1135 ../../library/codecs.rst:1183 -#: ../../library/codecs.rst:1248 ../../library/codecs.rst:1285 +#: ../../library/codecs.rst:1148 ../../library/codecs.rst:1196 +#: ../../library/codecs.rst:1261 ../../library/codecs.rst:1298 msgid "Belarusian, Bulgarian, Macedonian, Russian, Serbian" msgstr "" -#: ../../library/codecs.rst:1138 +#: ../../library/codecs.rst:1151 msgid "cp856" msgstr "cp856" -#: ../../library/codecs.rst:1140 +#: ../../library/codecs.rst:1153 msgid "cp857" msgstr "cp857" -#: ../../library/codecs.rst:1140 +#: ../../library/codecs.rst:1153 msgid "857, IBM857" msgstr "857, IBM857" -#: ../../library/codecs.rst:1140 ../../library/codecs.rst:1173 -#: ../../library/codecs.rst:1190 ../../library/codecs.rst:1257 -#: ../../library/codecs.rst:1297 +#: ../../library/codecs.rst:1153 ../../library/codecs.rst:1186 +#: ../../library/codecs.rst:1203 ../../library/codecs.rst:1270 +#: ../../library/codecs.rst:1310 msgid "Turkish" msgstr "土耳其文" -#: ../../library/codecs.rst:1142 +#: ../../library/codecs.rst:1155 msgid "cp858" msgstr "cp858" -#: ../../library/codecs.rst:1142 +#: ../../library/codecs.rst:1155 msgid "858, IBM858" msgstr "858, IBM858" -#: ../../library/codecs.rst:1144 +#: ../../library/codecs.rst:1157 msgid "cp860" msgstr "cp860" -#: ../../library/codecs.rst:1144 +#: ../../library/codecs.rst:1157 msgid "860, IBM860" msgstr "860, IBM860" -#: ../../library/codecs.rst:1144 +#: ../../library/codecs.rst:1157 msgid "Portuguese" msgstr "" -#: ../../library/codecs.rst:1146 +#: ../../library/codecs.rst:1159 msgid "cp861" msgstr "cp861" -#: ../../library/codecs.rst:1146 +#: ../../library/codecs.rst:1159 msgid "861, CP-IS, IBM861" msgstr "861, CP-IS, IBM861" -#: ../../library/codecs.rst:1146 ../../library/codecs.rst:1290 +#: ../../library/codecs.rst:1159 ../../library/codecs.rst:1303 msgid "Icelandic" msgstr "" -#: ../../library/codecs.rst:1148 +#: ../../library/codecs.rst:1161 msgid "cp862" msgstr "cp862" -#: ../../library/codecs.rst:1148 +#: ../../library/codecs.rst:1161 msgid "862, IBM862" msgstr "862, IBM862" -#: ../../library/codecs.rst:1150 +#: ../../library/codecs.rst:1163 msgid "cp863" msgstr "cp863" -#: ../../library/codecs.rst:1150 +#: ../../library/codecs.rst:1163 msgid "863, IBM863" msgstr "863, IBM863" -#: ../../library/codecs.rst:1150 +#: ../../library/codecs.rst:1163 msgid "Canadian" msgstr "" -#: ../../library/codecs.rst:1152 +#: ../../library/codecs.rst:1165 msgid "cp864" msgstr "cp864" -#: ../../library/codecs.rst:1152 +#: ../../library/codecs.rst:1165 msgid "IBM864" msgstr "IBM864" -#: ../../library/codecs.rst:1154 +#: ../../library/codecs.rst:1167 msgid "cp865" msgstr "cp865" -#: ../../library/codecs.rst:1154 +#: ../../library/codecs.rst:1167 msgid "865, IBM865" msgstr "865, IBM865" -#: ../../library/codecs.rst:1154 +#: ../../library/codecs.rst:1167 msgid "Danish, Norwegian" msgstr "" -#: ../../library/codecs.rst:1156 +#: ../../library/codecs.rst:1169 msgid "cp866" msgstr "cp866" -#: ../../library/codecs.rst:1156 +#: ../../library/codecs.rst:1169 msgid "866, IBM866" msgstr "866, IBM866" -#: ../../library/codecs.rst:1156 ../../library/codecs.rst:1273 +#: ../../library/codecs.rst:1169 ../../library/codecs.rst:1286 msgid "Russian" msgstr "俄羅斯文" -#: ../../library/codecs.rst:1158 +#: ../../library/codecs.rst:1171 msgid "cp869" msgstr "cp869" -#: ../../library/codecs.rst:1158 +#: ../../library/codecs.rst:1171 msgid "869, CP-GR, IBM869" msgstr "869, CP-GR, IBM869" -#: ../../library/codecs.rst:1160 +#: ../../library/codecs.rst:1173 msgid "cp874" msgstr "cp874" -#: ../../library/codecs.rst:1160 +#: ../../library/codecs.rst:1173 msgid "Thai" msgstr "泰文" -#: ../../library/codecs.rst:1162 +#: ../../library/codecs.rst:1175 msgid "cp875" msgstr "cp875" -#: ../../library/codecs.rst:1164 +#: ../../library/codecs.rst:1177 msgid "cp932" msgstr "cp932" -#: ../../library/codecs.rst:1164 +#: ../../library/codecs.rst:1177 msgid "932, ms932, mskanji, ms-kanji, windows-31j" msgstr "932, ms932, mskanji, ms-kanji, windows-31j" -#: ../../library/codecs.rst:1164 ../../library/codecs.rst:1200 -#: ../../library/codecs.rst:1202 ../../library/codecs.rst:1204 -#: ../../library/codecs.rst:1221 ../../library/codecs.rst:1224 -#: ../../library/codecs.rst:1229 ../../library/codecs.rst:1232 -#: ../../library/codecs.rst:1234 ../../library/codecs.rst:1302 -#: ../../library/codecs.rst:1305 ../../library/codecs.rst:1308 +#: ../../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 msgid "Japanese" msgstr "日文" -#: ../../library/codecs.rst:1167 +#: ../../library/codecs.rst:1180 msgid "cp949" msgstr "cp949" -#: ../../library/codecs.rst:1167 +#: ../../library/codecs.rst:1180 msgid "949, ms949, uhc" msgstr "949, ms949, uhc" -#: ../../library/codecs.rst:1167 ../../library/codecs.rst:1206 -#: ../../library/codecs.rst:1236 ../../library/codecs.rst:1271 +#: ../../library/codecs.rst:1180 ../../library/codecs.rst:1219 +#: ../../library/codecs.rst:1249 ../../library/codecs.rst:1284 msgid "Korean" msgstr "韓文" -#: ../../library/codecs.rst:1169 +#: ../../library/codecs.rst:1182 msgid "cp950" msgstr "cp950" -#: ../../library/codecs.rst:1169 +#: ../../library/codecs.rst:1182 msgid "950, ms950" msgstr "950, ms950" -#: ../../library/codecs.rst:1171 +#: ../../library/codecs.rst:1184 msgid "cp1006" msgstr "cp1006" -#: ../../library/codecs.rst:1171 +#: ../../library/codecs.rst:1184 msgid "Urdu" msgstr "" -#: ../../library/codecs.rst:1173 +#: ../../library/codecs.rst:1186 msgid "cp1026" msgstr "cp1026" -#: ../../library/codecs.rst:1173 +#: ../../library/codecs.rst:1186 msgid "ibm1026" msgstr "ibm1026" -#: ../../library/codecs.rst:1175 +#: ../../library/codecs.rst:1188 msgid "cp1125" msgstr "cp1125" -#: ../../library/codecs.rst:1175 +#: ../../library/codecs.rst:1188 msgid "1125, ibm1125, cp866u, ruscii" msgstr "1125, ibm1125, cp866u, ruscii" -#: ../../library/codecs.rst:1175 ../../library/codecs.rst:1279 +#: ../../library/codecs.rst:1188 ../../library/codecs.rst:1292 msgid "Ukrainian" msgstr "烏克蘭文" -#: ../../library/codecs.rst:1179 +#: ../../library/codecs.rst:1192 msgid "cp1140" msgstr "cp1140" -#: ../../library/codecs.rst:1179 +#: ../../library/codecs.rst:1192 msgid "ibm1140" msgstr "ibm1140" -#: ../../library/codecs.rst:1181 +#: ../../library/codecs.rst:1194 msgid "cp1250" msgstr "cp1250" -#: ../../library/codecs.rst:1181 +#: ../../library/codecs.rst:1194 msgid "windows-1250" msgstr "windows-1250" -#: ../../library/codecs.rst:1183 +#: ../../library/codecs.rst:1196 msgid "cp1251" msgstr "cp1251" -#: ../../library/codecs.rst:1183 +#: ../../library/codecs.rst:1196 msgid "windows-1251" msgstr "windows-1251" -#: ../../library/codecs.rst:1186 +#: ../../library/codecs.rst:1199 msgid "cp1252" msgstr "cp1252" -#: ../../library/codecs.rst:1186 +#: ../../library/codecs.rst:1199 msgid "windows-1252" msgstr "windows-1252" -#: ../../library/codecs.rst:1188 +#: ../../library/codecs.rst:1201 msgid "cp1253" msgstr "cp1253" -#: ../../library/codecs.rst:1188 +#: ../../library/codecs.rst:1201 msgid "windows-1253" msgstr "windows-1253" -#: ../../library/codecs.rst:1190 +#: ../../library/codecs.rst:1203 msgid "cp1254" msgstr "cp1254" -#: ../../library/codecs.rst:1190 +#: ../../library/codecs.rst:1203 msgid "windows-1254" msgstr "windows-1254" -#: ../../library/codecs.rst:1192 +#: ../../library/codecs.rst:1205 msgid "cp1255" msgstr "cp1255" -#: ../../library/codecs.rst:1192 +#: ../../library/codecs.rst:1205 msgid "windows-1255" msgstr "windows-1255" -#: ../../library/codecs.rst:1194 +#: ../../library/codecs.rst:1207 msgid "cp1256" msgstr "cp1256" -#: ../../library/codecs.rst:1194 +#: ../../library/codecs.rst:1207 msgid "windows-1256" msgstr "windows-1256" -#: ../../library/codecs.rst:1196 +#: ../../library/codecs.rst:1209 msgid "cp1257" msgstr "cp1257" -#: ../../library/codecs.rst:1196 +#: ../../library/codecs.rst:1209 msgid "windows-1257" msgstr "windows-1257" -#: ../../library/codecs.rst:1198 +#: ../../library/codecs.rst:1211 msgid "cp1258" msgstr "cp1258" -#: ../../library/codecs.rst:1198 +#: ../../library/codecs.rst:1211 msgid "windows-1258" msgstr "windows-1258" -#: ../../library/codecs.rst:1198 +#: ../../library/codecs.rst:1211 msgid "Vietnamese" msgstr "越南文" -#: ../../library/codecs.rst:1200 +#: ../../library/codecs.rst:1213 msgid "euc_jp" msgstr "euc_jp" -#: ../../library/codecs.rst:1200 +#: ../../library/codecs.rst:1213 msgid "eucjp, ujis, u-jis" msgstr "eucjp, ujis, u-jis" -#: ../../library/codecs.rst:1202 +#: ../../library/codecs.rst:1215 msgid "euc_jis_2004" msgstr "euc_jis_2004" -#: ../../library/codecs.rst:1202 +#: ../../library/codecs.rst:1215 msgid "jisx0213, eucjis2004" msgstr "jisx0213, eucjis2004" -#: ../../library/codecs.rst:1204 +#: ../../library/codecs.rst:1217 msgid "euc_jisx0213" msgstr "euc_jisx0213" -#: ../../library/codecs.rst:1204 +#: ../../library/codecs.rst:1217 msgid "eucjisx0213" msgstr "eucjisx0213" -#: ../../library/codecs.rst:1206 +#: ../../library/codecs.rst:1219 msgid "euc_kr" msgstr "euc_kr" -#: ../../library/codecs.rst:1206 +#: ../../library/codecs.rst:1219 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:1210 +#: ../../library/codecs.rst:1223 msgid "gb2312" msgstr "gb2312" -#: ../../library/codecs.rst:1210 +#: ../../library/codecs.rst:1223 msgid "" "chinese, csiso58gb231280, euc-cn, euccn, eucgb2312-cn, gb2312-1980, " "gb2312-80, iso-ir-58" @@ -1890,450 +1909,454 @@ msgstr "" "chinese, csiso58gb231280, euc-cn, euccn, eucgb2312-cn, gb2312-1980, " "gb2312-80, iso-ir-58" -#: ../../library/codecs.rst:1210 ../../library/codecs.rst:1219 +#: ../../library/codecs.rst:1223 ../../library/codecs.rst:1232 msgid "Simplified Chinese" msgstr "簡體中文" -#: ../../library/codecs.rst:1215 +#: ../../library/codecs.rst:1228 msgid "gbk" msgstr "gbk" -#: ../../library/codecs.rst:1215 +#: ../../library/codecs.rst:1228 msgid "936, cp936, ms936" msgstr "936, cp936, ms936" -#: ../../library/codecs.rst:1215 ../../library/codecs.rst:1217 +#: ../../library/codecs.rst:1228 ../../library/codecs.rst:1230 msgid "Unified Chinese" msgstr "" -#: ../../library/codecs.rst:1217 +#: ../../library/codecs.rst:1230 msgid "gb18030" msgstr "gb18030" -#: ../../library/codecs.rst:1217 +#: ../../library/codecs.rst:1230 msgid "gb18030-2000" msgstr "gb18030-2000" -#: ../../library/codecs.rst:1219 +#: ../../library/codecs.rst:1232 msgid "hz" msgstr "hz" -#: ../../library/codecs.rst:1219 +#: ../../library/codecs.rst:1232 msgid "hzgb, hz-gb, hz-gb-2312" msgstr "hzgb, hz-gb, hz-gb-2312" -#: ../../library/codecs.rst:1221 +#: ../../library/codecs.rst:1234 msgid "iso2022_jp" msgstr "iso2022_jp" -#: ../../library/codecs.rst:1221 +#: ../../library/codecs.rst:1234 msgid "csiso2022jp, iso2022jp, iso-2022-jp" msgstr "csiso2022jp, iso2022jp, iso-2022-jp" -#: ../../library/codecs.rst:1224 +#: ../../library/codecs.rst:1237 msgid "iso2022_jp_1" msgstr "iso2022_jp_1" -#: ../../library/codecs.rst:1224 +#: ../../library/codecs.rst:1237 msgid "iso2022jp-1, iso-2022-jp-1" msgstr "iso2022jp-1, iso-2022-jp-1" -#: ../../library/codecs.rst:1226 +#: ../../library/codecs.rst:1239 msgid "iso2022_jp_2" msgstr "iso2022_jp_2" -#: ../../library/codecs.rst:1226 +#: ../../library/codecs.rst:1239 msgid "iso2022jp-2, iso-2022-jp-2" msgstr "iso2022jp-2, iso-2022-jp-2" -#: ../../library/codecs.rst:1226 +#: ../../library/codecs.rst:1239 msgid "Japanese, Korean, Simplified Chinese, Western Europe, Greek" msgstr "" -#: ../../library/codecs.rst:1229 +#: ../../library/codecs.rst:1242 msgid "iso2022_jp_2004" msgstr "iso2022_jp_2004" -#: ../../library/codecs.rst:1229 +#: ../../library/codecs.rst:1242 msgid "iso2022jp-2004, iso-2022-jp-2004" msgstr "iso2022jp-2004, iso-2022-jp-2004" -#: ../../library/codecs.rst:1232 +#: ../../library/codecs.rst:1245 msgid "iso2022_jp_3" msgstr "iso2022_jp_3" -#: ../../library/codecs.rst:1232 +#: ../../library/codecs.rst:1245 msgid "iso2022jp-3, iso-2022-jp-3" msgstr "iso2022jp-3, iso-2022-jp-3" -#: ../../library/codecs.rst:1234 +#: ../../library/codecs.rst:1247 msgid "iso2022_jp_ext" msgstr "iso2022_jp_ext" -#: ../../library/codecs.rst:1234 +#: ../../library/codecs.rst:1247 msgid "iso2022jp-ext, iso-2022-jp-ext" msgstr "iso2022jp-ext, iso-2022-jp-ext" -#: ../../library/codecs.rst:1236 +#: ../../library/codecs.rst:1249 msgid "iso2022_kr" msgstr "iso2022_kr" -#: ../../library/codecs.rst:1236 +#: ../../library/codecs.rst:1249 msgid "csiso2022kr, iso2022kr, iso-2022-kr" msgstr "csiso2022kr, iso2022kr, iso-2022-kr" -#: ../../library/codecs.rst:1239 +#: ../../library/codecs.rst:1252 msgid "latin_1" msgstr "latin_1" -#: ../../library/codecs.rst:1239 +#: ../../library/codecs.rst:1252 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:1242 +#: ../../library/codecs.rst:1255 msgid "iso8859_2" msgstr "iso8859_2" -#: ../../library/codecs.rst:1242 +#: ../../library/codecs.rst:1255 msgid "iso-8859-2, latin2, L2" msgstr "iso-8859-2, latin2, L2" -#: ../../library/codecs.rst:1244 +#: ../../library/codecs.rst:1257 msgid "iso8859_3" msgstr "iso8859_3" -#: ../../library/codecs.rst:1244 +#: ../../library/codecs.rst:1257 msgid "iso-8859-3, latin3, L3" msgstr "iso-8859-3, latin3, L3" -#: ../../library/codecs.rst:1244 +#: ../../library/codecs.rst:1257 msgid "Esperanto, Maltese" msgstr "" -#: ../../library/codecs.rst:1246 +#: ../../library/codecs.rst:1259 msgid "iso8859_4" msgstr "iso8859_4" -#: ../../library/codecs.rst:1246 +#: ../../library/codecs.rst:1259 msgid "iso-8859-4, latin4, L4" msgstr "iso-8859-4, latin4, L4" -#: ../../library/codecs.rst:1246 +#: ../../library/codecs.rst:1259 msgid "Northern Europe" msgstr "" -#: ../../library/codecs.rst:1248 +#: ../../library/codecs.rst:1261 msgid "iso8859_5" msgstr "iso8859_5" -#: ../../library/codecs.rst:1248 +#: ../../library/codecs.rst:1261 msgid "iso-8859-5, cyrillic" msgstr "iso-8859-5, cyrillic" -#: ../../library/codecs.rst:1251 +#: ../../library/codecs.rst:1264 msgid "iso8859_6" msgstr "iso8859_6" -#: ../../library/codecs.rst:1251 +#: ../../library/codecs.rst:1264 msgid "iso-8859-6, arabic" msgstr "iso-8859-6, arabic" -#: ../../library/codecs.rst:1253 +#: ../../library/codecs.rst:1266 msgid "iso8859_7" msgstr "iso8859_7" -#: ../../library/codecs.rst:1253 +#: ../../library/codecs.rst:1266 msgid "iso-8859-7, greek, greek8" msgstr "iso-8859-7, greek, greek8" -#: ../../library/codecs.rst:1255 +#: ../../library/codecs.rst:1268 msgid "iso8859_8" msgstr "iso8859_8" -#: ../../library/codecs.rst:1255 +#: ../../library/codecs.rst:1268 msgid "iso-8859-8, hebrew" msgstr "iso-8859-8, hebrew" -#: ../../library/codecs.rst:1257 +#: ../../library/codecs.rst:1270 msgid "iso8859_9" msgstr "iso8859_9" -#: ../../library/codecs.rst:1257 +#: ../../library/codecs.rst:1270 msgid "iso-8859-9, latin5, L5" msgstr "iso-8859-9, latin5, L5" -#: ../../library/codecs.rst:1259 +#: ../../library/codecs.rst:1272 msgid "iso8859_10" msgstr "iso8859_10" -#: ../../library/codecs.rst:1259 +#: ../../library/codecs.rst:1272 msgid "iso-8859-10, latin6, L6" msgstr "iso-8859-10, latin6, L6" -#: ../../library/codecs.rst:1259 +#: ../../library/codecs.rst:1272 msgid "Nordic languages" msgstr "" -#: ../../library/codecs.rst:1261 +#: ../../library/codecs.rst:1274 msgid "iso8859_11" msgstr "iso8859_11" -#: ../../library/codecs.rst:1261 +#: ../../library/codecs.rst:1274 msgid "iso-8859-11, thai" msgstr "iso-8859-11, thai" -#: ../../library/codecs.rst:1261 +#: ../../library/codecs.rst:1274 msgid "Thai languages" msgstr "泰語" -#: ../../library/codecs.rst:1263 +#: ../../library/codecs.rst:1276 msgid "iso8859_13" msgstr "iso8859_13" -#: ../../library/codecs.rst:1263 +#: ../../library/codecs.rst:1276 msgid "iso-8859-13, latin7, L7" msgstr "iso-8859-13, latin7, L7" -#: ../../library/codecs.rst:1265 +#: ../../library/codecs.rst:1278 msgid "iso8859_14" msgstr "iso8859_14" -#: ../../library/codecs.rst:1265 +#: ../../library/codecs.rst:1278 msgid "iso-8859-14, latin8, L8" msgstr "iso-8859-14, latin8, L8" -#: ../../library/codecs.rst:1265 +#: ../../library/codecs.rst:1278 msgid "Celtic languages" msgstr "" -#: ../../library/codecs.rst:1267 +#: ../../library/codecs.rst:1280 msgid "iso8859_15" msgstr "iso8859_15" -#: ../../library/codecs.rst:1267 +#: ../../library/codecs.rst:1280 msgid "iso-8859-15, latin9, L9" msgstr "iso-8859-15, latin9, L9" -#: ../../library/codecs.rst:1269 +#: ../../library/codecs.rst:1282 msgid "iso8859_16" msgstr "iso8859_16" -#: ../../library/codecs.rst:1269 +#: ../../library/codecs.rst:1282 msgid "iso-8859-16, latin10, L10" msgstr "iso-8859-16, latin10, L10" -#: ../../library/codecs.rst:1269 +#: ../../library/codecs.rst:1282 msgid "South-Eastern Europe" msgstr "" -#: ../../library/codecs.rst:1271 +#: ../../library/codecs.rst:1284 msgid "johab" msgstr "" -#: ../../library/codecs.rst:1271 +#: ../../library/codecs.rst:1284 msgid "cp1361, ms1361" msgstr "cp1361, ms1361" -#: ../../library/codecs.rst:1273 +#: ../../library/codecs.rst:1286 msgid "koi8_r" msgstr "koi8_r" -#: ../../library/codecs.rst:1275 +#: ../../library/codecs.rst:1288 msgid "koi8_t" msgstr "koi8_t" -#: ../../library/codecs.rst:1275 +#: ../../library/codecs.rst:1288 msgid "Tajik" msgstr "" -#: ../../library/codecs.rst:1279 +#: ../../library/codecs.rst:1292 msgid "koi8_u" msgstr "koi8_u" -#: ../../library/codecs.rst:1281 +#: ../../library/codecs.rst:1294 msgid "kz1048" msgstr "kz1048" -#: ../../library/codecs.rst:1281 +#: ../../library/codecs.rst:1294 msgid "kz_1048, strk1048_2002, rk1048" msgstr "kz_1048, strk1048_2002, rk1048" -#: ../../library/codecs.rst:1281 ../../library/codecs.rst:1299 +#: ../../library/codecs.rst:1294 ../../library/codecs.rst:1312 msgid "Kazakh" msgstr "" -#: ../../library/codecs.rst:1285 +#: ../../library/codecs.rst:1298 msgid "mac_cyrillic" msgstr "mac_cyrillic" -#: ../../library/codecs.rst:1285 +#: ../../library/codecs.rst:1298 msgid "maccyrillic" msgstr "" -#: ../../library/codecs.rst:1288 +#: ../../library/codecs.rst:1301 msgid "mac_greek" msgstr "mac_greek" -#: ../../library/codecs.rst:1288 +#: ../../library/codecs.rst:1301 msgid "macgreek" msgstr "" -#: ../../library/codecs.rst:1290 +#: ../../library/codecs.rst:1303 msgid "mac_iceland" msgstr "mac_iceland" -#: ../../library/codecs.rst:1290 +#: ../../library/codecs.rst:1303 msgid "maciceland" msgstr "" -#: ../../library/codecs.rst:1292 +#: ../../library/codecs.rst:1305 msgid "mac_latin2" msgstr "mac_latin2" -#: ../../library/codecs.rst:1292 +#: ../../library/codecs.rst:1305 msgid "maclatin2, maccentraleurope, mac_centeuro" msgstr "maclatin2, maccentraleurope, mac_centeuro" -#: ../../library/codecs.rst:1295 +#: ../../library/codecs.rst:1308 msgid "mac_roman" msgstr "mac_roman" -#: ../../library/codecs.rst:1295 +#: ../../library/codecs.rst:1308 msgid "macroman, macintosh" msgstr "macroman, macintosh" -#: ../../library/codecs.rst:1297 +#: ../../library/codecs.rst:1310 msgid "mac_turkish" msgstr "mac_turkish" -#: ../../library/codecs.rst:1297 +#: ../../library/codecs.rst:1310 msgid "macturkish" msgstr "" -#: ../../library/codecs.rst:1299 +#: ../../library/codecs.rst:1312 msgid "ptcp154" msgstr "ptcp154" -#: ../../library/codecs.rst:1299 +#: ../../library/codecs.rst:1312 msgid "csptcp154, pt154, cp154, cyrillic-asian" msgstr "csptcp154, pt154, cp154, cyrillic-asian" -#: ../../library/codecs.rst:1302 +#: ../../library/codecs.rst:1315 msgid "shift_jis" msgstr "shift_jis" -#: ../../library/codecs.rst:1302 +#: ../../library/codecs.rst:1315 msgid "csshiftjis, shiftjis, sjis, s_jis" msgstr "csshiftjis, shiftjis, sjis, s_jis" -#: ../../library/codecs.rst:1305 +#: ../../library/codecs.rst:1318 msgid "shift_jis_2004" msgstr "shift_jis_2004" -#: ../../library/codecs.rst:1305 +#: ../../library/codecs.rst:1318 msgid "shiftjis2004, sjis_2004, sjis2004" msgstr "shiftjis2004, sjis_2004, sjis2004" -#: ../../library/codecs.rst:1308 +#: ../../library/codecs.rst:1321 msgid "shift_jisx0213" msgstr "shift_jisx0213" -#: ../../library/codecs.rst:1308 +#: ../../library/codecs.rst:1321 msgid "shiftjisx0213, sjisx0213, s_jisx0213" msgstr "shiftjisx0213, sjisx0213, s_jisx0213" -#: ../../library/codecs.rst:1311 +#: ../../library/codecs.rst:1324 msgid "utf_32" msgstr "utf_32" -#: ../../library/codecs.rst:1311 +#: ../../library/codecs.rst:1324 msgid "U32, utf32" msgstr "U32, utf32" -#: ../../library/codecs.rst:1311 ../../library/codecs.rst:1313 -#: ../../library/codecs.rst:1315 ../../library/codecs.rst:1317 -#: ../../library/codecs.rst:1319 ../../library/codecs.rst:1321 -#: ../../library/codecs.rst:1323 ../../library/codecs.rst:1325 -#: ../../library/codecs.rst:1327 +#: ../../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 msgid "all languages" msgstr "" -#: ../../library/codecs.rst:1313 +#: ../../library/codecs.rst:1326 msgid "utf_32_be" msgstr "utf_32_be" -#: ../../library/codecs.rst:1313 +#: ../../library/codecs.rst:1326 msgid "UTF-32BE" msgstr "UTF-32BE" -#: ../../library/codecs.rst:1315 +#: ../../library/codecs.rst:1328 msgid "utf_32_le" msgstr "utf_32_le" -#: ../../library/codecs.rst:1315 +#: ../../library/codecs.rst:1328 msgid "UTF-32LE" msgstr "UTF-32LE" -#: ../../library/codecs.rst:1317 +#: ../../library/codecs.rst:1330 msgid "utf_16" msgstr "utf_16" -#: ../../library/codecs.rst:1317 +#: ../../library/codecs.rst:1330 msgid "U16, utf16" msgstr "U16, utf16" -#: ../../library/codecs.rst:1319 +#: ../../library/codecs.rst:1332 msgid "utf_16_be" msgstr "utf_16_be" -#: ../../library/codecs.rst:1319 +#: ../../library/codecs.rst:1332 msgid "UTF-16BE" msgstr "UTF-16BE" -#: ../../library/codecs.rst:1321 +#: ../../library/codecs.rst:1334 msgid "utf_16_le" msgstr "utf_16_le" -#: ../../library/codecs.rst:1321 +#: ../../library/codecs.rst:1334 msgid "UTF-16LE" msgstr "UTF-16LE" -#: ../../library/codecs.rst:1323 +#: ../../library/codecs.rst:1336 msgid "utf_7" msgstr "utf_7" -#: ../../library/codecs.rst:1323 +#: ../../library/codecs.rst:1336 msgid "U7, unicode-1-1-utf-7" msgstr "U7, unicode-1-1-utf-7" -#: ../../library/codecs.rst:1325 +#: ../../library/codecs.rst:1338 msgid "utf_8" msgstr "utf_8" -#: ../../library/codecs.rst:1325 +#: ../../library/codecs.rst:1338 msgid "U8, UTF, utf8, cp65001" msgstr "U8, UTF, utf8, cp65001" -#: ../../library/codecs.rst:1327 +#: ../../library/codecs.rst:1340 msgid "utf_8_sig" msgstr "utf_8_sig" -#: ../../library/codecs.rst:1330 +#: ../../library/codecs.rst:1343 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:1336 +#: ../../library/codecs.rst:1349 msgid "``cp65001`` is now an alias to ``utf_8``." msgstr "``cp65001`` 現在是 ``utf_8`` 的別名。" -#: ../../library/codecs.rst:1341 +#: ../../library/codecs.rst:1352 +msgid "On Windows, ``cpXXX`` codecs are now available for all code pages." +msgstr "" + +#: ../../library/codecs.rst:1357 msgid "Python Specific Encodings" msgstr "" -#: ../../library/codecs.rst:1343 +#: ../../library/codecs.rst:1359 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 " @@ -2343,240 +2366,240 @@ msgid "" "asymmetric codecs, the stated meaning describes the encoding direction." msgstr "" -#: ../../library/codecs.rst:1351 +#: ../../library/codecs.rst:1367 msgid "Text Encodings" msgstr "" -#: ../../library/codecs.rst:1353 +#: ../../library/codecs.rst:1369 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:1362 +#: ../../library/codecs.rst:1378 msgid "idna" msgstr "idna" -#: ../../library/codecs.rst:1362 +#: ../../library/codecs.rst:1378 msgid "" "Implement :rfc:`3490`, see also :mod:`encodings.idna`. Only " "``errors='strict'`` is supported." msgstr "" -#: ../../library/codecs.rst:1368 +#: ../../library/codecs.rst:1384 msgid "mbcs" msgstr "mbcs" -#: ../../library/codecs.rst:1368 +#: ../../library/codecs.rst:1384 msgid "ansi, dbcs" msgstr "ansi, dbcs" -#: ../../library/codecs.rst:1368 +#: ../../library/codecs.rst:1384 msgid "" "Windows only: Encode the operand according to the ANSI codepage (CP_ACP)." msgstr "" -#: ../../library/codecs.rst:1372 +#: ../../library/codecs.rst:1388 msgid "oem" msgstr "oem" -#: ../../library/codecs.rst:1372 +#: ../../library/codecs.rst:1388 msgid "" "Windows only: Encode the operand according to the OEM codepage (CP_OEMCP)." msgstr "" -#: ../../library/codecs.rst:1378 +#: ../../library/codecs.rst:1394 msgid "palmos" msgstr "" -#: ../../library/codecs.rst:1378 +#: ../../library/codecs.rst:1394 msgid "Encoding of PalmOS 3.5." msgstr "" -#: ../../library/codecs.rst:1380 +#: ../../library/codecs.rst:1396 msgid "punycode" msgstr "" -#: ../../library/codecs.rst:1380 +#: ../../library/codecs.rst:1396 msgid "Implement :rfc:`3492`. Stateful codecs are not supported." msgstr "" -#: ../../library/codecs.rst:1384 +#: ../../library/codecs.rst:1400 msgid "raw_unicode_escape" msgstr "raw_unicode_escape" -#: ../../library/codecs.rst:1384 +#: ../../library/codecs.rst:1400 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:1394 +#: ../../library/codecs.rst:1410 msgid "undefined" msgstr "" -#: ../../library/codecs.rst:1394 +#: ../../library/codecs.rst:1410 msgid "This Codec should only be used for testing purposes." msgstr "" -#: ../../library/codecs.rst:1398 +#: ../../library/codecs.rst:1414 msgid "" "Raise an exception for all conversions, even empty strings. The error " "handler is ignored." msgstr "" -#: ../../library/codecs.rst:1403 +#: ../../library/codecs.rst:1419 msgid "unicode_escape" msgstr "unicode_escape" -#: ../../library/codecs.rst:1403 +#: ../../library/codecs.rst:1419 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:1415 +#: ../../library/codecs.rst:1431 msgid "\"unicode_internal\" codec is removed." msgstr "" -#: ../../library/codecs.rst:1422 +#: ../../library/codecs.rst:1438 msgid "Binary Transforms" msgstr "" -#: ../../library/codecs.rst:1424 +#: ../../library/codecs.rst:1440 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:1432 +#: ../../library/codecs.rst:1448 msgid "Encoder / decoder" msgstr "" -#: ../../library/codecs.rst:1434 +#: ../../library/codecs.rst:1450 msgid "base64_codec [#b64]_" msgstr "base64_codec [#b64]_" -#: ../../library/codecs.rst:1434 +#: ../../library/codecs.rst:1450 msgid "base64, base_64" msgstr "base64, base_64" -#: ../../library/codecs.rst:1434 +#: ../../library/codecs.rst:1450 msgid "" "Convert the operand to multiline MIME base64 (the result always includes a " "trailing ``'\\n'``)." msgstr "" -#: ../../library/codecs.rst:1439 +#: ../../library/codecs.rst:1455 msgid "" "accepts any :term:`bytes-like object` as input for encoding and decoding" msgstr "" -#: ../../library/codecs.rst:1434 +#: ../../library/codecs.rst:1450 msgid ":meth:`base64.encodebytes` / :meth:`base64.decodebytes`" msgstr ":meth:`base64.encodebytes` / :meth:`base64.decodebytes`" -#: ../../library/codecs.rst:1445 +#: ../../library/codecs.rst:1461 msgid "bz2_codec" msgstr "bz2_codec" -#: ../../library/codecs.rst:1445 +#: ../../library/codecs.rst:1461 msgid "bz2" msgstr "bz2" -#: ../../library/codecs.rst:1445 +#: ../../library/codecs.rst:1461 msgid "Compress the operand using bz2." msgstr "" -#: ../../library/codecs.rst:1445 +#: ../../library/codecs.rst:1461 msgid ":meth:`bz2.compress` / :meth:`bz2.decompress`" msgstr ":meth:`bz2.compress` / :meth:`bz2.decompress`" -#: ../../library/codecs.rst:1448 +#: ../../library/codecs.rst:1464 msgid "hex_codec" msgstr "hex_codec" -#: ../../library/codecs.rst:1448 +#: ../../library/codecs.rst:1464 msgid "hex" msgstr "hex" -#: ../../library/codecs.rst:1448 +#: ../../library/codecs.rst:1464 msgid "" "Convert the operand to hexadecimal representation, with two digits per byte." msgstr "" -#: ../../library/codecs.rst:1448 +#: ../../library/codecs.rst:1464 msgid ":meth:`binascii.b2a_hex` / :meth:`binascii.a2b_hex`" msgstr ":meth:`binascii.b2a_hex` / :meth:`binascii.a2b_hex`" -#: ../../library/codecs.rst:1453 +#: ../../library/codecs.rst:1469 msgid "quopri_codec" msgstr "quopri_codec" -#: ../../library/codecs.rst:1453 +#: ../../library/codecs.rst:1469 msgid "quopri, quotedprintable, quoted_printable" msgstr "quopri, quotedprintable, quoted_printable" -#: ../../library/codecs.rst:1453 +#: ../../library/codecs.rst:1469 msgid "Convert the operand to MIME quoted printable." msgstr "" -#: ../../library/codecs.rst:1453 +#: ../../library/codecs.rst:1469 msgid ":meth:`quopri.encode` with ``quotetabs=True`` / :meth:`quopri.decode`" msgstr ":meth:`quopri.encode` with ``quotetabs=True`` / :meth:`quopri.decode`" -#: ../../library/codecs.rst:1457 +#: ../../library/codecs.rst:1473 msgid "uu_codec" msgstr "uu_codec" -#: ../../library/codecs.rst:1457 +#: ../../library/codecs.rst:1473 msgid "uu" msgstr "uu" -#: ../../library/codecs.rst:1457 +#: ../../library/codecs.rst:1473 msgid "Convert the operand using uuencode." msgstr "" -#: ../../library/codecs.rst:1460 +#: ../../library/codecs.rst:1476 msgid "zlib_codec" msgstr "zlib_codec" -#: ../../library/codecs.rst:1460 +#: ../../library/codecs.rst:1476 msgid "zip, zlib" msgstr "zip, zlib" -#: ../../library/codecs.rst:1460 +#: ../../library/codecs.rst:1476 msgid "Compress the operand using gzip." msgstr "" -#: ../../library/codecs.rst:1460 +#: ../../library/codecs.rst:1476 msgid ":meth:`zlib.compress` / :meth:`zlib.decompress`" msgstr ":meth:`zlib.compress` / :meth:`zlib.decompress`" -#: ../../library/codecs.rst:1464 +#: ../../library/codecs.rst:1480 msgid "" "In addition to :term:`bytes-like objects `, " "``'base64_codec'`` also accepts ASCII-only instances of :class:`str` for " "decoding" msgstr "" -#: ../../library/codecs.rst:1468 +#: ../../library/codecs.rst:1484 msgid "Restoration of the binary transforms." msgstr "" -#: ../../library/codecs.rst:1471 +#: ../../library/codecs.rst:1487 msgid "Restoration of the aliases for the binary transforms." msgstr "" -#: ../../library/codecs.rst:1478 +#: ../../library/codecs.rst:1494 msgid "Standalone Codec Functions" msgstr "" -#: ../../library/codecs.rst:1480 +#: ../../library/codecs.rst:1496 msgid "" "The following functions provide encoding and decoding functionality similar " "to codecs, but are not available as named codecs through :func:`codecs." @@ -2585,74 +2608,74 @@ msgid "" "removed in Python 3." msgstr "" -#: ../../library/codecs.rst:1487 +#: ../../library/codecs.rst:1503 msgid "" "Encode *input* using escape sequences. Similar to how :func:`repr` on bytes " "produces escaped byte values." msgstr "" -#: ../../library/codecs.rst:1490 +#: ../../library/codecs.rst:1506 msgid "*input* must be a :class:`bytes` object." -msgstr "*input* 必須是 :class:`bytes` 物件。" +msgstr "" -#: ../../library/codecs.rst:1492 ../../library/codecs.rst:1501 +#: ../../library/codecs.rst:1508 ../../library/codecs.rst:1517 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:1497 +#: ../../library/codecs.rst:1513 msgid "Decode *input* from escape sequences back to the original bytes." msgstr "" -#: ../../library/codecs.rst:1499 +#: ../../library/codecs.rst:1515 msgid "*input* must be a :term:`bytes-like object`." -msgstr "*input* 必須是 :term:`bytes-like object`。" +msgstr "*input* 必須是個 :term:`bytes-like object`。" -#: ../../library/codecs.rst:1508 +#: ../../library/codecs.rst:1524 msgid "Text Transforms" msgstr "" -#: ../../library/codecs.rst:1510 +#: ../../library/codecs.rst:1526 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:1519 +#: ../../library/codecs.rst:1535 msgid "rot_13" msgstr "rot_13" -#: ../../library/codecs.rst:1519 +#: ../../library/codecs.rst:1535 msgid "rot13" msgstr "" -#: ../../library/codecs.rst:1519 +#: ../../library/codecs.rst:1535 msgid "Return the Caesar-cypher encryption of the operand." msgstr "" -#: ../../library/codecs.rst:1524 +#: ../../library/codecs.rst:1540 msgid "Restoration of the ``rot_13`` text transform." msgstr "" -#: ../../library/codecs.rst:1527 +#: ../../library/codecs.rst:1543 msgid "Restoration of the ``rot13`` alias." msgstr "" -#: ../../library/codecs.rst:1532 +#: ../../library/codecs.rst:1548 msgid ":mod:`encodings` --- Encodings package" msgstr "" -#: ../../library/codecs.rst:1537 +#: ../../library/codecs.rst:1553 msgid "This module implements the following functions:" msgstr "" -#: ../../library/codecs.rst:1541 +#: ../../library/codecs.rst:1557 msgid "Normalize encoding name *encoding*." msgstr "" -#: ../../library/codecs.rst:1543 +#: ../../library/codecs.rst:1559 msgid "" "Normalization works as follows: all non-alphanumeric characters except the " "dot used for Python package names are collapsed and replaced with a single " @@ -2660,23 +2683,23 @@ msgid "" "-;#'`` becomes ``'_'``." msgstr "" -#: ../../library/codecs.rst:1548 +#: ../../library/codecs.rst:1564 msgid "Note that *encoding* should be ASCII only." msgstr "" -#: ../../library/codecs.rst:1552 +#: ../../library/codecs.rst:1568 msgid "" -"The following function should not be used directly, except for testing " +"The following functions should not be used directly, except for testing " "purposes; :func:`codecs.lookup` should be used instead." msgstr "" -#: ../../library/codecs.rst:1558 +#: ../../library/codecs.rst:1574 msgid "" "Search for the codec module corresponding to the given encoding name " "*encoding*." msgstr "" -#: ../../library/codecs.rst:1561 +#: ../../library/codecs.rst:1577 msgid "" "This function first normalizes the *encoding* using :func:" "`normalize_encoding`, then looks for a corresponding alias. It attempts to " @@ -2686,26 +2709,41 @@ msgid "" "the codec is cached and returned." msgstr "" -#: ../../library/codecs.rst:1568 +#: ../../library/codecs.rst:1584 msgid "" "If the codec module defines a ``getaliases()`` function any returned aliases " "are registered for future use." msgstr "" -#: ../../library/codecs.rst:1572 +#: ../../library/codecs.rst:1590 +msgid "" +"Search for a Windows code page encoding *encoding* of the form ``cpXXXX``." +msgstr "" + +#: ../../library/codecs.rst:1592 +msgid "" +"If the code page is valid and supported, return a :class:`codecs.CodecInfo` " +"object for it." +msgstr "" + +#: ../../library/codecs.rst:1595 ../../library/codecs.rst:1681 +msgid "Availability" +msgstr "可用性" + +#: ../../library/codecs.rst:1600 msgid "This module implements the following exception:" msgstr "" -#: ../../library/codecs.rst:1576 +#: ../../library/codecs.rst:1604 msgid "Raised when a codec is invalid or incompatible." msgstr "" -#: ../../library/codecs.rst:1580 +#: ../../library/codecs.rst:1608 msgid "" ":mod:`encodings.idna` --- Internationalized Domain Names in Applications" msgstr "" -#: ../../library/codecs.rst:1586 +#: ../../library/codecs.rst:1614 msgid "" "This module implements :rfc:`3490` (Internationalized Domain Names in " "Applications) and :rfc:`3492` (Nameprep: A Stringprep Profile for " @@ -2713,13 +2751,13 @@ msgid "" "encoding and :mod:`stringprep`." msgstr "" -#: ../../library/codecs.rst:1591 +#: ../../library/codecs.rst:1619 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:1594 +#: ../../library/codecs.rst:1622 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." @@ -2733,7 +2771,7 @@ msgid "" "presenting them to the user." msgstr "" -#: ../../library/codecs.rst:1605 +#: ../../library/codecs.rst:1633 msgid "" "Python supports this conversion in several ways: the ``idna`` codec " "performs conversion between Unicode and ACE, separating an input string into " @@ -2750,14 +2788,14 @@ msgid "" "sends that field at all)." msgstr "" -#: ../../library/codecs.rst:1618 +#: ../../library/codecs.rst:1646 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:1622 +#: ../../library/codecs.rst:1650 msgid "" "The module :mod:`encodings.idna` also implements the nameprep procedure, " "which performs certain normalizations on host names, to achieve case-" @@ -2765,49 +2803,45 @@ msgid "" "characters. The nameprep functions can be used directly if desired." msgstr "" -#: ../../library/codecs.rst:1630 +#: ../../library/codecs.rst:1658 msgid "" "Return the nameprepped version of *label*. The implementation currently " "assumes query strings, so ``AllowUnassigned`` is true." msgstr "" -#: ../../library/codecs.rst:1636 +#: ../../library/codecs.rst:1664 msgid "" "Convert a label to ASCII, as specified in :rfc:`3490`. ``UseSTD3ASCIIRules`` " "is assumed to be false." msgstr "" -#: ../../library/codecs.rst:1642 +#: ../../library/codecs.rst:1670 msgid "Convert a label to Unicode, as specified in :rfc:`3490`." msgstr "" -#: ../../library/codecs.rst:1646 +#: ../../library/codecs.rst:1674 msgid ":mod:`encodings.mbcs` --- Windows ANSI codepage" msgstr ":mod:`encodings.mbcs` --- Windows ANSI 碼頁" -#: ../../library/codecs.rst:1651 +#: ../../library/codecs.rst:1679 msgid "This module implements the ANSI codepage (CP_ACP)." msgstr "這個模組實作了 ANSI 碼頁 (CP_ACP)。" -#: ../../library/codecs.rst:1653 -msgid "Availability" -msgstr "可用性" - -#: ../../library/codecs.rst:1655 +#: ../../library/codecs.rst:1683 msgid "" "Before 3.2, the *errors* argument was ignored; ``'replace'`` was always used " "to encode, and ``'ignore'`` to decode." msgstr "" -#: ../../library/codecs.rst:1659 +#: ../../library/codecs.rst:1687 msgid "Support any error handler." msgstr "" -#: ../../library/codecs.rst:1664 +#: ../../library/codecs.rst:1692 msgid ":mod:`encodings.utf_8_sig` --- UTF-8 codec with BOM signature" msgstr "" -#: ../../library/codecs.rst:1670 +#: ../../library/codecs.rst:1698 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 " @@ -2836,71 +2870,71 @@ msgstr "streams(串流)" msgid "stackable" msgstr "stackable(可堆疊)" -#: ../../library/codecs.rst:334 +#: ../../library/codecs.rst:338 msgid "strict" msgstr "strict" -#: ../../library/codecs.rst:334 ../../library/codecs.rst:386 -#: ../../library/codecs.rst:409 +#: ../../library/codecs.rst:338 ../../library/codecs.rst:390 +#: ../../library/codecs.rst:413 msgid "error handler's name" msgstr "error handler's name(錯誤處理器名稱)" -#: ../../library/codecs.rst:334 +#: ../../library/codecs.rst:338 msgid "ignore" msgstr "ignore" -#: ../../library/codecs.rst:334 +#: ../../library/codecs.rst:338 msgid "replace" msgstr "replace" -#: ../../library/codecs.rst:334 +#: ../../library/codecs.rst:338 msgid "backslashreplace" msgstr "backslashreplace" -#: ../../library/codecs.rst:334 +#: ../../library/codecs.rst:338 msgid "surrogateescape" msgstr "surrogateescape" -#: ../../library/codecs.rst:334 +#: ../../library/codecs.rst:338 msgid "? (question mark)" msgstr "? (問號)" -#: ../../library/codecs.rst:334 +#: ../../library/codecs.rst:338 msgid "replacement character" msgstr "replacement character(替代字元)" -#: ../../library/codecs.rst:334 +#: ../../library/codecs.rst:338 msgid "\\ (backslash)" msgstr "\\ (反斜線)" -#: ../../library/codecs.rst:334 ../../library/codecs.rst:386 +#: ../../library/codecs.rst:338 ../../library/codecs.rst:390 msgid "escape sequence" msgstr "escape sequence(跳脫序列)" -#: ../../library/codecs.rst:334 +#: ../../library/codecs.rst:338 msgid "\\x" msgstr "\\x" -#: ../../library/codecs.rst:334 +#: ../../library/codecs.rst:338 msgid "\\u" msgstr "\\u" -#: ../../library/codecs.rst:334 +#: ../../library/codecs.rst:338 msgid "\\U" msgstr "\\U" -#: ../../library/codecs.rst:386 +#: ../../library/codecs.rst:390 msgid "xmlcharrefreplace" msgstr "xmlcharrefreplace" -#: ../../library/codecs.rst:386 +#: ../../library/codecs.rst:390 msgid "namereplace" msgstr "namereplace" -#: ../../library/codecs.rst:386 +#: ../../library/codecs.rst:390 msgid "\\N" msgstr "\\N" -#: ../../library/codecs.rst:409 +#: ../../library/codecs.rst:413 msgid "surrogatepass" msgstr "surrogatepass" diff --git a/library/codeop.po b/library/codeop.po index 36b73d432c3..61d65f13996 100644 --- a/library/codeop.po +++ b/library/codeop.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -6,7 +6,7 @@ # Matt Wang , 2024 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-05-09 00:03+0000\n" "PO-Revision-Date: 2024-09-24 20:28+0000\n" diff --git a/library/collections.abc.po b/library/collections.abc.po index b071d8b15b8..b999edb5cc5 100644 --- a/library/collections.abc.po +++ b/library/collections.abc.po @@ -1,12 +1,12 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"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: 2025-10-08 00:15+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-" @@ -23,7 +23,7 @@ msgstr ":mod:`!collections.abc` --- 容器的抽象基底類別" #: ../../library/collections.abc.rst:10 msgid "Formerly, this module was part of the :mod:`collections` module." -msgstr "" +msgstr "過去此模組是 :mod:`collections` 模組的一部分。" #: ../../library/collections.abc.rst:13 msgid "**Source code:** :source:`Lib/_collections_abc.py`" @@ -68,6 +68,10 @@ msgid "" ">>> isinstance(C(), Sequence)\n" "True" msgstr "" +">>> issubclass(C, Sequence)\n" +"True\n" +">>> isinstance(C(), Sequence)\n" +"True" #: ../../library/collections.abc.rst:50 msgid "" @@ -99,6 +103,10 @@ msgid "" ">>> isinstance(D(), Sequence)\n" "True" msgstr "" +">>> issubclass(D, Sequence)\n" +"True\n" +">>> isinstance(D(), Sequence)\n" +"True" #: ../../library/collections.abc.rst:76 msgid "" @@ -173,7 +181,7 @@ msgstr "" #: ../../library/collections.abc.rst:120 msgid "Abstract Methods" -msgstr "" +msgstr "抽象方法" #: ../../library/collections.abc.rst:120 msgid "Mixin Methods" @@ -301,6 +309,8 @@ msgid "" "Inherited :class:`Sequence` methods and ``append``, ``clear``, ``reverse``, " "``extend``, ``pop``, ``remove``, and ``__iadd__``" msgstr "" +"繼承 :class:`Sequence` 方法和 ``append``、``clear``、``reverse``、``extend``、" +"``pop``、``remove`` 和 ``__iadd__``" #: ../../library/collections.abc.rst:143 msgid ":class:`ByteString`" @@ -308,7 +318,7 @@ msgstr ":class:`ByteString`" #: ../../library/collections.abc.rst:143 msgid "Inherited :class:`Sequence` methods" -msgstr "" +msgstr ":class:`Sequence` 的繼承方法" #: ../../library/collections.abc.rst:146 ../../library/collections.abc.rst:151 msgid ":class:`Set`" @@ -498,23 +508,23 @@ msgstr "" #: ../../library/collections.abc.rst:200 msgid "Collections Abstract Base Classes -- Detailed Descriptions" -msgstr "" +msgstr "集合抽象基底類別的詳細描述" #: ../../library/collections.abc.rst:205 msgid "ABC for classes that provide the :meth:`~object.__contains__` method." -msgstr "" +msgstr "有提供 :meth:`~object.__contains__` 方法之類別的 ABC。" #: ../../library/collections.abc.rst:209 msgid "ABC for classes that provide the :meth:`~object.__hash__` method." -msgstr "" +msgstr "有提供 :meth:`~object.__hash__` 方法之類別的 ABC。" #: ../../library/collections.abc.rst:213 msgid "ABC for classes that provide the :meth:`~object.__len__` method." -msgstr "" +msgstr "有提供 :meth:`~object.__len__` 方法之類別的 ABC。" #: ../../library/collections.abc.rst:217 msgid "ABC for classes that provide the :meth:`~object.__call__` method." -msgstr "" +msgstr "有提供 :meth:`~object.__call__` 方法之類別的 ABC。" #: ../../library/collections.abc.rst:219 msgid "" @@ -524,7 +534,7 @@ msgstr "" #: ../../library/collections.abc.rst:224 msgid "ABC for classes that provide the :meth:`~container.__iter__` method." -msgstr "" +msgstr "有提供 :meth:`~container.__iter__` 方法之類別的 ABC。" #: ../../library/collections.abc.rst:226 msgid "" @@ -544,12 +554,15 @@ msgid "" "ABC for classes that provide the :meth:`~iterator.__iter__` and :meth:" "`~iterator.__next__` methods. See also the definition of :term:`iterator`." msgstr "" +"有提供 :meth:`~iterator.__iter__` 和 :meth:`~iterator.__next__` 方法之類別的 ABC。" +"另請參閱 :term:`iterator` 的定義。" #: ../../library/collections.abc.rst:247 msgid "" "ABC for iterable classes that also provide the :meth:`~object.__reversed__` " "method." msgstr "" +"亦有提供 :meth:`~object.__reversed__` 方法之可疊代類別的 ABC。" #: ../../library/collections.abc.rst:254 msgid "" @@ -567,80 +580,106 @@ msgstr "" #: ../../library/collections.abc.rst:268 msgid "ABCs for read-only and mutable :term:`sequences `." -msgstr "" +msgstr "唯讀且可變\\ :term:`序列 `\\ 的 ABC。" #: ../../library/collections.abc.rst:270 msgid "" "Implementation note: Some of the mixin methods, such as :meth:`~container." -"__iter__`, :meth:`~object.__reversed__` and :meth:`index`, make repeated " -"calls to the underlying :meth:`~object.__getitem__` method. Consequently, " -"if :meth:`~object.__getitem__` is implemented with constant access speed, " -"the mixin methods will have linear performance; however, if the underlying " -"method is linear (as it would be with a linked list), the mixins will have " -"quadratic performance and will likely need to be overridden." +"__iter__`, :meth:`~object.__reversed__`, and :meth:`~sequence.index` make " +"repeated calls to the underlying :meth:`~object.__getitem__` method. " +"Consequently, if :meth:`~object.__getitem__` is implemented with constant " +"access speed, the mixin methods will have linear performance; however, if " +"the underlying method is linear (as it would be with a linked list), the " +"mixins will have quadratic performance and will likely need to be overridden." msgstr "" -#: ../../library/collections.abc.rst:281 +#: ../../library/collections.abc.rst:282 msgid "Return first index of *value*." -msgstr "" +msgstr "回傳 *value* 的第一個索引。" -#: ../../library/collections.abc.rst:283 +#: ../../library/collections.abc.rst:284 msgid "Raises :exc:`ValueError` if the value is not present." -msgstr "" +msgstr "如果找不到該值,則引發 :exc:`ValueError`。" -#: ../../library/collections.abc.rst:285 +#: ../../library/collections.abc.rst:286 msgid "" "Supporting the *start* and *stop* arguments is optional, but recommended." +msgstr "建議要支援 *start* 和 *stop* 引數,但並非必要。" + +#: ../../library/collections.abc.rst:288 +msgid "" +"The :meth:`~sequence.index` method gained support for the *stop* and *start* " +"arguments." msgstr "" -#: ../../library/collections.abc.rst:287 +#: ../../library/collections.abc.rst:292 +msgid "The :class:`ByteString` ABC has been deprecated." +msgstr ":class:`ByteString` ABC 已被棄用。" + +#: ../../library/collections.abc.rst:295 msgid "" -"The :meth:`!index` method added support for *stop* and *start* arguments." +"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:`Buffer` or a union that explicitly " +"specifies the types your code supports (e.g., ``bytes | bytearray | " +"memoryview``)." msgstr "" -#: ../../library/collections.abc.rst:291 +#: ../../library/collections.abc.rst:301 msgid "" -"The :class:`ByteString` ABC has been deprecated. For use in typing, prefer a " -"union, like ``bytes | bytearray``, or :class:`collections.abc.Buffer`. For " -"use as an ABC, prefer :class:`Sequence` or :class:`collections.abc.Buffer`." +":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 還是由靜態型別檢查器)。" + +#: ../../library/collections.abc.rst:309 +msgid "See :pep:`PEP 688 <688#current-options>` for more details." +msgstr "更多詳細資訊請參閱 :pep:`PEP 688 <688#current-options>`。" -#: ../../library/collections.abc.rst:300 +#: ../../library/collections.abc.rst:314 msgid "ABCs for read-only and mutable :ref:`sets `." -msgstr "" +msgstr "唯讀且可變\\ :ref:`集合 `\\ 的 ABC。" -#: ../../library/collections.abc.rst:305 +#: ../../library/collections.abc.rst:319 msgid "ABCs for read-only and mutable :term:`mappings `." -msgstr "" +msgstr "唯讀且可變\\ :term:`對映 `\\ 的 ABC。" -#: ../../library/collections.abc.rst:312 +#: ../../library/collections.abc.rst:326 msgid "" "ABCs for mapping, items, keys, and values :term:`views `." msgstr "" -#: ../../library/collections.abc.rst:316 +#: ../../library/collections.abc.rst:330 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:320 +#: ../../library/collections.abc.rst:334 msgid "" ":term:`Coroutine ` objects and instances of the :class:" "`~collections.abc.Coroutine` ABC are all instances of this ABC." msgstr "" -#: ../../library/collections.abc.rst:324 +#: ../../library/collections.abc.rst:338 msgid "" "In CPython, generator-based coroutines (:term:`generators ` " -"decorated with :func:`@types.coroutine `) are *awaitables*, " -"even though they do not have an :meth:`~object.__await__` method. Using " -"``isinstance(gencoro, Awaitable)`` for them will return ``False``. Use :func:" -"`inspect.isawaitable` to detect them." +"decorated with :deco:`types.coroutine`) are *awaitables*, even though they " +"do not have an :meth:`~object.__await__` method. Using ``isinstance(gencoro, " +"Awaitable)`` for them will return ``False``. Use :func:`inspect.isawaitable` " +"to detect them." msgstr "" -#: ../../library/collections.abc.rst:334 +#: ../../library/collections.abc.rst:348 msgid "" "ABC for :term:`coroutine` compatible classes. These implement the following " "methods, defined in :ref:`coroutine-objects`: :meth:`~coroutine.send`, :meth:" @@ -649,63 +688,63 @@ msgid "" "instances are also instances of :class:`Awaitable`." msgstr "" -#: ../../library/collections.abc.rst:342 +#: ../../library/collections.abc.rst:356 msgid "" "In CPython, generator-based coroutines (:term:`generators ` " -"decorated with :func:`@types.coroutine `) are *awaitables*, " -"even though they do not have an :meth:`~object.__await__` method. Using " -"``isinstance(gencoro, Coroutine)`` for them will return ``False``. Use :func:" -"`inspect.isawaitable` to detect them." +"decorated with :deco:`types.coroutine`) are *awaitables*, even though they " +"do not have an :meth:`~object.__await__` method. Using ``isinstance(gencoro, " +"Coroutine)`` for them will return ``False``. Use :func:`inspect.isawaitable` " +"to detect them." msgstr "" -#: ../../library/collections.abc.rst:348 +#: ../../library/collections.abc.rst:362 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:357 +#: ../../library/collections.abc.rst:371 msgid "" "ABC for classes that provide an ``__aiter__`` method. See also the " "definition of :term:`asynchronous iterable`." msgstr "" -#: ../../library/collections.abc.rst:364 +#: ../../library/collections.abc.rst:378 msgid "" "ABC for classes that provide ``__aiter__`` and ``__anext__`` methods. See " "also the definition of :term:`asynchronous iterator`." msgstr "" -#: ../../library/collections.abc.rst:371 +#: ../../library/collections.abc.rst:385 msgid "" "ABC for :term:`asynchronous generator` classes that implement the protocol " "defined in :pep:`525` and :pep:`492`." msgstr "" -#: ../../library/collections.abc.rst:374 +#: ../../library/collections.abc.rst:388 msgid "" "See :ref:`annotating-generators-and-coroutines` for details on using :class:" "`!AsyncGenerator` in type annotations." msgstr "" -#: ../../library/collections.abc.rst:381 +#: ../../library/collections.abc.rst:395 msgid "" "ABC for classes that provide the :meth:`~object.__buffer__` method, " "implementing the :ref:`buffer protocol `. See :pep:`688`." msgstr "" -#: ../../library/collections.abc.rst:387 +#: ../../library/collections.abc.rst:401 msgid "Examples and Recipes" msgstr "" -#: ../../library/collections.abc.rst:389 +#: ../../library/collections.abc.rst:403 msgid "" "ABCs allow us to ask classes or instances if they provide particular " "functionality, for example::" msgstr "" -#: ../../library/collections.abc.rst:392 +#: ../../library/collections.abc.rst:406 msgid "" "size = None\n" "if isinstance(myvar, collections.abc.Sized):\n" @@ -715,7 +754,7 @@ msgstr "" "if isinstance(myvar, collections.abc.Sized):\n" " size = len(myvar)" -#: ../../library/collections.abc.rst:396 +#: ../../library/collections.abc.rst:410 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 " @@ -725,7 +764,7 @@ msgid "" "methods such as :meth:`!__and__` and :meth:`~frozenset.isdisjoint`::" msgstr "" -#: ../../library/collections.abc.rst:403 +#: ../../library/collections.abc.rst:417 msgid "" "class ListBasedSet(collections.abc.Set):\n" " ''' Alternate set implementation favoring space over speed\n" @@ -751,11 +790,11 @@ msgid "" "automatically" msgstr "" -#: ../../library/collections.abc.rst:425 +#: ../../library/collections.abc.rst:439 msgid "Notes on using :class:`Set` and :class:`MutableSet` as a mixin:" msgstr "" -#: ../../library/collections.abc.rst:428 +#: ../../library/collections.abc.rst:442 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 " @@ -768,14 +807,14 @@ msgid "" "iterable argument." msgstr "" -#: ../../library/collections.abc.rst:439 +#: ../../library/collections.abc.rst:453 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:445 +#: ../../library/collections.abc.rst:459 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 " @@ -784,12 +823,12 @@ msgid "" "define ``__hash__ = Set._hash``." msgstr "" -#: ../../library/collections.abc.rst:453 +#: ../../library/collections.abc.rst:467 msgid "" "`OrderedSet recipe `_ for an " "example built on :class:`MutableSet`." msgstr "" -#: ../../library/collections.abc.rst:456 +#: ../../library/collections.abc.rst:470 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 28aa3f51f90..666c6f13b4d 100644 --- a/library/collections.po +++ b/library/collections.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -7,9 +7,9 @@ # Matt Wang , 2022-2024 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-03-04 00:14+0000\n" +"POT-Creation-Date: 2025-09-10 20:44+0800\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-" @@ -23,7 +23,7 @@ msgstr "" #: ../../library/collections.rst:2 msgid ":mod:`!collections` --- Container datatypes" -msgstr ":mod:`!collections` --- 容器資料型態" +msgstr ":mod:`!collections` --- 容器資料型別" #: ../../library/collections.rst:10 msgid "**Source code:** :source:`Lib/collections/__init__.py`" @@ -35,7 +35,7 @@ msgid "" "alternatives to Python's general purpose built-in " "containers, :class:`dict`, :class:`list`, :class:`set`, and :class:`tuple`." msgstr "" -"這個模組實作了一些特別的容器資料型態,用來替代 Python 一般內建的容器,例" +"這個模組實作了一些特別的容器資料型別,用來替代 Python 一般內建的容器,例" "如 :class:`dict`\\ (字典)、:class:`list`\\ (串列)、:class:`set`\\ (集" "合)和 :class:`tuple`\\ (元組)。" @@ -1027,6 +1027,10 @@ msgid "" " with open(filename) as f:\n" " return deque(f, n)" msgstr "" +"def tail(filename, n=10):\n" +" '回傳檔案的最後 n 行'\n" +" with open(filename) as f:\n" +" return deque(f, n)" #: ../../library/collections.rst:663 msgid "" @@ -1078,6 +1082,17 @@ msgid "" " # Remove an exhausted iterator.\n" " iterators.popleft()" msgstr "" +"def roundrobin(*iterables):\n" +" \"roundrobin('ABC', 'D', 'EF') --> A D E B F C\"\n" +" iterators = deque(map(iter, iterables))\n" +" while iterators:\n" +" try:\n" +" while True:\n" +" yield next(iterators[0])\n" +" iterators.rotate(-1)\n" +" except StopIteration:\n" +" # 移除耗盡的疊代器。\n" +" iterators.popleft()" #: ../../library/collections.rst:697 msgid "" @@ -1201,11 +1216,11 @@ msgstr ":class:`defaultdict` 物件支援以下實例變數:" #: ../../library/collections.rst:761 msgid "" -"This attribute is used by the :meth:`__missing__` method; it is initialized " -"from the first argument to the constructor, if present, or to ``None``, if " -"absent." +"This attribute is used by the :meth:`~defaultdict.__missing__` method; it is " +"initialized from the first argument to the constructor, if present, or to " +"``None``, if absent." msgstr "" -"此屬性為 :meth:`__missing__` 方法所使用。如果有引數被傳入建構函式,則此屬性會" +"此屬性為 :meth:`~defaultdict.__missing__` 方法所使用。如果有引數被傳入建構函式,則此屬性會" "被初始化成第一個引數,如未提供引數則被初始化為 ``None``。" #: ../../library/collections.rst:765 ../../library/collections.rst:1192 @@ -1230,19 +1245,19 @@ 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.default_factory` function which returns an " -"empty :class:`list`. The :meth:`!list.append` operation then attaches the " +"empty :class:`list`. The :meth:`list.append` operation then attaches the " "value to the new list. When keys are encountered again, the look-up " -"proceeds normally (returning the list for that key) and the :meth:`!" -"list.append` operation adds another value to the list. This technique is " -"simpler and faster than an equivalent technique " +"proceeds normally (returning the list for that key) and " +"the :meth:`list.append` operation adds another value to the list. This " +"technique is simpler and faster than an equivalent technique " "using :meth:`dict.setdefault`:" msgstr "" "當每個鍵第一次被存取時,它還沒有存在於對映中,所以會自動呼" "叫 :attr:`~defaultdict.default_factory` 方法來回傳一個空的 :class:`list` 以建" -"立一個條目,:meth:`!list.append` 操作後續會再新增值到這個新的列表裡。當再次存" -"取該鍵時,就如普通字典般操作(回傳該鍵所對應到的 list),:meth:`!" -"list.append` 也會新增另一個值到 list 中。和使用與其等價" -"的 :meth:`dict.setdefault` 相比,這個技巧更加快速和簡單:" +"立一個條目,:meth:`list.append` 操作後續會再新增值到這個新的列表裡。當再次存" +"取該鍵時,就如普通字典般操作(回傳該鍵所對應到的 list),:meth:`list.append` " +"也會新增另一個值到 list 中。和使用與其等價的 :meth:`dict.setdefault` 相比,這" +"個技巧更加快速和簡單:" #: ../../library/collections.rst:799 msgid "" @@ -1574,6 +1589,13 @@ msgid "" ">>> Pixel(11, 22, 128, 255, 0)\n" "Pixel(x=11, y=22, red=128, green=255, blue=0)" msgstr "" +">>> p._fields # 查看欄位名稱\n" +"('x', 'y')\n" +"\n" +">>> Color = namedtuple('Color', 'red green blue')\n" +">>> Pixel = namedtuple('Pixel', Point._fields + Color._fields)\n" +">>> Pixel(11, 22, 128, 255, 0)\n" +"Pixel(x=11, y=22, red=128, green=255, blue=0)" #: ../../library/collections.rst:1006 msgid "Dictionary mapping field names to default values." diff --git a/library/colorsys.po b/library/colorsys.po index 3bf03343123..2259120e20f 100644 --- a/library/colorsys.po +++ b/library/colorsys.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -6,7 +6,7 @@ # Matt Wang , 2022 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-03 11:11+0800\n" "PO-Revision-Date: 2022-02-15 20:58+0800\n" diff --git a/library/compileall.po b/library/compileall.po index 645f85c5df9..221b9ee0d56 100644 --- a/library/compileall.po +++ b/library/compileall.po @@ -1,11 +1,10 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2018-05-23 14:41+0000\n" @@ -417,6 +416,17 @@ msgid "" "import pathlib\n" "compileall.compile_dir(pathlib.Path('Lib/'), force=True)" msgstr "" +"import compileall\n" +"\n" +"compileall.compile_dir('Lib/', force=True)\n" +"\n" +"# 執行相同的編譯,但排除 .svn 目錄中的檔案。\n" +"import re\n" +"compileall.compile_dir('Lib/', rx=re.compile(r'[/\\\\][.]svn'), force=True)\n" +"\n" +"# pathlib.Path 物件也可以使用。\n" +"import pathlib\n" +"compileall.compile_dir(pathlib.Path('Lib/'), force=True)" #: ../../library/compileall.rst:347 msgid "Module :mod:`py_compile`" diff --git a/library/compression.po b/library/compression.po new file mode 100644 index 00000000000..db9321737a5 --- /dev/null +++ b/library/compression.po @@ -0,0 +1,55 @@ +# 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.14\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-10-05 00:16+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/compression.rst:2 +msgid "The :mod:`!compression` package" +msgstr ":mod:`!compression` 套件" + +#: ../../library/compression.rst:8 +msgid "" +"The :mod:`!compression` package contains the canonical compression modules " +"containing interfaces to several different compression algorithms. Some of " +"these modules have historically been available as separate modules; those " +"will continue to be available under their original names for compatibility " +"reasons, and will not be removed without a deprecation cycle. The use of " +"modules in :mod:`!compression` is encouraged where practical." +msgstr "" +":mod:`!compression` 套件包含了有多種不同壓縮演算法介面的標準壓縮模組。其中一些模組過去" +"是以獨立模組的形式提供;為了相容性考量,這些模組將繼續以其原始名稱提供,並且不會在沒有經過" +"棄用週期的情況下被移除。建議在可行的情況下盡量先使用 :mod:`!compression` 中的模組。" + +#: ../../library/compression.rst:15 +msgid ":mod:`!compression.bz2` -- Re-exports :mod:`bz2`" +msgstr ":mod:`!compression.bz2` -- 重新匯出 :mod:`bz2`" + +#: ../../library/compression.rst:16 +msgid ":mod:`!compression.gzip` -- Re-exports :mod:`gzip`" +msgstr ":mod:`!compression.gzip` -- 重新匯出 :mod:`gzip`" + +#: ../../library/compression.rst:17 +msgid ":mod:`!compression.lzma` -- Re-exports :mod:`lzma`" +msgstr ":mod:`!compression.lzma` -- 重新匯出 :mod:`lzma`" + +#: ../../library/compression.rst:18 +msgid ":mod:`!compression.zlib` -- Re-exports :mod:`zlib`" +msgstr ":mod:`!compression.zlib` -- 重新匯出 :mod:`zlib`" + +#: ../../library/compression.rst:19 +msgid "" +":mod:`compression.zstd` -- Wrapper for the Zstandard compression library" +msgstr ":mod:`compression.zstd` -- Zstandard 壓縮函式庫的包裝器" diff --git a/library/compression.zstd.po b/library/compression.zstd.po new file mode 100644 index 00000000000..5025aec25c5 --- /dev/null +++ b/library/compression.zstd.po @@ -0,0 +1,1198 @@ +# Copyright (C) 2001 Python Software Foundation +# This file is distributed under the same license as the Python package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: Python 3.14\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-11-10 16:45+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/compression.zstd.rst:2 +msgid "" +":mod:`!compression.zstd` --- Compression compatible with the Zstandard format" +msgstr ":mod:`!compression.zstd` --- 與 Zstandard 格式相容的壓縮" + +#: ../../library/compression.zstd.rst:10 +msgid "**Source code:** :source:`Lib/compression/zstd/__init__.py`" +msgstr "**原始碼:**\\ :source:`Lib/compression/zstd/__init__.py`" + +#: ../../library/compression.zstd.rst:14 +msgid "" +"This module provides classes and functions for compressing and decompressing " +"data using the Zstandard (or *zstd*) compression algorithm. The `zstd manual " +"`__ describes " +"Zstandard as \"a fast lossless compression algorithm, targeting real-time " +"compression scenarios at zlib-level and better compression ratios.\" Also " +"included is a file interface that supports reading and writing the contents " +"of ``.zst`` files created by the :program:`zstd` utility, as well as raw " +"zstd compressed streams." +msgstr "" + +#: ../../library/compression.zstd.rst:23 +msgid "The :mod:`!compression.zstd` module contains:" +msgstr ":mod:`!compression.zstd` 模組包含:" + +#: ../../library/compression.zstd.rst:25 +msgid "" +"The :func:`.open` function and :class:`ZstdFile` class for reading and " +"writing compressed files." +msgstr "" + +#: ../../library/compression.zstd.rst:27 +msgid "" +"The :class:`ZstdCompressor` and :class:`ZstdDecompressor` classes for " +"incremental (de)compression." +msgstr "" + +#: ../../library/compression.zstd.rst:29 +msgid "" +"The :func:`compress` and :func:`decompress` functions for one-shot " +"(de)compression." +msgstr "" + +#: ../../library/compression.zstd.rst:31 +msgid "" +"The :func:`train_dict` and :func:`finalize_dict` functions and the :class:" +"`ZstdDict` class to train and manage Zstandard dictionaries." +msgstr "" + +#: ../../library/compression.zstd.rst:33 +msgid "" +"The :class:`CompressionParameter`, :class:`DecompressionParameter`, and :" +"class:`Strategy` classes for setting advanced (de)compression parameters." +msgstr "" + +#: ../../includes/optional-module.rst:1 +msgid "" +"This is an :term:`optional module`. If it is missing from your copy of " +"CPython, look for documentation from your distributor (that is, whoever " +"provided Python to you). If you are the distributor, see :ref:`optional-" +"module-requirements`." +msgstr "" + +#: ../../library/compression.zstd.rst:40 +msgid "Exceptions" +msgstr "例外" + +#: ../../library/compression.zstd.rst:44 +msgid "" +"This exception is raised when an error occurs during compression or " +"decompression, or while initializing the (de)compressor state." +msgstr "" + +#: ../../library/compression.zstd.rst:49 +msgid "Reading and writing compressed files" +msgstr "" + +#: ../../library/compression.zstd.rst:54 +msgid "" +"Open a Zstandard-compressed file in binary or text mode, returning a :term:" +"`file object`." +msgstr "" + +#: ../../library/compression.zstd.rst:57 +msgid "" +"The *file* argument can be either a file name (given as a :class:`str`, :" +"class:`bytes` or :term:`path-like ` object), in which case " +"the named file is opened, or it can be an existing file object to read from " +"or write to." +msgstr "" + +#: ../../library/compression.zstd.rst:62 +msgid "" +"The mode argument can be either ``'rb'`` for reading (default), ``'wb'`` for " +"overwriting, ``'ab'`` for appending, or ``'xb'`` for exclusive creation. " +"These can equivalently be given as ``'r'``, ``'w'``, ``'a'``, and ``'x'`` " +"respectively. You may also open in text mode with ``'rt'``, ``'wt'``, " +"``'at'``, and ``'xt'`` respectively." +msgstr "" + +#: ../../library/compression.zstd.rst:68 ../../library/compression.zstd.rst:112 +msgid "" +"When reading, the *options* argument can be a dictionary providing advanced " +"decompression parameters; see :class:`DecompressionParameter` for detailed " +"information about supported parameters. The *zstd_dict* argument is a :class:" +"`ZstdDict` instance to be used during decompression. When reading, if the " +"*level* argument is not None, a :exc:`!TypeError` will be raised." +msgstr "" + +#: ../../library/compression.zstd.rst:75 +msgid "" +"When writing, the *options* argument can be a dictionary providing advanced " +"decompression parameters; see :class:`CompressionParameter` for detailed " +"information about supported parameters. The *level* argument is the " +"compression level to use when writing compressed data. Only one of *level* " +"or *options* may be non-None. The *zstd_dict* argument is a :class:" +"`ZstdDict` instance to be used during compression." +msgstr "" + +#: ../../library/compression.zstd.rst:83 +msgid "" +"In binary mode, this function is equivalent to the :class:`ZstdFile` " +"constructor: ``ZstdFile(file, mode, ...)``. In this case, the *encoding*, " +"*errors*, and *newline* parameters must not be provided." +msgstr "" + +#: ../../library/compression.zstd.rst:87 +msgid "" +"In text mode, a :class:`ZstdFile` object is created, and wrapped in an :" +"class:`io.TextIOWrapper` instance with the specified encoding, error " +"handling behavior, and line endings." +msgstr "" + +#: ../../library/compression.zstd.rst:95 +msgid "Open a Zstandard-compressed file in binary mode." +msgstr "" + +#: ../../library/compression.zstd.rst:97 +msgid "" +"A :class:`ZstdFile` can wrap an already-open :term:`file object`, or operate " +"directly on a named file. The *file* argument specifies either the file " +"object to wrap, or the name of the file to open (as a :class:`str`, :class:" +"`bytes` or :term:`path-like ` object). If wrapping an " +"existing file object, the wrapped file will not be closed when the :class:" +"`ZstdFile` is closed." +msgstr "" + +#: ../../library/compression.zstd.rst:104 +msgid "" +"The *mode* argument can be either ``'rb'`` for reading (default), ``'wb'`` " +"for overwriting, ``'xb'`` for exclusive creation, or ``'ab'`` for appending. " +"These can equivalently be given as ``'r'``, ``'w'``, ``'x'`` and ``'a'`` " +"respectively." +msgstr "" + +#: ../../library/compression.zstd.rst:109 +msgid "" +"If *file* 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/compression.zstd.rst:119 +msgid "" +"When writing, the *options* argument can be a dictionary providing advanced " +"decompression parameters; see :class:`CompressionParameter` for detailed " +"information about supported parameters. The *level* argument is the " +"compression level to use when writing compressed data. Only one of *level* " +"or *options* may be passed. The *zstd_dict* argument is a :class:`ZstdDict` " +"instance to be used during compression." +msgstr "" + +#: ../../library/compression.zstd.rst:127 +msgid "" +":class:`!ZstdFile` 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/compression.zstd.rst:132 +msgid "The following method and attributes are also provided:" +msgstr "" + +#: ../../library/compression.zstd.rst:136 +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/compression.zstd.rst:140 +msgid "" +"While calling :meth:`peek` does not change the file position of the :class:" +"`ZstdFile`, it may change the position of the underlying file object (for " +"example, if the :class:`ZstdFile` was constructed by passing a file object " +"for *file*)." +msgstr "" + +#: ../../library/compression.zstd.rst:147 +msgid "``'rb'`` for reading and ``'wb'`` for writing." +msgstr "" + +#: ../../library/compression.zstd.rst:151 +msgid "" +"The name of the Zstandard file. Equivalent to the :attr:`~io.FileIO.name` " +"attribute of the underlying :term:`file object`." +msgstr "" + +#: ../../library/compression.zstd.rst:156 +msgid "Compressing and decompressing data in memory" +msgstr "" + +#: ../../library/compression.zstd.rst:160 +msgid "" +"Compress *data* (a :term:`bytes-like object`), returning the compressed data " +"as a :class:`bytes` object." +msgstr "" + +#: ../../library/compression.zstd.rst:163 +#: ../../library/compression.zstd.rst:207 +msgid "" +"The *level* argument is an integer controlling the level of compression. " +"*level* is an alternative to setting :attr:`CompressionParameter." +"compression_level` in *options*. Use :meth:`~CompressionParameter.bounds` " +"on :attr:`~CompressionParameter.compression_level` to get the values that " +"can be passed for *level*. If advanced compression options are needed, the " +"*level* argument must be omitted and in the *options* dictionary the :attr:`!" +"CompressionParameter.compression_level` parameter should be set." +msgstr "" + +#: ../../library/compression.zstd.rst:172 +#: ../../library/compression.zstd.rst:216 +msgid "" +"The *options* argument is a Python dictionary containing advanced " +"compression parameters. The valid keys and values for compression parameters " +"are documented as part of the :class:`CompressionParameter` documentation." +msgstr "" + +#: ../../library/compression.zstd.rst:176 +msgid "" +"The *zstd_dict* argument is an instance of :class:`ZstdDict` containing " +"trained data to improve compression efficiency. The function :func:" +"`train_dict` can be used to generate a Zstandard dictionary." +msgstr "" + +#: ../../library/compression.zstd.rst:183 +msgid "" +"Decompress *data* (a :term:`bytes-like object`), returning the uncompressed " +"data as a :class:`bytes` object." +msgstr "" + +#: ../../library/compression.zstd.rst:186 +#: ../../library/compression.zstd.rst:308 +msgid "" +"The *options* argument is a Python dictionary containing advanced " +"decompression parameters. The valid keys and values for compression " +"parameters are documented as part of the :class:`DecompressionParameter` " +"documentation." +msgstr "" + +#: ../../library/compression.zstd.rst:191 +#: ../../library/compression.zstd.rst:313 +msgid "" +"The *zstd_dict* argument is an instance of :class:`ZstdDict` containing " +"trained data used during compression. This must be the same Zstandard " +"dictionary used during compression." +msgstr "" + +#: ../../library/compression.zstd.rst:195 +msgid "" +"If *data* is the concatenation of multiple distinct compressed frames, " +"decompress all of these frames, and return the concatenation of the results." +msgstr "" + +#: ../../library/compression.zstd.rst:201 +msgid "" +"Create a compressor object, which can be used to compress data incrementally." +msgstr "" + +#: ../../library/compression.zstd.rst:204 +msgid "" +"For a more convenient way of compressing a single chunk of data, see the " +"module-level function :func:`compress`." +msgstr "" + +#: ../../library/compression.zstd.rst:220 +msgid "" +"The *zstd_dict* argument is an optional instance of :class:`ZstdDict` " +"containing trained data to improve compression efficiency. The function :" +"func:`train_dict` can be used to generate a Zstandard dictionary." +msgstr "" + +#: ../../library/compression.zstd.rst:227 +msgid "" +"Compress *data* (a :term:`bytes-like object`), returning a :class:`bytes` " +"object with compressed data if possible, or otherwise an empty :class:`!" +"bytes` object. Some of *data* may be buffered internally, for use in later " +"calls to :meth:`!compress` and :meth:`~.flush`. The returned data should be " +"concatenated with the output of any previous calls to :meth:`~.compress`." +msgstr "" + +#: ../../library/compression.zstd.rst:234 +msgid "" +"The *mode* argument is a :class:`ZstdCompressor` attribute, either :attr:`~." +"CONTINUE`, :attr:`~.FLUSH_BLOCK`, or :attr:`~.FLUSH_FRAME`." +msgstr "" + +#: ../../library/compression.zstd.rst:238 +msgid "" +"When all data has been provided to the compressor, call the :meth:`~.flush` " +"method to finish the compression process. If :meth:`~.compress` is called " +"with *mode* set to :attr:`~.FLUSH_FRAME`, :meth:`~.flush` should not be " +"called, as it would write out a new empty frame." +msgstr "" + +#: ../../library/compression.zstd.rst:246 +msgid "" +"Finish the compression process, returning a :class:`bytes` object containing " +"any data stored in the compressor's internal buffers." +msgstr "" + +#: ../../library/compression.zstd.rst:249 +msgid "" +"The *mode* argument is a :class:`ZstdCompressor` attribute, either :attr:`~." +"FLUSH_BLOCK`, or :attr:`~.FLUSH_FRAME`." +msgstr "" + +#: ../../library/compression.zstd.rst:254 +msgid "" +"Specify the amount of uncompressed data *size* that will be provided for the " +"next frame. *size* will be written into the frame header of the next frame " +"unless :attr:`CompressionParameter.content_size_flag` is ``False`` or ``0``. " +"A size of ``0`` means that the frame is empty. If *size* is ``None``, the " +"frame header will omit the frame size. Frames that include the uncompressed " +"data size require less memory to decompress, especially at higher " +"compression levels." +msgstr "" + +#: ../../library/compression.zstd.rst:262 +msgid "" +"If :attr:`last_mode` is not :attr:`FLUSH_FRAME`, a :exc:`ValueError` is " +"raised as the compressor is not at the start of a frame. If the pledged size " +"does not match the actual size of data provided to :meth:`.compress`, future " +"calls to :meth:`!compress` or :meth:`flush` may raise :exc:`ZstdError` and " +"the last chunk of data may be lost." +msgstr "" + +#: ../../library/compression.zstd.rst:269 +msgid "" +"After :meth:`flush` or :meth:`.compress` are called with mode :attr:" +"`FLUSH_FRAME`, the next frame will not include the frame size into the " +"header unless :meth:`!set_pledged_input_size` is called again." +msgstr "" + +#: ../../library/compression.zstd.rst:275 +msgid "" +"Collect more data for compression, which may or may not generate output " +"immediately. This mode optimizes the compression ratio by maximizing the " +"amount of data per block and frame." +msgstr "" + +#: ../../library/compression.zstd.rst:281 +msgid "" +"Complete and write a block to the data stream. The data returned so far can " +"be immediately decompressed. Past data can still be referenced in future " +"blocks generated by calls to :meth:`~.compress`, improving compression." +msgstr "" + +#: ../../library/compression.zstd.rst:288 +msgid "" +"Complete and write out a frame. Future data provided to :meth:`~.compress` " +"will be written into a new frame and *cannot* reference past data." +msgstr "" + +#: ../../library/compression.zstd.rst:294 +msgid "" +"The last mode passed to either :meth:`~.compress` or :meth:`~.flush`. The " +"value can be one of :attr:`~.CONTINUE`, :attr:`~.FLUSH_BLOCK`, or :attr:`~." +"FLUSH_FRAME`. The initial value is :attr:`~.FLUSH_FRAME`, signifying that " +"the compressor is at the start of a new frame." +msgstr "" + +#: ../../library/compression.zstd.rst:302 +msgid "" +"Create a decompressor object, which can be used to decompress data " +"incrementally." +msgstr "" + +#: ../../library/compression.zstd.rst:305 +msgid "" +"For a more convenient way of decompressing an entire compressed stream at " +"once, see the module-level function :func:`decompress`." +msgstr "" + +#: ../../library/compression.zstd.rst:318 +msgid "" +"This class does not transparently handle inputs containing multiple " +"compressed frames, unlike the :func:`decompress` function and :class:" +"`ZstdFile` class. To decompress a multi-frame input, you should use :func:" +"`decompress`, :class:`ZstdFile` if working with a :term:`file object`, or " +"multiple :class:`!ZstdDecompressor` instances." +msgstr "" + +#: ../../library/compression.zstd.rst:326 +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 " +"to :meth:`!decompress`. The returned data should be concatenated with the " +"output of any previous calls to :meth:`!decompress`." +msgstr "" + +#: ../../library/compression.zstd.rst:332 +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." +msgstr "" + +#: ../../library/compression.zstd.rst:339 +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 +msgid "" +"Attempting to decompress data after the end of a frame will raise a :exc:" +"`ZstdError`. 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 +msgid "``True`` if the end-of-stream marker has been reached." +msgstr "" + +#: ../../library/compression.zstd.rst:354 +msgid "Data found after the end of the compressed stream." +msgstr "" + +#: ../../library/compression.zstd.rst:356 +msgid "Before the end of the stream is reached, this will be ``b''``." +msgstr "" + +#: ../../library/compression.zstd.rst:360 +msgid "" +"``False`` if the :meth:`.decompress` method can provide more decompressed " +"data before requiring new compressed input." +msgstr "" + +#: ../../library/compression.zstd.rst:365 +msgid "Zstandard dictionaries" +msgstr "Zstandard 字典" + +#: ../../library/compression.zstd.rst:370 +msgid "" +"Train a Zstandard dictionary, returning a :class:`ZstdDict` instance. " +"Zstandard dictionaries enable more efficient compression of smaller sizes of " +"data, which is traditionally difficult to compress due to less repetition. " +"If you are compressing multiple similar groups of data (such as similar " +"files), Zstandard dictionaries can improve compression ratios and speed " +"significantly." +msgstr "" + +#: ../../library/compression.zstd.rst:377 +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 +msgid "" +"The *dict_size* argument, an integer, is the maximum size (in bytes) the " +"Zstandard dictionary should be. The Zstandard documentation suggests an " +"absolute maximum of no more than 100 KB, but the maximum can often be " +"smaller depending on the data. Larger dictionaries generally slow down " +"compression, but improve compression ratios. Smaller dictionaries lead to " +"faster compression, but reduce the compression ratio." +msgstr "" + +#: ../../library/compression.zstd.rst:390 +msgid "" +"An advanced function for converting a \"raw content\" Zstandard dictionary " +"into a regular Zstandard dictionary. \"Raw content\" dictionaries are a " +"sequence of bytes that do not need to follow the structure of a normal " +"Zstandard dictionary." +msgstr "" + +#: ../../library/compression.zstd.rst:395 +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 +msgid "" +"The *samples* argument (an iterable of :class:`bytes` objects), contains " +"sample data for generating the Zstandard dictionary." +msgstr "" + +#: ../../library/compression.zstd.rst:401 +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 +msgid "" +"The *level* argument (an integer) is the compression level expected to be " +"passed to the compressors using this dictionary. The dictionary information " +"varies for each compression level, so tuning for the proper compression " +"level can make compression more efficient." +msgstr "" + +#: ../../library/compression.zstd.rst:413 +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 +msgid "" +"The *dict_content* argument (a :term:`bytes-like object`), is the already " +"trained dictionary information." +msgstr "" + +#: ../../library/compression.zstd.rst:420 +msgid "" +"The *is_raw* argument, a boolean, is an advanced parameter controlling the " +"meaning of *dict_content*. ``True`` means *dict_content* is a \"raw " +"content\" dictionary, without any format restrictions. ``False`` means " +"*dict_content* is an ordinary Zstandard dictionary, created from Zstandard " +"functions, for example, :func:`train_dict` or the external :program:`zstd` " +"CLI." +msgstr "" + +#: ../../library/compression.zstd.rst:426 +msgid "" +"When passing a :class:`!ZstdDict` to a function, the :attr:`!" +"as_digested_dict` and :attr:`!as_undigested_dict` attributes can control how " +"the dictionary is loaded by passing them as the ``zstd_dict`` argument, for " +"example, ``compress(data, zstd_dict=zd.as_digested_dict)``. Digesting a " +"dictionary is a costly operation that occurs when loading a Zstandard " +"dictionary. When making multiple calls to compression or decompression, " +"passing a digested dictionary will reduce the overhead of loading the " +"dictionary." +msgstr "" + +#: ../../library/compression.zstd.rst:435 +msgid "Difference for compression" +msgstr "" + +#: ../../library/compression.zstd.rst:440 +msgid "Digested dictionary" +msgstr "" + +#: ../../library/compression.zstd.rst:441 +msgid "Undigested dictionary" +msgstr "" + +#: ../../library/compression.zstd.rst:442 +msgid "" +"Advanced parameters of the compressor which may be overridden by the " +"dictionary's parameters" +msgstr "" + +#: ../../library/compression.zstd.rst:444 +msgid "" +"``window_log``, ``hash_log``, ``chain_log``, ``search_log``, ``min_match``, " +"``target_length``, ``strategy``, ``enable_long_distance_matching``, " +"``ldm_hash_log``, ``ldm_min_match``, ``ldm_bucket_size_log``, " +"``ldm_hash_rate_log``, and some non-public parameters." +msgstr "" + +#: ../../library/compression.zstd.rst:449 +msgid "None" +msgstr "" + +#: ../../library/compression.zstd.rst:450 +msgid ":class:`!ZstdDict` internally caches the dictionary" +msgstr "" + +#: ../../library/compression.zstd.rst:451 +msgid "" +"Yes. It's faster when loading a digested dictionary again with the same " +"compression level." +msgstr "" + +#: ../../library/compression.zstd.rst:453 +msgid "" +"No. If you wish to load an undigested dictionary multiple times, consider " +"reusing a compressor object." +msgstr "" + +#: ../../library/compression.zstd.rst:456 +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 +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 +msgid "Identifier of the Zstandard dictionary, a non-negative int value." +msgstr "" + +#: ../../library/compression.zstd.rst:470 +msgid "" +"Non-zero means the dictionary is ordinary, created by Zstandard functions " +"and following the Zstandard format." +msgstr "" + +#: ../../library/compression.zstd.rst:473 +msgid "" +"``0`` means a \"raw content\" dictionary, free of any format restriction, " +"used for advanced users." +msgstr "" + +#: ../../library/compression.zstd.rst:478 +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 +msgid "Load as a digested dictionary." +msgstr "" + +#: ../../library/compression.zstd.rst:488 +msgid "Load as an undigested dictionary." +msgstr "" + +#: ../../library/compression.zstd.rst:492 +msgid "Advanced parameter control" +msgstr "" + +#: ../../library/compression.zstd.rst:496 +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 +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 +msgid "" +"Parameters are optional; any omitted parameter will have it's value selected " +"automatically." +msgstr "" + +#: ../../library/compression.zstd.rst:505 +msgid "" +"Example getting the lower and upper bound of :attr:`~.compression_level`::" +msgstr "" + +#: ../../library/compression.zstd.rst:507 +msgid "lower, upper = CompressionParameter.compression_level.bounds()" +msgstr "" + +#: ../../library/compression.zstd.rst:509 +msgid "Example setting the :attr:`~.window_log` to the maximum size::" +msgstr "" + +#: ../../library/compression.zstd.rst:511 +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 +msgid "" +"Return the tuple of int bounds, ``(lower, upper)``, of a compression " +"parameter. This method should be called on the attribute you wish to " +"retrieve the bounds of. For example, to get the valid values for :attr:`~." +"compression_level`, one may check the result of ``CompressionParameter." +"compression_level.bounds()``." +msgstr "" + +#: ../../library/compression.zstd.rst:523 +#: ../../library/compression.zstd.rst:751 +msgid "Both the lower and upper bounds are inclusive." +msgstr "" + +#: ../../library/compression.zstd.rst:527 +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 +msgid "" +"Regular compression levels are greater than ``0``. Values greater than " +"``20`` are considered \"ultra\" compression and require more memory than " +"other levels. Negative values can be used to trade off faster compression " +"for worse compression ratios." +msgstr "" + +#: ../../library/compression.zstd.rst:535 +msgid "Setting the level to zero uses :attr:`COMPRESSION_LEVEL_DEFAULT`." +msgstr "" + +#: ../../library/compression.zstd.rst:539 +msgid "" +"Maximum allowed back-reference distance the compressor can use when " +"compressing data, expressed as power of two, ``1 << window_log`` bytes. This " +"parameter greatly influences the memory usage of compression. Higher values " +"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 +msgid "A value of zero causes the value to be selected automatically." +msgstr "" + +#: ../../library/compression.zstd.rst:548 +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 " +"ratio of strategies <= :attr:`~Strategy.dfast`, and improve compression " +"speed of strategies > :attr:`~Strategy.dfast`." +msgstr "" + +#: ../../library/compression.zstd.rst:557 +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 " +"and slower compression. This parameter has no effect for the :attr:" +"`~Strategy.fast` strategy. It's still useful when using :attr:`~Strategy." +"dfast` strategy, in which case it defines a secondary probe table." +msgstr "" + +#: ../../library/compression.zstd.rst:568 +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 +msgid "" +"Minimum size of searched matches. Larger values increase compression and " +"decompression speed, but decrease ratio. Note that Zstandard can still find " +"matches of smaller size, it just tweaks its search algorithm to look for " +"this size and larger. For all strategies < :attr:`~Strategy.btopt`, the " +"effective minimum is ``4``; for all strategies > :attr:`~Strategy.fast`, the " +"effective maximum is ``6``." +msgstr "" + +#: ../../library/compression.zstd.rst:587 +msgid "The impact of this field depends on the selected :class:`Strategy`." +msgstr "" + +#: ../../library/compression.zstd.rst:589 +msgid "" +"For strategies :attr:`~Strategy.btopt`, :attr:`~Strategy.btultra` and :attr:" +"`~Strategy.btultra2`, the value is the length of a match considered \"good " +"enough\" to stop searching. Larger values make compression ratios better, " +"but compresses slower." +msgstr "" + +#: ../../library/compression.zstd.rst:594 +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 +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 +msgid ":class:`Strategy`" +msgstr ":class:`Strategy`" + +#: ../../library/compression.zstd.rst:610 +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 +msgid "" +"``True`` or ``1`` enable long distance matching while ``False`` or ``0`` " +"disable it." +msgstr "" + +#: ../../library/compression.zstd.rst:617 +msgid "" +"Enabling this parameter increases default :attr:`~CompressionParameter." +"window_log` to 128 MiB except when expressly set to a different value. This " +"setting is enabled by default if :attr:`!window_log` >= 128 MiB and the " +"compression strategy >= :attr:`~Strategy.btopt` (compression level 16+)." +msgstr "" + +#: ../../library/compression.zstd.rst:625 +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 +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 +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 +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 +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 +msgid "This flag only takes effect under the following scenarios:" +msgstr "" + +#: ../../library/compression.zstd.rst:661 +msgid "Calling :func:`compress` for one-shot compression" +msgstr "" + +#: ../../library/compression.zstd.rst:662 +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 +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:" +"`ZstdCompressor.compress` for the current frame. :meth:`!ZstdCompressor." +"set_pledged_input_size` must be called for each new frame." +msgstr "" + +#: ../../library/compression.zstd.rst:671 +msgid "" +"All other compression calls may not write the size information into the " +"frame header." +msgstr "" + +#: ../../library/compression.zstd.rst:674 +msgid "" +"``True`` or ``1`` enable the content size flag while ``False`` or ``0`` " +"disable it." +msgstr "" + +#: ../../library/compression.zstd.rst:679 +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 +msgid "" +"``True`` or ``1`` enable checksum generation while ``False`` or ``0`` " +"disable it." +msgstr "" + +#: ../../library/compression.zstd.rst:689 +msgid "" +"When compressing with a :class:`ZstdDict`, the dictionary's ID is written " +"into the frame header." +msgstr "" + +#: ../../library/compression.zstd.rst:692 +msgid "" +"``True`` or ``1`` enable storing the dictionary ID while ``False`` or ``0`` " +"disable it." +msgstr "" + +#: ../../library/compression.zstd.rst:697 +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`` " +"means \"one-thread multi-threaded mode\". More workers improve speed, but " +"also increase memory usage and slightly reduce compression ratio." +msgstr "" + +#: ../../library/compression.zstd.rst:702 +msgid "A value of zero disables multi-threading." +msgstr "" + +#: ../../library/compression.zstd.rst:706 +msgid "" +"Size of a compression job, in bytes. This value is enforced only when :attr:" +"`~CompressionParameter.nb_workers` >= 1. Each compression job is completed " +"in parallel, so this value can indirectly impact the number of active " +"threads." +msgstr "" + +#: ../../library/compression.zstd.rst:715 +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 " +"used when :attr:`~CompressionParameter.nb_workers` >= 1. Acceptable values " +"vary from 0 to 9." +msgstr "" + +#: ../../library/compression.zstd.rst:720 +msgid "0 means dynamically set the overlap amount" +msgstr "" + +#: ../../library/compression.zstd.rst:721 +msgid "1 means no overlap" +msgstr "" + +#: ../../library/compression.zstd.rst:722 +msgid "9 means use a full window size from the previous job" +msgstr "" + +#: ../../library/compression.zstd.rst:724 +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 +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 it's value selected automatically." +msgstr "" + +#: ../../library/compression.zstd.rst:736 +msgid "Example setting the :attr:`~.window_log_max` to the maximum size::" +msgstr "" + +#: ../../library/compression.zstd.rst:738 +msgid "" +"data = compress(b'Some very long buffer of bytes...')\n" +"\n" +"_lower, upper = DecompressionParameter.window_log_max.bounds()\n" +"\n" +"options = {DecompressionParameter.window_log_max: upper}\n" +"decompress(data, options=options)" +msgstr "" +"data = compress(b'Some very long buffer of bytes...')\n" +"\n" +"_lower, upper = DecompressionParameter.window_log_max.bounds()\n" +"\n" +"options = {DecompressionParameter.window_log_max: upper}\n" +"decompress(data, options=options)" + +#: ../../library/compression.zstd.rst:747 +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 +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 " +"decompressing data. A larger maximum window size leads to faster " +"decompression." +msgstr "" + +#: ../../library/compression.zstd.rst:765 +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 +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 +msgid "The following strategies are available:" +msgstr "" + +#: ../../library/compression.zstd.rst:797 +msgid "Miscellaneous" +msgstr "" + +#: ../../library/compression.zstd.rst:801 +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 +msgid "Metadata related to a Zstandard frame." +msgstr "" + +#: ../../library/compression.zstd.rst:811 +msgid "The size of the decompressed contents of the frame." +msgstr "" + +#: ../../library/compression.zstd.rst:815 +msgid "" +"An integer representing the Zstandard dictionary ID needed for decompressing " +"the frame. ``0`` means the dictionary ID was not recorded in the frame " +"header. This may mean that a Zstandard dictionary is not needed, or that the " +"ID of a required dictionary was not recorded." +msgstr "" + +#: ../../library/compression.zstd.rst:823 +msgid "The default compression level for Zstandard: ``3``." +msgstr "" + +#: ../../library/compression.zstd.rst:828 +msgid "" +"Version number of the runtime zstd library as a tuple of integers (major, " +"minor, release)." +msgstr "" + +#: ../../library/compression.zstd.rst:833 +msgid "Examples" +msgstr "範例" + +#: ../../library/compression.zstd.rst:835 +msgid "Reading in a compressed file:" +msgstr "讀取壓縮檔案:" + +#: ../../library/compression.zstd.rst:837 +msgid "" +"from compression import zstd\n" +"\n" +"with zstd.open(\"file.zst\") as f:\n" +" file_content = f.read()" +msgstr "" +"from compression import zstd\n" +"\n" +"with zstd.open(\"file.zst\") as f:\n" +" file_content = f.read()" + +#: ../../library/compression.zstd.rst:844 +msgid "Creating a compressed file:" +msgstr "" + +#: ../../library/compression.zstd.rst:846 +msgid "" +"from compression import zstd\n" +"\n" +"data = b\"Insert Data Here\"\n" +"with zstd.open(\"file.zst\", \"w\") as f:\n" +" f.write(data)" +msgstr "" +"from compression import zstd\n" +"\n" +"data = b\"Insert Data Here\"\n" +"with zstd.open(\"file.zst\", \"w\") as f:\n" +" f.write(data)" + +#: ../../library/compression.zstd.rst:854 +msgid "Compressing data in memory:" +msgstr "" + +#: ../../library/compression.zstd.rst:856 +msgid "" +"from compression import zstd\n" +"\n" +"data_in = b\"Insert Data Here\"\n" +"data_out = zstd.compress(data_in)" +msgstr "" +"from compression import zstd\n" +"\n" +"data_in = b\"Insert Data Here\"\n" +"data_out = zstd.compress(data_in)" + +#: ../../library/compression.zstd.rst:863 +msgid "Incremental compression:" +msgstr "" + +#: ../../library/compression.zstd.rst:865 +msgid "" +"from compression import zstd\n" +"\n" +"comp = zstd.ZstdCompressor()\n" +"out1 = comp.compress(b\"Some data\\n\")\n" +"out2 = comp.compress(b\"Another piece of data\\n\")\n" +"out3 = comp.compress(b\"Even more data\\n\")\n" +"out4 = comp.flush()\n" +"# Concatenate all the partial results:\n" +"result = b\"\".join([out1, out2, out3, out4])" +msgstr "" +"from compression import zstd\n" +"\n" +"comp = zstd.ZstdCompressor()\n" +"out1 = comp.compress(b\"Some data\\n\")\n" +"out2 = comp.compress(b\"Another piece of data\\n\")\n" +"out3 = comp.compress(b\"Even more data\\n\")\n" +"out4 = comp.flush()\n" +"# Concatenate all the partial results:\n" +"result = b\"\".join([out1, out2, out3, out4])" + +#: ../../library/compression.zstd.rst:877 +msgid "Writing compressed data to an already-open file:" +msgstr "" + +#: ../../library/compression.zstd.rst:879 +msgid "" +"from compression import zstd\n" +"\n" +"with open(\"myfile\", \"wb\") as f:\n" +" f.write(b\"This data will not be compressed\\n\")\n" +" with zstd.open(f, \"w\") as zstf:\n" +" zstf.write(b\"This *will* be compressed\\n\")\n" +" f.write(b\"Not compressed\\n\")" +msgstr "" +"from compression import zstd\n" +"\n" +"with open(\"myfile\", \"wb\") as f:\n" +" f.write(b\"This data will not be compressed\\n\")\n" +" with zstd.open(f, \"w\") as zstf:\n" +" zstf.write(b\"This *will* be compressed\\n\")\n" +" f.write(b\"Not compressed\\n\")" + +#: ../../library/compression.zstd.rst:889 +msgid "Creating a compressed file using compression parameters:" +msgstr "" + +#: ../../library/compression.zstd.rst:891 +msgid "" +"from compression import zstd\n" +"\n" +"options = {\n" +" zstd.CompressionParameter.checksum_flag: 1\n" +"}\n" +"with zstd.open(\"file.zst\", \"w\", options=options) as f:\n" +" f.write(b\"Mind if I squeeze in?\")" +msgstr "" +"from compression import zstd\n" +"\n" +"options = {\n" +" zstd.CompressionParameter.checksum_flag: 1\n" +"}\n" +"with zstd.open(\"file.zst\", \"w\", options=options) as f:\n" +" f.write(b\"Mind if I squeeze in?\")" diff --git a/library/concurrency.po b/library/concurrency.po index fc7278d186b..aee93b82e77 100644 --- a/library/concurrency.po +++ b/library/concurrency.po @@ -1,14 +1,13 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Matt Wang , 2021 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-09-13 00:11+0000\n" +"POT-Creation-Date: 2025-09-08 15:25+0800\n" "PO-Revision-Date: 2021-11-23 13:36+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -36,6 +35,6 @@ msgstr "" "行什麼樣的任務(CPU 密集或 IO 密集)與偏好的開發風格(事件驅動協作式多工處理" "或搶占式多工處理)。以下為此章節總覽:" -#: ../../library/concurrency.rst:27 +#: ../../library/concurrency.rst:28 msgid "The following are support modules for some of the above services:" msgstr "以下是支援部份上述服務的模組:" diff --git a/library/concurrent.futures.po b/library/concurrent.futures.po index 1ad6ca601ae..27a025e3b45 100644 --- a/library/concurrent.futures.po +++ b/library/concurrent.futures.po @@ -1,13 +1,13 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Matt Wang , 2023-2024 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-08-16 00:16+0000\n" +"POT-Creation-Date: 2025-10-26 00:15+0000\n" "PO-Revision-Date: 2023-01-24 03:33+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -25,13 +25,15 @@ msgstr ":mod:`!concurrent.futures` --- 啟動平行任務" #: ../../library/concurrent.futures.rst:9 msgid "" -"**Source code:** :source:`Lib/concurrent/futures/thread.py` and :source:`Lib/" -"concurrent/futures/process.py`" +"**Source code:** :source:`Lib/concurrent/futures/thread.py`, :source:`Lib/" +"concurrent/futures/process.py`, and :source:`Lib/concurrent/futures/" +"interpreter.py`" msgstr "" -"**原始碼:**\\ :source:`Lib/concurrent/futures/thread.py` 與 :source:`Lib/" -"concurrent/futures/process.py`" +"**原始碼:**\\ :source:`Lib/concurrent/futures/thread.py`、:source:`Lib/" +"concurrent/futures/process.py` 與 :source:`Lib/concurrent/futures/" +"interpreter.py`" -#: ../../library/concurrent.futures.rst:14 +#: ../../library/concurrent.futures.rst:15 msgid "" "The :mod:`concurrent.futures` module provides a high-level interface for " "asynchronously executing callables." @@ -39,16 +41,17 @@ msgstr "" ":mod:`concurrent.futures` 模組提供了一個高階介面來非同步地 (asynchronously) " "執行可呼叫物件 (callable) 。" -#: ../../library/concurrent.futures.rst:17 +#: ../../library/concurrent.futures.rst:18 msgid "" "The asynchronous execution can be performed with threads, using :class:" -"`ThreadPoolExecutor`, or separate processes, using :class:" -"`ProcessPoolExecutor`. Both implement the same interface, which is defined " -"by the abstract :class:`Executor` class." +"`ThreadPoolExecutor` or :class:`InterpreterPoolExecutor`, or separate " +"processes, using :class:`ProcessPoolExecutor`. Each implements the same " +"interface, which is defined by the abstract :class:`Executor` class." msgstr "" -"非同步執行可以透過 :class:`ThreadPoolExecutor` 來使用執行緒 (thread) 執行,或" -"透過 :class:`ProcessPoolExecutor` 來使用單獨行程 (process) 執行。兩者都實作了" -"相同的介面,該介面由抽象的 :class:`Executor` 類別定義。" +"非同步執行可以透過 :class:`ThreadPoolExecutor` 或 :class:" +"`InterpreterPoolExecutor` 來使用執行緒 (thread) 執行,或透過 :class:" +"`ProcessPoolExecutor` 來使用單獨行程 (process) 執行。兩者都實作了相同的介面," +"該介面由抽象的 :class:`Executor` 類別定義。" #: ../../includes/wasm-notavail.rst:3 msgid "Availability" @@ -62,11 +65,11 @@ msgstr "" "此模組在 WebAssembly 平台上不起作用或無法使用。更多資訊請參閱 :ref:`wasm-" "availability`。" -#: ../../library/concurrent.futures.rst:25 +#: ../../library/concurrent.futures.rst:27 msgid "Executor Objects" msgstr "Executor 物件" -#: ../../library/concurrent.futures.rst:29 +#: ../../library/concurrent.futures.rst:31 msgid "" "An abstract class that provides methods to execute calls asynchronously. It " "should not be used directly, but through its concrete subclasses." @@ -74,7 +77,7 @@ msgstr "" "提供非同步執行呼叫方法的抽象類別。不應直接使用它,而應透過其具體子類別來使" "用。" -#: ../../library/concurrent.futures.rst:34 +#: ../../library/concurrent.futures.rst:36 msgid "" "Schedules the callable, *fn*, to be executed as ``fn(*args, **kwargs)`` and " "returns a :class:`Future` object representing the execution of the " @@ -83,7 +86,7 @@ msgstr "" "為可呼叫物件 *fn* 排程來以 ``fn(*args, **kwargs)`` 的形式執行並回傳一個表示可" "呼叫的執行的 :class:`Future` 物件。 ::" -#: ../../library/concurrent.futures.rst:38 +#: ../../library/concurrent.futures.rst:40 msgid "" "with ThreadPoolExecutor(max_workers=1) as executor:\n" " future = executor.submit(pow, 323, 1235)\n" @@ -93,21 +96,25 @@ msgstr "" " future = executor.submit(pow, 323, 1235)\n" " print(future.result())" -#: ../../library/concurrent.futures.rst:44 +#: ../../library/concurrent.futures.rst:46 msgid "Similar to :func:`map(fn, *iterables) ` except:" msgstr "類似於 :func:`map(fn, *iterables) `,除了:" -#: ../../library/concurrent.futures.rst:46 -msgid "the *iterables* are collected immediately rather than lazily;" -msgstr "*iterables* 立即被收集而不是延遲 (lazily) 收集;" - #: ../../library/concurrent.futures.rst:48 msgid "" +"The *iterables* are collected immediately rather than lazily, unless a " +"*buffersize* is specified to limit the number of submitted tasks whose " +"results have not yet been yielded. If the buffer is full, iteration over the " +"*iterables* pauses until a result is yielded from the buffer." +msgstr "" + +#: ../../library/concurrent.futures.rst:53 +msgid "" "*fn* is executed asynchronously and several calls to *fn* may be made " "concurrently." msgstr "*fn* 是非同步執行的,並且對 *fn* 的多次呼叫可以並行處理。" -#: ../../library/concurrent.futures.rst:51 +#: ../../library/concurrent.futures.rst:56 msgid "" "The returned iterator raises a :exc:`TimeoutError` if :meth:`~iterator." "__next__` is called and the result isn't available after *timeout* seconds " @@ -120,32 +127,37 @@ msgstr "" "*timeout* 可以是整數或浮點數。如果未指定 *timeout* 或為 ``None``,則等待時間" "就不會有限制。" -#: ../../library/concurrent.futures.rst:57 +#: ../../library/concurrent.futures.rst:62 msgid "" "If a *fn* call raises an exception, then that exception will be raised when " "its value is retrieved from the iterator." msgstr "如果 *fn* 呼叫引發例外,則當從疊代器中檢索到它的值時將引發該例外。" -#: ../../library/concurrent.futures.rst:60 +#: ../../library/concurrent.futures.rst:65 msgid "" "When using :class:`ProcessPoolExecutor`, this method chops *iterables* into " "a number of chunks which it submits to the pool as separate tasks. The " "(approximate) size of these chunks can be specified by setting *chunksize* " "to a positive integer. For very long iterables, using a large value for " "*chunksize* can significantly improve performance compared to the default " -"size of 1. With :class:`ThreadPoolExecutor`, *chunksize* has no effect." +"size of 1. With :class:`ThreadPoolExecutor` and :class:" +"`InterpreterPoolExecutor`, *chunksize* has no effect." msgstr "" "使用 :class:`ProcessPoolExecutor` 時,此方法將 *iterables* 分成許多分塊 " "(chunks),並將其作為獨立的任務來提交給池 (pool)。可以透過將 *chunksize* 設定" "為正整數來指定這些分塊的(約略)大小。對於非常長的可疊代物件,*chunksize* 使" "用較大的值(與預設大小 1 相比)可以顯著提高性能。對於 :class:" -"`ThreadPoolExecutor`,*chunksize* 無效。" +"`ThreadPoolExecutor` 和 :class:`InterpreterPoolExecutor`,*chunksize* 無效。" -#: ../../library/concurrent.futures.rst:68 -msgid "Added the *chunksize* argument." -msgstr "新增 *chunksize* 引數。" +#: ../../library/concurrent.futures.rst:74 +msgid "Added the *chunksize* parameter." +msgstr "新增 *chunksize* 參數。" -#: ../../library/concurrent.futures.rst:73 +#: ../../library/concurrent.futures.rst:77 +msgid "Added the *buffersize* parameter." +msgstr "新增 *buffersize* 參數。" + +#: ../../library/concurrent.futures.rst:82 msgid "" "Signal the executor that it should free any resources that it is using when " "the currently pending futures are done executing. Calls to :meth:`Executor." @@ -156,7 +168,7 @@ msgstr "" "執行時釋放它正在使用的任何資源。在關閉後呼叫 :meth:`Executor.submit` 和 :" "meth:`Executor.map` 將引發 :exc:`RuntimeError`。" -#: ../../library/concurrent.futures.rst:78 +#: ../../library/concurrent.futures.rst:87 msgid "" "If *wait* is ``True`` then this method will not return until all the pending " "futures are done executing and the resources associated with the executor " @@ -172,7 +184,7 @@ msgstr "" "*wait* 的值如何,整個 Python 程式都不會退出,直到所有未定的 futures 執行完" "畢。" -#: ../../library/concurrent.futures.rst:86 +#: ../../library/concurrent.futures.rst:95 msgid "" "If *cancel_futures* is ``True``, this method will cancel all pending futures " "that the executor has not started running. Any futures that are completed or " @@ -182,7 +194,7 @@ msgstr "" "定 future。無論 *cancel_futures* 的值如何,任何已完成或正在運行的 future 都不" "會被取消。" -#: ../../library/concurrent.futures.rst:91 +#: ../../library/concurrent.futures.rst:100 msgid "" "If both *cancel_futures* and *wait* are ``True``, all futures that the " "executor has started running will be completed prior to this method " @@ -191,18 +203,18 @@ msgstr "" "如果 *cancel_futures* 和 *wait* 都為 ``True``,則 executor 已開始運行的所有 " "future 將在此方法回傳之前完成。剩餘的 future 被取消。" -#: ../../library/concurrent.futures.rst:95 +#: ../../library/concurrent.futures.rst:104 msgid "" "You can avoid having to call this method explicitly if you use the executor " "as a :term:`context manager` via the :keyword:`with` statement, which will " "shutdown the :class:`Executor` (waiting as if :meth:`Executor.shutdown` were " "called with *wait* set to ``True``)::" msgstr "" -"如果透過 :keyword:`with` 陳述式來將 executor 作為\\ :term:`情境管理器 `\\ " -"使用,你就可以不用明確地呼叫此方法,這將會自己關閉 :class:`Executor`\\(如同呼叫" -" :meth:`Executor.shutdown` 時 *wait* 被設定為 ``True`` 般等待): ::" +"如果使用 :keyword:`with` 陳述式來將 executor 用作 :term:`context manager`,那" +"你就可以不用明確地呼叫此方法,這將會自己關閉 :class:`Executor`\\(如同呼叫 :" +"meth:`Executor.shutdown` 時 *wait* 被設定為 ``True`` 般等待): ::" -#: ../../library/concurrent.futures.rst:100 +#: ../../library/concurrent.futures.rst:109 msgid "" "import shutil\n" "with ThreadPoolExecutor(max_workers=4) as e:\n" @@ -218,15 +230,15 @@ msgstr "" " e.submit(shutil.copy, 'src3.txt', 'dest3.txt')\n" " e.submit(shutil.copy, 'src4.txt', 'dest4.txt')" -#: ../../library/concurrent.futures.rst:107 +#: ../../library/concurrent.futures.rst:116 msgid "Added *cancel_futures*." msgstr "新增 *cancel_futures*。" -#: ../../library/concurrent.futures.rst:112 +#: ../../library/concurrent.futures.rst:121 msgid "ThreadPoolExecutor" msgstr "ThreadPoolExecutor" -#: ../../library/concurrent.futures.rst:114 +#: ../../library/concurrent.futures.rst:123 msgid "" ":class:`ThreadPoolExecutor` is an :class:`Executor` subclass that uses a " "pool of threads to execute calls asynchronously." @@ -234,7 +246,7 @@ msgstr "" ":class:`ThreadPoolExecutor` 是一個 :class:`Executor` 子類別,它使用執行緒池來" "非同步地執行呼叫。" -#: ../../library/concurrent.futures.rst:117 +#: ../../library/concurrent.futures.rst:126 msgid "" "Deadlocks can occur when the callable associated with a :class:`Future` " "waits on the results of another :class:`Future`. For example::" @@ -242,7 +254,7 @@ msgstr "" "當與 :class:`Future` 關聯的可呼叫物件等待另一個 :class:`Future` 的結果時,可" "能會發生死鎖 (deadlock)。例如: ::" -#: ../../library/concurrent.futures.rst:120 +#: ../../library/concurrent.futures.rst:129 msgid "" "import time\n" "def wait_on_b():\n" @@ -276,11 +288,11 @@ msgstr "" "a = executor.submit(wait_on_b)\n" "b = executor.submit(wait_on_a)" -#: ../../library/concurrent.futures.rst:136 +#: ../../library/concurrent.futures.rst:145 msgid "And::" msgstr "和: ::" -#: ../../library/concurrent.futures.rst:138 +#: ../../library/concurrent.futures.rst:147 msgid "" "def wait_on_future():\n" " f = executor.submit(pow, 5, 2)\n" @@ -300,7 +312,7 @@ msgstr "" "executor = ThreadPoolExecutor(max_workers=1)\n" "executor.submit(wait_on_future)" -#: ../../library/concurrent.futures.rst:150 +#: ../../library/concurrent.futures.rst:159 msgid "" "An :class:`Executor` subclass that uses a pool of at most *max_workers* " "threads to execute calls asynchronously." @@ -308,7 +320,7 @@ msgstr "" "一個 :class:`Executor` 子類別,它使用最多有 *max_workers* 個執行緒的池來非同" "步地執行呼叫。" -#: ../../library/concurrent.futures.rst:153 +#: ../../library/concurrent.futures.rst:162 msgid "" "All threads enqueued to ``ThreadPoolExecutor`` will be joined before the " "interpreter can exit. Note that the exit handler which does this is executed " @@ -323,7 +335,7 @@ msgstr "" "退出 (gracefully exit)。因此,建議不要將 ``ThreadPoolExecutor`` 用於長時間運" "行的任務。" -#: ../../library/concurrent.futures.rst:160 +#: ../../library/concurrent.futures.rst:169 msgid "" "*initializer* is an optional callable that is called at the start of each " "worker thread; *initargs* is a tuple of arguments passed to the " @@ -336,7 +348,7 @@ msgstr "" "外,所有目前未定的作業以及任何向池中提交 (submit) 更多作業的嘗試都將引發 :" "exc:`~concurrent.futures.thread.BrokenThreadPool`。" -#: ../../library/concurrent.futures.rst:166 +#: ../../library/concurrent.futures.rst:175 msgid "" "If *max_workers* is ``None`` or not given, it will default to the number of " "processors on the machine, multiplied by ``5``, assuming that :class:" @@ -349,7 +361,7 @@ msgstr "" "作業,並且 worker 的數量應該高於 :class:`ProcessPoolExecutor` 的 worker 數" "量。" -#: ../../library/concurrent.futures.rst:174 +#: ../../library/concurrent.futures.rst:183 msgid "" "Added the *thread_name_prefix* parameter to allow users to control the :" "class:`threading.Thread` names for worker threads created by the pool for " @@ -358,12 +370,12 @@ msgstr "" "新增 *thread_name_prefix* 參數以允許使用者控制由池所建立的工作執行緒 (worker " "thread) 的 :class:`threading.Thread` 名稱,以便於除錯。" -#: ../../library/concurrent.futures.rst:179 -#: ../../library/concurrent.futures.rst:292 +#: ../../library/concurrent.futures.rst:188 +#: ../../library/concurrent.futures.rst:393 msgid "Added the *initializer* and *initargs* arguments." msgstr "新增 *initializer* 與 *initargs* 引數。" -#: ../../library/concurrent.futures.rst:182 +#: ../../library/concurrent.futures.rst:191 msgid "" "Default value of *max_workers* is changed to ``min(32, os.cpu_count() + " "4)``. This default value preserves at least 5 workers for I/O bound tasks. " @@ -374,7 +386,7 @@ msgstr "" "集任務至少保留了 5 個 worker。它最多使用 32 個 CPU 核心來執行CPU 密集任務,以" "釋放 GIL。並且它避免了在多核機器上隱晦地使用非常大量的資源。" -#: ../../library/concurrent.futures.rst:188 +#: ../../library/concurrent.futures.rst:197 msgid "" "ThreadPoolExecutor now reuses idle worker threads before starting " "*max_workers* worker threads too." @@ -382,18 +394,18 @@ msgstr "" "ThreadPoolExecutor 現在在啟動 *max_workers* 工作執行緒之前會重用 (reuse) 空閒" "的工作執行緒。" -#: ../../library/concurrent.futures.rst:191 +#: ../../library/concurrent.futures.rst:200 msgid "" "Default value of *max_workers* is changed to ``min(32, (os." "process_cpu_count() or 1) + 4)``." msgstr "" "*max_workers* 的預設值被改為 ``min(32, (os.process_cpu_count() or 1) + 4)``。" -#: ../../library/concurrent.futures.rst:199 +#: ../../library/concurrent.futures.rst:208 msgid "ThreadPoolExecutor Example" msgstr "ThreadPoolExecutor 範例" -#: ../../library/concurrent.futures.rst:202 +#: ../../library/concurrent.futures.rst:211 msgid "" "import concurrent.futures\n" "import urllib.request\n" @@ -424,11 +436,127 @@ msgid "" " print('%r page is %d bytes' % (url, len(data)))" msgstr "" -#: ../../library/concurrent.futures.rst:231 +#: ../../library/concurrent.futures.rst:240 +msgid "InterpreterPoolExecutor" +msgstr "InterpreterPoolExecutor" + +#: ../../library/concurrent.futures.rst:244 +msgid "" +"The :class:`InterpreterPoolExecutor` class uses a pool of interpreters to " +"execute calls asynchronously. It is a :class:`ThreadPoolExecutor` subclass, " +"which means each worker is running in its own thread. The difference here is " +"that each worker has its own interpreter, and runs each task using that " +"interpreter." +msgstr "" + +#: ../../library/concurrent.futures.rst:250 +msgid "" +"The biggest benefit to using interpreters instead of only threads is true " +"multi-core parallelism. Each interpreter has its own :term:`Global " +"Interpreter Lock `, so code running in one " +"interpreter can run on one CPU core, while code in another interpreter runs " +"unblocked on a different core." +msgstr "" + +#: ../../library/concurrent.futures.rst:256 +msgid "" +"The tradeoff is that writing concurrent code for use with multiple " +"interpreters can take extra effort. However, this is because it forces you " +"to be deliberate about how and when interpreters interact, and to be " +"explicit about what data is shared between interpreters. This results in " +"several benefits that help balance the extra effort, including true multi-" +"core parallelism, For example, code written this way can make it easier to " +"reason about concurrency. Another major benefit is that you don't have to " +"deal with several of the big pain points of using threads, like race " +"conditions." +msgstr "" + +#: ../../library/concurrent.futures.rst:266 +msgid "" +"Each worker's interpreter is isolated from all the other interpreters. " +"\"Isolated\" means each interpreter has its own runtime state and operates " +"completely independently. For example, if you redirect :data:`sys.stdout` " +"in one interpreter, it will not be automatically redirected to any other " +"interpreter. If you import a module in one interpreter, it is not " +"automatically imported in any other. You would need to import the module " +"separately in interpreter where you need it. In fact, each module imported " +"in an interpreter is a completely separate object from the same module in a " +"different interpreter, including :mod:`sys`, :mod:`builtins`, and even " +"``__main__``." +msgstr "" + +#: ../../library/concurrent.futures.rst:278 +msgid "" +"Isolation means a mutable object, or other data, cannot be used by more than " +"one interpreter at the same time. That effectively means interpreters " +"cannot actually share such objects or data. Instead, each interpreter must " +"have its own copy, and you will have to synchronize any changes between the " +"copies manually. Immutable objects and data, like the builtin singletons, " +"strings, and tuples of immutable objects, don't have these limitations." +msgstr "" + +#: ../../library/concurrent.futures.rst:286 +msgid "" +"Communicating and synchronizing between interpreters is most effectively " +"done using dedicated tools, like those proposed in :pep:`734`. One less " +"efficient alternative is to serialize with :mod:`pickle` and then send the " +"bytes over a shared :mod:`socket ` or :func:`pipe `." +msgstr "" + +#: ../../library/concurrent.futures.rst:294 +msgid "" +"A :class:`ThreadPoolExecutor` subclass that executes calls asynchronously " +"using a pool of at most *max_workers* threads. Each thread runs tasks in " +"its own interpreter. The worker interpreters are isolated from each other, " +"which means each has its own runtime state and that they can't share any " +"mutable objects or other data. Each interpreter has its own :term:`Global " +"Interpreter Lock `, which means code run with this " +"executor has true multi-core parallelism." +msgstr "" + +#: ../../library/concurrent.futures.rst:302 +msgid "" +"The optional *initializer* and *initargs* arguments have the same meaning as " +"for :class:`!ThreadPoolExecutor`: the initializer is run when each worker is " +"created, though in this case it is run in the worker's interpreter. The " +"executor serializes the *initializer* and *initargs* using :mod:`pickle` " +"when sending them to the worker's interpreter." +msgstr "" + +#: ../../library/concurrent.futures.rst:310 +msgid "" +"The executor may replace uncaught exceptions from *initializer* with :class:" +"`~concurrent.futures.interpreter.ExecutionFailed`." +msgstr "" + +#: ../../library/concurrent.futures.rst:313 +msgid "Other caveats from parent :class:`ThreadPoolExecutor` apply here." +msgstr "" + +#: ../../library/concurrent.futures.rst:315 +msgid "" +":meth:`~Executor.submit` and :meth:`~Executor.map` work like normal, except " +"the worker serializes the callable and arguments using :mod:`pickle` when " +"sending them to its interpreter. The worker likewise serializes the return " +"value when sending it back." +msgstr "" + +#: ../../library/concurrent.futures.rst:320 +msgid "" +"When a worker's current task raises an uncaught exception, the worker always " +"tries to preserve the exception as-is. If that is successful then it also " +"sets the ``__cause__`` to a corresponding :class:`~concurrent.futures." +"interpreter.ExecutionFailed` instance, which contains a summary of the " +"original exception. In the uncommon case that the worker is not able to " +"preserve the original as-is then it directly preserves the corresponding :" +"class:`~concurrent.futures.interpreter.ExecutionFailed` instance instead." +msgstr "" + +#: ../../library/concurrent.futures.rst:332 msgid "ProcessPoolExecutor" msgstr "ProcessPoolExecutor" -#: ../../library/concurrent.futures.rst:233 +#: ../../library/concurrent.futures.rst:334 msgid "" "The :class:`ProcessPoolExecutor` class is an :class:`Executor` subclass that " "uses a pool of processes to execute calls asynchronously. :class:" @@ -443,7 +571,7 @@ msgstr "" "Interpreter Lock) `,但也意味著只能執行和回傳可被 " "pickle 的 (picklable) 物件。" -#: ../../library/concurrent.futures.rst:240 +#: ../../library/concurrent.futures.rst:341 msgid "" "The ``__main__`` module must be importable by worker subprocesses. This " "means that :class:`ProcessPoolExecutor` will not work in the interactive " @@ -453,7 +581,7 @@ msgstr "" "class:`ProcessPoolExecutor` 將無法在交互式直譯器 (interactive interpreter) 中" "工作。" -#: ../../library/concurrent.futures.rst:243 +#: ../../library/concurrent.futures.rst:344 msgid "" "Calling :class:`Executor` or :class:`Future` methods from a callable " "submitted to a :class:`ProcessPoolExecutor` will result in deadlock." @@ -461,7 +589,7 @@ msgstr "" "從提交給 :class:`ProcessPoolExecutor` 的可呼叫物件中呼叫 :class:`Executor` " "或 :class:`Future` 方法將導致死鎖。" -#: ../../library/concurrent.futures.rst:246 +#: ../../library/concurrent.futures.rst:347 msgid "" "Note that the restrictions on functions and arguments needing to picklable " "as per :class:`multiprocessing.Process` apply when using :meth:`~Executor." @@ -469,7 +597,7 @@ msgid "" "function defined in a REPL or a lambda should not be expected to work." msgstr "" -#: ../../library/concurrent.futures.rst:253 +#: ../../library/concurrent.futures.rst:354 msgid "" "An :class:`Executor` subclass that executes calls asynchronously using a " "pool of at most *max_workers* processes. If *max_workers* is ``None`` or " @@ -493,7 +621,7 @@ msgstr "" "或未給定,則使用預設的 :mod:`multiprocessing` 情境。請見 :ref:" "`multiprocessing-start-methods`。" -#: ../../library/concurrent.futures.rst:267 +#: ../../library/concurrent.futures.rst:368 msgid "" "*initializer* is an optional callable that is called at the start of each " "worker process; *initargs* is a tuple of arguments passed to the " @@ -506,7 +634,7 @@ msgstr "" "外,所有目前未定的作業以及任何向池中提交更多作業的嘗試都將引發 :exc:" "`~concurrent.futures.process.BrokenProcessPool`。" -#: ../../library/concurrent.futures.rst:273 +#: ../../library/concurrent.futures.rst:374 msgid "" "*max_tasks_per_child* is an optional argument that specifies the maximum " "number of tasks a single process can execute before it will exit and be " @@ -522,7 +650,7 @@ msgstr "" "數的情況下,將預設使用 \"spawn\" 做為 multiprocessing 啟動方法。此功能與 " "\"fork\" 啟動方法不相容。" -#: ../../library/concurrent.futures.rst:281 +#: ../../library/concurrent.futures.rst:382 msgid "" "When one of the worker processes terminates abruptly, a :exc:`~concurrent." "futures.process.BrokenProcessPool` error is now raised. Previously, " @@ -533,34 +661,21 @@ msgstr "" "BrokenProcessPool` 錯誤。在過去,此行為是未定義的 (undefined),但對 executor " "或其 future 的操作經常會發生凍結或死鎖。" -#: ../../library/concurrent.futures.rst:288 +#: ../../library/concurrent.futures.rst:389 msgid "" "The *mp_context* argument was added to allow users to control the " "start_method for worker processes created by the pool." msgstr "" "新增了 *mp_context* 引數以允許使用者控制由池所建立的工作行程的 start_method。" -#: ../../library/concurrent.futures.rst:295 -msgid "" -"The default :mod:`multiprocessing` start method (see :ref:`multiprocessing-" -"start-methods`) will change away from *fork* in Python 3.14. Code that " -"requires *fork* be used for their :class:`ProcessPoolExecutor` should " -"explicitly specify that by passing a ``mp_context=multiprocessing." -"get_context(\"fork\")`` parameter." -msgstr "" -"預設的 :mod:`multiprocessing` 啟動方法(請參閱 :ref:`multiprocessing-start-" -"methods`\\ )將不再是 Python 3.14 中的 *fork*。需要 *fork* 用於其 :class:" -"`ProcessPoolExecutor` 的程式碼應透過傳遞 ``mp_context=multiprocessing." -"get_context(\"fork\")`` 參數來明確指定。" - -#: ../../library/concurrent.futures.rst:302 +#: ../../library/concurrent.futures.rst:395 msgid "" "The *max_tasks_per_child* argument was added to allow users to control the " "lifetime of workers in the pool." msgstr "" "新增了 *max_tasks_per_child* 引數以允許使用者控制池中 worker 的生命週期。" -#: ../../library/concurrent.futures.rst:306 +#: ../../library/concurrent.futures.rst:399 msgid "" "On POSIX systems, if your application has multiple threads and the :mod:" "`multiprocessing` context uses the ``\"fork\"`` start method: The :func:`os." @@ -573,17 +688,48 @@ msgstr "" "能會引發 :exc:`DeprecationWarning`。傳遞一個 *mp_context* 以配置為使用不同的" "啟動方法。更多說明請參閱 :func:`os.fork` 文件。" -#: ../../library/concurrent.futures.rst:314 +#: ../../library/concurrent.futures.rst:407 msgid "" "*max_workers* uses :func:`os.process_cpu_count` by default, instead of :func:" "`os.cpu_count`." msgstr "" -#: ../../library/concurrent.futures.rst:321 +#: ../../library/concurrent.futures.rst:411 +msgid "" +"The default process start method (see :ref:`multiprocessing-start-methods`) " +"changed away from *fork*. If you require the *fork* start method for :class:" +"`ProcessPoolExecutor` you must explicitly pass ``mp_context=multiprocessing." +"get_context(\"fork\")``." +msgstr "" + +#: ../../library/concurrent.futures.rst:419 +msgid "" +"Attempt to terminate all living worker processes immediately by calling :" +"meth:`Process.terminate ` on each of " +"them. Internally, it will also call :meth:`Executor.shutdown` to ensure that " +"all other resources associated with the executor are freed." +msgstr "" + +#: ../../library/concurrent.futures.rst:424 +#: ../../library/concurrent.futures.rst:436 +msgid "" +"After calling this method the caller should no longer submit tasks to the " +"executor." +msgstr "" + +#: ../../library/concurrent.futures.rst:431 +msgid "" +"Attempt to kill all living worker processes immediately by calling :meth:" +"`Process.kill ` on each of them. Internally, " +"it will also call :meth:`Executor.shutdown` to ensure that all other " +"resources associated with the executor are freed." +msgstr "" + +#: ../../library/concurrent.futures.rst:444 msgid "ProcessPoolExecutor Example" msgstr "ProcessPoolExecutor 範例" -#: ../../library/concurrent.futures.rst:324 +#: ../../library/concurrent.futures.rst:447 msgid "" "import concurrent.futures\n" "import math\n" @@ -651,11 +797,11 @@ msgstr "" "if __name__ == '__main__':\n" " main()" -#: ../../library/concurrent.futures.rst:359 +#: ../../library/concurrent.futures.rst:482 msgid "Future Objects" msgstr "Future 物件" -#: ../../library/concurrent.futures.rst:361 +#: ../../library/concurrent.futures.rst:484 msgid "" "The :class:`Future` class encapsulates the asynchronous execution of a " "callable. :class:`Future` instances are created by :meth:`Executor.submit`." @@ -663,7 +809,7 @@ msgstr "" ":class:`Future` 類別封裝了可呼叫物件的非同步執行。:class:`Future` 實例由 :" "meth:`Executor.submit` 建立。" -#: ../../library/concurrent.futures.rst:366 +#: ../../library/concurrent.futures.rst:489 msgid "" "Encapsulates the asynchronous execution of a callable. :class:`Future` " "instances are created by :meth:`Executor.submit` and should not be created " @@ -672,7 +818,7 @@ msgstr "" "封裝可呼叫物件的非同步執行。:class:`Future` 實例由 :meth:`Executor.submit` 建" "立,且除測試外不應直接建立。" -#: ../../library/concurrent.futures.rst:372 +#: ../../library/concurrent.futures.rst:495 msgid "" "Attempt to cancel the call. If the call is currently being executed or " "finished running and cannot be cancelled then the method will return " @@ -682,22 +828,22 @@ msgstr "" "嘗試取消呼叫。如果呼叫目前正在執行或已完成運行且無法取消,則該方法將回傳 " "``False``,否則呼叫將被取消並且該方法將回傳 ``True``。" -#: ../../library/concurrent.futures.rst:379 +#: ../../library/concurrent.futures.rst:502 msgid "Return ``True`` if the call was successfully cancelled." msgstr "如果該呼叫成功被取消,則回傳 ``True``。" -#: ../../library/concurrent.futures.rst:383 +#: ../../library/concurrent.futures.rst:506 msgid "" "Return ``True`` if the call is currently being executed and cannot be " "cancelled." msgstr "如果呼叫正在執行且無法取消,則回傳 ``True``。" -#: ../../library/concurrent.futures.rst:388 +#: ../../library/concurrent.futures.rst:511 msgid "" "Return ``True`` if the call was successfully cancelled or finished running." msgstr "如果呼叫成功被取消或結束運行,則回傳 ``True``。" -#: ../../library/concurrent.futures.rst:393 +#: ../../library/concurrent.futures.rst:516 msgid "" "Return the value returned by the call. If the call hasn't yet completed then " "this method will wait up to *timeout* seconds. If the call hasn't completed " @@ -709,19 +855,19 @@ msgstr "" "叫在 *timeout* 秒內未完成,則會引發 :exc:`TimeoutError`。*timeout* 可以是整數" "或浮點數。如果未指定 *timeout* 或為 ``None``,則等待時間就不會有限制。" -#: ../../library/concurrent.futures.rst:400 -#: ../../library/concurrent.futures.rst:414 +#: ../../library/concurrent.futures.rst:523 +#: ../../library/concurrent.futures.rst:537 msgid "" "If the future is cancelled before completing then :exc:`.CancelledError` " "will be raised." msgstr "如果 future 在完成之前被取消,那麼 :exc:`.CancelledError` 將被引發。" -#: ../../library/concurrent.futures.rst:403 +#: ../../library/concurrent.futures.rst:526 msgid "" "If the call raised an exception, this method will raise the same exception." msgstr "如果該呼叫引發了例外,此方法將引發相同的例外。" -#: ../../library/concurrent.futures.rst:407 +#: ../../library/concurrent.futures.rst:530 msgid "" "Return the exception raised by the call. If the call hasn't yet completed " "then this method will wait up to *timeout* seconds. If the call hasn't " @@ -733,11 +879,11 @@ msgstr "" "呼叫在 *timeout* 秒內未完成,則會引發 :exc:`TimeoutError`。 *timeout* 可以是" "整數或浮點數。如果未指定 *timeout* 或為 ``None``,則等待時間就不會有限制。" -#: ../../library/concurrent.futures.rst:417 +#: ../../library/concurrent.futures.rst:540 msgid "If the call completed without raising, ``None`` is returned." msgstr "如果呼叫在沒有引發的情況下完成,則回傳 ``None``。" -#: ../../library/concurrent.futures.rst:421 +#: ../../library/concurrent.futures.rst:544 msgid "" "Attaches the callable *fn* to the future. *fn* will be called, with the " "future as its only argument, when the future is cancelled or finishes " @@ -746,7 +892,7 @@ msgstr "" "將可呼叫的 *fn* 附加到 future 上。當 future 被取消或完成運行時,*fn* 將被以 " "future 作為其唯一引數來呼叫。" -#: ../../library/concurrent.futures.rst:425 +#: ../../library/concurrent.futures.rst:548 msgid "" "Added callables are called in the order that they were added and are always " "called in a thread belonging to the process that added them. If the " @@ -758,19 +904,19 @@ msgstr "" "如果可呼叫物件引發 :exc:`Exception` 子類別,它將被記錄 (log) 並忽略。如果可呼" "叫物件引發 :exc:`BaseException` 子類別,該行為未定義。" -#: ../../library/concurrent.futures.rst:431 +#: ../../library/concurrent.futures.rst:554 msgid "" "If the future has already completed or been cancelled, *fn* will be called " "immediately." msgstr "如果 future 已經完成或被取消,*fn* 將立即被呼叫。" -#: ../../library/concurrent.futures.rst:434 +#: ../../library/concurrent.futures.rst:557 msgid "" "The following :class:`Future` methods are meant for use in unit tests and :" "class:`Executor` implementations." msgstr "以下 :class:`Future` 方法旨在用於單元測試和 :class:`Executor` 實作。" -#: ../../library/concurrent.futures.rst:439 +#: ../../library/concurrent.futures.rst:562 msgid "" "This method should only be called by :class:`Executor` implementations " "before executing the work associated with the :class:`Future` and by unit " @@ -779,7 +925,7 @@ msgstr "" "此方法只能在與 :class:`Future` 關聯的工作被執行之前於 :class:`Executor` 實作" "中呼叫,或者在單元測試中呼叫。" -#: ../../library/concurrent.futures.rst:443 +#: ../../library/concurrent.futures.rst:566 msgid "" "If the method returns ``False`` then the :class:`Future` was cancelled, i." "e. :meth:`Future.cancel` was called and returned ``True``. Any threads " @@ -790,7 +936,7 @@ msgstr "" "cancel` 被呼叫並回傳 ``True``。任何等待 :class:`Future` 完成的執行緒(即透" "過 :func:`as_completed` 或 :func:`wait`)將被喚醒。" -#: ../../library/concurrent.futures.rst:448 +#: ../../library/concurrent.futures.rst:571 msgid "" "If the method returns ``True`` then the :class:`Future` was not cancelled " "and has been put in the running state, i.e. calls to :meth:`Future.running` " @@ -799,7 +945,7 @@ msgstr "" "如果該方法回傳 ``True`` 則代表 :class:`Future` 未被取消並已進入運行狀態,意即" "呼叫 :meth:`Future.running` 將回傳 ``True``。" -#: ../../library/concurrent.futures.rst:452 +#: ../../library/concurrent.futures.rst:575 msgid "" "This method can only be called once and cannot be called after :meth:`Future." "set_result` or :meth:`Future.set_exception` have been called." @@ -807,20 +953,20 @@ msgstr "" "此方法只能呼叫一次,且不能在呼叫 :meth:`Future.set_result` 或 :meth:`Future." "set_exception` 之後呼叫。" -#: ../../library/concurrent.futures.rst:458 +#: ../../library/concurrent.futures.rst:581 msgid "" "Sets the result of the work associated with the :class:`Future` to *result*." msgstr "將與 :class:`Future` 關聯的工作結果設定為 *result*。" -#: ../../library/concurrent.futures.rst:461 -#: ../../library/concurrent.futures.rst:474 +#: ../../library/concurrent.futures.rst:584 +#: ../../library/concurrent.futures.rst:597 msgid "" "This method should only be used by :class:`Executor` implementations and " "unit tests." msgstr "此方法只能在 :class:`Executor` 實作中和單元測試中使用。" -#: ../../library/concurrent.futures.rst:464 -#: ../../library/concurrent.futures.rst:477 +#: ../../library/concurrent.futures.rst:587 +#: ../../library/concurrent.futures.rst:600 msgid "" "This method raises :exc:`concurrent.futures.InvalidStateError` if the :class:" "`Future` is already done." @@ -828,18 +974,18 @@ msgstr "" "如果 :class:`Future` 已經完成,此方法會引發 :exc:`concurrent.futures." "InvalidStateError`。" -#: ../../library/concurrent.futures.rst:471 +#: ../../library/concurrent.futures.rst:594 msgid "" "Sets the result of the work associated with the :class:`Future` to the :" "class:`Exception` *exception*." msgstr "" "將與 :class:`Future` 關聯的工作結果設定為 :class:`Exception` *exception*。" -#: ../../library/concurrent.futures.rst:483 +#: ../../library/concurrent.futures.rst:606 msgid "Module Functions" msgstr "模組函式" -#: ../../library/concurrent.futures.rst:487 +#: ../../library/concurrent.futures.rst:610 msgid "" "Wait for the :class:`Future` instances (possibly created by different :class:" "`Executor` instances) given by *fs* to complete. Duplicate futures given to " @@ -855,7 +1001,7 @@ msgstr "" "完成的 future(已完成或被取消的 future)。第二組名為 ``not_done``,包含未完成" "的 future(未定或運行中的 future)。" -#: ../../library/concurrent.futures.rst:495 +#: ../../library/concurrent.futures.rst:618 msgid "" "*timeout* can be used to control the maximum number of seconds to wait " "before returning. *timeout* can be an int or float. If *timeout* is not " @@ -864,25 +1010,25 @@ msgstr "" "*timeout* 可用於控制回傳前等待的最大秒數。*timeout* 可以是整數或浮點數。如果" "未指定 *timeout* 或為 ``None``,則等待時間就沒有限制。" -#: ../../library/concurrent.futures.rst:499 +#: ../../library/concurrent.futures.rst:622 msgid "" "*return_when* indicates when this function should return. It must be one of " "the following constants:" msgstr "*return_when* 表示此函式應回傳的時間。它必須是以下常數之一:" -#: ../../library/concurrent.futures.rst:505 +#: ../../library/concurrent.futures.rst:628 msgid "Constant" msgstr "常數" -#: ../../library/concurrent.futures.rst:506 +#: ../../library/concurrent.futures.rst:629 msgid "Description" msgstr "描述" -#: ../../library/concurrent.futures.rst:509 +#: ../../library/concurrent.futures.rst:632 msgid "The function will return when any future finishes or is cancelled." msgstr "當任何 future 完成或被取消時,該函式就會回傳。" -#: ../../library/concurrent.futures.rst:512 +#: ../../library/concurrent.futures.rst:635 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:" @@ -891,11 +1037,11 @@ msgstr "" "該函式會在任何 future 透過引發例外而完結時回傳。如果 future 沒有引發例外,那" "麼它等同於 :const:`ALL_COMPLETED`。" -#: ../../library/concurrent.futures.rst:517 +#: ../../library/concurrent.futures.rst:640 msgid "The function will return when all futures finish or are cancelled." msgstr "當所有 future 都完成或被取消時,該函式才會回傳。" -#: ../../library/concurrent.futures.rst:521 +#: ../../library/concurrent.futures.rst:644 msgid "" "Returns an iterator over the :class:`Future` instances (possibly created by " "different :class:`Executor` instances) given by *fs* that yields futures as " @@ -915,36 +1061,36 @@ msgstr "" "`TimeoutError`。*timeout* 可以是整數或浮點數。如果未指定 *timeout* 或為 " "``None``,則等待時間就沒有限制。" -#: ../../library/concurrent.futures.rst:534 +#: ../../library/concurrent.futures.rst:657 msgid ":pep:`3148` -- futures - execute computations asynchronously" msgstr ":pep:`3148` -- futures - 非同步地執行運算" -#: ../../library/concurrent.futures.rst:535 +#: ../../library/concurrent.futures.rst:658 msgid "" "The proposal which described this feature for inclusion in the Python " "standard library." msgstr "描述此功能並提出被包含於 Python 標準函式庫中的提案。" -#: ../../library/concurrent.futures.rst:540 +#: ../../library/concurrent.futures.rst:663 msgid "Exception classes" msgstr "例外類別" -#: ../../library/concurrent.futures.rst:546 +#: ../../library/concurrent.futures.rst:669 msgid "Raised when a future is cancelled." msgstr "當 future 被取消時引發。" -#: ../../library/concurrent.futures.rst:550 +#: ../../library/concurrent.futures.rst:673 msgid "" "A deprecated alias of :exc:`TimeoutError`, raised when a future operation " "exceeds the given timeout." msgstr "" ":exc:`TimeoutError` 的棄用別名,在 future 操作超過給定超時 (timeout) 時引發。" -#: ../../library/concurrent.futures.rst:555 +#: ../../library/concurrent.futures.rst:678 msgid "This class was made an alias of :exc:`TimeoutError`." msgstr "這個類別是 :exc:`TimeoutError` 的別名。" -#: ../../library/concurrent.futures.rst:560 +#: ../../library/concurrent.futures.rst:683 msgid "" "Derived from :exc:`RuntimeError`, this exception class is raised when an " "executor is broken for some reason, and cannot be used to submit or execute " @@ -953,13 +1099,13 @@ msgstr "" "衍生自 :exc:`RuntimeError`,當執行器因某種原因損壞時會引發此例外類別,並且不" "能用於提交或執行新任務。" -#: ../../library/concurrent.futures.rst:568 +#: ../../library/concurrent.futures.rst:691 msgid "" "Raised when an operation is performed on a future that is not allowed in the " "current state." msgstr "目前狀態下不允許的 future 操作被執行時而引發。" -#: ../../library/concurrent.futures.rst:577 +#: ../../library/concurrent.futures.rst:700 msgid "" "Derived from :exc:`~concurrent.futures.BrokenExecutor`, this exception class " "is raised when one of the workers of a :class:`~concurrent.futures." @@ -968,7 +1114,24 @@ msgstr "" "衍生自 :exc:`~concurrent.futures.BrokenExecutor`,當 :class:`~concurrent." "futures.ThreadPoolExecutor` 的其中一個 worker 初始化失敗時會引發此例外類別。" -#: ../../library/concurrent.futures.rst:588 +#: ../../library/concurrent.futures.rst:711 +msgid "" +"Derived from :exc:`~concurrent.futures.thread.BrokenThreadPool`, this " +"exception class is raised when one of the workers of a :class:`~concurrent." +"futures.InterpreterPoolExecutor` has failed initializing." +msgstr "" +"衍生自 :exc:`~concurrent.futures.thread.BrokenThreadPool`,當 :class:" +"`~concurrent.futures.InterpreterPoolExecutor` 的其中一個 worker 初始化失敗時" +"會引發此例外類別。" + +#: ../../library/concurrent.futures.rst:720 +msgid "" +"Raised from :class:`~concurrent.futures.InterpreterPoolExecutor` when the " +"given initializer fails or from :meth:`~concurrent.futures.Executor.submit` " +"when there's an uncaught exception from the submitted task." +msgstr "" + +#: ../../library/concurrent.futures.rst:731 msgid "" "Derived from :exc:`~concurrent.futures.BrokenExecutor` (formerly :exc:" "`RuntimeError`), this exception class is raised when one of the workers of " diff --git a/library/concurrent.interpreters.po b/library/concurrent.interpreters.po new file mode 100644 index 00000000000..cd8cbd637fe --- /dev/null +++ b/library/concurrent.interpreters.po @@ -0,0 +1,523 @@ +# 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.14\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-11-07 00:14+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/concurrent.interpreters.rst:2 +msgid "" +":mod:`!concurrent.interpreters` --- Multiple interpreters in the same process" +msgstr ":mod:`!concurrent.interpreters` --- 在同一個行程中使用多個直譯器" + +#: ../../library/concurrent.interpreters.rst:12 +msgid "**Source code:** :source:`Lib/concurrent/interpreters`" +msgstr "**原始碼:**\\ :source:`Lib/concurrent/interpreters`" + +#: ../../library/concurrent.interpreters.rst:16 +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 +msgid "" +"The module is primarily meant to provide a basic API for managing " +"interpreters (AKA \"subinterpreters\") and running things in them. Running " +"mostly involves switching to an interpreter (in the current thread) and " +"calling a function in that execution context." +msgstr "" + +#: ../../library/concurrent.interpreters.rst:24 +msgid "" +"For concurrency, interpreters themselves (and this module) don't provide " +"much more than isolation, which on its own isn't useful. Actual concurrency " +"is available separately through :mod:`threads ` See `below " +"`_" +msgstr "" + +#: ../../library/concurrent.interpreters.rst:31 +msgid ":class:`~concurrent.futures.InterpreterPoolExecutor`" +msgstr ":class:`~concurrent.futures.InterpreterPoolExecutor`" + +#: ../../library/concurrent.interpreters.rst:32 +msgid "Combines threads with interpreters in a familiar interface." +msgstr "" + +#: ../../library/concurrent.interpreters.rst:36 +msgid ":ref:`isolating-extensions-howto`" +msgstr ":ref:`isolating-extensions-howto`" + +#: ../../library/concurrent.interpreters.rst:37 +msgid "How to update an extension module to support multiple interpreters." +msgstr "" + +#: ../../library/concurrent.interpreters.rst:39 +msgid ":pep:`554`" +msgstr ":pep:`554`" + +#: ../../library/concurrent.interpreters.rst:41 +msgid ":pep:`734`" +msgstr ":pep:`734`" + +#: ../../library/concurrent.interpreters.rst:43 +msgid ":pep:`684`" +msgstr ":pep:`684`" + +#: ../../includes/wasm-notavail.rst:3 +msgid "Availability" +msgstr "可用性" + +#: ../../includes/wasm-notavail.rst:5 +msgid "" +"This module does not work or is not available on WebAssembly. See :ref:`wasm-" +"availability` for more information." +msgstr "" + +#: ../../library/concurrent.interpreters.rst:51 +msgid "Key details" +msgstr "" + +#: ../../library/concurrent.interpreters.rst:53 +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 +msgid "`isolated `_, by default" +msgstr "" + +#: ../../library/concurrent.interpreters.rst:57 +msgid "no implicit threads" +msgstr "" + +#: ../../library/concurrent.interpreters.rst:58 +msgid "not all PyPI packages support use in multiple interpreters yet" +msgstr "" + +#: ../../library/concurrent.interpreters.rst:66 +msgid "Introduction" +msgstr "" + +#: ../../library/concurrent.interpreters.rst:68 +msgid "" +"An \"interpreter\" is effectively the execution context of the Python " +"runtime. It contains all of the state the runtime needs to execute a " +"program. This includes things like the import state and builtins. (Each " +"thread, even if there's only the main thread, has some extra runtime state, " +"in addition to the current interpreter, related to the current exception and " +"the bytecode eval loop.)" +msgstr "" + +#: ../../library/concurrent.interpreters.rst:75 +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 " +"not well known, and the `isolation `_ was relatively " +"incomplete until version 3.12." +msgstr "" + +#: ../../library/concurrent.interpreters.rst:83 +msgid "Multiple Interpreters and Isolation" +msgstr "" + +#: ../../library/concurrent.interpreters.rst:85 +msgid "" +"A Python implementation may support using multiple interpreters in the same " +"process. CPython has this support. Each interpreter is effectively " +"isolated from the others (with a limited number of carefully managed process-" +"global exceptions to the rule)." +msgstr "" + +#: ../../library/concurrent.interpreters.rst:90 +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 +msgid "" +"Interpreters in the same process can technically never be strictly isolated " +"from one another since there are few restrictions on memory access within " +"the same process. The Python runtime makes a best effort at isolation but " +"extension modules may easily violate that. Therefore, do not use multiple " +"interpreters in security-sensitive situations, where they shouldn't have " +"access to each other's data." +msgstr "" + +#: ../../library/concurrent.interpreters.rst:104 +msgid "Running in an Interpreter" +msgstr "" + +#: ../../library/concurrent.interpreters.rst:106 +msgid "" +"Running in a different interpreter involves switching to it in the current " +"thread and then calling some function. The runtime will execute the " +"function using the current interpreter's state. The :mod:`!concurrent." +"interpreters` module provides a basic API for creating and managing " +"interpreters, as well as the switch-and-call operation." +msgstr "" + +#: ../../library/concurrent.interpreters.rst:113 +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 +msgid "" +"When :func:`exec` (or :func:`eval`) are called in an interpreter, they run " +"using the interpreter's :mod:`!__main__` module as the \"globals\" " +"namespace. The same is true for functions that aren't associated with any " +"module. This is the same as how scripts invoked from the command-line run " +"in the :mod:`!__main__` module." +msgstr "" + +#: ../../library/concurrent.interpreters.rst:128 +msgid "Concurrency and Parallelism" +msgstr "" + +#: ../../library/concurrent.interpreters.rst:130 +msgid "" +"As noted earlier, interpreters do not provide any concurrency on their own. " +"They strictly represent the isolated execution context the runtime will use " +"*in the current thread*. That isolation makes them similar to processes, " +"but they still enjoy in-process efficiency, like threads." +msgstr "" + +#: ../../library/concurrent.interpreters.rst:136 +msgid "" +"All that said, interpreters do naturally support certain flavors of " +"concurrency. There's a powerful side effect of that isolation. It enables a " +"different approach to concurrency than you can take with async or threads. " +"It's a similar concurrency model to CSP or the actor model, a model which is " +"relatively easy to reason about." +msgstr "" + +#: ../../library/concurrent.interpreters.rst:143 +msgid "" +"You can take advantage of that concurrency model in a single thread, " +"switching back and forth between interpreters, Stackless-style. However, " +"this model is more useful when you combine interpreters with multiple " +"threads. This mostly involves starting a new thread, where you switch to " +"another interpreter and run what you want there." +msgstr "" + +#: ../../library/concurrent.interpreters.rst:149 +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 +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 +msgid "" +"As a significant bonus, interpreters are sufficiently isolated that they do " +"not share the :term:`GIL`, which means combining threads with multiple " +"interpreters enables full multi-core parallelism. (This has been the case " +"since Python 3.12.)" +msgstr "" + +#: ../../library/concurrent.interpreters.rst:162 +msgid "Communication Between Interpreters" +msgstr "直譯器之間的溝通" + +#: ../../library/concurrent.interpreters.rst:164 +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 +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 +msgid "\"Sharing\" Objects" +msgstr "" + +#: ../../library/concurrent.interpreters.rst:178 +msgid "" +"Any data actually shared between interpreters loses the thread-safety " +"provided by the :term:`GIL`. There are various options for dealing with " +"this in extension modules. However, from Python code the lack of thread-" +"safety means objects can't actually be shared, with a few exceptions. " +"Instead, a copy must be created, which means mutable objects won't stay in " +"sync." +msgstr "" + +#: ../../library/concurrent.interpreters.rst:185 +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 +msgid ":const:`None`" +msgstr ":const:`None`" + +#: ../../library/concurrent.interpreters.rst:190 +msgid ":class:`bool` (:const:`True` and :const:`False`)" +msgstr ":class:`bool`\\ (:const:`True` 和 :const:`False`)" + +#: ../../library/concurrent.interpreters.rst:191 +msgid ":class:`bytes`" +msgstr ":class:`bytes`" + +#: ../../library/concurrent.interpreters.rst:192 +msgid ":class:`str`" +msgstr ":class:`str`" + +#: ../../library/concurrent.interpreters.rst:193 +msgid ":class:`int`" +msgstr ":class:`int`" + +#: ../../library/concurrent.interpreters.rst:194 +msgid ":class:`float`" +msgstr ":class:`float`" + +#: ../../library/concurrent.interpreters.rst:195 +msgid ":class:`tuple` (of similarly supported objects)" +msgstr "" + +#: ../../library/concurrent.interpreters.rst:197 +msgid "" +"There is a small number of Python types that actually share mutable data " +"between interpreters:" +msgstr "" + +#: ../../library/concurrent.interpreters.rst:200 +msgid ":class:`memoryview`" +msgstr ":class:`memoryview`" + +#: ../../library/concurrent.interpreters.rst:201 +msgid ":class:`Queue`" +msgstr ":class:`Queue`" + +#: ../../library/concurrent.interpreters.rst:205 +msgid "Reference" +msgstr "" + +#: ../../library/concurrent.interpreters.rst:207 +msgid "This module defines the following functions:" +msgstr "" + +#: ../../library/concurrent.interpreters.rst:211 +msgid "" +"Return a :class:`list` of :class:`Interpreter` objects, one for each " +"existing interpreter." +msgstr "" + +#: ../../library/concurrent.interpreters.rst:216 +msgid "" +"Return an :class:`Interpreter` object for the currently running interpreter." +msgstr "" + +#: ../../library/concurrent.interpreters.rst:221 +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 +msgid "" +"Initialize a new (idle) Python interpreter and return a :class:`Interpreter` " +"object for it." +msgstr "" + +#: ../../library/concurrent.interpreters.rst:232 +msgid "" +"Initialize a new cross-interpreter queue and return a :class:`Queue` object " +"for it." +msgstr "" + +#: ../../library/concurrent.interpreters.rst:237 +msgid "Interpreter objects" +msgstr "" + +#: ../../library/concurrent.interpreters.rst:241 +msgid "A single interpreter in the current process." +msgstr "" + +#: ../../library/concurrent.interpreters.rst:243 +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:248 +#: ../../library/concurrent.interpreters.rst:254 +#: ../../library/concurrent.interpreters.rst:333 +msgid "(read-only)" +msgstr "" + +#: ../../library/concurrent.interpreters.rst:250 +msgid "The underlying interpreter's ID." +msgstr "" + +#: ../../library/concurrent.interpreters.rst:256 +msgid "A string describing where the interpreter came from." +msgstr "" + +#: ../../library/concurrent.interpreters.rst:260 +msgid "" +"Return ``True`` if the interpreter is currently executing code in its :mod:`!" +"__main__` module and ``False`` otherwise." +msgstr "" + +#: ../../library/concurrent.interpreters.rst:265 +msgid "Finalize and destroy the interpreter." +msgstr "" + +#: ../../library/concurrent.interpreters.rst:269 +msgid "Bind objects in the interpreter's :mod:`!__main__` module." +msgstr "" + +#: ../../library/concurrent.interpreters.rst:271 +#: ../../library/concurrent.interpreters.rst:328 +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:276 +msgid "Run the given source code in the interpreter (in the current thread)." +msgstr "" + +#: ../../library/concurrent.interpreters.rst:280 +msgid "" +"Return the result of calling running the given function in the interpreter " +"(in the current thread)." +msgstr "" + +#: ../../library/concurrent.interpreters.rst:287 +msgid "Run the given function in the interpreter (in a new thread)." +msgstr "" + +#: ../../library/concurrent.interpreters.rst:290 +msgid "Exceptions" +msgstr "例外" + +#: ../../library/concurrent.interpreters.rst:294 +msgid "" +"This exception, a subclass of :exc:`Exception`, is raised when an " +"interpreter-related error happens." +msgstr "" + +#: ../../library/concurrent.interpreters.rst:299 +msgid "" +"This exception, a subclass of :exc:`InterpreterError`, is raised when the " +"targeted interpreter no longer exists." +msgstr "" + +#: ../../library/concurrent.interpreters.rst:304 +msgid "" +"This exception, a subclass of :exc:`InterpreterError`, is raised when the " +"running code raised an uncaught exception." +msgstr "" + +#: ../../library/concurrent.interpreters.rst:309 +msgid "A basic snapshot of the exception raised in the other interpreter." +msgstr "" + +#: ../../library/concurrent.interpreters.rst:315 +msgid "" +"This exception, a subclass of :exc:`TypeError`, is raised when an object " +"cannot be sent to another interpreter." +msgstr "" + +#: ../../library/concurrent.interpreters.rst:320 +msgid "Communicating Between Interpreters" +msgstr "在直譯器之間溝通" + +#: ../../library/concurrent.interpreters.rst:324 +msgid "" +"A wrapper around a low-level, cross-interpreter queue, which implements the :" +"class:`queue.Queue` interface. The underlying queue can only be created " +"through :func:`create_queue`." +msgstr "" + +#: ../../library/concurrent.interpreters.rst:335 +msgid "The queue's ID." +msgstr "" + +#: ../../library/concurrent.interpreters.rst:340 +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:346 +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:352 +msgid "Basic usage" +msgstr "基本用法" + +#: ../../library/concurrent.interpreters.rst:354 +msgid "Creating an interpreter and running code in it::" +msgstr "建立一個直譯器並在其中運行程式碼: ::" + +#: ../../library/concurrent.interpreters.rst:356 +msgid "" +"from concurrent import interpreters\n" +"\n" +"interp = interpreters.create()\n" +"\n" +"# Run in the current OS thread.\n" +"\n" +"interp.exec('print(\"spam!\")')\n" +"\n" +"interp.exec(\"\"\"if True:\n" +" print('spam!')\n" +" \"\"\")\n" +"\n" +"from textwrap import dedent\n" +"interp.exec(dedent(\"\"\"\n" +" print('spam!')\n" +" \"\"\"))\n" +"\n" +"def run(arg):\n" +" return arg\n" +"\n" +"res = interp.call(run, 'spam!')\n" +"print(res)\n" +"\n" +"def run():\n" +" print('spam!')\n" +"\n" +"interp.call(run)\n" +"\n" +"# Run in new OS thread.\n" +"\n" +"t = interp.call_in_thread(run)\n" +"t.join()" +msgstr "" diff --git a/library/concurrent.po b/library/concurrent.po index 43635439dec..109a8dc4178 100644 --- a/library/concurrent.po +++ b/library/concurrent.po @@ -1,14 +1,13 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Matt Wang , 2021 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-07-29 10:36+0000\n" +"POT-Creation-Date: 2025-09-08 15:25+0800\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-" @@ -24,9 +23,15 @@ msgid "The :mod:`!concurrent` package" msgstr ":mod:`!concurrent` 套件" #: ../../library/concurrent.rst:4 -msgid "Currently, there is only one module in this package:" -msgstr "目前此套件只有一個模組:" +msgid "This package contains the following modules:" +msgstr "此套件包含下列模組:" #: ../../library/concurrent.rst:6 msgid ":mod:`concurrent.futures` -- Launching parallel tasks" msgstr ":mod:`concurrent.futures` -- 啟動平行任務" + +#: ../../library/concurrent.rst:7 +msgid "" +":mod:`concurrent.interpreters` -- Multiple interpreters in the same process" +msgstr "" +":mod:`concurrent.interpreters` -- 在同一行程中使用多個直譯器" diff --git a/library/configparser.po b/library/configparser.po index 4b3a98b31ef..8bd1c846380 100644 --- a/library/configparser.po +++ b/library/configparser.po @@ -1,12 +1,12 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-02-19 00:13+0000\n" +"POT-Creation-Date: 2025-09-08 15:25+0800\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-" @@ -396,6 +396,9 @@ msgid "" "... fallback='No such things as monsters')\n" "'No such things as monsters'" msgstr "" +">>> config.get('forge.example', 'monster',\n" +"... fallback='No such things as monsters')\n" +"'No such things as monsters'" #: ../../library/configparser.rst:252 msgid "" @@ -424,7 +427,7 @@ msgstr "" #: ../../library/configparser.rst:268 msgid "Supported INI File Structure" -msgstr "" +msgstr "支援的 INI 檔案結構" #: ../../library/configparser.rst:270 msgid "" @@ -719,19 +722,19 @@ msgstr "" #: ../../library/configparser.rst:482 msgid "``DEFAULTSECT`` cannot be removed from the parser:" -msgstr "" +msgstr "``DEFAULTSECT`` 不能從剖析器中移除:" #: ../../library/configparser.rst:484 msgid "trying to delete it raises :exc:`ValueError`," -msgstr "" +msgstr "嘗試刪除它會引發 :exc:`ValueError`," #: ../../library/configparser.rst:486 msgid "``parser.clear()`` leaves it intact," -msgstr "" +msgstr "``parser.clear()`` 會保持它不變," #: ../../library/configparser.rst:488 msgid "``parser.popitem()`` never returns it." -msgstr "" +msgstr "``parser.popitem()`` 永遠不會回傳它。" #: ../../library/configparser.rst:490 msgid "" @@ -1030,6 +1033,11 @@ msgid "" "\n" " this = is still a part of the multiline value of 'key'" msgstr "" +"[Section]\n" +"key = multiline\n" +" value with a gotcha\n" +"\n" +" this = is still a part of the multiline value of 'key'" #: ../../library/configparser.rst:695 msgid "" @@ -1460,15 +1468,15 @@ msgstr "" #: ../../library/configparser.rst:1028 msgid "The default *dict_type* is :class:`collections.OrderedDict`." -msgstr "" +msgstr "預設的 *dict_type* 是 :class:`collections.OrderedDict`。" -#: ../../library/configparser.rst:1031 ../../library/configparser.rst:1320 +#: ../../library/configparser.rst:1031 ../../library/configparser.rst:1324 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:1325 +#: ../../library/configparser.rst:1036 ../../library/configparser.rst:1329 msgid "The *converters* argument was added." msgstr "新增 *converters* 引數。" @@ -1479,7 +1487,7 @@ msgid "" "converted to strings." msgstr "" -#: ../../library/configparser.rst:1044 ../../library/configparser.rst:1328 +#: ../../library/configparser.rst:1044 ../../library/configparser.rst:1332 msgid "" "The default *dict_type* is :class:`dict`, since it now preserves insertion " "order." @@ -1491,7 +1499,7 @@ msgid "" "and a key without a value is continued with an indented line." msgstr "" -#: ../../library/configparser.rst:1052 ../../library/configparser.rst:1332 +#: ../../library/configparser.rst:1052 ../../library/configparser.rst:1336 msgid "The *allow_unnamed_section* argument was added." msgstr "新增 *allow_unnamed_section* 引數。" @@ -1721,27 +1729,33 @@ msgid "" "surrounded by spaces." msgstr "" -#: ../../library/configparser.rst:1249 +#: ../../library/configparser.rst:1247 +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 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:1257 +#: ../../library/configparser.rst:1261 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:1265 +#: ../../library/configparser.rst:1269 msgid "" "Remove the specified *section* from the configuration. If the section in " "fact existed, return ``True``. Otherwise return ``False``." msgstr "" -#: ../../library/configparser.rst:1271 +#: ../../library/configparser.rst:1275 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 " @@ -1750,7 +1764,7 @@ msgid "" "of this name on instances to affect this behavior." msgstr "" -#: ../../library/configparser.rst:1277 +#: ../../library/configparser.rst:1281 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 " @@ -1758,7 +1772,7 @@ msgid "" "sensitive::" msgstr "" -#: ../../library/configparser.rst:1282 +#: ../../library/configparser.rst:1286 msgid "" "cfgparser = ConfigParser()\n" "cfgparser.optionxform = str" @@ -1766,30 +1780,30 @@ msgstr "" "cfgparser = ConfigParser()\n" "cfgparser.optionxform = str" -#: ../../library/configparser.rst:1285 +#: ../../library/configparser.rst:1289 msgid "" "Note that when reading configuration files, whitespace around the option " "names is stripped before :meth:`optionxform` is called." msgstr "" -#: ../../library/configparser.rst:1291 +#: ../../library/configparser.rst:1295 msgid "" "A special object representing a section name used to reference the unnamed " "section (see :ref:`unnamed-sections`)." msgstr "" -#: ../../library/configparser.rst:1296 +#: ../../library/configparser.rst:1300 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:1304 +#: ../../library/configparser.rst:1308 msgid "RawConfigParser Objects" msgstr "RawConfigParser 物件" -#: ../../library/configparser.rst:1315 +#: ../../library/configparser.rst:1319 msgid "" "Legacy variant of the :class:`ConfigParser`. It has interpolation disabled " "by default and allows for non-string section names, option names, and values " @@ -1797,27 +1811,37 @@ msgid "" "``defaults=`` keyword argument handling." msgstr "" -#: ../../library/configparser.rst:1336 +#: ../../library/configparser.rst:1340 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:1343 +#: ../../library/configparser.rst:1347 +msgid "" +"Add a section named *section* or :const:`UNNAMED_SECTION` to the instance." +msgstr "" + +#: ../../library/configparser.rst:1349 msgid "" -"Add a section named *section* to the instance. If a section by the given " -"name already exists, :exc:`DuplicateSectionError` is raised. If the " -"*default section* name is passed, :exc:`ValueError` is raised." +"If the given section already exists, :exc:`DuplicateSectionError` is raised. " +"If the *default section* name is passed, :exc:`ValueError` is raised. " +"If :const:`UNNAMED_SECTION` is passed and support is " +"disabled, :exc:`UnnamedSectionDisabledError` is raised." msgstr "" -#: ../../library/configparser.rst:1347 +#: ../../library/configparser.rst:1354 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:1353 +#: ../../library/configparser.rst:1357 +msgid "Added support for :const:`UNNAMED_SECTION`." +msgstr "新增對 :const:`UNNAMED_SECTION` 的支援。" + +#: ../../library/configparser.rst:1363 msgid "" "If the given section exists, set the given option to the specified value; " "otherwise raise :exc:`NoSectionError`. While it is possible to " @@ -1827,7 +1851,7 @@ msgid "" "string values." msgstr "" -#: ../../library/configparser.rst:1360 +#: ../../library/configparser.rst:1370 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 " @@ -1835,32 +1859,32 @@ msgid "" "not allow such assignments to take place." msgstr "" -#: ../../library/configparser.rst:1367 +#: ../../library/configparser.rst:1377 msgid "Exceptions" msgstr "例外" -#: ../../library/configparser.rst:1371 +#: ../../library/configparser.rst:1381 msgid "Base class for all other :mod:`configparser` exceptions." msgstr "" -#: ../../library/configparser.rst:1376 +#: ../../library/configparser.rst:1386 msgid "Exception raised when a specified section is not found." msgstr "" -#: ../../library/configparser.rst:1381 +#: ../../library/configparser.rst:1391 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:1385 +#: ../../library/configparser.rst:1395 msgid "" "Added the optional *source* and *lineno* attributes and parameters " "to :meth:`!__init__`." msgstr "" -#: ../../library/configparser.rst:1392 +#: ../../library/configparser.rst:1402 msgid "" "Exception raised by strict parsers if a single option appears twice during " "reading from a single file, string or dictionary. This catches misspellings " @@ -1868,64 +1892,83 @@ msgid "" "representing the same case-insensitive configuration key." msgstr "" -#: ../../library/configparser.rst:1400 +#: ../../library/configparser.rst:1410 msgid "" "Exception raised when a specified option is not found in the specified " "section." msgstr "" -#: ../../library/configparser.rst:1406 +#: ../../library/configparser.rst:1416 msgid "" "Base class for exceptions raised when problems occur performing string " "interpolation." msgstr "" -#: ../../library/configparser.rst:1412 +#: ../../library/configparser.rst:1422 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:1419 +#: ../../library/configparser.rst:1429 msgid "" "Exception raised when an option referenced from a value does not exist. " "Subclass of :exc:`InterpolationError`." msgstr "" -#: ../../library/configparser.rst:1425 +#: ../../library/configparser.rst:1435 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:1431 +#: ../../library/configparser.rst:1441 msgid "" "Exception raised when attempting to parse a file which has no section " "headers." msgstr "" -#: ../../library/configparser.rst:1437 +#: ../../library/configparser.rst:1446 msgid "Exception raised when errors occur attempting to parse a file." msgstr "" -#: ../../library/configparser.rst:1439 +#: ../../library/configparser.rst:1448 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:1445 +#: ../../library/configparser.rst:1454 msgid "" "Exception raised when a key without a corresponding value is continued with " "an indented line." msgstr "" -#: ../../library/configparser.rst:1451 +#: ../../library/configparser.rst:1461 +msgid "" +"Exception raised when attempting to use the :const:`UNNAMED_SECTION` without " +"enabling it." +msgstr "" + +#: ../../library/configparser.rst:1468 +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 +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 msgid "Footnotes" msgstr "註腳" -#: ../../library/configparser.rst:1452 +#: ../../library/configparser.rst:1479 msgid "" "Config parsers allow for heavy customization. If you are interested in " "changing the behaviour outlined by the footnote reference, consult the " diff --git a/library/constants.po b/library/constants.po index 6b622131bca..ec45a2b3aba 100644 --- a/library/constants.po +++ b/library/constants.po @@ -1,5 +1,4 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -7,9 +6,9 @@ # Leon H., 2017 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-08-16 00:16+0000\n" +"POT-Creation-Date: 2025-09-12 00:14+0000\n" "PO-Revision-Date: 2021-11-19 23:36+0800\n" "Last-Translator: Jordan Su \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -106,27 +105,31 @@ msgstr "" "`NotImplementedError`。" #: ../../library/constants.rst:56 +msgid "Evaluating :data:`!NotImplemented` in a boolean context was deprecated." +msgstr "在 boolean(布林)上下文中對 :data:`!NotImplemented` 求值的操作已被棄用。" + +#: ../../library/constants.rst:59 msgid "" -"Evaluating :data:`!NotImplemented` in a boolean context is deprecated. While " -"it currently evaluates as true, it will emit a :exc:`DeprecationWarning`. It " -"will raise a :exc:`TypeError` in a future version of Python." +"Evaluating :data:`!NotImplemented` in a boolean context now raises a :exc:" +"`TypeError`. It previously evaluated to :const:`True` and emitted a :exc:" +"`DeprecationWarning` since Python 3.9." msgstr "" -"在 boolean(布林)上下文中解讀 :data:`!NotImplemented` 已經被棄用。雖然目前會" -"被解讀成 true,但會發出一個 :exc:`DeprecationWarning`。在未來版本的 Python 將" -"會拋出 :exc:`TypeError`。" +"在 boolean 上下文中解讀 :data:`!NotImplemented` 現在會引發 :exc:" +"`TypeError`。過去自 Python 3.9 以來,這會被解讀成 :const:`True`,並發出 :exc:" +"`DeprecationWarning`" -#: ../../library/constants.rst:65 +#: ../../library/constants.rst:68 msgid "" -"The same as the ellipsis literal \"``...``\". Special value used mostly in " -"conjunction with extended slicing syntax for user-defined container data " -"types. ``Ellipsis`` is the sole instance of the :data:`types.EllipsisType` " -"type." +"The same as the ellipsis literal \"``...``\", an object frequently used to " +"indicate that something is omitted. Assignment to ``Ellipsis`` is possible, " +"but assignment to ``...`` raises a :exc:`SyntaxError`. ``Ellipsis`` is the " +"sole instance of the :data:`types.EllipsisType` type." msgstr "" -"與刪節號 \"``...``\" 字面相同。為一特殊值,大多用於結合使用者定義資料型別的延" -"伸切片語法 (extended slicing syntax)。``Ellipsis`` 是型別 :data:`types." -"EllipsisType` 的唯一實例。" +"與刪節號 \"``...``\" 字面相同,是一個經常被用來表示某些東西被省略的物件。對於 " +"``Ellipsis`` 的賦值是可能的,但對於 ``...`` 的賦值會引發 :exc:`SyntaxError`。" +"``Ellipsis`` 是型別 :data:`types.EllipsisType` 的唯一實例。" -#: ../../library/constants.rst:72 +#: ../../library/constants.rst:76 msgid "" "This constant is true if Python was not started with an :option:`-O` option. " "See also the :keyword:`assert` statement." @@ -134,7 +137,7 @@ msgstr "" "如果 Python 沒有被以 :option:`-O` 選項啟動,則此常數為 true。請參見 :keyword:" "`assert` 陳述式。" -#: ../../library/constants.rst:78 +#: ../../library/constants.rst:82 msgid "" "The names :data:`None`, :data:`False`, :data:`True` and :data:`__debug__` " "cannot be reassigned (assignments to them, even as an attribute name, raise :" @@ -144,11 +147,11 @@ msgstr "" "重新賦值的(任何對它們的賦值,即使是屬性的名稱,也會拋出 :exc:" "`SyntaxError`)。因此,它們可以被視為”真正的”常數。" -#: ../../library/constants.rst:86 +#: ../../library/constants.rst:90 msgid "Constants added by the :mod:`site` module" msgstr "由 :mod:`site` module(模組)所添增的常數" -#: ../../library/constants.rst:88 +#: ../../library/constants.rst:92 msgid "" "The :mod:`site` module (which is imported automatically during startup, " "except if the :option:`-S` command-line option is given) adds several " @@ -159,16 +162,17 @@ msgstr "" "指令行選項)會添增一些常數到內建命名空間 (built-in namespace) 中。它們在互動" "式直譯器中是很有幫助的,但不應該在程式 (programs) 中被使用。" -#: ../../library/constants.rst:96 +#: ../../library/constants.rst:100 msgid "" "Objects that when printed, print a message like \"Use quit() or Ctrl-D (i.e. " "EOF) to exit\", and when accessed directly in the interactive interpreter or " "called as functions, raise :exc:`SystemExit` with the specified exit code." msgstr "" -"當印出物件時,會印出一個訊息:\"Use quit() or Ctrl-D (i.e. EOF) to exit\"。" -"當直接在互動式直譯器中存取或作為函式呼叫時,會引發 :exc:`SystemExit` 並帶有指定的返回碼(exit code)。" +"當印出物件時,會印出一個訊息:\"Use quit() or Ctrl-D (i.e. EOF) to exit\"。當" +"直接在互動式直譯器中存取或作為函式呼叫時,會引發 :exc:`SystemExit` 並帶有指定" +"的返回碼(exit code)。" -#: ../../library/constants.rst:104 +#: ../../library/constants.rst:108 msgid "" "Object that when printed, prints the message \"Type help() for interactive " "help, or help(object) for help about object.\", and when accessed directly " @@ -176,16 +180,16 @@ msgid "" "`help`)." msgstr "" "當印出此物件時,會印出訊息 \"Type help() for interactive help, or " -"help(object) for help about object.\",並在互動式直譯器中直接存取時,會叫用內建的" -"幫助系統(參見 :func:`help`)。" +"help(object) for help about object.\",並在互動式直譯器中直接存取時,會叫用內" +"建的幫助系統(參見 :func:`help`)。" -#: ../../library/constants.rst:112 +#: ../../library/constants.rst:116 msgid "" "Objects that when printed or called, print the text of copyright or credits, " "respectively." msgstr "當印出或是呼叫此物件時,分別會印出版權與致謝的文字。" -#: ../../library/constants.rst:117 +#: ../../library/constants.rst:121 msgid "" "Object that when printed, prints the message \"Type license() to see the " "full license text\", and when called, displays the full license text in a " @@ -194,10 +198,10 @@ msgstr "" "當印出此物件時,會印出訊息 \"Type license() to see the full license text\"," "並在呼叫時以分頁形式印出完整的許可證文字(一次一整個畫面)。" -#: ../../library/constants.rst:62 +#: ../../library/constants.rst:65 msgid "..." msgstr "..." -#: ../../library/constants.rst:62 +#: ../../library/constants.rst:65 msgid "ellipsis literal" -msgstr "ellipsis literal(刪節號)" +msgstr "ellipsis literal(刪節號字面值)" diff --git a/library/contextlib.po b/library/contextlib.po index a7be4735e6c..95c6fea0157 100644 --- a/library/contextlib.po +++ b/library/contextlib.po @@ -1,11 +1,10 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2025-04-11 00:15+0000\n" "PO-Revision-Date: 2018-05-23 14:41+0000\n" @@ -637,7 +636,7 @@ msgstr "" #: ../../library/contextlib.rst:418 ../../library/contextlib.rst:490 msgid "The class can then be used like this::" -msgstr "" +msgstr "這個類別可以這樣使用: ::" #: ../../library/contextlib.rst:420 msgid "" @@ -676,7 +675,7 @@ msgstr "" #: ../../library/contextlib.rst:436 msgid "" "This change is just syntactic sugar for any construct of the following form::" -msgstr "" +msgstr "這個變更只是以下形式的語法糖: ::" #: ../../library/contextlib.rst:438 msgid "" @@ -684,10 +683,13 @@ msgid "" " with cm():\n" " # Do stuff" msgstr "" +"def f():\n" +" with cm():\n" +" # Do stuff" #: ../../library/contextlib.rst:442 msgid "``ContextDecorator`` lets you instead write::" -msgstr "" +msgstr "``ContextDecorator`` 讓你可以改寫成: ::" #: ../../library/contextlib.rst:444 msgid "" @@ -695,6 +697,9 @@ msgid "" "def f():\n" " # Do stuff" msgstr "" +"@cm()\n" +"def f():\n" +" # Do stuff" #: ../../library/contextlib.rst:448 msgid "" @@ -739,7 +744,7 @@ msgstr "" #: ../../library/contextlib.rst:474 msgid "" "Similar to :class:`ContextDecorator` but only for asynchronous functions." -msgstr "" +msgstr "和 :class:`ContextDecorator` 類似,但僅用於非同步函式。" #: ../../library/contextlib.rst:476 msgid "Example of ``AsyncContextDecorator``::" @@ -1007,15 +1012,15 @@ msgstr "" #: ../../library/contextlib.rst:649 msgid "Similar to :meth:`ExitStack.callback` but expects a coroutine function." -msgstr "" +msgstr "和 :meth:`ExitStack.callback` 類似,但預期接受一個協程函式。" #: ../../library/contextlib.rst:654 msgid "Similar to :meth:`ExitStack.close` but properly handles awaitables." -msgstr "" +msgstr "和 :meth:`ExitStack.close` 類似,但能夠正確處理可等待物件。" #: ../../library/contextlib.rst:656 msgid "Continuing the example for :func:`asynccontextmanager`::" -msgstr "" +msgstr "延續 :func:`asynccontextmanager` 的範例: ::" #: ../../library/contextlib.rst:658 msgid "" diff --git a/library/contextvars.po b/library/contextvars.po index 781c21303f7..99e9c78a456 100644 --- a/library/contextvars.po +++ b/library/contextvars.po @@ -1,10 +1,10 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-10-31 00:13+0000\n" +"POT-Creation-Date: 2025-09-08 15:25+0800\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-" @@ -28,15 +28,15 @@ msgid "" "context in asynchronous frameworks." msgstr "" "本模組供 API 來管理、儲存及存取單一情境各自的狀態(context-local state)。 " -"用 :class:`~contextvars.ContextVar` 類別宣告和處理\\ *情境變數*。 :func:" -"`~contextvars.copy_context` 函式和 :class:`~contextvars.Context` 類別應在非同" -"步框架中管理目前的情境。" +"用 :class:`~contextvars.ContextVar` 類別宣告和處理\\ *情境變數" +"*。 :func:`~contextvars.copy_context` 函式和 :class:`~contextvars.Context` 類" +"別應在非同步框架中管理目前的情境。" #: ../../library/contextvars.rst:17 msgid "" -"Context managers that have state should use Context Variables instead of :" -"func:`threading.local` to prevent their state from bleeding to other code " -"unexpectedly, when used in concurrent code." +"Context managers that have state should use Context Variables instead " +"of :func:`threading.local` to prevent their state from bleeding to other " +"code unexpectedly, when used in concurrent code." msgstr "" "帶有狀態的 Context Manager 應該使用情境變數,而不是 :func:`threading.local`," "才能防止它們的狀態在並行(concurrent)程式碼中使用時意外外溢並干擾到其他程式" @@ -65,12 +65,12 @@ msgstr "必要參數 *name* 用於自我檢查(introspection)和除錯。" #: ../../library/contextvars.rst:38 msgid "" -"The optional keyword-only *default* parameter is returned by :meth:" -"`ContextVar.get` when no value for the variable is found in the current " -"context." +"The optional keyword-only *default* parameter is returned " +"by :meth:`ContextVar.get` when no value for the variable is found in the " +"current context." msgstr "" -"當在目前的情境中找不到變數的值時,:meth:`ContextVar.get` 會回傳可選的僅限關鍵字參" -"數 *default*。" +"當在目前的情境中找不到變數的值時,:meth:`ContextVar.get` 會回傳可選的僅限關鍵" +"字參數 *default*。" #: ../../library/contextvars.rst:42 msgid "" @@ -127,13 +127,13 @@ 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." msgstr "" -"回傳一個 :class:`~contextvars.Token` 物件,該物件可透過 :meth:`ContextVar." -"reset` 方法,用來將變數還原到之前的值。" +"回傳一個 :class:`~contextvars.Token` 物件,該物件可透" +"過 :meth:`ContextVar.reset` 方法,用來將變數還原到之前的值。" #: ../../library/contextvars.rst:82 msgid "" -"Reset the context variable to the value it had before the :meth:`ContextVar." -"set` that created the *token* was used." +"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:85 @@ -166,44 +166,72 @@ msgid "" "be passed to the :meth:`ContextVar.reset` method to revert the value of the " "variable to what it was before the corresponding *set*." msgstr "" -"*Token* 物件由 :meth:`ContextVar.set` 方法回傳,可以傳遞給 :meth:`ContextVar." -"reset` 方法,用以將變數的值還原為相對應的 *set* 之前的值。" +"*Token* 物件由 :meth:`ContextVar.set` 方法回傳,可以傳遞" +"給 :meth:`ContextVar.reset` 方法,用以將變數的值還原為相對應的 *set* 之前的" +"值。" -#: ../../library/contextvars.rst:106 +#: ../../library/contextvars.rst:104 +msgid "" +"The token supports :ref:`context manager protocol ` to " +"restore the corresponding context variable value at the exit " +"from :keyword:`with` block::" +msgstr "" + +#: ../../library/contextvars.rst:108 +msgid "" +"var = ContextVar('var', default='default value')\n" +"\n" +"with var.set('new value'):\n" +" assert var.get() == 'new value'\n" +"\n" +"assert var.get() == 'default value'" +msgstr "" +"var = ContextVar('var', default='default value')\n" +"\n" +"with var.set('new value'):\n" +" assert var.get() == 'new value'\n" +"\n" +"assert var.get() == 'default value'" + +#: ../../library/contextvars.rst:117 +msgid "Added support for usage as a context manager." +msgstr "新增對用作情境管理器的支援。" + +#: ../../library/contextvars.rst:121 msgid "" "A read-only property. Points to the :class:`ContextVar` object that created " "the token." msgstr "唯讀屬性。 指向建立 token 的 :class:`ContextVar` 物件。" -#: ../../library/contextvars.rst:111 +#: ../../library/contextvars.rst:126 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:" -"`Token.MISSING` if the variable was not set before the call." +"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:`Token.MISSING` if the variable was not set before the call." msgstr "" "唯讀屬性。 值為變數在呼叫 :meth:`ContextVar.set` 方法之前的值。如果變數在呼叫" "前沒有設定,則指向 :attr:`Token.MISSING`。" -#: ../../library/contextvars.rst:118 +#: ../../library/contextvars.rst:133 msgid "A marker object used by :attr:`Token.old_value`." msgstr "由 :attr:`Token.old_value` 使用的標記物件。" -#: ../../library/contextvars.rst:122 +#: ../../library/contextvars.rst:137 msgid "Manual Context Management" msgstr "手動情境管理" -#: ../../library/contextvars.rst:126 +#: ../../library/contextvars.rst:141 msgid "Returns a copy of the current :class:`~contextvars.Context` object." msgstr "回傳目前 :class:`~contextvars.Context` 物件的複本(copy)。" -#: ../../library/contextvars.rst:128 +#: ../../library/contextvars.rst:143 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:131 +#: ../../library/contextvars.rst:146 msgid "" "ctx: Context = copy_context()\n" "print(list(ctx.items()))" @@ -211,7 +239,7 @@ msgstr "" "ctx: Context = copy_context()\n" "print(list(ctx.items()))" -#: ../../library/contextvars.rst:134 +#: ../../library/contextvars.rst:149 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 " @@ -220,30 +248,30 @@ msgstr "" "這個函式具有 *O*\\ (1) 的複雜度,也就是說,對於只有少許情境變數的情境和有大量" "情境變數的情境,速度都一樣快。" -#: ../../library/contextvars.rst:141 +#: ../../library/contextvars.rst:156 msgid "A mapping of :class:`ContextVars ` to their values." msgstr ":class:`ContextVars` 到其值的映射。" -#: ../../library/contextvars.rst:143 +#: ../../library/contextvars.rst:158 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." msgstr "" -"``Context()`` 會建立一個沒有值的空情境。要取得目前情境的複本,請使用 :func:" -"`~contextvars.copy_context` 函式。" +"``Context()`` 會建立一個沒有值的空情境。要取得目前情境的複本,請使" +"用 :func:`~contextvars.copy_context` 函式。" -#: ../../library/contextvars.rst:147 +#: ../../library/contextvars.rst:162 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 " -"current thread's stack. All :class:`!Context` objects in the stacks are " +"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 current thread's stack. All :class:`!Context` objects in the stacks are " "considered to be *entered*." msgstr "" -"每個執行緒都有自己的 :class:`!Context` 物件中目前主控中的堆疊(stack)。:" -"term:`current context` 是目前執行緒堆疊頂端的 :class:`!Context` 物件。 堆疊" -"中的所有 :class:`!Context` 物件都被視為\\ *已進入*。" +"每個執行緒都有自己的 :class:`!Context` 物件中目前主控中的堆疊" +"(stack)。:term:`current context` 是目前執行緒堆疊頂端的 :class:`!Context` " +"物件。 堆疊中的所有 :class:`!Context` 物件都被視為\\ *已進入*。" -#: ../../library/contextvars.rst:152 +#: ../../library/contextvars.rst:167 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 " @@ -252,7 +280,7 @@ msgstr "" "*進入*\\ 一個情境,可以藉由呼叫其 :meth:`~Context.run` 方法來完成,此\\ *進入" "*\\ 的動作會將一情境推到目前執行緒的情境堆疊的頂端,使該情境成為目前的情境。" -#: ../../library/contextvars.rst:156 +#: ../../library/contextvars.rst:171 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 " @@ -263,28 +291,28 @@ msgstr "" "式回傳之後,就會自動\\ *退出*\\ 目前的情境,這會將目前的情境還原到進入情境之" "前的狀態,方法是將情境從情境堆疊的頂端彈出。" -#: ../../library/contextvars.rst:161 +#: ../../library/contextvars.rst:176 msgid "" "Since each thread has its own context stack, :class:`ContextVar` objects " "behave in a similar fashion to :func:`threading.local` when values are " "assigned in different threads." msgstr "" -"因為每個執行緒都有自己的情境堆疊,當值在不同的執行緒中被指定時, :class:" -"`ContextVar` 物件的行為與 :func:`threading.local` 相似。" +"因為每個執行緒都有自己的情境堆疊,當值在不同的執行緒中被指定" +"時, :class:`ContextVar` 物件的行為與 :func:`threading.local` 相似。" -#: ../../library/contextvars.rst:165 +#: ../../library/contextvars.rst:180 msgid "" "Attempting to enter an already entered context, including contexts entered " "in other threads, raises a :exc:`RuntimeError`." msgstr "" -"嘗試進入已進入的情境,包括在其他執行緒中進入的情境,會引發 :exc:" -"`RuntimeError`。" +"嘗試進入已進入的情境,包括在其他執行緒中進入的情境,會引" +"發 :exc:`RuntimeError`。" -#: ../../library/contextvars.rst:168 +#: ../../library/contextvars.rst:183 msgid "After exiting a context, it can later be re-entered (from any thread)." msgstr "退出情境後,之後可以重新進入(從任何執行緒)。" -#: ../../library/contextvars.rst:170 +#: ../../library/contextvars.rst:185 msgid "" "Any changes to :class:`ContextVar` values via the :meth:`ContextVar.set` " "method are recorded in the current context. The :meth:`ContextVar.get` " @@ -298,11 +326,11 @@ msgstr "" "實際造成的效果會像是將其在進入情境時對情境變數所做的任何變一一彈出並還原(如" "果需要,可以透過重新進入情境來還原值)。" -#: ../../library/contextvars.rst:177 +#: ../../library/contextvars.rst:192 msgid "Context implements the :class:`collections.abc.Mapping` interface." msgstr "情境(Context)實作了 :class:`collections.abc.Mapping` 介面。" -#: ../../library/contextvars.rst:181 +#: ../../library/contextvars.rst:196 msgid "" "Enters the Context, executes ``callable(*args, **kwargs)``, then exits the " "Context. Returns *callable*'s return value, or propagates an exception if " @@ -311,11 +339,11 @@ msgstr "" "進入 Context,執行 ``callable(*args, **kwargs)``,然後退出 Context。 回傳 " "*callable* 的回傳值,如果發生例外(exception),則傳播例外。" -#: ../../library/contextvars.rst:185 +#: ../../library/contextvars.rst:200 msgid "Example:" msgstr "例如:" -#: ../../library/contextvars.rst:187 +#: ../../library/contextvars.rst:202 msgid "" "import contextvars\n" "\n" @@ -379,18 +407,18 @@ msgstr "" "# 但是,在 'ctx' 外, 'var' 的值仍然是 'spam':\n" "print(var.get()) # 'spam'" -#: ../../library/contextvars.rst:233 +#: ../../library/contextvars.rst:248 msgid "Return a shallow copy of the context object." msgstr "回傳情境物件的淺層複本(shallow copy)。" -#: ../../library/contextvars.rst:237 +#: ../../library/contextvars.rst:252 msgid "" "Return ``True`` if the *context* has a value for *var* set; return ``False`` " "otherwise." msgstr "" "如果\\ *情境*\\ 裡面有 *var* 的值,則回傳 ``True``,否則回傳 ``False``。" -#: ../../library/contextvars.rst:242 +#: ../../library/contextvars.rst:257 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." @@ -398,41 +426,41 @@ msgstr "" "回傳 *var* :class:`ContextVar` 變數的值。如果該變數並沒有在情境物件中設定,則" "會引發 :exc:`KeyError` 錯誤。" -#: ../../library/contextvars.rst:248 +#: ../../library/contextvars.rst:263 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``." msgstr "" -"如果 *var* 的值在情境物件中,則回傳 *var* 的值。否則回傳 *default*。如果" -"沒有 *default* 值,則回傳 ``None``。" +"如果 *var* 的值在情境物件中,則回傳 *var* 的值。否則回傳 *default*。如果沒有 " +"*default* 值,則回傳 ``None``。" -#: ../../library/contextvars.rst:254 +#: ../../library/contextvars.rst:269 msgid "Return an iterator over the variables stored in the context object." msgstr "回傳儲存於情境物件中變數的疊代器。" -#: ../../library/contextvars.rst:259 +#: ../../library/contextvars.rst:274 msgid "Return the number of variables set in the context object." msgstr "回傳情境物件中的變數個數。" -#: ../../library/contextvars.rst:263 +#: ../../library/contextvars.rst:278 msgid "Return a list of all variables in the context object." msgstr "回傳情境物件中所有變數的串列。" -#: ../../library/contextvars.rst:267 +#: ../../library/contextvars.rst:282 msgid "Return a list of all variables' values in the context object." msgstr "回傳情境物件中所有變數的值的串列。" -#: ../../library/contextvars.rst:272 +#: ../../library/contextvars.rst:287 msgid "" "Return a list of 2-tuples containing all variables and their values in the " "context object." msgstr "回傳情境物件中所有變數與其值的 2-元組(2-tuples)的串列。" -#: ../../library/contextvars.rst:277 +#: ../../library/contextvars.rst:292 msgid "asyncio support" msgstr "對 asyncio 的支援" -#: ../../library/contextvars.rst:279 +#: ../../library/contextvars.rst:294 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 " @@ -442,7 +470,7 @@ msgstr "" ":mod:`asyncio` 原生支援情境變數,不需任何額外設定。 舉例來說,以下是一個簡單" "的 echo 伺服器,使用情境變數讓遠端用戶端的位址在處理該用戶端的任務中可用:" -#: ../../library/contextvars.rst:285 +#: ../../library/contextvars.rst:300 msgid "" "import asyncio\n" "import contextvars\n" diff --git a/library/copy.po b/library/copy.po index d3d49fd63fa..0d7aa89b793 100644 --- a/library/copy.po +++ b/library/copy.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -6,7 +6,7 @@ # Matt Wang , 2022 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2022-01-20 18:49+0800\n" diff --git a/library/copyreg.po b/library/copyreg.po index d0f8976f36a..eb99e7b7fc0 100644 --- a/library/copyreg.po +++ b/library/copyreg.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2023, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -6,7 +6,7 @@ # Matt Wang , 2023 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-05-09 00:03+0000\n" "PO-Revision-Date: 2023-12-29 00:29+0000\n" diff --git a/library/crypt.po b/library/crypt.po index c8e1251bc01..07db5a7c63d 100644 --- a/library/crypt.po +++ b/library/crypt.po @@ -1,12 +1,12 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # #, fuzzy msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-11-18 00:15+0000\n" +"POT-Creation-Date: 2025-10-10 00:15+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -34,12 +34,12 @@ msgstr "" msgid "" "Applications can use the :mod:`hashlib` module from the standard library. " "Other possible replacements are third-party libraries from PyPI: :pypi:" -"`legacycrypt`, :pypi:`bcrypt`, :pypi:`argon2-cffi`, or :pypi:`passlib`. " -"These are not supported or maintained by the Python core team." +"`legacycrypt`, :pypi:`bcrypt`, or :pypi:`argon2-cffi`. These are not " +"supported or maintained by the Python core team." msgstr "" "應用程式可以改用標準函式庫中的 :mod:`hashlib` 模組。其他可能的替代方案是 " -"PyPI 上的第三方庫::pypi:`legacycrypt`、:pypi:`bcrypt`、:pypi:`argon2-cffi` " -"或 :pypi:`passlib`。這些函式庫並不受 Python 核心團隊支援或維護。" +"PyPI 上的第三方庫::pypi:`legacycrypt`、:pypi:`bcrypt` 或 :pypi:`argon2-cffi`" +"。這些函式庫並不受 Python 核心團隊支援或維護。" #: ../../library/crypt.rst:19 msgid "" diff --git a/library/crypto.po b/library/crypto.po index acdd2c02bfe..86e4a6c1df1 100644 --- a/library/crypto.po +++ b/library/crypto.po @@ -1,11 +1,11 @@ -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Matt Wang , 2022 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-23 07:52+0800\n" "PO-Revision-Date: 2022-02-15 18:06+0800\n" diff --git a/library/csv.po b/library/csv.po index 521f820d4fb..a88e2758512 100644 --- a/library/csv.po +++ b/library/csv.po @@ -1,12 +1,12 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-08-25 00:17+0000\n" +"POT-Creation-Date: 2025-11-12 00:16+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-" @@ -483,10 +483,10 @@ msgstr "" #: ../../library/csv.rst:298 msgid "" -"Twenty rows after the first row are sampled; if more than half of columns + " -"rows meet the criteria, :const:`True` is returned." +"Twenty-one rows after the header are sampled; if more than half of the " +"columns + rows meet the criteria, :const:`True` is returned." msgstr "" -"對第一列之後的二十個列進行取樣;如果超過一半的行及列滿足條件,則返回 :const:" +"對標頭之後的二十一個列進行取樣;如果超過一半的行及列滿足條件,則回傳 :const:" "`True`。" #: ../../library/csv.rst:303 @@ -603,7 +603,7 @@ msgid "" "``None`` and to otherwise behave as :data:`QUOTE_NONNUMERIC`." msgstr "" "引導 :class:`reader` 物件將空(沒有引號)字串直譯為 ``None``,否則會和 :data:" -"`QUOTE_ALL` 有相同的表現方式。" +"`QUOTE_NONNUMERIC` 有相同的表現方式。" #: ../../library/csv.rst:378 msgid "The :mod:`csv` module defines the following exception:" @@ -743,23 +743,25 @@ msgstr "" #: ../../library/csv.rst:470 msgid "" "When :const:`True`, spaces immediately following the *delimiter* are " -"ignored. The default is :const:`False`." +"ignored. The default is :const:`False`. When combining ``delimiter=' '`` " +"with ``skipinitialspace=True``, unquoted empty fields are not allowed." msgstr "" "若為 :const:`True`,在緊接著\\ *delimiter*\\ 後的空格會被忽略。預設為 :const:" -"`False`。" +"`False`。當結合 ``delimiter=' '`` 與 ``skipinitialspace=True`` 時,不允許沒有" +"引號的空欄位。" -#: ../../library/csv.rst:476 +#: ../../library/csv.rst:477 msgid "" "When ``True``, raise exception :exc:`Error` on bad CSV input. The default is " "``False``." msgstr "" "若為 ``True``,若有錯誤的 CSV 輸入則會引發 :exc:`Error`。預設為 ``False``。" -#: ../../library/csv.rst:482 +#: ../../library/csv.rst:483 msgid "Reader Objects" msgstr "讀取器物件" -#: ../../library/csv.rst:484 +#: ../../library/csv.rst:485 msgid "" "Reader objects (:class:`DictReader` instances and objects returned by the :" "func:`reader` function) have the following public methods:" @@ -767,7 +769,7 @@ msgstr "" "讀取器物件(:func:`reader` 函式回傳的 :class:`DictReader` 實例與物件)有下列" "公開方法 (public method):" -#: ../../library/csv.rst:489 +#: ../../library/csv.rst:490 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` " @@ -778,25 +780,25 @@ msgstr "" "傳)或是一個 dict(若為 :class:`DictReader` 實例),會依據目前的 :class:" "`Dialect` 進行剖析。通常會用 ``next(reader)`` 來進行呼叫。" -#: ../../library/csv.rst:495 +#: ../../library/csv.rst:496 msgid "Reader objects have the following public attributes:" msgstr "讀取器物件有下列公開屬性 (public attributes):" -#: ../../library/csv.rst:499 +#: ../../library/csv.rst:500 msgid "A read-only description of the dialect in use by the parser." msgstr "dialect 的唯讀敘述,會被剖析器使用。" -#: ../../library/csv.rst:504 +#: ../../library/csv.rst:505 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:508 +#: ../../library/csv.rst:509 msgid "DictReader objects have the following public attribute:" msgstr "DictReader 物件有下列公開屬性:" -#: ../../library/csv.rst:512 +#: ../../library/csv.rst:513 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." @@ -804,11 +806,11 @@ msgstr "" "若在建立物件時沒有作為參數傳遞,這個屬性會在第一次存取之前或是第一筆資料被讀" "取之前進行初始化 (initialize)。" -#: ../../library/csv.rst:519 +#: ../../library/csv.rst:520 msgid "Writer Objects" msgstr "寫入器物件" -#: ../../library/csv.rst:521 +#: ../../library/csv.rst:522 msgid "" ":class:`writer` objects (:class:`DictWriter` instances and objects returned " "by the :func:`writer` function) have the following public methods. A *row* " @@ -826,7 +828,7 @@ msgstr "" "遞)。請注意,在寫入複數 (complex number) 時會用小括號 (parens) 包起來。這可" "能在其他程式讀取 CSV 檔案時導致某些問題(假設他們完全支援複雜數字)。" -#: ../../library/csv.rst:532 +#: ../../library/csv.rst:533 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 " @@ -835,11 +837,11 @@ msgstr "" "將參數 *row* 寫入至寫入器的檔案物件中,並依照目前的 :class:`Dialect` 進行格式" "化。回傳下層檔案物件 *write* 方法的回傳值。" -#: ../../library/csv.rst:536 +#: ../../library/csv.rst:537 msgid "Added support of arbitrary iterables." msgstr "新增對任意可疊代物件 (arbitrary iterables) 的支援。" -#: ../../library/csv.rst:541 +#: ../../library/csv.rst:542 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 " @@ -848,19 +850,19 @@ msgstr "" "將 *rows* 中所有元素(為上述的一個可疊代的 *row* 物件)寫入至寫入器的檔案物件" "中,並依照目前的 dialect 進行格式化。" -#: ../../library/csv.rst:545 +#: ../../library/csv.rst:546 msgid "Writer objects have the following public attribute:" msgstr "寫入器物件有下列公開屬性:" -#: ../../library/csv.rst:550 +#: ../../library/csv.rst:551 msgid "A read-only description of the dialect in use by the writer." msgstr "dialect 的唯讀敘述,會被寫入器使用。" -#: ../../library/csv.rst:553 +#: ../../library/csv.rst:554 msgid "DictWriter objects have the following public method:" msgstr "DictWriter 物件有下列公開方法:" -#: ../../library/csv.rst:558 +#: ../../library/csv.rst:559 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 " @@ -870,7 +872,7 @@ msgstr "" "中,並依照目前的 dialect 進行格式化。回傳內部呼叫 :meth:`csvwriter.writerow` " "的回傳值。" -#: ../../library/csv.rst:563 +#: ../../library/csv.rst:564 msgid "" ":meth:`writeheader` now also returns the value returned by the :meth:" "`csvwriter.writerow` method it uses internally." @@ -878,15 +880,15 @@ msgstr "" ":meth:`writeheader` 現在也會回傳內部呼叫 :meth:`csvwriter.writerow` 的回傳" "值。" -#: ../../library/csv.rst:571 +#: ../../library/csv.rst:572 msgid "Examples" msgstr "範例" -#: ../../library/csv.rst:573 +#: ../../library/csv.rst:574 msgid "The simplest example of reading a CSV file::" msgstr "最簡單的讀取 CSV 檔案範例: ::" -#: ../../library/csv.rst:575 +#: ../../library/csv.rst:576 msgid "" "import csv\n" "with open('some.csv', newline='') as f:\n" @@ -900,11 +902,11 @@ msgstr "" " for row in reader:\n" " print(row)" -#: ../../library/csv.rst:581 +#: ../../library/csv.rst:582 msgid "Reading a file with an alternate format::" msgstr "讀取一個其他格式的檔案: ::" -#: ../../library/csv.rst:583 +#: ../../library/csv.rst:584 msgid "" "import csv\n" "with open('passwd', newline='') as f:\n" @@ -918,19 +920,23 @@ msgstr "" " for row in reader:\n" " print(row)" -#: ../../library/csv.rst:589 +#: ../../library/csv.rst:590 msgid "The corresponding simplest possible writing example is::" msgstr "相對最簡單、可行的寫入範例為: ::" -#: ../../library/csv.rst:591 +#: ../../library/csv.rst:592 msgid "" "import csv\n" "with open('some.csv', 'w', newline='') as f:\n" " writer = csv.writer(f)\n" " writer.writerows(someiterable)" msgstr "" +"import csv\n" +"with open('some.csv', 'w', newline='') as f:\n" +" writer = csv.writer(f)\n" +" writer.writerows(someiterable)" -#: ../../library/csv.rst:596 +#: ../../library/csv.rst:597 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:" @@ -941,7 +947,7 @@ msgstr "" "碼格式(請見 :func:`locale.getencoding`),並解碼為 unicode。若要使用不同編碼" "格式進行檔案解碼,請使用 open 函式的 ``encoding`` 引數: ::" -#: ../../library/csv.rst:601 +#: ../../library/csv.rst:602 msgid "" "import csv\n" "with open('some.csv', newline='', encoding='utf-8') as f:\n" @@ -955,7 +961,7 @@ msgstr "" " for row in reader:\n" " print(row)" -#: ../../library/csv.rst:607 +#: ../../library/csv.rst:608 msgid "" "The same applies to writing in something other than the system default " "encoding: specify the encoding argument when opening the output file." @@ -963,11 +969,11 @@ msgstr "" "同理可以應用到使用不同編碼格式進行寫入:當開啟輸出檔案時,指定 ``encoding`` " "引數。" -#: ../../library/csv.rst:610 +#: ../../library/csv.rst:611 msgid "Registering a new dialect::" msgstr "註冊一個新的 dialect : ::" -#: ../../library/csv.rst:612 +#: ../../library/csv.rst:613 msgid "" "import csv\n" "csv.register_dialect('unixpwd', delimiter=':', quoting=csv.QUOTE_NONE)\n" @@ -979,13 +985,13 @@ msgstr "" "with open('passwd', newline='') as f:\n" " reader = csv.reader(f, 'unixpwd')" -#: ../../library/csv.rst:617 +#: ../../library/csv.rst:618 msgid "" "A slightly more advanced use of the reader --- catching and reporting " "errors::" msgstr "稍微進階的讀取器用法 -- 擷取及回報錯誤: ::" -#: ../../library/csv.rst:619 +#: ../../library/csv.rst:620 msgid "" "import csv, sys\n" "filename = 'some.csv'\n" @@ -1007,13 +1013,13 @@ msgstr "" " except csv.Error as e:\n" " sys.exit(f'file {filename}, line {reader.line_num}: {e}')" -#: ../../library/csv.rst:629 +#: ../../library/csv.rst:630 msgid "" "And while the module doesn't directly support parsing strings, it can easily " "be done::" msgstr "而當模組無法直接支援剖析字串時,仍可以輕鬆的解決: ::" -#: ../../library/csv.rst:632 +#: ../../library/csv.rst:633 msgid "" "import csv\n" "for row in csv.reader(['one,two,three']):\n" @@ -1023,22 +1029,22 @@ msgstr "" "for row in csv.reader(['one,two,three']):\n" " print(row)" -#: ../../library/csv.rst:638 +#: ../../library/csv.rst:639 msgid "Footnotes" msgstr "註解" -#: ../../library/csv.rst:639 +#: ../../library/csv.rst:640 msgid "" "If ``newline=''`` is not specified, newlines embedded inside quoted fields " -"will not be interpreted correctly, and on platforms that use ``\\r\\n`` " -"linendings on write an extra ``\\r`` will be added. It should always be " -"safe to specify ``newline=''``, since the csv module does its own (:term:" +"will not be interpreted correctly, and on platforms that use ``\\r\\n`` line " +"endings on write an extra ``\\r`` will be added. It should always be safe " +"to specify ``newline=''``, since the csv module does its own (:term:" "`universal `) newline handling." msgstr "" "如果 ``newline=''`` 沒有被指定,則嵌入引號中的換行符號不會被正確直譯,使用 " -"``\\r\\n`` 行尾 (linending) 的平台會寫入額外的 ``\\r``。自從 csv 模組有自己 " -"(:term:`統一的 `) 換行處理方式,因此指定 ``newline=''`` " -"會永遠是安全的。" +"``\\r\\n`` 行尾 (line ending) 的平台會寫入額外的 ``\\r``。自從 csv 模組有自" +"己 (:term:`統一的 `) 換行處理方式,因此指定 " +"``newline=''`` 會永遠是安全的。" #: ../../library/csv.rst:11 msgid "csv" diff --git a/library/ctypes.po b/library/ctypes.po index 484f953dee9..4c5f26f403b 100644 --- a/library/ctypes.po +++ b/library/ctypes.po @@ -1,12 +1,12 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-07-20 00:19+0000\n" +"POT-Creation-Date: 2025-11-10 16:45+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-" @@ -33,18 +33,26 @@ msgid "" "libraries. It can be used to wrap these libraries in pure Python." msgstr "" -#: ../../library/ctypes.rst:21 +#: ../../includes/optional-module.rst:1 +msgid "" +"This is an :term:`optional module`. If it is missing from your copy of " +"CPython, look for documentation from your distributor (that is, whoever " +"provided Python to you). If you are the distributor, see :ref:`optional-" +"module-requirements`." +msgstr "" + +#: ../../library/ctypes.rst:23 msgid "ctypes tutorial" msgstr "ctypes 教學" -#: ../../library/ctypes.rst:23 +#: ../../library/ctypes.rst:25 msgid "" "Note: The code samples in this tutorial use :mod:`doctest` to make sure that " "they actually work. Since some code samples behave differently under Linux, " "Windows, or macOS, they contain doctest directives in comments." msgstr "" -#: ../../library/ctypes.rst:27 +#: ../../library/ctypes.rst:29 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:" @@ -52,17 +60,17 @@ msgid "" "you would expect :class:`c_int` --- they are actually the same type." msgstr "" -#: ../../library/ctypes.rst:35 +#: ../../library/ctypes.rst:37 msgid "Loading dynamic link libraries" msgstr "" -#: ../../library/ctypes.rst:37 +#: ../../library/ctypes.rst:39 msgid "" ":mod:`ctypes` exports the *cdll*, and on Windows *windll* and *oledll* " "objects, for loading dynamic link libraries." msgstr "" -#: ../../library/ctypes.rst:40 +#: ../../library/ctypes.rst:42 msgid "" "You load libraries by accessing them as attributes of these objects. *cdll* " "loads libraries which export functions using the standard ``cdecl`` calling " @@ -73,20 +81,20 @@ msgid "" "when the function call fails." msgstr "" -#: ../../library/ctypes.rst:48 +#: ../../library/ctypes.rst:50 msgid "" "Windows errors used to raise :exc:`WindowsError`, which is now an alias of :" "exc:`OSError`." msgstr "" -#: ../../library/ctypes.rst:53 +#: ../../library/ctypes.rst:55 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:57 +#: ../../library/ctypes.rst:59 msgid "" ">>> from ctypes import *\n" ">>> print(windll.kernel32)\n" @@ -104,11 +112,11 @@ msgstr "" ">>> libc = cdll.msvcrt\n" ">>>" -#: ../../library/ctypes.rst:65 +#: ../../library/ctypes.rst:67 msgid "Windows appends the usual ``.dll`` file suffix automatically." msgstr "" -#: ../../library/ctypes.rst:68 +#: ../../library/ctypes.rst:70 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 " @@ -116,7 +124,7 @@ msgid "" "import and use the ``msvcrt`` module." msgstr "" -#: ../../library/ctypes.rst:73 +#: ../../library/ctypes.rst:75 msgid "" "On Linux, it is required to specify the filename *including* the extension " "to load a library, so attribute access can not be used to load libraries. " @@ -125,7 +133,7 @@ msgid "" "CDLL by calling the constructor::" msgstr "" -#: ../../library/ctypes.rst:79 +#: ../../library/ctypes.rst:81 msgid "" ">>> cdll.LoadLibrary(\"libc.so.6\")\n" "\n" @@ -141,15 +149,15 @@ msgstr "" "\n" ">>>" -#: ../../library/ctypes.rst:92 +#: ../../library/ctypes.rst:94 msgid "Accessing functions from loaded dlls" msgstr "" -#: ../../library/ctypes.rst:94 +#: ../../library/ctypes.rst:96 msgid "Functions are accessed as attributes of dll objects::" msgstr "" -#: ../../library/ctypes.rst:96 +#: ../../library/ctypes.rst:98 msgid "" ">>> libc.printf\n" "<_FuncPtr object at 0x...>\n" @@ -175,7 +183,7 @@ msgstr "" "AttributeError: function 'MyOwnFunction' not found\n" ">>>" -#: ../../library/ctypes.rst:108 +#: ../../library/ctypes.rst:110 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 " @@ -186,7 +194,7 @@ msgid "" "``GetModuleHandle`` depending on whether UNICODE is defined or not::" msgstr "" -#: ../../library/ctypes.rst:116 +#: ../../library/ctypes.rst:118 msgid "" "/* ANSI version */\n" "HMODULE GetModuleHandleA(LPCSTR lpModuleName);\n" @@ -198,21 +206,21 @@ msgstr "" "/* UNICODE 版本 */\n" "HMODULE GetModuleHandleW(LPCWSTR lpModuleName);" -#: ../../library/ctypes.rst:121 +#: ../../library/ctypes.rst:123 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:125 +#: ../../library/ctypes.rst:127 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:129 +#: ../../library/ctypes.rst:131 msgid "" ">>> getattr(cdll.msvcrt, \"??2@YAPAXI@Z\")\n" "<_FuncPtr object at 0x...>\n" @@ -222,14 +230,14 @@ msgstr "" "<_FuncPtr object at 0x...>\n" ">>>" -#: ../../library/ctypes.rst:133 +#: ../../library/ctypes.rst:135 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:136 +#: ../../library/ctypes.rst:138 msgid "" ">>> cdll.kernel32[1]\n" "<_FuncPtr object at 0x...>\n" @@ -251,18 +259,18 @@ msgstr "" "AttributeError: function ordinal 0 not found\n" ">>>" -#: ../../library/ctypes.rst:150 +#: ../../library/ctypes.rst:152 msgid "Calling functions" msgstr "呼叫函式" -#: ../../library/ctypes.rst:152 +#: ../../library/ctypes.rst:154 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:155 +#: ../../library/ctypes.rst:157 msgid "" ">>> print(libc.rand())\n" "1804289383" @@ -270,14 +278,14 @@ msgstr "" ">>> print(libc.rand())\n" "1804289383" -#: ../../library/ctypes.rst:158 +#: ../../library/ctypes.rst:160 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:161 +#: ../../library/ctypes.rst:163 msgid "" ">>> print(hex(windll.kernel32.GetModuleHandleA(None)))\n" "0x1d000000\n" @@ -287,13 +295,13 @@ msgstr "" "0x1d000000\n" ">>>" -#: ../../library/ctypes.rst:165 +#: ../../library/ctypes.rst:167 msgid "" ":exc:`ValueError` is raised when you call an ``stdcall`` function with the " "``cdecl`` calling convention, or vice versa::" msgstr "" -#: ../../library/ctypes.rst:168 +#: ../../library/ctypes.rst:170 msgid "" ">>> cdll.kernel32.GetModuleHandleA(None)\n" "Traceback (most recent call last):\n" @@ -323,20 +331,20 @@ msgstr "" "excess)\n" ">>>" -#: ../../library/ctypes.rst:180 +#: ../../library/ctypes.rst:182 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:183 +#: ../../library/ctypes.rst:185 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:187 +#: ../../library/ctypes.rst:189 msgid "" ">>> windll.kernel32.GetModuleHandleA(32)\n" "Traceback (most recent call last):\n" @@ -350,7 +358,7 @@ msgstr "" "OSError: exception: access violation reading 0x00000020\n" ">>>" -#: ../../library/ctypes.rst:193 +#: ../../library/ctypes.rst:195 msgid "" "There are, however, enough ways to crash Python with :mod:`ctypes`, so you " "should be careful anyway. The :mod:`faulthandler` module can be helpful in " @@ -358,7 +366,7 @@ msgid "" "library calls)." msgstr "" -#: ../../library/ctypes.rst:198 +#: ../../library/ctypes.rst:200 msgid "" "``None``, integers, bytes objects and (unicode) strings are the only native " "Python objects that can directly be used as parameters in these function " @@ -369,322 +377,358 @@ msgid "" "the C type." msgstr "" -#: ../../library/ctypes.rst:205 +#: ../../library/ctypes.rst:207 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:212 ../../library/ctypes.rst:2278 +#: ../../library/ctypes.rst:214 ../../library/ctypes.rst:2428 msgid "Fundamental data types" msgstr "" -#: ../../library/ctypes.rst:214 +#: ../../library/ctypes.rst:216 msgid ":mod:`ctypes` defines a number of primitive C compatible data types:" msgstr "" -#: ../../library/ctypes.rst:217 +#: ../../library/ctypes.rst:219 ../../library/ctypes.rst:291 msgid "ctypes type" msgstr "ctypes 型別" -#: ../../library/ctypes.rst:217 +#: ../../library/ctypes.rst:219 ../../library/ctypes.rst:291 msgid "C type" msgstr "C 型別" -#: ../../library/ctypes.rst:217 +#: ../../library/ctypes.rst:219 ../../library/ctypes.rst:291 msgid "Python type" msgstr "Python 型別" -#: ../../library/ctypes.rst:219 +#: ../../library/ctypes.rst:221 msgid ":class:`c_bool`" msgstr ":class:`c_bool`" -#: ../../library/ctypes.rst:219 +#: ../../library/ctypes.rst:221 msgid ":c:expr:`_Bool`" msgstr ":c:expr:`_Bool`" -#: ../../library/ctypes.rst:219 +#: ../../library/ctypes.rst:221 msgid "bool (1)" msgstr "bool (1)" -#: ../../library/ctypes.rst:221 +#: ../../library/ctypes.rst:223 msgid ":class:`c_char`" msgstr ":class:`c_char`" -#: ../../library/ctypes.rst:221 ../../library/ctypes.rst:225 +#: ../../library/ctypes.rst:223 ../../library/ctypes.rst:227 msgid ":c:expr:`char`" msgstr ":c:expr:`char`" -#: ../../library/ctypes.rst:221 +#: ../../library/ctypes.rst:223 msgid "1-character bytes object" msgstr "" -#: ../../library/ctypes.rst:223 +#: ../../library/ctypes.rst:225 msgid ":class:`c_wchar`" msgstr ":class:`c_wchar`" -#: ../../library/ctypes.rst:223 +#: ../../library/ctypes.rst:225 msgid ":c:type:`wchar_t`" msgstr ":c:type:`wchar_t`" -#: ../../library/ctypes.rst:223 +#: ../../library/ctypes.rst:225 msgid "1-character string" msgstr "" -#: ../../library/ctypes.rst:225 +#: ../../library/ctypes.rst:227 msgid ":class:`c_byte`" msgstr ":class:`c_byte`" -#: ../../library/ctypes.rst:225 ../../library/ctypes.rst:227 -#: ../../library/ctypes.rst:229 ../../library/ctypes.rst:231 -#: ../../library/ctypes.rst:233 ../../library/ctypes.rst:235 -#: ../../library/ctypes.rst:237 ../../library/ctypes.rst:239 -#: ../../library/ctypes.rst:241 ../../library/ctypes.rst:243 -#: ../../library/ctypes.rst:245 ../../library/ctypes.rst:247 -#: ../../library/ctypes.rst:249 ../../library/ctypes.rst:251 -#: ../../library/ctypes.rst:253 ../../library/ctypes.rst:255 -#: ../../library/ctypes.rst:257 ../../library/ctypes.rst:259 -#: ../../library/ctypes.rst:262 ../../library/ctypes.rst:264 -#: ../../library/ctypes.rst:267 +#: ../../library/ctypes.rst:227 ../../library/ctypes.rst:229 +#: ../../library/ctypes.rst:231 ../../library/ctypes.rst:233 +#: ../../library/ctypes.rst:235 ../../library/ctypes.rst:237 +#: ../../library/ctypes.rst:239 ../../library/ctypes.rst:241 +#: ../../library/ctypes.rst:243 ../../library/ctypes.rst:245 +#: ../../library/ctypes.rst:247 ../../library/ctypes.rst:249 +#: ../../library/ctypes.rst:251 ../../library/ctypes.rst:253 +#: ../../library/ctypes.rst:255 ../../library/ctypes.rst:257 +#: ../../library/ctypes.rst:259 ../../library/ctypes.rst:261 +#: ../../library/ctypes.rst:264 ../../library/ctypes.rst:266 +#: ../../library/ctypes.rst:269 msgid "int" msgstr "int" -#: ../../library/ctypes.rst:227 +#: ../../library/ctypes.rst:229 msgid ":class:`c_ubyte`" msgstr ":class:`c_ubyte`" -#: ../../library/ctypes.rst:227 +#: ../../library/ctypes.rst:229 msgid ":c:expr:`unsigned char`" msgstr ":c:expr:`unsigned char`" -#: ../../library/ctypes.rst:229 +#: ../../library/ctypes.rst:231 msgid ":class:`c_short`" msgstr ":class:`c_short`" -#: ../../library/ctypes.rst:229 +#: ../../library/ctypes.rst:231 msgid ":c:expr:`short`" msgstr ":c:expr:`short`" -#: ../../library/ctypes.rst:231 +#: ../../library/ctypes.rst:233 msgid ":class:`c_ushort`" msgstr ":class:`c_ushort`" -#: ../../library/ctypes.rst:231 +#: ../../library/ctypes.rst:233 msgid ":c:expr:`unsigned short`" msgstr ":c:expr:`unsigned short`" -#: ../../library/ctypes.rst:233 +#: ../../library/ctypes.rst:235 msgid ":class:`c_int`" msgstr ":class:`c_int`" -#: ../../library/ctypes.rst:233 +#: ../../library/ctypes.rst:235 msgid ":c:expr:`int`" msgstr ":c:expr:`int`" -#: ../../library/ctypes.rst:235 +#: ../../library/ctypes.rst:237 msgid ":class:`c_int8`" msgstr ":class:`c_int8`" -#: ../../library/ctypes.rst:235 +#: ../../library/ctypes.rst:237 msgid ":c:type:`int8_t`" msgstr ":c:type:`int8_t`" -#: ../../library/ctypes.rst:237 +#: ../../library/ctypes.rst:239 msgid ":class:`c_int16`" msgstr ":class:`c_int16`" -#: ../../library/ctypes.rst:237 +#: ../../library/ctypes.rst:239 msgid ":c:type:`int16_t`" msgstr ":c:type:`int16_t`" -#: ../../library/ctypes.rst:239 +#: ../../library/ctypes.rst:241 msgid ":class:`c_int32`" msgstr ":class:`c_int32`" -#: ../../library/ctypes.rst:239 +#: ../../library/ctypes.rst:241 msgid ":c:type:`int32_t`" msgstr ":c:type:`int32_t`" -#: ../../library/ctypes.rst:241 +#: ../../library/ctypes.rst:243 msgid ":class:`c_int64`" msgstr ":class:`c_int64`" -#: ../../library/ctypes.rst:241 +#: ../../library/ctypes.rst:243 msgid ":c:type:`int64_t`" msgstr ":c:type:`int64_t`" -#: ../../library/ctypes.rst:243 +#: ../../library/ctypes.rst:245 msgid ":class:`c_uint`" msgstr ":class:`c_uint`" -#: ../../library/ctypes.rst:243 +#: ../../library/ctypes.rst:245 msgid ":c:expr:`unsigned int`" msgstr ":c:expr:`unsigned int`" -#: ../../library/ctypes.rst:245 +#: ../../library/ctypes.rst:247 msgid ":class:`c_uint8`" msgstr ":class:`c_uint8`" -#: ../../library/ctypes.rst:245 +#: ../../library/ctypes.rst:247 msgid ":c:type:`uint8_t`" msgstr ":c:type:`uint8_t`" -#: ../../library/ctypes.rst:247 +#: ../../library/ctypes.rst:249 msgid ":class:`c_uint16`" msgstr ":class:`c_uint16`" -#: ../../library/ctypes.rst:247 +#: ../../library/ctypes.rst:249 msgid ":c:type:`uint16_t`" msgstr ":c:type:`uint16_t`" -#: ../../library/ctypes.rst:249 +#: ../../library/ctypes.rst:251 msgid ":class:`c_uint32`" msgstr ":class:`c_uint32`" -#: ../../library/ctypes.rst:249 +#: ../../library/ctypes.rst:251 msgid ":c:type:`uint32_t`" msgstr ":c:type:`uint32_t`" -#: ../../library/ctypes.rst:251 +#: ../../library/ctypes.rst:253 msgid ":class:`c_uint64`" msgstr ":class:`c_uint64`" -#: ../../library/ctypes.rst:251 +#: ../../library/ctypes.rst:253 msgid ":c:type:`uint64_t`" msgstr ":c:type:`uint64_t`" -#: ../../library/ctypes.rst:253 +#: ../../library/ctypes.rst:255 msgid ":class:`c_long`" msgstr ":class:`c_long`" -#: ../../library/ctypes.rst:253 +#: ../../library/ctypes.rst:255 msgid ":c:expr:`long`" msgstr ":c:expr:`long`" -#: ../../library/ctypes.rst:255 +#: ../../library/ctypes.rst:257 msgid ":class:`c_ulong`" msgstr ":class:`c_ulong`" -#: ../../library/ctypes.rst:255 +#: ../../library/ctypes.rst:257 msgid ":c:expr:`unsigned long`" msgstr ":c:expr:`unsigned long`" -#: ../../library/ctypes.rst:257 +#: ../../library/ctypes.rst:259 msgid ":class:`c_longlong`" msgstr ":class:`c_longlong`" -#: ../../library/ctypes.rst:257 +#: ../../library/ctypes.rst:259 msgid ":c:expr:`__int64` or :c:expr:`long long`" msgstr ":c:expr:`__int64` 或 :c:expr:`long long`" -#: ../../library/ctypes.rst:259 +#: ../../library/ctypes.rst:261 msgid ":class:`c_ulonglong`" msgstr ":class:`c_ulonglong`" -#: ../../library/ctypes.rst:259 +#: ../../library/ctypes.rst:261 msgid ":c:expr:`unsigned __int64` or :c:expr:`unsigned long long`" msgstr ":c:expr:`unsigned __int64` 或 :c:expr:`unsigned long long`" -#: ../../library/ctypes.rst:262 +#: ../../library/ctypes.rst:264 msgid ":class:`c_size_t`" msgstr ":class:`c_size_t`" -#: ../../library/ctypes.rst:262 +#: ../../library/ctypes.rst:264 msgid ":c:type:`size_t`" msgstr ":c:type:`size_t`" -#: ../../library/ctypes.rst:264 +#: ../../library/ctypes.rst:266 msgid ":class:`c_ssize_t`" msgstr ":class:`c_ssize_t`" -#: ../../library/ctypes.rst:264 +#: ../../library/ctypes.rst:266 msgid ":c:type:`ssize_t` or :c:expr:`Py_ssize_t`" msgstr ":c:type:`ssize_t` 或 :c:expr:`Py_ssize_t`" -#: ../../library/ctypes.rst:267 +#: ../../library/ctypes.rst:269 msgid ":class:`c_time_t`" msgstr ":class:`c_time_t`" -#: ../../library/ctypes.rst:267 +#: ../../library/ctypes.rst:269 msgid ":c:type:`time_t`" msgstr ":c:type:`time_t`" -#: ../../library/ctypes.rst:269 +#: ../../library/ctypes.rst:271 msgid ":class:`c_float`" msgstr ":class:`c_float`" -#: ../../library/ctypes.rst:269 +#: ../../library/ctypes.rst:271 msgid ":c:expr:`float`" msgstr ":c:expr:`float`" -#: ../../library/ctypes.rst:269 ../../library/ctypes.rst:271 -#: ../../library/ctypes.rst:273 +#: ../../library/ctypes.rst:271 ../../library/ctypes.rst:273 +#: ../../library/ctypes.rst:275 msgid "float" msgstr "float" -#: ../../library/ctypes.rst:271 +#: ../../library/ctypes.rst:273 msgid ":class:`c_double`" msgstr ":class:`c_double`" -#: ../../library/ctypes.rst:271 +#: ../../library/ctypes.rst:273 msgid ":c:expr:`double`" msgstr ":c:expr:`double`" -#: ../../library/ctypes.rst:273 +#: ../../library/ctypes.rst:275 msgid ":class:`c_longdouble`" msgstr ":class:`c_longdouble`" -#: ../../library/ctypes.rst:273 +#: ../../library/ctypes.rst:275 msgid ":c:expr:`long double`" msgstr ":c:expr:`long double`" -#: ../../library/ctypes.rst:275 +#: ../../library/ctypes.rst:277 msgid ":class:`c_char_p`" msgstr ":class:`c_char_p`" -#: ../../library/ctypes.rst:275 +#: ../../library/ctypes.rst:277 msgid ":c:expr:`char *` (NUL terminated)" msgstr "" -#: ../../library/ctypes.rst:275 +#: ../../library/ctypes.rst:277 msgid "bytes object or ``None``" msgstr "位元組物件或 ``None``" -#: ../../library/ctypes.rst:277 +#: ../../library/ctypes.rst:279 msgid ":class:`c_wchar_p`" msgstr ":class:`c_wchar_p`" -#: ../../library/ctypes.rst:277 +#: ../../library/ctypes.rst:279 msgid ":c:expr:`wchar_t *` (NUL terminated)" msgstr "" -#: ../../library/ctypes.rst:277 +#: ../../library/ctypes.rst:279 msgid "string or ``None``" msgstr "字串或 ``None``" -#: ../../library/ctypes.rst:279 +#: ../../library/ctypes.rst:281 msgid ":class:`c_void_p`" msgstr ":class:`c_void_p`" -#: ../../library/ctypes.rst:279 +#: ../../library/ctypes.rst:281 msgid ":c:expr:`void *`" msgstr ":c:expr:`void *`" -#: ../../library/ctypes.rst:279 +#: ../../library/ctypes.rst:281 msgid "int or ``None``" msgstr "" -#: ../../library/ctypes.rst:283 +#: ../../library/ctypes.rst:285 msgid "The constructor accepts any object with a truth value." msgstr "" -#: ../../library/ctypes.rst:285 +#: ../../library/ctypes.rst:287 +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:293 +msgid ":class:`c_float_complex`" +msgstr ":class:`c_float_complex`" + +#: ../../library/ctypes.rst:293 +msgid ":c:expr:`float complex`" +msgstr ":c:expr:`float complex`" + +#: ../../library/ctypes.rst:293 ../../library/ctypes.rst:295 +#: ../../library/ctypes.rst:297 +msgid "complex" +msgstr "" + +#: ../../library/ctypes.rst:295 +msgid ":class:`c_double_complex`" +msgstr ":class:`c_double_complex`" + +#: ../../library/ctypes.rst:295 +msgid ":c:expr:`double complex`" +msgstr ":c:expr:`double complex`" + +#: ../../library/ctypes.rst:297 +msgid ":class:`c_longdouble_complex`" +msgstr ":class:`c_longdouble_complex`" + +#: ../../library/ctypes.rst:297 +msgid ":c:expr:`long double complex`" +msgstr ":c:expr:`long double complex`" + +#: ../../library/ctypes.rst:301 msgid "" "All these types can be created by calling them with an optional initializer " "of the correct type and value::" msgstr "" -#: ../../library/ctypes.rst:288 +#: ../../library/ctypes.rst:304 msgid "" ">>> c_int()\n" "c_long(0)\n" @@ -702,12 +746,12 @@ msgstr "" "c_ushort(65533)\n" ">>>" -#: ../../library/ctypes.rst:296 +#: ../../library/ctypes.rst:312 msgid "" "Since these types are mutable, their value can also be changed afterwards::" msgstr "" -#: ../../library/ctypes.rst:298 +#: ../../library/ctypes.rst:314 msgid "" ">>> i = c_int(42)\n" ">>> print(i)\n" @@ -729,7 +773,7 @@ msgstr "" "-99\n" ">>>" -#: ../../library/ctypes.rst:308 +#: ../../library/ctypes.rst:324 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 " @@ -737,7 +781,7 @@ msgid "" "Python string objects are immutable)::" msgstr "" -#: ../../library/ctypes.rst:313 +#: ../../library/ctypes.rst:329 msgid "" ">>> s = \"Hello, World\"\n" ">>> c_s = c_wchar_p(s)\n" @@ -769,7 +813,7 @@ msgstr "" "Hello, World\n" ">>>" -#: ../../library/ctypes.rst:328 +#: ../../library/ctypes.rst:344 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 :" @@ -779,7 +823,7 @@ msgid "" "``value`` property::" msgstr "" -#: ../../library/ctypes.rst:335 +#: ../../library/ctypes.rst:351 msgid "" ">>> from ctypes import *\n" ">>> p = create_string_buffer(3) # create a 3 byte buffer, " @@ -801,7 +845,7 @@ msgid "" ">>>" msgstr "" -#: ../../library/ctypes.rst:352 +#: ../../library/ctypes.rst:368 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 " @@ -809,18 +853,18 @@ msgid "" "the :func:`create_unicode_buffer` function." msgstr "" -#: ../../library/ctypes.rst:361 +#: ../../library/ctypes.rst:377 msgid "Calling functions, continued" msgstr "" -#: ../../library/ctypes.rst:363 +#: ../../library/ctypes.rst:379 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:367 +#: ../../library/ctypes.rst:383 msgid "" ">>> printf = libc.printf\n" ">>> printf(b\"Hello, %s\\n\", b\"World!\")\n" @@ -856,14 +900,14 @@ msgstr "" "parameter 2\n" ">>>" -#: ../../library/ctypes.rst:383 +#: ../../library/ctypes.rst:399 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:387 +#: ../../library/ctypes.rst:403 msgid "" ">>> printf(b\"An int %d, a double %f\\n\", 1234, c_double(3.14))\n" "An int 1234, a double 3.140000\n" @@ -875,11 +919,11 @@ msgstr "" "31\n" ">>>" -#: ../../library/ctypes.rst:395 +#: ../../library/ctypes.rst:411 msgid "Calling variadic functions" msgstr "" -#: ../../library/ctypes.rst:397 +#: ../../library/ctypes.rst:413 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 " @@ -888,27 +932,27 @@ msgid "" "functions." msgstr "" -#: ../../library/ctypes.rst:402 +#: ../../library/ctypes.rst:418 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:405 +#: ../../library/ctypes.rst:421 msgid "libc.printf.argtypes = [ctypes.c_char_p]" msgstr "libc.printf.argtypes = [ctypes.c_char_p]" -#: ../../library/ctypes.rst:409 +#: ../../library/ctypes.rst:425 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:416 +#: ../../library/ctypes.rst:432 msgid "Calling functions with your own custom data types" msgstr "" -#: ../../library/ctypes.rst:418 +#: ../../library/ctypes.rst:434 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 " @@ -917,7 +961,7 @@ msgid "" "or an object with an :attr:`!_as_parameter_` attribute::" msgstr "" -#: ../../library/ctypes.rst:424 +#: ../../library/ctypes.rst:440 msgid "" ">>> class Bottles:\n" "... def __init__(self, number):\n" @@ -939,24 +983,24 @@ msgstr "" "19\n" ">>>" -#: ../../library/ctypes.rst:434 +#: ../../library/ctypes.rst:450 msgid "" "If you don't want to store the instance's data in the :attr:`!" "_as_parameter_` instance variable, you could define a :class:`property` " "which makes the attribute available on request." msgstr "" -#: ../../library/ctypes.rst:442 +#: ../../library/ctypes.rst:458 msgid "Specifying the required argument types (function prototypes)" msgstr "" -#: ../../library/ctypes.rst:444 +#: ../../library/ctypes.rst:460 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:447 +#: ../../library/ctypes.rst:463 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 " @@ -965,7 +1009,7 @@ msgid "" "feature)::" msgstr "" -#: ../../library/ctypes.rst:452 +#: ../../library/ctypes.rst:468 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" @@ -979,14 +1023,14 @@ msgstr "" "37\n" ">>>" -#: ../../library/ctypes.rst:458 +#: ../../library/ctypes.rst:474 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:461 +#: ../../library/ctypes.rst:477 msgid "" ">>> printf(b\"%d %d %d\", 1, 2, 3)\n" "Traceback (most recent call last):\n" @@ -1008,7 +1052,7 @@ msgstr "" "13\n" ">>>" -#: ../../library/ctypes.rst:470 +#: ../../library/ctypes.rst:486 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 " @@ -1022,43 +1066,43 @@ msgid "" "_as_parameter_` attribute." msgstr "" -#: ../../library/ctypes.rst:484 +#: ../../library/ctypes.rst:500 msgid "Return types" msgstr "" -#: ../../library/ctypes.rst:494 +#: ../../library/ctypes.rst:510 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:498 +#: ../../library/ctypes.rst:514 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:502 +#: ../../library/ctypes.rst:518 msgid ">>> libc.time.restype = c_time_t" msgstr ">>> libc.time.restype = c_time_t" -#: ../../library/ctypes.rst:504 +#: ../../library/ctypes.rst:520 msgid "The argument types can be specified using :attr:`~_CFuncPtr.argtypes`::" msgstr "" -#: ../../library/ctypes.rst:506 +#: ../../library/ctypes.rst:522 msgid ">>> libc.time.argtypes = (POINTER(c_time_t),)" msgstr ">>> libc.time.argtypes = (POINTER(c_time_t),)" -#: ../../library/ctypes.rst:508 +#: ../../library/ctypes.rst:524 msgid "" "To call the function with a ``NULL`` pointer as first argument, use " "``None``::" msgstr "" -#: ../../library/ctypes.rst:510 +#: ../../library/ctypes.rst:526 msgid "" ">>> print(libc.time(None))\n" "1150640792" @@ -1066,13 +1110,13 @@ msgstr "" ">>> print(libc.time(None))\n" "1150640792" -#: ../../library/ctypes.rst:513 +#: ../../library/ctypes.rst:529 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:516 +#: ../../library/ctypes.rst:532 msgid "" ">>> strchr = libc.strchr\n" ">>> strchr(b\"abcdef\", ord(\"d\"))\n" @@ -1094,14 +1138,14 @@ msgstr "" "None\n" ">>>" -#: ../../library/ctypes.rst:526 +#: ../../library/ctypes.rst:542 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:530 +#: ../../library/ctypes.rst:546 msgid "" ">>> strchr.restype = c_char_p\n" ">>> strchr.argtypes = [c_char_p, c_char]\n" @@ -1131,7 +1175,7 @@ msgstr "" "b'def'\n" ">>>" -#: ../../library/ctypes.rst:545 +#: ../../library/ctypes.rst:561 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 " @@ -1141,7 +1185,7 @@ msgid "" "values and automatically raise an exception::" msgstr "" -#: ../../library/ctypes.rst:551 +#: ../../library/ctypes.rst:567 msgid "" ">>> GetModuleHandle = windll.kernel32.GetModuleHandleA\n" ">>> def ValidHandle(value):\n" @@ -1177,7 +1221,7 @@ msgstr "" "OSError: [Errno 126] The specified module could not be found.\n" ">>>" -#: ../../library/ctypes.rst:568 +#: ../../library/ctypes.rst:584 msgid "" "``WinError`` is a function which will call Windows ``FormatMessage()`` api " "to get the string representation of an error code, and *returns* an " @@ -1185,18 +1229,18 @@ msgid "" "used, it calls :func:`GetLastError` to retrieve it." msgstr "" -#: ../../library/ctypes.rst:573 +#: ../../library/ctypes.rst:589 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:581 +#: ../../library/ctypes.rst:597 msgid "Passing pointers (or: passing parameters by reference)" msgstr "" -#: ../../library/ctypes.rst:583 +#: ../../library/ctypes.rst:599 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 " @@ -1204,7 +1248,7 @@ msgid "" "reference*." msgstr "" -#: ../../library/ctypes.rst:587 +#: ../../library/ctypes.rst:603 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:" @@ -1213,7 +1257,7 @@ msgid "" "you don't need the pointer object in Python itself::" msgstr "" -#: ../../library/ctypes.rst:593 +#: ../../library/ctypes.rst:609 msgid "" ">>> i = c_int()\n" ">>> f = c_float()\n" @@ -1239,11 +1283,11 @@ msgstr "" "1 3.1400001049 b'Hello'\n" ">>>" -#: ../../library/ctypes.rst:609 +#: ../../library/ctypes.rst:625 msgid "Structures and unions" msgstr "" -#: ../../library/ctypes.rst:611 +#: ../../library/ctypes.rst:627 msgid "" "Structures and unions must derive from the :class:`Structure` and :class:" "`Union` base classes which are defined in the :mod:`ctypes` module. Each " @@ -1252,20 +1296,20 @@ msgid "" "*field type*." msgstr "" -#: ../../library/ctypes.rst:616 +#: ../../library/ctypes.rst:632 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:619 +#: ../../library/ctypes.rst:635 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:622 +#: ../../library/ctypes.rst:638 msgid "" ">>> from ctypes import *\n" ">>> class POINT(Structure):\n" @@ -1301,19 +1345,19 @@ msgstr "" "TypeError: too many initializers\n" ">>>" -#: ../../library/ctypes.rst:639 +#: ../../library/ctypes.rst:655 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:642 +#: ../../library/ctypes.rst:658 msgid "" "Here is a RECT structure which contains two POINTs named *upperleft* and " "*lowerright*::" msgstr "" -#: ../../library/ctypes.rst:645 +#: ../../library/ctypes.rst:661 msgid "" ">>> class RECT(Structure):\n" "... _fields_ = [(\"upperleft\", POINT),\n" @@ -1337,13 +1381,13 @@ msgstr "" "0 0\n" ">>>" -#: ../../library/ctypes.rst:656 +#: ../../library/ctypes.rst:672 msgid "" "Nested structures can also be initialized in the constructor in several " "ways::" msgstr "" -#: ../../library/ctypes.rst:658 +#: ../../library/ctypes.rst:674 msgid "" ">>> r = RECT(POINT(1, 2), POINT(3, 4))\n" ">>> r = RECT((1, 2), (3, 4))" @@ -1351,27 +1395,28 @@ msgstr "" ">>> r = RECT(POINT(1, 2), POINT(3, 4))\n" ">>> r = RECT((1, 2), (3, 4))" -#: ../../library/ctypes.rst:661 +#: ../../library/ctypes.rst:677 msgid "" "Field :term:`descriptor`\\s can be retrieved from the *class*, they are " -"useful for debugging because they can provide useful information::" +"useful for debugging because they can provide useful information. See :class:" +"`CField`::" msgstr "" -#: ../../library/ctypes.rst:664 +#: ../../library/ctypes.rst:681 msgid "" -">>> print(POINT.x)\n" -"\n" -">>> print(POINT.y)\n" -"\n" +">>> POINT.x\n" +"\n" +">>> POINT.y\n" +"\n" ">>>" msgstr "" -">>> print(POINT.x)\n" -"\n" -">>> print(POINT.y)\n" -"\n" +">>> POINT.x\n" +"\n" +">>> POINT.y\n" +"\n" ">>>" -#: ../../library/ctypes.rst:675 +#: ../../library/ctypes.rst:692 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 " @@ -1379,24 +1424,27 @@ msgid "" "structures with bit-fields should always be passed to functions by pointer." msgstr "" -#: ../../library/ctypes.rst:681 -msgid "Structure/union alignment and byte order" +#: ../../library/ctypes.rst:698 +msgid "Structure/union layout, alignment and byte order" +msgstr "" + +#: ../../library/ctypes.rst:700 +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 " +"specifying a :attr:`~Structure._layout_` class attribute in the subclass " +"definition; see the attribute documentation for details." msgstr "" -#: ../../library/ctypes.rst:683 +#: ../../library/ctypes.rst:705 msgid "" -"By default, Structure and Union fields are aligned in the same way the C " -"compiler does it. It is possible to override this behavior by specifying a :" -"attr:`~Structure._pack_` class attribute in the subclass definition. This " -"must be set to a positive integer and specifies the maximum alignment for " -"the fields. This is what ``#pragma pack(n)`` also does in MSVC. It is also " -"possible to set a minimum alignment for how the subclass itself is packed in " -"the same way ``#pragma align(n)`` works in MSVC. This can be achieved by " -"specifying a :attr:`~Structure._align_` class attribute in the subclass " -"definition." +"It is possible to specify the maximum alignment for the fields and/or for " +"the structure itself by setting the class attributes :attr:`~Structure." +"_pack_` and/or :attr:`~Structure._align_`, respectively. See the attribute " +"documentation for details." msgstr "" -#: ../../library/ctypes.rst:693 +#: ../../library/ctypes.rst:710 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:" @@ -1405,66 +1453,73 @@ msgid "" "classes cannot contain pointer fields." msgstr "" -#: ../../library/ctypes.rst:703 +#: ../../library/ctypes.rst:720 msgid "Bit fields in structures and unions" msgstr "" -#: ../../library/ctypes.rst:705 +#: ../../library/ctypes.rst:722 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:709 +#: ../../library/ctypes.rst:726 msgid "" ">>> class Int(Structure):\n" "... _fields_ = [(\"first_16\", c_int, 16),\n" "... (\"second_16\", c_int, 16)]\n" "...\n" ">>> print(Int.first_16)\n" -"\n" +"\n" ">>> print(Int.second_16)\n" -"\n" -">>>" +"" msgstr "" ">>> class Int(Structure):\n" "... _fields_ = [(\"first_16\", c_int, 16),\n" "... (\"second_16\", c_int, 16)]\n" "...\n" ">>> print(Int.first_16)\n" -"\n" +"\n" ">>> print(Int.second_16)\n" -"\n" -">>>" +"" + +#: ../../library/ctypes.rst:735 +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 " +"default, Python will attempt to match the behavior of a \"native\" compiler " +"for the current platform. See the :attr:`~Structure._layout_` attribute for " +"details on the default behavior and how to change it." +msgstr "" -#: ../../library/ctypes.rst:723 +#: ../../library/ctypes.rst:746 msgid "Arrays" msgstr "" -#: ../../library/ctypes.rst:725 +#: ../../library/ctypes.rst:748 msgid "" "Arrays are sequences, containing a fixed number of instances of the same " "type." msgstr "" -#: ../../library/ctypes.rst:727 +#: ../../library/ctypes.rst:750 msgid "" "The recommended way to create array types is by multiplying a data type with " "a positive integer::" msgstr "" -#: ../../library/ctypes.rst:730 +#: ../../library/ctypes.rst:753 msgid "TenPointsArrayType = POINT * 10" msgstr "" -#: ../../library/ctypes.rst:732 +#: ../../library/ctypes.rst:755 msgid "" "Here is an example of a somewhat artificial data type, a structure " "containing 4 POINTs among other stuff::" msgstr "" -#: ../../library/ctypes.rst:735 +#: ../../library/ctypes.rst:758 msgid "" ">>> from ctypes import *\n" ">>> class POINT(Structure):\n" @@ -1492,11 +1547,11 @@ msgstr "" "4\n" ">>>" -#: ../../library/ctypes.rst:748 +#: ../../library/ctypes.rst:771 msgid "Instances are created in the usual way, by calling the class::" msgstr "" -#: ../../library/ctypes.rst:750 +#: ../../library/ctypes.rst:773 msgid "" "arr = TenPointsArrayType()\n" "for pt in arr:\n" @@ -1506,17 +1561,17 @@ msgstr "" "for pt in arr:\n" " print(pt.x, pt.y)" -#: ../../library/ctypes.rst:754 +#: ../../library/ctypes.rst:777 msgid "" "The above code print a series of ``0 0`` lines, because the array contents " "is initialized to zeros." msgstr "" -#: ../../library/ctypes.rst:757 +#: ../../library/ctypes.rst:780 msgid "Initializers of the correct type can also be specified::" msgstr "" -#: ../../library/ctypes.rst:759 +#: ../../library/ctypes.rst:782 msgid "" ">>> from ctypes import *\n" ">>> TenIntegers = c_int * 10\n" @@ -1538,17 +1593,17 @@ msgstr "" "1 2 3 4 5 6 7 8 9 10\n" ">>>" -#: ../../library/ctypes.rst:773 +#: ../../library/ctypes.rst:796 msgid "Pointers" msgstr "指標" -#: ../../library/ctypes.rst:775 +#: ../../library/ctypes.rst:798 msgid "" "Pointer instances are created by calling the :func:`pointer` function on a :" "mod:`ctypes` type::" msgstr "" -#: ../../library/ctypes.rst:778 +#: ../../library/ctypes.rst:801 msgid "" ">>> from ctypes import *\n" ">>> i = c_int(42)\n" @@ -1560,13 +1615,13 @@ msgstr "" ">>> pi = pointer(i)\n" ">>>" -#: ../../library/ctypes.rst:783 +#: ../../library/ctypes.rst:806 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:786 +#: ../../library/ctypes.rst:809 msgid "" ">>> pi.contents\n" "c_long(42)\n" @@ -1576,13 +1631,13 @@ msgstr "" "c_long(42)\n" ">>>" -#: ../../library/ctypes.rst:790 +#: ../../library/ctypes.rst:813 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:793 +#: ../../library/ctypes.rst:816 msgid "" ">>> pi.contents is i\n" "False\n" @@ -1596,14 +1651,14 @@ msgstr "" "False\n" ">>>" -#: ../../library/ctypes.rst:799 +#: ../../library/ctypes.rst:822 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:802 +#: ../../library/ctypes.rst:825 msgid "" ">>> i = c_int(99)\n" ">>> pi.contents = i\n" @@ -1617,11 +1672,11 @@ msgstr "" "c_long(99)\n" ">>>" -#: ../../library/ctypes.rst:811 +#: ../../library/ctypes.rst:834 msgid "Pointer instances can also be indexed with integers::" msgstr "" -#: ../../library/ctypes.rst:813 +#: ../../library/ctypes.rst:836 msgid "" ">>> pi[0]\n" "99\n" @@ -1631,11 +1686,11 @@ msgstr "" "99\n" ">>>" -#: ../../library/ctypes.rst:817 +#: ../../library/ctypes.rst:840 msgid "Assigning to an integer index changes the pointed to value::" msgstr "" -#: ../../library/ctypes.rst:819 +#: ../../library/ctypes.rst:842 msgid "" ">>> print(i)\n" "c_long(99)\n" @@ -1651,7 +1706,7 @@ msgstr "" "c_long(22)\n" ">>>" -#: ../../library/ctypes.rst:826 +#: ../../library/ctypes.rst:849 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 " @@ -1660,7 +1715,7 @@ msgid "" "instead of a single item." msgstr "" -#: ../../library/ctypes.rst:832 +#: ../../library/ctypes.rst:855 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 " @@ -1668,7 +1723,7 @@ msgid "" "returns a new type::" msgstr "" -#: ../../library/ctypes.rst:837 +#: ../../library/ctypes.rst:860 msgid "" ">>> PI = POINTER(c_int)\n" ">>> PI\n" @@ -1692,13 +1747,13 @@ msgstr "" "\n" ">>>" -#: ../../library/ctypes.rst:848 +#: ../../library/ctypes.rst:871 msgid "" "Calling the pointer type without an argument creates a ``NULL`` pointer. " "``NULL`` pointers have a ``False`` boolean value::" msgstr "" -#: ../../library/ctypes.rst:851 +#: ../../library/ctypes.rst:874 msgid "" ">>> null_ptr = POINTER(c_int)()\n" ">>> print(bool(null_ptr))\n" @@ -1710,13 +1765,13 @@ msgstr "" "False\n" ">>>" -#: ../../library/ctypes.rst:856 +#: ../../library/ctypes.rst:879 msgid "" ":mod:`ctypes` checks for ``NULL`` when dereferencing pointers (but " "dereferencing invalid non-\\ ``NULL`` pointers would crash Python)::" msgstr "" -#: ../../library/ctypes.rst:859 +#: ../../library/ctypes.rst:882 msgid "" ">>> null_ptr[0]\n" "Traceback (most recent call last):\n" @@ -1742,11 +1797,61 @@ msgstr "" "ValueError: NULL pointer access\n" ">>>" -#: ../../library/ctypes.rst:875 +#: ../../library/ctypes.rst:897 +msgid "Thread safety without the GIL" +msgstr "" + +#: ../../library/ctypes.rst:899 +msgid "" +"From Python 3.13 onward, the :term:`GIL` can be disabled on :term:`free " +"threaded ` builds. In ctypes, reads and writes to a single " +"object concurrently is safe, but not across multiple objects:" +msgstr "" + +#: ../../library/ctypes.rst:902 +msgid "" +">>> number = c_int(42)\n" +">>> pointer_a = pointer(number)\n" +">>> pointer_b = pointer(number)" +msgstr "" +">>> number = c_int(42)\n" +">>> pointer_a = pointer(number)\n" +">>> pointer_b = pointer(number)" + +#: ../../library/ctypes.rst:908 +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 " +"to across multiple threads, but only if ``pointer_b`` is not also attempting " +"to do the same. If this is an issue, consider using a :class:`threading." +"Lock` to synchronize access to memory:" +msgstr "" + +#: ../../library/ctypes.rst:913 +msgid "" +">>> import threading\n" +">>> lock = threading.Lock()\n" +">>> # Thread 1\n" +">>> with lock:\n" +"... pointer_a.contents = 24\n" +">>> # Thread 2\n" +">>> with lock:\n" +"... pointer_b.contents = 42" +msgstr "" +">>> import threading\n" +">>> lock = threading.Lock()\n" +">>> # 執行緒 1\n" +">>> with lock:\n" +"... pointer_a.contents = 24\n" +">>> # 執行緒 2\n" +">>> with lock:\n" +"... pointer_b.contents = 42" + +#: ../../library/ctypes.rst:928 msgid "Type conversions" msgstr "" -#: ../../library/ctypes.rst:877 +#: ../../library/ctypes.rst:930 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 " @@ -1757,7 +1862,7 @@ msgid "" "ctypes accepts an array of c_int::" msgstr "" -#: ../../library/ctypes.rst:884 +#: ../../library/ctypes.rst:937 msgid "" ">>> class Bar(Structure):\n" "... _fields_ = [(\"count\", c_int), (\"values\", POINTER(c_int))]\n" @@ -1787,7 +1892,7 @@ msgstr "" "3\n" ">>>" -#: ../../library/ctypes.rst:898 +#: ../../library/ctypes.rst:951 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 " @@ -1796,11 +1901,11 @@ msgid "" "automatically." msgstr "" -#: ../../library/ctypes.rst:903 +#: ../../library/ctypes.rst:956 msgid "To set a POINTER type field to ``NULL``, you can assign ``None``::" msgstr "" -#: ../../library/ctypes.rst:905 +#: ../../library/ctypes.rst:958 msgid "" ">>> bar.values = None\n" ">>>" @@ -1808,7 +1913,7 @@ msgstr "" ">>> bar.values = None\n" ">>>" -#: ../../library/ctypes.rst:910 +#: ../../library/ctypes.rst:963 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 " @@ -1817,7 +1922,7 @@ msgid "" "``values`` field, but not instances of other types::" msgstr "" -#: ../../library/ctypes.rst:916 +#: ../../library/ctypes.rst:969 msgid "" ">>> bar.values = (c_byte * 4)()\n" "Traceback (most recent call last):\n" @@ -1833,11 +1938,11 @@ msgstr "" "instance\n" ">>>" -#: ../../library/ctypes.rst:922 +#: ../../library/ctypes.rst:975 msgid "For these cases, the :func:`cast` function is handy." msgstr "" -#: ../../library/ctypes.rst:924 +#: ../../library/ctypes.rst:977 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, " @@ -1846,7 +1951,7 @@ msgid "" "references the same memory block as the first argument::" msgstr "" -#: ../../library/ctypes.rst:930 +#: ../../library/ctypes.rst:983 msgid "" ">>> a = (c_byte * 4)()\n" ">>> cast(a, POINTER(c_int))\n" @@ -1858,13 +1963,13 @@ msgstr "" "\n" ">>>" -#: ../../library/ctypes.rst:935 +#: ../../library/ctypes.rst:988 msgid "" "So, :func:`cast` can be used to assign to the ``values`` field of ``Bar`` " "the structure::" msgstr "" -#: ../../library/ctypes.rst:938 +#: ../../library/ctypes.rst:991 msgid "" ">>> bar = Bar()\n" ">>> bar.values = cast((c_byte * 4)(), POINTER(c_int))\n" @@ -1878,18 +1983,18 @@ msgstr "" "0\n" ">>>" -#: ../../library/ctypes.rst:948 +#: ../../library/ctypes.rst:1001 msgid "Incomplete Types" msgstr "" -#: ../../library/ctypes.rst:950 +#: ../../library/ctypes.rst:1003 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:954 +#: ../../library/ctypes.rst:1007 msgid "" "struct cell; /* forward declaration */\n" "\n" @@ -1899,13 +2004,13 @@ msgid "" "};" msgstr "" -#: ../../library/ctypes.rst:961 +#: ../../library/ctypes.rst:1014 msgid "" "The straightforward translation into ctypes code would be this, but it does " "not work::" msgstr "" -#: ../../library/ctypes.rst:964 +#: ../../library/ctypes.rst:1017 msgid "" ">>> class cell(Structure):\n" "... _fields_ = [(\"name\", c_char_p),\n" @@ -1927,14 +2032,14 @@ msgstr "" "NameError: name 'cell' is not defined\n" ">>>" -#: ../../library/ctypes.rst:974 +#: ../../library/ctypes.rst:1027 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:978 +#: ../../library/ctypes.rst:1031 msgid "" ">>> from ctypes import *\n" ">>> class cell(Structure):\n" @@ -1952,13 +2057,13 @@ msgstr "" "... (\"next\", POINTER(cell))]\n" ">>>" -#: ../../library/ctypes.rst:986 +#: ../../library/ctypes.rst:1039 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:989 +#: ../../library/ctypes.rst:1042 msgid "" ">>> c1 = cell()\n" ">>> c1.name = b\"foo\"\n" @@ -1988,24 +2093,24 @@ msgstr "" "foo bar foo bar foo bar foo bar\n" ">>>" -#: ../../library/ctypes.rst:1007 +#: ../../library/ctypes.rst:1060 msgid "Callback functions" msgstr "回呼函式" -#: ../../library/ctypes.rst:1009 +#: ../../library/ctypes.rst:1062 msgid "" ":mod:`ctypes` allows creating C callable function pointers from Python " "callables. These are sometimes called *callback functions*." msgstr "" -#: ../../library/ctypes.rst:1012 +#: ../../library/ctypes.rst:1065 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:1016 +#: ../../library/ctypes.rst:1069 msgid "" "The :func:`CFUNCTYPE` factory function creates types for callback functions " "using the ``cdecl`` calling convention. On Windows, the :func:`WINFUNCTYPE` " @@ -2013,21 +2118,21 @@ msgid "" "calling convention." msgstr "" -#: ../../library/ctypes.rst:1021 +#: ../../library/ctypes.rst:1074 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:1025 +#: ../../library/ctypes.rst:1078 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:1029 +#: ../../library/ctypes.rst:1082 msgid "" ">>> IntArray5 = c_int * 5\n" ">>> ia = IntArray5(5, 1, 7, 33, 99)\n" @@ -2041,7 +2146,7 @@ msgstr "" ">>> qsort.restype = None\n" ">>>" -#: ../../library/ctypes.rst:1035 +#: ../../library/ctypes.rst:1088 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 " @@ -2051,13 +2156,13 @@ msgid "" "otherwise." msgstr "" -#: ../../library/ctypes.rst:1041 +#: ../../library/ctypes.rst:1094 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:1044 +#: ../../library/ctypes.rst:1097 msgid "" ">>> CMPFUNC = CFUNCTYPE(c_int, POINTER(c_int), POINTER(c_int))\n" ">>>" @@ -2065,13 +2170,13 @@ msgstr "" ">>> CMPFUNC = CFUNCTYPE(c_int, POINTER(c_int), POINTER(c_int))\n" ">>>" -#: ../../library/ctypes.rst:1047 +#: ../../library/ctypes.rst:1100 msgid "" "To get started, here is a simple callback that shows the values it gets " "passed::" msgstr "" -#: ../../library/ctypes.rst:1050 +#: ../../library/ctypes.rst:1103 msgid "" ">>> def py_cmp_func(a, b):\n" "... print(\"py_cmp_func\", a[0], b[0])\n" @@ -2087,11 +2192,11 @@ msgstr "" ">>> cmp_func = CMPFUNC(py_cmp_func)\n" ">>>" -#: ../../library/ctypes.rst:1057 +#: ../../library/ctypes.rst:1110 msgid "The result::" msgstr "結果為: ::" -#: ../../library/ctypes.rst:1059 +#: ../../library/ctypes.rst:1112 msgid "" ">>> qsort(ia, len(ia), sizeof(c_int), cmp_func)\n" "py_cmp_func 5 1\n" @@ -2109,11 +2214,11 @@ msgstr "" "py_cmp_func 1 7\n" ">>>" -#: ../../library/ctypes.rst:1067 +#: ../../library/ctypes.rst:1120 msgid "Now we can actually compare the two items and return a useful result::" msgstr "" -#: ../../library/ctypes.rst:1069 +#: ../../library/ctypes.rst:1122 msgid "" ">>> def py_cmp_func(a, b):\n" "... print(\"py_cmp_func\", a[0], b[0])\n" @@ -2141,11 +2246,11 @@ msgstr "" "py_cmp_func 5 7\n" ">>>" -#: ../../library/ctypes.rst:1082 +#: ../../library/ctypes.rst:1135 msgid "As we can easily check, our array is sorted now::" msgstr "" -#: ../../library/ctypes.rst:1084 +#: ../../library/ctypes.rst:1137 msgid "" ">>> for i in ia: print(i, end=\" \")\n" "...\n" @@ -2157,13 +2262,13 @@ msgstr "" "1 5 7 33 99\n" ">>>" -#: ../../library/ctypes.rst:1089 +#: ../../library/ctypes.rst:1142 msgid "" "The function factories can be used as decorator factories, so we may as well " "write::" msgstr "" -#: ../../library/ctypes.rst:1092 +#: ../../library/ctypes.rst:1145 msgid "" ">>> @CFUNCTYPE(c_int, POINTER(c_int), POINTER(c_int))\n" "... def py_cmp_func(a, b):\n" @@ -2191,14 +2296,14 @@ msgstr "" "py_cmp_func 5 7\n" ">>>" -#: ../../library/ctypes.rst:1107 +#: ../../library/ctypes.rst:1160 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:1111 +#: ../../library/ctypes.rst:1164 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 " @@ -2208,25 +2313,25 @@ msgid "" "even when those calls are made from the same C thread." msgstr "" -#: ../../library/ctypes.rst:1121 +#: ../../library/ctypes.rst:1174 msgid "Accessing values exported from dlls" msgstr "" -#: ../../library/ctypes.rst:1123 +#: ../../library/ctypes.rst:1176 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:1127 +#: ../../library/ctypes.rst:1180 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:1131 +#: ../../library/ctypes.rst:1184 msgid "" ">>> version = ctypes.c_int.in_dll(ctypes.pythonapi, \"Py_Version\")\n" ">>> print(hex(version.value))\n" @@ -2236,17 +2341,17 @@ msgstr "" ">>> print(hex(version.value))\n" "0x30c00a0" -#: ../../library/ctypes.rst:1135 +#: ../../library/ctypes.rst:1188 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:1138 +#: ../../library/ctypes.rst:1191 msgid "Quoting the docs for that value:" msgstr "" -#: ../../library/ctypes.rst:1140 +#: ../../library/ctypes.rst:1193 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 " @@ -2255,13 +2360,13 @@ msgid "" "frozen modules." msgstr "" -#: ../../library/ctypes.rst:1145 +#: ../../library/ctypes.rst:1198 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:1148 +#: ../../library/ctypes.rst:1201 msgid "" ">>> from ctypes import *\n" ">>>\n" @@ -2285,13 +2390,13 @@ msgstr "" "...\n" ">>>" -#: ../../library/ctypes.rst:1159 +#: ../../library/ctypes.rst:1212 msgid "" "We have defined the :c:struct:`_frozen` data type, so we can get the pointer " "to the table::" msgstr "" -#: ../../library/ctypes.rst:1162 +#: ../../library/ctypes.rst:1215 msgid "" ">>> FrozenTable = POINTER(struct_frozen)\n" ">>> table = FrozenTable.in_dll(pythonapi, \"_PyImport_FrozenBootstrap\")\n" @@ -2301,7 +2406,7 @@ msgstr "" ">>> table = FrozenTable.in_dll(pythonapi, \"_PyImport_FrozenBootstrap\")\n" ">>>" -#: ../../library/ctypes.rst:1166 +#: ../../library/ctypes.rst:1219 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 " @@ -2310,7 +2415,7 @@ msgid "" "the loop when we hit the ``NULL`` entry::" msgstr "" -#: ../../library/ctypes.rst:1172 +#: ../../library/ctypes.rst:1225 msgid "" ">>> for item in table:\n" "... if item.name is None:\n" @@ -2332,28 +2437,28 @@ msgstr "" "zipimport 12345\n" ">>>" -#: ../../library/ctypes.rst:1182 +#: ../../library/ctypes.rst:1235 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:1190 +#: ../../library/ctypes.rst:1243 msgid "Surprises" msgstr "" -#: ../../library/ctypes.rst:1192 +#: ../../library/ctypes.rst:1245 msgid "" "There are some edges in :mod:`ctypes` where you might expect something other " "than what actually happens." msgstr "" -#: ../../library/ctypes.rst:1195 +#: ../../library/ctypes.rst:1248 msgid "Consider the following example::" msgstr "" -#: ../../library/ctypes.rst:1197 +#: ../../library/ctypes.rst:1250 msgid "" ">>> from ctypes import *\n" ">>> class POINT(Structure):\n" @@ -2391,13 +2496,13 @@ msgstr "" "3 4 3 4\n" ">>>" -#: ../../library/ctypes.rst:1215 +#: ../../library/ctypes.rst:1268 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:1218 +#: ../../library/ctypes.rst:1271 msgid "" ">>> temp0, temp1 = rc.b, rc.a\n" ">>> rc.a = temp0\n" @@ -2409,7 +2514,7 @@ msgstr "" ">>> rc.b = temp1\n" ">>>" -#: ../../library/ctypes.rst:1223 +#: ../../library/ctypes.rst:1276 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 " @@ -2418,20 +2523,20 @@ msgid "" "have the expected effect." msgstr "" -#: ../../library/ctypes.rst:1229 +#: ../../library/ctypes.rst:1282 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:1233 +#: ../../library/ctypes.rst:1286 msgid "" "Another example that may behave differently from what one would expect is " "this::" msgstr "" -#: ../../library/ctypes.rst:1235 +#: ../../library/ctypes.rst:1288 msgid "" ">>> s = c_char_p()\n" ">>> s.value = b\"abc def ghi\"\n" @@ -2449,13 +2554,13 @@ msgstr "" "False\n" ">>>" -#: ../../library/ctypes.rst:1245 +#: ../../library/ctypes.rst:1298 msgid "" "Objects instantiated from :class:`c_char_p` can only have their value set to " "bytes or integers." msgstr "" -#: ../../library/ctypes.rst:1248 +#: ../../library/ctypes.rst:1301 msgid "" "Why is it printing ``False``? ctypes instances are objects containing a " "memory block plus some :term:`descriptor`\\s accessing the contents of the " @@ -2464,16 +2569,16 @@ msgid "" "the contents again constructs a new Python object each time!" msgstr "" -#: ../../library/ctypes.rst:1258 +#: ../../library/ctypes.rst:1311 msgid "Variable-sized data types" msgstr "" -#: ../../library/ctypes.rst:1260 +#: ../../library/ctypes.rst:1313 msgid "" ":mod:`ctypes` provides some support for variable-sized arrays and structures." msgstr "" -#: ../../library/ctypes.rst:1262 +#: ../../library/ctypes.rst:1315 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, " @@ -2482,7 +2587,7 @@ msgid "" "objects type, a :exc:`ValueError` is raised if this is tried::" msgstr "" -#: ../../library/ctypes.rst:1268 +#: ../../library/ctypes.rst:1321 msgid "" ">>> short_array = (c_short * 4)()\n" ">>> print(sizeof(short_array))\n" @@ -2512,14 +2617,14 @@ msgstr "" "8\n" ">>>" -#: ../../library/ctypes.rst:1282 +#: ../../library/ctypes.rst:1335 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:1286 +#: ../../library/ctypes.rst:1339 msgid "" ">>> short_array[:]\n" "[0, 0, 0, 0]\n" @@ -2537,28 +2642,28 @@ msgstr "" "IndexError: invalid index\n" ">>>" -#: ../../library/ctypes.rst:1294 +#: ../../library/ctypes.rst:1347 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:1302 +#: ../../library/ctypes.rst:1355 msgid "ctypes reference" msgstr "" -#: ../../library/ctypes.rst:1308 +#: ../../library/ctypes.rst:1361 msgid "Finding shared libraries" msgstr "" -#: ../../library/ctypes.rst:1310 +#: ../../library/ctypes.rst:1363 msgid "" "When programming in a compiled language, shared libraries are accessed when " "compiling/linking a program, and when the program is run." msgstr "" -#: ../../library/ctypes.rst:1313 +#: ../../library/ctypes.rst:1366 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 " @@ -2567,13 +2672,13 @@ msgid "" "and call the runtime loader directly." msgstr "" -#: ../../library/ctypes.rst:1319 +#: ../../library/ctypes.rst:1372 msgid "" "The :mod:`!ctypes.util` module provides a function which can help to " "determine the library to load." msgstr "" -#: ../../library/ctypes.rst:1327 +#: ../../library/ctypes.rst:1380 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 " @@ -2581,29 +2686,29 @@ msgid "" "If no library can be found, returns ``None``." msgstr "" -#: ../../library/ctypes.rst:1332 ../../library/ctypes.rst:2038 +#: ../../library/ctypes.rst:1385 ../../library/ctypes.rst:2133 msgid "The exact functionality is system dependent." msgstr "" -#: ../../library/ctypes.rst:1334 +#: ../../library/ctypes.rst:1387 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." msgstr "" -#: ../../library/ctypes.rst:1338 +#: ../../library/ctypes.rst:1391 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:1342 +#: ../../library/ctypes.rst:1395 msgid "Here are some examples::" msgstr "以下是一些範例: ::" -#: ../../library/ctypes.rst:1344 +#: ../../library/ctypes.rst:1397 msgid "" ">>> from ctypes.util import find_library\n" ">>> find_library(\"m\")\n" @@ -2623,14 +2728,14 @@ msgstr "" "'libbz2.so.1.0'\n" ">>>" -#: ../../library/ctypes.rst:1353 +#: ../../library/ctypes.rst:1406 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:1357 +#: ../../library/ctypes.rst:1410 msgid "" ">>> from ctypes.util import find_library\n" ">>> find_library(\"c\")\n" @@ -2654,7 +2759,7 @@ msgstr "" "'/System/Library/Frameworks/AGL.framework/AGL'\n" ">>>" -#: ../../library/ctypes.rst:1368 +#: ../../library/ctypes.rst:1421 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 " @@ -2662,7 +2767,7 @@ msgid "" "``None``." msgstr "" -#: ../../library/ctypes.rst:1372 +#: ../../library/ctypes.rst:1425 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 " @@ -2670,24 +2775,63 @@ msgid "" "to locate the library at runtime." msgstr "" -#: ../../library/ctypes.rst:1380 +#: ../../library/ctypes.rst:1433 +msgid "Listing loaded shared libraries" +msgstr "" + +#: ../../library/ctypes.rst:1435 +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:1439 +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:1443 +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:1448 +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:1455 msgid "Loading shared libraries" msgstr "" -#: ../../library/ctypes.rst:1382 +#: ../../library/ctypes.rst:1457 msgid "" "There are several ways to load shared libraries into the Python process. " "One way is to instantiate one of the following classes:" msgstr "" -#: ../../library/ctypes.rst:1388 +#: ../../library/ctypes.rst:1463 msgid "" "Instances of this class represent loaded shared libraries. Functions in " "these libraries use the standard C calling convention, and are assumed to " "return :c:expr:`int`." msgstr "" -#: ../../library/ctypes.rst:1392 +#: ../../library/ctypes.rst:1467 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:" @@ -2699,18 +2843,18 @@ msgid "" "determine which one is not found using Windows debugging and tracing tools." msgstr "" -#: ../../library/ctypes.rst:1404 ../../library/ctypes.rst:1429 -#: ../../library/ctypes.rst:1442 ../../library/ctypes.rst:1460 +#: ../../library/ctypes.rst:1479 ../../library/ctypes.rst:1504 +#: ../../library/ctypes.rst:1517 ../../library/ctypes.rst:1535 msgid "The *name* parameter can now be a :term:`path-like object`." msgstr "" -#: ../../library/ctypes.rst:1408 +#: ../../library/ctypes.rst:1483 msgid "" "`Microsoft DUMPBIN tool `_ -- A tool to find DLL dependents." msgstr "" -#: ../../library/ctypes.rst:1414 +#: ../../library/ctypes.rst:1489 msgid "" "Instances of this class represent loaded shared libraries, functions in " "these libraries use the ``stdcall`` calling convention, and are assumed to " @@ -2720,36 +2864,38 @@ msgid "" "a failure, an :class:`OSError` is automatically raised." msgstr "" -#: ../../library/ctypes.rst:1421 ../../library/ctypes.rst:1438 -#: ../../library/ctypes.rst:1582 ../../library/ctypes.rst:1590 -#: ../../library/ctypes.rst:1767 ../../library/ctypes.rst:2018 -#: ../../library/ctypes.rst:2027 ../../library/ctypes.rst:2052 -#: ../../library/ctypes.rst:2061 ../../library/ctypes.rst:2070 -#: ../../library/ctypes.rst:2085 ../../library/ctypes.rst:2142 -#: ../../library/ctypes.rst:2170 ../../library/ctypes.rst:2514 +#: ../../library/ctypes.rst:1496 ../../library/ctypes.rst:1513 +#: ../../library/ctypes.rst:1657 ../../library/ctypes.rst:1665 +#: ../../library/ctypes.rst:1837 ../../library/ctypes.rst:1889 +#: ../../library/ctypes.rst:2041 ../../library/ctypes.rst:2113 +#: ../../library/ctypes.rst:2122 ../../library/ctypes.rst:2147 +#: ../../library/ctypes.rst:2161 ../../library/ctypes.rst:2170 +#: ../../library/ctypes.rst:2179 ../../library/ctypes.rst:2194 +#: ../../library/ctypes.rst:2261 ../../library/ctypes.rst:2288 +#: ../../library/ctypes.rst:2688 ../../library/ctypes.rst:3106 msgid "Availability" msgstr "可用性" -#: ../../library/ctypes.rst:1423 +#: ../../library/ctypes.rst:1498 msgid "" ":exc:`WindowsError` used to be raised, which is now an alias of :exc:" "`OSError`." msgstr "" -#: ../../library/ctypes.rst:1434 +#: ../../library/ctypes.rst:1509 msgid "" "Instances of this class represent loaded shared libraries, functions in " "these libraries use the ``stdcall`` calling convention, and are assumed to " "return :c:expr:`int` by default." msgstr "" -#: ../../library/ctypes.rst:1445 +#: ../../library/ctypes.rst:1520 msgid "" "The Python :term:`global interpreter lock` is released before calling any " "function exported by these libraries, and reacquired afterwards." msgstr "" -#: ../../library/ctypes.rst:1451 +#: ../../library/ctypes.rst:1526 msgid "" "Instances of this class behave like :class:`CDLL` instances, except that the " "Python GIL is *not* released during the function call, and after the " @@ -2757,11 +2903,11 @@ msgid "" "set, a Python exception is raised." msgstr "" -#: ../../library/ctypes.rst:1456 +#: ../../library/ctypes.rst:1531 msgid "Thus, this is only useful to call Python C api functions directly." msgstr "" -#: ../../library/ctypes.rst:1462 +#: ../../library/ctypes.rst:1537 msgid "" "All these classes can be instantiated by calling them with at least one " "argument, the pathname of the shared library. If you have an existing " @@ -2771,7 +2917,7 @@ msgid "" "the process, and to get a handle to it." msgstr "" -#: ../../library/ctypes.rst:1469 +#: ../../library/ctypes.rst:1544 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 " @@ -2779,7 +2925,7 @@ msgid "" "configurable." msgstr "" -#: ../../library/ctypes.rst:1474 +#: ../../library/ctypes.rst:1549 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:" @@ -2789,14 +2935,14 @@ msgid "" "private copy, the same happens immediately after the function call." msgstr "" -#: ../../library/ctypes.rst:1481 +#: ../../library/ctypes.rst:1556 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:1485 +#: ../../library/ctypes.rst:1560 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 :" @@ -2805,7 +2951,7 @@ msgid "" "private copy of the windows error code." msgstr "" -#: ../../library/ctypes.rst:1491 +#: ../../library/ctypes.rst:1566 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 " @@ -2815,29 +2961,29 @@ msgid "" "ensure the correct library and dependencies are loaded." msgstr "" -#: ../../library/ctypes.rst:1498 +#: ../../library/ctypes.rst:1573 msgid "Added *winmode* parameter." msgstr "新增 *winmode* 參數。" -#: ../../library/ctypes.rst:1505 +#: ../../library/ctypes.rst:1580 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:1512 +#: ../../library/ctypes.rst:1587 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:1519 +#: ../../library/ctypes.rst:1594 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:1522 +#: ../../library/ctypes.rst:1597 msgid "" "Instances of these classes have no public methods. Functions exported by " "the shared library can be accessed as attributes or by index. Please note " @@ -2846,7 +2992,7 @@ msgid "" "other hand, accessing it through an index returns a new object each time::" msgstr "" -#: ../../library/ctypes.rst:1528 +#: ../../library/ctypes.rst:1603 msgid "" ">>> from ctypes import CDLL\n" ">>> libc = CDLL(\"libc.so.6\") # On Linux\n" @@ -2862,21 +3008,21 @@ msgstr "" ">>> libc['time'] == libc['time']\n" "False" -#: ../../library/ctypes.rst:1535 +#: ../../library/ctypes.rst:1610 msgid "" "The following public attributes are available, their name starts with an " "underscore to not clash with exported function names:" msgstr "" -#: ../../library/ctypes.rst:1541 +#: ../../library/ctypes.rst:1616 msgid "The system handle used to access the library." msgstr "" -#: ../../library/ctypes.rst:1546 +#: ../../library/ctypes.rst:1621 msgid "The name of the library passed in the constructor." msgstr "" -#: ../../library/ctypes.rst:1548 +#: ../../library/ctypes.rst:1623 msgid "" "Shared libraries can also be loaded by using one of the prefabricated " "objects, which are instances of the :class:`LibraryLoader` class, either by " @@ -2884,13 +3030,13 @@ msgid "" "library as attribute of the loader instance." msgstr "" -#: ../../library/ctypes.rst:1556 +#: ../../library/ctypes.rst:1631 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:1559 +#: ../../library/ctypes.rst:1634 msgid "" ":meth:`!__getattr__` has special behavior: It allows loading a shared " "library by accessing it as attribute of a library loader instance. The " @@ -2898,39 +3044,39 @@ msgid "" "each time." msgstr "" -#: ../../library/ctypes.rst:1565 +#: ../../library/ctypes.rst:1640 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:1569 +#: ../../library/ctypes.rst:1644 msgid "These prefabricated library loaders are available:" msgstr "" -#: ../../library/ctypes.rst:1574 +#: ../../library/ctypes.rst:1649 msgid "Creates :class:`CDLL` instances." msgstr "" -#: ../../library/ctypes.rst:1580 +#: ../../library/ctypes.rst:1655 msgid "Creates :class:`WinDLL` instances." msgstr "" -#: ../../library/ctypes.rst:1588 +#: ../../library/ctypes.rst:1663 msgid "Creates :class:`OleDLL` instances." msgstr "" -#: ../../library/ctypes.rst:1596 +#: ../../library/ctypes.rst:1671 msgid "Creates :class:`PyDLL` instances." msgstr "" -#: ../../library/ctypes.rst:1599 +#: ../../library/ctypes.rst:1674 msgid "" "For accessing the C Python api directly, a ready-to-use Python shared " "library object is available:" msgstr "" -#: ../../library/ctypes.rst:1605 +#: ../../library/ctypes.rst:1680 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:" @@ -2938,32 +3084,32 @@ msgid "" "correct :attr:`!restype` attribute to use these functions." msgstr "" -#: ../../library/ctypes.rst:1610 ../../library/ctypes.rst:1612 +#: ../../library/ctypes.rst:1685 ../../library/ctypes.rst:1687 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:1616 ../../library/ctypes.rst:1618 +#: ../../library/ctypes.rst:1691 ../../library/ctypes.rst:1693 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:1622 ../../library/ctypes.rst:1624 +#: ../../library/ctypes.rst:1697 ../../library/ctypes.rst:1699 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:1631 +#: ../../library/ctypes.rst:1706 msgid "Foreign functions" msgstr "" -#: ../../library/ctypes.rst:1633 +#: ../../library/ctypes.rst:1708 msgid "" "As explained in the previous section, foreign functions can be accessed as " "attributes of loaded shared libraries. The function objects created in this " @@ -2972,13 +3118,13 @@ msgid "" "library loader." msgstr "" -#: ../../library/ctypes.rst:1638 +#: ../../library/ctypes.rst:1713 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:1641 +#: ../../library/ctypes.rst:1716 msgid "" ">>> import ctypes\n" ">>> lib = ctypes.CDLL(None)\n" @@ -2987,30 +3133,36 @@ msgid "" ">>> lib._FuncPtr is ctypes._CFuncPtr\n" "False" msgstr "" - -#: ../../library/ctypes.rst:1652 -msgid "Base class for C callable foreign functions." +">>> import ctypes\n" +">>> lib = ctypes.CDLL(None)\n" +">>> issubclass(lib._FuncPtr, ctypes._CFuncPtr)\n" +"True\n" +">>> lib._FuncPtr is ctypes._CFuncPtr\n" +"False" + +#: ../../library/ctypes.rst:1727 +msgid "Base class for C callable foreign functions." msgstr "" -#: ../../library/ctypes.rst:1654 +#: ../../library/ctypes.rst:1729 msgid "" "Instances of foreign functions are also C compatible data types; they " "represent C function pointers." msgstr "" -#: ../../library/ctypes.rst:1657 +#: ../../library/ctypes.rst:1732 msgid "" "This behavior can be customized by assigning to special attributes of the " "foreign function object." msgstr "" -#: ../../library/ctypes.rst:1662 +#: ../../library/ctypes.rst:1737 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:1665 +#: ../../library/ctypes.rst:1740 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 " @@ -3020,7 +3172,7 @@ msgid "" "callable to the :attr:`errcheck` attribute." msgstr "" -#: ../../library/ctypes.rst:1674 +#: ../../library/ctypes.rst:1749 msgid "" "Assign a tuple of ctypes types to specify the argument types that the " "function accepts. Functions using the ``stdcall`` calling convention can " @@ -3029,7 +3181,7 @@ msgid "" "unspecified arguments as well." msgstr "" -#: ../../library/ctypes.rst:1680 +#: ../../library/ctypes.rst:1755 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` " @@ -3039,7 +3191,7 @@ msgid "" "object using ctypes conversion rules." msgstr "" -#: ../../library/ctypes.rst:1687 +#: ../../library/ctypes.rst:1762 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 " @@ -3047,44 +3199,38 @@ msgid "" "defining adapters that can adapt custom objects as function parameters." msgstr "" -#: ../../library/ctypes.rst:1694 +#: ../../library/ctypes.rst:1769 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:1701 +#: ../../library/ctypes.rst:1776 msgid "" "*result* is what the foreign function returns, as specified by the :attr:`!" "restype` attribute." msgstr "" -#: ../../library/ctypes.rst:1704 +#: ../../library/ctypes.rst:1779 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:1708 +#: ../../library/ctypes.rst:1783 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:1712 +#: ../../library/ctypes.rst:1787 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:1719 -msgid "" -"This exception is raised when a foreign function call cannot convert one of " -"the passed arguments." -msgstr "" - -#: ../../library/ctypes.rst:1723 ../../library/ctypes.rst:1725 +#: ../../library/ctypes.rst:1792 ../../library/ctypes.rst:1794 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 " @@ -3093,18 +3239,18 @@ msgid "" "hook to replace the exception with its own." msgstr "" -#: ../../library/ctypes.rst:1731 ../../library/ctypes.rst:1733 +#: ../../library/ctypes.rst:1800 ../../library/ctypes.rst:1802 msgid "" -"Some ways to invoke foreign function calls may raise an auditing event " -"``ctypes.call_function`` with arguments ``function pointer`` and " -"``arguments``." +"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:1739 +#: ../../library/ctypes.rst:1809 msgid "Function prototypes" msgstr "" -#: ../../library/ctypes.rst:1741 +#: ../../library/ctypes.rst:1811 msgid "" "Foreign functions can also be created by instantiating function prototypes. " "Function prototypes are similar to function prototypes in C; they describe a " @@ -3115,7 +3261,7 @@ msgid "" "``@wrapper`` syntax. See :ref:`ctypes-callback-functions` for examples." msgstr "" -#: ../../library/ctypes.rst:1752 +#: ../../library/ctypes.rst:1822 msgid "" "The returned function prototype creates functions that use the standard C " "calling convention. The function will release the GIL during the call. If " @@ -3124,37 +3270,37 @@ msgid "" "after the call; *use_last_error* does the same for the Windows error code." msgstr "" -#: ../../library/ctypes.rst:1762 +#: ../../library/ctypes.rst:1832 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:1772 +#: ../../library/ctypes.rst:1842 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:1775 +#: ../../library/ctypes.rst:1845 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:1782 +#: ../../library/ctypes.rst:1852 msgid "" "Returns a foreign function at the specified address which must be an integer." msgstr "" -#: ../../library/ctypes.rst:1789 +#: ../../library/ctypes.rst:1859 msgid "" "Create a C callable function (a callback function) from a Python *callable*." msgstr "" -#: ../../library/ctypes.rst:1796 +#: ../../library/ctypes.rst:1866 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 " @@ -3162,7 +3308,7 @@ msgid "" "small integer. The second item is the shared library instance." msgstr "" -#: ../../library/ctypes.rst:1806 +#: ../../library/ctypes.rst:1876 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* " @@ -3170,79 +3316,86 @@ msgid "" "identifier which is used in extended error reporting." msgstr "" -#: ../../library/ctypes.rst:1811 +#: ../../library/ctypes.rst:1881 +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:1885 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:1815 +#: ../../library/ctypes.rst:1892 msgid "" "The optional *paramflags* parameter creates foreign function wrappers with " "much more functionality than the features described above." msgstr "" -#: ../../library/ctypes.rst:1818 +#: ../../library/ctypes.rst:1895 msgid "" "*paramflags* must be a tuple of the same length as :attr:`~_CFuncPtr." "argtypes`." msgstr "" -#: ../../library/ctypes.rst:1820 +#: ../../library/ctypes.rst:1897 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:1823 +#: ../../library/ctypes.rst:1900 msgid "" "The first item is an integer containing a combination of direction flags for " "the parameter:" msgstr "" -#: ../../library/ctypes.rst:1826 +#: ../../library/ctypes.rst:1903 msgid "1" msgstr "1" -#: ../../library/ctypes.rst:1827 +#: ../../library/ctypes.rst:1904 msgid "Specifies an input parameter to the function." msgstr "" -#: ../../library/ctypes.rst:1829 +#: ../../library/ctypes.rst:1906 msgid "2" msgstr "2" -#: ../../library/ctypes.rst:1830 +#: ../../library/ctypes.rst:1907 msgid "Output parameter. The foreign function fills in a value." msgstr "" -#: ../../library/ctypes.rst:1832 +#: ../../library/ctypes.rst:1909 msgid "4" msgstr "4" -#: ../../library/ctypes.rst:1833 +#: ../../library/ctypes.rst:1910 msgid "Input parameter which defaults to the integer zero." msgstr "" -#: ../../library/ctypes.rst:1835 +#: ../../library/ctypes.rst:1912 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:1838 +#: ../../library/ctypes.rst:1915 msgid "The optional third item is the default value for this parameter." msgstr "" -#: ../../library/ctypes.rst:1841 +#: ../../library/ctypes.rst:1918 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:1845 +#: ../../library/ctypes.rst:1922 msgid "" "WINUSERAPI int WINAPI\n" "MessageBoxW(\n" @@ -3258,11 +3411,11 @@ msgstr "" " LPCWSTR lpCaption,\n" " UINT uType);" -#: ../../library/ctypes.rst:1852 ../../library/ctypes.rst:1875 +#: ../../library/ctypes.rst:1929 ../../library/ctypes.rst:1952 msgid "Here is the wrapping with :mod:`ctypes`::" msgstr "" -#: ../../library/ctypes.rst:1854 +#: ../../library/ctypes.rst:1931 msgid "" ">>> from ctypes import c_int, WINFUNCTYPE, windll\n" ">>> from ctypes.wintypes import HWND, LPCWSTR, UINT\n" @@ -3278,11 +3431,11 @@ msgstr "" "\"Hello from ctypes\"), (1, \"flags\", 0)\n" ">>> MessageBox = prototype((\"MessageBoxW\", windll.user32), paramflags)" -#: ../../library/ctypes.rst:1860 +#: ../../library/ctypes.rst:1937 msgid "The ``MessageBox`` foreign function can now be called in these ways::" msgstr "" -#: ../../library/ctypes.rst:1862 +#: ../../library/ctypes.rst:1939 msgid "" ">>> MessageBox()\n" ">>> MessageBox(text=\"Spam, spam, spam\")\n" @@ -3292,7 +3445,7 @@ msgstr "" ">>> MessageBox(text=\"Spam, spam, spam\")\n" ">>> MessageBox(flags=2, text=\"foo bar\")" -#: ../../library/ctypes.rst:1866 +#: ../../library/ctypes.rst:1943 msgid "" "A second example demonstrates output parameters. The win32 " "``GetWindowRect`` function retrieves the dimensions of a specified window by " @@ -3300,7 +3453,7 @@ msgid "" "the C declaration::" msgstr "" -#: ../../library/ctypes.rst:1870 +#: ../../library/ctypes.rst:1947 msgid "" "WINUSERAPI BOOL WINAPI\n" "GetWindowRect(\n" @@ -3312,7 +3465,7 @@ msgstr "" " HWND hWnd,\n" " LPRECT lpRect);" -#: ../../library/ctypes.rst:1877 +#: ../../library/ctypes.rst:1954 msgid "" ">>> from ctypes import POINTER, WINFUNCTYPE, windll, WinError\n" ">>> from ctypes.wintypes import BOOL, HWND, RECT\n" @@ -3330,7 +3483,7 @@ msgstr "" "paramflags)\n" ">>>" -#: ../../library/ctypes.rst:1884 +#: ../../library/ctypes.rst:1961 msgid "" "Functions with output parameters will automatically return the output " "parameter value if there is a single one, or a tuple containing the output " @@ -3338,7 +3491,7 @@ msgid "" "now returns a RECT instance, when called." msgstr "" -#: ../../library/ctypes.rst:1889 +#: ../../library/ctypes.rst:1966 msgid "" "Output parameters can be combined with the :attr:`~_CFuncPtr.errcheck` " "protocol to do further output processing and error checking. The win32 " @@ -3347,7 +3500,7 @@ msgid "" "exception when the api call failed::" msgstr "" -#: ../../library/ctypes.rst:1894 +#: ../../library/ctypes.rst:1971 msgid "" ">>> def errcheck(result, func, args):\n" "... if not result:\n" @@ -3365,7 +3518,7 @@ msgstr "" ">>> GetWindowRect.errcheck = errcheck\n" ">>>" -#: ../../library/ctypes.rst:1902 +#: ../../library/ctypes.rst:1979 msgid "" "If the :attr:`~_CFuncPtr.errcheck` function returns the argument tuple it " "receives unchanged, :mod:`ctypes` continues the normal processing it does on " @@ -3374,7 +3527,7 @@ msgid "" "and return them instead, the normal processing will no longer take place::" msgstr "" -#: ../../library/ctypes.rst:1908 +#: ../../library/ctypes.rst:1985 msgid "" ">>> def errcheck(result, func, args):\n" "... if not result:\n" @@ -3394,17 +3547,17 @@ msgstr "" ">>> GetWindowRect.errcheck = errcheck\n" ">>>" -#: ../../library/ctypes.rst:1921 +#: ../../library/ctypes.rst:1998 msgid "Utility functions" msgstr "" -#: ../../library/ctypes.rst:1925 +#: ../../library/ctypes.rst:2002 msgid "" "Returns the address of the memory buffer as integer. *obj* must be an " "instance of a ctypes type." msgstr "" -#: ../../library/ctypes.rst:1928 +#: ../../library/ctypes.rst:2005 msgid "" "Raises an :ref:`auditing event ` ``ctypes.addressof`` with " "argument ``obj``." @@ -3412,34 +3565,54 @@ msgstr "" "引發一個附帶引數 ``obj`` 的\\ :ref:`稽核事件 ` ``ctypes." "addressof``。" -#: ../../library/ctypes.rst:1933 +#: ../../library/ctypes.rst:2010 msgid "" "Returns the alignment requirements of a ctypes type. *obj_or_type* must be a " "ctypes type or instance." msgstr "" -#: ../../library/ctypes.rst:1939 +#: ../../library/ctypes.rst:2016 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:1943 +#: ../../library/ctypes.rst:2020 msgid "``byref(obj, offset)`` corresponds to this C code::" msgstr "" -#: ../../library/ctypes.rst:1945 +#: ../../library/ctypes.rst:2022 msgid "(((char *)&obj) + offset)" msgstr "(((char *)&obj) + offset)" -#: ../../library/ctypes.rst:1947 +#: ../../library/ctypes.rst:2024 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:1953 +#: ../../library/ctypes.rst:2030 +msgid "" +"Copies a COM pointer from *src* to *dst* and returns the Windows specific :c:" +"type:`!HRESULT` value." +msgstr "" + +#: ../../library/ctypes.rst:2033 +msgid "" +"If *src* is not ``NULL``, its ``AddRef`` method is called, incrementing the " +"reference count." +msgstr "" + +#: ../../library/ctypes.rst:2036 +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 " +"for decrementing the reference count by calling its ``Release`` method when " +"necessary." +msgstr "" + +#: ../../library/ctypes.rst:2048 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* " @@ -3447,47 +3620,47 @@ msgid "" "as a pointer." msgstr "" -#: ../../library/ctypes.rst:1962 +#: ../../library/ctypes.rst:2057 msgid "" "This function creates a mutable character buffer. The returned object is a " "ctypes array of :class:`c_char`." msgstr "" -#: ../../library/ctypes.rst:1965 +#: ../../library/ctypes.rst:2060 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:1968 +#: ../../library/ctypes.rst:2063 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:1972 +#: ../../library/ctypes.rst:2067 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:1975 +#: ../../library/ctypes.rst:2070 msgid "" "If both arguments are given, *size* must not be less than ``len(init)``." -msgstr "" +msgstr "如果兩個引數皆有提供,*size* 不得小於 ``len(init)``。" -#: ../../library/ctypes.rst:1979 +#: ../../library/ctypes.rst:2074 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:1982 +#: ../../library/ctypes.rst:2077 msgid "For example::" -msgstr "" +msgstr "舉例來說: ::" -#: ../../library/ctypes.rst:1984 +#: ../../library/ctypes.rst:2079 msgid "" ">>> bytes(create_string_buffer(2))\n" "b'\\x00\\x00'\n" @@ -3502,8 +3675,20 @@ msgid "" " ...\n" "ValueError: byte string too long" msgstr "" +">>> bytes(create_string_buffer(2))\n" +"b'\\x00\\x00'\n" +">>> bytes(create_string_buffer(b'ab'))\n" +"b'ab\\x00'\n" +">>> bytes(create_string_buffer(b'ab', 2))\n" +"b'ab'\n" +">>> bytes(create_string_buffer(b'ab', 4))\n" +"b'ab\\x00\\x00'\n" +">>> bytes(create_string_buffer(b'abcdef', 2))\n" +"Traceback (most recent call last):\n" +" ...\n" +"ValueError: byte string too long" -#: ../../library/ctypes.rst:1997 +#: ../../library/ctypes.rst:2092 msgid "" "Raises an :ref:`auditing event ` ``ctypes.create_string_buffer`` " "with arguments ``init``, ``size``." @@ -3511,19 +3696,19 @@ msgstr "" "引發一個附帶引數 ``init`` 與 ``size`` 的\\ :ref:`稽核事件 ` " "``ctypes.create_string_buffer``。" -#: ../../library/ctypes.rst:2003 +#: ../../library/ctypes.rst:2098 msgid "" "This function creates a mutable unicode character buffer. The returned " "object is a ctypes array of :class:`c_wchar`." msgstr "" -#: ../../library/ctypes.rst:2006 +#: ../../library/ctypes.rst:2101 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:2009 +#: ../../library/ctypes.rst:2104 msgid "" "Raises an :ref:`auditing event ` ``ctypes.create_unicode_buffer`` " "with arguments ``init``, ``size``." @@ -3531,21 +3716,21 @@ msgstr "" "引發一個附帶引數 ``init`` 與 ``size`` 的\\ :ref:`稽核事件 ` " "``ctypes.create_unicode_buffer``。" -#: ../../library/ctypes.rst:2014 +#: ../../library/ctypes.rst:2109 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:2023 +#: ../../library/ctypes.rst:2118 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:2033 +#: ../../library/ctypes.rst:2128 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 " @@ -3553,94 +3738,117 @@ msgid "" "If no library can be found, returns ``None``." msgstr "" -#: ../../library/ctypes.rst:2044 +#: ../../library/ctypes.rst:2139 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:2048 +#: ../../library/ctypes.rst:2143 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:2057 +#: ../../library/ctypes.rst:2153 +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. " +"The function can raise :exc:`OSError` if the underlying platform APIs fail. " +"The exact functionality is system dependent." +msgstr "" + +#: ../../library/ctypes.rst:2158 +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:2166 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 " -"GetLastError." +"specified, the last error code is used by calling the Windows API function :" +"func:`GetLastError`." msgstr "" -#: ../../library/ctypes.rst:2066 +#: ../../library/ctypes.rst:2175 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:2075 +#: ../../library/ctypes.rst:2184 msgid "" "Returns the current value of the ctypes-private copy of the system :data:" "`errno` variable in the calling thread." msgstr "" -#: ../../library/ctypes.rst:2078 +#: ../../library/ctypes.rst:2187 msgid "" "Raises an :ref:`auditing event ` ``ctypes.get_errno`` with no " "arguments." msgstr "" "引發一個不附帶引數的\\ :ref:`稽核事件 ` ``ctypes.get_errno``。" -#: ../../library/ctypes.rst:2082 +#: ../../library/ctypes.rst:2191 msgid "" "Returns the current value of the ctypes-private copy of the system :data:`!" "LastError` variable in the calling thread." msgstr "" -#: ../../library/ctypes.rst:2087 +#: ../../library/ctypes.rst:2196 msgid "" "Raises an :ref:`auditing event ` ``ctypes.get_last_error`` with no " "arguments." msgstr "" "引發一個不附帶引數的\\ :ref:`稽核事件 ` ``ctypes.get_last_error``。" -#: ../../library/ctypes.rst:2092 +#: ../../library/ctypes.rst:2201 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:2099 +#: ../../library/ctypes.rst:2208 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:2106 +#: ../../library/ctypes.rst:2215 msgid "" -"Create and return a new ctypes pointer type. Pointer types are cached and " -"reused internally, so calling this function repeatedly is cheap. *type* must " -"be a ctypes type." +"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:2113 +#: ../../library/ctypes.rst:2221 +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 " +"``POINTER`` in order to set a custom pointer type. However, doing this is " +"discouraged: manually creating a suitable pointer type is difficult without " +"relying on implementation details that may change in future Python versions." +msgstr "" + +#: ../../library/ctypes.rst:2232 msgid "" "Create a new pointer instance, pointing to *obj*. The returned object is of " "the type ``POINTER(type(obj))``." msgstr "" -#: ../../library/ctypes.rst:2116 +#: ../../library/ctypes.rst:2235 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:2122 +#: ../../library/ctypes.rst:2241 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 " @@ -3648,13 +3856,13 @@ msgid "" "but it is possible to enlarge the buffer." msgstr "" -#: ../../library/ctypes.rst:2130 +#: ../../library/ctypes.rst:2249 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:2133 +#: ../../library/ctypes.rst:2252 msgid "" "Raises an :ref:`auditing event ` ``ctypes.set_errno`` with " "argument ``errno``." @@ -3662,14 +3870,14 @@ msgstr "" "引發一個附帶引數 ``errno`` 的\\ :ref:`稽核事件 ` ``ctypes." "set_errno``。" -#: ../../library/ctypes.rst:2138 +#: ../../library/ctypes.rst:2257 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:2144 +#: ../../library/ctypes.rst:2263 msgid "" "Raises an :ref:`auditing event ` ``ctypes.set_last_error`` with " "argument ``error``." @@ -3677,19 +3885,19 @@ msgstr "" "引發一個附帶引數 ``error`` 的\\ :ref:`稽核事件 ` ``ctypes." "set_last_error``。" -#: ../../library/ctypes.rst:2149 +#: ../../library/ctypes.rst:2268 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:2155 +#: ../../library/ctypes.rst:2274 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:2159 +#: ../../library/ctypes.rst:2278 msgid "" "Raises an :ref:`auditing event ` ``ctypes.string_at`` with " "arguments ``ptr``, ``size``." @@ -3697,28 +3905,28 @@ msgstr "" "引發一個附帶引數 ``ptr``、``size`` 的\\ :ref:`稽核事件 ` ``ctypes." "string_at``。" -#: ../../library/ctypes.rst:2164 +#: ../../library/ctypes.rst:2283 msgid "" -"This function is probably the worst-named thing in ctypes. It creates an " -"instance of :exc:`OSError`. If *code* is not specified, ``GetLastError`` is " -"called to determine the error code. If *descr* is not specified, :func:" -"`FormatError` is called to get a textual description of the error." +"Creates an instance of :exc:`OSError`. If *code* is not specified, :func:" +"`GetLastError` is called to determine the error code. If *descr* is not " +"specified, :func:`FormatError` is called to get a textual description of the " +"error." msgstr "" -#: ../../library/ctypes.rst:2172 +#: ../../library/ctypes.rst:2290 msgid "" "An instance of :exc:`WindowsError` used to be created, which is now an alias " "of :exc:`OSError`." msgstr "" -#: ../../library/ctypes.rst:2179 +#: ../../library/ctypes.rst:2297 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:2184 +#: ../../library/ctypes.rst:2302 msgid "" "Raises an :ref:`auditing event ` ``ctypes.wstring_at`` with " "arguments ``ptr``, ``size``." @@ -3726,11 +3934,42 @@ msgstr "" "引發一個附帶引數 ``ptr``、``size`` 的\\ :ref:`稽核事件 ` ``ctypes." "wstring_at``。" -#: ../../library/ctypes.rst:2190 +#: ../../library/ctypes.rst:2307 +msgid "" +"Return a :class:`memoryview` object of length *size* that references memory " +"starting at *void \\*ptr*." +msgstr "" + +#: ../../library/ctypes.rst:2310 +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:2315 +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 " +"more efficient) alternative to ``memoryview((c_byte * size)." +"from_address(ptr))``. (While :meth:`~_CData.from_address` only takes " +"integers, *ptr* can also be given as a :class:`ctypes.POINTER` or a :func:" +"`~ctypes.byref` object.)" +msgstr "" + +#: ../../library/ctypes.rst:2322 +msgid "" +"Raises an :ref:`auditing event ` ``ctypes.memoryview_at`` with " +"arguments ``address``, ``size``, ``readonly``." +msgstr "" +"引發一個附帶引數 ``address``、``size`` 與 ``readonly`` 的\\ :ref:`稽核事件 " +"` ``ctypes.memoryview_at``。" + +#: ../../library/ctypes.rst:2330 msgid "Data types" msgstr "" -#: ../../library/ctypes.rst:2195 +#: ../../library/ctypes.rst:2335 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 " @@ -3740,13 +3979,13 @@ msgid "" "alive in case the memory block contains pointers." msgstr "" -#: ../../library/ctypes.rst:2202 +#: ../../library/ctypes.rst:2342 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:2207 +#: ../../library/ctypes.rst:2347 msgid "" "This method returns a ctypes instance that shares the buffer of the *source* " "object. The *source* object must support the writeable buffer interface. " @@ -3755,7 +3994,7 @@ msgid "" "exc:`ValueError` is raised." msgstr "" -#: ../../library/ctypes.rst:2213 ../../library/ctypes.rst:2223 +#: ../../library/ctypes.rst:2353 ../../library/ctypes.rst:2363 msgid "" "Raises an :ref:`auditing event ` ``ctypes.cdata/buffer`` with " "arguments ``pointer``, ``size``, ``offset``." @@ -3763,7 +4002,7 @@ msgstr "" "引發一個附帶引數 ``pointer``、``size``、``offset`` 的\\ :ref:`稽核事件 " "` ``ctypes.cdata/buffer``。" -#: ../../library/ctypes.rst:2217 +#: ../../library/ctypes.rst:2357 msgid "" "This method creates a ctypes instance, copying the buffer from the *source* " "object buffer which must be readable. The optional *offset* parameter " @@ -3771,19 +4010,19 @@ msgid "" "If the source buffer is not large enough a :exc:`ValueError` is raised." msgstr "" -#: ../../library/ctypes.rst:2227 +#: ../../library/ctypes.rst:2367 msgid "" "This method returns a ctypes type instance using the memory specified by " "*address* which must be an integer." msgstr "" -#: ../../library/ctypes.rst:2230 ../../library/ctypes.rst:2232 +#: ../../library/ctypes.rst:2370 ../../library/ctypes.rst:2372 msgid "" "This method, and others that indirectly call this method, raises an :ref:" "`auditing event ` ``ctypes.cdata`` with argument ``address``." msgstr "" -#: ../../library/ctypes.rst:2238 +#: ../../library/ctypes.rst:2378 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 " @@ -3791,25 +4030,36 @@ msgid "" "object that can be used as a function call parameter." msgstr "" -#: ../../library/ctypes.rst:2243 +#: ../../library/ctypes.rst:2383 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:2249 +#: ../../library/ctypes.rst:2389 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:2253 +#: ../../library/ctypes.rst:2393 +msgid "Common class variables of ctypes data types:" +msgstr "" + +#: ../../library/ctypes.rst:2397 +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:2403 msgid "Common instance variables of ctypes data types:" msgstr "" -#: ../../library/ctypes.rst:2257 +#: ../../library/ctypes.rst:2407 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:" @@ -3817,13 +4067,13 @@ msgid "" "block." msgstr "" -#: ../../library/ctypes.rst:2264 +#: ../../library/ctypes.rst:2414 msgid "" "This read-only variable is true when the ctypes data instance has allocated " "the memory block itself, false otherwise." msgstr "" -#: ../../library/ctypes.rst:2269 +#: ../../library/ctypes.rst:2419 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. " @@ -3831,7 +4081,7 @@ msgid "" "dictionary." msgstr "" -#: ../../library/ctypes.rst:2282 +#: ../../library/ctypes.rst:2432 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 " @@ -3840,11 +4090,11 @@ msgid "" "types that are not and do not contain pointers can now be pickled." msgstr "" -#: ../../library/ctypes.rst:2288 +#: ../../library/ctypes.rst:2438 msgid "Instances have a single attribute:" msgstr "" -#: ../../library/ctypes.rst:2292 +#: ../../library/ctypes.rst:2442 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 " @@ -3852,7 +4102,7 @@ msgid "" "bytes object or string." msgstr "" -#: ../../library/ctypes.rst:2297 +#: ../../library/ctypes.rst:2447 msgid "" "When the ``value`` attribute is retrieved from a ctypes instance, usually a " "new object is returned each time. :mod:`ctypes` does *not* implement " @@ -3860,7 +4110,7 @@ msgid "" "true for all other ctypes object instances." msgstr "" -#: ../../library/ctypes.rst:2303 +#: ../../library/ctypes.rst:2453 msgid "" "Fundamental data types, when returned as foreign function call results, or, " "for example, by retrieving structure field members or array items, are " @@ -3870,7 +4120,7 @@ msgid "" "instance." msgstr "" -#: ../../library/ctypes.rst:2311 +#: ../../library/ctypes.rst:2461 msgid "" "Subclasses of fundamental data types do *not* inherit this behavior. So, if " "a foreign functions :attr:`!restype` is a subclass of :class:`c_void_p`, you " @@ -3878,25 +4128,25 @@ msgid "" "you can get the value of the pointer by accessing the ``value`` attribute." msgstr "" -#: ../../library/ctypes.rst:2316 +#: ../../library/ctypes.rst:2466 msgid "These are the fundamental ctypes data types:" msgstr "" -#: ../../library/ctypes.rst:2320 +#: ../../library/ctypes.rst:2470 msgid "" "Represents the C :c:expr:`signed char` datatype, and interprets the value as " "small integer. The constructor accepts an optional integer initializer; no " "overflow checking is done." msgstr "" -#: ../../library/ctypes.rst:2327 +#: ../../library/ctypes.rst:2477 msgid "" "Represents the C :c:expr:`char` datatype, and interprets the value as a " "single character. The constructor accepts an optional string initializer, " "the length of the string must be exactly one character." msgstr "" -#: ../../library/ctypes.rst:2334 +#: ../../library/ctypes.rst:2484 msgid "" "Represents the C :c:expr:`char *` datatype when it points to a zero-" "terminated string. For a general character pointer that may also point to " @@ -3904,182 +4154,204 @@ msgid "" "integer address, or a bytes object." msgstr "" -#: ../../library/ctypes.rst:2342 +#: ../../library/ctypes.rst:2492 msgid "" "Represents the C :c:expr:`double` datatype. The constructor accepts an " "optional float initializer." msgstr "" -#: ../../library/ctypes.rst:2348 +#: ../../library/ctypes.rst:2498 msgid "" "Represents the C :c:expr:`long double` datatype. The constructor accepts an " "optional float initializer. On platforms where ``sizeof(long double) == " "sizeof(double)`` it is an alias to :class:`c_double`." msgstr "" -#: ../../library/ctypes.rst:2354 +#: ../../library/ctypes.rst:2504 msgid "" "Represents the C :c:expr:`float` datatype. The constructor accepts an " "optional float initializer." msgstr "" -#: ../../library/ctypes.rst:2360 +#: ../../library/ctypes.rst:2510 +msgid "" +"Represents the C :c:expr:`double complex` datatype, if available. The " +"constructor accepts an optional :class:`complex` initializer." +msgstr "" + +#: ../../library/ctypes.rst:2518 +msgid "" +"Represents the C :c:expr:`float complex` datatype, if available. The " +"constructor accepts an optional :class:`complex` initializer." +msgstr "" + +#: ../../library/ctypes.rst:2526 +msgid "" +"Represents the C :c:expr:`long double complex` datatype, if available. The " +"constructor accepts an optional :class:`complex` initializer." +msgstr "" + +#: ../../library/ctypes.rst:2534 msgid "" "Represents the C :c:expr:`signed int` datatype. The constructor accepts an " "optional integer initializer; no overflow checking is done. On platforms " "where ``sizeof(int) == sizeof(long)`` it is an alias to :class:`c_long`." msgstr "" -#: ../../library/ctypes.rst:2367 +#: ../../library/ctypes.rst:2541 msgid "" "Represents the C 8-bit :c:expr:`signed int` datatype. It is an alias for :" "class:`c_byte`." msgstr "" -#: ../../library/ctypes.rst:2373 +#: ../../library/ctypes.rst:2547 msgid "" "Represents the C 16-bit :c:expr:`signed int` datatype. Usually an alias " "for :class:`c_short`." msgstr "" -#: ../../library/ctypes.rst:2379 +#: ../../library/ctypes.rst:2553 msgid "" "Represents the C 32-bit :c:expr:`signed int` datatype. Usually an alias " "for :class:`c_int`." msgstr "" -#: ../../library/ctypes.rst:2385 +#: ../../library/ctypes.rst:2559 msgid "" "Represents the C 64-bit :c:expr:`signed int` datatype. Usually an alias " "for :class:`c_longlong`." msgstr "" -#: ../../library/ctypes.rst:2391 +#: ../../library/ctypes.rst:2565 msgid "" "Represents the C :c:expr:`signed long` datatype. The constructor accepts an " "optional integer initializer; no overflow checking is done." msgstr "" -#: ../../library/ctypes.rst:2397 +#: ../../library/ctypes.rst:2571 msgid "" "Represents the C :c:expr:`signed long long` datatype. The constructor " "accepts an optional integer initializer; no overflow checking is done." msgstr "" -#: ../../library/ctypes.rst:2403 +#: ../../library/ctypes.rst:2577 msgid "" "Represents the C :c:expr:`signed short` datatype. The constructor accepts " "an optional integer initializer; no overflow checking is done." msgstr "" -#: ../../library/ctypes.rst:2409 +#: ../../library/ctypes.rst:2583 msgid "Represents the C :c:type:`size_t` datatype." msgstr "" -#: ../../library/ctypes.rst:2414 +#: ../../library/ctypes.rst:2588 msgid "Represents the C :c:type:`ssize_t` datatype." msgstr "" -#: ../../library/ctypes.rst:2421 +#: ../../library/ctypes.rst:2595 msgid "Represents the C :c:type:`time_t` datatype." msgstr "" -#: ../../library/ctypes.rst:2428 +#: ../../library/ctypes.rst:2602 msgid "" "Represents the C :c:expr:`unsigned char` datatype, it interprets the value " "as small integer. The constructor accepts an optional integer initializer; " "no overflow checking is done." msgstr "" -#: ../../library/ctypes.rst:2435 +#: ../../library/ctypes.rst:2609 msgid "" "Represents the C :c:expr:`unsigned int` datatype. The constructor accepts " "an optional integer initializer; no overflow checking is done. On platforms " "where ``sizeof(int) == sizeof(long)`` it is an alias for :class:`c_ulong`." msgstr "" -#: ../../library/ctypes.rst:2442 +#: ../../library/ctypes.rst:2616 msgid "" "Represents the C 8-bit :c:expr:`unsigned int` datatype. It is an alias for :" "class:`c_ubyte`." msgstr "" -#: ../../library/ctypes.rst:2448 +#: ../../library/ctypes.rst:2622 msgid "" "Represents the C 16-bit :c:expr:`unsigned int` datatype. Usually an alias " "for :class:`c_ushort`." msgstr "" -#: ../../library/ctypes.rst:2454 +#: ../../library/ctypes.rst:2628 msgid "" "Represents the C 32-bit :c:expr:`unsigned int` datatype. Usually an alias " "for :class:`c_uint`." msgstr "" -#: ../../library/ctypes.rst:2460 +#: ../../library/ctypes.rst:2634 msgid "" "Represents the C 64-bit :c:expr:`unsigned int` datatype. Usually an alias " "for :class:`c_ulonglong`." msgstr "" -#: ../../library/ctypes.rst:2466 +#: ../../library/ctypes.rst:2640 msgid "" "Represents the C :c:expr:`unsigned long` datatype. The constructor accepts " "an optional integer initializer; no overflow checking is done." msgstr "" -#: ../../library/ctypes.rst:2472 +#: ../../library/ctypes.rst:2646 msgid "" "Represents the C :c:expr:`unsigned long long` datatype. The constructor " "accepts an optional integer initializer; no overflow checking is done." msgstr "" -#: ../../library/ctypes.rst:2478 +#: ../../library/ctypes.rst:2652 msgid "" "Represents the C :c:expr:`unsigned short` datatype. The constructor accepts " "an optional integer initializer; no overflow checking is done." msgstr "" -#: ../../library/ctypes.rst:2484 +#: ../../library/ctypes.rst:2658 msgid "" "Represents the C :c:expr:`void *` type. The value is represented as " "integer. The constructor accepts an optional integer initializer." msgstr "" -#: ../../library/ctypes.rst:2490 +#: ../../library/ctypes.rst:2664 msgid "" "Represents the C :c:type:`wchar_t` datatype, and interprets the value as a " "single character unicode string. The constructor accepts an optional string " "initializer, the length of the string must be exactly one character." msgstr "" -#: ../../library/ctypes.rst:2497 +#: ../../library/ctypes.rst:2671 msgid "" "Represents the C :c:expr:`wchar_t *` datatype, which must be a pointer to a " "zero-terminated wide character string. The constructor accepts an integer " "address, or a string." msgstr "" -#: ../../library/ctypes.rst:2504 +#: ../../library/ctypes.rst:2678 msgid "" "Represent the C :c:expr:`bool` datatype (more accurately, :c:expr:`_Bool` " "from C99). Its value can be ``True`` or ``False``, and the constructor " "accepts any object that has a truth value." msgstr "" -#: ../../library/ctypes.rst:2511 +#: ../../library/ctypes.rst:2685 msgid "" "Represents a :c:type:`!HRESULT` value, which contains success or error " "information for a function or method call." msgstr "" -#: ../../library/ctypes.rst:2519 +#: ../../library/ctypes.rst:2693 msgid "" "Represents the C :c:expr:`PyObject *` datatype. Calling this without an " "argument creates a ``NULL`` :c:expr:`PyObject *` pointer." msgstr "" -#: ../../library/ctypes.rst:2522 +#: ../../library/ctypes.rst:2696 +msgid ":class:`!py_object` is now a :term:`generic type`." +msgstr "" + +#: ../../library/ctypes.rst:2699 msgid "" "The :mod:`!ctypes.wintypes` module provides quite some other Windows " "specific data types, for example :c:type:`!HWND`, :c:type:`!WPARAM`, or :c:" @@ -4087,41 +4359,47 @@ msgid "" "are also defined." msgstr "" -#: ../../library/ctypes.rst:2530 +#: ../../library/ctypes.rst:2707 msgid "Structured data types" msgstr "" -#: ../../library/ctypes.rst:2535 +#: ../../library/ctypes.rst:2712 msgid "Abstract base class for unions in native byte order." msgstr "" -#: ../../library/ctypes.rst:2540 +#: ../../library/ctypes.rst:2714 +msgid "" +"Unions share common attributes and behavior with structures; see :class:" +"`Structure` documentation for details." +msgstr "" + +#: ../../library/ctypes.rst:2719 msgid "Abstract base class for unions in *big endian* byte order." msgstr "" -#: ../../library/ctypes.rst:2546 +#: ../../library/ctypes.rst:2725 msgid "Abstract base class for unions in *little endian* byte order." msgstr "" -#: ../../library/ctypes.rst:2552 +#: ../../library/ctypes.rst:2731 msgid "Abstract base class for structures in *big endian* byte order." msgstr "" -#: ../../library/ctypes.rst:2557 +#: ../../library/ctypes.rst:2736 msgid "Abstract base class for structures in *little endian* byte order." msgstr "" -#: ../../library/ctypes.rst:2559 +#: ../../library/ctypes.rst:2738 msgid "" "Structures and unions with non-native byte order cannot contain pointer type " "fields, or any other data types containing pointer type fields." msgstr "" -#: ../../library/ctypes.rst:2565 +#: ../../library/ctypes.rst:2744 msgid "Abstract base class for structures in *native* byte order." msgstr "" -#: ../../library/ctypes.rst:2567 +#: ../../library/ctypes.rst:2746 msgid "" "Concrete structure and union types must be created by subclassing one of " "these types, and at least define a :attr:`_fields_` class variable. :mod:" @@ -4129,34 +4407,34 @@ msgid "" "the fields by direct attribute accesses. These are the" msgstr "" -#: ../../library/ctypes.rst:2575 +#: ../../library/ctypes.rst:2754 msgid "" "A sequence defining the structure fields. The items must be 2-tuples or 3-" "tuples. The first item is the name of the field, the second item specifies " "the type of the field; it can be any ctypes data type." msgstr "" -#: ../../library/ctypes.rst:2579 +#: ../../library/ctypes.rst:2758 msgid "" "For integer type fields like :class:`c_int`, a third optional item can be " "given. It must be a small positive integer defining the bit width of the " "field." msgstr "" -#: ../../library/ctypes.rst:2583 +#: ../../library/ctypes.rst:2762 msgid "" "Field names must be unique within one structure or union. This is not " "checked, only one field can be accessed when names are repeated." msgstr "" -#: ../../library/ctypes.rst:2586 +#: ../../library/ctypes.rst:2765 msgid "" "It is possible to define the :attr:`_fields_` class variable *after* the " "class statement that defines the Structure subclass, this allows creating " "data types that directly or indirectly reference themselves::" msgstr "" -#: ../../library/ctypes.rst:2590 +#: ../../library/ctypes.rst:2769 msgid "" "class List(Structure):\n" " pass\n" @@ -4170,44 +4448,148 @@ msgstr "" " ...\n" " ]" -#: ../../library/ctypes.rst:2596 +#: ../../library/ctypes.rst:2775 +msgid "" +"The :attr:`!_fields_` class variable can only be set once. Later assignments " +"will raise an :exc:`AttributeError`." +msgstr "" + +#: ../../library/ctypes.rst:2778 msgid "" -"The :attr:`_fields_` class variable must, however, be defined before the " -"type is first used (an instance is created, :func:`sizeof` is called on it, " -"and so on). Later assignments to the :attr:`_fields_` class variable will " -"raise an AttributeError." +"Additionally, the :attr:`!_fields_` class variable must be defined before " +"the structure or union type is first used: an instance or subclass is " +"created, :func:`sizeof` is called on it, and so on. Later assignments to :" +"attr:`!_fields_` will raise an :exc:`AttributeError`. If :attr:`!_fields_` " +"has not been set before such use, the structure or union will have no own " +"fields, as if :attr:`!_fields_` was empty." msgstr "" -#: ../../library/ctypes.rst:2601 +#: ../../library/ctypes.rst:2786 msgid "" -"It is possible to define sub-subclasses of structure types, they inherit the " -"fields of the base class plus the :attr:`_fields_` defined in the sub-" -"subclass, if any." +"Sub-subclasses of structure types inherit the fields of the base class plus " +"the :attr:`_fields_` defined in the sub-subclass, if any." msgstr "" -#: ../../library/ctypes.rst:2608 +#: ../../library/ctypes.rst:2792 msgid "" "An optional small integer that allows overriding the alignment of structure " -"fields in the instance. :attr:`_pack_` must already be defined when :attr:" -"`_fields_` is assigned, otherwise it will have no effect. Setting this " -"attribute to 0 is the same as not setting it at all." +"fields in the instance." msgstr "" -#: ../../library/ctypes.rst:2616 +#: ../../library/ctypes.rst:2795 +msgid "" +"This is only implemented for the MSVC-compatible memory layout (see :attr:" +"`_layout_`)." +msgstr "" + +#: ../../library/ctypes.rst:2798 msgid "" -"An optional small integer that allows overriding the alignment of the " -"structure when being packed or unpacked to/from memory. Setting this " -"attribute to 0 is the same as not setting it at all." +"Setting :attr:`!_pack_` to 0 is the same as not setting it at all. " +"Otherwise, the value must be a positive power of two. The effect is " +"equivalent to ``#pragma pack(N)`` in C, except :mod:`ctypes` may allow " +"larger *n* than what the compiler accepts." msgstr "" -#: ../../library/ctypes.rst:2624 +#: ../../library/ctypes.rst:2803 +msgid "" +":attr:`!_pack_` must already be defined when :attr:`_fields_` is assigned, " +"otherwise it will have no effect." +msgstr "" + +#: ../../library/ctypes.rst:2808 +msgid "" +"For historical reasons, if :attr:`!_pack_` is non-zero, the MSVC-compatible " +"layout will be used by default. On non-Windows platforms, this default is " +"deprecated and is slated to become an error in Python 3.19. If it is " +"intended, set :attr:`~Structure._layout_` to ``'ms'`` explicitly." +msgstr "" + +#: ../../library/ctypes.rst:2817 +msgid "" +"An optional small integer that allows increasing the alignment of the " +"structure when being packed or unpacked to/from memory." +msgstr "" + +#: ../../library/ctypes.rst:2820 +msgid "" +"The value must not be negative. The effect is equivalent to " +"``__attribute__((aligned(N)))`` on GCC or ``#pragma align(N)`` on MSVC, " +"except :mod:`ctypes` may allow values that the compiler would reject." +msgstr "" + +#: ../../library/ctypes.rst:2825 +msgid "" +":attr:`!_align_` can only *increase* a structure's alignment requirements. " +"Setting it to 0 or 1 has no effect." +msgstr "" + +#: ../../library/ctypes.rst:2828 +msgid "" +"Using values that are not powers of two is discouraged and may lead to " +"surprising behavior." +msgstr "" + +#: ../../library/ctypes.rst:2831 +msgid "" +":attr:`!_align_` must already be defined when :attr:`_fields_` is assigned, " +"otherwise it will have no effect." +msgstr "" + +#: ../../library/ctypes.rst:2838 +msgid "" +"An optional string naming the struct/union layout. It can currently be set " +"to:" +msgstr "" + +#: ../../library/ctypes.rst:2841 +msgid "" +"``\"ms\"``: the layout used by the Microsoft compiler (MSVC). On GCC and " +"Clang, this layout can be selected with ``__attribute__((ms_struct))``." +msgstr "" + +#: ../../library/ctypes.rst:2844 +msgid "" +"``\"gcc-sysv\"``: the layout used by GCC with the System V or “SysV-like” " +"data model, as used on Linux and macOS. With this layout, :attr:`~Structure." +"_pack_` must be unset or zero." +msgstr "" + +#: ../../library/ctypes.rst:2848 +msgid "" +"If not set explicitly, ``ctypes`` will use a default that matches the " +"platform conventions. This default may change in future Python releases (for " +"example, when a new platform gains official support, or when a difference " +"between similar platforms is found). Currently the default will be:" +msgstr "" + +#: ../../library/ctypes.rst:2854 +msgid "On Windows: ``\"ms\"``" +msgstr "" + +#: ../../library/ctypes.rst:2855 +msgid "" +"When :attr:`~Structure._pack_` is specified: ``\"ms\"``. (This is " +"deprecated; see :attr:`~Structure._pack_` documentation.)" +msgstr "" + +#: ../../library/ctypes.rst:2857 +msgid "Otherwise: ``\"gcc-sysv\"``" +msgstr "" + +#: ../../library/ctypes.rst:2859 +msgid "" +":attr:`!_layout_` must already be defined when :attr:`~Structure._fields_` " +"is assigned, otherwise it will have no effect." +msgstr "" + +#: ../../library/ctypes.rst:2866 msgid "" "An optional sequence that lists the names of unnamed (anonymous) fields. :" "attr:`_anonymous_` must be already defined when :attr:`_fields_` is " "assigned, otherwise it will have no effect." msgstr "" -#: ../../library/ctypes.rst:2628 +#: ../../library/ctypes.rst:2870 msgid "" "The fields listed in this variable must be structure or union type fields. :" "mod:`ctypes` will create descriptors in the structure type that allows " @@ -4215,11 +4597,11 @@ msgid "" "structure or union field." msgstr "" -#: ../../library/ctypes.rst:2633 +#: ../../library/ctypes.rst:2875 msgid "Here is an example type (Windows)::" msgstr "" -#: ../../library/ctypes.rst:2635 +#: ../../library/ctypes.rst:2877 msgid "" "class _U(Union):\n" " _fields_ = [(\"lptdesc\", POINTER(TYPEDESC)),\n" @@ -4241,7 +4623,7 @@ msgstr "" " _fields_ = [(\"u\", _U),\n" " (\"vt\", VARTYPE)]" -#: ../../library/ctypes.rst:2646 +#: ../../library/ctypes.rst:2888 msgid "" "The ``TYPEDESC`` structure describes a COM data type, the ``vt`` field " "specifies which one of the union fields is valid. Since the ``u`` field is " @@ -4251,7 +4633,7 @@ msgid "" "temporary union instance::" msgstr "" -#: ../../library/ctypes.rst:2653 +#: ../../library/ctypes.rst:2895 msgid "" "td = TYPEDESC()\n" "td.vt = VT_PTR\n" @@ -4263,7 +4645,7 @@ msgstr "" "td.lptdesc = POINTER(some_type)\n" "td.u.lptdesc = POINTER(some_type)" -#: ../../library/ctypes.rst:2658 +#: ../../library/ctypes.rst:2900 msgid "" "It is possible to define sub-subclasses of structures, they inherit the " "fields of the base class. If the subclass definition has a separate :attr:" @@ -4271,7 +4653,7 @@ msgid "" "of the base class." msgstr "" -#: ../../library/ctypes.rst:2663 +#: ../../library/ctypes.rst:2905 msgid "" "Structure and union constructors accept both positional and keyword " "arguments. Positional arguments are used to initialize member fields in the " @@ -4281,15 +4663,148 @@ msgid "" "names not present in :attr:`_fields_`." msgstr "" -#: ../../library/ctypes.rst:2674 +#: ../../library/ctypes.rst:2915 +msgid "" +"Descriptor for fields of a :class:`Structure` and :class:`Union`. For " +"example::" +msgstr "" + +#: ../../library/ctypes.rst:2918 +msgid "" +">>> class Color(Structure):\n" +"... _fields_ = (\n" +"... ('red', c_uint8),\n" +"... ('green', c_uint8),\n" +"... ('blue', c_uint8),\n" +"... ('intense', c_bool, 1),\n" +"... ('blinking', c_bool, 1),\n" +"... )\n" +"...\n" +">>> Color.red\n" +"\n" +">>> Color.green.type\n" +"\n" +">>> Color.blue.byte_offset\n" +"2\n" +">>> Color.intense\n" +"\n" +">>> Color.blinking.bit_offset\n" +"1" +msgstr "" +">>> class Color(Structure):\n" +"... _fields_ = (\n" +"... ('red', c_uint8),\n" +"... ('green', c_uint8),\n" +"... ('blue', c_uint8),\n" +"... ('intense', c_bool, 1),\n" +"... ('blinking', c_bool, 1),\n" +"... )\n" +"...\n" +">>> Color.red\n" +"\n" +">>> Color.green.type\n" +"\n" +">>> Color.blue.byte_offset\n" +"2\n" +">>> Color.intense\n" +"\n" +">>> Color.blinking.bit_offset\n" +"1" + +#: ../../library/ctypes.rst:2938 +msgid "All attributes are read-only." +msgstr "" + +#: ../../library/ctypes.rst:2940 +msgid "" +":class:`!CField` objects are created via :attr:`~Structure._fields_`; do not " +"instantiate the class directly." +msgstr "" + +#: ../../library/ctypes.rst:2945 +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:2951 +msgid "Name of the field, as a string." +msgstr "" + +#: ../../library/ctypes.rst:2955 +msgid "Type of the field, as a :ref:`ctypes class `." +msgstr "" + +#: ../../library/ctypes.rst:2960 +msgid "Offset of the field, in bytes." +msgstr "" + +#: ../../library/ctypes.rst:2962 +msgid "" +"For bitfields, this is the offset of the underlying byte-aligned *storage " +"unit*; see :attr:`~CField.bit_offset`." +msgstr "" + +#: ../../library/ctypes.rst:2967 +msgid "Size of the field, in bytes." +msgstr "" + +#: ../../library/ctypes.rst:2969 +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:2974 +msgid "For non-bitfields, equivalent to :attr:`~CField.byte_size`." +msgstr "" + +#: ../../library/ctypes.rst:2976 +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:2983 +msgid "True if this is a bitfield." +msgstr "" + +#: ../../library/ctypes.rst:2988 +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:2992 +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:2996 +msgid "" +"For non-bitfields, :attr:`!bit_offset` is zero and :attr:`!bit_size` is " +"equal to ``byte_size * 8``." +msgstr "" + +#: ../../library/ctypes.rst:3001 +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:3008 msgid "Arrays and pointers" msgstr "" -#: ../../library/ctypes.rst:2678 +#: ../../library/ctypes.rst:3012 msgid "Abstract base class for arrays." msgstr "" -#: ../../library/ctypes.rst:2680 +#: ../../library/ctypes.rst:3014 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 " @@ -4299,46 +4814,46 @@ msgid "" "an :class:`Array`." msgstr "" -#: ../../library/ctypes.rst:2690 +#: ../../library/ctypes.rst:3024 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:2697 +#: ../../library/ctypes.rst:3031 msgid "Specifies the type of each element in the array." msgstr "" -#: ../../library/ctypes.rst:2700 +#: ../../library/ctypes.rst:3034 msgid "" "Array subclass constructors accept positional arguments, used to initialize " "the elements in order." msgstr "" -#: ../../library/ctypes.rst:2705 +#: ../../library/ctypes.rst:3039 msgid "" "Create an array. Equivalent to ``type * length``, where *type* is a :mod:" "`ctypes` data type and *length* an integer." msgstr "" -#: ../../library/ctypes.rst:2709 +#: ../../library/ctypes.rst:3043 msgid "" "This function is :term:`soft deprecated` in favor of multiplication. There " "are no plans to remove it." msgstr "" -#: ../../library/ctypes.rst:2715 +#: ../../library/ctypes.rst:3049 msgid "Private, abstract base class for pointers." msgstr "" -#: ../../library/ctypes.rst:2717 +#: ../../library/ctypes.rst:3051 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:2721 +#: ../../library/ctypes.rst:3055 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 :" @@ -4347,12 +4862,47 @@ msgid "" "probably crash with an access violation (if you're lucky)." msgstr "" -#: ../../library/ctypes.rst:2731 +#: ../../library/ctypes.rst:3065 msgid "Specifies the type pointed to." msgstr "" -#: ../../library/ctypes.rst:2735 +#: ../../library/ctypes.rst:3069 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:3076 +msgid "Exceptions" +msgstr "" + +#: ../../library/ctypes.rst:3080 +msgid "" +"This exception is raised when a foreign function call cannot convert one of " +"the passed arguments." +msgstr "" + +#: ../../library/ctypes.rst:3086 +msgid "This exception is raised when a COM method call failed." +msgstr "" + +#: ../../library/ctypes.rst:3090 +msgid "The integer value representing the error code." +msgstr "" + +#: ../../library/ctypes.rst:3094 +msgid "The error message." +msgstr "" + +#: ../../library/ctypes.rst:3098 +msgid "The 5-tuple ``(descr, source, helpfile, helpcontext, progid)``." +msgstr "" + +#: ../../library/ctypes.rst:3100 +msgid "" +"*descr* is the textual description. *source* is the language-dependent " +"``ProgID`` for the class or application that raised the error. *helpfile* " +"is the path of the help file. *helpcontext* is the help context " +"identifier. *progid* is the ``ProgID`` of the interface that defined the " +"error." +msgstr "" diff --git a/library/curses.ascii.po b/library/curses.ascii.po index 9c57ae467b0..bc02ebebee2 100644 --- a/library/curses.ascii.po +++ b/library/curses.ascii.po @@ -1,11 +1,10 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-05-09 00:03+0000\n" "PO-Revision-Date: 2018-05-23 14:42+0000\n" diff --git a/library/curses.panel.po b/library/curses.panel.po index 4419591d4dc..6be0d1be8a8 100644 --- a/library/curses.panel.po +++ b/library/curses.panel.po @@ -1,11 +1,10 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-05-09 00:03+0000\n" "PO-Revision-Date: 2018-05-23 14:42+0000\n" diff --git a/library/curses.po b/library/curses.po index 6983ffd45cc..c8b146785dd 100644 --- a/library/curses.po +++ b/library/curses.po @@ -1,13 +1,12 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"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: 2025-11-10 16:45+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-" @@ -52,80 +51,106 @@ msgstr "" "此模組在\\ :ref:`行動平台 `\\ 或\\ :ref:`WebAssembly 平" "台 `\\ 上不支援。" -#: ../../library/curses.rst:28 +#: ../../includes/optional-module.rst:1 +msgid "" +"This is an :term:`optional module`. If it is missing from your copy of " +"CPython, look for documentation from your distributor (that is, whoever " +"provided Python to you). If you are the distributor, see :ref:`optional-" +"module-requirements`." +msgstr "" + +#: ../../library/curses.rst:30 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." msgstr "" -#: ../../library/curses.rst:31 +#: ../../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:36 +#: ../../library/curses.rst:38 msgid "Module :mod:`curses.ascii`" msgstr ":mod:`curses.ascii` 模組" -#: ../../library/curses.rst:37 +#: ../../library/curses.rst:39 msgid "" "Utilities for working with ASCII characters, regardless of your locale " "settings." msgstr "" -#: ../../library/curses.rst:39 +#: ../../library/curses.rst:41 msgid "Module :mod:`curses.panel`" msgstr ":mod:`curses.panel` 模組" -#: ../../library/curses.rst:40 +#: ../../library/curses.rst:42 msgid "A panel stack extension that adds depth to curses windows." msgstr "" -#: ../../library/curses.rst:42 +#: ../../library/curses.rst:44 msgid "Module :mod:`curses.textpad`" msgstr ":mod:`curses.textpad` 模組" -#: ../../library/curses.rst:43 +#: ../../library/curses.rst:45 msgid "" "Editable text widget for curses supporting :program:`Emacs`\\ -like " "bindings." msgstr "" -#: ../../library/curses.rst:45 +#: ../../library/curses.rst:47 msgid ":ref:`curses-howto`" msgstr ":ref:`curses-howto`" -#: ../../library/curses.rst:46 +#: ../../library/curses.rst:48 msgid "" "Tutorial material on using curses with Python, by Andrew Kuchling and Eric " "Raymond." msgstr "" -#: ../../library/curses.rst:53 +#: ../../library/curses.rst:55 msgid "Functions" msgstr "函式" -#: ../../library/curses.rst:55 +#: ../../library/curses.rst:57 msgid "The module :mod:`curses` defines the following exception:" msgstr ":mod:`curses` 模組定義了以下例外:" -#: ../../library/curses.rst:60 +#: ../../library/curses.rst:62 msgid "Exception raised when a curses library function returns an error." msgstr "" -#: ../../library/curses.rst:64 +#: ../../library/curses.rst:66 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:68 +#: ../../library/curses.rst:70 msgid "The module :mod:`curses` defines the following functions:" msgstr ":mod:`curses` 模組定義了以下函式:" -#: ../../library/curses.rst:73 +#: ../../library/curses.rst:75 +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:78 +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 " +"default background and ``init_pair(x, -1, COLOR_BLUE)`` will initialize pair " +"*x* as default foreground on blue." +msgstr "" + +#: ../../library/curses.rst:83 +msgid "Change the definition of the color-pair ``0`` to ``(fg, bg)``." +msgstr "" + +#: ../../library/curses.rst:90 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 " @@ -133,17 +158,17 @@ msgid "" "and occasionally to change interfaces depending on the line speed." msgstr "" -#: ../../library/curses.rst:81 +#: ../../library/curses.rst:98 msgid "Emit a short attention sound." msgstr "" -#: ../../library/curses.rst:86 +#: ../../library/curses.rst:103 msgid "" "Return ``True`` or ``False``, depending on whether the programmer can change " "the colors displayed by the terminal." msgstr "" -#: ../../library/curses.rst:92 +#: ../../library/curses.rst:109 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 " @@ -153,7 +178,7 @@ msgid "" "terminal in cbreak mode." msgstr "" -#: ../../library/curses.rst:101 +#: ../../library/curses.rst:118 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``. " @@ -162,7 +187,7 @@ msgid "" "component)." msgstr "" -#: ../../library/curses.rst:109 +#: ../../library/curses.rst:126 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 " @@ -171,7 +196,7 @@ msgid "" "function." msgstr "" -#: ../../library/curses.rst:118 +#: ../../library/curses.rst:135 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 " @@ -180,7 +205,7 @@ msgid "" "and the \"very visible\" mode is a block cursor." msgstr "" -#: ../../library/curses.rst:127 +#: ../../library/curses.rst:144 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, " @@ -188,7 +213,7 @@ msgid "" "`reset_prog_mode` will restore this mode." msgstr "" -#: ../../library/curses.rst:135 +#: ../../library/curses.rst:152 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\" " @@ -196,11 +221,11 @@ msgid "" "func:`reset_shell_mode` will restore this mode." msgstr "" -#: ../../library/curses.rst:143 +#: ../../library/curses.rst:160 msgid "Insert an *ms* millisecond pause in output." msgstr "" -#: ../../library/curses.rst:148 +#: ../../library/curses.rst:165 msgid "" "Update the physical screen. The curses library keeps two data structures, " "one representing the current physical screen contents and a virtual screen " @@ -208,7 +233,7 @@ msgid "" "the physical screen to match the virtual screen." msgstr "" -#: ../../library/curses.rst:153 +#: ../../library/curses.rst:170 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 " @@ -219,24 +244,24 @@ msgid "" "func:`!doupdate`." msgstr "" -#: ../../library/curses.rst:163 +#: ../../library/curses.rst:180 msgid "" "Enter echo mode. In echo mode, each character input is echoed to the screen " "as it is entered." msgstr "" -#: ../../library/curses.rst:169 +#: ../../library/curses.rst:186 msgid "De-initialize the library, and return terminal to normal status." msgstr "" -#: ../../library/curses.rst:174 +#: ../../library/curses.rst:191 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:181 +#: ../../library/curses.rst:198 msgid "" "The :func:`.filter` routine, if used, must be called before :func:`initscr` " "is called. The effect is that, during those calls, :envvar:`LINES` is set " @@ -247,20 +272,20 @@ msgid "" "time line editing without touching the rest of the screen." msgstr "" -#: ../../library/curses.rst:191 +#: ../../library/curses.rst:208 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:198 +#: ../../library/curses.rst:215 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:204 +#: ../../library/curses.rst:221 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, " @@ -275,51 +300,51 @@ msgid "" "const:`BUTTON_ALT`." msgstr "" -#: ../../library/curses.rst:215 ../../library/curses.rst:1778 +#: ../../library/curses.rst:232 ../../library/curses.rst:1800 msgid "" "The ``BUTTON5_*`` constants are now exposed if they are provided by the " "underlying curses library." msgstr "" -#: ../../library/curses.rst:222 +#: ../../library/curses.rst:239 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:228 +#: ../../library/curses.rst:245 msgid "" "Read window related data stored in the file by an earlier :func:`window." "putwin` call. The routine then creates and initializes a new window using " "that data, returning the new window object." msgstr "" -#: ../../library/curses.rst:235 +#: ../../library/curses.rst:252 msgid "" "Return ``True`` if the terminal can display colors; otherwise, return " "``False``." msgstr "" -#: ../../library/curses.rst:239 +#: ../../library/curses.rst:256 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 (e.g. xterm-256color)." msgstr "" -#: ../../library/curses.rst:243 +#: ../../library/curses.rst:260 msgid "Extended color support requires ncurses version 6.1 or later." msgstr "" -#: ../../library/curses.rst:249 +#: ../../library/curses.rst:266 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:256 +#: ../../library/curses.rst:273 msgid "" "Return ``True`` if the terminal has insert- and delete-line capabilities, or " "can simulate them using scrolling regions. This function is included for " @@ -327,13 +352,13 @@ msgid "" "capabilities." msgstr "" -#: ../../library/curses.rst:264 +#: ../../library/curses.rst:281 msgid "" "Take a key value *ch*, and return ``True`` if the current terminal type " "recognizes a key with that value." msgstr "" -#: ../../library/curses.rst:270 +#: ../../library/curses.rst:287 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 " @@ -342,7 +367,7 @@ msgid "" "``255``. Use :func:`nocbreak` to leave half-delay mode." msgstr "" -#: ../../library/curses.rst:279 +#: ../../library/curses.rst:296 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 " @@ -354,44 +379,45 @@ msgid "" "``True``." msgstr "" -#: ../../library/curses.rst:290 +#: ../../library/curses.rst:307 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 " "background color number. The value of *pair_number* must be between ``1`` " -"and ``COLOR_PAIRS - 1`` (the ``0`` color pair is wired to white on black and " -"cannot be changed). The value of *fg* and *bg* arguments must be between " -"``0`` and ``COLORS - 1``, or, after calling :func:`use_default_colors`, " +"and ``COLOR_PAIRS - 1`` (the ``0`` color pair can only be changed by :func:" +"`use_default_colors` and :func:`assume_default_colors`). The value of *fg* " +"and *bg* arguments must be between ``0`` and ``COLORS - 1``, or, after " +"calling :func:`!use_default_colors` or :func:`!assume_default_colors`, " "``-1``. If the color-pair was previously initialized, the screen is " "refreshed and all occurrences of that color-pair are changed to the new " "definition." msgstr "" -#: ../../library/curses.rst:303 +#: ../../library/curses.rst:322 msgid "" "Initialize the library. Return a :ref:`window ` " "object which represents the whole screen." msgstr "" -#: ../../library/curses.rst:308 +#: ../../library/curses.rst:327 msgid "" "If there is an error opening the terminal, the underlying curses library may " "cause the interpreter to exit." msgstr "" -#: ../../library/curses.rst:314 +#: ../../library/curses.rst:333 msgid "" "Return ``True`` if :func:`resize_term` would modify the window structure, " "``False`` otherwise." msgstr "" -#: ../../library/curses.rst:320 +#: ../../library/curses.rst:339 msgid "" "Return ``True`` if :func:`endwin` has been called (that is, the curses " "library has been deinitialized)." msgstr "" -#: ../../library/curses.rst:326 +#: ../../library/curses.rst:345 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 " @@ -402,27 +428,27 @@ msgid "" "character." msgstr "" -#: ../../library/curses.rst:336 +#: ../../library/curses.rst:355 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:343 +#: ../../library/curses.rst:362 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:350 +#: ../../library/curses.rst:369 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:356 +#: ../../library/curses.rst:375 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 " @@ -430,7 +456,7 @@ msgid "" "fifth of a second." msgstr "" -#: ../../library/curses.rst:363 +#: ../../library/curses.rst:382 msgid "" "Set the mouse events to be reported, and return a tuple ``(availmask, " "oldmask)``. *availmask* indicates which of the specified mouse events can " @@ -439,17 +465,17 @@ msgid "" "never called, no mouse events are ever reported." msgstr "" -#: ../../library/curses.rst:372 +#: ../../library/curses.rst:391 msgid "Sleep for *ms* milliseconds." msgstr "" -#: ../../library/curses.rst:377 +#: ../../library/curses.rst:396 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:380 +#: ../../library/curses.rst:399 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. " @@ -465,35 +491,35 @@ msgid "" "to be displayed." msgstr "" -#: ../../library/curses.rst:396 +#: ../../library/curses.rst:415 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:399 +#: ../../library/curses.rst:418 msgid "" "By default, the window will extend from the specified position to the lower " "right corner of the screen." msgstr "" -#: ../../library/curses.rst:405 +#: ../../library/curses.rst:424 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:412 +#: ../../library/curses.rst:431 msgid "" "Leave cbreak mode. Return to normal \"cooked\" mode with line buffering." msgstr "" -#: ../../library/curses.rst:417 +#: ../../library/curses.rst:436 msgid "Leave echo mode. Echoing of input characters is turned off." msgstr "" -#: ../../library/curses.rst:422 +#: ../../library/curses.rst:441 msgid "" "Leave newline mode. Disable translation of return into newline on input, " "and disable low-level translation of newline into newline/return on output " @@ -503,7 +529,7 @@ msgid "" "also, it will be able to detect the return key on input." msgstr "" -#: ../../library/curses.rst:432 +#: ../../library/curses.rst:451 msgid "" "When the :func:`!noqiflush` routine is used, normal flush of input and " "output queues associated with the ``INTR``, ``QUIT`` and ``SUSP`` characters " @@ -512,63 +538,63 @@ msgid "" "occurred, after the handler exits." msgstr "" -#: ../../library/curses.rst:440 +#: ../../library/curses.rst:459 msgid "Leave raw mode. Return to normal \"cooked\" mode with line buffering." msgstr "" -#: ../../library/curses.rst:445 +#: ../../library/curses.rst:464 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:451 +#: ../../library/curses.rst:470 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:457 +#: ../../library/curses.rst:476 msgid "" "Equivalent to ``tputs(str, 1, putchar)``; emit the value of a specified " "terminfo capability for the current terminal. Note that the output of :func:" "`putp` always goes to standard output." msgstr "" -#: ../../library/curses.rst:464 +#: ../../library/curses.rst:483 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:471 +#: ../../library/curses.rst:490 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:478 +#: ../../library/curses.rst:497 msgid "" "Restore the terminal to \"program\" mode, as previously saved by :func:" "`def_prog_mode`." msgstr "" -#: ../../library/curses.rst:484 +#: ../../library/curses.rst:503 msgid "" "Restore the terminal to \"shell\" mode, as previously saved by :func:" "`def_shell_mode`." msgstr "" -#: ../../library/curses.rst:490 +#: ../../library/curses.rst:509 msgid "" "Restore the state of the terminal modes to what it was at the last call to :" "func:`savetty`." msgstr "" -#: ../../library/curses.rst:496 +#: ../../library/curses.rst:515 msgid "" "Backend function used by :func:`resizeterm`, performing most of the work; " "when resizing the windows, :func:`resize_term` blank-fills the areas that " @@ -578,47 +604,47 @@ msgid "" "to resize these without additional interaction with the application." msgstr "" -#: ../../library/curses.rst:506 +#: ../../library/curses.rst:525 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:513 +#: ../../library/curses.rst:532 msgid "" "Save the current state of the terminal modes in a buffer, usable by :func:" "`resetty`." msgstr "" -#: ../../library/curses.rst:518 +#: ../../library/curses.rst:537 msgid "Retrieves the value set by :func:`set_escdelay`." msgstr "" -#: ../../library/curses.rst:524 +#: ../../library/curses.rst:543 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:532 +#: ../../library/curses.rst:551 msgid "Retrieves the value set by :func:`set_tabsize`." msgstr "" -#: ../../library/curses.rst:538 +#: ../../library/curses.rst:557 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:545 +#: ../../library/curses.rst:564 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:551 +#: ../../library/curses.rst:570 msgid "" "Initialize the terminal. *term* is a string giving the terminal name, or " "``None``; if omitted or ``None``, the value of the :envvar:`TERM` " @@ -627,14 +653,14 @@ msgid "" "descriptor for ``sys.stdout`` will be used." msgstr "" -#: ../../library/curses.rst:560 +#: ../../library/curses.rst:579 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:564 +#: ../../library/curses.rst:583 msgid "" ":func:`start_color` initializes eight basic colors (black, red, green, " "yellow, blue, magenta, cyan, and white), and two global variables in the :" @@ -644,20 +670,20 @@ msgid "" "terminal was just turned on." msgstr "" -#: ../../library/curses.rst:573 +#: ../../library/curses.rst:592 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:580 +#: ../../library/curses.rst:599 msgid "" "Return the value of the environment variable :envvar:`TERM`, as a bytes " "object, truncated to 14 characters." msgstr "" -#: ../../library/curses.rst:586 +#: ../../library/curses.rst:605 msgid "" "Return the value of the Boolean capability corresponding to the terminfo " "capability name *capname* as an integer. Return the value ``-1`` if " @@ -665,7 +691,7 @@ msgid "" "from the terminal description." msgstr "" -#: ../../library/curses.rst:594 +#: ../../library/curses.rst:613 msgid "" "Return the value of the numeric capability corresponding to the terminfo " "capability name *capname* as an integer. Return the value ``-2`` if " @@ -673,7 +699,7 @@ msgid "" "from the terminal description." msgstr "" -#: ../../library/curses.rst:602 +#: ../../library/curses.rst:621 msgid "" "Return the value of the string capability corresponding to the terminfo " "capability name *capname* as a bytes object. Return ``None`` if *capname* " @@ -681,7 +707,7 @@ msgid "" "terminal description." msgstr "" -#: ../../library/curses.rst:610 +#: ../../library/curses.rst:629 msgid "" "Instantiate the bytes object *str* with the supplied parameters, where *str* " "should be a parameterized string obtained from the terminfo database. E.g. " @@ -689,13 +715,13 @@ msgid "" "exact result depending on terminal type." msgstr "" -#: ../../library/curses.rst:618 +#: ../../library/curses.rst:637 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:621 +#: ../../library/curses.rst:640 msgid "" "The curses library does \"line-breakout optimization\" by looking for " "typeahead periodically while updating the screen. If input is found, and it " @@ -705,7 +731,7 @@ msgid "" "typeahead checking." msgstr "" -#: ../../library/curses.rst:630 +#: ../../library/curses.rst:649 msgid "" "Return a bytes object which is a printable representation of the character " "*ch*. Control characters are represented as a caret followed by the " @@ -713,35 +739,35 @@ msgid "" "are." msgstr "" -#: ../../library/curses.rst:637 +#: ../../library/curses.rst:656 msgid "Push *ch* so the next :meth:`~window.getch` will return it." msgstr "" -#: ../../library/curses.rst:641 +#: ../../library/curses.rst:660 msgid "Only one *ch* can be pushed before :meth:`!getch` is called." msgstr "" -#: ../../library/curses.rst:646 +#: ../../library/curses.rst:665 msgid "" "Update the :const:`LINES` and :const:`COLS` module variables. Useful for " "detecting manual screen resize." msgstr "" -#: ../../library/curses.rst:654 +#: ../../library/curses.rst:673 msgid "Push *ch* so the next :meth:`~window.get_wch` will return it." msgstr "" -#: ../../library/curses.rst:658 +#: ../../library/curses.rst:677 msgid "Only one *ch* can be pushed before :meth:`!get_wch` is called." msgstr "" -#: ../../library/curses.rst:665 +#: ../../library/curses.rst:684 msgid "" "Push a :const:`KEY_MOUSE` event onto the input queue, associating the given " "state data with it." msgstr "" -#: ../../library/curses.rst:671 +#: ../../library/curses.rst:690 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 " @@ -751,16 +777,11 @@ msgid "" "to use the window size if :envvar:`LINES` and :envvar:`COLUMNS` are not set)." msgstr "" -#: ../../library/curses.rst:681 -msgid "" -"Allow use of default values for colors on terminals supporting this feature. " -"Use this to support transparency in your application. The default color is " -"assigned to the color number ``-1``. After calling this function, " -"``init_pair(x, curses.COLOR_RED, -1)`` initializes, for instance, color pair " -"*x* to a red foreground color on the default background." +#: ../../library/curses.rst:700 +msgid "Equivalent to ``assume_default_colors(-1, -1)``." msgstr "" -#: ../../library/curses.rst:690 +#: ../../library/curses.rst:705 msgid "" "Initialize curses and call another callable object, *func*, which should be " "the rest of your curses-using application. If the application raises an " @@ -774,50 +795,50 @@ msgid "" "echo, and disables the terminal keypad." msgstr "" -#: ../../library/curses.rst:704 +#: ../../library/curses.rst:719 msgid "Window Objects" msgstr "" -#: ../../library/curses.rst:708 +#: ../../library/curses.rst:723 msgid "" "Window objects, as returned by :func:`initscr` and :func:`newwin` above, " "have the following methods and attributes:" msgstr "" -#: ../../library/curses.rst:715 +#: ../../library/curses.rst:730 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:721 +#: ../../library/curses.rst:736 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:729 +#: ../../library/curses.rst:744 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:737 +#: ../../library/curses.rst:752 msgid "" "Paint the character string *str* at ``(y, x)`` with attributes *attr*, " "overwriting anything previously on the display." msgstr "" -#: ../../library/curses.rst:742 +#: ../../library/curses.rst:757 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:746 +#: ../../library/curses.rst:761 msgid "" "A `bug in ncurses `_, the backend for " "this Python module, can cause SegFaults when resizing windows. This is fixed " @@ -827,44 +848,44 @@ msgid "" "line." msgstr "" -#: ../../library/curses.rst:756 +#: ../../library/curses.rst:771 msgid "" "Remove attribute *attr* from the \"background\" set applied to all writes to " "the current window." msgstr "" -#: ../../library/curses.rst:762 +#: ../../library/curses.rst:777 msgid "" -"Add attribute *attr* from the \"background\" set applied to all writes to " -"the current window." +"Add attribute *attr* to the \"background\" set applied to all writes to the " +"current window." msgstr "" -#: ../../library/curses.rst:768 +#: ../../library/curses.rst:783 msgid "" "Set the \"background\" set of attributes to *attr*. This set is initially " "``0`` (no attributes)." msgstr "" -#: ../../library/curses.rst:774 +#: ../../library/curses.rst:789 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:778 +#: ../../library/curses.rst:793 msgid "" "The attribute of every character in the window is changed to the new " "background attribute." msgstr "" -#: ../../library/curses.rst:781 +#: ../../library/curses.rst:796 msgid "" "Wherever the former background character appears, it is changed to the new " "background character." msgstr "" -#: ../../library/curses.rst:787 +#: ../../library/curses.rst:802 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 " @@ -875,128 +896,128 @@ msgid "" "delete line/character operations." msgstr "" -#: ../../library/curses.rst:797 +#: ../../library/curses.rst:812 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:803 +#: ../../library/curses.rst:818 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:808 +#: ../../library/curses.rst:823 msgid "Parameter" msgstr "參數" -#: ../../library/curses.rst:808 +#: ../../library/curses.rst:823 msgid "Description" msgstr "描述" -#: ../../library/curses.rst:808 +#: ../../library/curses.rst:823 msgid "Default value" -msgstr "" +msgstr "預設值" -#: ../../library/curses.rst:810 +#: ../../library/curses.rst:825 msgid "*ls*" msgstr "*ls*" -#: ../../library/curses.rst:810 +#: ../../library/curses.rst:825 msgid "Left side" msgstr "" -#: ../../library/curses.rst:810 ../../library/curses.rst:812 +#: ../../library/curses.rst:825 ../../library/curses.rst:827 msgid ":const:`ACS_VLINE`" msgstr ":const:`ACS_VLINE`" -#: ../../library/curses.rst:812 +#: ../../library/curses.rst:827 msgid "*rs*" msgstr "*rs*" -#: ../../library/curses.rst:812 +#: ../../library/curses.rst:827 msgid "Right side" msgstr "" -#: ../../library/curses.rst:814 +#: ../../library/curses.rst:829 msgid "*ts*" msgstr "*ts*" -#: ../../library/curses.rst:814 +#: ../../library/curses.rst:829 msgid "Top" msgstr "" -#: ../../library/curses.rst:814 ../../library/curses.rst:816 +#: ../../library/curses.rst:829 ../../library/curses.rst:831 msgid ":const:`ACS_HLINE`" msgstr ":const:`ACS_HLINE`" -#: ../../library/curses.rst:816 +#: ../../library/curses.rst:831 msgid "*bs*" msgstr "*bs*" -#: ../../library/curses.rst:816 +#: ../../library/curses.rst:831 msgid "Bottom" msgstr "" -#: ../../library/curses.rst:818 +#: ../../library/curses.rst:833 msgid "*tl*" msgstr "*tl*" -#: ../../library/curses.rst:818 +#: ../../library/curses.rst:833 msgid "Upper-left corner" msgstr "" -#: ../../library/curses.rst:818 +#: ../../library/curses.rst:833 msgid ":const:`ACS_ULCORNER`" msgstr ":const:`ACS_ULCORNER`" -#: ../../library/curses.rst:820 +#: ../../library/curses.rst:835 msgid "*tr*" msgstr "*tr*" -#: ../../library/curses.rst:820 +#: ../../library/curses.rst:835 msgid "Upper-right corner" msgstr "" -#: ../../library/curses.rst:820 +#: ../../library/curses.rst:835 msgid ":const:`ACS_URCORNER`" msgstr ":const:`ACS_URCORNER`" -#: ../../library/curses.rst:822 +#: ../../library/curses.rst:837 msgid "*bl*" msgstr "*bl*" -#: ../../library/curses.rst:822 +#: ../../library/curses.rst:837 msgid "Bottom-left corner" msgstr "" -#: ../../library/curses.rst:822 +#: ../../library/curses.rst:837 msgid ":const:`ACS_LLCORNER`" msgstr ":const:`ACS_LLCORNER`" -#: ../../library/curses.rst:824 +#: ../../library/curses.rst:839 msgid "*br*" msgstr "*br*" -#: ../../library/curses.rst:824 +#: ../../library/curses.rst:839 msgid "Bottom-right corner" msgstr "" -#: ../../library/curses.rst:824 +#: ../../library/curses.rst:839 msgid ":const:`ACS_LRCORNER`" msgstr ":const:`ACS_LRCORNER`" -#: ../../library/curses.rst:830 +#: ../../library/curses.rst:845 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:839 +#: ../../library/curses.rst:854 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 " @@ -1006,45 +1027,45 @@ msgid "" "be redisplayed by the next window refresh." msgstr "" -#: ../../library/curses.rst:849 +#: ../../library/curses.rst:864 msgid "" "Like :meth:`erase`, but also cause the whole window to be repainted upon " "next call to :meth:`refresh`." msgstr "" -#: ../../library/curses.rst:855 +#: ../../library/curses.rst:870 msgid "" "If *flag* is ``True``, the next call to :meth:`refresh` will clear the " "window completely." msgstr "" -#: ../../library/curses.rst:861 +#: ../../library/curses.rst:876 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:867 +#: ../../library/curses.rst:882 msgid "Erase from cursor to the end of the line." msgstr "" -#: ../../library/curses.rst:872 +#: ../../library/curses.rst:887 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:878 +#: ../../library/curses.rst:893 msgid "Delete any character at ``(y, x)``." msgstr "" -#: ../../library/curses.rst:883 +#: ../../library/curses.rst:898 msgid "" "Delete the line under the cursor. All following lines are moved up by one " "line." msgstr "" -#: ../../library/curses.rst:889 +#: ../../library/curses.rst:904 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 " @@ -1052,13 +1073,13 @@ msgid "" "a window object for the derived window." msgstr "" -#: ../../library/curses.rst:897 +#: ../../library/curses.rst:912 msgid "" "Add character *ch* with attribute *attr*, and immediately call :meth:" "`refresh` on the window." msgstr "" -#: ../../library/curses.rst:903 +#: ../../library/curses.rst:918 msgid "" "Test whether the given pair of screen-relative character-cell coordinates " "are enclosed by the given window, returning ``True`` or ``False``. It is " @@ -1066,11 +1087,11 @@ msgid "" "location of a mouse event." msgstr "" -#: ../../library/curses.rst:908 +#: ../../library/curses.rst:923 msgid "Previously it returned ``1`` or ``0`` instead of ``True`` or ``False``." msgstr "" -#: ../../library/curses.rst:914 +#: ../../library/curses.rst:929 msgid "" "Encoding used to encode method arguments (Unicode strings and characters). " "The encoding attribute is inherited from the parent window when a subwindow " @@ -1078,19 +1099,19 @@ msgid "" "locale encoding is used (see :func:`locale.getencoding`)." msgstr "" -#: ../../library/curses.rst:924 +#: ../../library/curses.rst:939 msgid "Clear the window." -msgstr "" +msgstr "清除視窗。" -#: ../../library/curses.rst:929 +#: ../../library/curses.rst:944 msgid "Return a tuple ``(y, x)`` of coordinates of upper-left corner." -msgstr "" +msgstr "回傳左上角的座標 ``(y, x)``。" -#: ../../library/curses.rst:934 +#: ../../library/curses.rst:949 msgid "Return the given window's current background character/attribute pair." -msgstr "" +msgstr "回傳給定視窗目前的背景字元/屬性對。" -#: ../../library/curses.rst:939 +#: ../../library/curses.rst:954 msgid "" "Get a character. Note that the integer returned does *not* have to be in " "ASCII range: function keys, keypad keys and so on are represented by numbers " @@ -1098,14 +1119,14 @@ msgid "" "otherwise wait until a key is pressed." msgstr "" -#: ../../library/curses.rst:947 +#: ../../library/curses.rst:962 msgid "" "Get a wide character. Return a character for most keys, or an integer for " "function keys, keypad keys, and other special keys. In no-delay mode, raise " "an exception if there is no input." msgstr "" -#: ../../library/curses.rst:956 +#: ../../library/curses.rst:971 msgid "" "Get a character, returning a string instead of an integer, as :meth:`getch` " "does. Function keys, keypad keys and other special keys return a multibyte " @@ -1113,35 +1134,40 @@ msgid "" "there is no input." msgstr "" -#: ../../library/curses.rst:964 +#: ../../library/curses.rst:979 msgid "Return a tuple ``(y, x)`` of the height and width of the window." -msgstr "" +msgstr "回傳視窗的高度和寬度的元組 ``(y, x)``。" -#: ../../library/curses.rst:969 +#: ../../library/curses.rst:984 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:979 +#: ../../library/curses.rst:994 msgid "" -"Read a bytes object from the user, with primitive line editing capacity." +"Read a bytes object from the user, with primitive line editing capacity. The " +"maximum value for *n* is 2047." msgstr "" -#: ../../library/curses.rst:984 +#: ../../library/curses.rst:997 ../../library/curses.rst:1092 +msgid "The maximum value for *n* was increased from 1023 to 2047." +msgstr "" + +#: ../../library/curses.rst:1003 msgid "" "Return a tuple ``(y, x)`` of current cursor position relative to the " "window's upper-left corner." msgstr "" -#: ../../library/curses.rst:991 +#: ../../library/curses.rst:1010 msgid "" "Display a horizontal line starting at ``(y, x)`` with length *n* consisting " "of the character *ch*." msgstr "" -#: ../../library/curses.rst:997 +#: ../../library/curses.rst:1016 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 " @@ -1149,13 +1175,13 @@ msgid "" "initialized, use of character insert/delete is enabled by default." msgstr "" -#: ../../library/curses.rst:1005 +#: ../../library/curses.rst:1024 msgid "" "If *flag* is ``True``, :mod:`curses` will try and use hardware line editing " "facilities. Otherwise, line insertion/deletion are disabled." msgstr "" -#: ../../library/curses.rst:1011 +#: ../../library/curses.rst:1030 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` " @@ -1163,19 +1189,19 @@ msgid "" "calls to wrefresh. This option is disabled by default." msgstr "" -#: ../../library/curses.rst:1019 +#: ../../library/curses.rst:1038 msgid "" "Return the character at the given position in the window. The bottom 8 bits " "are the character proper, and upper bits are the attributes." msgstr "" -#: ../../library/curses.rst:1026 +#: ../../library/curses.rst:1045 msgid "" "Paint character *ch* at ``(y, x)`` with attributes *attr*, moving the line " "from position *x* right by one character." msgstr "" -#: ../../library/curses.rst:1032 +#: ../../library/curses.rst:1051 msgid "" "Insert *nlines* lines into the specified window above the current line. The " "*nlines* bottom lines are lost. For negative *nlines*, delete *nlines* " @@ -1184,13 +1210,13 @@ msgid "" "remains the same." msgstr "" -#: ../../library/curses.rst:1041 +#: ../../library/curses.rst:1060 msgid "" "Insert a blank line under the cursor. All following lines are moved down by " "one line." msgstr "" -#: ../../library/curses.rst:1048 +#: ../../library/curses.rst:1067 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 " @@ -1200,7 +1226,7 @@ msgid "" "if specified)." msgstr "" -#: ../../library/curses.rst:1058 +#: ../../library/curses.rst:1077 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 " @@ -1209,84 +1235,85 @@ msgid "" "specified)." msgstr "" -#: ../../library/curses.rst:1067 +#: ../../library/curses.rst:1086 msgid "" "Return a bytes object of characters, extracted from the window starting at " "the current cursor position, or at *y*, *x* if specified. Attributes are " "stripped from the characters. If *n* is specified, :meth:`instr` returns a " -"string at most *n* characters long (exclusive of the trailing NUL)." +"string at most *n* characters long (exclusive of the trailing NUL). The " +"maximum value for *n* is 2047." msgstr "" -#: ../../library/curses.rst:1075 +#: ../../library/curses.rst:1098 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:1082 +#: ../../library/curses.rst:1105 msgid "" "Return ``True`` if the specified window was modified since the last call to :" "meth:`refresh`; otherwise return ``False``." msgstr "" -#: ../../library/curses.rst:1088 +#: ../../library/curses.rst:1111 msgid "" "If *flag* is ``True``, escape sequences generated by some keys (keypad, " "function keys) will be interpreted by :mod:`curses`. If *flag* is ``False``, " "escape sequences will be left as is in the input stream." msgstr "" -#: ../../library/curses.rst:1095 +#: ../../library/curses.rst:1118 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. " "If possible the cursor will be made invisible." msgstr "" -#: ../../library/curses.rst:1099 +#: ../../library/curses.rst:1122 msgid "" "If *flag* is ``False``, cursor will always be at \"cursor position\" after " "an update." msgstr "" -#: ../../library/curses.rst:1104 +#: ../../library/curses.rst:1127 msgid "Move cursor to ``(new_y, new_x)``." -msgstr "" +msgstr "移動游標到 ``(new_y, new_x)``。" -#: ../../library/curses.rst:1109 +#: ../../library/curses.rst:1132 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:1116 +#: ../../library/curses.rst:1139 msgid "Move the window so its upper-left corner is at ``(new_y, new_x)``." msgstr "" -#: ../../library/curses.rst:1121 +#: ../../library/curses.rst:1144 msgid "If *flag* is ``True``, :meth:`getch` will be non-blocking." -msgstr "" +msgstr "如果 *flag* 為 ``True``,則 :meth:`getch` 將為非阻塞的。" -#: ../../library/curses.rst:1126 +#: ../../library/curses.rst:1149 msgid "If *flag* is ``True``, escape sequences will not be timed out." msgstr "" -#: ../../library/curses.rst:1128 +#: ../../library/curses.rst:1151 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:1134 +#: ../../library/curses.rst:1157 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:1141 +#: ../../library/curses.rst:1164 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, " @@ -1294,7 +1321,7 @@ msgid "" "contents of *destwin*." msgstr "" -#: ../../library/curses.rst:1146 +#: ../../library/curses.rst:1169 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 " @@ -1302,7 +1329,7 @@ msgid "" "in the destination window." msgstr "" -#: ../../library/curses.rst:1154 +#: ../../library/curses.rst:1177 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 " @@ -1310,7 +1337,7 @@ msgid "" "the old contents of *destwin*." msgstr "" -#: ../../library/curses.rst:1159 +#: ../../library/curses.rst:1182 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 " @@ -1318,31 +1345,31 @@ msgid "" "the destination window." msgstr "" -#: ../../library/curses.rst:1167 +#: ../../library/curses.rst:1190 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:1173 +#: ../../library/curses.rst:1196 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:1179 +#: ../../library/curses.rst:1202 msgid "" "Touch the entire window, causing it to be completely redrawn on the next :" "meth:`refresh` call." msgstr "" -#: ../../library/curses.rst:1185 +#: ../../library/curses.rst:1208 msgid "" "Update the display immediately (sync actual screen with previous drawing/" "deleting methods)." msgstr "" -#: ../../library/curses.rst:1188 +#: ../../library/curses.rst:1211 msgid "" "The 6 optional arguments can only be specified when the window is a pad " "created with :func:`newpad`. The additional parameters are needed to " @@ -1357,7 +1384,7 @@ msgid "" "*smincol* are treated as if they were zero." msgstr "" -#: ../../library/curses.rst:1202 +#: ../../library/curses.rst:1225 msgid "" "Reallocate storage for a curses window to adjust its dimensions to the " "specified values. If either dimension is larger than the current values, " @@ -1365,11 +1392,11 @@ msgid "" "rendition (as set by :meth:`bkgdset`) merged into them." msgstr "" -#: ../../library/curses.rst:1210 +#: ../../library/curses.rst:1233 msgid "Scroll the screen or scrolling region upward by *lines* lines." msgstr "" -#: ../../library/curses.rst:1215 +#: ../../library/curses.rst:1238 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 " @@ -1379,54 +1406,54 @@ msgid "" "scrolling effect on the terminal, it is also necessary to call :meth:`idlok`." msgstr "" -#: ../../library/curses.rst:1225 +#: ../../library/curses.rst:1248 msgid "" "Set the scrolling region from line *top* to line *bottom*. All scrolling " "actions will take place in this region." msgstr "" -#: ../../library/curses.rst:1231 +#: ../../library/curses.rst:1254 msgid "" "Turn off the standout attribute. On some terminals this has the side effect " "of turning off all attributes." msgstr "" -#: ../../library/curses.rst:1237 +#: ../../library/curses.rst:1260 msgid "Turn on attribute *A_STANDOUT*." msgstr "" -#: ../../library/curses.rst:1243 ../../library/curses.rst:1250 +#: ../../library/curses.rst:1266 ../../library/curses.rst:1273 msgid "" "Return a sub-window, whose upper-left corner is at ``(begin_y, begin_x)``, " "and whose width/height is *ncols*/*nlines*." msgstr "" -#: ../../library/curses.rst:1253 +#: ../../library/curses.rst:1276 msgid "" "By default, the sub-window will extend from the specified position to the " "lower right corner of the window." msgstr "" -#: ../../library/curses.rst:1259 +#: ../../library/curses.rst:1282 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:1266 +#: ../../library/curses.rst:1289 msgid "" "If *flag* is ``True``, then :meth:`syncup` is called automatically whenever " "there is a change in the window." msgstr "" -#: ../../library/curses.rst:1272 +#: ../../library/curses.rst:1295 msgid "" "Touch all locations in ancestors of the window that have been changed in " "the window." msgstr "" -#: ../../library/curses.rst:1278 +#: ../../library/curses.rst:1301 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). " @@ -1436,7 +1463,7 @@ msgid "" "still no input at the end of that time." msgstr "" -#: ../../library/curses.rst:1288 +#: ../../library/curses.rst:1311 msgid "" "Pretend *count* lines have been changed, starting with line *start*. If " "*changed* is supplied, it specifies whether the affected lines are marked as " @@ -1444,49 +1471,49 @@ msgid "" "``=False``)." msgstr "" -#: ../../library/curses.rst:1295 +#: ../../library/curses.rst:1318 msgid "" "Pretend the whole window has been changed, for purposes of drawing " "optimizations." msgstr "" -#: ../../library/curses.rst:1301 +#: ../../library/curses.rst:1324 msgid "" "Mark all lines in the window as unchanged since the last call to :meth:" "`refresh`." msgstr "" -#: ../../library/curses.rst:1308 +#: ../../library/curses.rst:1331 msgid "" "Display a vertical line starting at ``(y, x)`` with length *n* consisting of " "the character *ch* with attributes *attr*." msgstr "" -#: ../../library/curses.rst:1313 +#: ../../library/curses.rst:1336 msgid "Constants" msgstr "" -#: ../../library/curses.rst:1315 +#: ../../library/curses.rst:1338 msgid "The :mod:`curses` module defines the following data members:" msgstr ":mod:`curses` 模組定義了以下資料成員:" -#: ../../library/curses.rst:1320 +#: ../../library/curses.rst:1343 msgid "" "Some curses routines that return an integer, such as :meth:`~window." "getch`, return :const:`ERR` upon failure." msgstr "" -#: ../../library/curses.rst:1326 +#: ../../library/curses.rst:1349 msgid "" "Some curses routines that return an integer, such as :func:`napms`, " "return :const:`OK` upon success." msgstr "" -#: ../../library/curses.rst:1333 +#: ../../library/curses.rst:1355 msgid "A bytes object representing the current version of the module." msgstr "" -#: ../../library/curses.rst:1338 +#: ../../library/curses.rst:1360 msgid "" "A named tuple containing the three components of the ncurses library " "version: *major*, *minor*, and *patch*. All values are integers. The " @@ -1494,536 +1521,536 @@ msgid "" "is equivalent to ``curses.ncurses_version.major`` and so on." msgstr "" -#: ../../library/curses.rst:1343 +#: ../../library/curses.rst:1365 msgid "Availability: if the ncurses library is used." msgstr "" -#: ../../library/curses.rst:1349 +#: ../../library/curses.rst:1371 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:1354 +#: ../../library/curses.rst:1376 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:1359 +#: ../../library/curses.rst:1381 msgid "" "The width of the screen, i.e., 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:1366 +#: ../../library/curses.rst:1388 msgid "" "The height of the screen, i.e., 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:1372 +#: ../../library/curses.rst:1394 msgid "" "Some constants are available to specify character cell attributes. The exact " "constants available are system dependent." msgstr "" -#: ../../library/curses.rst:1376 +#: ../../library/curses.rst:1398 msgid "Attribute" msgstr "" -#: ../../library/curses.rst:1376 ../../library/curses.rst:1421 -#: ../../library/curses.rst:1667 ../../library/curses.rst:1759 +#: ../../library/curses.rst:1398 ../../library/curses.rst:1443 +#: ../../library/curses.rst:1689 ../../library/curses.rst:1781 msgid "Meaning" msgstr "含義" -#: ../../library/curses.rst:1378 +#: ../../library/curses.rst:1400 msgid "Alternate character set mode" msgstr "" -#: ../../library/curses.rst:1380 +#: ../../library/curses.rst:1402 msgid "Blink mode" msgstr "" -#: ../../library/curses.rst:1382 +#: ../../library/curses.rst:1404 msgid "Bold mode" msgstr "" -#: ../../library/curses.rst:1384 +#: ../../library/curses.rst:1406 msgid "Dim mode" msgstr "" -#: ../../library/curses.rst:1386 +#: ../../library/curses.rst:1408 msgid "Invisible or blank mode" msgstr "" -#: ../../library/curses.rst:1388 +#: ../../library/curses.rst:1410 msgid "Italic mode" msgstr "" -#: ../../library/curses.rst:1390 +#: ../../library/curses.rst:1412 msgid "Normal attribute" msgstr "" -#: ../../library/curses.rst:1392 +#: ../../library/curses.rst:1414 msgid "Protected mode" msgstr "" -#: ../../library/curses.rst:1394 +#: ../../library/curses.rst:1416 msgid "Reverse background and foreground colors" msgstr "" -#: ../../library/curses.rst:1397 +#: ../../library/curses.rst:1419 msgid "Standout mode" msgstr "" -#: ../../library/curses.rst:1399 +#: ../../library/curses.rst:1421 msgid "Underline mode" msgstr "" -#: ../../library/curses.rst:1401 +#: ../../library/curses.rst:1423 msgid "Horizontal highlight" msgstr "" -#: ../../library/curses.rst:1403 +#: ../../library/curses.rst:1425 msgid "Left highlight" msgstr "" -#: ../../library/curses.rst:1405 +#: ../../library/curses.rst:1427 msgid "Low highlight" msgstr "" -#: ../../library/curses.rst:1407 +#: ../../library/curses.rst:1429 msgid "Right highlight" msgstr "" -#: ../../library/curses.rst:1409 +#: ../../library/curses.rst:1431 msgid "Top highlight" msgstr "" -#: ../../library/curses.rst:1411 +#: ../../library/curses.rst:1433 msgid "Vertical highlight" msgstr "" -#: ../../library/curses.rst:1414 +#: ../../library/curses.rst:1436 msgid "``A_ITALIC`` was added." -msgstr "" +msgstr "新增 ``A_ITALIC``。" -#: ../../library/curses.rst:1417 +#: ../../library/curses.rst:1439 msgid "" "Several constants are available to extract corresponding attributes returned " "by some methods." msgstr "" -#: ../../library/curses.rst:1421 +#: ../../library/curses.rst:1443 msgid "Bit-mask" msgstr "" -#: ../../library/curses.rst:1423 +#: ../../library/curses.rst:1445 msgid "Bit-mask to extract attributes" msgstr "" -#: ../../library/curses.rst:1426 +#: ../../library/curses.rst:1448 msgid "Bit-mask to extract a character" msgstr "" -#: ../../library/curses.rst:1429 +#: ../../library/curses.rst:1451 msgid "Bit-mask to extract color-pair field information" msgstr "" -#: ../../library/curses.rst:1433 +#: ../../library/curses.rst:1455 msgid "" "Keys are referred to by integer constants with names starting with " "``KEY_``. The exact keycaps available are system dependent." msgstr "" -#: ../../library/curses.rst:1439 +#: ../../library/curses.rst:1461 msgid "Key constant" msgstr "" -#: ../../library/curses.rst:1439 +#: ../../library/curses.rst:1461 msgid "Key" msgstr "" -#: ../../library/curses.rst:1441 +#: ../../library/curses.rst:1463 msgid "Minimum key value" msgstr "" -#: ../../library/curses.rst:1443 +#: ../../library/curses.rst:1465 msgid "Break key (unreliable)" msgstr "" -#: ../../library/curses.rst:1445 +#: ../../library/curses.rst:1467 msgid "Down-arrow" msgstr "" -#: ../../library/curses.rst:1447 +#: ../../library/curses.rst:1469 msgid "Up-arrow" msgstr "" -#: ../../library/curses.rst:1449 +#: ../../library/curses.rst:1471 msgid "Left-arrow" msgstr "" -#: ../../library/curses.rst:1451 +#: ../../library/curses.rst:1473 msgid "Right-arrow" msgstr "" -#: ../../library/curses.rst:1453 +#: ../../library/curses.rst:1475 msgid "Home key (upward+left arrow)" msgstr "" -#: ../../library/curses.rst:1455 +#: ../../library/curses.rst:1477 msgid "Backspace (unreliable)" msgstr "" -#: ../../library/curses.rst:1457 +#: ../../library/curses.rst:1479 msgid "Function keys. Up to 64 function keys are supported." msgstr "" -#: ../../library/curses.rst:1460 +#: ../../library/curses.rst:1482 msgid "Value of function key *n*" msgstr "" -#: ../../library/curses.rst:1462 +#: ../../library/curses.rst:1484 msgid "Delete line" msgstr "" -#: ../../library/curses.rst:1464 +#: ../../library/curses.rst:1486 msgid "Insert line" msgstr "" -#: ../../library/curses.rst:1466 +#: ../../library/curses.rst:1488 msgid "Delete character" msgstr "" -#: ../../library/curses.rst:1468 +#: ../../library/curses.rst:1490 msgid "Insert char or enter insert mode" msgstr "" -#: ../../library/curses.rst:1470 +#: ../../library/curses.rst:1492 msgid "Exit insert char mode" msgstr "" -#: ../../library/curses.rst:1472 +#: ../../library/curses.rst:1494 msgid "Clear screen" msgstr "" -#: ../../library/curses.rst:1474 +#: ../../library/curses.rst:1496 msgid "Clear to end of screen" msgstr "" -#: ../../library/curses.rst:1476 +#: ../../library/curses.rst:1498 msgid "Clear to end of line" msgstr "" -#: ../../library/curses.rst:1478 +#: ../../library/curses.rst:1500 msgid "Scroll 1 line forward" msgstr "" -#: ../../library/curses.rst:1480 +#: ../../library/curses.rst:1502 msgid "Scroll 1 line backward (reverse)" msgstr "" -#: ../../library/curses.rst:1482 +#: ../../library/curses.rst:1504 msgid "Next page" msgstr "" -#: ../../library/curses.rst:1484 +#: ../../library/curses.rst:1506 msgid "Previous page" msgstr "" -#: ../../library/curses.rst:1486 +#: ../../library/curses.rst:1508 msgid "Set tab" msgstr "" -#: ../../library/curses.rst:1488 +#: ../../library/curses.rst:1510 msgid "Clear tab" msgstr "" -#: ../../library/curses.rst:1490 +#: ../../library/curses.rst:1512 msgid "Clear all tabs" msgstr "" -#: ../../library/curses.rst:1492 +#: ../../library/curses.rst:1514 msgid "Enter or send (unreliable)" msgstr "" -#: ../../library/curses.rst:1494 +#: ../../library/curses.rst:1516 msgid "Soft (partial) reset (unreliable)" msgstr "" -#: ../../library/curses.rst:1496 +#: ../../library/curses.rst:1518 msgid "Reset or hard reset (unreliable)" msgstr "" -#: ../../library/curses.rst:1498 +#: ../../library/curses.rst:1520 msgid "Print" msgstr "" -#: ../../library/curses.rst:1500 +#: ../../library/curses.rst:1522 msgid "Home down or bottom (lower left)" msgstr "" -#: ../../library/curses.rst:1502 +#: ../../library/curses.rst:1524 msgid "Upper left of keypad" msgstr "" -#: ../../library/curses.rst:1504 +#: ../../library/curses.rst:1526 msgid "Upper right of keypad" msgstr "" -#: ../../library/curses.rst:1506 +#: ../../library/curses.rst:1528 msgid "Center of keypad" msgstr "" -#: ../../library/curses.rst:1508 +#: ../../library/curses.rst:1530 msgid "Lower left of keypad" msgstr "" -#: ../../library/curses.rst:1510 +#: ../../library/curses.rst:1532 msgid "Lower right of keypad" msgstr "" -#: ../../library/curses.rst:1512 +#: ../../library/curses.rst:1534 msgid "Back tab" msgstr "" -#: ../../library/curses.rst:1514 +#: ../../library/curses.rst:1536 msgid "Beg (beginning)" msgstr "" -#: ../../library/curses.rst:1516 +#: ../../library/curses.rst:1538 msgid "Cancel" msgstr "" -#: ../../library/curses.rst:1518 +#: ../../library/curses.rst:1540 msgid "Close" msgstr "" -#: ../../library/curses.rst:1520 +#: ../../library/curses.rst:1542 msgid "Cmd (command)" msgstr "" -#: ../../library/curses.rst:1522 +#: ../../library/curses.rst:1544 msgid "Copy" msgstr "" -#: ../../library/curses.rst:1524 +#: ../../library/curses.rst:1546 msgid "Create" msgstr "" -#: ../../library/curses.rst:1526 +#: ../../library/curses.rst:1548 msgid "End" msgstr "" -#: ../../library/curses.rst:1528 +#: ../../library/curses.rst:1550 msgid "Exit" msgstr "" -#: ../../library/curses.rst:1530 +#: ../../library/curses.rst:1552 msgid "Find" msgstr "" -#: ../../library/curses.rst:1532 +#: ../../library/curses.rst:1554 msgid "Help" msgstr "" -#: ../../library/curses.rst:1534 +#: ../../library/curses.rst:1556 msgid "Mark" msgstr "" -#: ../../library/curses.rst:1536 +#: ../../library/curses.rst:1558 msgid "Message" msgstr "" -#: ../../library/curses.rst:1538 +#: ../../library/curses.rst:1560 msgid "Move" msgstr "" -#: ../../library/curses.rst:1540 +#: ../../library/curses.rst:1562 msgid "Next" msgstr "" -#: ../../library/curses.rst:1542 +#: ../../library/curses.rst:1564 msgid "Open" msgstr "" -#: ../../library/curses.rst:1544 +#: ../../library/curses.rst:1566 msgid "Options" msgstr "" -#: ../../library/curses.rst:1546 +#: ../../library/curses.rst:1568 msgid "Prev (previous)" msgstr "" -#: ../../library/curses.rst:1548 +#: ../../library/curses.rst:1570 msgid "Redo" msgstr "" -#: ../../library/curses.rst:1550 +#: ../../library/curses.rst:1572 msgid "Ref (reference)" msgstr "" -#: ../../library/curses.rst:1552 +#: ../../library/curses.rst:1574 msgid "Refresh" msgstr "" -#: ../../library/curses.rst:1554 +#: ../../library/curses.rst:1576 msgid "Replace" msgstr "" -#: ../../library/curses.rst:1556 +#: ../../library/curses.rst:1578 msgid "Restart" msgstr "" -#: ../../library/curses.rst:1558 +#: ../../library/curses.rst:1580 msgid "Resume" msgstr "" -#: ../../library/curses.rst:1560 +#: ../../library/curses.rst:1582 msgid "Save" msgstr "" -#: ../../library/curses.rst:1562 +#: ../../library/curses.rst:1584 msgid "Shifted Beg (beginning)" msgstr "" -#: ../../library/curses.rst:1564 +#: ../../library/curses.rst:1586 msgid "Shifted Cancel" msgstr "" -#: ../../library/curses.rst:1566 +#: ../../library/curses.rst:1588 msgid "Shifted Command" msgstr "" -#: ../../library/curses.rst:1568 +#: ../../library/curses.rst:1590 msgid "Shifted Copy" msgstr "" -#: ../../library/curses.rst:1570 +#: ../../library/curses.rst:1592 msgid "Shifted Create" msgstr "" -#: ../../library/curses.rst:1572 +#: ../../library/curses.rst:1594 msgid "Shifted Delete char" msgstr "" -#: ../../library/curses.rst:1574 +#: ../../library/curses.rst:1596 msgid "Shifted Delete line" msgstr "" -#: ../../library/curses.rst:1576 +#: ../../library/curses.rst:1598 msgid "Select" msgstr "" -#: ../../library/curses.rst:1578 +#: ../../library/curses.rst:1600 msgid "Shifted End" msgstr "" -#: ../../library/curses.rst:1580 +#: ../../library/curses.rst:1602 msgid "Shifted Clear line" msgstr "" -#: ../../library/curses.rst:1582 +#: ../../library/curses.rst:1604 msgid "Shifted Exit" msgstr "" -#: ../../library/curses.rst:1584 +#: ../../library/curses.rst:1606 msgid "Shifted Find" msgstr "" -#: ../../library/curses.rst:1586 +#: ../../library/curses.rst:1608 msgid "Shifted Help" msgstr "" -#: ../../library/curses.rst:1588 +#: ../../library/curses.rst:1610 msgid "Shifted Home" msgstr "" -#: ../../library/curses.rst:1590 +#: ../../library/curses.rst:1612 msgid "Shifted Input" msgstr "" -#: ../../library/curses.rst:1592 +#: ../../library/curses.rst:1614 msgid "Shifted Left arrow" msgstr "" -#: ../../library/curses.rst:1594 +#: ../../library/curses.rst:1616 msgid "Shifted Message" msgstr "" -#: ../../library/curses.rst:1596 +#: ../../library/curses.rst:1618 msgid "Shifted Move" msgstr "" -#: ../../library/curses.rst:1598 +#: ../../library/curses.rst:1620 msgid "Shifted Next" msgstr "" -#: ../../library/curses.rst:1600 +#: ../../library/curses.rst:1622 msgid "Shifted Options" msgstr "" -#: ../../library/curses.rst:1602 +#: ../../library/curses.rst:1624 msgid "Shifted Prev" msgstr "" -#: ../../library/curses.rst:1604 +#: ../../library/curses.rst:1626 msgid "Shifted Print" msgstr "" -#: ../../library/curses.rst:1606 +#: ../../library/curses.rst:1628 msgid "Shifted Redo" msgstr "" -#: ../../library/curses.rst:1608 +#: ../../library/curses.rst:1630 msgid "Shifted Replace" msgstr "" -#: ../../library/curses.rst:1610 +#: ../../library/curses.rst:1632 msgid "Shifted Right arrow" msgstr "" -#: ../../library/curses.rst:1612 +#: ../../library/curses.rst:1634 msgid "Shifted Resume" msgstr "" -#: ../../library/curses.rst:1614 +#: ../../library/curses.rst:1636 msgid "Shifted Save" msgstr "" -#: ../../library/curses.rst:1616 +#: ../../library/curses.rst:1638 msgid "Shifted Suspend" msgstr "" -#: ../../library/curses.rst:1618 +#: ../../library/curses.rst:1640 msgid "Shifted Undo" msgstr "" -#: ../../library/curses.rst:1620 +#: ../../library/curses.rst:1642 msgid "Suspend" msgstr "" -#: ../../library/curses.rst:1622 +#: ../../library/curses.rst:1644 msgid "Undo" msgstr "" -#: ../../library/curses.rst:1624 +#: ../../library/curses.rst:1646 msgid "Mouse event has occurred" msgstr "" -#: ../../library/curses.rst:1626 +#: ../../library/curses.rst:1648 msgid "Terminal resize event" msgstr "" -#: ../../library/curses.rst:1628 +#: ../../library/curses.rst:1650 msgid "Maximum key value" msgstr "" -#: ../../library/curses.rst:1631 +#: ../../library/curses.rst:1653 msgid "" "On VT100s and their software emulations, such as X terminal emulators, there " "are normally at least four function keys (:const:`KEY_F1 `, :const:" @@ -2035,64 +2062,64 @@ msgid "" "keypad mappings are standard:" msgstr "" -#: ../../library/curses.rst:1640 +#: ../../library/curses.rst:1662 msgid "Keycap" msgstr "" -#: ../../library/curses.rst:1640 ../../library/curses.rst:1785 -#: ../../library/curses.rst:1909 +#: ../../library/curses.rst:1662 ../../library/curses.rst:1807 +#: ../../library/curses.rst:1931 msgid "Constant" msgstr "" -#: ../../library/curses.rst:1642 +#: ../../library/curses.rst:1664 msgid ":kbd:`Insert`" msgstr ":kbd:`Insert`" -#: ../../library/curses.rst:1642 +#: ../../library/curses.rst:1664 msgid "KEY_IC" msgstr "KEY_IC" -#: ../../library/curses.rst:1644 +#: ../../library/curses.rst:1666 msgid ":kbd:`Delete`" msgstr ":kbd:`Delete`" -#: ../../library/curses.rst:1644 +#: ../../library/curses.rst:1666 msgid "KEY_DC" msgstr "KEY_DC" -#: ../../library/curses.rst:1646 +#: ../../library/curses.rst:1668 msgid ":kbd:`Home`" msgstr ":kbd:`Home`" -#: ../../library/curses.rst:1646 +#: ../../library/curses.rst:1668 msgid "KEY_HOME" msgstr "KEY_HOME" -#: ../../library/curses.rst:1648 +#: ../../library/curses.rst:1670 msgid ":kbd:`End`" msgstr ":kbd:`End`" -#: ../../library/curses.rst:1648 +#: ../../library/curses.rst:1670 msgid "KEY_END" msgstr "KEY_END" -#: ../../library/curses.rst:1650 +#: ../../library/curses.rst:1672 msgid ":kbd:`Page Up`" msgstr ":kbd:`Page Up`" -#: ../../library/curses.rst:1650 +#: ../../library/curses.rst:1672 msgid "KEY_PPAGE" msgstr "KEY_PPAGE" -#: ../../library/curses.rst:1652 +#: ../../library/curses.rst:1674 msgid ":kbd:`Page Down`" msgstr ":kbd:`Page Down`" -#: ../../library/curses.rst:1652 +#: ../../library/curses.rst:1674 msgid "KEY_NPAGE" msgstr "KEY_NPAGE" -#: ../../library/curses.rst:1657 +#: ../../library/curses.rst:1679 msgid "" "The following table lists characters from the alternate character set. These " "are inherited from the VT100 terminal, and will generally be available on " @@ -2100,268 +2127,268 @@ msgid "" "available, curses falls back on a crude printable ASCII approximation." msgstr "" -#: ../../library/curses.rst:1664 +#: ../../library/curses.rst:1686 msgid "These are available only after :func:`initscr` has been called." msgstr "" -#: ../../library/curses.rst:1667 +#: ../../library/curses.rst:1689 msgid "ACS code" msgstr "" -#: ../../library/curses.rst:1669 +#: ../../library/curses.rst:1691 msgid "alternate name for upper right corner" msgstr "" -#: ../../library/curses.rst:1671 +#: ../../library/curses.rst:1693 msgid "solid square block" msgstr "" -#: ../../library/curses.rst:1673 +#: ../../library/curses.rst:1695 msgid "board of squares" msgstr "" -#: ../../library/curses.rst:1675 +#: ../../library/curses.rst:1697 msgid "alternate name for horizontal line" msgstr "" -#: ../../library/curses.rst:1677 +#: ../../library/curses.rst:1699 msgid "alternate name for upper left corner" msgstr "" -#: ../../library/curses.rst:1679 +#: ../../library/curses.rst:1701 msgid "alternate name for top tee" msgstr "" -#: ../../library/curses.rst:1681 +#: ../../library/curses.rst:1703 msgid "bottom tee" msgstr "" -#: ../../library/curses.rst:1683 +#: ../../library/curses.rst:1705 msgid "bullet" msgstr "" -#: ../../library/curses.rst:1685 +#: ../../library/curses.rst:1707 msgid "checker board (stipple)" msgstr "" -#: ../../library/curses.rst:1687 +#: ../../library/curses.rst:1709 msgid "arrow pointing down" msgstr "" -#: ../../library/curses.rst:1689 +#: ../../library/curses.rst:1711 msgid "degree symbol" msgstr "" -#: ../../library/curses.rst:1691 +#: ../../library/curses.rst:1713 msgid "diamond" msgstr "" -#: ../../library/curses.rst:1693 +#: ../../library/curses.rst:1715 msgid "greater-than-or-equal-to" msgstr "" -#: ../../library/curses.rst:1695 +#: ../../library/curses.rst:1717 msgid "horizontal line" msgstr "" -#: ../../library/curses.rst:1697 +#: ../../library/curses.rst:1719 msgid "lantern symbol" msgstr "" -#: ../../library/curses.rst:1699 +#: ../../library/curses.rst:1721 msgid "left arrow" msgstr "" -#: ../../library/curses.rst:1701 +#: ../../library/curses.rst:1723 msgid "less-than-or-equal-to" msgstr "" -#: ../../library/curses.rst:1703 +#: ../../library/curses.rst:1725 msgid "lower left-hand corner" msgstr "" -#: ../../library/curses.rst:1705 +#: ../../library/curses.rst:1727 msgid "lower right-hand corner" msgstr "" -#: ../../library/curses.rst:1707 +#: ../../library/curses.rst:1729 msgid "left tee" msgstr "" -#: ../../library/curses.rst:1709 +#: ../../library/curses.rst:1731 msgid "not-equal sign" msgstr "" -#: ../../library/curses.rst:1711 +#: ../../library/curses.rst:1733 msgid "letter pi" msgstr "" -#: ../../library/curses.rst:1713 +#: ../../library/curses.rst:1735 msgid "plus-or-minus sign" msgstr "" -#: ../../library/curses.rst:1715 +#: ../../library/curses.rst:1737 msgid "big plus sign" msgstr "" -#: ../../library/curses.rst:1717 +#: ../../library/curses.rst:1739 msgid "right arrow" msgstr "" -#: ../../library/curses.rst:1719 +#: ../../library/curses.rst:1741 msgid "right tee" msgstr "" -#: ../../library/curses.rst:1721 +#: ../../library/curses.rst:1743 msgid "scan line 1" msgstr "" -#: ../../library/curses.rst:1723 +#: ../../library/curses.rst:1745 msgid "scan line 3" msgstr "" -#: ../../library/curses.rst:1725 +#: ../../library/curses.rst:1747 msgid "scan line 7" msgstr "" -#: ../../library/curses.rst:1727 +#: ../../library/curses.rst:1749 msgid "scan line 9" msgstr "" -#: ../../library/curses.rst:1729 +#: ../../library/curses.rst:1751 msgid "alternate name for lower right corner" msgstr "" -#: ../../library/curses.rst:1731 +#: ../../library/curses.rst:1753 msgid "alternate name for vertical line" msgstr "" -#: ../../library/curses.rst:1733 +#: ../../library/curses.rst:1755 msgid "alternate name for right tee" msgstr "" -#: ../../library/curses.rst:1735 +#: ../../library/curses.rst:1757 msgid "alternate name for lower left corner" msgstr "" -#: ../../library/curses.rst:1737 +#: ../../library/curses.rst:1759 msgid "alternate name for bottom tee" msgstr "" -#: ../../library/curses.rst:1739 +#: ../../library/curses.rst:1761 msgid "alternate name for left tee" msgstr "" -#: ../../library/curses.rst:1741 +#: ../../library/curses.rst:1763 msgid "alternate name for crossover or big plus" msgstr "" -#: ../../library/curses.rst:1743 +#: ../../library/curses.rst:1765 msgid "pound sterling" msgstr "" -#: ../../library/curses.rst:1745 +#: ../../library/curses.rst:1767 msgid "top tee" msgstr "" -#: ../../library/curses.rst:1747 +#: ../../library/curses.rst:1769 msgid "up arrow" msgstr "" -#: ../../library/curses.rst:1749 +#: ../../library/curses.rst:1771 msgid "upper left corner" msgstr "" -#: ../../library/curses.rst:1751 +#: ../../library/curses.rst:1773 msgid "upper right corner" msgstr "" -#: ../../library/curses.rst:1753 +#: ../../library/curses.rst:1775 msgid "vertical line" msgstr "" -#: ../../library/curses.rst:1756 +#: ../../library/curses.rst:1778 msgid "" "The following table lists mouse button constants used by :meth:`getmouse`:" msgstr "" -#: ../../library/curses.rst:1759 +#: ../../library/curses.rst:1781 msgid "Mouse button constant" msgstr "" -#: ../../library/curses.rst:1761 +#: ../../library/curses.rst:1783 msgid "Mouse button *n* pressed" msgstr "" -#: ../../library/curses.rst:1763 +#: ../../library/curses.rst:1785 msgid "Mouse button *n* released" msgstr "" -#: ../../library/curses.rst:1765 +#: ../../library/curses.rst:1787 msgid "Mouse button *n* clicked" msgstr "" -#: ../../library/curses.rst:1767 +#: ../../library/curses.rst:1789 msgid "Mouse button *n* double clicked" msgstr "" -#: ../../library/curses.rst:1769 +#: ../../library/curses.rst:1791 msgid "Mouse button *n* triple clicked" msgstr "" -#: ../../library/curses.rst:1771 +#: ../../library/curses.rst:1793 msgid "Shift was down during button state change" msgstr "" -#: ../../library/curses.rst:1773 ../../library/curses.rst:1775 +#: ../../library/curses.rst:1795 ../../library/curses.rst:1797 msgid "Control was down during button state change" msgstr "" -#: ../../library/curses.rst:1782 +#: ../../library/curses.rst:1804 msgid "The following table lists the predefined colors:" msgstr "" -#: ../../library/curses.rst:1785 +#: ../../library/curses.rst:1807 msgid "Color" msgstr "顏色" -#: ../../library/curses.rst:1787 +#: ../../library/curses.rst:1809 msgid "Black" msgstr "黑" -#: ../../library/curses.rst:1789 +#: ../../library/curses.rst:1811 msgid "Blue" msgstr "藍" -#: ../../library/curses.rst:1791 +#: ../../library/curses.rst:1813 msgid "Cyan (light greenish blue)" msgstr "" -#: ../../library/curses.rst:1793 +#: ../../library/curses.rst:1815 msgid "Green" msgstr "綠" -#: ../../library/curses.rst:1795 +#: ../../library/curses.rst:1817 msgid "Magenta (purplish red)" msgstr "" -#: ../../library/curses.rst:1797 +#: ../../library/curses.rst:1819 msgid "Red" msgstr "紅" -#: ../../library/curses.rst:1799 +#: ../../library/curses.rst:1821 msgid "White" msgstr "白" -#: ../../library/curses.rst:1801 +#: ../../library/curses.rst:1823 msgid "Yellow" msgstr "" -#: ../../library/curses.rst:1806 +#: ../../library/curses.rst:1828 msgid ":mod:`curses.textpad` --- Text input widget for curses programs" msgstr "" -#: ../../library/curses.rst:1814 +#: ../../library/curses.rst:1836 msgid "" "The :mod:`curses.textpad` module provides a :class:`Textbox` class that " "handles elementary text editing in a curses window, supporting a set of " @@ -2371,11 +2398,11 @@ msgid "" "purposes." msgstr "" -#: ../../library/curses.rst:1820 +#: ../../library/curses.rst:1842 msgid "The module :mod:`curses.textpad` defines the following function:" msgstr ":mod:`curses.textpad` 模組定義了以下函式:" -#: ../../library/curses.rst:1825 +#: ../../library/curses.rst:1847 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 " @@ -2387,15 +2414,15 @@ msgid "" "will be drawn with ASCII dashes, vertical bars, and plus signs." msgstr "" -#: ../../library/curses.rst:1838 +#: ../../library/curses.rst:1860 msgid "Textbox objects" msgstr "" -#: ../../library/curses.rst:1840 +#: ../../library/curses.rst:1862 msgid "You can instantiate a :class:`Textbox` object as follows:" msgstr "" -#: ../../library/curses.rst:1845 +#: ../../library/curses.rst:1867 msgid "" "Return a textbox widget object. The *win* argument should be a curses :ref:" "`window ` object in which the textbox is to be " @@ -2404,11 +2431,11 @@ msgid "" "instance's :attr:`stripspaces` flag is initially on." msgstr "" -#: ../../library/curses.rst:1851 +#: ../../library/curses.rst:1873 msgid ":class:`Textbox` objects have the following methods:" msgstr "" -#: ../../library/curses.rst:1856 +#: ../../library/curses.rst:1878 msgid "" "This is the entry point you will normally use. It accepts editing " "keystrokes until one of the termination keystrokes is entered. If " @@ -2419,167 +2446,167 @@ msgid "" "`stripspaces` attribute." msgstr "" -#: ../../library/curses.rst:1867 +#: ../../library/curses.rst:1889 msgid "" "Process a single command keystroke. Here are the supported special " "keystrokes:" msgstr "" -#: ../../library/curses.rst:1871 ../../library/curses.rst:1909 +#: ../../library/curses.rst:1893 ../../library/curses.rst:1931 msgid "Keystroke" msgstr "" -#: ../../library/curses.rst:1871 +#: ../../library/curses.rst:1893 msgid "Action" msgstr "" -#: ../../library/curses.rst:1873 +#: ../../library/curses.rst:1895 msgid ":kbd:`Control-A`" msgstr ":kbd:`Control-A`" -#: ../../library/curses.rst:1873 +#: ../../library/curses.rst:1895 msgid "Go to left edge of window." msgstr "" -#: ../../library/curses.rst:1875 ../../library/curses.rst:1911 +#: ../../library/curses.rst:1897 ../../library/curses.rst:1933 msgid ":kbd:`Control-B`" msgstr ":kbd:`Control-B`" -#: ../../library/curses.rst:1875 +#: ../../library/curses.rst:1897 msgid "Cursor left, wrapping to previous line if appropriate." msgstr "" -#: ../../library/curses.rst:1878 +#: ../../library/curses.rst:1900 msgid ":kbd:`Control-D`" msgstr ":kbd:`Control-D`" -#: ../../library/curses.rst:1878 +#: ../../library/curses.rst:1900 msgid "Delete character under cursor." msgstr "" -#: ../../library/curses.rst:1880 +#: ../../library/curses.rst:1902 msgid ":kbd:`Control-E`" msgstr ":kbd:`Control-E`" -#: ../../library/curses.rst:1880 +#: ../../library/curses.rst:1902 msgid "Go to right edge (stripspaces off) or end of line (stripspaces on)." msgstr "" -#: ../../library/curses.rst:1883 ../../library/curses.rst:1913 +#: ../../library/curses.rst:1905 ../../library/curses.rst:1935 msgid ":kbd:`Control-F`" msgstr ":kbd:`Control-F`" -#: ../../library/curses.rst:1883 +#: ../../library/curses.rst:1905 msgid "Cursor right, wrapping to next line when appropriate." msgstr "" -#: ../../library/curses.rst:1886 +#: ../../library/curses.rst:1908 msgid ":kbd:`Control-G`" msgstr ":kbd:`Control-G`" -#: ../../library/curses.rst:1886 +#: ../../library/curses.rst:1908 msgid "Terminate, returning the window contents." msgstr "" -#: ../../library/curses.rst:1888 +#: ../../library/curses.rst:1910 msgid ":kbd:`Control-H`" msgstr ":kbd:`Control-H`" -#: ../../library/curses.rst:1888 +#: ../../library/curses.rst:1910 msgid "Delete character backward." msgstr "" -#: ../../library/curses.rst:1890 +#: ../../library/curses.rst:1912 msgid ":kbd:`Control-J`" msgstr ":kbd:`Control-J`" -#: ../../library/curses.rst:1890 +#: ../../library/curses.rst:1912 msgid "Terminate if the window is 1 line, otherwise insert newline." msgstr "" -#: ../../library/curses.rst:1893 +#: ../../library/curses.rst:1915 msgid ":kbd:`Control-K`" msgstr ":kbd:`Control-K`" -#: ../../library/curses.rst:1893 +#: ../../library/curses.rst:1915 msgid "If line is blank, delete it, otherwise clear to end of line." msgstr "" -#: ../../library/curses.rst:1896 +#: ../../library/curses.rst:1918 msgid ":kbd:`Control-L`" msgstr ":kbd:`Control-L`" -#: ../../library/curses.rst:1896 +#: ../../library/curses.rst:1918 msgid "Refresh screen." msgstr "" -#: ../../library/curses.rst:1898 ../../library/curses.rst:1917 +#: ../../library/curses.rst:1920 ../../library/curses.rst:1939 msgid ":kbd:`Control-N`" msgstr ":kbd:`Control-N`" -#: ../../library/curses.rst:1898 +#: ../../library/curses.rst:1920 msgid "Cursor down; move down one line." msgstr "" -#: ../../library/curses.rst:1900 +#: ../../library/curses.rst:1922 msgid ":kbd:`Control-O`" msgstr ":kbd:`Control-O`" -#: ../../library/curses.rst:1900 +#: ../../library/curses.rst:1922 msgid "Insert a blank line at cursor location." msgstr "" -#: ../../library/curses.rst:1902 ../../library/curses.rst:1915 +#: ../../library/curses.rst:1924 ../../library/curses.rst:1937 msgid ":kbd:`Control-P`" msgstr ":kbd:`Control-P`" -#: ../../library/curses.rst:1902 +#: ../../library/curses.rst:1924 msgid "Cursor up; move up one line." msgstr "" -#: ../../library/curses.rst:1905 +#: ../../library/curses.rst:1927 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:1911 +#: ../../library/curses.rst:1933 msgid ":const:`~curses.KEY_LEFT`" msgstr ":const:`~curses.KEY_LEFT`" -#: ../../library/curses.rst:1913 +#: ../../library/curses.rst:1935 msgid ":const:`~curses.KEY_RIGHT`" msgstr ":const:`~curses.KEY_RIGHT`" -#: ../../library/curses.rst:1915 +#: ../../library/curses.rst:1937 msgid ":const:`~curses.KEY_UP`" msgstr ":const:`~curses.KEY_UP`" -#: ../../library/curses.rst:1917 +#: ../../library/curses.rst:1939 msgid ":const:`~curses.KEY_DOWN`" msgstr ":const:`~curses.KEY_DOWN`" -#: ../../library/curses.rst:1919 +#: ../../library/curses.rst:1941 msgid ":const:`~curses.KEY_BACKSPACE`" msgstr ":const:`~curses.KEY_BACKSPACE`" -#: ../../library/curses.rst:1919 +#: ../../library/curses.rst:1941 msgid ":kbd:`Control-h`" msgstr ":kbd:`Control-h`" -#: ../../library/curses.rst:1922 +#: ../../library/curses.rst:1944 msgid "" "All other keystrokes are treated as a command to insert the given character " "and move right (with line wrapping)." msgstr "" -#: ../../library/curses.rst:1928 +#: ../../library/curses.rst:1950 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:1934 +#: ../../library/curses.rst:1956 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/custominterp.po b/library/custominterp.po index ddfef2e2750..1f661fe658f 100644 --- a/library/custominterp.po +++ b/library/custominterp.po @@ -1,12 +1,11 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Weilin Du, 2025 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2022-07-06 00:17+0000\n" "PO-Revision-Date: 2025-06-28 10:57+0800\n" diff --git a/library/dataclasses.po b/library/dataclasses.po index 4a2bf07608e..2ac99a0c25e 100644 --- a/library/dataclasses.po +++ b/library/dataclasses.po @@ -1,10 +1,10 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-08-21 00:15+0000\n" +"POT-Creation-Date: 2025-10-08 00:15+0000\n" "PO-Revision-Date: 2023-02-11 15:02+0800\n" "Last-Translator: \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -72,6 +72,11 @@ msgid "" " self.unit_price = unit_price\n" " self.quantity_on_hand = quantity_on_hand" msgstr "" +"def __init__(self, name: str, unit_price: float, quantity_on_hand: int = " +"0):\n" +" self.name = name\n" +" self.unit_price = unit_price\n" +" self.quantity_on_hand = quantity_on_hand" #: ../../library/dataclasses.rst:41 #, fuzzy @@ -171,17 +176,15 @@ msgid "The parameters to ``@dataclass`` are:" msgstr "``@dataclass`` 的參數是:" #: ../../library/dataclasses.rst:89 -#, fuzzy msgid "" "*init*: If true (the default), a :meth:`~object.__init__` method will be " "generated." msgstr "*init*:如果為真(預設值),將生成一個 :meth:`~object.__init__` 方法。" #: ../../library/dataclasses.rst:92 -#, fuzzy msgid "" "If the class already defines :meth:`!__init__`, this parameter is ignored." -msgstr "如果該類別已經定義了 :meth:`!__init__`,則忽略此參數。" +msgstr "如果該類別已經定義了 :meth:`!__init__`,則此參數會被忽略。" #: ../../library/dataclasses.rst:95 #, fuzzy @@ -249,7 +252,7 @@ msgid "" "generate a :meth:`~object.__hash__` method according to how *eq* and " "*frozen* are set. The default value is ``False``." msgstr "" -"*unsafe_hash*:如果 ``False``(預設值),將根據 *eq* 和 *frozen* 的設定生成一" +"*unsafe_hash*:如果 ``False``\\ (預設值),將根據 *eq* 和 *frozen* 的設定生成一" "個 :meth:`~object.__hash__` 方法。" #: ../../library/dataclasses.rst:130 @@ -262,7 +265,7 @@ msgid "" "and behavior of :meth:`!__eq__`, and the values of the *eq* and *frozen* " "flags in the ``@dataclass`` decorator." msgstr "" -":meth:`!__hash__` 由內建的 :meth:`hash` 使用,當對像被新增到散列集合(如字典" +":meth:`!__hash__` 由內建的 :meth:`hash` 使用,當物件被新增到雜湊集合(如字典" "和集合)時。擁有 :meth:`!__hash__` 意味著該類別的實例是不可變的。可變性是一個" "複雜的屬性,它取決於程序員的意圖 :meth:`!__eq__` 的存在和行為,以及 " "dataclass 裝飾器中的 *eq* 和 *frozen* 旗標的值." @@ -320,10 +323,10 @@ msgid "" "id-based hashing)." msgstr "" "如果 *eq* 和 *frozen* 都為真,預設情況下 ``@dataclass`` 會為你生成一個 :meth:" -"`!__hash__` 方法。如果 *eq* 為真且 *frozen* 為假,:meth:`!__hash__` 將被" -"設定為 ``None``,並將其標記為不可雜湊(因為它是可變的)。如果 " -"*eq* 為假,:meth:`!__hash__` 將保持不變,這意味著將使用超類別的 :meth:`!" -"__hash__` 方法(如果超類別是 :class:`object`,這意味著它將回退到基於 id 的雜湊)。" +"`!__hash__` 方法。如果 *eq* 為真且 *frozen* 為假,:meth:`!__hash__` 將被設定" +"為 ``None``,並將其標記為不可雜湊(因為它是可變的)。如果 *eq* 為假,:meth:`!" +"__hash__` 將保持不變,這意味著將使用超類別的 :meth:`!__hash__` 方法(如果超類" +"別是 :class:`object`,這意味著它將回退到基於 id 的雜湊)。" #: ../../library/dataclasses.rst:163 #, fuzzy @@ -392,18 +395,6 @@ msgstr "" "則 :exc:`TypeError` 被引發。" #: ../../library/dataclasses.rst:197 -#, fuzzy -msgid "" -"Calling no-arg :func:`super` in dataclasses using ``slots=True`` will result " -"in the following exception being raised: ``TypeError: super(type, obj): obj " -"must be an instance or subtype of type``. The two-arg :func:`super` is a " -"valid workaround. See :gh:`90562` for full details." -msgstr "" -"``slots``:如果為 true(預設為 ``False``),將生成 :attr:`~object.__slots__` " -"屬性並回傳新類別而不是原始類別。如果 :attr:`!__slots__` 已經在類別中定義," -"則 :exc:`TypeError` 被引發。" - -#: ../../library/dataclasses.rst:204 msgid "" "Passing parameters to a base class :meth:`~object.__init_subclass__` when " "using ``slots=True`` will result in a :exc:`TypeError`. Either use " @@ -411,7 +402,7 @@ msgid "" "workaround. See :gh:`91126` for full details." msgstr "" -#: ../../library/dataclasses.rst:212 +#: ../../library/dataclasses.rst:205 #, fuzzy msgid "" "If a field name is already included in the :attr:`!__slots__` of a base " @@ -427,7 +418,7 @@ msgstr "" "夠確定繼承的插槽,基底類別 :attr:`!__slots__` 可以是任何可疊代的,但*不是*疊" "代器。" -#: ../../library/dataclasses.rst:222 +#: ../../library/dataclasses.rst:215 #, fuzzy msgid "" "*weakref_slot*: If true (the default is ``False``), add a slot named " @@ -439,14 +430,14 @@ msgstr "" "插槽,這是使實例可弱引用所必需的。在沒有指定 ``slots=True`` 的情況下指定 " "``weakref_slot=True`` 是錯誤的。" -#: ../../library/dataclasses.rst:230 +#: ../../library/dataclasses.rst:223 #, fuzzy msgid "" "``field``\\s may optionally specify a default value, using normal Python " "syntax::" msgstr "``field``\\s 可以選擇指定一個預設值,使用普通的 Python 語法: ::" -#: ../../library/dataclasses.rst:233 +#: ../../library/dataclasses.rst:226 msgid "" "@dataclass\n" "class C:\n" @@ -454,7 +445,7 @@ msgid "" " b: int = 0 # assign a default value for 'b'" msgstr "" -#: ../../library/dataclasses.rst:238 +#: ../../library/dataclasses.rst:231 #, fuzzy msgid "" "In this example, both :attr:`!a` and :attr:`!b` will be included in the " @@ -463,11 +454,11 @@ msgstr "" "在此示例中,:attr:`!a` 和 :attr:`!b` 都將包含在新增的 :meth:`~object." "__init__` 方法中,該方法將定義為: ::" -#: ../../library/dataclasses.rst:241 +#: ../../library/dataclasses.rst:234 msgid "def __init__(self, a: int, b: int = 0):" msgstr "def __init__(self, a: int, b: int = 0):" -#: ../../library/dataclasses.rst:243 +#: ../../library/dataclasses.rst:236 #, fuzzy msgid "" ":exc:`TypeError` will be raised if a field without a default value follows a " @@ -477,7 +468,7 @@ msgstr "" ":exc:`TypeError` 如果沒有預設值的欄位跟在具有預設值的欄位之後,將引發。無論這" "發生在單個類別中還是作為類別繼承的結果,都是如此。" -#: ../../library/dataclasses.rst:249 +#: ../../library/dataclasses.rst:242 #, fuzzy msgid "" "For common and simple use cases, no other functionality is required. There " @@ -490,7 +481,7 @@ msgstr "" "位資訊。為了滿足這種對附加資訊的需求,你可以通過呼叫提供的 :func:`!field` 函" "式來替換預設欄位值。例如: ::" -#: ../../library/dataclasses.rst:255 +#: ../../library/dataclasses.rst:248 msgid "" "@dataclass\n" "class C:\n" @@ -506,7 +497,7 @@ msgstr "" "c = C()\n" "c.mylist += [1, 2, 3]" -#: ../../library/dataclasses.rst:262 +#: ../../library/dataclasses.rst:255 #, fuzzy msgid "" "As shown above, the :const:`MISSING` value is a sentinel object used to " @@ -518,20 +509,20 @@ msgstr "" "供。使用此標記是因為 ``None`` 對於某些具有不同含義的參數是有效值。任何程式碼" "都不應直接使用 :const:`MISSING` 值。" -#: ../../library/dataclasses.rst:267 +#: ../../library/dataclasses.rst:260 msgid "The parameters to :func:`!field` are:" msgstr ":func:`!field` 的參數是:" -#: ../../library/dataclasses.rst:269 +#: ../../library/dataclasses.rst:262 msgid "" "*default*: If provided, this will be the default value for this field. This " "is needed because the :func:`!field` call itself replaces the normal " "position of the default value." msgstr "" -"*default*:如果有提供,這將是該欄位的預設值。這是必需的,因為 :meth:`!field` 呼" -"叫本身會替換預設值的正常位置。" +"*default*:如果有提供,這將是該欄位的預設值。這是必需的,因為 :meth:`!field` " +"呼叫本身會替換預設值的正常位置。" -#: ../../library/dataclasses.rst:273 +#: ../../library/dataclasses.rst:266 #, fuzzy msgid "" "*default_factory*: If provided, it must be a zero-argument callable that " @@ -544,7 +535,7 @@ msgstr "" "時將被呼叫。除其他用途外,這可用於指定具有可變預設值的欄位,如下所述。同時指" "定 *default* 和 *default_factory* 是錯誤的。" -#: ../../library/dataclasses.rst:279 +#: ../../library/dataclasses.rst:272 #, fuzzy msgid "" "*init*: If true (the default), this field is included as a parameter to the " @@ -553,7 +544,7 @@ msgstr "" "*init*:如果為 true(預設值),則此欄位將作為生成的 :meth:`~object.__init__` " "方法的參數包含在內。" -#: ../../library/dataclasses.rst:282 +#: ../../library/dataclasses.rst:275 #, fuzzy msgid "" "*repr*: If true (the default), this field is included in the string returned " @@ -562,7 +553,7 @@ msgstr "" "*repr*:如果為真(預設值),則此欄位包含在生成的 :meth:`~object.__repr__` 方" "法回傳的字串中。" -#: ../../library/dataclasses.rst:285 +#: ../../library/dataclasses.rst:278 #, fuzzy msgid "" "*hash*: This can be a bool or ``None``. If true, this field is included in " @@ -578,7 +569,7 @@ msgstr "" "是預期的行為。如果一個欄位用於比較,則應在雜湊中考慮該欄位。不鼓勵將此值設定" "為 ``None`` 以外的任何值。" -#: ../../library/dataclasses.rst:293 +#: ../../library/dataclasses.rst:286 #, fuzzy msgid "" "One possible reason to set ``hash=False`` but ``compare=True`` would be if a " @@ -591,7 +582,7 @@ msgstr "" "湊值的成本很高,則需要該欄位進行相等性測試,並且還有其他欄位有助於型別的雜湊" "值。即使一個欄位被排除在雜湊之外,它仍然會被用於比較。" -#: ../../library/dataclasses.rst:299 +#: ../../library/dataclasses.rst:292 #, fuzzy msgid "" "*compare*: If true (the default), this field is included in the generated " @@ -601,7 +592,7 @@ msgstr "" "*compare*:如果為真(預設值),則此欄位包含在生成的相等和比較方法中(:meth:" "`~object.__eq__`、:meth:`~object.__gt__` 等)。" -#: ../../library/dataclasses.rst:303 +#: ../../library/dataclasses.rst:296 #, fuzzy msgid "" "*metadata*: This can be a mapping or ``None``. ``None`` is treated as an " @@ -612,11 +603,11 @@ msgid "" "namespace in the metadata." msgstr "" "*metadata*:這可以是對映或無。 None 被視為空字典。此值包含在 :func:`~types." -"MappingProxyType` 中以使其成為只讀的,並暴露在 :class:`Field` 對像上。它根本" +"MappingProxyType` 中以使其成為只讀的,並暴露在 :class:`Field` 物件上。它根本" "不被資料類別使用,而是作為第三方擴充機制提供的。多個第三方可以各自擁有自己的" "密鑰,用作元資料中的命名空間。" -#: ../../library/dataclasses.rst:311 +#: ../../library/dataclasses.rst:304 #, fuzzy msgid "" "*kw_only*: If true, this field will be marked as keyword-only. This is used " @@ -625,27 +616,31 @@ msgstr "" "*kw_only*:如果為真,該欄位將被標記為僅限關鍵字。這在計算生成的 :meth:" "`~object.__init__` 方法的參數時使用。" -#: ../../library/dataclasses.rst:315 +#: ../../library/dataclasses.rst:308 msgid "Keyword-only fields are also not included in :attr:`!__match_args__`." msgstr "" -#: ../../library/dataclasses.rst:319 +#: ../../library/dataclasses.rst:312 +msgid "*doc*: optional docstring for this field." +msgstr "" + +#: ../../library/dataclasses.rst:316 #, fuzzy msgid "" "If the default value of a field is specified by a call to :func:`!field`, " "then the class attribute for this field will be replaced by the specified " "*default* value. If *default* is not provided, then the class attribute " -"will be deleted. The intent is that after the :func:`@dataclass " -"` decorator runs, the class attributes will all contain the " -"default values for the fields, just as if the default value itself were " -"specified. For example, after::" +"will be deleted. The intent is that after the :deco:`dataclass` decorator " +"runs, the class attributes will all contain the default values for the " +"fields, just as if the default value itself were specified. For example, " +"after::" msgstr "" "如果欄位的預設值是通過呼叫 :func:`!field` 指定的,那麼該欄位的類別屬性將被指" "定的 *default* 值替換。如果沒有提供 *default*,那麼類別屬性將被刪除。目的是" "在 :func:`@dataclass ` 裝飾器運行後,類別屬性將全部包含欄位的預設" "值,就像預設值本身已指定一樣。例如,在: ::" -#: ../../library/dataclasses.rst:328 +#: ../../library/dataclasses.rst:325 msgid "" "@dataclass\n" "class C:\n" @@ -661,7 +656,7 @@ msgstr "" " z: int = field(repr=False, default=10)\n" " t: int = 20" -#: ../../library/dataclasses.rst:335 +#: ../../library/dataclasses.rst:332 #, fuzzy msgid "" "The class attribute :attr:`!C.z` will be ``10``, the class attribute :attr:`!" @@ -671,7 +666,7 @@ msgstr "" "類別屬性 :attr:`!C.z` 將為 ``10``,類別屬性 :attr:`!C.t` 將為 ``20``,類別屬" "性 :attr:`!C.x` 和 :attr:`!C.y` 將不會放。" -#: ../../library/dataclasses.rst:341 +#: ../../library/dataclasses.rst:338 #, fuzzy msgid "" ":class:`!Field` objects describe each defined field. These objects are " @@ -679,19 +674,19 @@ msgid "" "method (see below). Users should never instantiate a :class:`!Field` object " "directly. Its documented attributes are:" msgstr "" -":class:`!Field` 物件描述每個定義的欄位。這些對像在內部建立,並由 :func:" +":class:`!Field` 物件描述每個定義的欄位。這些物件在內部建立,並由 :func:" "`fields` 模組級方法回傳(見下文)。使用者不應該直接實例化 :class:`!Field` 物" "件。它記錄的屬性是:" -#: ../../library/dataclasses.rst:346 +#: ../../library/dataclasses.rst:343 msgid ":attr:`!name`: The name of the field." msgstr ":attr:`!name`:欄位的名稱。" -#: ../../library/dataclasses.rst:347 +#: ../../library/dataclasses.rst:344 msgid ":attr:`!type`: The type of the field." msgstr ":attr:`!type`:欄位的型別。" -#: ../../library/dataclasses.rst:348 +#: ../../library/dataclasses.rst:345 #, fuzzy msgid "" ":attr:`!default`, :attr:`!default_factory`, :attr:`!init`, :attr:`!repr`, :" @@ -702,14 +697,14 @@ msgstr "" "attr:`!hash`、:attr:`!compare`, :attr:`!metadata` 和 :attr:`!kw_only` 有與它" "們在 :func:`field` 函式中的含義和值相同。" -#: ../../library/dataclasses.rst:352 +#: ../../library/dataclasses.rst:349 #, fuzzy msgid "" "Other attributes may exist, but they are private and must not be inspected " "or relied on." msgstr "可能存在其他屬性,但它們是私有的,不得檢查或依賴。" -#: ../../library/dataclasses.rst:357 +#: ../../library/dataclasses.rst:354 msgid "" "``InitVar[T]`` type annotations describe variables that are :ref:`init-only " "`. Fields annotated with :class:`!InitVar` " @@ -718,7 +713,7 @@ msgid "" "meth:`~object.__init__` and an optional :meth:`__post_init__`." msgstr "" -#: ../../library/dataclasses.rst:366 +#: ../../library/dataclasses.rst:363 #, fuzzy msgid "" "Returns a tuple of :class:`Field` objects that define the fields for this " @@ -730,7 +725,7 @@ msgstr "" "實例。如果未傳遞資料類別或其中一個實例,則引發 :exc:`TypeError`。不回傳 " "``ClassVar`` 或 ``InitVar`` 的偽欄位。" -#: ../../library/dataclasses.rst:373 +#: ../../library/dataclasses.rst:370 #, fuzzy msgid "" "Converts the dataclass *obj* to a dict (by using the factory function " @@ -742,12 +737,12 @@ msgstr "" "都被轉換為其欄位的字典,作為 ``name: value`` 對。資料類別、字典、列表和元組被" "遞迴到。其他物件使用 :func:`copy.deepcopy` 複製。" -#: ../../library/dataclasses.rst:379 +#: ../../library/dataclasses.rst:376 #, fuzzy msgid "Example of using :func:`!asdict` on nested dataclasses::" msgstr "在嵌套資料類別上使用 :func:`!asdict` 的範例: ::" -#: ../../library/dataclasses.rst:381 +#: ../../library/dataclasses.rst:378 msgid "" "@dataclass\n" "class Point:\n" @@ -779,22 +774,22 @@ msgstr "" "c = C([Point(0, 0), Point(10, 4)])\n" "assert asdict(c) == {'mylist': [{'x': 0, 'y': 0}, {'x': 10, 'y': 4}]}" -#: ../../library/dataclasses.rst:396 ../../library/dataclasses.rst:416 +#: ../../library/dataclasses.rst:393 ../../library/dataclasses.rst:413 #, fuzzy msgid "To create a shallow copy, the following workaround may be used::" msgstr "要建立淺複製,可以使用以下解決方法:" -#: ../../library/dataclasses.rst:398 +#: ../../library/dataclasses.rst:395 msgid "{field.name: getattr(obj, field.name) for field in fields(obj)}" -msgstr "" +msgstr "{field.name: getattr(obj, field.name) for field in fields(obj)}" -#: ../../library/dataclasses.rst:400 +#: ../../library/dataclasses.rst:397 #, fuzzy msgid "" ":func:`!asdict` raises :exc:`TypeError` if *obj* is not a dataclass instance." msgstr ":func:`!asdict` 如果 *obj* 不是資料類別實例,則引發 :exc:`TypeError`。" -#: ../../library/dataclasses.rst:405 +#: ../../library/dataclasses.rst:402 #, fuzzy msgid "" "Converts the dataclass *obj* to a tuple (by using the factory function " @@ -806,11 +801,11 @@ msgstr "" "都被轉換為其欄位值的元組。資料類別、字典、列表和元組被遞迴到。其他物件使用 :" "func:`copy.deepcopy` 複製。" -#: ../../library/dataclasses.rst:411 +#: ../../library/dataclasses.rst:408 msgid "Continuing from the previous example::" msgstr "從前面的例子繼續: ::" -#: ../../library/dataclasses.rst:413 +#: ../../library/dataclasses.rst:410 msgid "" "assert astuple(p) == (10, 20)\n" "assert astuple(c) == ([(0, 0), (10, 4)],)" @@ -818,11 +813,11 @@ msgstr "" "assert astuple(p) == (10, 20)\n" "assert astuple(c) == ([(0, 0), (10, 4)],)" -#: ../../library/dataclasses.rst:418 +#: ../../library/dataclasses.rst:415 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:420 +#: ../../library/dataclasses.rst:417 #, fuzzy msgid "" ":func:`!astuple` raises :exc:`TypeError` if *obj* is not a dataclass " @@ -830,7 +825,7 @@ msgid "" msgstr "" ":func:`!astuple` 如果 *obj* 不是資料類別實例,則引發 :exc:`TypeError`。" -#: ../../library/dataclasses.rst:425 +#: ../../library/dataclasses.rst:422 #, fuzzy msgid "" "Creates a new dataclass with name *cls_name*, fields as defined in *fields*, " @@ -839,8 +834,8 @@ msgid "" "``name``, ``(name, type)``, or ``(name, type, Field)``. If just ``name`` is " "supplied, :data:`typing.Any` is used for ``type``. The values of *init*, " "*repr*, *eq*, *order*, *unsafe_hash*, *frozen*, *match_args*, *kw_only*, " -"*slots*, and *weakref_slot* have the same meaning as they do in :func:" -"`@dataclass `." +"*slots*, and *weakref_slot* have the same meaning as they do in :deco:" +"`dataclass`." msgstr "" "建立一個名為 *cls_name* 的新資料類別,欄位在 *fields* 中定義,基底類別在 " "*bases* 中給出,並使用 *namespace* 中給出的命名空間進行初始化。 ``fields`` 是" @@ -850,25 +845,33 @@ msgstr "" "``kw_only`` 的值, ``slots`` 和 ``weakref_slot`` 與它們在 :func:`dataclass` 中" "的含義相同。" -#: ../../library/dataclasses.rst:435 +#: ../../library/dataclasses.rst:432 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:439 +#: ../../library/dataclasses.rst:436 +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 " +"keyword arguments as :deco:`dataclass`. By default, the :deco:`dataclass` " +"function is used." +msgstr "" + +#: ../../library/dataclasses.rst:441 #, fuzzy msgid "" "This function is not strictly required, because any Python mechanism for " -"creating a new class with :attr:`!__annotations__` can then apply the :func:" -"`@dataclass ` function to convert that class to a dataclass. " -"This function is provided as a convenience. For example::" +"creating a new class with :attr:`~object.__annotations__` can then apply " +"the :deco:`dataclass` function to convert that class to a dataclass. This " +"function is provided as a convenience. For example::" msgstr "" -"這個函式不是嚴格要求的,因為任何使用 ``__annotations__`` 建立新類別的 Python " -"機制都可以應用 :func:`dataclass` 函式將該類別轉換為資料類別。提供此功能是為了" -"方便。例如: ::" +"這個函式不是嚴格要求的,因為任何使用 :attr:`~object.__annotations__` 建立新類" +"別的 Python 機制都可以應用 :func:`dataclass` 函式將該類別轉換為資料類別。提供" +"此功能是為了方便。例如: ::" -#: ../../library/dataclasses.rst:445 +#: ../../library/dataclasses.rst:447 msgid "" "C = make_dataclass('C',\n" " [('x', int),\n" @@ -882,11 +885,11 @@ msgstr "" " ('z', int, field(default=5))],\n" " namespace={'add_one': lambda self: self.x + 1})" -#: ../../library/dataclasses.rst:451 +#: ../../library/dataclasses.rst:453 msgid "Is equivalent to::" msgstr "相當於: ::" -#: ../../library/dataclasses.rst:453 +#: ../../library/dataclasses.rst:455 msgid "" "@dataclass\n" "class C:\n" @@ -899,6 +902,10 @@ msgid "" msgstr "" #: ../../library/dataclasses.rst:464 +msgid "Added the *decorator* parameter." +msgstr "" + +#: ../../library/dataclasses.rst:469 #, fuzzy msgid "" "Creates a new object of the same type as *obj*, replacing fields with values " @@ -910,17 +917,17 @@ msgstr "" "``obj`` 不是資料類別,則引發 :exc:`TypeError`。如果 ``changes`` 中的值未指定" "欄位,則引發 :exc:`TypeError`。" -#: ../../library/dataclasses.rst:469 +#: ../../library/dataclasses.rst:474 #, fuzzy msgid "" "The newly returned object is created by calling the :meth:`~object.__init__` " "method of the dataclass. This ensures that :meth:`__post_init__`, if " "present, is also called." msgstr "" -"新回傳的對像是通過呼叫資料類別的 :meth:`~object.__init__` 方法建立的。這確" -"保 :meth:`__post_init__`(如果存在)也被呼叫。" +"新回傳的物件是通過呼叫資料類別的 :meth:`~object.__init__` 方法建立的。這確" +"保 :meth:`__post_init__`\\ (如果存在)也被呼叫。" -#: ../../library/dataclasses.rst:473 +#: ../../library/dataclasses.rst:478 #, fuzzy msgid "" "Init-only variables without default values, if any exist, must be specified " @@ -930,7 +937,7 @@ msgstr "" "沒有預設值的僅初始化變數(如果存在)必須在呼叫 :func:`replace` 時指定,以便它" "們可以傳遞給 :meth:`__init__` 和 :meth:`__post_init__`。" -#: ../../library/dataclasses.rst:477 +#: ../../library/dataclasses.rst:482 #, fuzzy msgid "" "It is an error for *changes* to contain any fields that are defined as " @@ -939,7 +946,7 @@ msgstr "" "*changes* 包含任何定義為具有 ``init=False`` 的欄位是錯誤的。在這種情況下將引" "發 :exc:`ValueError`。" -#: ../../library/dataclasses.rst:481 +#: ../../library/dataclasses.rst:486 #, fuzzy msgid "" "Be forewarned about how ``init=False`` fields work during a call to :func:`!" @@ -956,21 +963,20 @@ msgstr "" "建構函式可能是明智的,或者可能是處理實例複製的自定義:func:`!replace` (或類似" "命名的)方法。" -#: ../../library/dataclasses.rst:490 +#: ../../library/dataclasses.rst:495 msgid "" "Dataclass instances are also supported by generic function :func:`copy." "replace`." msgstr "" -#: ../../library/dataclasses.rst:494 -#, fuzzy +#: ../../library/dataclasses.rst:499 msgid "" "Return ``True`` if its parameter is a dataclass (including subclasses of a " "dataclass) or an instance of one, otherwise return ``False``." msgstr "" -"如果它的參數是一個資料類別或一個實例,則回傳 ``True``,否則回傳 ``False``。" +"如果它的參數是一個資料類別(包含一個資料類別的子類別)或一個實例則回傳 ``True``,否則回傳 ``False``。" -#: ../../library/dataclasses.rst:497 +#: ../../library/dataclasses.rst:502 #, fuzzy msgid "" "If you need to know if a class is an instance of a dataclass (and not a " @@ -980,18 +986,20 @@ msgstr "" "如果你需要知道一個類別是否是資料類別的實例(而不是資料類別本身),那麼新增一" "個進一步的檢查 ``not isinstance(obj, type)``: ::" -#: ../../library/dataclasses.rst:501 +#: ../../library/dataclasses.rst:506 msgid "" "def is_dataclass_instance(obj):\n" " return is_dataclass(obj) and not isinstance(obj, type)" msgstr "" +"def is_dataclass_instance(obj):\n" +" return is_dataclass(obj) and not isinstance(obj, type)" -#: ../../library/dataclasses.rst:506 +#: ../../library/dataclasses.rst:511 #, fuzzy msgid "A sentinel value signifying a missing default or default_factory." msgstr "表示缺少 default 或 default_factory 的標記值。" -#: ../../library/dataclasses.rst:510 +#: ../../library/dataclasses.rst:515 #, fuzzy msgid "" "A sentinel value used as a type annotation. Any fields after a pseudo-field " @@ -1007,14 +1015,14 @@ msgstr "" "類欄位的名稱。按照慣例,名稱 ``_`` 用於 :const:`!KW_ONLY` 欄位。僅關鍵字欄位" "表示 :meth:`~object.__init__` 參數,在實例化類別時必須將其指定為關鍵字。" -#: ../../library/dataclasses.rst:519 +#: ../../library/dataclasses.rst:524 #, fuzzy msgid "" "In this example, the fields ``y`` and ``z`` will be marked as keyword-only " "fields::" msgstr "在此示例中,欄位 ``y`` 和 ``z`` 將被標記為僅關鍵字欄位: ::" -#: ../../library/dataclasses.rst:521 +#: ../../library/dataclasses.rst:526 msgid "" "@dataclass\n" "class Point:\n" @@ -1034,14 +1042,14 @@ msgstr "" "\n" "p = Point(0, y=1.5, z=2.0)" -#: ../../library/dataclasses.rst:530 +#: ../../library/dataclasses.rst:535 #, 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:537 +#: ../../library/dataclasses.rst:542 #, fuzzy msgid "" "Raised when an implicitly defined :meth:`~object.__setattr__` or :meth:" @@ -1051,12 +1059,12 @@ msgstr "" "當在使用 frozen=True 定義的資料類別上呼叫隱式定義的 :meth:`__setattr__` 或 :" "meth:`__delattr__` 時引發。它是 :exc:`AttributeError` 的子類別。" -#: ../../library/dataclasses.rst:544 +#: ../../library/dataclasses.rst:549 #, fuzzy msgid "Post-init processing" -msgstr "初始化後處理" +msgstr "後初始化處理" -#: ../../library/dataclasses.rst:548 +#: ../../library/dataclasses.rst:553 #, fuzzy msgid "" "When defined on the class, it will be called by the generated :meth:`~object." @@ -1072,14 +1080,14 @@ msgstr "" "將按照它們在類別中定義的順序傳遞給 :meth:`!__post_init__` 。如果沒有生成 :" "meth:`!__init__` 方法,那麼 :meth:`!__post_init__` 將不會被自動呼叫。" -#: ../../library/dataclasses.rst:555 +#: ../../library/dataclasses.rst:560 #, 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:558 +#: ../../library/dataclasses.rst:563 msgid "" "@dataclass\n" "class C:\n" @@ -1099,19 +1107,19 @@ msgstr "" " def __post_init__(self):\n" " self.c = self.a + self.b" -#: ../../library/dataclasses.rst:567 +#: ../../library/dataclasses.rst:572 #, fuzzy msgid "" -"The :meth:`~object.__init__` method generated by :func:`@dataclass " -"` does not call base class :meth:`!__init__` methods. If the base " -"class has an :meth:`!__init__` method that has to be called, it is common to " -"call this method in a :meth:`__post_init__` method::" +"The :meth:`~object.__init__` method generated by :deco:`dataclass` does not " +"call base class :meth:`!__init__` methods. If the base class has an :meth:`!" +"__init__` method that has to be called, it is common to call this method in " +"a :meth:`__post_init__` method::" msgstr "" ":func:`@dataclass ` 生成的 :meth:`~object.__init__` 方法不呼叫基底" "類別 :meth:`!__init__` 方法。如果基底類別有一個必須呼叫的 :meth:`!__init__` " "方法,通常在 :meth:`__post_init__` 方法中呼叫此方法: ::" -#: ../../library/dataclasses.rst:572 +#: ../../library/dataclasses.rst:577 msgid "" "class Rectangle:\n" " def __init__(self, height, width):\n" @@ -1137,7 +1145,7 @@ msgstr "" " def __post_init__(self):\n" " super().__init__(self.side, self.side)" -#: ../../library/dataclasses.rst:584 +#: ../../library/dataclasses.rst:589 #, fuzzy msgid "" "Note, however, that in general the dataclass-generated :meth:`!__init__` " @@ -1147,7 +1155,7 @@ msgstr "" "但是請注意,通常不需要呼叫資料類別生成的 :meth:`!__init__` 方法,因為衍生資料" "類別將負責初始化作為資料類別本身的任何基底類別的所有欄位。" -#: ../../library/dataclasses.rst:588 +#: ../../library/dataclasses.rst:593 #, fuzzy msgid "" "See the section below on init-only variables for ways to pass parameters to :" @@ -1157,20 +1165,19 @@ msgstr "" "請參閱下面有關僅初始化變數的部分,了解將參數傳遞給 :meth:`!__post_init__` 的" "方法。另請參閱有關 :func:`replace` 如何處理 ``init=False`` 欄位的警告。" -#: ../../library/dataclasses.rst:595 +#: ../../library/dataclasses.rst:600 msgid "Class variables" msgstr "類別變數" -#: ../../library/dataclasses.rst:597 +#: ../../library/dataclasses.rst:602 #, fuzzy msgid "" -"One of the few places where :func:`@dataclass ` actually inspects " -"the type of a field is to determine if a field is a class variable as " -"defined in :pep:`526`. It does this by checking if the type of the field " -"is :data:`typing.ClassVar`. If a field is a ``ClassVar``, it is excluded " -"from consideration as a field and is ignored by the dataclass mechanisms. " -"Such ``ClassVar`` pseudo-fields are not returned by the module-level :func:" -"`fields` function." +"One of the few places where :deco:`dataclass` actually inspects the type of " +"a field is to determine if a field is a class variable as defined in :pep:" +"`526`. It does this by checking if the type of the field is :data:`typing." +"ClassVar`. If a field is a ``ClassVar``, it is excluded from consideration " +"as a field and is ignored by the dataclass mechanisms. Such ``ClassVar`` " +"pseudo-fields are not returned by the module-level :func:`fields` function." msgstr "" ":func:`@dataclass ` 實際檢查欄位型別的少數地方之一是確定欄位是否" "是 :pep:`526` 中定義的類別變數。它通過檢查欄位的型別是否為 :data:`typing." @@ -1178,23 +1185,22 @@ msgstr "" "外,並被資料類別機制忽略。模組級 :func:`fields` 函式不會回傳此類別 " "``ClassVar`` 偽欄位。" -#: ../../library/dataclasses.rst:608 +#: ../../library/dataclasses.rst:613 #, fuzzy msgid "Init-only variables" msgstr "僅初始化變數" -#: ../../library/dataclasses.rst:610 +#: ../../library/dataclasses.rst:615 #, fuzzy msgid "" -"Another place where :func:`@dataclass ` inspects a type " -"annotation is to determine if a field is an init-only variable. It does " -"this by seeing if the type of a field is of type :class:`InitVar`. If a " -"field is an :class:`InitVar`, it is considered a pseudo-field called an init-" -"only field. As it is not a true field, it is not returned by the module-" -"level :func:`fields` function. Init-only fields are added as parameters to " -"the generated :meth:`~object.__init__` method, and are passed to the " -"optional :meth:`__post_init__` method. They are not otherwise used by " -"dataclasses." +"Another place where :deco:`dataclass` inspects a type annotation is to " +"determine if a field is an init-only variable. It does this by seeing if " +"the type of a field is of type :class:`InitVar`. If a field is an :class:" +"`InitVar`, it is considered a pseudo-field called an init-only field. As it " +"is not a true field, it is not returned by the module-level :func:`fields` " +"function. Init-only fields are added as parameters to the generated :meth:" +"`~object.__init__` method, and are passed to the optional :meth:" +"`__post_init__` method. They are not otherwise used by dataclasses." msgstr "" ":func:`dataclass` 檢查型別註解的另一個地方是確定欄位是否是僅初始化變數。它通" "過查看欄位的型別是否為 ``dataclasses.InitVar`` 型別來執行此操作。如果一個欄位" @@ -1203,14 +1209,14 @@ msgstr "" "的 :meth:`~object.__init__` 方法,並傳遞給可選的 :meth:`__post_init__` 方法。" "它們不被資料類別使用。" -#: ../../library/dataclasses.rst:620 +#: ../../library/dataclasses.rst:625 #, 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:623 +#: ../../library/dataclasses.rst:628 msgid "" "@dataclass\n" "class C:\n" @@ -1236,7 +1242,7 @@ msgstr "" "\n" "c = C(10, database=my_database)" -#: ../../library/dataclasses.rst:635 +#: ../../library/dataclasses.rst:640 #, fuzzy msgid "" "In this case, :func:`fields` will return :class:`Field` objects for :attr:`!" @@ -1245,16 +1251,16 @@ msgstr "" "在這種情況下,:func:`fields` 將為 :attr:`!i` 和 :attr:`!j` 回傳 :class:" "`Field` 物件,但不會為 :attr:`!database` 回傳。" -#: ../../library/dataclasses.rst:641 +#: ../../library/dataclasses.rst:646 msgid "Frozen instances" msgstr "凍結實例" -#: ../../library/dataclasses.rst:643 +#: ../../library/dataclasses.rst:648 #, fuzzy msgid "" "It is not possible to create truly immutable Python objects. However, by " -"passing ``frozen=True`` to the :func:`@dataclass ` decorator you " -"can emulate immutability. In that case, dataclasses will add :meth:`~object." +"passing ``frozen=True`` to the :deco:`dataclass` decorator you can emulate " +"immutability. In that case, dataclasses will add :meth:`~object." "__setattr__` and :meth:`~object.__delattr__` methods to the class. These " "methods will raise a :exc:`FrozenInstanceError` when invoked." msgstr "" @@ -1263,7 +1269,7 @@ msgstr "" "別將向類別新增 :meth:`~object.__setattr__` 和 :meth:`~object.__delattr__` 方" "法。這些方法在叫用時會引發 :exc:`FrozenInstanceError`。" -#: ../../library/dataclasses.rst:649 +#: ../../library/dataclasses.rst:654 #, fuzzy msgid "" "There is a tiny performance penalty when using ``frozen=True``: :meth:" @@ -1273,21 +1279,21 @@ msgstr "" "使用 ``frozen=True`` 時有一個微小的性能損失::meth:`~object.__init__` 不能使" "用簡單賦值來初始化欄位,必須使用 :meth:`!object.__setattr__`。" -#: ../../library/dataclasses.rst:658 +#: ../../library/dataclasses.rst:663 msgid "Inheritance" msgstr "繼承" -#: ../../library/dataclasses.rst:660 +#: ../../library/dataclasses.rst:665 #, fuzzy msgid "" -"When the dataclass is being created by the :func:`@dataclass ` " -"decorator, it looks through all of the class's base classes in reverse MRO " -"(that is, starting at :class:`object`) and, for each dataclass that it " -"finds, adds the fields from that base class to an ordered mapping of fields. " -"After all of the base class fields are added, it adds its own fields to the " -"ordered mapping. All of the generated methods will use this combined, " -"calculated ordered mapping of fields. Because the fields are in insertion " -"order, derived classes override base classes. An example::" +"When the dataclass is being created by the :deco:`dataclass` decorator, it " +"looks through all of the class's base classes in reverse MRO (that is, " +"starting at :class:`object`) and, for each dataclass that it finds, adds the " +"fields from that base class to an ordered mapping of fields. After all of " +"the base class fields are added, it adds its own fields to the ordered " +"mapping. All of the generated methods will use this combined, calculated " +"ordered mapping of fields. Because the fields are in insertion order, " +"derived classes override base classes. An example::" msgstr "" "當 :func:`@dataclass ` 裝飾器建立資料類別時,它會以反向 MRO(即" "從 :class:`object` 開始)查看該類別的所有基底類別,並且對於它找到的每個資料類" @@ -1295,7 +1301,7 @@ msgstr "" "將自己的欄位新增到有序對映中。所有生成的方法都將使用這種組合的、計算的有序欄" "位對映。因為欄位是按插入順序排列的,所以衍生類別會覆蓋基底類別。一個例子: ::" -#: ../../library/dataclasses.rst:670 +#: ../../library/dataclasses.rst:675 msgid "" "@dataclass\n" "class Base:\n" @@ -1317,7 +1323,7 @@ msgstr "" " z: int = 10\n" " x: int = 15" -#: ../../library/dataclasses.rst:680 +#: ../../library/dataclasses.rst:685 #, fuzzy msgid "" "The final list of fields is, in order, :attr:`!x`, :attr:`!y`, :attr:`!z`. " @@ -1327,23 +1333,23 @@ msgstr "" "最終的欄位列表按順序為 :attr:`!x`、:attr:`!y`、:attr:`!z`。:attr:`!x` 的最終" "型別是 :class:`int`,如類別 :class:`!C` 中指定的那樣。" -#: ../../library/dataclasses.rst:683 +#: ../../library/dataclasses.rst:688 #, fuzzy msgid "" "The generated :meth:`~object.__init__` method for :class:`!C` will look " "like::" msgstr "為 :class:`!C` 生成的 :meth:`~object.__init__` 方法將如下所示: ::" -#: ../../library/dataclasses.rst:685 +#: ../../library/dataclasses.rst:690 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:688 +#: ../../library/dataclasses.rst:693 #, fuzzy msgid "Re-ordering of keyword-only parameters in :meth:`!__init__`" msgstr ":meth:`!__init__` 中僅關鍵字參數的重新排序" -#: ../../library/dataclasses.rst:690 +#: ../../library/dataclasses.rst:695 #, fuzzy msgid "" "After the parameters needed for :meth:`~object.__init__` are computed, any " @@ -1355,7 +1361,7 @@ msgstr "" "僅關鍵字)參數之後。這是如何在 Python 中實作僅關鍵字參數的要求:它們必須位於" "非僅關鍵字參數之後。" -#: ../../library/dataclasses.rst:696 +#: ../../library/dataclasses.rst:701 #, fuzzy msgid "" "In this example, :attr:`!Base.y`, :attr:`!Base.w`, and :attr:`!D.t` are " @@ -1365,7 +1371,7 @@ msgstr "" "在此示例中,:attr:`!Base.y`、:attr:`!Base.w` 和 :attr:`!D.t` 是僅限關鍵字的欄" "位,:attr:`!Base.x` 和 :attr:`!D.z` 是常規欄位: ::" -#: ../../library/dataclasses.rst:699 +#: ../../library/dataclasses.rst:704 msgid "" "@dataclass\n" "class Base:\n" @@ -1391,12 +1397,12 @@ msgstr "" " z: int = 10\n" " t: int = field(kw_only=True, default=0)" -#: ../../library/dataclasses.rst:711 +#: ../../library/dataclasses.rst:716 #, fuzzy msgid "The generated :meth:`!__init__` method for :class:`!D` will look like::" msgstr "為 :class:`!D` 生成的 :meth:`!__init__` 方法將如下所示: ::" -#: ../../library/dataclasses.rst:713 +#: ../../library/dataclasses.rst:718 msgid "" "def __init__(self, x: Any = 15.0, z: int = 10, *, y: int = 0, w: int = 1, t: " "int = 0):" @@ -1404,7 +1410,7 @@ msgstr "" "def __init__(self, x: Any = 15.0, z: int = 10, *, y: int = 0, w: int = 1, t: " "int = 0):" -#: ../../library/dataclasses.rst:715 +#: ../../library/dataclasses.rst:720 #, fuzzy msgid "" "Note that the parameters have been re-ordered from how they appear in the " @@ -1414,18 +1420,18 @@ msgstr "" "請注意,參數已根據它們在欄位列表中的顯示方式重新排序:從常規欄位衍生的參數後" "跟從僅關鍵字欄位衍生的參數。" -#: ../../library/dataclasses.rst:719 +#: ../../library/dataclasses.rst:724 #, 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:724 +#: ../../library/dataclasses.rst:729 msgid "Default factory functions" msgstr "預設工廠函式" -#: ../../library/dataclasses.rst:726 +#: ../../library/dataclasses.rst:731 #, fuzzy msgid "" "If a :func:`field` specifies a *default_factory*, it is called with zero " @@ -1435,11 +1441,11 @@ msgstr "" "如果 :func:`field` 指定了 *default_factory*,當需要該欄位的預設值時,它會以零" "引數呼叫。例如,要建立列表的新實例,請使用: ::" -#: ../../library/dataclasses.rst:730 +#: ../../library/dataclasses.rst:735 msgid "mylist: list = field(default_factory=list)" msgstr "mylist: list = field(default_factory=list)" -#: ../../library/dataclasses.rst:732 +#: ../../library/dataclasses.rst:737 #, fuzzy msgid "" "If a field is excluded from :meth:`~object.__init__` (using ``init=False``) " @@ -1452,11 +1458,11 @@ msgstr "" "位還指定了 ``default_factory``,那麼預設工廠函式將始終從生成的 :meth:" "`__init__ 中呼叫`功能。發生這種情況是因為沒有其他方法可以為該欄位賦予初始值。" -#: ../../library/dataclasses.rst:739 +#: ../../library/dataclasses.rst:744 msgid "Mutable default values" msgstr "可變預設值" -#: ../../library/dataclasses.rst:741 +#: ../../library/dataclasses.rst:746 #, fuzzy msgid "" "Python stores default member variable values in class attributes. Consider " @@ -1464,7 +1470,7 @@ msgid "" msgstr "" "Python 將預設成員變數值儲存在類別屬性中。考慮這個例子,不使用資料類別: ::" -#: ../../library/dataclasses.rst:744 +#: ../../library/dataclasses.rst:749 msgid "" "class C:\n" " x = []\n" @@ -1490,7 +1496,7 @@ msgstr "" "assert o1.x == [1, 2]\n" "assert o1.x is o2.x" -#: ../../library/dataclasses.rst:756 +#: ../../library/dataclasses.rst:761 #, fuzzy msgid "" "Note that the two instances of class :class:`!C` share the same class " @@ -1499,12 +1505,12 @@ msgstr "" "請注意,類別 :class:`!C` 的兩個實例共享同一個類別變數 :attr:`!x`,正如預期的" "那樣。" -#: ../../library/dataclasses.rst:759 +#: ../../library/dataclasses.rst:764 #, fuzzy msgid "Using dataclasses, *if* this code was valid::" -msgstr "使用資料類別,*如果*此程式碼有效: ::" +msgstr "使用資料類別,*如果*\\ 此程式碼有效: ::" -#: ../../library/dataclasses.rst:761 +#: ../../library/dataclasses.rst:766 msgid "" "@dataclass\n" "class D:\n" @@ -1518,11 +1524,11 @@ msgstr "" " def add(self, element):\n" " self.x.append(element)" -#: ../../library/dataclasses.rst:767 +#: ../../library/dataclasses.rst:772 msgid "it would generate code similar to::" msgstr "它會生成類似的程式碼: ::" -#: ../../library/dataclasses.rst:769 +#: ../../library/dataclasses.rst:774 msgid "" "class D:\n" " x = []\n" @@ -1542,7 +1548,7 @@ msgstr "" "\n" "assert D().x is D().x" -#: ../../library/dataclasses.rst:778 +#: ../../library/dataclasses.rst:783 #, fuzzy msgid "" "This has the same issue as the original example using class :class:`!C`. " @@ -1550,26 +1556,26 @@ msgid "" "attr:`!x` when creating a class instance will share the same copy of :attr:`!" "x`. Because dataclasses just use normal Python class creation they also " "share this behavior. There is no general way for Data Classes to detect " -"this condition. Instead, the :func:`@dataclass ` decorator will " -"raise a :exc:`ValueError` if it detects an unhashable default parameter. " -"The assumption is that if a value is unhashable, it is mutable. This is a " -"partial solution, but it does protect against many common errors." +"this condition. Instead, the :deco:`dataclass` decorator will raise a :exc:" +"`ValueError` if it detects an unhashable default parameter. The assumption " +"is that if a value is unhashable, it is mutable. This is a partial " +"solution, but it does protect against many common errors." msgstr "" "這與使用類別 :class:`!C` 的原始示例存在相同的問題。也就是說,類別 :class:`!" "D` 的兩個實例在建立類別實例時沒有為 :attr:`!x` 指定值,它們將共享 :attr:`!x` " "的同一個副本。因為資料類別只是使用普通的 Python 類別建立,所以它們也有這種行" "為。資料類別沒有通用的方法來檢測這種情況。相反,如果 :func:`dataclass` 裝飾器" -"檢測到不可散列的預設參數,它將引發 :exc:`TypeError`。假設是如果一個值是不可散" +"檢測到不可雜湊的預設參數,它將引發 :exc:`TypeError`。假設是如果一個值是不可散" "列的,那麼它就是可變的。這是一個部分解決方案,但它確實可以防止許多常見錯誤。" -#: ../../library/dataclasses.rst:789 +#: ../../library/dataclasses.rst:794 #, 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:792 +#: ../../library/dataclasses.rst:797 msgid "" "@dataclass\n" "class D:\n" @@ -1583,7 +1589,7 @@ msgstr "" "\n" "assert D().x is not D().x" -#: ../../library/dataclasses.rst:798 +#: ../../library/dataclasses.rst:803 #, fuzzy msgid "" "Instead of looking for and disallowing objects of type :class:`list`, :class:" @@ -1591,14 +1597,14 @@ msgid "" "values. Unhashability is used to approximate mutability." msgstr "" "不再查找和禁止型別為 :class:`list`、:class:`dict` 或 :class:`set` 的物件,現" -"在不允許使用不可散列的對像作為預設值。不可散列性用於近似可變性。" +"在不允許使用不可雜湊的物件作為預設值。不可雜湊性用於近似可變性。" -#: ../../library/dataclasses.rst:805 +#: ../../library/dataclasses.rst:810 #, fuzzy msgid "Descriptor-typed fields" msgstr "描述器型別的欄位" -#: ../../library/dataclasses.rst:807 +#: ../../library/dataclasses.rst:812 #, fuzzy msgid "" "Fields that are assigned :ref:`descriptor objects ` as their " @@ -1606,7 +1612,7 @@ msgid "" msgstr "" "指定為\\ :ref:`描述器物件 `\\ 作為預設值的欄位具有以下特殊行為:" -#: ../../library/dataclasses.rst:810 +#: ../../library/dataclasses.rst:815 #, fuzzy msgid "" "The value for the field passed to the dataclass's :meth:`~object.__init__` " @@ -1616,7 +1622,7 @@ msgstr "" "傳遞給資料類別的 :meth:`~object.__init__` 方法的欄位值被傳遞給描述器的 :meth:" "`~object.__set__` 方法,而不是覆蓋描述器物件。" -#: ../../library/dataclasses.rst:814 +#: ../../library/dataclasses.rst:819 #, fuzzy msgid "" "Similarly, when getting or setting the field, the descriptor's :meth:" @@ -1626,15 +1632,15 @@ msgstr "" "同樣,在取得或設定欄位時,將呼叫描述器的 :meth:`~object.__get__` 或 :meth:`!" "__set__` 方法,而不是回傳或覆蓋描述器物件。" -#: ../../library/dataclasses.rst:818 +#: ../../library/dataclasses.rst:823 #, fuzzy msgid "" -"To determine whether a field contains a default value, :func:`@dataclass " -"` will call the descriptor's :meth:`!__get__` method using its " -"class access form: ``descriptor.__get__(obj=None, type=cls)``. If the " -"descriptor returns a value in this case, it will be used as the field's " -"default. On the other hand, if the descriptor raises :exc:`AttributeError` " -"in this situation, no default value will be provided for the field." +"To determine whether a field contains a default value, :deco:`dataclass` " +"will call the descriptor's :meth:`!__get__` method using its class access " +"form: ``descriptor.__get__(obj=None, type=cls)``. If the descriptor returns " +"a value in this case, it will be used as the field's default. On the other " +"hand, if the descriptor raises :exc:`AttributeError` in this situation, no " +"default value will be provided for the field." msgstr "" "為了確定一個欄位是否包含預設值,:func:`@dataclass ` 將使用其類別存" "取形式呼叫描述器的 :meth:`!__get__` 方法(即 ``descriptor.__get__(obj=None, " @@ -1642,7 +1648,7 @@ msgstr "" "面,如果描述器在這種情況下引發 :exc:`AttributeError`,則不會為該欄位提供預設" "值。" -#: ../../library/dataclasses.rst:828 +#: ../../library/dataclasses.rst:833 msgid "" "class IntConversionDescriptor:\n" " def __init__(self, *, default):\n" @@ -1696,12 +1702,12 @@ msgstr "" "i.quantity_on_hand = 2.5 # 以 2.5 呼叫 __set__\n" "print(i.quantity_on_hand) # 2" -#: ../../library/dataclasses.rst:853 +#: ../../library/dataclasses.rst:858 #, fuzzy msgid "" "Note that if a field is annotated with a descriptor type, but is not " "assigned a descriptor object as its default value, the field will act like a " "normal field." msgstr "" -"請注意,如果一個欄位用描述器型別註釋,但未分配描述器對像作為其預設值,則該欄" +"請注意,如果一個欄位用描述器型別註釋,但未分配描述器物件作為其預設值,則該欄" "位將像普通欄位一樣工作。" diff --git a/library/datatypes.po b/library/datatypes.po index 82edc28c58a..c6980edfad2 100644 --- a/library/datatypes.po +++ b/library/datatypes.po @@ -1,10 +1,10 @@ -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-06-20 18:08+0800\n" "PO-Revision-Date: 2022-02-11 12:12+0800\n" diff --git a/library/datetime.po b/library/datetime.po index 5078659845c..0feee5c371f 100644 --- a/library/datetime.po +++ b/library/datetime.po @@ -1,12 +1,12 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-05-11 00:17+0000\n" +"POT-Creation-Date: 2025-12-01 00:17+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-" @@ -68,7 +68,7 @@ msgstr "" #: ../../library/datetime.rst:37 msgid "Package `dateutil `_" -msgstr "" +msgstr "`dateutil `_ 套件" #: ../../library/datetime.rst:38 msgid "Third-party library with expanded time zone and parsing support." @@ -442,10 +442,20 @@ msgid "" ">>> pretty_timedelta(d)\n" "'-(1:00:00)'" msgstr "" +">>> def pretty_timedelta(td):\n" +"... if td.days >= 0:\n" +"... return str(td)\n" +"... return f'-({-td!s})'\n" +"...\n" +">>> d = timedelta(hours=-1)\n" +">>> str(d) # not human-friendly\n" +"'-1 day, 23:00:00'\n" +">>> pretty_timedelta(d)\n" +"'-(1:00:00)'" -#: ../../library/datetime.rst:281 ../../library/datetime.rst:582 -#: ../../library/datetime.rst:1142 ../../library/datetime.rst:1780 -#: ../../library/datetime.rst:2385 +#: ../../library/datetime.rst:281 ../../library/datetime.rst:615 +#: ../../library/datetime.rst:1175 ../../library/datetime.rst:1813 +#: ../../library/datetime.rst:2434 msgid "Class attributes:" msgstr "類別屬性:" @@ -472,8 +482,8 @@ msgid "" "`timedelta` object." msgstr "" -#: ../../library/datetime.rst:303 ../../library/datetime.rst:600 -#: ../../library/datetime.rst:1162 ../../library/datetime.rst:1800 +#: ../../library/datetime.rst:303 ../../library/datetime.rst:633 +#: ../../library/datetime.rst:1195 ../../library/datetime.rst:1833 msgid "Instance attributes (read-only):" msgstr "" @@ -512,18 +522,18 @@ msgstr "" msgid "Between 0 and 999,999 inclusive." msgstr "在 0 到 999,999 (含)之間" -#: ../../library/datetime.rst:334 ../../library/datetime.rst:617 -#: ../../library/datetime.rst:1215 +#: ../../library/datetime.rst:334 ../../library/datetime.rst:650 +#: ../../library/datetime.rst:1248 msgid "Supported operations:" msgstr "" -#: ../../library/datetime.rst:339 ../../library/datetime.rst:620 -#: ../../library/datetime.rst:1218 +#: ../../library/datetime.rst:339 ../../library/datetime.rst:653 +#: ../../library/datetime.rst:1251 msgid "Operation" msgstr "" -#: ../../library/datetime.rst:339 ../../library/datetime.rst:620 -#: ../../library/datetime.rst:1218 +#: ../../library/datetime.rst:339 ../../library/datetime.rst:653 +#: ../../library/datetime.rst:1251 msgid "Result" msgstr "" @@ -669,8 +679,8 @@ msgid "" "constructor call with canonical attribute values." msgstr "" -#: ../../library/datetime.rst:400 ../../library/datetime.rst:639 -#: ../../library/datetime.rst:2616 +#: ../../library/datetime.rst:400 ../../library/datetime.rst:672 +#: ../../library/datetime.rst:2663 msgid "Notes:" msgstr "註解:" @@ -741,8 +751,8 @@ msgid "" "and only if it isn't equal to ``timedelta(0)``." msgstr "" -#: ../../library/datetime.rst:444 ../../library/datetime.rst:681 -#: ../../library/datetime.rst:1305 ../../library/datetime.rst:1907 +#: ../../library/datetime.rst:444 ../../library/datetime.rst:714 +#: ../../library/datetime.rst:1338 ../../library/datetime.rst:1956 msgid "Instance methods:" msgstr "實例方法:" @@ -847,14 +857,14 @@ msgstr "``1 <= month <= 12``" #: ../../library/datetime.rst:507 msgid "``1 <= day <= number of days in the given month and year``" -msgstr "" +msgstr "``1 <= day <= 該年該月的天數``" -#: ../../library/datetime.rst:509 ../../library/datetime.rst:899 +#: ../../library/datetime.rst:509 ../../library/datetime.rst:932 msgid "" "If an argument outside those ranges is given, :exc:`ValueError` is raised." msgstr "" -#: ../../library/datetime.rst:512 ../../library/datetime.rst:904 +#: ../../library/datetime.rst:512 ../../library/datetime.rst:937 msgid "Other constructors, all class methods:" msgstr "" @@ -908,23 +918,23 @@ msgid "" "ISO 8601 format, with the following exceptions:" msgstr "" -#: ../../library/datetime.rst:554 ../../library/datetime.rst:1064 +#: ../../library/datetime.rst:554 ../../library/datetime.rst:1097 msgid "" "Reduced precision dates are not currently supported (``YYYY-MM``, ``YYYY``)." msgstr "" -#: ../../library/datetime.rst:556 ../../library/datetime.rst:1066 +#: ../../library/datetime.rst:556 ../../library/datetime.rst:1099 msgid "" "Extended date representations are not currently supported (``±YYYYYY-MM-" "DD``)." msgstr "" -#: ../../library/datetime.rst:558 ../../library/datetime.rst:1068 +#: ../../library/datetime.rst:558 ../../library/datetime.rst:1101 msgid "Ordinal dates are not currently supported (``YYYY-OOO``)." msgstr "" -#: ../../library/datetime.rst:560 ../../library/datetime.rst:1070 -#: ../../library/datetime.rst:1536 +#: ../../library/datetime.rst:560 ../../library/datetime.rst:1103 +#: ../../library/datetime.rst:1569 msgid "Examples::" msgstr "範例: ::" @@ -957,89 +967,133 @@ msgid "" "isocalendar`." msgstr "" +#: ../../library/datetime.rst:583 +msgid "" +"Return a :class:`.date` corresponding to *date_string*, parsed according to " +"*format*. This is equivalent to::" +msgstr "" + #: ../../library/datetime.rst:586 +msgid "date(*(time.strptime(date_string, format)[0:3]))" +msgstr "date(*(time.strptime(date_string, format)[0:3]))" + +#: ../../library/datetime.rst:588 +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:595 +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:" +msgstr "" + +#: ../../library/datetime.rst:604 +msgid "" +">>> from datetime import date\n" +">>> date_string = \"02/29\"\n" +">>> when = date.strptime(f\"{date_string};1984\", \"%m/%d;%Y\") # Avoids " +"leap year bug.\n" +">>> when.strftime(\"%B %d\")\n" +"'February 29'" +msgstr "" +">>> from datetime import date\n" +">>> date_string = \"02/29\"\n" +">>> when = date.strptime(f\"{date_string};1984\", \"%m/%d;%Y\") # 避免閏年錯" +"誤。\n" +">>> when.strftime(\"%B %d\")\n" +"'February 29'" + +#: ../../library/datetime.rst:619 msgid "The earliest representable date, ``date(MINYEAR, 1, 1)``." msgstr "" -#: ../../library/datetime.rst:591 +#: ../../library/datetime.rst:624 msgid "The latest representable date, ``date(MAXYEAR, 12, 31)``." msgstr "" -#: ../../library/datetime.rst:596 +#: ../../library/datetime.rst:629 msgid "" "The smallest possible difference between non-equal date objects, " "``timedelta(days=1)``." msgstr "" -#: ../../library/datetime.rst:604 ../../library/datetime.rst:1166 +#: ../../library/datetime.rst:637 ../../library/datetime.rst:1199 msgid "Between :const:`MINYEAR` and :const:`MAXYEAR` inclusive." msgstr "" -#: ../../library/datetime.rst:609 ../../library/datetime.rst:1171 +#: ../../library/datetime.rst:642 ../../library/datetime.rst:1204 msgid "Between 1 and 12 inclusive." msgstr "在 1 到 12 (含)之間。" -#: ../../library/datetime.rst:614 ../../library/datetime.rst:1176 +#: ../../library/datetime.rst:647 ../../library/datetime.rst:1209 msgid "Between 1 and the number of days in the given month of the given year." msgstr "" -#: ../../library/datetime.rst:622 +#: ../../library/datetime.rst:655 msgid "``date2 = date1 + timedelta``" msgstr "``date2 = date1 + timedelta``" -#: ../../library/datetime.rst:622 +#: ../../library/datetime.rst:655 msgid "``date2`` will be ``timedelta.days`` days after ``date1``. (1)" msgstr "" -#: ../../library/datetime.rst:625 +#: ../../library/datetime.rst:658 msgid "``date2 = date1 - timedelta``" msgstr "``date2 = date1 - timedelta``" -#: ../../library/datetime.rst:625 +#: ../../library/datetime.rst:658 msgid "Computes ``date2`` such that ``date2 + timedelta == date1``. (2)" msgstr "" -#: ../../library/datetime.rst:628 +#: ../../library/datetime.rst:661 msgid "``timedelta = date1 - date2``" msgstr "``timedelta = date1 - date2``" -#: ../../library/datetime.rst:628 ../../library/datetime.rst:1224 +#: ../../library/datetime.rst:661 ../../library/datetime.rst:1257 msgid "\\(3)" msgstr "\\(3)" -#: ../../library/datetime.rst:0 +#: ../../library/datetime.rst:663 msgid "``date1 == date2``" msgstr "``date1 == date2``" -#: ../../library/datetime.rst:0 +#: ../../library/datetime.rst:664 msgid "``date1 != date2``" msgstr "``date1 != date2``" -#: ../../library/datetime.rst:630 ../../library/datetime.rst:1226 +#: ../../library/datetime.rst:663 ../../library/datetime.rst:1259 msgid "Equality comparison. (4)" msgstr "" -#: ../../library/datetime.rst:0 +#: ../../library/datetime.rst:666 msgid "``date1 < date2``" msgstr "``date1 < date2``" -#: ../../library/datetime.rst:0 +#: ../../library/datetime.rst:667 msgid "``date1 > date2``" msgstr "``date1 > date2``" -#: ../../library/datetime.rst:0 +#: ../../library/datetime.rst:668 msgid "``date1 <= date2``" msgstr "``date1 <= date2``" -#: ../../library/datetime.rst:0 +#: ../../library/datetime.rst:669 msgid "``date1 >= date2``" msgstr "``date1 >= date2``" -#: ../../library/datetime.rst:633 ../../library/datetime.rst:1229 +#: ../../library/datetime.rst:666 ../../library/datetime.rst:1262 msgid "Order comparison. (5)" msgstr "" -#: ../../library/datetime.rst:642 +#: ../../library/datetime.rst:675 msgid "" "*date2* is moved forward in time if ``timedelta.days > 0``, or backward if " "``timedelta.days < 0``. Afterward ``date2 - date1 == timedelta.days``. " @@ -1048,41 +1102,41 @@ msgid "" "`MINYEAR` or larger than :const:`MAXYEAR`." msgstr "" -#: ../../library/datetime.rst:649 +#: ../../library/datetime.rst:682 msgid "``timedelta.seconds`` and ``timedelta.microseconds`` are ignored." msgstr "``timedelta.seconds`` 和 ``timedelta.microseconds`` 被忽略。" -#: ../../library/datetime.rst:652 +#: ../../library/datetime.rst:685 msgid "" "This is exact, and cannot overflow. ``timedelta.seconds`` and ``timedelta." "microseconds`` are 0, and ``date2 + timedelta == date1`` after." msgstr "" -#: ../../library/datetime.rst:656 +#: ../../library/datetime.rst:689 msgid ":class:`date` objects are equal if they represent the same date." msgstr "" -#: ../../library/datetime.rst:658 +#: ../../library/datetime.rst:691 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:663 +#: ../../library/datetime.rst:696 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:667 +#: ../../library/datetime.rst:700 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:671 ../../library/datetime.rst:1297 +#: ../../library/datetime.rst:704 ../../library/datetime.rst:1330 msgid "" "Comparison between :class:`.datetime` object and an instance of the :class:" "`date` subclass that is not a :class:`!datetime` subclass no longer converts " @@ -1091,22 +1145,22 @@ msgid "" "in subclasses." msgstr "" -#: ../../library/datetime.rst:679 +#: ../../library/datetime.rst:712 msgid "" "In Boolean contexts, all :class:`date` objects are considered to be true." msgstr "" -#: ../../library/datetime.rst:685 +#: ../../library/datetime.rst:718 msgid "" "Return a new :class:`date` object with the same values, but with specified " "parameters updated." msgstr "" -#: ../../library/datetime.rst:688 ../../library/datetime.rst:1953 +#: ../../library/datetime.rst:721 ../../library/datetime.rst:2002 msgid "Example::" msgstr "範例: ::" -#: ../../library/datetime.rst:690 +#: ../../library/datetime.rst:723 msgid "" ">>> from datetime import date\n" ">>> d = date(2002, 12, 31)\n" @@ -1118,47 +1172,47 @@ msgstr "" ">>> d.replace(day=26)\n" "datetime.date(2002, 12, 26)" -#: ../../library/datetime.rst:695 +#: ../../library/datetime.rst:728 msgid "" "The generic function :func:`copy.replace` also supports :class:`date` " "objects." msgstr "" -#: ../../library/datetime.rst:701 ../../library/datetime.rst:1421 +#: ../../library/datetime.rst:734 ../../library/datetime.rst:1454 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:703 +#: ../../library/datetime.rst:736 msgid "The hours, minutes and seconds are 0, and the DST flag is -1." msgstr "" -#: ../../library/datetime.rst:705 ../../library/datetime.rst:1423 +#: ../../library/datetime.rst:738 ../../library/datetime.rst:1456 msgid "``d.timetuple()`` is equivalent to::" msgstr "``d.timetuple()`` 等價於: ::" -#: ../../library/datetime.rst:707 +#: ../../library/datetime.rst:740 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:709 +#: ../../library/datetime.rst:742 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:715 +#: ../../library/datetime.rst:748 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:722 +#: ../../library/datetime.rst:755 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 :" @@ -1167,25 +1221,25 @@ msgstr "" "回傳一個代表星期幾的整數,星期一為 0、星期日為 6。例如 ``date(2002, 12, 4)." "weekday() == 2`` 為星期三。也請參考 :meth:`isoweekday`。" -#: ../../library/datetime.rst:729 +#: ../../library/datetime.rst:762 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:736 +#: ../../library/datetime.rst:769 msgid "" "Return a :term:`named tuple` object with three components: ``year``, " "``week`` and ``weekday``." msgstr "" -#: ../../library/datetime.rst:739 +#: ../../library/datetime.rst:772 msgid "" "The ISO calendar is a widely used variant of the Gregorian calendar. [#]_" msgstr "" -#: ../../library/datetime.rst:741 +#: ../../library/datetime.rst:774 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 " @@ -1194,13 +1248,13 @@ msgid "" "Gregorian year." msgstr "" -#: ../../library/datetime.rst:746 +#: ../../library/datetime.rst:779 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:749 +#: ../../library/datetime.rst:782 msgid "" ">>> from datetime import date\n" ">>> date(2003, 12, 29).isocalendar()\n" @@ -1214,16 +1268,16 @@ msgstr "" ">>> date(2004, 1, 4).isocalendar()\n" "datetime.IsoCalendarDate(year=2004, week=1, weekday=7)" -#: ../../library/datetime.rst:755 +#: ../../library/datetime.rst:788 msgid "Result changed from a tuple to a :term:`named tuple`." msgstr "" -#: ../../library/datetime.rst:760 +#: ../../library/datetime.rst:793 msgid "" "Return a string representing the date in ISO 8601 format, ``YYYY-MM-DD``::" msgstr "回傳一以 ISO 8601 格式 ``YYYY-MM-DD`` 表示的日期字串: ::" -#: ../../library/datetime.rst:762 +#: ../../library/datetime.rst:795 msgid "" ">>> from datetime import date\n" ">>> date(2002, 12, 4).isoformat()\n" @@ -1233,15 +1287,15 @@ msgstr "" ">>> date(2002, 12, 4).isoformat()\n" "'2002-12-04'" -#: ../../library/datetime.rst:768 +#: ../../library/datetime.rst:801 msgid "For a date ``d``, ``str(d)`` is equivalent to ``d.isoformat()``." msgstr "" -#: ../../library/datetime.rst:773 +#: ../../library/datetime.rst:806 msgid "Return a string representing the date::" msgstr "" -#: ../../library/datetime.rst:775 +#: ../../library/datetime.rst:808 msgid "" ">>> from datetime import date\n" ">>> date(2002, 12, 4).ctime()\n" @@ -1251,22 +1305,22 @@ msgstr "" ">>> date(2002, 12, 4).ctime()\n" "'Wed Dec 4 00:00:00 2002'" -#: ../../library/datetime.rst:779 ../../library/datetime.rst:1607 +#: ../../library/datetime.rst:812 ../../library/datetime.rst:1640 msgid "``d.ctime()`` is equivalent to::" msgstr "``d.ctime()`` 等價於: ::" -#: ../../library/datetime.rst:781 ../../library/datetime.rst:1609 +#: ../../library/datetime.rst:814 ../../library/datetime.rst:1642 msgid "time.ctime(time.mktime(d.timetuple()))" msgstr "time.ctime(time.mktime(d.timetuple()))" -#: ../../library/datetime.rst:783 +#: ../../library/datetime.rst:816 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:790 +#: ../../library/datetime.rst:823 msgid "" "Return a string representing the date, controlled by an explicit format " "string. Format codes referring to hours, minutes or seconds will see 0 " @@ -1274,7 +1328,7 @@ msgid "" "isoformat`." msgstr "" -#: ../../library/datetime.rst:797 +#: ../../library/datetime.rst:830 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" ">>> from datetime import date\n" @@ -1326,11 +1380,11 @@ msgstr "" ">>> time_to_birthday.days\n" "202" -#: ../../library/datetime.rst:824 +#: ../../library/datetime.rst:857 msgid "More examples of working with :class:`date`:" msgstr "更多 :class:`date` 的用法範例:" -#: ../../library/datetime.rst:826 +#: ../../library/datetime.rst:859 msgid "" ">>> from datetime import date\n" ">>> d = date.fromordinal(730920) # 730920th day after 1. 1. 0001\n" @@ -1374,17 +1428,17 @@ msgid "" "datetime.date(2005, 3, 11)" msgstr "" -#: ../../library/datetime.rst:873 +#: ../../library/datetime.rst:906 msgid ":class:`.datetime` Objects" msgstr ":class:`.datetime` 物件" -#: ../../library/datetime.rst:875 +#: ../../library/datetime.rst:908 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:878 +#: ../../library/datetime.rst:911 msgid "" "Like a :class:`date` object, :class:`.datetime` assumes the current " "Gregorian calendar extended in both directions; like a :class:`.time` " @@ -1392,81 +1446,81 @@ msgid "" "every day." msgstr "" -#: ../../library/datetime.rst:882 +#: ../../library/datetime.rst:915 msgid "Constructor:" msgstr "建構函式:" -#: ../../library/datetime.rst:886 +#: ../../library/datetime.rst:919 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:890 +#: ../../library/datetime.rst:923 msgid "``MINYEAR <= year <= MAXYEAR``," msgstr "``MINYEAR <= year <= MAXYEAR``," -#: ../../library/datetime.rst:891 +#: ../../library/datetime.rst:924 msgid "``1 <= month <= 12``," msgstr "``1 <= month <= 12``," -#: ../../library/datetime.rst:892 +#: ../../library/datetime.rst:925 msgid "``1 <= day <= number of days in the given month and year``," msgstr "" -#: ../../library/datetime.rst:893 ../../library/datetime.rst:1771 +#: ../../library/datetime.rst:926 ../../library/datetime.rst:1804 msgid "``0 <= hour < 24``," msgstr "``0 <= hour < 24``," -#: ../../library/datetime.rst:894 ../../library/datetime.rst:1772 +#: ../../library/datetime.rst:927 ../../library/datetime.rst:1805 msgid "``0 <= minute < 60``," msgstr "``0 <= minute < 60``," -#: ../../library/datetime.rst:895 ../../library/datetime.rst:1773 +#: ../../library/datetime.rst:928 ../../library/datetime.rst:1806 msgid "``0 <= second < 60``," msgstr "``0 <= second < 60``," -#: ../../library/datetime.rst:896 ../../library/datetime.rst:1774 +#: ../../library/datetime.rst:929 ../../library/datetime.rst:1807 msgid "``0 <= microsecond < 1000000``," msgstr "``0 <= microsecond < 1000000``," -#: ../../library/datetime.rst:897 ../../library/datetime.rst:1775 +#: ../../library/datetime.rst:930 ../../library/datetime.rst:1808 msgid "``fold in [0, 1]``." msgstr "``fold in [0, 1]``。" -#: ../../library/datetime.rst:901 ../../library/datetime.rst:1342 -#: ../../library/datetime.rst:1920 +#: ../../library/datetime.rst:934 ../../library/datetime.rst:1375 +#: ../../library/datetime.rst:1969 msgid "Added the *fold* parameter." msgstr "新增 *fold* 參數。" -#: ../../library/datetime.rst:908 +#: ../../library/datetime.rst:941 msgid "Return the current local date and time, with :attr:`.tzinfo` ``None``." msgstr "回傳目前的本地日期與時間,且 :attr:`.tzinfo` 為 ``None``。" -#: ../../library/datetime.rst:910 +#: ../../library/datetime.rst:943 msgid "Equivalent to::" msgstr "等價於: ::" -#: ../../library/datetime.rst:912 +#: ../../library/datetime.rst:945 msgid "datetime.fromtimestamp(time.time())" msgstr "datetime.fromtimestamp(time.time())" -#: ../../library/datetime.rst:914 +#: ../../library/datetime.rst:947 msgid "See also :meth:`now`, :meth:`fromtimestamp`." msgstr "也請見 :meth:`now`、:meth:`fromtimestamp`。" -#: ../../library/datetime.rst:916 +#: ../../library/datetime.rst:949 msgid "" "This method is functionally equivalent to :meth:`now`, but without a ``tz`` " "parameter." msgstr "" -#: ../../library/datetime.rst:921 +#: ../../library/datetime.rst:954 msgid "Return the current local date and time." msgstr "" -#: ../../library/datetime.rst:923 +#: ../../library/datetime.rst:956 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 " @@ -1477,34 +1531,34 @@ msgstr "" "供比透過 :func:`time.time` 取得的時間戳記更多位數的資訊(例如,這在有提供 C :" "c:func:`gettimeofday` 函式的平台上可能可行)。" -#: ../../library/datetime.rst:929 +#: ../../library/datetime.rst:962 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:932 +#: ../../library/datetime.rst:965 msgid "This function is preferred over :meth:`today` and :meth:`utcnow`." msgstr "" -#: ../../library/datetime.rst:936 +#: ../../library/datetime.rst:969 msgid "" "Subsequent calls to :meth:`!datetime.now` may return the same instant " "depending on the precision of the underlying clock." msgstr "" -#: ../../library/datetime.rst:941 +#: ../../library/datetime.rst:974 msgid "Return the current UTC date and time, with :attr:`.tzinfo` ``None``." msgstr "" -#: ../../library/datetime.rst:943 +#: ../../library/datetime.rst:976 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:949 +#: ../../library/datetime.rst:982 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 " @@ -1512,11 +1566,11 @@ msgid "" "current time in UTC is by calling ``datetime.now(timezone.utc)``." msgstr "" -#: ../../library/datetime.rst:956 +#: ../../library/datetime.rst:989 msgid "Use :meth:`datetime.now` with :const:`UTC` instead." msgstr "" -#: ../../library/datetime.rst:961 +#: ../../library/datetime.rst:994 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 " @@ -1524,13 +1578,13 @@ msgid "" "time, and the returned :class:`.datetime` object is naive." msgstr "" -#: ../../library/datetime.rst:966 +#: ../../library/datetime.rst:999 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:969 +#: ../../library/datetime.rst:1002 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` " @@ -1543,7 +1597,7 @@ msgid "" "preferred over :meth:`utcfromtimestamp`." msgstr "" -#: ../../library/datetime.rst:980 +#: ../../library/datetime.rst:1013 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` " @@ -1551,17 +1605,17 @@ msgid "" "`ValueError` on :c:func:`localtime` or :c:func:`gmtime` failure." msgstr "" -#: ../../library/datetime.rst:987 +#: ../../library/datetime.rst:1020 msgid ":meth:`fromtimestamp` may return instances with :attr:`.fold` set to 1." msgstr "" -#: ../../library/datetime.rst:992 +#: ../../library/datetime.rst:1025 msgid "" "Return the UTC :class:`.datetime` corresponding to the POSIX timestamp, " "with :attr:`.tzinfo` ``None``. (The resulting object is naive.)" msgstr "" -#: ../../library/datetime.rst:995 +#: ../../library/datetime.rst:1028 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:" @@ -1569,33 +1623,33 @@ msgid "" "to years in 1970 through 2038." msgstr "" -#: ../../library/datetime.rst:1000 +#: ../../library/datetime.rst:1033 msgid "To get an aware :class:`.datetime` object, call :meth:`fromtimestamp`::" msgstr "" -#: ../../library/datetime.rst:1002 +#: ../../library/datetime.rst:1035 msgid "datetime.fromtimestamp(timestamp, timezone.utc)" msgstr "datetime.fromtimestamp(timestamp, timezone.utc)" -#: ../../library/datetime.rst:1004 +#: ../../library/datetime.rst:1037 msgid "" "On the POSIX compliant platforms, it is equivalent to the following " "expression::" msgstr "" -#: ../../library/datetime.rst:1007 +#: ../../library/datetime.rst:1040 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:1009 +#: ../../library/datetime.rst:1042 msgid "" "except the latter formula always supports the full years range: between :" "const:`MINYEAR` and :const:`MAXYEAR` inclusive." msgstr "" -#: ../../library/datetime.rst:1014 +#: ../../library/datetime.rst:1047 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 " @@ -1604,7 +1658,7 @@ msgid "" "tz=timezone.utc)``." msgstr "" -#: ../../library/datetime.rst:1020 +#: ../../library/datetime.rst:1053 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` " @@ -1612,11 +1666,11 @@ msgid "" "`gmtime` failure." msgstr "" -#: ../../library/datetime.rst:1028 +#: ../../library/datetime.rst:1061 msgid "Use :meth:`datetime.fromtimestamp` with :const:`UTC` instead." msgstr "" -#: ../../library/datetime.rst:1033 +#: ../../library/datetime.rst:1066 msgid "" "Return the :class:`.datetime` corresponding to the proleptic Gregorian " "ordinal, where January 1 of year 1 has ordinal 1. :exc:`ValueError` is " @@ -1625,7 +1679,7 @@ msgid "" "is ``None``." msgstr "" -#: ../../library/datetime.rst:1041 +#: ../../library/datetime.rst:1074 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 " @@ -1636,35 +1690,35 @@ msgid "" "attr:`.tzinfo` attributes are ignored." msgstr "" -#: ../../library/datetime.rst:1049 +#: ../../library/datetime.rst:1082 msgid "" "For any :class:`.datetime` object ``d``, ``d == datetime.combine(d.date(), d." "time(), d.tzinfo)``." msgstr "" -#: ../../library/datetime.rst:1052 +#: ../../library/datetime.rst:1085 msgid "Added the *tzinfo* argument." msgstr "新增 *tzinfo* 引數。" -#: ../../library/datetime.rst:1058 +#: ../../library/datetime.rst:1091 msgid "" "Return a :class:`.datetime` corresponding to a *date_string* in any valid " "ISO 8601 format, with the following exceptions:" msgstr "" -#: ../../library/datetime.rst:1061 ../../library/datetime.rst:1871 +#: ../../library/datetime.rst:1094 ../../library/datetime.rst:1904 msgid "Time zone offsets may have fractional seconds." msgstr "" -#: ../../library/datetime.rst:1062 +#: ../../library/datetime.rst:1095 msgid "The ``T`` separator may be replaced by any single unicode character." msgstr "" -#: ../../library/datetime.rst:1063 ../../library/datetime.rst:1876 +#: ../../library/datetime.rst:1096 ../../library/datetime.rst:1909 msgid "Fractional hours and minutes are not supported." msgstr "" -#: ../../library/datetime.rst:1072 +#: ../../library/datetime.rst:1105 msgid "" ">>> from datetime import datetime\n" ">>> datetime.fromisoformat('2011-11-04')\n" @@ -1710,13 +1764,13 @@ msgstr "" "datetime.datetime(2011, 11, 4, 0, 5, 23,\n" " tzinfo=datetime.timezone(datetime.timedelta(seconds=14400)))" -#: ../../library/datetime.rst:1094 +#: ../../library/datetime.rst:1127 msgid "" "Previously, this method only supported formats that could be emitted by :" "meth:`date.isoformat` or :meth:`datetime.isoformat`." msgstr "" -#: ../../library/datetime.rst:1101 +#: ../../library/datetime.rst:1134 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 populated " @@ -1724,23 +1778,23 @@ msgid "" "`datetime.isocalendar`." msgstr "" -#: ../../library/datetime.rst:1110 +#: ../../library/datetime.rst:1143 msgid "" "Return a :class:`.datetime` corresponding to *date_string*, parsed according " "to *format*." msgstr "" -#: ../../library/datetime.rst:1113 +#: ../../library/datetime.rst:1146 msgid "" "If *format* does not contain microseconds or time zone information, this is " "equivalent to::" msgstr "" -#: ../../library/datetime.rst:1115 ../../library/datetime.rst:2596 +#: ../../library/datetime.rst:1148 ../../library/datetime.rst:2643 msgid "datetime(*(time.strptime(date_string, format)[0:6]))" msgstr "datetime(*(time.strptime(date_string, format)[0:6]))" -#: ../../library/datetime.rst:1117 +#: ../../library/datetime.rst:1150 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. " @@ -1748,7 +1802,7 @@ msgid "" "fromisoformat`." msgstr "" -#: ../../library/datetime.rst:1124 +#: ../../library/datetime.rst:1157 msgid "" "If *format* specifies a day of month without a year a :exc:" "`DeprecationWarning` is now emitted. This is to avoid a quadrennial leap " @@ -1759,7 +1813,7 @@ msgid "" "not have a year, explicitly add a year that is a leap year before parsing:" msgstr "" -#: ../../library/datetime.rst:1133 +#: ../../library/datetime.rst:1166 msgid "" ">>> from datetime import datetime\n" ">>> date_string = \"02/29\"\n" @@ -1768,45 +1822,51 @@ msgid "" ">>> when.strftime(\"%B %d\")\n" "'February 29'" msgstr "" +">>> from datetime import datetime\n" +">>> date_string = \"02/29\"\n" +">>> when = datetime.strptime(f\"{date_string};1984\", \"%m/%d;%Y\") # 避免閏" +"年錯誤。\n" +">>> when.strftime(\"%B %d\")\n" +"'February 29'" -#: ../../library/datetime.rst:1146 +#: ../../library/datetime.rst:1179 msgid "" "The earliest representable :class:`.datetime`, ``datetime(MINYEAR, 1, 1, " "tzinfo=None)``." msgstr "" -#: ../../library/datetime.rst:1152 +#: ../../library/datetime.rst:1185 msgid "" "The latest representable :class:`.datetime`, ``datetime(MAXYEAR, 12, 31, 23, " "59, 59, 999999, tzinfo=None)``." msgstr "" -#: ../../library/datetime.rst:1158 +#: ../../library/datetime.rst:1191 msgid "" "The smallest possible difference between non-equal :class:`.datetime` " "objects, ``timedelta(microseconds=1)``." msgstr "" -#: ../../library/datetime.rst:1181 ../../library/datetime.rst:1804 +#: ../../library/datetime.rst:1214 ../../library/datetime.rst:1837 msgid "In ``range(24)``." msgstr "" -#: ../../library/datetime.rst:1186 ../../library/datetime.rst:1191 -#: ../../library/datetime.rst:1809 ../../library/datetime.rst:1814 +#: ../../library/datetime.rst:1219 ../../library/datetime.rst:1224 +#: ../../library/datetime.rst:1842 ../../library/datetime.rst:1847 msgid "In ``range(60)``." msgstr "" -#: ../../library/datetime.rst:1196 ../../library/datetime.rst:1819 +#: ../../library/datetime.rst:1229 ../../library/datetime.rst:1852 msgid "In ``range(1000000)``." msgstr "" -#: ../../library/datetime.rst:1201 +#: ../../library/datetime.rst:1234 msgid "" "The object passed as the *tzinfo* argument to the :class:`.datetime` " "constructor, or ``None`` if none was passed." msgstr "" -#: ../../library/datetime.rst:1207 ../../library/datetime.rst:1830 +#: ../../library/datetime.rst:1240 ../../library/datetime.rst:1863 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 " @@ -1816,54 +1876,54 @@ msgid "" "time representation." msgstr "" -#: ../../library/datetime.rst:1220 +#: ../../library/datetime.rst:1253 msgid "``datetime2 = datetime1 + timedelta``" msgstr "``datetime2 = datetime1 + timedelta``" -#: ../../library/datetime.rst:1220 ../../library/datetime.rst:2443 -#: ../../library/datetime.rst:2448 ../../library/datetime.rst:2460 -#: ../../library/datetime.rst:2465 ../../library/datetime.rst:2525 -#: ../../library/datetime.rst:2530 ../../library/datetime.rst:2534 +#: ../../library/datetime.rst:1253 ../../library/datetime.rst:2490 +#: ../../library/datetime.rst:2495 ../../library/datetime.rst:2507 +#: ../../library/datetime.rst:2512 ../../library/datetime.rst:2572 +#: ../../library/datetime.rst:2577 ../../library/datetime.rst:2581 msgid "\\(1)" msgstr "\\(1)" -#: ../../library/datetime.rst:1222 +#: ../../library/datetime.rst:1255 msgid "``datetime2 = datetime1 - timedelta``" msgstr "``datetime2 = datetime1 - timedelta``" -#: ../../library/datetime.rst:1222 ../../library/datetime.rst:2476 +#: ../../library/datetime.rst:1255 ../../library/datetime.rst:2523 msgid "\\(2)" msgstr "\\(2)" -#: ../../library/datetime.rst:1224 +#: ../../library/datetime.rst:1257 msgid "``timedelta = datetime1 - datetime2``" msgstr "``timedelta = datetime1 - datetime2``" -#: ../../library/datetime.rst:0 +#: ../../library/datetime.rst:1259 msgid "``datetime1 == datetime2``" msgstr "``datetime1 == datetime2``" -#: ../../library/datetime.rst:0 +#: ../../library/datetime.rst:1260 msgid "``datetime1 != datetime2``" msgstr "``datetime1 != datetime2``" -#: ../../library/datetime.rst:0 +#: ../../library/datetime.rst:1262 msgid "``datetime1 < datetime2``" msgstr "``datetime1 < datetime2``" -#: ../../library/datetime.rst:0 +#: ../../library/datetime.rst:1263 msgid "``datetime1 > datetime2``" msgstr "``datetime1 > datetime2``" -#: ../../library/datetime.rst:0 +#: ../../library/datetime.rst:1264 msgid "``datetime1 <= datetime2``" msgstr "``datetime1 <= datetime2``" -#: ../../library/datetime.rst:0 +#: ../../library/datetime.rst:1265 msgid "``datetime1 >= datetime2``" msgstr "``datetime1 >= datetime2``" -#: ../../library/datetime.rst:1236 +#: ../../library/datetime.rst:1269 msgid "" "``datetime2`` is a duration of ``timedelta`` removed from ``datetime1``, " "moving forward in time if ``timedelta.days > 0``, or backward if ``timedelta." @@ -1874,7 +1934,7 @@ msgid "" "adjustments are done even if the input is an aware object." msgstr "" -#: ../../library/datetime.rst:1245 +#: ../../library/datetime.rst:1278 msgid "" "Computes the ``datetime2`` such that ``datetime2 + timedelta == datetime1``. " "As for addition, the result has the same :attr:`~.datetime.tzinfo` attribute " @@ -1882,14 +1942,14 @@ msgid "" "input is aware." msgstr "" -#: ../../library/datetime.rst:1250 +#: ../../library/datetime.rst:1283 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:1254 +#: ../../library/datetime.rst:1287 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 " @@ -1897,7 +1957,7 @@ msgid "" "datetime1``. No time zone adjustments are done in this case." msgstr "" -#: ../../library/datetime.rst:1259 +#: ../../library/datetime.rst:1292 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 " @@ -1906,17 +1966,17 @@ msgid "" "overflows." msgstr "" -#: ../../library/datetime.rst:1265 +#: ../../library/datetime.rst:1298 msgid "" ":class:`.datetime` objects are equal if they represent the same date and " "time, taking into account the time zone." msgstr "" -#: ../../library/datetime.rst:1268 +#: ../../library/datetime.rst:1301 msgid "Naive and aware :class:`!datetime` objects are never equal." msgstr "" -#: ../../library/datetime.rst:1270 +#: ../../library/datetime.rst:1303 msgid "" "If both comparands are aware, and have the same :attr:`!tzinfo` attribute, " "the :attr:`!tzinfo` and :attr:`~.datetime.fold` attributes are ignored and " @@ -1927,19 +1987,19 @@ msgid "" "interval are never equal to :class:`!datetime` instances in other time zone." msgstr "" -#: ../../library/datetime.rst:1280 +#: ../../library/datetime.rst:1313 msgid "" "*datetime1* is considered less than *datetime2* when *datetime1* precedes " "*datetime2* in time, taking into account the time zone." msgstr "" -#: ../../library/datetime.rst:1283 +#: ../../library/datetime.rst:1316 msgid "" "Order comparison between naive and aware :class:`.datetime` objects raises :" "exc:`TypeError`." msgstr "" -#: ../../library/datetime.rst:1286 +#: ../../library/datetime.rst:1319 msgid "" "If both comparands are aware, and have the same :attr:`!tzinfo` attribute, " "the :attr:`!tzinfo` and :attr:`~.datetime.fold` attributes are ignored and " @@ -1949,33 +2009,33 @@ msgid "" "implementation never overflows." msgstr "" -#: ../../library/datetime.rst:1293 +#: ../../library/datetime.rst:1326 msgid "" "Equality comparisons between aware and naive :class:`.datetime` instances " "don't raise :exc:`TypeError`." msgstr "" -#: ../../library/datetime.rst:1309 +#: ../../library/datetime.rst:1342 msgid "Return :class:`date` object with same year, month and day." msgstr "" -#: ../../library/datetime.rst:1314 +#: ../../library/datetime.rst:1347 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:1317 ../../library/datetime.rst:1326 +#: ../../library/datetime.rst:1350 ../../library/datetime.rst:1359 msgid "The fold value is copied to the returned :class:`.time` object." msgstr "" -#: ../../library/datetime.rst:1323 +#: ../../library/datetime.rst:1356 msgid "" "Return :class:`.time` object with same hour, minute, second, microsecond, " "fold, and tzinfo attributes. See also method :meth:`time`." msgstr "" -#: ../../library/datetime.rst:1334 +#: ../../library/datetime.rst:1367 msgid "" "Return a new :class:`datetime` object with the same attributes, but with " "specified parameters updated. Note that ``tzinfo=None`` can be specified to " @@ -1983,27 +2043,27 @@ msgid "" "and time data." msgstr "" -#: ../../library/datetime.rst:1339 +#: ../../library/datetime.rst:1372 msgid "" ":class:`.datetime` objects are also supported by generic function :func:" "`copy.replace`." msgstr "" -#: ../../library/datetime.rst:1348 +#: ../../library/datetime.rst:1381 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:1352 +#: ../../library/datetime.rst:1385 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:1356 +#: ../../library/datetime.rst:1389 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 " @@ -2011,7 +2071,7 @@ msgid "" "with the zone name and offset obtained from the OS." msgstr "" -#: ../../library/datetime.rst:1361 +#: ../../library/datetime.rst:1394 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 " @@ -2020,7 +2080,7 @@ msgid "" "date and time data as ``dt - dt.utcoffset()``." msgstr "" -#: ../../library/datetime.rst:1367 +#: ../../library/datetime.rst:1400 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." @@ -2029,14 +2089,14 @@ msgid "" "use ``dt.replace(tzinfo=None)``." msgstr "" -#: ../../library/datetime.rst:1372 +#: ../../library/datetime.rst:1405 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:1376 +#: ../../library/datetime.rst:1409 msgid "" "def astimezone(self, tz):\n" " if self.tzinfo is tz:\n" @@ -2047,49 +2107,49 @@ msgid "" " return tz.fromutc(utc)" msgstr "" -#: ../../library/datetime.rst:1384 +#: ../../library/datetime.rst:1417 msgid "*tz* now can be omitted." msgstr "" -#: ../../library/datetime.rst:1387 +#: ../../library/datetime.rst:1420 msgid "" "The :meth:`astimezone` method can now be called on naive instances that are " "presumed to represent system local time." msgstr "" -#: ../../library/datetime.rst:1394 +#: ../../library/datetime.rst:1427 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:1398 ../../library/datetime.rst:1993 -#: ../../library/datetime.rst:2100 ../../library/datetime.rst:2345 -#: ../../library/datetime.rst:2357 ../../library/datetime.rst:2669 +#: ../../library/datetime.rst:1431 ../../library/datetime.rst:2042 +#: ../../library/datetime.rst:2149 ../../library/datetime.rst:2394 +#: ../../library/datetime.rst:2406 ../../library/datetime.rst:2716 msgid "The UTC offset is not restricted to a whole number of minutes." msgstr "" -#: ../../library/datetime.rst:1404 +#: ../../library/datetime.rst:1437 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:1408 ../../library/datetime.rst:2003 -#: ../../library/datetime.rst:2154 +#: ../../library/datetime.rst:1441 ../../library/datetime.rst:2052 +#: ../../library/datetime.rst:2203 msgid "The DST offset is not restricted to a whole number of minutes." msgstr "" -#: ../../library/datetime.rst:1414 +#: ../../library/datetime.rst:1447 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:1425 +#: ../../library/datetime.rst:1458 msgid "" "time.struct_time((d.year, d.month, d.day,\n" " d.hour, d.minute, d.second,\n" @@ -2099,7 +2159,7 @@ msgstr "" " d.hour, d.minute, d.second,\n" " d.weekday(), yday, dst))" -#: ../../library/datetime.rst:1429 +#: ../../library/datetime.rst:1462 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 :" @@ -2110,7 +2170,7 @@ msgid "" "to 0." msgstr "" -#: ../../library/datetime.rst:1440 +#: ../../library/datetime.rst:1473 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 " @@ -2118,7 +2178,7 @@ msgid "" "time." msgstr "" -#: ../../library/datetime.rst:1444 +#: ../../library/datetime.rst:1477 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 " @@ -2127,7 +2187,7 @@ msgid "" "and UTC adjustment spills over a year boundary." msgstr "" -#: ../../library/datetime.rst:1453 +#: ../../library/datetime.rst:1486 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 " @@ -2137,20 +2197,20 @@ msgid "" "meth:`.datetime.timetuple`." msgstr "" -#: ../../library/datetime.rst:1462 +#: ../../library/datetime.rst:1495 msgid "" "Return the proleptic Gregorian ordinal of the date. The same as ``self." "date().toordinal()``." msgstr "" -#: ../../library/datetime.rst:1467 +#: ../../library/datetime.rst:1500 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:1471 +#: ../../library/datetime.rst:1504 msgid "" "Naive :class:`.datetime` instances are assumed to represent local time and " "this method relies on the platform C :c:func:`mktime` function to perform " @@ -2160,22 +2220,22 @@ msgid "" "future." msgstr "" -#: ../../library/datetime.rst:1478 +#: ../../library/datetime.rst:1511 msgid "" "For aware :class:`.datetime` instances, the return value is computed as::" msgstr "" -#: ../../library/datetime.rst:1481 +#: ../../library/datetime.rst:1514 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:1485 +#: ../../library/datetime.rst:1518 msgid "" "The :meth:`timestamp` method uses the :attr:`.fold` attribute to " "disambiguate the times during a repeated interval." msgstr "" -#: ../../library/datetime.rst:1491 +#: ../../library/datetime.rst:1524 msgid "" "There is no method to obtain the POSIX timestamp directly from a naive :" "class:`.datetime` instance representing UTC time. If your application uses " @@ -2183,57 +2243,57 @@ msgid "" "the POSIX timestamp by supplying ``tzinfo=timezone.utc``::" msgstr "" -#: ../../library/datetime.rst:1497 +#: ../../library/datetime.rst:1530 msgid "timestamp = dt.replace(tzinfo=timezone.utc).timestamp()" msgstr "timestamp = dt.replace(tzinfo=timezone.utc).timestamp()" -#: ../../library/datetime.rst:1499 +#: ../../library/datetime.rst:1532 msgid "or by calculating the timestamp directly::" msgstr "" -#: ../../library/datetime.rst:1501 +#: ../../library/datetime.rst:1534 msgid "timestamp = (dt - datetime(1970, 1, 1)) / timedelta(seconds=1)" msgstr "timestamp = (dt - datetime(1970, 1, 1)) / timedelta(seconds=1)" -#: ../../library/datetime.rst:1505 +#: ../../library/datetime.rst:1538 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:1511 +#: ../../library/datetime.rst:1544 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:1518 +#: ../../library/datetime.rst:1551 msgid "" "Return a :term:`named tuple` with three components: ``year``, ``week`` and " "``weekday``. The same as ``self.date().isocalendar()``." msgstr "" -#: ../../library/datetime.rst:1524 +#: ../../library/datetime.rst:1557 msgid "Return a string representing the date and time in ISO 8601 format:" msgstr "" -#: ../../library/datetime.rst:1526 +#: ../../library/datetime.rst:1559 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:1527 +#: ../../library/datetime.rst:1560 msgid "``YYYY-MM-DDTHH:MM:SS``, if :attr:`microsecond` is 0" msgstr "``YYYY-MM-DDTHH:MM:SS``,如果 :attr:`microsecond` 是 0" -#: ../../library/datetime.rst:1529 +#: ../../library/datetime.rst:1562 msgid "" "If :meth:`utcoffset` does not return ``None``, a string is appended, giving " "the UTC offset:" msgstr "" "如果 :meth:`utcoffset` 没有回傳 ``None``,則會附加一个字串,給出 UTC 偏移:" -#: ../../library/datetime.rst:1532 +#: ../../library/datetime.rst:1565 msgid "" "``YYYY-MM-DDTHH:MM:SS.ffffff+HH:MM[:SS[.ffffff]]``, if :attr:`microsecond` " "is not 0" @@ -2241,13 +2301,13 @@ msgstr "" "``YYYY-MM-DDTHH:MM:SS.ffffff+HH:MM[:SS[.ffffff]]``,如果 :attr:`microsecond` " "不是 0" -#: ../../library/datetime.rst:1534 +#: ../../library/datetime.rst:1567 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:1538 +#: ../../library/datetime.rst:1571 msgid "" ">>> from datetime import datetime, timezone\n" ">>> datetime(2019, 5, 18, 15, 17, 8, 132263).isoformat()\n" @@ -2261,13 +2321,13 @@ msgstr "" ">>> datetime(2019, 5, 18, 15, 17, tzinfo=timezone.utc).isoformat()\n" "'2019-05-18T15:17:00+00:00'" -#: ../../library/datetime.rst:1544 +#: ../../library/datetime.rst:1577 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:1547 +#: ../../library/datetime.rst:1580 msgid "" ">>> from datetime import tzinfo, timedelta, datetime\n" ">>> class TZ(tzinfo):\n" @@ -2280,54 +2340,64 @@ msgid "" ">>> datetime(2009, 11, 27, microsecond=100, tzinfo=TZ()).isoformat()\n" "'2009-11-27T00:00:00.000100-06:39'" msgstr "" +">>> from datetime import tzinfo, timedelta, datetime\n" +">>> class TZ(tzinfo):\n" +"... \"\"\"A time zone with an arbitrary, constant -06:39 offset.\"\"\"\n" +"... def utcoffset(self, dt):\n" +"... return timedelta(hours=-6, minutes=-39)\n" +"...\n" +">>> datetime(2002, 12, 25, tzinfo=TZ()).isoformat(' ')\n" +"'2002-12-25 00:00:00-06:39'\n" +">>> datetime(2009, 11, 27, microsecond=100, tzinfo=TZ()).isoformat()\n" +"'2009-11-27T00:00:00.000100-06:39'" -#: ../../library/datetime.rst:1558 ../../library/datetime.rst:1933 +#: ../../library/datetime.rst:1591 ../../library/datetime.rst:1982 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:1562 ../../library/datetime.rst:1937 +#: ../../library/datetime.rst:1595 ../../library/datetime.rst:1986 msgid "" "``'auto'``: Same as ``'seconds'`` if :attr:`microsecond` is 0, same as " "``'microseconds'`` otherwise." msgstr "" -#: ../../library/datetime.rst:1564 ../../library/datetime.rst:1939 +#: ../../library/datetime.rst:1597 ../../library/datetime.rst:1988 msgid "``'hours'``: Include the :attr:`hour` in the two-digit ``HH`` format." msgstr "" -#: ../../library/datetime.rst:1565 ../../library/datetime.rst:1940 +#: ../../library/datetime.rst:1598 ../../library/datetime.rst:1989 msgid "" "``'minutes'``: Include :attr:`hour` and :attr:`minute` in ``HH:MM`` format." msgstr "" -#: ../../library/datetime.rst:1566 ../../library/datetime.rst:1941 +#: ../../library/datetime.rst:1599 ../../library/datetime.rst:1990 msgid "" "``'seconds'``: Include :attr:`hour`, :attr:`minute`, and :attr:`second` in " "``HH:MM:SS`` format." msgstr "" -#: ../../library/datetime.rst:1568 ../../library/datetime.rst:1943 +#: ../../library/datetime.rst:1601 ../../library/datetime.rst:1992 msgid "" "``'milliseconds'``: Include full time, but truncate fractional second part " "to milliseconds. ``HH:MM:SS.sss`` format." msgstr "" -#: ../../library/datetime.rst:1570 ../../library/datetime.rst:1945 +#: ../../library/datetime.rst:1603 ../../library/datetime.rst:1994 msgid "``'microseconds'``: Include full time in ``HH:MM:SS.ffffff`` format." msgstr "" -#: ../../library/datetime.rst:1574 ../../library/datetime.rst:1949 +#: ../../library/datetime.rst:1607 ../../library/datetime.rst:1998 msgid "Excluded time components are truncated, not rounded." msgstr "" -#: ../../library/datetime.rst:1576 +#: ../../library/datetime.rst:1609 msgid ":exc:`ValueError` will be raised on an invalid *timespec* argument::" msgstr "" -#: ../../library/datetime.rst:1579 +#: ../../library/datetime.rst:1612 msgid "" ">>> from datetime import datetime\n" ">>> datetime.now().isoformat(timespec='minutes')\n" @@ -2343,21 +2413,21 @@ msgstr "" ">>> dt.isoformat(timespec='microseconds')\n" "'2015-01-01T12:30:59.000000'" -#: ../../library/datetime.rst:1586 ../../library/datetime.rst:1964 +#: ../../library/datetime.rst:1619 ../../library/datetime.rst:2013 msgid "Added the *timespec* parameter." msgstr "新增 *timespec* 參數。" -#: ../../library/datetime.rst:1592 +#: ../../library/datetime.rst:1625 msgid "" "For a :class:`.datetime` instance ``d``, ``str(d)`` is equivalent to ``d." "isoformat(' ')``." msgstr "" -#: ../../library/datetime.rst:1598 +#: ../../library/datetime.rst:1631 msgid "Return a string representing the date and time::" msgstr "" -#: ../../library/datetime.rst:1600 +#: ../../library/datetime.rst:1633 msgid "" ">>> from datetime import datetime\n" ">>> datetime(2002, 12, 4, 20, 30, 40).ctime()\n" @@ -2367,27 +2437,27 @@ msgstr "" ">>> datetime(2002, 12, 4, 20, 30, 40).ctime()\n" "'Wed Dec 4 20:30:40 2002'" -#: ../../library/datetime.rst:1604 +#: ../../library/datetime.rst:1637 msgid "" "The output string will *not* include time zone information, regardless of " "whether the input is aware or naive." msgstr "" -#: ../../library/datetime.rst:1611 +#: ../../library/datetime.rst:1644 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:1618 +#: ../../library/datetime.rst:1651 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:1625 +#: ../../library/datetime.rst:1658 msgid "" "Same as :meth:`.datetime.strftime`. This makes it possible to specify a " "format string for a :class:`.datetime` object in :ref:`formatted string " @@ -2395,15 +2465,15 @@ msgid "" "`strftime-strptime-behavior` and :meth:`datetime.isoformat`." msgstr "" -#: ../../library/datetime.rst:1632 +#: ../../library/datetime.rst:1665 msgid "Examples of Usage: :class:`.datetime`" msgstr "用法範例::class:`.datetime`" -#: ../../library/datetime.rst:1634 +#: ../../library/datetime.rst:1667 msgid "Examples of working with :class:`.datetime` objects:" msgstr "更多 :class:`.datetime` 的用法範例:" -#: ../../library/datetime.rst:1636 +#: ../../library/datetime.rst:1669 msgid "" ">>> from datetime import datetime, date, time, timezone\n" "\n" @@ -2457,14 +2527,14 @@ msgid "" "'The day is 21, the month is November, the time is 04:30PM.'" msgstr "" -#: ../../library/datetime.rst:1687 +#: ../../library/datetime.rst:1720 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:1691 +#: ../../library/datetime.rst:1724 msgid "" "from datetime import timedelta, datetime, tzinfo, timezone\n" "\n" @@ -2511,11 +2581,11 @@ msgid "" " return \"+04\"" msgstr "" -#: ../../library/datetime.rst:1734 +#: ../../library/datetime.rst:1767 msgid "Usage of ``KabulTz`` from above::" msgstr "" -#: ../../library/datetime.rst:1736 +#: ../../library/datetime.rst:1769 msgid "" ">>> tz1 = KabulTz()\n" "\n" @@ -2539,63 +2609,63 @@ msgid "" "True" msgstr "" -#: ../../library/datetime.rst:1760 +#: ../../library/datetime.rst:1793 msgid ":class:`.time` Objects" msgstr ":class:`.time` 物件" -#: ../../library/datetime.rst:1762 +#: ../../library/datetime.rst:1795 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:1767 +#: ../../library/datetime.rst:1800 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:1777 +#: ../../library/datetime.rst:1810 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:1785 +#: ../../library/datetime.rst:1818 msgid "The earliest representable :class:`.time`, ``time(0, 0, 0, 0)``." msgstr "" -#: ../../library/datetime.rst:1790 +#: ../../library/datetime.rst:1823 msgid "The latest representable :class:`.time`, ``time(23, 59, 59, 999999)``." msgstr "" -#: ../../library/datetime.rst:1795 +#: ../../library/datetime.rst:1828 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:1824 +#: ../../library/datetime.rst:1857 msgid "" "The object passed as the tzinfo argument to the :class:`.time` constructor, " "or ``None`` if none was passed." msgstr "" -#: ../../library/datetime.rst:1838 +#: ../../library/datetime.rst:1871 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:1841 +#: ../../library/datetime.rst:1874 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:1845 +#: ../../library/datetime.rst:1878 msgid "" "If both comparands are aware, and have the same :attr:`~.time.tzinfo` " "attribute, the :attr:`!tzinfo` and :attr:`!fold` attributes are ignored and " @@ -2604,18 +2674,18 @@ msgid "" "subtracting their UTC offsets (obtained from ``self.utcoffset()``)." msgstr "" -#: ../../library/datetime.rst:1851 +#: ../../library/datetime.rst:1884 msgid "" "Equality comparisons between aware and naive :class:`.time` instances don't " "raise :exc:`TypeError`." msgstr "" -#: ../../library/datetime.rst:1855 +#: ../../library/datetime.rst:1888 msgid "" "In Boolean contexts, a :class:`.time` object is always considered to be true." msgstr "" -#: ../../library/datetime.rst:1857 +#: ../../library/datetime.rst:1890 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-" @@ -2623,33 +2693,33 @@ msgid "" "details." msgstr "" -#: ../../library/datetime.rst:1864 -msgid "Other constructor:" -msgstr "" +#: ../../library/datetime.rst:1897 +msgid "Other constructors:" +msgstr "其他建構函式:" -#: ../../library/datetime.rst:1868 +#: ../../library/datetime.rst:1901 msgid "" "Return a :class:`.time` corresponding to a *time_string* in any valid ISO " "8601 format, with the following exceptions:" msgstr "" -#: ../../library/datetime.rst:1872 +#: ../../library/datetime.rst:1905 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:1874 +#: ../../library/datetime.rst:1907 msgid "" "Fractional seconds may have any number of digits (anything beyond 6 will be " "truncated)." msgstr "" -#: ../../library/datetime.rst:1878 +#: ../../library/datetime.rst:1911 msgid "Examples:" msgstr "範例: ::" -#: ../../library/datetime.rst:1880 +#: ../../library/datetime.rst:1913 msgid "" ">>> from datetime import time\n" ">>> time.fromisoformat('04:23:01')\n" @@ -2689,13 +2759,37 @@ msgstr "" ">>> time.fromisoformat('04:23:01+00:00')\n" "datetime.time(4, 23, 1, tzinfo=datetime.timezone.utc)" -#: ../../library/datetime.rst:1902 +#: ../../library/datetime.rst:1935 msgid "" "Previously, this method only supported formats that could be emitted by :" "meth:`time.isoformat`." msgstr "" -#: ../../library/datetime.rst:1912 +#: ../../library/datetime.rst:1941 +msgid "" +"Return a :class:`.time` corresponding to *date_string*, parsed according to " +"*format*." +msgstr "" + +#: ../../library/datetime.rst:1944 +msgid "" +"If *format* does not contain microseconds or timezone information, this is " +"equivalent to::" +msgstr "" + +#: ../../library/datetime.rst:1946 +msgid "time(*(time.strptime(date_string, format)[3:6]))" +msgstr "time(*(time.strptime(date_string, format)[3:6]))" + +#: ../../library/datetime.rst:1948 +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 " +"tuple. See also :ref:`strftime-strptime-behavior` and :meth:`time." +"fromisoformat`." +msgstr "" + +#: ../../library/datetime.rst:1961 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 " @@ -2703,41 +2797,41 @@ msgid "" "time data." msgstr "" -#: ../../library/datetime.rst:1917 +#: ../../library/datetime.rst:1966 msgid "" ":class:`.time` objects are also supported by generic function :func:`copy." "replace`." msgstr "" -#: ../../library/datetime.rst:1926 +#: ../../library/datetime.rst:1975 msgid "Return a string representing the time in ISO 8601 format, one of:" msgstr "" -#: ../../library/datetime.rst:1928 +#: ../../library/datetime.rst:1977 msgid "``HH:MM:SS.ffffff``, if :attr:`microsecond` is not 0" msgstr "" -#: ../../library/datetime.rst:1929 +#: ../../library/datetime.rst:1978 msgid "``HH:MM:SS``, if :attr:`microsecond` is 0" msgstr "" -#: ../../library/datetime.rst:1930 +#: ../../library/datetime.rst:1979 msgid "" "``HH:MM:SS.ffffff+HH:MM[:SS[.ffffff]]``, if :meth:`utcoffset` does not " "return ``None``" msgstr "" -#: ../../library/datetime.rst:1931 +#: ../../library/datetime.rst:1980 msgid "" "``HH:MM:SS+HH:MM[:SS[.ffffff]]``, if :attr:`microsecond` is 0 and :meth:" "`utcoffset` does not return ``None``" msgstr "" -#: ../../library/datetime.rst:1951 +#: ../../library/datetime.rst:2000 msgid ":exc:`ValueError` will be raised on an invalid *timespec* argument." msgstr "" -#: ../../library/datetime.rst:1955 +#: ../../library/datetime.rst:2004 msgid "" ">>> from datetime import time\n" ">>> time(hour=12, minute=34, second=56, microsecond=123456)." @@ -2759,18 +2853,18 @@ msgstr "" ">>> dt.isoformat(timespec='auto')\n" "'12:34:56'" -#: ../../library/datetime.rst:1970 +#: ../../library/datetime.rst:2019 msgid "For a time ``t``, ``str(t)`` is equivalent to ``t.isoformat()``." msgstr "" -#: ../../library/datetime.rst:1975 +#: ../../library/datetime.rst:2024 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:1981 +#: ../../library/datetime.rst:2030 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 >> from datetime import time, tzinfo, timedelta\n" ">>> class TZ1(tzinfo):\n" @@ -2859,18 +2953,18 @@ msgstr "" ">>> 'The {} is {:%H:%M}.'.format(\"time\", t)\n" "'The time is 12:10.'" -#: ../../library/datetime.rst:2046 +#: ../../library/datetime.rst:2095 msgid ":class:`tzinfo` Objects" msgstr ":class:`tzinfo` 物件" -#: ../../library/datetime.rst:2050 +#: ../../library/datetime.rst:2099 msgid "" "This is an 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:2054 +#: ../../library/datetime.rst:2103 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 " @@ -2880,7 +2974,7 @@ msgid "" "object passed to them." msgstr "" -#: ../../library/datetime.rst:2060 +#: ../../library/datetime.rst:2109 msgid "" "You need to derive a concrete subclass, and (at least) supply " "implementations of the standard :class:`tzinfo` methods needed by the :class:" @@ -2890,7 +2984,7 @@ msgid "" "American EST and EDT." msgstr "" -#: ../../library/datetime.rst:2067 +#: ../../library/datetime.rst:2116 msgid "" "Special requirement for pickling: A :class:`tzinfo` subclass must have an :" "meth:`~object.__init__` method that can be called with no arguments, " @@ -2898,20 +2992,20 @@ msgid "" "technical requirement that may be relaxed in the future." msgstr "" -#: ../../library/datetime.rst:2073 +#: ../../library/datetime.rst:2122 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:2080 +#: ../../library/datetime.rst:2129 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:2083 +#: ../../library/datetime.rst:2132 msgid "" "This represents the *total* offset from UTC; for example, if a :class:" "`tzinfo` object represents both time zone and DST adjustments, :meth:" @@ -2922,31 +3016,31 @@ msgid "" "meth:`utcoffset` will probably look like one of these two::" msgstr "" -#: ../../library/datetime.rst:2091 +#: ../../library/datetime.rst:2140 msgid "" "return CONSTANT # fixed-offset class\n" "return CONSTANT + self.dst(dt) # daylight-aware class" msgstr "" -#: ../../library/datetime.rst:2094 +#: ../../library/datetime.rst:2143 msgid "" "If :meth:`utcoffset` does not return ``None``, :meth:`dst` should not return " "``None`` either." msgstr "" -#: ../../library/datetime.rst:2097 +#: ../../library/datetime.rst:2146 msgid "" "The default implementation of :meth:`utcoffset` raises :exc:" "`NotImplementedError`." msgstr "" -#: ../../library/datetime.rst:2106 +#: ../../library/datetime.rst:2155 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:2110 +#: ../../library/datetime.rst:2159 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 " @@ -2959,17 +3053,17 @@ msgid "" "to account for DST changes when crossing time zones." msgstr "" -#: ../../library/datetime.rst:2120 +#: ../../library/datetime.rst:2169 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:2123 +#: ../../library/datetime.rst:2172 msgid "``tz.utcoffset(dt) - tz.dst(dt)``" msgstr "``tz.utcoffset(dt) - tz.dst(dt)``" -#: ../../library/datetime.rst:2125 +#: ../../library/datetime.rst:2174 msgid "" "must return the same result for every :class:`.datetime` *dt* with ``dt." "tzinfo == tz``. For sane :class:`tzinfo` subclasses, this expression yields " @@ -2982,24 +3076,24 @@ msgid "" "astimezone` regardless." msgstr "" -#: ../../library/datetime.rst:2134 +#: ../../library/datetime.rst:2183 msgid "" "Most implementations of :meth:`dst` will probably look like one of these " "two::" msgstr "" -#: ../../library/datetime.rst:2136 +#: ../../library/datetime.rst:2185 msgid "" "def dst(self, dt):\n" " # a fixed-offset class: doesn't account for DST\n" " return timedelta(0)" msgstr "" -#: ../../library/datetime.rst:2140 +#: ../../library/datetime.rst:2189 msgid "or::" msgstr "或是: ::" -#: ../../library/datetime.rst:2142 +#: ../../library/datetime.rst:2191 msgid "" "def dst(self, dt):\n" " # Code to set dston and dstoff to the time zone's DST\n" @@ -3012,12 +3106,12 @@ msgid "" " return timedelta(0)" msgstr "" -#: ../../library/datetime.rst:2152 +#: ../../library/datetime.rst:2201 msgid "" "The default implementation of :meth:`dst` raises :exc:`NotImplementedError`." msgstr "" -#: ../../library/datetime.rst:2160 +#: ../../library/datetime.rst:2209 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:`!" @@ -3031,13 +3125,13 @@ msgid "" "accounting for daylight time." msgstr "" -#: ../../library/datetime.rst:2170 +#: ../../library/datetime.rst:2219 msgid "" "The default implementation of :meth:`tzname` raises :exc:" "`NotImplementedError`." msgstr "" -#: ../../library/datetime.rst:2173 +#: ../../library/datetime.rst:2222 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 " @@ -3047,7 +3141,7 @@ msgid "" "datetime`." msgstr "" -#: ../../library/datetime.rst:2179 +#: ../../library/datetime.rst:2228 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 " @@ -3056,7 +3150,7 @@ msgid "" "offset, as there is no other convention for discovering the standard offset." msgstr "" -#: ../../library/datetime.rst:2185 +#: ../../library/datetime.rst:2234 msgid "" "When a :class:`.datetime` object is passed in response to a :class:`." "datetime` method, ``dt.tzinfo`` is the same object as *self*. :class:" @@ -3066,13 +3160,13 @@ msgid "" "zones." msgstr "" -#: ../../library/datetime.rst:2191 +#: ../../library/datetime.rst:2240 msgid "" "There is one more :class:`tzinfo` method that a subclass may wish to " "override:" msgstr "" -#: ../../library/datetime.rst:2196 +#: ../../library/datetime.rst:2245 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 " @@ -3081,7 +3175,7 @@ msgid "" "datetime in *self*'s local time." msgstr "" -#: ../../library/datetime.rst:2202 +#: ../../library/datetime.rst:2251 msgid "" "Most :class:`tzinfo` subclasses should be able to inherit the default :meth:" "`fromutc` implementation without problems. It's strong enough to handle " @@ -3096,13 +3190,13 @@ msgid "" "offset changes." msgstr "" -#: ../../library/datetime.rst:2213 +#: ../../library/datetime.rst:2262 msgid "" "Skipping code for error cases, the default :meth:`fromutc` implementation " "acts like::" msgstr "" -#: ../../library/datetime.rst:2216 +#: ../../library/datetime.rst:2265 msgid "" "def fromutc(self, dt):\n" " # raise ValueError error if dt.tzinfo is not self\n" @@ -3120,13 +3214,13 @@ msgid "" " return dt" msgstr "" -#: ../../library/datetime.rst:2231 +#: ../../library/datetime.rst:2280 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:2235 +#: ../../library/datetime.rst:2284 msgid "" "from datetime import tzinfo, timedelta, datetime\n" "\n" @@ -3306,7 +3400,7 @@ msgid "" "Pacific = USTimeZone(-8, \"Pacific\", \"PST\", \"PDT\")\n" msgstr "" -#: ../../library/datetime.rst:2237 +#: ../../library/datetime.rst:2286 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 " @@ -3315,7 +3409,7 @@ msgid "" "ends the minute after 1:59 (EDT) on the first Sunday in November::" msgstr "" -#: ../../library/datetime.rst:2243 +#: ../../library/datetime.rst:2292 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" @@ -3333,7 +3427,7 @@ msgstr "" "\n" " end 23:MM 0:MM 1:MM 1:MM 2:MM 3:MM" -#: ../../library/datetime.rst:2251 +#: ../../library/datetime.rst:2300 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, " @@ -3342,7 +3436,7 @@ msgid "" "get::" msgstr "" -#: ../../library/datetime.rst:2256 +#: ../../library/datetime.rst:2305 msgid "" ">>> from datetime import datetime, timezone\n" ">>> from tzinfo_examples import HOUR, Eastern\n" @@ -3370,7 +3464,7 @@ msgstr "" "07:00:00 UTC = 03:00:00 EDT\n" "08:00:00 UTC = 04:00:00 EDT" -#: ../../library/datetime.rst:2270 +#: ../../library/datetime.rst:2319 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 " @@ -3385,7 +3479,7 @@ msgid "" "Fall back transition of 2016, we get::" msgstr "" -#: ../../library/datetime.rst:2281 +#: ../../library/datetime.rst:2330 msgid "" ">>> u0 = datetime(2016, 11, 6, 4, tzinfo=timezone.utc)\n" ">>> for i in range(4):\n" @@ -3409,13 +3503,13 @@ msgstr "" "06:00:00 UTC = 01:00:00 EST 1\n" "07:00:00 UTC = 02:00:00 EST 0" -#: ../../library/datetime.rst:2292 +#: ../../library/datetime.rst:2341 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:2295 +#: ../../library/datetime.rst:2344 msgid "" "Applications that can't bear wall-time ambiguities should explicitly check " "the value of the :attr:`~.datetime.fold` attribute or avoid using hybrid :" @@ -3425,28 +3519,28 @@ msgid "" "offset -4 hours))." msgstr "" -#: ../../library/datetime.rst:2303 +#: ../../library/datetime.rst:2352 msgid ":mod:`zoneinfo`" msgstr ":mod:`zoneinfo`" -#: ../../library/datetime.rst:2304 +#: ../../library/datetime.rst:2353 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:2308 +#: ../../library/datetime.rst:2357 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:2311 +#: ../../library/datetime.rst:2360 msgid "`IANA time zone database `_" msgstr "`IANA 時區資料庫 `_" -#: ../../library/datetime.rst:2312 +#: ../../library/datetime.rst:2361 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 " @@ -3455,24 +3549,24 @@ msgid "" "saving rules." msgstr "" -#: ../../library/datetime.rst:2322 +#: ../../library/datetime.rst:2371 msgid ":class:`timezone` Objects" msgstr ":class:`timezone` 物件" -#: ../../library/datetime.rst:2324 +#: ../../library/datetime.rst:2373 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:2328 +#: ../../library/datetime.rst:2377 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:2335 +#: ../../library/datetime.rst:2384 msgid "" "The *offset* argument must be specified as a :class:`timedelta` object " "representing the difference between the local time and UTC. It must be " @@ -3480,25 +3574,25 @@ msgid "" "otherwise :exc:`ValueError` is raised." msgstr "" -#: ../../library/datetime.rst:2340 +#: ../../library/datetime.rst:2389 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:2351 ../../library/datetime.rst:2362 +#: ../../library/datetime.rst:2400 ../../library/datetime.rst:2411 msgid "" "Return the fixed value specified when the :class:`timezone` instance is " "constructed." msgstr "" -#: ../../library/datetime.rst:2354 +#: ../../library/datetime.rst:2403 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:2365 +#: ../../library/datetime.rst:2414 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 " @@ -3507,119 +3601,106 @@ msgid "" "are two digits of ``offset.hours`` and ``offset.minutes`` respectively." msgstr "" -#: ../../library/datetime.rst:2371 +#: ../../library/datetime.rst:2420 msgid "" "Name generated from ``offset=timedelta(0)`` is now plain ``'UTC'``, not " "``'UTC+00:00'``." msgstr "" -#: ../../library/datetime.rst:2378 +#: ../../library/datetime.rst:2427 msgid "Always returns ``None``." msgstr "總是回傳 ``None``。" -#: ../../library/datetime.rst:2382 +#: ../../library/datetime.rst:2431 msgid "" "Return ``dt + offset``. The *dt* argument must be an aware :class:`." "datetime` instance, with ``tzinfo`` set to ``self``." msgstr "" -#: ../../library/datetime.rst:2389 +#: ../../library/datetime.rst:2438 msgid "The UTC time zone, ``timezone(timedelta(0))``." msgstr "UTC 時區,``timezone(timedelta(0))``。" -#: ../../library/datetime.rst:2398 +#: ../../library/datetime.rst:2447 msgid ":meth:`~.datetime.strftime` and :meth:`~.datetime.strptime` Behavior" msgstr ":meth:`~.datetime.strftime` 與 :meth:`~.datetime.strptime` 的行為" -#: ../../library/datetime.rst:2400 +#: ../../library/datetime.rst:2449 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:2404 +#: ../../library/datetime.rst:2453 msgid "" -"Conversely, the :meth:`datetime.strptime` class method creates a :class:`." -"datetime` object from a string representing a date and time and a " -"corresponding format string." +"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:2408 +#: ../../library/datetime.rst:2457 msgid "" "The table below provides a high-level comparison of :meth:`~.datetime." "strftime` versus :meth:`~.datetime.strptime`:" msgstr "" -#: ../../library/datetime.rst:2412 +#: ../../library/datetime.rst:2461 msgid "``strftime``" msgstr "``strftime``" -#: ../../library/datetime.rst:2412 +#: ../../library/datetime.rst:2461 msgid "``strptime``" msgstr "``strptime``" -#: ../../library/datetime.rst:2414 +#: ../../library/datetime.rst:2463 msgid "Usage" msgstr "用法" -#: ../../library/datetime.rst:2414 +#: ../../library/datetime.rst:2463 msgid "Convert object to a string according to a given format" msgstr "" -#: ../../library/datetime.rst:2414 -msgid "" -"Parse a string into a :class:`.datetime` object given a corresponding format" +#: ../../library/datetime.rst:2463 +msgid "Parse a string into an object given a corresponding format" msgstr "" -#: ../../library/datetime.rst:2416 +#: ../../library/datetime.rst:2465 msgid "Type of method" msgstr "" -#: ../../library/datetime.rst:2416 +#: ../../library/datetime.rst:2465 msgid "Instance method" msgstr "實例方法" -#: ../../library/datetime.rst:2416 +#: ../../library/datetime.rst:2465 msgid "Class method" msgstr "類別方法" -#: ../../library/datetime.rst:2418 -msgid "Method of" -msgstr "" - -#: ../../library/datetime.rst:2418 -msgid ":class:`date`; :class:`.datetime`; :class:`.time`" -msgstr ":class:`date`; :class:`.datetime`; :class:`.time`" - -#: ../../library/datetime.rst:2418 -msgid ":class:`.datetime`" -msgstr ":class:`.datetime`" - -#: ../../library/datetime.rst:2420 +#: ../../library/datetime.rst:2467 msgid "Signature" msgstr "" -#: ../../library/datetime.rst:2420 +#: ../../library/datetime.rst:2467 msgid "``strftime(format)``" msgstr "``strftime(format)``" -#: ../../library/datetime.rst:2420 +#: ../../library/datetime.rst:2467 msgid "``strptime(date_string, format)``" msgstr "``strptime(date_string, format)``" -#: ../../library/datetime.rst:2427 +#: ../../library/datetime.rst:2474 msgid "" ":meth:`~.datetime.strftime` and :meth:`~.datetime.strptime` Format Codes" msgstr ":meth:`~.datetime.strftime` 與 :meth:`~.datetime.strptime` 格式碼" -#: ../../library/datetime.rst:2429 +#: ../../library/datetime.rst:2476 msgid "" "These methods accept format codes that can be used to parse and format " "dates::" msgstr "" -#: ../../library/datetime.rst:2431 +#: ../../library/datetime.rst:2478 msgid "" ">>> datetime.strptime('31/01/22 23:59:59.999999',\n" "... '%d/%m/%y %H:%M:%S.%f')\n" @@ -3633,441 +3714,441 @@ msgstr "" ">>> _.strftime('%a %d %b %Y, %I:%M%p')\n" "'Mon 31 Jan 2022, 11:59PM'" -#: ../../library/datetime.rst:2437 +#: ../../library/datetime.rst:2484 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." msgstr "" -#: ../../library/datetime.rst:2441 ../../library/datetime.rst:2544 +#: ../../library/datetime.rst:2488 ../../library/datetime.rst:2591 msgid "Directive" msgstr "" -#: ../../library/datetime.rst:2441 ../../library/datetime.rst:2544 +#: ../../library/datetime.rst:2488 ../../library/datetime.rst:2591 msgid "Meaning" msgstr "含義" -#: ../../library/datetime.rst:2441 ../../library/datetime.rst:2544 +#: ../../library/datetime.rst:2488 ../../library/datetime.rst:2591 msgid "Example" msgstr "範例" -#: ../../library/datetime.rst:2441 ../../library/datetime.rst:2544 +#: ../../library/datetime.rst:2488 ../../library/datetime.rst:2591 msgid "Notes" msgstr "註解" -#: ../../library/datetime.rst:2443 +#: ../../library/datetime.rst:2490 msgid "``%a``" msgstr "``%a``" -#: ../../library/datetime.rst:2443 +#: ../../library/datetime.rst:2490 msgid "Weekday as locale's abbreviated name." msgstr "" -#: ../../library/datetime.rst:0 +#: ../../library/datetime.rst:2490 msgid "Sun, Mon, ..., Sat (en_US);" msgstr "" -#: ../../library/datetime.rst:0 +#: ../../library/datetime.rst:2492 msgid "So, Mo, ..., Sa (de_DE)" msgstr "" -#: ../../library/datetime.rst:2448 +#: ../../library/datetime.rst:2495 msgid "``%A``" msgstr "``%A``" -#: ../../library/datetime.rst:2448 +#: ../../library/datetime.rst:2495 msgid "Weekday as locale's full name." msgstr "" -#: ../../library/datetime.rst:0 +#: ../../library/datetime.rst:2495 msgid "Sunday, Monday, ..., Saturday (en_US);" msgstr "" -#: ../../library/datetime.rst:0 +#: ../../library/datetime.rst:2497 msgid "Sonntag, Montag, ..., Samstag (de_DE)" msgstr "" -#: ../../library/datetime.rst:2453 +#: ../../library/datetime.rst:2500 msgid "``%w``" msgstr "``%w``" -#: ../../library/datetime.rst:2453 +#: ../../library/datetime.rst:2500 msgid "Weekday as a decimal number, where 0 is Sunday and 6 is Saturday." msgstr "" -#: ../../library/datetime.rst:2453 +#: ../../library/datetime.rst:2500 msgid "0, 1, ..., 6" msgstr "0, 1, ..., 6" -#: ../../library/datetime.rst:2457 +#: ../../library/datetime.rst:2504 msgid "``%d``" msgstr "``%d``" -#: ../../library/datetime.rst:2457 +#: ../../library/datetime.rst:2504 msgid "Day of the month as a zero-padded decimal number." msgstr "" -#: ../../library/datetime.rst:2457 +#: ../../library/datetime.rst:2504 msgid "01, 02, ..., 31" msgstr "01, 02, ..., 31" -#: ../../library/datetime.rst:2457 ../../library/datetime.rst:2470 -#: ../../library/datetime.rst:2473 ../../library/datetime.rst:2479 -#: ../../library/datetime.rst:2482 ../../library/datetime.rst:2488 -#: ../../library/datetime.rst:2506 +#: ../../library/datetime.rst:2504 ../../library/datetime.rst:2517 +#: ../../library/datetime.rst:2520 ../../library/datetime.rst:2526 +#: ../../library/datetime.rst:2529 ../../library/datetime.rst:2535 +#: ../../library/datetime.rst:2553 msgid "\\(9)" msgstr "\\(9)" -#: ../../library/datetime.rst:2460 +#: ../../library/datetime.rst:2507 msgid "``%b``" msgstr "``%b``" -#: ../../library/datetime.rst:2460 +#: ../../library/datetime.rst:2507 msgid "Month as locale's abbreviated name." msgstr "" -#: ../../library/datetime.rst:0 +#: ../../library/datetime.rst:2507 msgid "Jan, Feb, ..., Dec (en_US);" msgstr "" -#: ../../library/datetime.rst:0 +#: ../../library/datetime.rst:2509 msgid "Jan, Feb, ..., Dez (de_DE)" msgstr "" -#: ../../library/datetime.rst:2465 +#: ../../library/datetime.rst:2512 msgid "``%B``" msgstr "``%B``" -#: ../../library/datetime.rst:2465 +#: ../../library/datetime.rst:2512 msgid "Month as locale's full name." msgstr "" -#: ../../library/datetime.rst:0 +#: ../../library/datetime.rst:2512 msgid "January, February, ..., December (en_US);" msgstr "" -#: ../../library/datetime.rst:0 +#: ../../library/datetime.rst:2514 msgid "Januar, Februar, ..., Dezember (de_DE)" msgstr "" -#: ../../library/datetime.rst:2470 +#: ../../library/datetime.rst:2517 msgid "``%m``" msgstr "``%m``" -#: ../../library/datetime.rst:2470 +#: ../../library/datetime.rst:2517 msgid "Month as a zero-padded decimal number." msgstr "以零填充的並以十進位數字表示的月份。" -#: ../../library/datetime.rst:2470 ../../library/datetime.rst:2482 +#: ../../library/datetime.rst:2517 ../../library/datetime.rst:2529 msgid "01, 02, ..., 12" msgstr "01, 02, ..., 12" -#: ../../library/datetime.rst:2473 +#: ../../library/datetime.rst:2520 msgid "``%y``" msgstr "``%y``" -#: ../../library/datetime.rst:2473 +#: ../../library/datetime.rst:2520 msgid "Year without century as a zero-padded decimal number." msgstr "" -#: ../../library/datetime.rst:2473 +#: ../../library/datetime.rst:2520 msgid "00, 01, ..., 99" msgstr "00, 01, ..., 99" -#: ../../library/datetime.rst:2476 +#: ../../library/datetime.rst:2523 msgid "``%Y``" msgstr "``%Y``" -#: ../../library/datetime.rst:2476 +#: ../../library/datetime.rst:2523 msgid "Year with century as a decimal number." msgstr "" -#: ../../library/datetime.rst:2476 ../../library/datetime.rst:2546 +#: ../../library/datetime.rst:2523 ../../library/datetime.rst:2593 msgid "0001, 0002, ..., 2013, 2014, ..., 9998, 9999" msgstr "0001, 0002, ..., 2013, 2014, ..., 9998, 9999" -#: ../../library/datetime.rst:2479 +#: ../../library/datetime.rst:2526 msgid "``%H``" msgstr "``%H``" -#: ../../library/datetime.rst:2479 +#: ../../library/datetime.rst:2526 msgid "Hour (24-hour clock) as a zero-padded decimal number." msgstr "" -#: ../../library/datetime.rst:2479 +#: ../../library/datetime.rst:2526 msgid "00, 01, ..., 23" msgstr "00, 01, ..., 23" -#: ../../library/datetime.rst:2482 +#: ../../library/datetime.rst:2529 msgid "``%I``" msgstr "``%I``" -#: ../../library/datetime.rst:2482 +#: ../../library/datetime.rst:2529 msgid "Hour (12-hour clock) as a zero-padded decimal number." msgstr "" -#: ../../library/datetime.rst:2485 +#: ../../library/datetime.rst:2532 msgid "``%p``" msgstr "``%p``" -#: ../../library/datetime.rst:2485 +#: ../../library/datetime.rst:2532 msgid "Locale's equivalent of either AM or PM." msgstr "" -#: ../../library/datetime.rst:0 +#: ../../library/datetime.rst:2532 msgid "AM, PM (en_US);" msgstr "AM, PM (en_US);" -#: ../../library/datetime.rst:0 +#: ../../library/datetime.rst:2533 msgid "am, pm (de_DE)" msgstr "am, pm (de_DE)" -#: ../../library/datetime.rst:2485 +#: ../../library/datetime.rst:2532 msgid "\\(1), \\(3)" msgstr "\\(1), \\(3)" -#: ../../library/datetime.rst:2488 +#: ../../library/datetime.rst:2535 msgid "``%M``" msgstr "``%M``" -#: ../../library/datetime.rst:2488 +#: ../../library/datetime.rst:2535 msgid "Minute as a zero-padded decimal number." msgstr "" -#: ../../library/datetime.rst:2488 ../../library/datetime.rst:2491 +#: ../../library/datetime.rst:2535 ../../library/datetime.rst:2538 msgid "00, 01, ..., 59" msgstr "00, 01, ..., 59" -#: ../../library/datetime.rst:2491 +#: ../../library/datetime.rst:2538 msgid "``%S``" msgstr "``%S``" -#: ../../library/datetime.rst:2491 +#: ../../library/datetime.rst:2538 msgid "Second as a zero-padded decimal number." msgstr "" -#: ../../library/datetime.rst:2491 +#: ../../library/datetime.rst:2538 msgid "\\(4), \\(9)" msgstr "\\(4), \\(9)" -#: ../../library/datetime.rst:2494 +#: ../../library/datetime.rst:2541 msgid "``%f``" msgstr "``%f``" -#: ../../library/datetime.rst:2494 +#: ../../library/datetime.rst:2541 msgid "Microsecond as a decimal number, zero-padded to 6 digits." msgstr "" -#: ../../library/datetime.rst:2494 +#: ../../library/datetime.rst:2541 msgid "000000, 000001, ..., 999999" msgstr "000000, 000001, ..., 999999" -#: ../../library/datetime.rst:2494 +#: ../../library/datetime.rst:2541 msgid "\\(5)" msgstr "\\(5)" -#: ../../library/datetime.rst:2498 ../../library/datetime.rst:2657 +#: ../../library/datetime.rst:2545 ../../library/datetime.rst:2704 msgid "``%z``" msgstr "``%z``" -#: ../../library/datetime.rst:2498 +#: ../../library/datetime.rst:2545 msgid "" "UTC offset in the form ``±HHMM[SS[.ffffff]]`` (empty string if the object is " "naive)." msgstr "" -#: ../../library/datetime.rst:2498 +#: ../../library/datetime.rst:2545 msgid "(empty), +0000, -0400, +1030, +063415, -030712.345216" msgstr "" -#: ../../library/datetime.rst:2498 ../../library/datetime.rst:2503 -#: ../../library/datetime.rst:2560 +#: ../../library/datetime.rst:2545 ../../library/datetime.rst:2550 +#: ../../library/datetime.rst:2607 msgid "\\(6)" msgstr "\\(6)" -#: ../../library/datetime.rst:2503 ../../library/datetime.rst:2683 +#: ../../library/datetime.rst:2550 ../../library/datetime.rst:2730 msgid "``%Z``" msgstr "``%Z``" -#: ../../library/datetime.rst:2503 +#: ../../library/datetime.rst:2550 msgid "Time zone name (empty string if the object is naive)." msgstr "" -#: ../../library/datetime.rst:2503 +#: ../../library/datetime.rst:2550 msgid "(empty), UTC, GMT" msgstr "" -#: ../../library/datetime.rst:2506 +#: ../../library/datetime.rst:2553 msgid "``%j``" msgstr "``%j``" -#: ../../library/datetime.rst:2506 +#: ../../library/datetime.rst:2553 msgid "Day of the year as a zero-padded decimal number." msgstr "" -#: ../../library/datetime.rst:2506 +#: ../../library/datetime.rst:2553 msgid "001, 002, ..., 366" msgstr "001, 002, ..., 366" -#: ../../library/datetime.rst:2509 +#: ../../library/datetime.rst:2556 msgid "``%U``" msgstr "``%U``" -#: ../../library/datetime.rst:2509 +#: ../../library/datetime.rst:2556 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:2509 ../../library/datetime.rst:2517 +#: ../../library/datetime.rst:2556 ../../library/datetime.rst:2564 msgid "00, 01, ..., 53" msgstr "00, 01, ..., 53" -#: ../../library/datetime.rst:2509 ../../library/datetime.rst:2517 +#: ../../library/datetime.rst:2556 ../../library/datetime.rst:2564 msgid "\\(7), \\(9)" msgstr "\\(7), \\(9)" -#: ../../library/datetime.rst:2517 +#: ../../library/datetime.rst:2564 msgid "``%W``" msgstr "``%W``" -#: ../../library/datetime.rst:2517 +#: ../../library/datetime.rst:2564 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:2525 +#: ../../library/datetime.rst:2572 msgid "``%c``" msgstr "``%c``" -#: ../../library/datetime.rst:2525 +#: ../../library/datetime.rst:2572 msgid "Locale's appropriate date and time representation." msgstr "" -#: ../../library/datetime.rst:0 +#: ../../library/datetime.rst:2572 msgid "Tue Aug 16 21:30:00 1988 (en_US);" msgstr "" -#: ../../library/datetime.rst:0 +#: ../../library/datetime.rst:2574 msgid "Di 16 Aug 21:30:00 1988 (de_DE)" msgstr "" -#: ../../library/datetime.rst:2530 +#: ../../library/datetime.rst:2577 msgid "``%x``" msgstr "``%x``" -#: ../../library/datetime.rst:2530 +#: ../../library/datetime.rst:2577 msgid "Locale's appropriate date representation." msgstr "" -#: ../../library/datetime.rst:0 +#: ../../library/datetime.rst:2577 msgid "08/16/88 (None);" msgstr "" -#: ../../library/datetime.rst:0 +#: ../../library/datetime.rst:2578 msgid "08/16/1988 (en_US);" msgstr "" -#: ../../library/datetime.rst:0 +#: ../../library/datetime.rst:2579 msgid "16.08.1988 (de_DE)" msgstr "" -#: ../../library/datetime.rst:2534 +#: ../../library/datetime.rst:2581 msgid "``%X``" msgstr "``%X``" -#: ../../library/datetime.rst:2534 +#: ../../library/datetime.rst:2581 msgid "Locale's appropriate time representation." msgstr "" -#: ../../library/datetime.rst:0 +#: ../../library/datetime.rst:2581 msgid "21:30:00 (en_US);" msgstr "" -#: ../../library/datetime.rst:0 +#: ../../library/datetime.rst:2582 msgid "21:30:00 (de_DE)" msgstr "" -#: ../../library/datetime.rst:2537 +#: ../../library/datetime.rst:2584 msgid "``%%``" msgstr "``%%``" -#: ../../library/datetime.rst:2537 +#: ../../library/datetime.rst:2584 msgid "A literal ``'%'`` character." msgstr "" -#: ../../library/datetime.rst:2537 +#: ../../library/datetime.rst:2584 msgid "%" msgstr "%" -#: ../../library/datetime.rst:2540 +#: ../../library/datetime.rst:2587 msgid "" "Several additional directives not required by the C89 standard are included " "for convenience. These parameters all correspond to ISO 8601 date values." msgstr "" -#: ../../library/datetime.rst:2546 +#: ../../library/datetime.rst:2593 msgid "``%G``" msgstr "``%G``" -#: ../../library/datetime.rst:2546 +#: ../../library/datetime.rst:2593 msgid "" "ISO 8601 year with century representing the year that contains the greater " "part of the ISO week (``%V``)." msgstr "" -#: ../../library/datetime.rst:2546 +#: ../../library/datetime.rst:2593 msgid "\\(8)" msgstr "\\(8)" -#: ../../library/datetime.rst:2551 +#: ../../library/datetime.rst:2598 msgid "``%u``" msgstr "``%u``" -#: ../../library/datetime.rst:2551 +#: ../../library/datetime.rst:2598 msgid "ISO 8601 weekday as a decimal number where 1 is Monday." msgstr "" -#: ../../library/datetime.rst:2551 +#: ../../library/datetime.rst:2598 msgid "1, 2, ..., 7" msgstr "1, 2, ..., 7" -#: ../../library/datetime.rst:2554 +#: ../../library/datetime.rst:2601 msgid "``%V``" msgstr "``%V``" -#: ../../library/datetime.rst:2554 +#: ../../library/datetime.rst:2601 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." msgstr "" -#: ../../library/datetime.rst:2554 +#: ../../library/datetime.rst:2601 msgid "01, 02, ..., 53" msgstr "01, 02, ..., 53" -#: ../../library/datetime.rst:2554 +#: ../../library/datetime.rst:2601 msgid "\\(8), \\(9)" msgstr "\\(8), \\(9)" -#: ../../library/datetime.rst:2560 ../../library/datetime.rst:2679 +#: ../../library/datetime.rst:2607 ../../library/datetime.rst:2726 msgid "``%:z``" msgstr "``%:z``" -#: ../../library/datetime.rst:2560 +#: ../../library/datetime.rst:2607 msgid "" "UTC offset in the form ``±HH:MM[:SS[.ffffff]]`` (empty string if the object " "is naive)." msgstr "" -#: ../../library/datetime.rst:2560 +#: ../../library/datetime.rst:2607 msgid "(empty), +00:00, -04:00, +10:30, +06:34:15, -03:07:12.345216" msgstr "" -#: ../../library/datetime.rst:2566 +#: ../../library/datetime.rst:2613 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 " @@ -4076,7 +4157,7 @@ msgid "" "directives will raise a :exc:`ValueError`." msgstr "" -#: ../../library/datetime.rst:2571 +#: ../../library/datetime.rst:2618 msgid "" "The full set of format codes supported varies across platforms, because " "Python calls the platform C library's :c:func:`strftime` function, and " @@ -4086,44 +4167,44 @@ msgid "" "unsupported format specifiers." msgstr "" -#: ../../library/datetime.rst:2577 +#: ../../library/datetime.rst:2624 msgid "``%G``, ``%u`` and ``%V`` were added." msgstr "新增 ``%G``、``%u`` 與 ``%V``。" -#: ../../library/datetime.rst:2580 +#: ../../library/datetime.rst:2627 msgid "``%:z`` was added." msgstr "新增 ``%:z``。" -#: ../../library/datetime.rst:2584 +#: ../../library/datetime.rst:2631 msgid "Technical Detail" msgstr "技術細節" -#: ../../library/datetime.rst:2586 +#: ../../library/datetime.rst:2633 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:2590 +#: ../../library/datetime.rst:2637 msgid "" "For the :meth:`.datetime.strptime` class method, 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:2594 +#: ../../library/datetime.rst:2641 msgid "Using ``datetime.strptime(date_string, format)`` is equivalent to::" msgstr "" -#: ../../library/datetime.rst:2598 +#: ../../library/datetime.rst:2645 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:2602 +#: ../../library/datetime.rst:2649 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 " @@ -4133,7 +4214,7 @@ msgstr "" "time` 物件並沒有這些值。如果使用這些格式碼,年份會以 1900 代替、月及日會以 1 " "代替。" -#: ../../library/datetime.rst:2606 +#: ../../library/datetime.rst:2653 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 " @@ -4142,7 +4223,7 @@ msgstr "" "對 :class:`.date` 物件來說,不應該使用時、分、秒、微秒的格式碼,因為 :class:" "`date` 物件並沒有這些值。如果使用這些格式碼,這些值都會以 0 代替。" -#: ../../library/datetime.rst:2610 +#: ../../library/datetime.rst:2657 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 " @@ -4151,7 +4232,7 @@ msgid "" "`UnicodeError` or return an empty string instead." msgstr "" -#: ../../library/datetime.rst:2619 +#: ../../library/datetime.rst:2666 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 " @@ -4159,38 +4240,38 @@ msgid "" "contain non-ASCII characters." msgstr "" -#: ../../library/datetime.rst:2625 +#: ../../library/datetime.rst:2672 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:2628 +#: ../../library/datetime.rst:2675 msgid "" "In previous versions, :meth:`~.datetime.strftime` method was restricted to " "years >= 1900." msgstr "" -#: ../../library/datetime.rst:2632 +#: ../../library/datetime.rst:2679 msgid "" "In version 3.2, :meth:`~.datetime.strftime` method was restricted to years " ">= 1000." msgstr "" -#: ../../library/datetime.rst:2637 +#: ../../library/datetime.rst:2684 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:2641 +#: ../../library/datetime.rst:2688 msgid "" "Unlike the :mod:`time` module, the :mod:`!datetime` module does not support " "leap seconds." msgstr "" -#: ../../library/datetime.rst:2645 +#: ../../library/datetime.rst:2692 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 " @@ -4198,17 +4279,17 @@ msgid "" "separately in datetime objects, and therefore always available)." msgstr "" -#: ../../library/datetime.rst:2652 +#: ../../library/datetime.rst:2699 msgid "" "For a naive object, the ``%z``, ``%:z`` and ``%Z`` format codes are replaced " "by empty strings." msgstr "" -#: ../../library/datetime.rst:2655 +#: ../../library/datetime.rst:2702 msgid "For an aware object:" msgstr "" -#: ../../library/datetime.rst:2658 +#: ../../library/datetime.rst:2705 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 " @@ -4222,7 +4303,7 @@ msgid "" "replaced with the string ``'-0330'``." msgstr "" -#: ../../library/datetime.rst:2672 +#: ../../library/datetime.rst:2719 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, " @@ -4231,53 +4312,53 @@ msgid "" "``'+00:00'``." msgstr "" -#: ../../library/datetime.rst:2680 +#: ../../library/datetime.rst:2727 msgid "" "Behaves exactly as ``%z``, but has a colon separator added between hours, " "minutes and seconds." msgstr "" -#: ../../library/datetime.rst:2684 +#: ../../library/datetime.rst:2731 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:2688 +#: ../../library/datetime.rst:2735 msgid ":meth:`~.datetime.strptime` only accepts certain values for ``%Z``:" msgstr "" -#: ../../library/datetime.rst:2690 +#: ../../library/datetime.rst:2737 msgid "any value in ``time.tzname`` for your machine's locale" msgstr "" -#: ../../library/datetime.rst:2691 +#: ../../library/datetime.rst:2738 msgid "the hard-coded values ``UTC`` and ``GMT``" msgstr "" -#: ../../library/datetime.rst:2693 +#: ../../library/datetime.rst:2740 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:2697 +#: ../../library/datetime.rst:2744 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:2703 +#: ../../library/datetime.rst:2750 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:2708 +#: ../../library/datetime.rst:2755 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:`~." @@ -4285,7 +4366,7 @@ msgid "" "interchangeable." msgstr "" -#: ../../library/datetime.rst:2714 +#: ../../library/datetime.rst:2761 msgid "" "When used with the :meth:`~.datetime.strptime` method, the leading zero is " "optional for formats ``%d``, ``%m``, ``%H``, ``%I``, ``%M``, ``%S``, " @@ -4293,7 +4374,7 @@ msgid "" "zero." msgstr "" -#: ../../library/datetime.rst:2719 +#: ../../library/datetime.rst:2766 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, " @@ -4302,15 +4383,19 @@ msgid "" "parser is not a leap year. Users run into this bug every four years..." msgstr "" -#: ../../library/datetime.rst:2725 +#: ../../library/datetime.rst:2772 msgid "" ">>> month_day = \"02/29\"\n" ">>> datetime.strptime(f\"{month_day};1984\", \"%m/%d;%Y\") # No leap year " "bug.\n" "datetime.datetime(1984, 2, 29, 0, 0)" msgstr "" +">>> month_day = \"02/29\"\n" +">>> datetime.strptime(f\"{month_day};1984\", \"%m/%d;%Y\") # 沒有閏年問" +"題。\n" +"datetime.datetime(1984, 2, 29, 0, 0)" -#: ../../library/datetime.rst:2731 +#: ../../library/datetime.rst:2778 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 " @@ -4318,15 +4403,15 @@ msgid "" "See :gh:`70647`." msgstr "" -#: ../../library/datetime.rst:2738 +#: ../../library/datetime.rst:2785 msgid "Footnotes" msgstr "註解" -#: ../../library/datetime.rst:2739 +#: ../../library/datetime.rst:2786 msgid "If, that is, we ignore the effects of Relativity" msgstr "也就是說,我們會忽略相對論的效應" -#: ../../library/datetime.rst:2741 +#: ../../library/datetime.rst:2788 msgid "" "This matches the definition of the \"proleptic Gregorian\" calendar in " "Dershowitz and Reingold's book *Calendrical Calculations*, where it's the " @@ -4335,23 +4420,29 @@ msgid "" "systems." msgstr "" -#: ../../library/datetime.rst:2747 +#: ../../library/datetime.rst:2794 msgid "" "See R. H. van Gent's `guide to the mathematics of the ISO 8601 calendar " "`_ for a good explanation." msgstr "" -#: ../../library/datetime.rst:2751 +#: ../../library/datetime.rst:2798 msgid "" "Passing ``datetime.strptime('Feb 29', '%b %d')`` will fail since 1900 is not " "a leap year." msgstr "" -#: ../../library/datetime.rst:2392 +#: ../../library/datetime.rst:2441 msgid "% (percent)" msgstr "% (百分號)" -#: ../../library/datetime.rst:2392 +#: ../../library/datetime.rst:2441 msgid "datetime format" msgstr "datetime format(日期時間格式)" + +#~ msgid ":class:`date`; :class:`.datetime`; :class:`.time`" +#~ msgstr ":class:`date`; :class:`.datetime`; :class:`.time`" + +#~ msgid ":class:`.datetime`" +#~ msgstr ":class:`.datetime`" diff --git a/library/dbm.po b/library/dbm.po index efc712a72b3..c7d077cc8fe 100644 --- a/library/dbm.po +++ b/library/dbm.po @@ -1,13 +1,13 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # jerrychen , 2016 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-08-20 00:15+0000\n" +"POT-Creation-Date: 2025-10-08 00:15+0000\n" "PO-Revision-Date: 2018-05-23 14:42+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -403,15 +403,15 @@ msgstr "" #: ../../library/dbm.rst:280 ../../library/dbm.rst:393 msgid "Added the :meth:`!get` and :meth:`!setdefault` methods." -msgstr "" +msgstr "新增了 :meth:`!get` 和 :meth:`!setdefault` 方法。" #: ../../library/dbm.rst:283 ../../library/dbm.rst:396 msgid "Added the :meth:`!clear` method." -msgstr "" +msgstr "新增了 :meth:`!clear` 方法。" #: ../../library/dbm.rst:286 ../../library/dbm.rst:479 msgid "The following methods are also provided:" -msgstr "" +msgstr "也提供了以下方法:" #: ../../library/dbm.rst:290 msgid "Close the GDBM database." @@ -556,7 +556,7 @@ msgstr "" #: ../../library/dbm.rst:440 msgid "Open a :mod:`!dbm.dumb` database." -msgstr "" +msgstr "開啟一個 :mod:`!dbm.dumb` 資料庫。" #: ../../library/dbm.rst:442 msgid "" diff --git a/library/debug.po b/library/debug.po index e6d1cd53393..17ff8f43eda 100644 --- a/library/debug.po +++ b/library/debug.po @@ -1,12 +1,11 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Liang-Bo Wang , 2015 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-06-20 18:08+0800\n" "PO-Revision-Date: 2021-12-08 00:47+0800\n" diff --git a/library/decimal.po b/library/decimal.po index 384c9f1508a..7ae695837f0 100644 --- a/library/decimal.po +++ b/library/decimal.po @@ -1,13 +1,12 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"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: 2025-11-30 00:16+0000\n" "PO-Revision-Date: 2018-05-23 14:43+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -379,7 +378,7 @@ msgstr "" #: ../../library/decimal.rst:266 msgid "" "For more advanced work, it may be useful to create alternate contexts using " -"the Context() constructor. To make an alternate active, use the :func:" +"the :meth:`Context` constructor. To make an alternate active, use the :func:" "`setcontext` function." msgstr "" @@ -767,7 +766,7 @@ msgid "" msgstr "" #: ../../library/decimal.rst:522 ../../library/decimal.rst:533 -#: ../../library/decimal.rst:561 ../../library/decimal.rst:848 +#: ../../library/decimal.rst:561 ../../library/decimal.rst:865 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 " @@ -856,84 +855,106 @@ msgstr "" #: ../../library/decimal.rst:605 msgid "" +"Alternative constructor that only accepts instances of :class:`float`, :" +"class:`int` or :class:`Decimal`, but not strings or tuples." +msgstr "" + +#: ../../library/decimal.rst:609 +msgid "" +">>> Decimal.from_number(314)\n" +"Decimal('314')\n" +">>> Decimal.from_number(0.1)\n" +"Decimal('0.1000000000000000055511151231257827021181583404541015625')\n" +">>> Decimal.from_number(Decimal('3.14'))\n" +"Decimal('3.14')" +msgstr "" +">>> Decimal.from_number(314)\n" +"Decimal('314')\n" +">>> Decimal.from_number(0.1)\n" +"Decimal('0.1000000000000000055511151231257827021181583404541015625')\n" +">>> Decimal.from_number(Decimal('3.14'))\n" +"Decimal('3.14')" + +#: ../../library/decimal.rst:622 +msgid "" "Fused multiply-add. Return self*other+third with no rounding of the " "intermediate product self*other." msgstr "" -#: ../../library/decimal.rst:613 +#: ../../library/decimal.rst:630 msgid "" "Return :const:`True` if the argument is canonical and :const:`False` " "otherwise. Currently, a :class:`Decimal` instance is always canonical, so " "this operation always returns :const:`True`." msgstr "" -#: ../../library/decimal.rst:619 +#: ../../library/decimal.rst:636 msgid "" "Return :const:`True` if the argument is a finite number, and :const:`False` " "if the argument is an infinity or a NaN." msgstr "" -#: ../../library/decimal.rst:624 +#: ../../library/decimal.rst:641 msgid "" "Return :const:`True` if the argument is either positive or negative infinity " "and :const:`False` otherwise." msgstr "" -#: ../../library/decimal.rst:629 +#: ../../library/decimal.rst:646 msgid "" "Return :const:`True` if the argument is a (quiet or signaling) NaN and :" "const:`False` otherwise." msgstr "" -#: ../../library/decimal.rst:634 +#: ../../library/decimal.rst:651 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." msgstr "" -#: ../../library/decimal.rst:639 +#: ../../library/decimal.rst:656 msgid "" "Return :const:`True` if the argument is a quiet NaN, and :const:`False` " "otherwise." msgstr "" -#: ../../library/decimal.rst:644 +#: ../../library/decimal.rst:661 msgid "" "Return :const:`True` if the argument has a negative sign and :const:`False` " "otherwise. Note that zeros and NaNs can both carry signs." msgstr "" -#: ../../library/decimal.rst:649 +#: ../../library/decimal.rst:666 msgid "" "Return :const:`True` if the argument is a signaling NaN and :const:`False` " "otherwise." msgstr "" -#: ../../library/decimal.rst:654 +#: ../../library/decimal.rst:671 msgid "" "Return :const:`True` if the argument is subnormal, and :const:`False` " "otherwise." msgstr "" -#: ../../library/decimal.rst:659 +#: ../../library/decimal.rst:676 msgid "" "Return :const:`True` if the argument is a (positive or negative) zero and :" "const:`False` otherwise." msgstr "" -#: ../../library/decimal.rst:664 +#: ../../library/decimal.rst:681 msgid "" "Return the natural (base e) logarithm of the operand. The result is " "correctly rounded using the :const:`ROUND_HALF_EVEN` rounding mode." msgstr "" -#: ../../library/decimal.rst:669 +#: ../../library/decimal.rst:686 msgid "" "Return the base ten logarithm of the operand. The result is correctly " "rounded using the :const:`ROUND_HALF_EVEN` rounding mode." msgstr "" -#: ../../library/decimal.rst:674 +#: ../../library/decimal.rst:691 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('-" @@ -941,74 +962,74 @@ msgid "" "the operand is an infinity then ``Decimal('Infinity')`` is returned." msgstr "" -#: ../../library/decimal.rst:682 +#: ../../library/decimal.rst:699 msgid "" ":meth:`logical_and` is a logical operation which takes two *logical " "operands* (see :ref:`logical_operands_label`). The result is the digit-wise " "``and`` of the two operands." msgstr "" -#: ../../library/decimal.rst:688 +#: ../../library/decimal.rst:705 msgid "" ":meth:`logical_invert` is a logical operation. The result is the digit-wise " "inversion of the operand." msgstr "" -#: ../../library/decimal.rst:693 +#: ../../library/decimal.rst:710 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 " "the two operands." msgstr "" -#: ../../library/decimal.rst:699 +#: ../../library/decimal.rst:716 msgid "" ":meth:`logical_xor` is a logical operation which takes two *logical " "operands* (see :ref:`logical_operands_label`). The result is the digit-wise " "exclusive or of the two operands." msgstr "" -#: ../../library/decimal.rst:705 +#: ../../library/decimal.rst:722 msgid "" "Like ``max(self, other)`` except that the context rounding rule is applied " "before returning and that ``NaN`` values are either signaled or ignored " "(depending on the context and whether they are signaling or quiet)." msgstr "" -#: ../../library/decimal.rst:712 +#: ../../library/decimal.rst:729 msgid "" "Similar to the :meth:`.max` method, but the comparison is done using the " "absolute values of the operands." msgstr "" -#: ../../library/decimal.rst:717 +#: ../../library/decimal.rst:734 msgid "" "Like ``min(self, other)`` except that the context rounding rule is applied " "before returning and that ``NaN`` values are either signaled or ignored " "(depending on the context and whether they are signaling or quiet)." msgstr "" -#: ../../library/decimal.rst:724 +#: ../../library/decimal.rst:741 msgid "" "Similar to the :meth:`.min` method, but the comparison is done using the " "absolute values of the operands." msgstr "" -#: ../../library/decimal.rst:729 +#: ../../library/decimal.rst:746 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 " "given operand." msgstr "" -#: ../../library/decimal.rst:735 +#: ../../library/decimal.rst:752 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 " "given operand." msgstr "" -#: ../../library/decimal.rst:741 +#: ../../library/decimal.rst:758 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 " @@ -1016,13 +1037,13 @@ msgid "" "be the same as the sign of the second operand." msgstr "" -#: ../../library/decimal.rst:748 +#: ../../library/decimal.rst:765 msgid "" "Used for producing canonical values of an equivalence class within either " "the current context or the specified context." msgstr "" -#: ../../library/decimal.rst:751 +#: ../../library/decimal.rst:768 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 " @@ -1032,79 +1053,79 @@ msgid "" "exponent is set to 0. In all cases the sign is unchanged." msgstr "" -#: ../../library/decimal.rst:758 +#: ../../library/decimal.rst:775 msgid "" "For example, ``Decimal('32.100')`` and ``Decimal('0.321000e+2')`` both " "normalize to the equivalent value ``Decimal('32.1')``." msgstr "" -#: ../../library/decimal.rst:761 +#: ../../library/decimal.rst:778 msgid "Note that rounding is applied *before* reducing to simplest form." msgstr "" -#: ../../library/decimal.rst:763 +#: ../../library/decimal.rst:780 msgid "" "In the latest versions of the specification, this operation is also known as " "``reduce``." msgstr "" -#: ../../library/decimal.rst:768 +#: ../../library/decimal.rst:785 msgid "" "Return a string describing the *class* of the operand. The returned value " "is one of the following ten strings." msgstr "" -#: ../../library/decimal.rst:771 +#: ../../library/decimal.rst:788 msgid "``\"-Infinity\"``, indicating that the operand is negative infinity." msgstr "" -#: ../../library/decimal.rst:772 +#: ../../library/decimal.rst:789 msgid "" "``\"-Normal\"``, indicating that the operand is a negative normal number." msgstr "" -#: ../../library/decimal.rst:773 +#: ../../library/decimal.rst:790 msgid "" "``\"-Subnormal\"``, indicating that the operand is negative and subnormal." msgstr "" -#: ../../library/decimal.rst:774 +#: ../../library/decimal.rst:791 msgid "``\"-Zero\"``, indicating that the operand is a negative zero." msgstr "" -#: ../../library/decimal.rst:775 +#: ../../library/decimal.rst:792 msgid "``\"+Zero\"``, indicating that the operand is a positive zero." msgstr "" -#: ../../library/decimal.rst:776 +#: ../../library/decimal.rst:793 msgid "" "``\"+Subnormal\"``, indicating that the operand is positive and subnormal." msgstr "" -#: ../../library/decimal.rst:777 +#: ../../library/decimal.rst:794 msgid "" "``\"+Normal\"``, indicating that the operand is a positive normal number." msgstr "" -#: ../../library/decimal.rst:778 +#: ../../library/decimal.rst:795 msgid "``\"+Infinity\"``, indicating that the operand is positive infinity." msgstr "" -#: ../../library/decimal.rst:779 +#: ../../library/decimal.rst:796 msgid "``\"NaN\"``, indicating that the operand is a quiet NaN (Not a Number)." msgstr "" -#: ../../library/decimal.rst:780 +#: ../../library/decimal.rst:797 msgid "``\"sNaN\"``, indicating that the operand is a signaling NaN." msgstr "" -#: ../../library/decimal.rst:784 +#: ../../library/decimal.rst:801 msgid "" "Return a value equal to the first operand after rounding and having the " "exponent of the second operand." msgstr "" -#: ../../library/decimal.rst:790 +#: ../../library/decimal.rst:807 msgid "" "Unlike other operations, if the length of the coefficient after the quantize " "operation would be greater than precision, then an :const:`InvalidOperation` " @@ -1112,13 +1133,13 @@ msgid "" "quantized exponent is always equal to that of the right-hand operand." msgstr "" -#: ../../library/decimal.rst:796 +#: ../../library/decimal.rst:813 msgid "" "Also unlike other operations, quantize never signals Underflow, even if the " "result is subnormal and inexact." msgstr "" -#: ../../library/decimal.rst:799 +#: ../../library/decimal.rst:816 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 " @@ -1127,19 +1148,19 @@ msgid "" "context is used." msgstr "" -#: ../../library/decimal.rst:805 +#: ../../library/decimal.rst:822 msgid "" "An error is returned whenever the resulting exponent is greater than :attr:" "`~Context.Emax` or less than :meth:`~Context.Etiny`." msgstr "" -#: ../../library/decimal.rst:810 +#: ../../library/decimal.rst:827 msgid "" "Return ``Decimal(10)``, the radix (base) in which the :class:`Decimal` class " "does all its arithmetic. Included for compatibility with the specification." msgstr "" -#: ../../library/decimal.rst:816 +#: ../../library/decimal.rst:833 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 " @@ -1148,11 +1169,11 @@ msgid "" "other``, and if two integers are equally near then the even one is chosen." msgstr "" -#: ../../library/decimal.rst:823 +#: ../../library/decimal.rst:840 msgid "If the result is zero then its sign will be the sign of *self*." msgstr "" -#: ../../library/decimal.rst:834 +#: ../../library/decimal.rst:851 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 " @@ -1164,20 +1185,20 @@ msgid "" "are unchanged." msgstr "" -#: ../../library/decimal.rst:845 +#: ../../library/decimal.rst:862 msgid "" "Test whether self and other have the same exponent or whether both are " "``NaN``." msgstr "" -#: ../../library/decimal.rst:854 +#: ../../library/decimal.rst:871 msgid "" "Return the first operand with exponent adjusted by the second. Equivalently, " "return the first operand multiplied by ``10**other``. The second operand " "must be an integer." msgstr "" -#: ../../library/decimal.rst:860 +#: ../../library/decimal.rst:877 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 " @@ -1188,34 +1209,34 @@ msgid "" "exponent of the first operand are unchanged." msgstr "" -#: ../../library/decimal.rst:870 +#: ../../library/decimal.rst:887 msgid "Return the square root of the argument to full precision." msgstr "" -#: ../../library/decimal.rst:875 ../../library/decimal.rst:1524 +#: ../../library/decimal.rst:892 ../../library/decimal.rst:1549 msgid "" "Convert to a string, using engineering notation if an exponent is needed." msgstr "" -#: ../../library/decimal.rst:877 ../../library/decimal.rst:1526 +#: ../../library/decimal.rst:894 ../../library/decimal.rst:1551 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 " "addition of either one or two trailing zeros." msgstr "" -#: ../../library/decimal.rst:881 +#: ../../library/decimal.rst:898 msgid "" "For example, this converts ``Decimal('123E+1')`` to ``Decimal('1.23E+3')``." msgstr "" -#: ../../library/decimal.rst:885 +#: ../../library/decimal.rst:902 msgid "" "Identical to the :meth:`to_integral_value` method. The ``to_integral`` name " "has been kept for compatibility with older versions." msgstr "" -#: ../../library/decimal.rst:890 +#: ../../library/decimal.rst:907 msgid "" "Round to the nearest integer, signaling :const:`Inexact` or :const:`Rounded` " "as appropriate if rounding occurs. The rounding mode is determined by the " @@ -1223,18 +1244,18 @@ msgid "" "parameter is given then the rounding mode of the current context is used." msgstr "" -#: ../../library/decimal.rst:898 +#: ../../library/decimal.rst:915 msgid "" "Round to the nearest integer without signaling :const:`Inexact` or :const:" "`Rounded`. If given, applies *rounding*; otherwise, uses the rounding " "method in either the supplied *context* or the current context." msgstr "" -#: ../../library/decimal.rst:902 +#: ../../library/decimal.rst:919 msgid "Decimal numbers can be rounded using the :func:`.round` function:" msgstr "" -#: ../../library/decimal.rst:907 +#: ../../library/decimal.rst:924 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 :" @@ -1242,7 +1263,7 @@ msgid "" "infinity or :exc:`ValueError` if it is a (quiet or signaling) NaN." msgstr "" -#: ../../library/decimal.rst:913 +#: ../../library/decimal.rst:930 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 " @@ -1254,27 +1275,27 @@ msgid "" "the current context's precision. In other words, for the non-corner cases:" msgstr "" -#: ../../library/decimal.rst:923 +#: ../../library/decimal.rst:940 msgid "" "if *ndigits* is positive, return *number* rounded to *ndigits* decimal " "places;" msgstr "" -#: ../../library/decimal.rst:925 +#: ../../library/decimal.rst:942 msgid "if *ndigits* is zero, return *number* rounded to the nearest integer;" msgstr "" -#: ../../library/decimal.rst:926 +#: ../../library/decimal.rst:943 msgid "" "if *ndigits* is negative, return *number* rounded to the nearest multiple of " "``10**abs(ndigits)``." msgstr "" -#: ../../library/decimal.rst:929 +#: ../../library/decimal.rst:946 msgid "For example::" -msgstr "" +msgstr "舉例來說: ::" -#: ../../library/decimal.rst:931 +#: ../../library/decimal.rst:948 msgid "" ">>> from decimal import Decimal, getcontext, ROUND_DOWN\n" ">>> getcontext().rounding = ROUND_DOWN\n" @@ -1290,11 +1311,11 @@ msgid "" "Decimal('0E+1')" msgstr "" -#: ../../library/decimal.rst:948 +#: ../../library/decimal.rst:965 msgid "Logical operands" msgstr "" -#: ../../library/decimal.rst:950 +#: ../../library/decimal.rst:967 msgid "" "The :meth:`~Decimal.logical_and`, :meth:`~Decimal.logical_invert`, :meth:" "`~Decimal.logical_or`, and :meth:`~Decimal.logical_xor` methods expect their " @@ -1303,38 +1324,38 @@ msgid "" "are all either ``0`` or ``1``." msgstr "" -#: ../../library/decimal.rst:962 +#: ../../library/decimal.rst:979 msgid "Context objects" msgstr "" -#: ../../library/decimal.rst:964 +#: ../../library/decimal.rst:981 msgid "" "Contexts are environments for arithmetic operations. They govern precision, " "set rules for rounding, determine which signals are treated as exceptions, " "and limit the range for exponents." msgstr "" -#: ../../library/decimal.rst:968 +#: ../../library/decimal.rst:985 msgid "" "Each thread has its own current context which is accessed or changed using " "the :func:`getcontext` and :func:`setcontext` functions:" msgstr "" -#: ../../library/decimal.rst:974 +#: ../../library/decimal.rst:991 msgid "Return the current context for the active thread." msgstr "" -#: ../../library/decimal.rst:979 +#: ../../library/decimal.rst:996 msgid "Set the current context for the active thread to *c*." msgstr "" -#: ../../library/decimal.rst:981 +#: ../../library/decimal.rst:998 msgid "" "You can also use the :keyword:`with` statement and the :func:`localcontext` " "function to temporarily change the active context." msgstr "" -#: ../../library/decimal.rst:986 +#: ../../library/decimal.rst:1003 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 " @@ -1343,14 +1364,14 @@ msgid "" "used to set the attributes of the new context." msgstr "" -#: ../../library/decimal.rst:992 +#: ../../library/decimal.rst:1009 msgid "" "For example, the following code sets the current decimal precision to 42 " "places, performs a calculation, and then automatically restores the previous " "context::" msgstr "" -#: ../../library/decimal.rst:995 +#: ../../library/decimal.rst:1012 msgid "" "from decimal import localcontext\n" "\n" @@ -1360,11 +1381,11 @@ msgid "" "s = +s # Round the final result back to the default precision" msgstr "" -#: ../../library/decimal.rst:1002 +#: ../../library/decimal.rst:1019 msgid "Using keyword arguments, the code would be the following::" msgstr "" -#: ../../library/decimal.rst:1004 +#: ../../library/decimal.rst:1021 msgid "" "from decimal import localcontext\n" "\n" @@ -1378,26 +1399,33 @@ msgstr "" " s = calculate_something()\n" "s = +s" -#: ../../library/decimal.rst:1010 +#: ../../library/decimal.rst:1027 msgid "" "Raises :exc:`TypeError` if *kwargs* supplies an attribute that :class:" "`Context` doesn't support. Raises either :exc:`TypeError` or :exc:" "`ValueError` if *kwargs* supplies an invalid value for an attribute." msgstr "" -#: ../../library/decimal.rst:1014 +#: ../../library/decimal.rst:1031 msgid "" ":meth:`localcontext` now supports setting context attributes through the use " "of keyword arguments." msgstr "" -#: ../../library/decimal.rst:1017 +#: ../../library/decimal.rst:1036 +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 :" +"const:`IEEE_CONTEXT_MAX_BITS`." +msgstr "" + +#: ../../library/decimal.rst:1042 msgid "" "New contexts can also be created using the :class:`Context` constructor " "described below. In addition, the module provides three pre-made contexts:" msgstr "" -#: ../../library/decimal.rst:1023 +#: ../../library/decimal.rst:1048 msgid "" "This is a standard context defined by the General Decimal Arithmetic " "Specification. Precision is set to nine. Rounding is set to :const:" @@ -1406,12 +1434,12 @@ msgid "" "`Subnormal`." msgstr "" -#: ../../library/decimal.rst:1029 +#: ../../library/decimal.rst:1054 msgid "" "Because many of the traps are enabled, this context is useful for debugging." msgstr "" -#: ../../library/decimal.rst:1034 +#: ../../library/decimal.rst:1059 msgid "" "This is a standard context defined by the General Decimal Arithmetic " "Specification. Precision is set to nine. Rounding is set to :const:" @@ -1419,7 +1447,7 @@ msgid "" "exceptions are not raised during computations)." msgstr "" -#: ../../library/decimal.rst:1039 +#: ../../library/decimal.rst:1064 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 " @@ -1427,7 +1455,7 @@ msgid "" "conditions that would otherwise halt the program." msgstr "" -#: ../../library/decimal.rst:1047 +#: ../../library/decimal.rst:1072 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 " @@ -1435,7 +1463,7 @@ msgid "" "constructor." msgstr "" -#: ../../library/decimal.rst:1051 +#: ../../library/decimal.rst:1076 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 " @@ -1443,63 +1471,63 @@ msgid "" "as it would require thread synchronization to prevent race conditions." msgstr "" -#: ../../library/decimal.rst:1056 +#: ../../library/decimal.rst:1081 msgid "" "In single threaded environments, it is preferable to not use this context at " "all. Instead, simply create contexts explicitly as described below." msgstr "" -#: ../../library/decimal.rst:1059 +#: ../../library/decimal.rst:1084 msgid "" "The default values are :attr:`Context.prec`\\ =\\ ``28``, :attr:`Context." "rounding`\\ =\\ :const:`ROUND_HALF_EVEN`, and enabled traps for :class:" "`Overflow`, :class:`InvalidOperation`, and :class:`DivisionByZero`." msgstr "" -#: ../../library/decimal.rst:1064 +#: ../../library/decimal.rst:1089 msgid "" "In addition to the three supplied contexts, new contexts can be created with " "the :class:`Context` constructor." msgstr "" -#: ../../library/decimal.rst:1070 +#: ../../library/decimal.rst:1095 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* " "field is not specified or is :const:`None`, all flags are cleared." msgstr "" -#: ../../library/decimal.rst:1076 +#: ../../library/decimal.rst:1101 msgid "" "An integer in the range [``1``, :const:`MAX_PREC`] that sets the precision " "for arithmetic operations in the context." msgstr "" -#: ../../library/decimal.rst:1081 +#: ../../library/decimal.rst:1106 msgid "One of the constants listed in the section `Rounding Modes`_." msgstr "" -#: ../../library/decimal.rst:1086 +#: ../../library/decimal.rst:1111 msgid "" "Lists of any signals to be set. Generally, new contexts should only set " "traps and leave the flags clear." msgstr "" -#: ../../library/decimal.rst:1092 +#: ../../library/decimal.rst:1117 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:" "`MAX_EMAX`]." msgstr "" -#: ../../library/decimal.rst:1098 +#: ../../library/decimal.rst:1123 msgid "" "Either ``0`` or ``1`` (the default). If set to ``1``, exponents are printed " "with a capital ``E``; otherwise, a lowercase ``e`` is used: " "``Decimal('6.02e+23')``." msgstr "" -#: ../../library/decimal.rst:1104 +#: ../../library/decimal.rst:1129 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 " @@ -1512,7 +1540,7 @@ msgid "" "information about significant trailing zeros. For example::" msgstr "" -#: ../../library/decimal.rst:1115 +#: ../../library/decimal.rst:1140 msgid "" ">>> Context(prec=6, Emax=999, clamp=1).create_decimal('1.23e999')\n" "Decimal('1.23000E+999')" @@ -1520,13 +1548,13 @@ msgstr "" ">>> Context(prec=6, Emax=999, clamp=1).create_decimal('1.23e999')\n" "Decimal('1.23000E+999')" -#: ../../library/decimal.rst:1118 +#: ../../library/decimal.rst:1143 msgid "" "A *clamp* value of ``1`` allows compatibility with the fixed-width decimal " "interchange formats specified in IEEE 754." msgstr "" -#: ../../library/decimal.rst:1121 +#: ../../library/decimal.rst:1146 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 " @@ -1539,30 +1567,30 @@ msgid "" "instance of :class:`int`) anywhere that a Decimal instance is accepted." msgstr "" -#: ../../library/decimal.rst:1134 +#: ../../library/decimal.rst:1159 msgid "Resets all of the flags to ``0``." msgstr "" -#: ../../library/decimal.rst:1138 +#: ../../library/decimal.rst:1163 msgid "Resets all of the traps to ``0``." msgstr "" -#: ../../library/decimal.rst:1144 +#: ../../library/decimal.rst:1169 msgid "Return a duplicate of the context." msgstr "" -#: ../../library/decimal.rst:1148 +#: ../../library/decimal.rst:1173 msgid "Return a copy of the Decimal instance num." msgstr "" -#: ../../library/decimal.rst:1152 +#: ../../library/decimal.rst:1177 msgid "" "Creates a new Decimal instance from *num* but using *self* as context. " "Unlike the :class:`Decimal` constructor, the context precision, rounding " "method, flags, and traps are applied to the conversion." msgstr "" -#: ../../library/decimal.rst:1156 +#: ../../library/decimal.rst:1181 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 " @@ -1571,7 +1599,7 @@ msgid "" "sum can change the result:" msgstr "" -#: ../../library/decimal.rst:1162 +#: ../../library/decimal.rst:1187 msgid "" ">>> getcontext().prec = 3\n" ">>> Decimal('3.4445') + Decimal('1.0023')\n" @@ -1585,14 +1613,14 @@ msgstr "" ">>> Decimal('3.4445') + Decimal(0) + Decimal('1.0023')\n" "Decimal('4.44')" -#: ../../library/decimal.rst:1170 +#: ../../library/decimal.rst:1195 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 " "are permitted." msgstr "" -#: ../../library/decimal.rst:1176 +#: ../../library/decimal.rst:1201 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 " @@ -1600,7 +1628,7 @@ msgid "" "conversion." msgstr "" -#: ../../library/decimal.rst:1181 +#: ../../library/decimal.rst:1206 msgid "" ">>> context = Context(prec=5, rounding=ROUND_DOWN)\n" ">>> context.create_decimal_from_float(math.pi)\n" @@ -1620,18 +1648,18 @@ msgstr "" " ...\n" "decimal.Inexact: None" -#: ../../library/decimal.rst:1196 +#: ../../library/decimal.rst:1221 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 :" "const:`Etiny`." msgstr "" -#: ../../library/decimal.rst:1202 +#: ../../library/decimal.rst:1227 msgid "Returns a value equal to ``Emax - prec + 1``." -msgstr "" +msgstr "回傳一個等於 ``Emax - prec + 1`` 的值。" -#: ../../library/decimal.rst:1204 +#: ../../library/decimal.rst:1229 msgid "" "The usual approach to working with decimals is to create :class:`Decimal` " "instances and then apply arithmetic operations which take place within the " @@ -1641,189 +1669,192 @@ msgid "" "recounted here." msgstr "" -#: ../../library/decimal.rst:1214 +#: ../../library/decimal.rst:1239 msgid "Returns the absolute value of *x*." -msgstr "" +msgstr "回傳 *x* 的絕對值。" -#: ../../library/decimal.rst:1219 +#: ../../library/decimal.rst:1244 msgid "Return the sum of *x* and *y*." -msgstr "" +msgstr "回傳 *x* 與 *y* 的和。" -#: ../../library/decimal.rst:1224 +#: ../../library/decimal.rst:1249 msgid "Returns the same Decimal object *x*." -msgstr "" +msgstr "回傳相同的 Decimal 物件 *x*。" -#: ../../library/decimal.rst:1229 +#: ../../library/decimal.rst:1254 msgid "Compares *x* and *y* numerically." msgstr "" -#: ../../library/decimal.rst:1234 +#: ../../library/decimal.rst:1259 msgid "Compares the values of the two operands numerically." msgstr "" -#: ../../library/decimal.rst:1239 +#: ../../library/decimal.rst:1264 msgid "Compares two operands using their abstract representation." msgstr "" -#: ../../library/decimal.rst:1244 +#: ../../library/decimal.rst:1269 msgid "" "Compares two operands using their abstract representation, ignoring sign." msgstr "" -#: ../../library/decimal.rst:1249 +#: ../../library/decimal.rst:1274 msgid "Returns a copy of *x* with the sign set to 0." msgstr "" -#: ../../library/decimal.rst:1254 +#: ../../library/decimal.rst:1279 msgid "Returns a copy of *x* with the sign inverted." msgstr "" -#: ../../library/decimal.rst:1259 +#: ../../library/decimal.rst:1284 msgid "Copies the sign from *y* to *x*." -msgstr "" +msgstr "將 *y* 的正負號複製到 *x*。" -#: ../../library/decimal.rst:1264 +#: ../../library/decimal.rst:1289 msgid "Return *x* divided by *y*." -msgstr "" +msgstr "回傳 *x* 除以 *y*。" -#: ../../library/decimal.rst:1269 +#: ../../library/decimal.rst:1294 msgid "Return *x* divided by *y*, truncated to an integer." msgstr "" -#: ../../library/decimal.rst:1274 +#: ../../library/decimal.rst:1299 msgid "Divides two numbers and returns the integer part of the result." msgstr "" -#: ../../library/decimal.rst:1279 +#: ../../library/decimal.rst:1304 msgid "Returns ``e ** x``." -msgstr "" +msgstr "回傳 ``e ** x``。" -#: ../../library/decimal.rst:1284 +#: ../../library/decimal.rst:1309 msgid "Returns *x* multiplied by *y*, plus *z*." -msgstr "" +msgstr "回傳 *x* 乘以 *y*,再加上 *z*。" -#: ../../library/decimal.rst:1289 +#: ../../library/decimal.rst:1314 msgid "Returns ``True`` if *x* is canonical; otherwise returns ``False``." msgstr "" -#: ../../library/decimal.rst:1294 +#: ../../library/decimal.rst:1319 msgid "Returns ``True`` if *x* is finite; otherwise returns ``False``." -msgstr "" +msgstr "如果 *x* 是有限的則回傳 ``True``;否則回傳 ``False``。" -#: ../../library/decimal.rst:1299 +#: ../../library/decimal.rst:1324 msgid "Returns ``True`` if *x* is infinite; otherwise returns ``False``." -msgstr "" +msgstr "如果 *x* 是無限大則回傳 ``True``;否則回傳 ``False``。" -#: ../../library/decimal.rst:1304 +#: ../../library/decimal.rst:1329 msgid "Returns ``True`` if *x* is a qNaN or sNaN; otherwise returns ``False``." -msgstr "" +msgstr "如果 *x* 是 qNaN 或 sNaN 則回傳 ``True``;否則回傳 ``False``。" -#: ../../library/decimal.rst:1309 +#: ../../library/decimal.rst:1334 msgid "" "Returns ``True`` if *x* is a normal number; otherwise returns ``False``." msgstr "" +"如果 *x* 是正規數 (normal number) 則回傳 ``True``;否則回傳 ``False``。" -#: ../../library/decimal.rst:1314 +#: ../../library/decimal.rst:1339 msgid "Returns ``True`` if *x* is a quiet NaN; otherwise returns ``False``." msgstr "" +"如果 *x* 是安靜型 NaN (quiet NaN) 則回傳 ``True``;否則回傳 ``False``。" -#: ../../library/decimal.rst:1319 +#: ../../library/decimal.rst:1344 msgid "Returns ``True`` if *x* is negative; otherwise returns ``False``." -msgstr "" +msgstr "如果 *x* 是負數則回傳 ``True``;否則回傳 ``False``。" -#: ../../library/decimal.rst:1324 +#: ../../library/decimal.rst:1349 msgid "" "Returns ``True`` if *x* is a signaling NaN; otherwise returns ``False``." msgstr "" +"如果 *x* 是訊號型 NaN (signaling NaN) 則回傳 ``True``;否則回傳 ``False``。" -#: ../../library/decimal.rst:1329 +#: ../../library/decimal.rst:1354 msgid "Returns ``True`` if *x* is subnormal; otherwise returns ``False``." -msgstr "" +msgstr "如果 *x* 是次正規數 (subnormal) 則回傳 ``True``;否則回傳 ``False``。" -#: ../../library/decimal.rst:1334 +#: ../../library/decimal.rst:1359 msgid "Returns ``True`` if *x* is a zero; otherwise returns ``False``." -msgstr "" +msgstr "如果 *x* 是零則回傳 ``True``;否則回傳 ``False``。" -#: ../../library/decimal.rst:1339 +#: ../../library/decimal.rst:1364 msgid "Returns the natural (base e) logarithm of *x*." -msgstr "" +msgstr "回傳 *x* 的自然對數(以 e 為底)。" -#: ../../library/decimal.rst:1344 +#: ../../library/decimal.rst:1369 msgid "Returns the base 10 logarithm of *x*." -msgstr "" +msgstr "回傳 *x* 的以 10 為底的對數。" -#: ../../library/decimal.rst:1349 +#: ../../library/decimal.rst:1374 msgid "Returns the exponent of the magnitude of the operand's MSD." -msgstr "" +msgstr "回傳運算元最高有效位數(MSD)數值的指數。" -#: ../../library/decimal.rst:1354 +#: ../../library/decimal.rst:1379 msgid "Applies the logical operation *and* between each operand's digits." -msgstr "" +msgstr "將每個運算元的位數套用邏輯運算 *and*。" -#: ../../library/decimal.rst:1359 +#: ../../library/decimal.rst:1384 msgid "Invert all the digits in *x*." msgstr "" -#: ../../library/decimal.rst:1364 +#: ../../library/decimal.rst:1389 msgid "Applies the logical operation *or* between each operand's digits." msgstr "" -#: ../../library/decimal.rst:1369 +#: ../../library/decimal.rst:1394 msgid "Applies the logical operation *xor* between each operand's digits." msgstr "" -#: ../../library/decimal.rst:1374 +#: ../../library/decimal.rst:1399 msgid "Compares two values numerically and returns the maximum." msgstr "" -#: ../../library/decimal.rst:1379 ../../library/decimal.rst:1389 +#: ../../library/decimal.rst:1404 ../../library/decimal.rst:1414 msgid "Compares the values numerically with their sign ignored." msgstr "" -#: ../../library/decimal.rst:1384 +#: ../../library/decimal.rst:1409 msgid "Compares two values numerically and returns the minimum." msgstr "" -#: ../../library/decimal.rst:1394 +#: ../../library/decimal.rst:1419 msgid "Minus corresponds to the unary prefix minus operator in Python." msgstr "" -#: ../../library/decimal.rst:1399 +#: ../../library/decimal.rst:1424 msgid "Return the product of *x* and *y*." msgstr "" -#: ../../library/decimal.rst:1404 +#: ../../library/decimal.rst:1429 msgid "Returns the largest representable number smaller than *x*." msgstr "" -#: ../../library/decimal.rst:1409 +#: ../../library/decimal.rst:1434 msgid "Returns the smallest representable number larger than *x*." msgstr "" -#: ../../library/decimal.rst:1414 +#: ../../library/decimal.rst:1439 msgid "Returns the number closest to *x*, in direction towards *y*." msgstr "" -#: ../../library/decimal.rst:1419 +#: ../../library/decimal.rst:1444 msgid "Reduces *x* to its simplest form." msgstr "" -#: ../../library/decimal.rst:1424 +#: ../../library/decimal.rst:1449 msgid "Returns an indication of the class of *x*." msgstr "" -#: ../../library/decimal.rst:1429 +#: ../../library/decimal.rst:1454 msgid "" "Plus corresponds to the unary prefix plus operator in Python. This " "operation applies the context precision and rounding, so it is *not* an " "identity operation." msgstr "" -#: ../../library/decimal.rst:1436 +#: ../../library/decimal.rst:1461 msgid "Return ``x`` to the power of ``y``, reduced modulo ``modulo`` if given." msgstr "" -#: ../../library/decimal.rst:1438 +#: ../../library/decimal.rst:1463 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 " @@ -1832,42 +1863,42 @@ msgid "" "in the Python version." msgstr "" -#: ../../library/decimal.rst:1444 +#: ../../library/decimal.rst:1469 msgid "" "``Decimal(0) ** Decimal(0)`` results in ``InvalidOperation``, and if " "``InvalidOperation`` is not trapped, then results in ``Decimal('NaN')``." msgstr "" -#: ../../library/decimal.rst:1447 +#: ../../library/decimal.rst:1472 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 " "always correctly rounded\"." msgstr "" -#: ../../library/decimal.rst:1452 +#: ../../library/decimal.rst:1477 msgid "" "With three arguments, compute ``(x**y) % modulo``. For the three argument " "form, the following restrictions on the arguments hold:" msgstr "" -#: ../../library/decimal.rst:1455 +#: ../../library/decimal.rst:1480 msgid "all three arguments must be integral" msgstr "" -#: ../../library/decimal.rst:1456 +#: ../../library/decimal.rst:1481 msgid "``y`` must be nonnegative" msgstr "" -#: ../../library/decimal.rst:1457 +#: ../../library/decimal.rst:1482 msgid "at least one of ``x`` or ``y`` must be nonzero" msgstr "" -#: ../../library/decimal.rst:1458 +#: ../../library/decimal.rst:1483 msgid "``modulo`` must be nonzero and have at most 'precision' digits" msgstr "" -#: ../../library/decimal.rst:1460 +#: ../../library/decimal.rst:1485 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 " @@ -1876,110 +1907,118 @@ msgid "" "result is always exact." msgstr "" -#: ../../library/decimal.rst:1470 +#: ../../library/decimal.rst:1495 msgid "Returns a value equal to *x* (rounded), having the exponent of *y*." msgstr "" -#: ../../library/decimal.rst:1475 +#: ../../library/decimal.rst:1500 msgid "Just returns 10, as this is Decimal, :)" msgstr "" -#: ../../library/decimal.rst:1480 +#: ../../library/decimal.rst:1505 msgid "Returns the remainder from integer division." msgstr "" -#: ../../library/decimal.rst:1482 +#: ../../library/decimal.rst:1507 msgid "" "The sign of the result, if non-zero, is the same as that of the original " "dividend." msgstr "" -#: ../../library/decimal.rst:1488 +#: ../../library/decimal.rst:1513 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*)." msgstr "" -#: ../../library/decimal.rst:1494 +#: ../../library/decimal.rst:1519 msgid "Returns a rotated copy of *x*, *y* times." msgstr "" -#: ../../library/decimal.rst:1499 +#: ../../library/decimal.rst:1524 msgid "Returns ``True`` if the two operands have the same exponent." -msgstr "" +msgstr "如果兩個運算元有相同的指數則回傳 ``True``。" -#: ../../library/decimal.rst:1504 +#: ../../library/decimal.rst:1529 msgid "Returns the first operand after adding the second value its exp." msgstr "" -#: ../../library/decimal.rst:1509 +#: ../../library/decimal.rst:1534 msgid "Returns a shifted copy of *x*, *y* times." msgstr "" -#: ../../library/decimal.rst:1514 +#: ../../library/decimal.rst:1539 msgid "Square root of a non-negative number to context precision." msgstr "" -#: ../../library/decimal.rst:1519 +#: ../../library/decimal.rst:1544 msgid "Return the difference between *x* and *y*." msgstr "" -#: ../../library/decimal.rst:1533 +#: ../../library/decimal.rst:1558 msgid "Rounds to an integer." msgstr "" -#: ../../library/decimal.rst:1538 +#: ../../library/decimal.rst:1563 msgid "Converts a number to a string using scientific notation." msgstr "" -#: ../../library/decimal.rst:1545 +#: ../../library/decimal.rst:1570 msgid "Constants" msgstr "常數" -#: ../../library/decimal.rst:1547 +#: ../../library/decimal.rst:1572 msgid "" "The constants in this section are only relevant for the C module. They are " "also included in the pure Python version for compatibility." msgstr "" -#: ../../library/decimal.rst:1551 +#: ../../library/decimal.rst:1576 msgid "32-bit" msgstr "32 位元" -#: ../../library/decimal.rst:1551 +#: ../../library/decimal.rst:1576 msgid "64-bit" msgstr "64 位元" -#: ../../library/decimal.rst:1553 ../../library/decimal.rst:1555 +#: ../../library/decimal.rst:1578 ../../library/decimal.rst:1580 msgid "``425000000``" msgstr "``425000000``" -#: ../../library/decimal.rst:1553 ../../library/decimal.rst:1555 +#: ../../library/decimal.rst:1578 ../../library/decimal.rst:1580 msgid "``999999999999999999``" msgstr "``999999999999999999``" -#: ../../library/decimal.rst:1557 +#: ../../library/decimal.rst:1582 msgid "``-425000000``" msgstr "``-425000000``" -#: ../../library/decimal.rst:1557 +#: ../../library/decimal.rst:1582 msgid "``-999999999999999999``" msgstr "``-999999999999999999``" -#: ../../library/decimal.rst:1559 +#: ../../library/decimal.rst:1584 msgid "``-849999999``" msgstr "``-849999999``" -#: ../../library/decimal.rst:1559 +#: ../../library/decimal.rst:1584 msgid "``-1999999999999999997``" msgstr "``-1999999999999999997``" -#: ../../library/decimal.rst:1565 +#: ../../library/decimal.rst:1586 +msgid "``256``" +msgstr "``256``" + +#: ../../library/decimal.rst:1586 +msgid "``512``" +msgstr "``512``" + +#: ../../library/decimal.rst:1591 msgid "" "The value is ``True``. Deprecated, because Python now always has threads." msgstr "" -#: ../../library/decimal.rst:1571 +#: ../../library/decimal.rst:1597 msgid "" "The default value is ``True``. If Python is :option:`configured using the --" "without-decimal-contextvar option <--without-decimal-contextvar>`, the C " @@ -1988,55 +2027,55 @@ msgid "" "scenarios." msgstr "" -#: ../../library/decimal.rst:1580 +#: ../../library/decimal.rst:1606 msgid "Rounding modes" msgstr "" -#: ../../library/decimal.rst:1584 +#: ../../library/decimal.rst:1610 msgid "Round towards ``Infinity``." msgstr "" -#: ../../library/decimal.rst:1588 +#: ../../library/decimal.rst:1614 msgid "Round towards zero." msgstr "" -#: ../../library/decimal.rst:1592 +#: ../../library/decimal.rst:1618 msgid "Round towards ``-Infinity``." msgstr "" -#: ../../library/decimal.rst:1596 +#: ../../library/decimal.rst:1622 msgid "Round to nearest with ties going towards zero." msgstr "" -#: ../../library/decimal.rst:1600 +#: ../../library/decimal.rst:1626 msgid "Round to nearest with ties going to nearest even integer." msgstr "" -#: ../../library/decimal.rst:1604 +#: ../../library/decimal.rst:1630 msgid "Round to nearest with ties going away from zero." msgstr "" -#: ../../library/decimal.rst:1608 +#: ../../library/decimal.rst:1634 msgid "Round away from zero." msgstr "" -#: ../../library/decimal.rst:1612 +#: ../../library/decimal.rst:1638 msgid "" "Round away from zero if last digit after rounding towards zero would have " "been 0 or 5; otherwise round towards zero." msgstr "" -#: ../../library/decimal.rst:1619 +#: ../../library/decimal.rst:1645 msgid "Signals" msgstr "" -#: ../../library/decimal.rst:1621 +#: ../../library/decimal.rst:1647 msgid "" "Signals represent conditions that arise during computation. Each corresponds " "to one context flag and one context trap enabler." msgstr "" -#: ../../library/decimal.rst:1624 +#: ../../library/decimal.rst:1650 msgid "" "The context flag is set whenever the condition is encountered. After the " "computation, flags may be checked for informational purposes (for instance, " @@ -2044,7 +2083,7 @@ msgid "" "sure to clear all flags before starting the next computation." msgstr "" -#: ../../library/decimal.rst:1629 +#: ../../library/decimal.rst:1655 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:" @@ -2052,54 +2091,54 @@ msgid "" "raised upon encountering the condition." msgstr "" -#: ../../library/decimal.rst:1637 +#: ../../library/decimal.rst:1663 msgid "Altered an exponent to fit representation constraints." msgstr "" -#: ../../library/decimal.rst:1639 +#: ../../library/decimal.rst:1665 msgid "" "Typically, clamping occurs when an exponent falls outside the context's :" "attr:`~Context.Emin` and :attr:`~Context.Emax` limits. If possible, the " "exponent is reduced to fit by adding zeros to the coefficient." msgstr "" -#: ../../library/decimal.rst:1646 +#: ../../library/decimal.rst:1672 msgid "Base class for other signals and a subclass of :exc:`ArithmeticError`." msgstr "" -#: ../../library/decimal.rst:1651 +#: ../../library/decimal.rst:1677 msgid "Signals the division of a non-infinite number by zero." msgstr "" -#: ../../library/decimal.rst:1653 +#: ../../library/decimal.rst:1679 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 ``-" "Infinity`` with the sign determined by the inputs to the calculation." msgstr "" -#: ../../library/decimal.rst:1660 +#: ../../library/decimal.rst:1686 msgid "Indicates that rounding occurred and the result is not exact." msgstr "" -#: ../../library/decimal.rst:1662 +#: ../../library/decimal.rst:1688 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 " "are inexact." msgstr "" -#: ../../library/decimal.rst:1669 +#: ../../library/decimal.rst:1695 msgid "An invalid operation was performed." msgstr "" -#: ../../library/decimal.rst:1671 +#: ../../library/decimal.rst:1697 msgid "" "Indicates that an operation was requested that does not make sense. If not " "trapped, returns ``NaN``. Possible causes include::" msgstr "" -#: ../../library/decimal.rst:1674 +#: ../../library/decimal.rst:1700 msgid "" "Infinity - Infinity\n" "0 * Infinity\n" @@ -2121,11 +2160,11 @@ msgstr "" "x ** (non-integer)\n" "x ** Infinity" -#: ../../library/decimal.rst:1687 +#: ../../library/decimal.rst:1713 msgid "Numerical overflow." msgstr "" -#: ../../library/decimal.rst:1689 +#: ../../library/decimal.rst:1715 msgid "" "Indicates the exponent is larger than :attr:`Context.Emax` after rounding " "has occurred. If not trapped, the result depends on the rounding mode, " @@ -2134,42 +2173,42 @@ msgid "" "`Rounded` are also signaled." msgstr "" -#: ../../library/decimal.rst:1698 +#: ../../library/decimal.rst:1724 msgid "Rounding occurred though possibly no information was lost." msgstr "" -#: ../../library/decimal.rst:1700 +#: ../../library/decimal.rst:1726 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 " "unchanged. This signal is used to detect loss of significant digits." msgstr "" -#: ../../library/decimal.rst:1708 +#: ../../library/decimal.rst:1734 msgid "Exponent was lower than :attr:`~Context.Emin` prior to rounding." msgstr "" -#: ../../library/decimal.rst:1710 +#: ../../library/decimal.rst:1736 msgid "" "Occurs when an operation result is subnormal (the exponent is too small). If " "not trapped, returns the result unchanged." msgstr "" -#: ../../library/decimal.rst:1716 +#: ../../library/decimal.rst:1742 msgid "Numerical underflow with result rounded to zero." msgstr "" -#: ../../library/decimal.rst:1718 +#: ../../library/decimal.rst:1744 msgid "" "Occurs when a subnormal result is pushed to zero by rounding. :class:" "`Inexact` and :class:`Subnormal` are also signaled." msgstr "" -#: ../../library/decimal.rst:1724 +#: ../../library/decimal.rst:1750 msgid "Enable stricter semantics for mixing floats and Decimals." msgstr "" -#: ../../library/decimal.rst:1726 +#: ../../library/decimal.rst:1752 msgid "" "If the signal is not trapped (default), mixing floats and Decimals is " "permitted in the :class:`~decimal.Decimal` constructor, :meth:`~decimal." @@ -2180,18 +2219,18 @@ msgid "" "Context.create_decimal_from_float` do not set the flag." msgstr "" -#: ../../library/decimal.rst:1734 +#: ../../library/decimal.rst:1760 msgid "" "Otherwise (the signal is trapped), only equality comparisons and explicit " "conversions are silent. All other mixed operations raise :exc:" "`FloatOperation`." msgstr "" -#: ../../library/decimal.rst:1738 +#: ../../library/decimal.rst:1764 msgid "The following table summarizes the hierarchy of signals::" msgstr "" -#: ../../library/decimal.rst:1740 +#: ../../library/decimal.rst:1766 msgid "" "exceptions.ArithmeticError(exceptions.Exception)\n" " DecimalException\n" @@ -2217,15 +2256,15 @@ msgstr "" " Subnormal\n" " FloatOperation(DecimalException, exceptions.TypeError)" -#: ../../library/decimal.rst:1759 +#: ../../library/decimal.rst:1785 msgid "Floating-point notes" msgstr "" -#: ../../library/decimal.rst:1763 +#: ../../library/decimal.rst:1789 msgid "Mitigating round-off error with increased precision" msgstr "" -#: ../../library/decimal.rst:1765 +#: ../../library/decimal.rst:1791 msgid "" "The use of decimal floating point eliminates decimal representation error " "(making it possible to represent ``0.1`` exactly); however, some operations " @@ -2233,7 +2272,7 @@ msgid "" "precision." msgstr "" -#: ../../library/decimal.rst:1769 +#: ../../library/decimal.rst:1795 msgid "" "The effects of round-off error can be amplified by the addition or " "subtraction of nearly offsetting quantities resulting in loss of " @@ -2242,7 +2281,7 @@ msgid "" "of the associative and distributive properties of addition:" msgstr "" -#: ../../library/decimal.rst:1775 +#: ../../library/decimal.rst:1801 msgid "" "# Examples from Seminumerical Algorithms, Section 4.2.2.\n" ">>> from decimal import Decimal, getcontext\n" @@ -2261,13 +2300,13 @@ msgid "" "Decimal('0.0060000')" msgstr "" -#: ../../library/decimal.rst:1793 +#: ../../library/decimal.rst:1819 msgid "" "The :mod:`decimal` module makes it possible to restore the identities by " "expanding the precision sufficiently to avoid loss of significance:" msgstr "" -#: ../../library/decimal.rst:1796 +#: ../../library/decimal.rst:1822 msgid "" ">>> getcontext().prec = 20\n" ">>> u, v, w = Decimal(11111113), Decimal(-11111111), Decimal('7.51111111')\n" @@ -2282,19 +2321,31 @@ msgid "" ">>> u * (v+w)\n" "Decimal('0.0060000')" msgstr "" +">>> getcontext().prec = 20\n" +">>> u, v, w = Decimal(11111113), Decimal(-11111111), Decimal('7.51111111')\n" +">>> (u + v) + w\n" +"Decimal('9.51111111')\n" +">>> u + (v + w)\n" +"Decimal('9.51111111')\n" +">>>\n" +">>> u, v, w = Decimal(20000), Decimal(-6), Decimal('6.0000003')\n" +">>> (u*v) + (u*w)\n" +"Decimal('0.0060000')\n" +">>> u * (v+w)\n" +"Decimal('0.0060000')" -#: ../../library/decimal.rst:1813 +#: ../../library/decimal.rst:1839 msgid "Special values" msgstr "特殊值" -#: ../../library/decimal.rst:1815 +#: ../../library/decimal.rst:1841 msgid "" "The number system for the :mod:`decimal` module provides special values " "including ``NaN``, ``sNaN``, ``-Infinity``, ``Infinity``, and two zeros, " "``+0`` and ``-0``." msgstr "" -#: ../../library/decimal.rst:1819 +#: ../../library/decimal.rst:1845 msgid "" "Infinities can be constructed directly with: ``Decimal('Infinity')``. Also, " "they can arise from dividing by zero when the :exc:`DivisionByZero` signal " @@ -2303,14 +2354,14 @@ msgid "" "representable number." msgstr "" -#: ../../library/decimal.rst:1824 +#: ../../library/decimal.rst:1850 msgid "" "The infinities are signed (affine) and can be used in arithmetic operations " "where they get treated as very large, indeterminate numbers. For instance, " "adding a constant to infinity gives another infinite result." msgstr "" -#: ../../library/decimal.rst:1828 +#: ../../library/decimal.rst:1854 msgid "" "Some operations are indeterminate and return ``NaN``, or if the :exc:" "`InvalidOperation` signal is trapped, raise an exception. For example, " @@ -2321,14 +2372,14 @@ msgid "" "the calculation to proceed while flagging specific results as invalid." msgstr "" -#: ../../library/decimal.rst:1836 +#: ../../library/decimal.rst:1862 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 " "interrupt a calculation for special handling." msgstr "" -#: ../../library/decimal.rst:1840 +#: ../../library/decimal.rst:1866 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 " @@ -2345,7 +2396,7 @@ msgid "" "compare_signal` methods instead." msgstr "" -#: ../../library/decimal.rst:1853 +#: ../../library/decimal.rst:1879 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 " @@ -2353,7 +2404,7 @@ msgid "" "negative zeros are treated as equal and their sign is informational." msgstr "" -#: ../../library/decimal.rst:1858 +#: ../../library/decimal.rst:1884 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 " @@ -2362,11 +2413,11 @@ msgid "" "that the following calculation returns a value equal to zero:" msgstr "" -#: ../../library/decimal.rst:1873 +#: ../../library/decimal.rst:1899 msgid "Working with threads" msgstr "" -#: ../../library/decimal.rst:1875 +#: ../../library/decimal.rst:1901 msgid "" "The :func:`getcontext` function accesses a different :class:`Context` object " "for each thread. Having separate thread contexts means that threads may " @@ -2374,29 +2425,39 @@ msgid "" "other threads." msgstr "" -#: ../../library/decimal.rst:1879 +#: ../../library/decimal.rst:1905 msgid "" "Likewise, the :func:`setcontext` function automatically assigns its target " "to the current thread." msgstr "" -#: ../../library/decimal.rst:1882 +#: ../../library/decimal.rst:1908 msgid "" "If :func:`setcontext` has not been called before :func:`getcontext`, then :" "func:`getcontext` will automatically create a new context for use in the " -"current thread." +"current thread. New context objects have default values set from the :data:" +"`decimal.DefaultContext` object." msgstr "" -#: ../../library/decimal.rst:1886 +#: ../../library/decimal.rst:1913 +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 " +"context. In this case, :func:`getcontext` will create a new context object " +"when called and use the default values from *DefaultContext*. If the flag " +"is true, new threads will start with a copy of context from the caller of :" +"meth:`threading.Thread.start`." +msgstr "" + +#: ../../library/decimal.rst:1920 msgid "" -"The new context is copied from a prototype context called *DefaultContext*. " "To control the defaults so that each thread will use the same values " "throughout the application, directly modify the *DefaultContext* object. " "This should be done *before* any threads are started so that there won't be " "a race condition between threads calling :func:`getcontext`. For example::" msgstr "" -#: ../../library/decimal.rst:1892 +#: ../../library/decimal.rst:1925 msgid "" "# Set applicationwide defaults for all threads about to be launched\n" "DefaultContext.prec = 12\n" @@ -2412,17 +2473,17 @@ msgid "" " . . ." msgstr "" -#: ../../library/decimal.rst:1911 +#: ../../library/decimal.rst:1944 msgid "Recipes" msgstr "" -#: ../../library/decimal.rst:1913 +#: ../../library/decimal.rst:1946 msgid "" "Here are a few recipes that serve as utility functions and that demonstrate " "ways to work with the :class:`Decimal` class::" msgstr "" -#: ../../library/decimal.rst:1916 +#: ../../library/decimal.rst:1949 msgid "" "def moneyfmt(value, places=2, curr='', sep=',', dp='.',\n" " pos='', neg='-', trailneg=''):\n" @@ -2571,75 +2632,75 @@ msgid "" " return +s" msgstr "" -#: ../../library/decimal.rst:2068 +#: ../../library/decimal.rst:2101 msgid "Decimal FAQ" msgstr "" -#: ../../library/decimal.rst:2070 +#: ../../library/decimal.rst:2103 msgid "" -"Q. It is cumbersome to type ``decimal.Decimal('1234.5')``. Is there a way " +"Q: It is cumbersome to type ``decimal.Decimal('1234.5')``. Is there a way " "to minimize typing when using the interactive interpreter?" msgstr "" -#: ../../library/decimal.rst:2073 -msgid "A. Some users abbreviate the constructor to just a single letter:" +#: ../../library/decimal.rst:2106 +msgid "A: Some users abbreviate the constructor to just a single letter:" msgstr "" -#: ../../library/decimal.rst:2079 +#: ../../library/decimal.rst:2112 msgid "" -"Q. In a fixed-point application with two decimal places, some inputs have " +"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 " "digits and need to be validated. What methods should be used?" msgstr "" -#: ../../library/decimal.rst:2083 +#: ../../library/decimal.rst:2116 msgid "" -"A. The :meth:`~Decimal.quantize` method rounds to a fixed number of decimal " +"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 " "validation:" msgstr "" -#: ../../library/decimal.rst:2101 +#: ../../library/decimal.rst:2134 msgid "" -"Q. Once I have valid two place inputs, how do I maintain that invariant " +"Q: Once I have valid two place inputs, how do I maintain that invariant " "throughout an application?" msgstr "" -#: ../../library/decimal.rst:2104 +#: ../../library/decimal.rst:2137 msgid "" -"A. Some operations like addition, subtraction, and multiplication by an " +"A: Some operations like addition, subtraction, and multiplication by an " "integer will automatically preserve fixed point. Others operations, like " "division and non-integer multiplication, will change the number of decimal " "places and need to be followed-up with a :meth:`~Decimal.quantize` step:" msgstr "" -#: ../../library/decimal.rst:2122 +#: ../../library/decimal.rst:2155 msgid "" "In developing fixed-point applications, it is convenient to define functions " "to handle the :meth:`~Decimal.quantize` step:" msgstr "" -#: ../../library/decimal.rst:2136 +#: ../../library/decimal.rst:2169 msgid "" -"Q. There are many ways to express the same value. The numbers ``200``, " +"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 " "precisions. Is there a way to transform them to a single recognizable " "canonical value?" msgstr "" -#: ../../library/decimal.rst:2141 +#: ../../library/decimal.rst:2174 msgid "" -"A. The :meth:`~Decimal.normalize` method maps all equivalent values to a " +"A: The :meth:`~Decimal.normalize` method maps all equivalent values to a " "single representative:" msgstr "" -#: ../../library/decimal.rst:2148 -msgid "Q. When does rounding occur in a computation?" +#: ../../library/decimal.rst:2181 +msgid "Q: When does rounding occur in a computation?" msgstr "" -#: ../../library/decimal.rst:2150 +#: ../../library/decimal.rst:2183 msgid "" -"A. It occurs *after* the computation. The philosophy of the decimal " +"A: It occurs *after* the computation. The philosophy of the decimal " "specification is that numbers are considered exact and are created " "independent of the current context. They can even have greater precision " "than current context. Computations process with those exact inputs and then " @@ -2647,7 +2708,7 @@ msgid "" "computation::" msgstr "" -#: ../../library/decimal.rst:2157 +#: ../../library/decimal.rst:2190 msgid "" ">>> getcontext().prec = 5\n" ">>> pi = Decimal('3.1415926535') # More than 5 digits\n" @@ -2661,39 +2722,39 @@ msgid "" "Decimal('3.1416')" msgstr "" -#: ../../library/decimal.rst:2168 +#: ../../library/decimal.rst:2201 msgid "" -"Q. Some decimal values always print with exponential notation. Is there a " +"Q: Some decimal values always print with exponential notation. Is there a " "way to get a non-exponential representation?" msgstr "" -#: ../../library/decimal.rst:2171 +#: ../../library/decimal.rst:2204 msgid "" -"A. For some values, exponential notation is the only way to express the " +"A: For some values, exponential notation is the only way to express the " "number of significant places in the coefficient. For example, expressing " "``5.0E+3`` as ``5000`` keeps the value constant but cannot show the " "original's two-place significance." msgstr "" -#: ../../library/decimal.rst:2176 +#: ../../library/decimal.rst:2209 msgid "" "If an application does not care about tracking significance, it is easy to " "remove the exponent and trailing zeroes, losing significance, but keeping " "the value unchanged:" msgstr "" -#: ../../library/decimal.rst:2186 -msgid "Q. Is there a way to convert a regular float to a :class:`Decimal`?" +#: ../../library/decimal.rst:2219 +msgid "Q: Is there a way to convert a regular float to a :class:`Decimal`?" msgstr "" -#: ../../library/decimal.rst:2188 +#: ../../library/decimal.rst:2221 msgid "" -"A. Yes, any binary floating-point number can be exactly expressed as a " +"A: Yes, any binary floating-point number can be exactly expressed as a " "Decimal though an exact conversion may take more precision than intuition " "would suggest:" msgstr "" -#: ../../library/decimal.rst:2192 +#: ../../library/decimal.rst:2225 msgid "" ">>> Decimal(math.pi)\n" "Decimal('3.141592653589793115997963468544185161590576171875')" @@ -2701,37 +2762,37 @@ msgstr "" ">>> Decimal(math.pi)\n" "Decimal('3.141592653589793115997963468544185161590576171875')" -#: ../../library/decimal.rst:2197 +#: ../../library/decimal.rst:2230 msgid "" -"Q. Within a complex calculation, how can I make sure that I haven't gotten a " +"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:2200 +#: ../../library/decimal.rst:2233 msgid "" -"A. The decimal module makes it easy to test results. A best practice is to " +"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. " "Widely differing results indicate insufficient precision, rounding mode " "issues, ill-conditioned inputs, or a numerically unstable algorithm." msgstr "" -#: ../../library/decimal.rst:2205 +#: ../../library/decimal.rst:2238 msgid "" -"Q. I noticed that context precision is applied to the results of operations " +"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 " "values of different precisions?" msgstr "" -#: ../../library/decimal.rst:2209 +#: ../../library/decimal.rst:2242 msgid "" -"A. Yes. The principle is that all values are considered to be exact and so " +"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 " "advantage for inputs is that \"what you type is what you get\". A " "disadvantage is that the results can look odd if you forget that the inputs " "haven't been rounded:" msgstr "" -#: ../../library/decimal.rst:2214 +#: ../../library/decimal.rst:2247 msgid "" ">>> getcontext().prec = 3\n" ">>> Decimal('3.104') + Decimal('2.104')\n" @@ -2745,32 +2806,32 @@ msgstr "" ">>> Decimal('3.104') + Decimal('0.000') + Decimal('2.104')\n" "Decimal('5.20')" -#: ../../library/decimal.rst:2222 +#: ../../library/decimal.rst:2255 msgid "" "The solution is either to increase precision or to force rounding of inputs " "using the unary plus operation:" msgstr "" -#: ../../library/decimal.rst:2225 +#: ../../library/decimal.rst:2258 msgid "" ">>> getcontext().prec = 3\n" ">>> +Decimal('1.23456789') # unary plus triggers rounding\n" "Decimal('1.23')" msgstr "" -#: ../../library/decimal.rst:2231 +#: ../../library/decimal.rst:2264 msgid "" "Alternatively, inputs can be rounded upon creation using the :meth:`Context." "create_decimal` method:" msgstr "" -#: ../../library/decimal.rst:2237 -msgid "Q. Is the CPython implementation fast for large numbers?" +#: ../../library/decimal.rst:2270 +msgid "Q: Is the CPython implementation fast for large numbers?" msgstr "" -#: ../../library/decimal.rst:2239 +#: ../../library/decimal.rst:2272 msgid "" -"A. Yes. In the CPython and PyPy3 implementations, the C/CFFI versions of " +"A: Yes. In the CPython and PyPy3 implementations, the C/CFFI versions of " "the decimal module integrate the high speed `libmpdec `_ library for arbitrary precision " "correctly rounded decimal floating-point arithmetic [#]_. ``libmpdec`` uses " @@ -2781,7 +2842,7 @@ msgid "" "large numbers." msgstr "" -#: ../../library/decimal.rst:2249 +#: ../../library/decimal.rst:2282 msgid "" "The context must be adapted for exact arbitrary precision arithmetic. :attr:" "`~Context.Emin` and :attr:`~Context.Emax` should always be set to the " @@ -2789,13 +2850,13 @@ msgid "" "Setting :attr:`~Context.prec` requires some care." msgstr "" -#: ../../library/decimal.rst:2253 +#: ../../library/decimal.rst:2286 msgid "" "The easiest approach for trying out bignum arithmetic is to use the maximum " "value for :attr:`~Context.prec` as well [#]_::" msgstr "" -#: ../../library/decimal.rst:2256 +#: ../../library/decimal.rst:2289 msgid "" ">>> setcontext(Context(prec=MAX_PREC, Emax=MAX_EMAX, Emin=MIN_EMIN))\n" ">>> x = Decimal(2) ** 256\n" @@ -2807,13 +2868,13 @@ msgstr "" ">>> x / 128\n" "Decimal('904625697166532776746648320380374280103671755200316906558262375061821325312')" -#: ../../library/decimal.rst:2262 +#: ../../library/decimal.rst:2295 msgid "" "For inexact results, :const:`MAX_PREC` is far too large on 64-bit platforms " "and the available memory will be insufficient::" msgstr "" -#: ../../library/decimal.rst:2265 +#: ../../library/decimal.rst:2298 msgid "" ">>> Decimal(1) / 3\n" "Traceback (most recent call last):\n" @@ -2825,7 +2886,7 @@ msgstr "" " File \"\", line 1, in \n" "MemoryError" -#: ../../library/decimal.rst:2270 +#: ../../library/decimal.rst:2303 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 " @@ -2833,7 +2894,7 @@ msgid "" "of 500MB each::" msgstr "" -#: ../../library/decimal.rst:2274 +#: ../../library/decimal.rst:2307 msgid "" ">>> import sys\n" ">>>\n" @@ -2857,14 +2918,14 @@ msgid "" " decimal.Inexact: []" msgstr "" -#: ../../library/decimal.rst:2294 +#: ../../library/decimal.rst:2327 msgid "" "In general (and especially on systems without overallocation), it is " "recommended to estimate even tighter bounds and set the :attr:`Inexact` trap " "if all calculations are expected to be exact." msgstr "" -#: ../../library/decimal.rst:2303 +#: ../../library/decimal.rst:2336 msgid "" "This approach now works for all exact results except for non-integer powers." msgstr "" diff --git a/library/development.po b/library/development.po index 0272023235a..9e47eced753 100644 --- a/library/development.po +++ b/library/development.po @@ -1,12 +1,11 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Leon H., 2017 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-23 07:52+0800\n" "PO-Revision-Date: 2017-09-22 18:26+0000\n" diff --git a/library/devmode.po b/library/devmode.po index d624765024b..3d05d82aac6 100644 --- a/library/devmode.po +++ b/library/devmode.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -6,7 +6,7 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-01 22:24+0800\n" "PO-Revision-Date: 2024-05-03 02:14+0800\n" @@ -279,6 +279,16 @@ msgid "" "if __name__ == \"__main__\":\n" " main()" msgstr "" +"import sys\n" +"\n" +"def main():\n" +" fp = open(sys.argv[1])\n" +" nlines = len(fp.readlines())\n" +" print(nlines)\n" +" # The file is closed implicitly\n" +"\n" +"if __name__ == \"__main__\":\n" +" main()" #: ../../library/devmode.rst:127 msgid "" @@ -361,6 +371,11 @@ msgid "" " nlines = len(fp.readlines())\n" " print(nlines)" msgstr "" +"def main():\n" +" # 在退出 with 區塊時明確關閉檔案\n" +" with open(sys.argv[1]) as fp:\n" +" nlines = len(fp.readlines())\n" +" print(nlines)" #: ../../library/devmode.rst:168 msgid "" @@ -394,6 +409,16 @@ msgid "" "\n" "main()" msgstr "" +"import os\n" +"\n" +"def main():\n" +" fp = open(__file__)\n" +" firstline = fp.readline()\n" +" print(firstline.rstrip())\n" +" os.close(fp.fileno())\n" +" # 檔案是隱式關閉的\n" +"\n" +"main()" #: ../../library/devmode.rst:190 msgid "By default, Python does not emit any warning:" diff --git a/library/dialog.po b/library/dialog.po index 34608654673..7bc9c50cda9 100644 --- a/library/dialog.po +++ b/library/dialog.po @@ -1,14 +1,13 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# 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.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-09-13 00:11+0000\n" +"POT-Creation-Date: 2025-12-01 00:17+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-" @@ -60,7 +59,7 @@ msgstr "" #: ../../library/dialog.rst:43 msgid ":mod:`tkinter.filedialog` --- File selection dialogs" -msgstr "" +msgstr ":mod:`tkinter.filedialog` --- 檔案選擇對話框" #: ../../library/dialog.rst:49 msgid "**Source code:** :source:`Lib/tkinter/filedialog.py`" @@ -84,32 +83,32 @@ msgid "" "listed below:" msgstr "" -#: ../../library/dialog.rst:0 +#: ../../library/dialog.rst:64 msgid "*parent* - the window to place the dialog on top of" msgstr "" -#: ../../library/dialog.rst:0 +#: ../../library/dialog.rst:66 msgid "*title* - the title of the window" msgstr "" -#: ../../library/dialog.rst:0 +#: ../../library/dialog.rst:68 msgid "*initialdir* - the directory that the dialog starts in" msgstr "" -#: ../../library/dialog.rst:0 +#: ../../library/dialog.rst:70 msgid "*initialfile* - the file selected upon opening of the dialog" msgstr "" -#: ../../library/dialog.rst:0 +#: ../../library/dialog.rst:72 msgid "" "*filetypes* - a sequence of (label, pattern) tuples, '*' wildcard is allowed" msgstr "" -#: ../../library/dialog.rst:0 +#: ../../library/dialog.rst:74 msgid "*defaultextension* - default extension to append to file (save dialogs)" msgstr "" -#: ../../library/dialog.rst:0 +#: ../../library/dialog.rst:76 msgid "*multiple* - when true, selection of multiple items is allowed" msgstr "" diff --git a/library/difflib.po b/library/difflib.po index f47345cb456..8db7c3d59af 100644 --- a/library/difflib.po +++ b/library/difflib.po @@ -1,12 +1,12 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-08-08 00:17+0000\n" +"POT-Creation-Date: 2025-10-08 00:15+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-" @@ -89,7 +89,7 @@ msgstr "" #: ../../library/difflib.rst:69 msgid "Code" -msgstr "" +msgstr "程式碼" #: ../../library/difflib.rst:69 ../../library/difflib.rst:496 msgid "Meaning" @@ -310,7 +310,7 @@ 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 " "is also a module-level function :func:`IS_LINE_JUNK`, which filters out " -"lines without visible characters, except for at most one pound character " +"lines without visible characters, except for at most one hash character " "(``'#'``) -- however the underlying :class:`SequenceMatcher` class does a " "dynamic analysis of which lines are so frequent as to constitute noise, and " "this usually works better than using this function." diff --git a/library/dis.po b/library/dis.po index d6ce62924e1..187ceb7964f 100644 --- a/library/dis.po +++ b/library/dis.po @@ -1,13 +1,13 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # splasky Chang , 2017 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-04-24 05:58+0000\n" +"POT-Creation-Date: 2025-11-10 00:16+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-" @@ -61,17 +61,17 @@ msgstr "" msgid "" "Some instructions are accompanied by one or more inline cache entries, which " "take the form of :opcode:`CACHE` instructions. These instructions are hidden " -"by default, but can be shown by passing ``show_caches=True`` to " -"any :mod:`dis` utility. Furthermore, the interpreter now adapts the bytecode " -"to specialize it for different runtime conditions. The adaptive bytecode can " -"be shown by passing ``adaptive=True``." +"by default, but can be shown by passing ``show_caches=True`` to any :mod:" +"`dis` utility. Furthermore, the interpreter now adapts the bytecode to " +"specialize it for different runtime conditions. The adaptive bytecode can be " +"shown by passing ``adaptive=True``." msgstr "" #: ../../library/dis.rst:45 msgid "" "The argument of a jump is the offset of the target instruction relative to " -"the instruction that appears immediately after the jump " -"instruction's :opcode:`CACHE` entries." +"the instruction that appears immediately after the jump instruction's :" +"opcode:`CACHE` entries." msgstr "" #: ../../library/dis.rst:50 @@ -89,10 +89,20 @@ msgid "" msgstr "" #: ../../library/dis.rst:59 +msgid "" +"The :option:`-P ` command-line option and the " +"``show_positions`` argument were added." +msgstr "" + +#: ../../library/dis.rst:63 +msgid "The :option:`-S ` command-line option is added." +msgstr "" + +#: ../../library/dis.rst:65 msgid "Example: Given the function :func:`!myfunc`::" msgstr "" -#: ../../library/dis.rst:61 +#: ../../library/dis.rst:67 msgid "" "def myfunc(alist):\n" " return len(alist)" @@ -100,19 +110,19 @@ msgstr "" "def myfunc(alist):\n" " return len(alist)" -#: ../../library/dis.rst:64 +#: ../../library/dis.rst:70 msgid "" "the following command can be used to display the disassembly of :func:`!" "myfunc`:" -msgstr "" +msgstr "可以使用以下指令來顯示 :func:`!myfunc` 的反組譯:" -#: ../../library/dis.rst:67 +#: ../../library/dis.rst:73 msgid "" ">>> dis.dis(myfunc)\n" " 2 RESUME 0\n" "\n" " 3 LOAD_GLOBAL 1 (len + NULL)\n" -" LOAD_FAST 0 (alist)\n" +" LOAD_FAST_BORROW 0 (alist)\n" " CALL 1\n" " RETURN_VALUE" msgstr "" @@ -120,75 +130,83 @@ msgstr "" " 2 RESUME 0\n" "\n" " 3 LOAD_GLOBAL 1 (len + NULL)\n" -" LOAD_FAST 0 (alist)\n" +" LOAD_FAST_BORROW 0 (alist)\n" " CALL 1\n" " RETURN_VALUE" -#: ../../library/dis.rst:77 +#: ../../library/dis.rst:83 msgid "(The \"2\" is a line number)." msgstr "" -#: ../../library/dis.rst:82 +#: ../../library/dis.rst:88 msgid "Command-line interface" msgstr "命令列介面" -#: ../../library/dis.rst:84 +#: ../../library/dis.rst:90 msgid "The :mod:`dis` module can be invoked as a script from the command line:" msgstr "" -#: ../../library/dis.rst:86 -msgid "python -m dis [-h] [-C] [-O] [infile]" -msgstr "python -m dis [-h] [-C] [-O] [infile]" +#: ../../library/dis.rst:92 +msgid "python -m dis [-h] [-C] [-O] [-P] [-S] [infile]" +msgstr "python -m dis [-h] [-C] [-O] [-P] [-S] [infile]" -#: ../../library/dis.rst:90 +#: ../../library/dis.rst:96 msgid "The following options are accepted:" msgstr "可接受以下選項:" -#: ../../library/dis.rst:96 +#: ../../library/dis.rst:102 msgid "Display usage and exit." msgstr "" -#: ../../library/dis.rst:100 +#: ../../library/dis.rst:106 msgid "Show inline caches." msgstr "" -#: ../../library/dis.rst:106 +#: ../../library/dis.rst:112 msgid "Show offsets of instructions." msgstr "" -#: ../../library/dis.rst:110 +#: ../../library/dis.rst:118 +msgid "Show positions of instructions in the source code." +msgstr "" + +#: ../../library/dis.rst:124 +msgid "Show specialized bytecode." +msgstr "" + +#: ../../library/dis.rst:128 msgid "" "If :file:`infile` is specified, its disassembled code will be written to " "stdout. Otherwise, disassembly is performed on compiled source code received " "from stdin." msgstr "" -#: ../../library/dis.rst:114 +#: ../../library/dis.rst:132 msgid "Bytecode analysis" msgstr "" -#: ../../library/dis.rst:118 +#: ../../library/dis.rst:136 msgid "" -"The bytecode analysis API allows pieces of Python code to be wrapped in " -"a :class:`Bytecode` object that provides easy access to details of the " -"compiled code." +"The bytecode analysis API allows pieces of Python code to be wrapped in a :" +"class:`Bytecode` object that provides easy access to details of the compiled " +"code." msgstr "" -#: ../../library/dis.rst:125 +#: ../../library/dis.rst:144 msgid "" "Analyse the bytecode corresponding to a function, generator, asynchronous " "generator, coroutine, method, string of source code, or a code object (as " "returned by :func:`compile`)." msgstr "" -#: ../../library/dis.rst:129 +#: ../../library/dis.rst:148 msgid "" "This is a convenience wrapper around many of the functions listed below, " "most notably :func:`get_instructions`, as iterating over a :class:`Bytecode` " "instance yields the bytecode operations as :class:`Instruction` instances." msgstr "" -#: ../../library/dis.rst:133 ../../library/dis.rst:330 +#: ../../library/dis.rst:152 ../../library/dis.rst:373 msgid "" "If *first_line* is not ``None``, it indicates the line number that should be " "reported for the first source line in the disassembled code. Otherwise, the " @@ -196,73 +214,88 @@ msgid "" "code object." msgstr "" -#: ../../library/dis.rst:138 +#: ../../library/dis.rst:157 msgid "" "If *current_offset* is not ``None``, it refers to an instruction offset in " "the disassembled code. Setting this means :meth:`.dis` will display a " "\"current instruction\" marker against the specified opcode." msgstr "" -#: ../../library/dis.rst:142 +#: ../../library/dis.rst:161 msgid "" "If *show_caches* is ``True``, :meth:`.dis` will display inline cache entries " "used by the interpreter to specialize the bytecode." msgstr "" -#: ../../library/dis.rst:145 +#: ../../library/dis.rst:164 msgid "" "If *adaptive* is ``True``, :meth:`.dis` will display specialized bytecode " "that may be different from the original bytecode." msgstr "" -#: ../../library/dis.rst:148 +#: ../../library/dis.rst:167 msgid "" "If *show_offsets* is ``True``, :meth:`.dis` will include instruction offsets " "in the output." msgstr "" -#: ../../library/dis.rst:153 +#: ../../library/dis.rst:170 +msgid "" +"If *show_positions* is ``True``, :meth:`.dis` will include instruction " +"source code positions in the output." +msgstr "" + +#: ../../library/dis.rst:175 msgid "" "Construct a :class:`Bytecode` instance from the given traceback, setting " "*current_offset* to the instruction responsible for the exception." msgstr "" -#: ../../library/dis.rst:158 +#: ../../library/dis.rst:180 msgid "The compiled code object." msgstr "" -#: ../../library/dis.rst:162 +#: ../../library/dis.rst:184 msgid "The first source line of the code object (if available)" msgstr "" -#: ../../library/dis.rst:166 +#: ../../library/dis.rst:188 msgid "" -"Return a formatted view of the bytecode operations (the same as printed " -"by :func:`dis.dis`, but returned as a multi-line string)." +"Return a formatted view of the bytecode operations (the same as printed by :" +"func:`dis.dis`, but returned as a multi-line string)." msgstr "" -#: ../../library/dis.rst:171 +#: ../../library/dis.rst:193 msgid "" "Return a formatted multi-line string with detailed information about the " "code object, like :func:`code_info`." msgstr "" -#: ../../library/dis.rst:174 ../../library/dis.rst:214 -#: ../../library/dis.rst:266 +#: ../../library/dis.rst:196 ../../library/dis.rst:242 +#: ../../library/dis.rst:295 msgid "This can now handle coroutine and asynchronous generator objects." msgstr "" -#: ../../library/dis.rst:177 ../../library/dis.rst:269 -#: ../../library/dis.rst:286 ../../library/dis.rst:316 -#: ../../library/dis.rst:339 +#: ../../library/dis.rst:199 ../../library/dis.rst:298 +#: ../../library/dis.rst:320 ../../library/dis.rst:356 +#: ../../library/dis.rst:382 msgid "Added the *show_caches* and *adaptive* parameters." msgstr "新增 *show_caches* 與 *adaptive* 參數。" -#: ../../library/dis.rst:180 +#: ../../library/dis.rst:202 +msgid "Added the *show_offsets* parameter" +msgstr "新增 *show_offsets* 參數。" + +#: ../../library/dis.rst:205 ../../library/dis.rst:304 +#: ../../library/dis.rst:326 ../../library/dis.rst:362 +msgid "Added the *show_positions* parameter." +msgstr "新增 *show_positions* 參數。" + +#: ../../library/dis.rst:208 msgid "Example:" msgstr "範例:" -#: ../../library/dis.rst:182 +#: ../../library/dis.rst:210 msgid "" ">>> bytecode = dis.Bytecode(myfunc)\n" ">>> for instr in bytecode:\n" @@ -270,7 +303,7 @@ msgid "" "...\n" "RESUME\n" "LOAD_GLOBAL\n" -"LOAD_FAST\n" +"LOAD_FAST_BORROW\n" "CALL\n" "RETURN_VALUE" msgstr "" @@ -280,15 +313,15 @@ msgstr "" "...\n" "RESUME\n" "LOAD_GLOBAL\n" -"LOAD_FAST\n" +"LOAD_FAST_BORROW\n" "CALL\n" "RETURN_VALUE" -#: ../../library/dis.rst:196 +#: ../../library/dis.rst:224 msgid "Analysis functions" msgstr "分析函式" -#: ../../library/dis.rst:198 +#: ../../library/dis.rst:226 msgid "" "The :mod:`dis` module also defines the following analysis functions that " "convert the input directly to the desired output. They can be useful if only " @@ -296,39 +329,39 @@ msgid "" "isn't useful:" msgstr "" -#: ../../library/dis.rst:204 +#: ../../library/dis.rst:232 msgid "" "Return a formatted multi-line string with detailed code object information " "for the supplied function, generator, asynchronous generator, coroutine, " "method, source code string or code object." msgstr "" -#: ../../library/dis.rst:208 +#: ../../library/dis.rst:236 msgid "" "Note that the exact contents of code info strings are highly implementation " "dependent and they may change arbitrarily across Python VMs or Python " "releases." msgstr "" -#: ../../library/dis.rst:220 +#: ../../library/dis.rst:248 msgid "" "Print detailed code object information for the supplied function, method, " "source code string or code object to *file* (or ``sys.stdout`` if *file* is " "not specified)." msgstr "" -#: ../../library/dis.rst:224 +#: ../../library/dis.rst:252 msgid "" "This is a convenient shorthand for ``print(code_info(x), file=file)``, " "intended for interactive exploration at the interpreter prompt." msgstr "" -#: ../../library/dis.rst:229 ../../library/dis.rst:260 -#: ../../library/dis.rst:283 ../../library/dis.rst:313 +#: ../../library/dis.rst:257 ../../library/dis.rst:289 +#: ../../library/dis.rst:317 ../../library/dis.rst:353 msgid "Added *file* parameter." msgstr "新增 *file* 參數。" -#: ../../library/dis.rst:235 +#: ../../library/dis.rst:264 msgid "" "Disassemble the *x* object. *x* can denote either a module, a class, a " "method, a function, a generator, an asynchronous generator, a coroutine, a " @@ -344,103 +377,107 @@ msgid "" "disassembles the last traceback." msgstr "" -#: ../../library/dis.rst:248 ../../library/dis.rst:280 -#: ../../library/dis.rst:310 +#: ../../library/dis.rst:277 ../../library/dis.rst:314 +#: ../../library/dis.rst:350 msgid "" "The disassembly is written as text to the supplied *file* argument if " "provided and to ``sys.stdout`` otherwise." msgstr "" -#: ../../library/dis.rst:251 +#: ../../library/dis.rst:280 msgid "" "The maximal depth of recursion is limited by *depth* unless it is ``None``. " "``depth=0`` means no recursion." msgstr "" -#: ../../library/dis.rst:254 +#: ../../library/dis.rst:283 msgid "" "If *show_caches* is ``True``, this function will display inline cache " "entries used by the interpreter to specialize the bytecode." msgstr "" -#: ../../library/dis.rst:257 +#: ../../library/dis.rst:286 msgid "" "If *adaptive* is ``True``, this function will display specialized bytecode " "that may be different from the original bytecode." msgstr "" -#: ../../library/dis.rst:263 +#: ../../library/dis.rst:292 msgid "Implemented recursive disassembling and added *depth* parameter." msgstr "" -#: ../../library/dis.rst:276 +#: ../../library/dis.rst:301 ../../library/dis.rst:323 +#: ../../library/dis.rst:359 +msgid "Added the *show_offsets* parameter." +msgstr "新增 *show_offsets* 參數。" + +#: ../../library/dis.rst:310 msgid "" "Disassemble the top-of-stack function of a traceback, using the last " "traceback if none was passed. The instruction causing the exception is " "indicated." msgstr "" -#: ../../library/dis.rst:289 ../../library/dis.rst:319 -msgid "Added the *show_offsets* parameter." -msgstr "新增 *show_offsets* 參數。" - -#: ../../library/dis.rst:296 +#: ../../library/dis.rst:334 msgid "" "Disassemble a code object, indicating the last instruction if *lasti* was " "provided. The output is divided in the following columns:" msgstr "" -#: ../../library/dis.rst:299 -msgid "the line number, for the first instruction of each line" +#: ../../library/dis.rst:337 +msgid "" +"the source code location of the instruction. Complete location information " +"is shown if *show_positions* is true. Otherwise (the default) only the line " +"number is displayed." msgstr "" -#: ../../library/dis.rst:300 +#: ../../library/dis.rst:340 msgid "the current instruction, indicated as ``-->``," msgstr "" -#: ../../library/dis.rst:301 +#: ../../library/dis.rst:341 msgid "a labelled instruction, indicated with ``>>``," msgstr "" -#: ../../library/dis.rst:302 +#: ../../library/dis.rst:342 msgid "the address of the instruction," msgstr "" -#: ../../library/dis.rst:303 +#: ../../library/dis.rst:343 msgid "the operation code name," msgstr "" -#: ../../library/dis.rst:304 +#: ../../library/dis.rst:344 msgid "operation parameters, and" msgstr "" -#: ../../library/dis.rst:305 +#: ../../library/dis.rst:345 msgid "interpretation of the parameters in parentheses." msgstr "" -#: ../../library/dis.rst:307 +#: ../../library/dis.rst:347 msgid "" "The parameter interpretation recognizes local and global variable names, " "constant values, branch targets, and compare operators." msgstr "" -#: ../../library/dis.rst:324 +#: ../../library/dis.rst:367 msgid "" "Return an iterator over the instructions in the supplied function, method, " "source code string or code object." msgstr "" -#: ../../library/dis.rst:327 +#: ../../library/dis.rst:370 msgid "" "The iterator generates a series of :class:`Instruction` named tuples giving " "the details of each operation in the supplied code." msgstr "" -#: ../../library/dis.rst:335 +#: ../../library/dis.rst:378 msgid "The *adaptive* parameter works as it does in :func:`dis`." msgstr "" -#: ../../library/dis.rst:342 +#: ../../library/dis.rst:385 msgid "" "The *show_caches* parameter is deprecated and has no effect. The iterator " "generates the :class:`Instruction` instances with the *cache_info* field " @@ -448,41 +485,41 @@ msgid "" "generates separate items for the cache entries." msgstr "" -#: ../../library/dis.rst:350 +#: ../../library/dis.rst:393 msgid "" -"This generator function uses the :meth:`~codeobject.co_lines` method of " -"the :ref:`code object ` *code* to find the offsets which are " -"starts of lines in the source code. They are generated as ``(offset, " -"lineno)`` pairs." +"This generator function uses the :meth:`~codeobject.co_lines` method of the :" +"ref:`code object ` *code* to find the offsets which are starts " +"of lines in the source code. They are generated as ``(offset, lineno)`` " +"pairs." msgstr "" -#: ../../library/dis.rst:355 +#: ../../library/dis.rst:398 msgid "Line numbers can be decreasing. Before, they were always increasing." msgstr "" -#: ../../library/dis.rst:358 +#: ../../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` " +"The :pep:`626` :meth:`~codeobject.co_lines` method is used instead of the :" +"attr:`~codeobject.co_firstlineno` and :attr:`~codeobject.co_lnotab` " "attributes of the :ref:`code object `." msgstr "" -#: ../../library/dis.rst:363 +#: ../../library/dis.rst:406 msgid "" "Line numbers can be ``None`` for bytecode that does not map to source lines." msgstr "" -#: ../../library/dis.rst:369 +#: ../../library/dis.rst:412 msgid "" "Detect all offsets in the raw compiled bytecode string *code* which are jump " "targets, and return a list of these offsets." msgstr "" -#: ../../library/dis.rst:375 +#: ../../library/dis.rst:418 msgid "Compute the stack effect of *opcode* with argument *oparg*." msgstr "" -#: ../../library/dis.rst:377 +#: ../../library/dis.rst:420 msgid "" "If the code has a jump target and *jump* is ``True``, :func:`~stack_effect` " "will return the stack effect of jumping. If *jump* is ``False``, it will " @@ -490,11 +527,11 @@ msgid "" "it will return the maximal stack effect of both cases." msgstr "" -#: ../../library/dis.rst:384 +#: ../../library/dis.rst:427 msgid "Added *jump* parameter." msgstr "新增 *jump* 參數。" -#: ../../library/dis.rst:387 +#: ../../library/dis.rst:430 msgid "" "If ``oparg`` is omitted (or ``None``), the stack effect is now returned for " "``oparg=0``. Previously this was an error for opcodes that use their arg. It " @@ -502,104 +539,104 @@ msgid "" "does not use it; the ``oparg`` in this case is ignored." msgstr "" -#: ../../library/dis.rst:397 +#: ../../library/dis.rst:440 msgid "Python Bytecode Instructions" msgstr "Python 位元組碼指令" -#: ../../library/dis.rst:399 +#: ../../library/dis.rst:442 msgid "" "The :func:`get_instructions` function and :class:`Bytecode` class provide " "details of bytecode instructions as :class:`Instruction` instances:" msgstr "" -#: ../../library/dis.rst:404 +#: ../../library/dis.rst:447 msgid "Details for a bytecode operation" msgstr "位元組碼操作的詳細資訊" -#: ../../library/dis.rst:408 +#: ../../library/dis.rst:451 msgid "" "numeric code for operation, corresponding to the opcode values listed below " "and the bytecode values in the :ref:`opcode_collections`." msgstr "" -#: ../../library/dis.rst:414 +#: ../../library/dis.rst:457 msgid "human readable name for operation" msgstr "操作的可讀名稱" -#: ../../library/dis.rst:419 +#: ../../library/dis.rst:462 msgid "" "numeric code for the base operation if operation is specialized; otherwise " "equal to :data:`opcode`" msgstr "" -#: ../../library/dis.rst:425 +#: ../../library/dis.rst:468 msgid "" "human readable name for the base operation if operation is specialized; " "otherwise equal to :data:`opname`" msgstr "" -#: ../../library/dis.rst:431 +#: ../../library/dis.rst:474 msgid "numeric argument to operation (if any), otherwise ``None``" msgstr "" -#: ../../library/dis.rst:435 +#: ../../library/dis.rst:478 msgid "alias for :data:`arg`" msgstr ":data:`arg` 的別名。" -#: ../../library/dis.rst:439 +#: ../../library/dis.rst:482 msgid "resolved arg value (if any), otherwise ``None``" msgstr "" -#: ../../library/dis.rst:444 +#: ../../library/dis.rst:487 msgid "" "human readable description of operation argument (if any), otherwise an " "empty string." msgstr "" -#: ../../library/dis.rst:450 +#: ../../library/dis.rst:493 msgid "start index of operation within bytecode sequence" msgstr "" -#: ../../library/dis.rst:455 +#: ../../library/dis.rst:498 msgid "" "start index of operation within bytecode sequence, including prefixed " "``EXTENDED_ARG`` operations if present; otherwise equal to :data:`offset`" msgstr "" -#: ../../library/dis.rst:461 +#: ../../library/dis.rst:504 msgid "start index of the cache entries following the operation" msgstr "" -#: ../../library/dis.rst:466 +#: ../../library/dis.rst:509 msgid "end index of the cache entries following the operation" msgstr "" -#: ../../library/dis.rst:471 +#: ../../library/dis.rst:514 msgid "``True`` if this opcode starts a source line, otherwise ``False``" msgstr "" -#: ../../library/dis.rst:476 +#: ../../library/dis.rst:519 msgid "" "source line number associated with this opcode (if any), otherwise ``None``" msgstr "" -#: ../../library/dis.rst:481 +#: ../../library/dis.rst:524 msgid "``True`` if other code jumps to here, otherwise ``False``" msgstr "" -#: ../../library/dis.rst:486 +#: ../../library/dis.rst:529 msgid "" "bytecode index of the jump target if this is a jump operation, otherwise " "``None``" msgstr "" -#: ../../library/dis.rst:492 +#: ../../library/dis.rst:535 msgid "" ":class:`dis.Positions` object holding the start and end locations that are " "covered by this instruction." msgstr "" -#: ../../library/dis.rst:497 +#: ../../library/dis.rst:540 msgid "" "Information about the cache entries of this instruction, as triplets of the " "form ``(name, size, data)``, where the ``name`` and ``size`` describe the " @@ -607,73 +644,84 @@ msgid "" "``None`` if the instruction does not have caches." msgstr "" -#: ../../library/dis.rst:507 +#: ../../library/dis.rst:550 msgid "Field ``positions`` is added." msgstr "" -#: ../../library/dis.rst:511 +#: ../../library/dis.rst:554 msgid "Changed field ``starts_line``." msgstr "" -#: ../../library/dis.rst:513 +#: ../../library/dis.rst:556 msgid "" "Added fields ``start_offset``, ``cache_offset``, ``end_offset``, " "``baseopname``, ``baseopcode``, ``jump_target``, ``oparg``, ``line_number`` " "and ``cache_info``." msgstr "" -#: ../../library/dis.rst:520 +#: ../../library/dis.rst:563 msgid "" "In case the information is not available, some fields might be ``None``." msgstr "" -#: ../../library/dis.rst:530 +#: ../../library/dis.rst:573 msgid "" "The Python compiler currently generates the following bytecode instructions." msgstr "" -#: ../../library/dis.rst:533 +#: ../../library/dis.rst:576 msgid "**General instructions**" msgstr "**一般指令**" -#: ../../library/dis.rst:535 +#: ../../library/dis.rst:578 msgid "" "In the following, We will refer to the interpreter stack as ``STACK`` and " "describe operations on it as if it was a Python list. The top of the stack " "corresponds to ``STACK[-1]`` in this language." msgstr "" -#: ../../library/dis.rst:541 +#: ../../library/dis.rst:584 msgid "" "Do nothing code. Used as a placeholder by the bytecode optimizer, and to " "generate line tracing events." msgstr "" -#: ../../library/dis.rst:547 +#: ../../library/dis.rst:590 +msgid "" +"Do nothing code. Used by the interpreter to record :monitoring-event:" +"`BRANCH_LEFT` and :monitoring-event:`BRANCH_RIGHT` events for :mod:`sys." +"monitoring`." +msgstr "" + +#: ../../library/dis.rst:599 +msgid "Removes the iterator from the top of the stack." +msgstr "" + +#: ../../library/dis.rst:606 msgid "Removes the top-of-stack item::" msgstr "" -#: ../../library/dis.rst:549 +#: ../../library/dis.rst:608 msgid "STACK.pop()" msgstr "STACK.pop()" -#: ../../library/dis.rst:554 +#: ../../library/dis.rst:613 msgid "" "Removes the top-of-stack item. Equivalent to ``POP_TOP``. Used to clean up " "at the end of loops, hence the name." msgstr "" -#: ../../library/dis.rst:563 +#: ../../library/dis.rst:622 msgid "Implements ``del STACK[-2]``. Used to clean up when a generator exits." msgstr "" -#: ../../library/dis.rst:571 +#: ../../library/dis.rst:630 msgid "" "Push the i-th item to the top of the stack without removing it from its " "original location::" msgstr "" -#: ../../library/dis.rst:574 +#: ../../library/dis.rst:633 msgid "" "assert i > 0\n" "STACK.append(STACK[-i])" @@ -681,15 +729,15 @@ msgstr "" "assert i > 0\n" "STACK.append(STACK[-i])" -#: ../../library/dis.rst:582 +#: ../../library/dis.rst:641 msgid "Swap the top of the stack with the i-th element::" msgstr "" -#: ../../library/dis.rst:584 +#: ../../library/dis.rst:643 msgid "STACK[-i], STACK[-1] = STACK[-1], STACK[-i]" msgstr "STACK[-i], STACK[-1] = STACK[-1], STACK[-i]" -#: ../../library/dis.rst:591 +#: ../../library/dis.rst:650 msgid "" "Rather than being an actual instruction, this opcode is used to mark extra " "space for the interpreter to cache useful data directly in the bytecode " @@ -697,86 +745,86 @@ msgid "" "viewed with ``show_caches=True``." msgstr "" -#: ../../library/dis.rst:596 +#: ../../library/dis.rst:655 msgid "" "Logically, this space is part of the preceding instruction. Many opcodes " "expect to be followed by an exact number of caches, and will instruct the " "interpreter to skip over them at runtime." msgstr "" -#: ../../library/dis.rst:600 +#: ../../library/dis.rst:659 msgid "" "Populated caches can look like arbitrary instructions, so great care should " "be taken when reading or modifying raw, adaptive bytecode containing " "quickened data." msgstr "" -#: ../../library/dis.rst:607 +#: ../../library/dis.rst:666 msgid "**Unary operations**" msgstr "" -#: ../../library/dis.rst:609 +#: ../../library/dis.rst:668 msgid "" "Unary operations take the top of the stack, apply the operation, and push " "the result back on the stack." msgstr "" -#: ../../library/dis.rst:615 +#: ../../library/dis.rst:674 msgid "Implements ``STACK[-1] = -STACK[-1]``." msgstr "實作 ``STACK[-1] = -STACK[-1]``。" -#: ../../library/dis.rst:620 +#: ../../library/dis.rst:679 msgid "Implements ``STACK[-1] = not STACK[-1]``." msgstr "實作 ``STACK[-1] = not STACK[-1]``。" -#: ../../library/dis.rst:622 ../../library/dis.rst:1318 -#: ../../library/dis.rst:1334 +#: ../../library/dis.rst:681 ../../library/dis.rst:1383 +#: ../../library/dis.rst:1399 msgid "This instruction now requires an exact :class:`bool` operand." msgstr "" -#: ../../library/dis.rst:628 +#: ../../library/dis.rst:687 msgid "Implements ``STACK[-1] = ~STACK[-1]``." msgstr "實作 ``STACK[-1] = ~STACK[-1]``。" -#: ../../library/dis.rst:633 +#: ../../library/dis.rst:692 msgid "Implements ``STACK[-1] = iter(STACK[-1])``." msgstr "實作 ``STACK[-1] = iter(STACK[-1])``。" -#: ../../library/dis.rst:638 +#: ../../library/dis.rst:697 msgid "" "If ``STACK[-1]`` is a :term:`generator iterator` or :term:`coroutine` object " "it is left as is. Otherwise, implements ``STACK[-1] = iter(STACK[-1])``." msgstr "" -#: ../../library/dis.rst:646 +#: ../../library/dis.rst:705 msgid "Implements ``STACK[-1] = bool(STACK[-1])``." msgstr "" -#: ../../library/dis.rst:651 +#: ../../library/dis.rst:710 msgid "**Binary and in-place operations**" msgstr "" -#: ../../library/dis.rst:653 +#: ../../library/dis.rst:712 msgid "" "Binary operations remove the top two items from the stack (``STACK[-1]`` and " "``STACK[-2]``). They perform the operation, then put the result back on the " "stack." msgstr "" -#: ../../library/dis.rst:656 +#: ../../library/dis.rst:715 msgid "" "In-place operations are like binary operations, but the operation is done in-" "place when ``STACK[-2]`` supports it, and the resulting ``STACK[-1]`` may be " "(but does not have to be) the original ``STACK[-2]``." msgstr "" -#: ../../library/dis.rst:663 +#: ../../library/dis.rst:722 msgid "" "Implements the binary and in-place operators (depending on the value of " "*op*)::" msgstr "" -#: ../../library/dis.rst:666 +#: ../../library/dis.rst:725 msgid "" "rhs = STACK.pop()\n" "lhs = STACK.pop()\n" @@ -786,27 +834,22 @@ msgstr "" "lhs = STACK.pop()\n" "STACK.append(lhs op rhs)" -#: ../../library/dis.rst:675 ../../library/dis.rst:684 -#: ../../library/dis.rst:694 ../../library/dis.rst:702 -#: ../../library/dis.rst:714 ../../library/dis.rst:802 -#: ../../library/dis.rst:812 ../../library/dis.rst:822 -#: ../../library/dis.rst:1046 ../../library/dis.rst:1057 -#: ../../library/dis.rst:1161 ../../library/dis.rst:1173 -#: ../../library/dis.rst:1185 -msgid "Implements::" -msgstr "" - -#: ../../library/dis.rst:677 +#: ../../library/dis.rst:730 msgid "" -"key = STACK.pop()\n" -"container = STACK.pop()\n" -"STACK.append(container[key])" +"With oparg :``NB_SUBSCR``, implements binary subscript (replaces opcode " +"``BINARY_SUBSCR``)" msgstr "" -"key = STACK.pop()\n" -"container = STACK.pop()\n" -"STACK.append(container[key])" -#: ../../library/dis.rst:686 +#: ../../library/dis.rst:736 ../../library/dis.rst:746 +#: ../../library/dis.rst:754 ../../library/dis.rst:766 +#: ../../library/dis.rst:844 ../../library/dis.rst:854 +#: ../../library/dis.rst:864 ../../library/dis.rst:1070 +#: ../../library/dis.rst:1081 ../../library/dis.rst:1226 +#: ../../library/dis.rst:1238 ../../library/dis.rst:1250 +msgid "Implements::" +msgstr "實作了: ::" + +#: ../../library/dis.rst:738 msgid "" "key = STACK.pop()\n" "container = STACK.pop()\n" @@ -818,7 +861,7 @@ msgstr "" "value = STACK.pop()\n" "container[key] = value" -#: ../../library/dis.rst:696 +#: ../../library/dis.rst:748 msgid "" "key = STACK.pop()\n" "container = STACK.pop()\n" @@ -828,7 +871,7 @@ msgstr "" "container = STACK.pop()\n" "del container[key]" -#: ../../library/dis.rst:704 +#: ../../library/dis.rst:756 msgid "" "end = STACK.pop()\n" "start = STACK.pop()\n" @@ -840,7 +883,7 @@ msgstr "" "container = STACK.pop()\n" "STACK.append(container[start:end])" -#: ../../library/dis.rst:716 +#: ../../library/dis.rst:768 msgid "" "end = STACK.pop()\n" "start = STACK.pop()\n" @@ -854,11 +897,11 @@ msgstr "" "values = STACK.pop()\n" "container[start:end] = value" -#: ../../library/dis.rst:725 +#: ../../library/dis.rst:777 msgid "**Coroutine opcodes**" msgstr "" -#: ../../library/dis.rst:729 +#: ../../library/dis.rst:781 msgid "" "Implements ``STACK[-1] = get_awaitable(STACK[-1])``, where " "``get_awaitable(o)`` returns ``o`` if ``o`` is a coroutine object or a " @@ -866,39 +909,39 @@ msgid "" "resolves ``o.__await__``." msgstr "" -#: ../../library/dis.rst:734 +#: ../../library/dis.rst:786 msgid "" "If the ``where`` operand is nonzero, it indicates where the instruction " "occurs:" msgstr "" -#: ../../library/dis.rst:737 +#: ../../library/dis.rst:789 msgid "``1``: After a call to ``__aenter__``" msgstr "" -#: ../../library/dis.rst:738 +#: ../../library/dis.rst:790 msgid "``2``: After a call to ``__aexit__``" msgstr "" -#: ../../library/dis.rst:742 +#: ../../library/dis.rst:794 msgid "Previously, this instruction did not have an oparg." msgstr "" -#: ../../library/dis.rst:748 +#: ../../library/dis.rst:800 msgid "Implements ``STACK[-1] = STACK[-1].__aiter__()``." msgstr "" -#: ../../library/dis.rst:751 +#: ../../library/dis.rst:803 msgid "Returning awaitable objects from ``__aiter__`` is no longer supported." msgstr "" -#: ../../library/dis.rst:758 +#: ../../library/dis.rst:810 msgid "" "Implement ``STACK.append(get_awaitable(STACK[-1].__anext__()))`` to the " "stack. See ``GET_AWAITABLE`` for details about ``get_awaitable``." msgstr "" -#: ../../library/dis.rst:766 +#: ../../library/dis.rst:818 msgid "" "Terminates an :keyword:`async for` loop. Handles an exception raised when " "awaiting a next item. The stack contains the async iterable in ``STACK[-2]`` " @@ -906,35 +949,25 @@ msgid "" "is not :exc:`StopAsyncIteration`, it is re-raised." msgstr "" -#: ../../library/dis.rst:773 ../../library/dis.rst:881 -#: ../../library/dis.rst:892 +#: ../../library/dis.rst:825 ../../library/dis.rst:916 +#: ../../library/dis.rst:927 msgid "" "Exception representation on the stack now consist of one, not three, items." msgstr "" -#: ../../library/dis.rst:779 -msgid "" -"Handles an exception raised during a :meth:`~generator.throw` " -"or :meth:`~generator.close` call through the current frame. If " -"``STACK[-1]`` is an instance of :exc:`StopIteration`, pop three values from " -"the stack and push its ``value`` member. Otherwise, re-raise ``STACK[-1]``." -msgstr "" - -#: ../../library/dis.rst:789 +#: ../../library/dis.rst:831 msgid "" -"Resolves ``__aenter__`` and ``__aexit__`` from ``STACK[-1]``. Pushes " -"``__aexit__`` and result of ``__aenter__()`` to the stack::" +"Handles an exception raised during a :meth:`~generator.throw` or :meth:" +"`~generator.close` call through the current frame. If ``STACK[-1]`` is an " +"instance of :exc:`StopIteration`, pop three values from the stack and push " +"its ``value`` member. Otherwise, re-raise ``STACK[-1]``." msgstr "" -#: ../../library/dis.rst:792 -msgid "STACK.extend((__aexit__, __aenter__())" -msgstr "STACK.extend((__aexit__, __aenter__())" - -#: ../../library/dis.rst:798 +#: ../../library/dis.rst:840 msgid "**Miscellaneous opcodes**" msgstr "" -#: ../../library/dis.rst:804 +#: ../../library/dis.rst:846 msgid "" "item = STACK.pop()\n" "set.add(STACK[-i], item)" @@ -942,11 +975,11 @@ msgstr "" "item = STACK.pop()\n" "set.add(STACK[-i], item)" -#: ../../library/dis.rst:807 +#: ../../library/dis.rst:849 msgid "Used to implement set comprehensions." msgstr "" -#: ../../library/dis.rst:814 +#: ../../library/dis.rst:856 msgid "" "item = STACK.pop()\n" "list.append(STACK[-i], item)" @@ -954,11 +987,11 @@ msgstr "" "item = STACK.pop()\n" "list.append(STACK[-i], item)" -#: ../../library/dis.rst:817 +#: ../../library/dis.rst:859 msgid "Used to implement list comprehensions." msgstr "" -#: ../../library/dis.rst:824 +#: ../../library/dis.rst:866 msgid "" "value = STACK.pop()\n" "key = STACK.pop()\n" @@ -968,53 +1001,49 @@ msgstr "" "key = STACK.pop()\n" "dict.__setitem__(STACK[-i], key, value)" -#: ../../library/dis.rst:828 +#: ../../library/dis.rst:870 msgid "Used to implement dict comprehensions." msgstr "" -#: ../../library/dis.rst:831 +#: ../../library/dis.rst:873 msgid "" "Map value is ``STACK[-1]`` and map key is ``STACK[-2]``. Before, those were " "reversed." msgstr "" -#: ../../library/dis.rst:835 +#: ../../library/dis.rst:877 msgid "" -"For all of the :opcode:`SET_ADD`, :opcode:`LIST_APPEND` " -"and :opcode:`MAP_ADD` instructions, while the added value or key/value pair " -"is popped off, the container object remains on the stack so that it is " -"available for further iterations of the loop." +"For all of the :opcode:`SET_ADD`, :opcode:`LIST_APPEND` and :opcode:" +"`MAP_ADD` instructions, while the added value or key/value pair is popped " +"off, the container object remains on the stack so that it is available for " +"further iterations of the loop." msgstr "" -#: ../../library/dis.rst:843 +#: ../../library/dis.rst:885 msgid "Returns with ``STACK[-1]`` to the caller of the function." msgstr "" -#: ../../library/dis.rst:848 -msgid "Returns with ``co_consts[consti]`` to the caller of the function." -msgstr "" - -#: ../../library/dis.rst:855 +#: ../../library/dis.rst:890 msgid "Yields ``STACK.pop()`` from a :term:`generator`." msgstr "" -#: ../../library/dis.rst:857 +#: ../../library/dis.rst:892 msgid "oparg set to be the stack depth." msgstr "" -#: ../../library/dis.rst:860 +#: ../../library/dis.rst:895 msgid "" "oparg set to be the exception block depth, for efficient closing of " "generators." msgstr "" -#: ../../library/dis.rst:863 +#: ../../library/dis.rst:898 msgid "" "oparg is ``1`` if this instruction is part of a yield-from or await, and " "``0`` otherwise." msgstr "" -#: ../../library/dis.rst:869 +#: ../../library/dis.rst:904 msgid "" "Checks whether ``__annotations__`` is defined in ``locals()``, if not it is " "set up to an empty ``dict``. This opcode is only emitted if a class or " @@ -1022,39 +1051,39 @@ msgid "" "statically." msgstr "" -#: ../../library/dis.rst:879 +#: ../../library/dis.rst:914 msgid "" "Pops a value from the stack, which is used to restore the exception state." msgstr "" -#: ../../library/dis.rst:886 +#: ../../library/dis.rst:921 msgid "" "Re-raises the exception currently on top of the stack. If oparg is non-zero, " -"pops an additional value from the stack which is used to " -"set :attr:`~frame.f_lasti` of the current frame." +"pops an additional value from the stack which is used to set :attr:`~frame." +"f_lasti` of the current frame." msgstr "" -#: ../../library/dis.rst:897 +#: ../../library/dis.rst:932 msgid "" "Pops a value from the stack. Pushes the current exception to the top of the " "stack. Pushes the value originally popped back to the stack. Used in " "exception handlers." msgstr "" -#: ../../library/dis.rst:905 +#: ../../library/dis.rst:940 msgid "" "Performs exception matching for ``except``. Tests whether the ``STACK[-2]`` " "is an exception matching ``STACK[-1]``. Pops ``STACK[-1]`` and pushes the " "boolean result of the test." msgstr "" -#: ../../library/dis.rst:913 +#: ../../library/dis.rst:948 msgid "" "Performs exception matching for ``except*``. Applies ``split(STACK[-1])`` on " "the exception group representing ``STACK[-2]``." msgstr "" -#: ../../library/dis.rst:916 +#: ../../library/dis.rst:951 msgid "" "In case of a match, pops two items from the stack and pushes the non-" "matching subgroup (``None`` in case of full match) followed by the matching " @@ -1062,7 +1091,7 @@ msgid "" "``None``." msgstr "" -#: ../../library/dis.rst:925 +#: ../../library/dis.rst:960 msgid "" "Calls the function in position 4 on the stack with arguments (type, val, tb) " "representing the exception at the top of the stack. Used to implement the " @@ -1070,40 +1099,32 @@ msgid "" "occurred in a :keyword:`with` statement." msgstr "" -#: ../../library/dis.rst:932 +#: ../../library/dis.rst:967 msgid "" "The ``__exit__`` function is in position 4 of the stack rather than 7. " "Exception representation on the stack now consist of one, not three, items." msgstr "" -#: ../../library/dis.rst:939 +#: ../../library/dis.rst:974 msgid "" -"Pushes :exc:`AssertionError` onto the stack. Used by the :keyword:`assert` " -"statement." +"Pushes a common constant onto the stack. The interpreter contains a " +"hardcoded list of constants supported by this instruction. Used by the :" +"keyword:`assert` statement to load :exc:`AssertionError`." msgstr "" -#: ../../library/dis.rst:947 +#: ../../library/dis.rst:983 msgid "" "Pushes :func:`!builtins.__build_class__` onto the stack. It is later called " "to construct a class." msgstr "" -#: ../../library/dis.rst:953 -msgid "" -"This opcode performs several operations before a with block starts. First, " -"it loads :meth:`~object.__exit__` from the context manager and pushes it " -"onto the stack for later use by :opcode:`WITH_EXCEPT_START`. " -"Then, :meth:`~object.__enter__` is called. Finally, the result of calling " -"the ``__enter__()`` method is pushed onto the stack." -msgstr "" - -#: ../../library/dis.rst:964 +#: ../../library/dis.rst:988 msgid "" "Perform ``STACK.append(len(STACK[-1]))``. Used in :keyword:`match` " "statements where comparison with structure of pattern is needed." msgstr "" -#: ../../library/dis.rst:972 +#: ../../library/dis.rst:996 msgid "" "If ``STACK[-1]`` is an instance of :class:`collections.abc.Mapping` (or, " "more technically: if it has the :c:macro:`Py_TPFLAGS_MAPPING` flag set in " @@ -1111,7 +1132,7 @@ msgid "" "Otherwise, push ``False``." msgstr "" -#: ../../library/dis.rst:982 +#: ../../library/dis.rst:1006 msgid "" "If ``STACK[-1]`` is an instance of :class:`collections.abc.Sequence` and is " "*not* an instance of :class:`str`/:class:`bytes`/:class:`bytearray` (or, " @@ -1120,42 +1141,40 @@ msgid "" "Otherwise, push ``False``." msgstr "" -#: ../../library/dis.rst:992 +#: ../../library/dis.rst:1016 msgid "" "``STACK[-1]`` is a tuple of mapping keys, and ``STACK[-2]`` is the match " -"subject. If ``STACK[-2]`` contains all of the keys in ``STACK[-1]``, push " -"a :class:`tuple` containing the corresponding values. Otherwise, push " -"``None``." +"subject. If ``STACK[-2]`` contains all of the keys in ``STACK[-1]``, push a :" +"class:`tuple` containing the corresponding values. Otherwise, push ``None``." msgstr "" -#: ../../library/dis.rst:998 ../../library/dis.rst:1684 +#: ../../library/dis.rst:1022 ../../library/dis.rst:1768 msgid "" "Previously, this instruction also pushed a boolean value indicating success " "(``True``) or failure (``False``)." msgstr "" -#: ../../library/dis.rst:1005 +#: ../../library/dis.rst:1029 msgid "" "Implements ``name = STACK.pop()``. *namei* is the index of *name* in the " "attribute :attr:`~codeobject.co_names` of the :ref:`code object `. The compiler tries to use :opcode:`STORE_FAST` " -"or :opcode:`STORE_GLOBAL` if possible." +"objects>`. The compiler tries to use :opcode:`STORE_FAST` or :opcode:" +"`STORE_GLOBAL` if possible." msgstr "" -#: ../../library/dis.rst:1012 +#: ../../library/dis.rst:1036 msgid "" -"Implements ``del name``, where *namei* is the index " -"into :attr:`~codeobject.co_names` attribute of the :ref:`code object `." +"Implements ``del name``, where *namei* is the index into :attr:`~codeobject." +"co_names` attribute of the :ref:`code object `." msgstr "" -#: ../../library/dis.rst:1018 +#: ../../library/dis.rst:1042 msgid "" "Unpacks ``STACK[-1]`` into *count* individual values, which are put onto the " "stack right-to-left. Require there to be exactly *count* values.::" msgstr "" -#: ../../library/dis.rst:1021 +#: ../../library/dis.rst:1045 msgid "" "assert(len(STACK[-1]) == count)\n" "STACK.extend(STACK.pop()[:-count-1:-1])" @@ -1163,7 +1182,7 @@ msgstr "" "assert(len(STACK[-1]) == count)\n" "STACK.extend(STACK.pop()[:-count-1:-1])" -#: ../../library/dis.rst:1027 +#: ../../library/dis.rst:1051 msgid "" "Implements assignment with a starred target: Unpacks an iterable in " "``STACK[-1]`` into individual values, where the total number of values can " @@ -1171,11 +1190,11 @@ msgid "" "will be a list of all leftover items." msgstr "" -#: ../../library/dis.rst:1032 +#: ../../library/dis.rst:1056 msgid "The number of values before and after the list value is limited to 255." msgstr "" -#: ../../library/dis.rst:1034 +#: ../../library/dis.rst:1058 msgid "" "The number of values before the list value is encoded in the argument of the " "opcode. The number of values after the list if any is encoded using an " @@ -1184,13 +1203,13 @@ msgid "" "list value, the high byte of *counts* the number of values after it." msgstr "" -#: ../../library/dis.rst:1040 +#: ../../library/dis.rst:1064 msgid "" "The extracted values are put onto the stack right-to-left, i.e. ``a, *b, c = " "d`` will be stored after execution as ``STACK.extend((a, b, c))``." msgstr "" -#: ../../library/dis.rst:1048 +#: ../../library/dis.rst:1072 msgid "" "obj = STACK.pop()\n" "value = STACK.pop()\n" @@ -1200,13 +1219,13 @@ msgstr "" "value = STACK.pop()\n" "obj.name = value" -#: ../../library/dis.rst:1052 +#: ../../library/dis.rst:1076 msgid "" -"where *namei* is the index of name in :attr:`~codeobject.co_names` of " -"the :ref:`code object `." +"where *namei* is the index of name in :attr:`~codeobject.co_names` of the :" +"ref:`code object `." msgstr "" -#: ../../library/dis.rst:1059 +#: ../../library/dis.rst:1083 msgid "" "obj = STACK.pop()\n" "del obj.name" @@ -1214,38 +1233,43 @@ msgstr "" "obj = STACK.pop()\n" "del obj.name" -#: ../../library/dis.rst:1062 +#: ../../library/dis.rst:1086 msgid "" -"where *namei* is the index of name into :attr:`~codeobject.co_names` of " -"the :ref:`code object `." +"where *namei* is the index of name into :attr:`~codeobject.co_names` of the :" +"ref:`code object `." msgstr "" -#: ../../library/dis.rst:1068 +#: ../../library/dis.rst:1092 msgid "Works as :opcode:`STORE_NAME`, but stores the name as a global." msgstr "" -#: ../../library/dis.rst:1073 +#: ../../library/dis.rst:1097 msgid "Works as :opcode:`DELETE_NAME`, but deletes a global name." msgstr "" -#: ../../library/dis.rst:1078 +#: ../../library/dis.rst:1102 msgid "Pushes ``co_consts[consti]`` onto the stack." msgstr "" -#: ../../library/dis.rst:1083 +#: ../../library/dis.rst:1107 +msgid "" +"Pushes the integer ``i`` onto the stack. ``i`` must be in ``range(256)``" +msgstr "" + +#: ../../library/dis.rst:1115 msgid "" "Pushes the value associated with ``co_names[namei]`` onto the stack. The " "name is looked up within the locals, then the globals, then the builtins." msgstr "" -#: ../../library/dis.rst:1089 +#: ../../library/dis.rst:1121 msgid "" "Pushes a reference to the locals dictionary onto the stack. This is used to " -"prepare namespace dictionaries for :opcode:`LOAD_FROM_DICT_OR_DEREF` " -"and :opcode:`LOAD_FROM_DICT_OR_GLOBALS`." +"prepare namespace dictionaries for :opcode:`LOAD_FROM_DICT_OR_DEREF` and :" +"opcode:`LOAD_FROM_DICT_OR_GLOBALS`." msgstr "" -#: ../../library/dis.rst:1098 +#: ../../library/dis.rst:1130 msgid "" "Pops a mapping off the stack and looks up the value for ``co_names[namei]``. " "If the name is not found there, looks it up in the globals and then the " @@ -1254,13 +1278,78 @@ msgid "" "bodies." msgstr "" -#: ../../library/dis.rst:1109 +#: ../../library/dis.rst:1141 +msgid "" +"Constructs a new :class:`~string.templatelib.Template` instance from a tuple " +"of strings and a tuple of interpolations and pushes the resulting object " +"onto the stack::" +msgstr "" + +#: ../../library/dis.rst:1145 +msgid "" +"interpolations = STACK.pop()\n" +"strings = STACK.pop()\n" +"STACK.append(_build_template(strings, interpolations))" +msgstr "" +"interpolations = STACK.pop()\n" +"strings = STACK.pop()\n" +"STACK.append(_build_template(strings, interpolations))" + +#: ../../library/dis.rst:1154 +msgid "" +"Constructs a new :class:`~string.templatelib.Interpolation` instance from a " +"value and its source expression and pushes the resulting object onto the " +"stack." +msgstr "" + +#: ../../library/dis.rst:1158 +msgid "" +"If no conversion or format specification is present, ``format`` is set to " +"``2``." +msgstr "" + +#: ../../library/dis.rst:1161 +msgid "" +"If the low bit of ``format`` is set, it indicates that the interpolation " +"contains a format specification." +msgstr "" + +#: ../../library/dis.rst:1164 +msgid "" +"If ``format >> 2`` is non-zero, it indicates that the interpolation contains " +"a conversion. The value of ``format >> 2`` is the conversion type (``0`` for " +"no conversion, ``1`` for ``!s``, ``2`` for ``!r``, and ``3`` for ``!a``)::" +msgstr "" + +#: ../../library/dis.rst:1169 +msgid "" +"conversion = format >> 2\n" +"if format & 1:\n" +" format_spec = STACK.pop()\n" +"else:\n" +" format_spec = None\n" +"expression = STACK.pop()\n" +"value = STACK.pop()\n" +"STACK.append(_build_interpolation(value, expression, conversion, " +"format_spec))" +msgstr "" +"conversion = format >> 2\n" +"if format & 1:\n" +" format_spec = STACK.pop()\n" +"else:\n" +" format_spec = None\n" +"expression = STACK.pop()\n" +"value = STACK.pop()\n" +"STACK.append(_build_interpolation(value, expression, conversion, " +"format_spec))" + +#: ../../library/dis.rst:1183 msgid "" "Creates a tuple consuming *count* items from the stack, and pushes the " "resulting tuple onto the stack::" msgstr "" -#: ../../library/dis.rst:1112 +#: ../../library/dis.rst:1186 msgid "" "if count == 0:\n" " value = ()\n" @@ -1278,41 +1367,34 @@ msgstr "" "\n" "STACK.append(value)" -#: ../../library/dis.rst:1123 +#: ../../library/dis.rst:1197 msgid "Works as :opcode:`BUILD_TUPLE`, but creates a list." msgstr "" -#: ../../library/dis.rst:1128 +#: ../../library/dis.rst:1202 msgid "Works as :opcode:`BUILD_TUPLE`, but creates a set." msgstr "" -#: ../../library/dis.rst:1133 +#: ../../library/dis.rst:1207 msgid "" "Pushes a new dictionary object onto the stack. Pops ``2 * count`` items so " "that the dictionary holds *count* entries: ``{..., STACK[-4]: STACK[-3], " "STACK[-2]: STACK[-1]}``." msgstr "" -#: ../../library/dis.rst:1137 +#: ../../library/dis.rst:1211 msgid "" "The dictionary is created from stack items instead of creating an empty " "dictionary pre-sized to hold *count* items." msgstr "" -#: ../../library/dis.rst:1144 -msgid "" -"The version of :opcode:`BUILD_MAP` specialized for constant keys. Pops the " -"top element on the stack which contains a tuple of keys, then starting from " -"``STACK[-2]``, pops *count* values to form values in the built dictionary." -msgstr "" - -#: ../../library/dis.rst:1153 +#: ../../library/dis.rst:1218 msgid "" "Concatenates *count* strings from the stack and pushes the resulting string " "onto the stack." msgstr "" -#: ../../library/dis.rst:1163 +#: ../../library/dis.rst:1228 msgid "" "seq = STACK.pop()\n" "list.extend(STACK[-i], seq)" @@ -1320,11 +1402,11 @@ msgstr "" "seq = STACK.pop()\n" "list.extend(STACK[-i], seq)" -#: ../../library/dis.rst:1166 +#: ../../library/dis.rst:1231 msgid "Used to build lists." msgstr "" -#: ../../library/dis.rst:1175 +#: ../../library/dis.rst:1240 msgid "" "seq = STACK.pop()\n" "set.update(STACK[-i], seq)" @@ -1332,11 +1414,11 @@ msgstr "" "seq = STACK.pop()\n" "set.update(STACK[-i], seq)" -#: ../../library/dis.rst:1178 +#: ../../library/dis.rst:1243 msgid "Used to build sets." msgstr "" -#: ../../library/dis.rst:1187 +#: ../../library/dis.rst:1252 msgid "" "map = STACK.pop()\n" "dict.update(STACK[-i], map)" @@ -1344,21 +1426,21 @@ msgstr "" "map = STACK.pop()\n" "dict.update(STACK[-i], map)" -#: ../../library/dis.rst:1190 +#: ../../library/dis.rst:1255 msgid "Used to build dicts." msgstr "" -#: ../../library/dis.rst:1197 +#: ../../library/dis.rst:1262 msgid "Like :opcode:`DICT_UPDATE` but raises an exception for duplicate keys." msgstr "" -#: ../../library/dis.rst:1204 +#: ../../library/dis.rst:1269 msgid "" "If the low bit of ``namei`` is not set, this replaces ``STACK[-1]`` with " "``getattr(STACK[-1], co_names[namei>>1])``." msgstr "" -#: ../../library/dis.rst:1207 +#: ../../library/dis.rst:1272 msgid "" "If the low bit of ``namei`` is set, this will attempt to load a method named " "``co_names[namei>>1]`` from the ``STACK[-1]`` object. ``STACK[-1]`` is " @@ -1370,140 +1452,140 @@ msgid "" "pushed." msgstr "" -#: ../../library/dis.rst:1216 +#: ../../library/dis.rst:1281 msgid "" "If the low bit of ``namei`` is set, then a ``NULL`` or ``self`` is pushed to " "the stack before the attribute or unbound method respectively." msgstr "" -#: ../../library/dis.rst:1223 +#: ../../library/dis.rst:1288 msgid "" "This opcode implements :func:`super`, both in its zero-argument and two-" "argument forms (e.g. ``super().method()``, ``super().attr`` and ``super(cls, " "self).method()``, ``super(cls, self).attr``)." msgstr "" -#: ../../library/dis.rst:1227 +#: ../../library/dis.rst:1292 msgid "It pops three values from the stack (from top of stack down):" msgstr "" -#: ../../library/dis.rst:1229 +#: ../../library/dis.rst:1294 msgid "``self``: the first argument to the current method" msgstr "" -#: ../../library/dis.rst:1230 +#: ../../library/dis.rst:1295 msgid "``cls``: the class within which the current method was defined" msgstr "" -#: ../../library/dis.rst:1231 +#: ../../library/dis.rst:1296 msgid "the global ``super``" msgstr "" -#: ../../library/dis.rst:1233 +#: ../../library/dis.rst:1298 msgid "" "With respect to its argument, it works similarly to :opcode:`LOAD_ATTR`, " "except that ``namei`` is shifted left by 2 bits instead of 1." msgstr "" -#: ../../library/dis.rst:1236 +#: ../../library/dis.rst:1301 msgid "" -"The low bit of ``namei`` signals to attempt a method load, as " -"with :opcode:`LOAD_ATTR`, which results in pushing ``NULL`` and the loaded " -"method. When it is unset a single value is pushed to the stack." +"The low bit of ``namei`` signals to attempt a method load, as with :opcode:" +"`LOAD_ATTR`, which results in pushing ``NULL`` and the loaded method. When " +"it is unset a single value is pushed to the stack." msgstr "" -#: ../../library/dis.rst:1240 +#: ../../library/dis.rst:1305 msgid "" "The second-low bit of ``namei``, if set, means that this was a two-argument " "call to :func:`super` (unset means zero-argument)." msgstr "" -#: ../../library/dis.rst:1248 +#: ../../library/dis.rst:1313 msgid "" "Performs a Boolean operation. The operation name can be found in " "``cmp_op[opname >> 5]``. If the fifth-lowest bit of ``opname`` is set " "(``opname & 16``), the result should be coerced to ``bool``." msgstr "" -#: ../../library/dis.rst:1252 +#: ../../library/dis.rst:1317 msgid "" -"The fifth-lowest bit of the oparg now indicates a forced conversion " -"to :class:`bool`." +"The fifth-lowest bit of the oparg now indicates a forced conversion to :" +"class:`bool`." msgstr "" -#: ../../library/dis.rst:1259 +#: ../../library/dis.rst:1324 msgid "Performs ``is`` comparison, or ``is not`` if ``invert`` is 1." msgstr "" -#: ../../library/dis.rst:1266 +#: ../../library/dis.rst:1331 msgid "Performs ``in`` comparison, or ``not in`` if ``invert`` is 1." msgstr "" -#: ../../library/dis.rst:1273 +#: ../../library/dis.rst:1338 msgid "" "Imports the module ``co_names[namei]``. ``STACK[-1]`` and ``STACK[-2]`` are " -"popped and provide the *fromlist* and *level* arguments " -"of :func:`__import__`. The module object is pushed onto the stack. The " -"current namespace is not affected: for a proper import statement, a " -"subsequent :opcode:`STORE_FAST` instruction modifies the namespace." +"popped and provide the *fromlist* and *level* arguments of :func:" +"`__import__`. The module object is pushed onto the stack. The current " +"namespace is not affected: for a proper import statement, a subsequent :" +"opcode:`STORE_FAST` instruction modifies the namespace." msgstr "" -#: ../../library/dis.rst:1281 +#: ../../library/dis.rst:1346 msgid "" "Loads the attribute ``co_names[namei]`` from the module found in " "``STACK[-1]``. The resulting object is pushed onto the stack, to be " "subsequently stored by a :opcode:`STORE_FAST` instruction." msgstr "" -#: ../../library/dis.rst:1288 +#: ../../library/dis.rst:1353 msgid "Increments bytecode counter by *delta*." msgstr "" -#: ../../library/dis.rst:1293 +#: ../../library/dis.rst:1358 msgid "Decrements bytecode counter by *delta*. Checks for interrupts." msgstr "" -#: ../../library/dis.rst:1300 +#: ../../library/dis.rst:1365 msgid "Decrements bytecode counter by *delta*. Does not check for interrupts." msgstr "" -#: ../../library/dis.rst:1307 +#: ../../library/dis.rst:1372 msgid "" "If ``STACK[-1]`` is true, increments the bytecode counter by *delta*. " "``STACK[-1]`` is popped." msgstr "" -#: ../../library/dis.rst:1310 ../../library/dis.rst:1326 +#: ../../library/dis.rst:1375 ../../library/dis.rst:1391 msgid "" "The oparg is now a relative delta rather than an absolute target. This " "opcode is a pseudo-instruction, replaced in final bytecode by the directed " "versions (forward/backward)." msgstr "" -#: ../../library/dis.rst:1315 ../../library/dis.rst:1331 -#: ../../library/dis.rst:1344 ../../library/dis.rst:1355 +#: ../../library/dis.rst:1380 ../../library/dis.rst:1396 +#: ../../library/dis.rst:1409 ../../library/dis.rst:1420 msgid "This is no longer a pseudo-instruction." msgstr "" -#: ../../library/dis.rst:1323 +#: ../../library/dis.rst:1388 msgid "" "If ``STACK[-1]`` is false, increments the bytecode counter by *delta*. " "``STACK[-1]`` is popped." msgstr "" -#: ../../library/dis.rst:1339 +#: ../../library/dis.rst:1404 msgid "" "If ``STACK[-1]`` is not ``None``, increments the bytecode counter by " "*delta*. ``STACK[-1]`` is popped." msgstr "" -#: ../../library/dis.rst:1350 +#: ../../library/dis.rst:1415 msgid "" "If ``STACK[-1]`` is ``None``, increments the bytecode counter by *delta*. " "``STACK[-1]`` is popped." msgstr "" -#: ../../library/dis.rst:1360 +#: ../../library/dis.rst:1425 msgid "" "``STACK[-1]`` is an :term:`iterator`. Call its :meth:`~iterator.__next__` " "method. If this yields a new value, push it on the stack (leaving the " @@ -1511,207 +1593,219 @@ msgid "" "code counter is incremented by *delta*." msgstr "" -#: ../../library/dis.rst:1365 +#: ../../library/dis.rst:1430 msgid "Up until 3.11 the iterator was popped when it was exhausted." msgstr "" -#: ../../library/dis.rst:1370 +#: ../../library/dis.rst:1435 msgid "Loads the global named ``co_names[namei>>1]`` onto the stack." msgstr "" -#: ../../library/dis.rst:1372 +#: ../../library/dis.rst:1437 msgid "" "If the low bit of ``namei`` is set, then a ``NULL`` is pushed to the stack " "before the global variable." msgstr "" -#: ../../library/dis.rst:1378 +#: ../../library/dis.rst:1443 msgid "" "Pushes a reference to the local ``co_varnames[var_num]`` onto the stack." msgstr "" -#: ../../library/dis.rst:1380 +#: ../../library/dis.rst:1445 msgid "" "This opcode is now only used in situations where the local variable is " "guaranteed to be initialized. It cannot raise :exc:`UnboundLocalError`." msgstr "" -#: ../../library/dis.rst:1386 +#: ../../library/dis.rst:1451 +msgid "" +"Pushes a borrowed reference to the local ``co_varnames[var_num]`` onto the " +"stack." +msgstr "" + +#: ../../library/dis.rst:1458 msgid "" "Pushes references to ``co_varnames[var_nums >> 4]`` and " "``co_varnames[var_nums & 15]`` onto the stack." msgstr "" -#: ../../library/dis.rst:1393 +#: ../../library/dis.rst:1466 +msgid "" +"Pushes borrowed references to ``co_varnames[var_nums >> 4]`` and " +"``co_varnames[var_nums & 15]`` onto the stack." +msgstr "" + +#: ../../library/dis.rst:1473 msgid "" "Pushes a reference to the local ``co_varnames[var_num]`` onto the stack, " "raising an :exc:`UnboundLocalError` if the local variable has not been " "initialized." msgstr "" -#: ../../library/dis.rst:1401 +#: ../../library/dis.rst:1481 msgid "" "Pushes a reference to the local ``co_varnames[var_num]`` onto the stack (or " "pushes ``NULL`` onto the stack if the local variable has not been " "initialized) and sets ``co_varnames[var_num]`` to ``NULL``." msgstr "" -#: ../../library/dis.rst:1409 +#: ../../library/dis.rst:1489 msgid "Stores ``STACK.pop()`` into the local ``co_varnames[var_num]``." msgstr "" -#: ../../library/dis.rst:1413 +#: ../../library/dis.rst:1493 msgid "" "Stores ``STACK[-1]`` into ``co_varnames[var_nums >> 4]`` and ``STACK[-2]`` " "into ``co_varnames[var_nums & 15]``." msgstr "" -#: ../../library/dis.rst:1420 +#: ../../library/dis.rst:1500 msgid "" "Stores ``STACK.pop()`` into the local ``co_varnames[var_nums >> 4]`` and " "pushes a reference to the local ``co_varnames[var_nums & 15]`` onto the " "stack." msgstr "" -#: ../../library/dis.rst:1428 +#: ../../library/dis.rst:1508 msgid "Deletes local ``co_varnames[var_num]``." msgstr "" -#: ../../library/dis.rst:1433 +#: ../../library/dis.rst:1513 msgid "" "Creates a new cell in slot ``i``. If that slot is nonempty then that value " "is stored into the new cell." msgstr "" -#: ../../library/dis.rst:1441 +#: ../../library/dis.rst:1521 msgid "" "Loads the cell contained in slot ``i`` of the \"fast locals\" storage. " "Pushes a reference to the object the cell contains on the stack." msgstr "" -#: ../../library/dis.rst:1444 ../../library/dis.rst:1466 -#: ../../library/dis.rst:1477 +#: ../../library/dis.rst:1524 ../../library/dis.rst:1546 +#: ../../library/dis.rst:1557 msgid "" "``i`` is no longer offset by the length of :attr:`~codeobject.co_varnames`." msgstr "" -#: ../../library/dis.rst:1450 +#: ../../library/dis.rst:1530 msgid "" "Pops a mapping off the stack and looks up the name associated with slot " "``i`` of the \"fast locals\" storage in this mapping. If the name is not " -"found there, loads it from the cell contained in slot ``i``, similar " -"to :opcode:`LOAD_DEREF`. This is used for loading :term:`closure variables " +"found there, loads it from the cell contained in slot ``i``, similar to :" +"opcode:`LOAD_DEREF`. This is used for loading :term:`closure variables " "` in class bodies (which previously used :opcode:`!" "LOAD_CLASSDEREF`) and in :ref:`annotation scopes ` within " "class bodies." msgstr "" -#: ../../library/dis.rst:1463 +#: ../../library/dis.rst:1543 msgid "" "Stores ``STACK.pop()`` into the cell contained in slot ``i`` of the \"fast " "locals\" storage." msgstr "" -#: ../../library/dis.rst:1472 +#: ../../library/dis.rst:1552 msgid "" "Empties the cell contained in slot ``i`` of the \"fast locals\" storage. " "Used by the :keyword:`del` statement." msgstr "" -#: ../../library/dis.rst:1483 +#: ../../library/dis.rst:1563 msgid "" "Copies the ``n`` :term:`free (closure) variables ` from " "the closure into the frame. Removes the need for special code on the " "caller's side when calling closures." msgstr "" -#: ../../library/dis.rst:1492 +#: ../../library/dis.rst:1572 msgid "" "Raises an exception using one of the 3 forms of the ``raise`` statement, " "depending on the value of *argc*:" msgstr "" -#: ../../library/dis.rst:1495 +#: ../../library/dis.rst:1575 msgid "0: ``raise`` (re-raise previous exception)" msgstr "" -#: ../../library/dis.rst:1496 +#: ../../library/dis.rst:1576 msgid "" "1: ``raise STACK[-1]`` (raise exception instance or type at ``STACK[-1]``)" msgstr "" -#: ../../library/dis.rst:1497 +#: ../../library/dis.rst:1577 msgid "" "2: ``raise STACK[-2] from STACK[-1]`` (raise exception instance or type at " "``STACK[-2]`` with ``__cause__`` set to ``STACK[-1]``)" msgstr "" -#: ../../library/dis.rst:1503 +#: ../../library/dis.rst:1583 msgid "" "Calls a callable object with the number of arguments specified by ``argc``. " "On the stack are (in ascending order):" msgstr "" -#: ../../library/dis.rst:1506 ../../library/dis.rst:1530 +#: ../../library/dis.rst:1586 ../../library/dis.rst:1610 msgid "The callable" msgstr "" -#: ../../library/dis.rst:1507 ../../library/dis.rst:1531 +#: ../../library/dis.rst:1587 ../../library/dis.rst:1611 msgid "``self`` or ``NULL``" msgstr "``self`` 或 ``NULL``" -#: ../../library/dis.rst:1508 ../../library/dis.rst:1532 +#: ../../library/dis.rst:1588 ../../library/dis.rst:1612 msgid "The remaining positional arguments" msgstr "剩餘的位置引數" -#: ../../library/dis.rst:1510 +#: ../../library/dis.rst:1590 msgid "``argc`` is the total of the positional arguments, excluding ``self``." msgstr "" -#: ../../library/dis.rst:1512 +#: ../../library/dis.rst:1592 msgid "" "``CALL`` pops all arguments and the callable object off the stack, calls the " "callable object with those arguments, and pushes the return value returned " "by the callable object." msgstr "" -#: ../../library/dis.rst:1518 +#: ../../library/dis.rst:1598 msgid "The callable now always appears at the same position on the stack." msgstr "" -#: ../../library/dis.rst:1521 +#: ../../library/dis.rst:1601 msgid "Calls with keyword arguments are now handled by :opcode:`CALL_KW`." msgstr "" -#: ../../library/dis.rst:1527 +#: ../../library/dis.rst:1607 msgid "" "Calls a callable object with the number of arguments specified by ``argc``, " "including one or more named arguments. On the stack are (in ascending order):" msgstr "" -#: ../../library/dis.rst:1533 +#: ../../library/dis.rst:1613 msgid "The named arguments" msgstr "" -#: ../../library/dis.rst:1534 +#: ../../library/dis.rst:1614 msgid "A :class:`tuple` of keyword argument names" msgstr "" -#: ../../library/dis.rst:1536 +#: ../../library/dis.rst:1616 msgid "" "``argc`` is the total of the positional and named arguments, excluding " "``self``. The length of the tuple of keyword argument names is the number of " "named arguments." msgstr "" -#: ../../library/dis.rst:1539 +#: ../../library/dis.rst:1619 msgid "" "``CALL_KW`` pops all arguments, the keyword names, and the callable object " "off the stack, calls the callable object with those arguments, and pushes " "the return value returned by the callable object." msgstr "" -#: ../../library/dis.rst:1548 +#: ../../library/dis.rst:1628 msgid "" "Calls a callable object with variable set of positional and keyword " "arguments. If the lowest bit of *flags* is set, the top of the stack " @@ -1723,33 +1817,33 @@ msgid "" "arguments, and pushes the return value returned by the callable object." msgstr "" -#: ../../library/dis.rst:1563 +#: ../../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_METHOD` for non-method calls." msgstr "" -#: ../../library/dis.rst:1572 +#: ../../library/dis.rst:1652 msgid "" "Pushes a new function object on the stack built from the code object at " "``STACK[-1]``." msgstr "" -#: ../../library/dis.rst:1574 +#: ../../library/dis.rst:1654 msgid "Flag value ``0x04`` is a tuple of strings instead of dictionary" msgstr "" -#: ../../library/dis.rst:1577 +#: ../../library/dis.rst:1657 msgid "Qualified name at ``STACK[-1]`` was removed." msgstr "" -#: ../../library/dis.rst:1580 +#: ../../library/dis.rst:1660 msgid "" "Extra function attributes on the stack, signaled by oparg flags, were " "removed. They now use :opcode:`SET_FUNCTION_ATTRIBUTE`." msgstr "" -#: ../../library/dis.rst:1587 +#: ../../library/dis.rst:1667 msgid "" "Sets an attribute on a function object. Expects the function at " "``STACK[-1]`` and the attribute value to set at ``STACK[-2]``; consumes both " @@ -1757,42 +1851,51 @@ msgid "" "attribute to set:" msgstr "" -#: ../../library/dis.rst:1591 +#: ../../library/dis.rst:1671 msgid "" "``0x01`` a tuple of default values for positional-only and positional-or-" "keyword parameters in positional order" msgstr "" -#: ../../library/dis.rst:1593 +#: ../../library/dis.rst:1673 msgid "``0x02`` a dictionary of keyword-only parameters' default values" msgstr "" -#: ../../library/dis.rst:1594 +#: ../../library/dis.rst:1674 msgid "``0x04`` a tuple of strings containing parameters' annotations" msgstr "" -#: ../../library/dis.rst:1595 +#: ../../library/dis.rst:1675 msgid "``0x08`` a tuple containing cells for free variables, making a closure" msgstr "" -#: ../../library/dis.rst:1604 +#: ../../library/dis.rst:1676 +msgid "``0x10`` the :term:`annotate function` for the function object" +msgstr "" + +#: ../../library/dis.rst:1680 +msgid "" +"Added ``0x10`` to indicate the annotate function for the function object." +msgstr "" + +#: ../../library/dis.rst:1688 msgid "" "Pushes a slice object on the stack. *argc* must be 2 or 3. If it is 2, " "implements::" msgstr "" -#: ../../library/dis.rst:1606 +#: ../../library/dis.rst:1690 msgid "" "end = STACK.pop()\n" "start = STACK.pop()\n" "STACK.append(slice(start, end))" msgstr "" -#: ../../library/dis.rst:1610 +#: ../../library/dis.rst:1694 msgid "if it is 3, implements::" msgstr "" -#: ../../library/dis.rst:1612 +#: ../../library/dis.rst:1696 msgid "" "step = STACK.pop()\n" "end = STACK.pop()\n" @@ -1804,11 +1907,11 @@ msgstr "" "start = STACK.pop()\n" "STACK.append(slice(start, end, step))" -#: ../../library/dis.rst:1617 +#: ../../library/dis.rst:1701 msgid "See the :func:`slice` built-in function for more information." msgstr "" -#: ../../library/dis.rst:1622 +#: ../../library/dis.rst:1706 msgid "" "Prefixes any opcode which has an argument too big to fit into the default " "one byte. *ext* holds an additional byte which act as higher bits in the " @@ -1816,11 +1919,11 @@ msgid "" "allowed, forming an argument from two-byte to four-byte." msgstr "" -#: ../../library/dis.rst:1630 +#: ../../library/dis.rst:1714 msgid "Convert value to a string, depending on ``oparg``::" msgstr "" -#: ../../library/dis.rst:1632 +#: ../../library/dis.rst:1716 msgid "" "value = STACK.pop()\n" "result = func(value)\n" @@ -1830,28 +1933,28 @@ msgstr "" "result = func(value)\n" "STACK.append(result)" -#: ../../library/dis.rst:1636 +#: ../../library/dis.rst:1720 msgid "``oparg == 1``: call :func:`str` on *value*" msgstr "" -#: ../../library/dis.rst:1637 +#: ../../library/dis.rst:1721 msgid "``oparg == 2``: call :func:`repr` on *value*" msgstr "" -#: ../../library/dis.rst:1638 +#: ../../library/dis.rst:1722 msgid "``oparg == 3``: call :func:`ascii` on *value*" msgstr "" -#: ../../library/dis.rst:1640 ../../library/dis.rst:1653 -#: ../../library/dis.rst:1666 +#: ../../library/dis.rst:1724 ../../library/dis.rst:1737 +#: ../../library/dis.rst:1750 msgid "Used for implementing formatted string literals (f-strings)." msgstr "" -#: ../../library/dis.rst:1647 +#: ../../library/dis.rst:1731 msgid "Formats the value on top of stack::" msgstr "" -#: ../../library/dis.rst:1649 +#: ../../library/dis.rst:1733 msgid "" "value = STACK.pop()\n" "result = value.__format__(\"\")\n" @@ -1861,11 +1964,11 @@ msgstr "" "result = value.__format__(\"\")\n" "STACK.append(result)" -#: ../../library/dis.rst:1659 +#: ../../library/dis.rst:1743 msgid "Formats the given value with the given format spec::" msgstr "" -#: ../../library/dis.rst:1661 +#: ../../library/dis.rst:1745 msgid "" "spec = STACK.pop()\n" "value = STACK.pop()\n" @@ -1877,14 +1980,14 @@ msgstr "" "result = value.__format__(spec)\n" "STACK.append(result)" -#: ../../library/dis.rst:1673 +#: ../../library/dis.rst:1757 msgid "" "``STACK[-1]`` is a tuple of keyword attribute names, ``STACK[-2]`` is the " "class being matched against, and ``STACK[-3]`` is the match subject. " "*count* is the number of positional sub-patterns." msgstr "" -#: ../../library/dis.rst:1677 +#: ../../library/dis.rst:1761 msgid "" "Pop ``STACK[-1]``, ``STACK[-2]``, and ``STACK[-3]``. If ``STACK[-3]`` is an " "instance of ``STACK[-2]`` and has the positional and keyword attributes " @@ -1892,219 +1995,219 @@ msgid "" "Otherwise, push ``None``." msgstr "" -#: ../../library/dis.rst:1691 +#: ../../library/dis.rst:1775 msgid "A no-op. Performs internal tracing, debugging and optimization checks." msgstr "" -#: ../../library/dis.rst:1693 +#: ../../library/dis.rst:1777 msgid "" -"The ``context`` oparand consists of two parts. The lowest two bits indicate " +"The ``context`` operand consists of two parts. The lowest two bits indicate " "where the ``RESUME`` occurs:" msgstr "" -#: ../../library/dis.rst:1696 +#: ../../library/dis.rst:1780 msgid "" "``0`` The start of a function, which is neither a generator, coroutine nor " "an async generator" msgstr "" -#: ../../library/dis.rst:1698 +#: ../../library/dis.rst:1782 msgid "``1`` After a ``yield`` expression" msgstr "" -#: ../../library/dis.rst:1699 +#: ../../library/dis.rst:1783 msgid "``2`` After a ``yield from`` expression" msgstr "" -#: ../../library/dis.rst:1700 +#: ../../library/dis.rst:1784 msgid "``3`` After an ``await`` expression" msgstr "" -#: ../../library/dis.rst:1702 +#: ../../library/dis.rst:1786 msgid "" "The next bit is ``1`` if the RESUME is at except-depth ``1``, and ``0`` " "otherwise." msgstr "" -#: ../../library/dis.rst:1707 +#: ../../library/dis.rst:1791 msgid "The oparg value changed to include information about except-depth" msgstr "" -#: ../../library/dis.rst:1713 +#: ../../library/dis.rst:1797 msgid "" "Create a generator, coroutine, or async generator from the current frame. " "Used as first opcode of in code object for the above mentioned callables. " "Clear the current frame and return the newly created generator." msgstr "" -#: ../../library/dis.rst:1722 +#: ../../library/dis.rst:1806 msgid "" "Equivalent to ``STACK[-1] = STACK[-2].send(STACK[-1])``. Used in ``yield " "from`` and ``await`` statements." msgstr "" -#: ../../library/dis.rst:1725 +#: ../../library/dis.rst:1809 msgid "" "If the call raises :exc:`StopIteration`, pop the top value from the stack, " "push the exception's ``value`` attribute, and increment the bytecode counter " "by *delta*." msgstr "" -#: ../../library/dis.rst:1734 +#: ../../library/dis.rst:1818 msgid "" "This is not really an opcode. It identifies the dividing line between " "opcodes in the range [0,255] which don't use their argument and those that " "do (``< HAVE_ARGUMENT`` and ``>= HAVE_ARGUMENT``, respectively)." msgstr "" -#: ../../library/dis.rst:1738 +#: ../../library/dis.rst:1822 msgid "" "If your application uses pseudo instructions or specialized instructions, " "use the :data:`hasarg` collection instead." msgstr "" -#: ../../library/dis.rst:1741 +#: ../../library/dis.rst:1825 msgid "" "Now every instruction has an argument, but opcodes ``< HAVE_ARGUMENT`` " "ignore it. Before, only opcodes ``>= HAVE_ARGUMENT`` had an argument." msgstr "" -#: ../../library/dis.rst:1745 +#: ../../library/dis.rst:1829 msgid "" "Pseudo instructions were added to the :mod:`dis` module, and for them it is " "not true that comparison with ``HAVE_ARGUMENT`` indicates whether they use " "their arg." msgstr "" -#: ../../library/dis.rst:1750 +#: ../../library/dis.rst:1834 msgid "Use :data:`hasarg` instead." msgstr "" -#: ../../library/dis.rst:1755 +#: ../../library/dis.rst:1839 msgid "" "Calls an intrinsic function with one argument. Passes ``STACK[-1]`` as the " "argument and sets ``STACK[-1]`` to the result. Used to implement " "functionality that is not performance critical." msgstr "" -#: ../../library/dis.rst:1759 ../../library/dis.rst:1813 +#: ../../library/dis.rst:1843 ../../library/dis.rst:1897 msgid "The operand determines which intrinsic function is called:" msgstr "" -#: ../../library/dis.rst:1762 ../../library/dis.rst:1816 +#: ../../library/dis.rst:1846 ../../library/dis.rst:1900 msgid "Operand" msgstr "運算元" -#: ../../library/dis.rst:1762 ../../library/dis.rst:1816 +#: ../../library/dis.rst:1846 ../../library/dis.rst:1900 msgid "Description" msgstr "描述" -#: ../../library/dis.rst:1764 +#: ../../library/dis.rst:1848 msgid "``INTRINSIC_1_INVALID``" msgstr "``INTRINSIC_1_INVALID``" -#: ../../library/dis.rst:1764 ../../library/dis.rst:1818 +#: ../../library/dis.rst:1848 ../../library/dis.rst:1902 msgid "Not valid" msgstr "" -#: ../../library/dis.rst:1766 +#: ../../library/dis.rst:1850 msgid "``INTRINSIC_PRINT``" msgstr "``INTRINSIC_PRINT``" -#: ../../library/dis.rst:1766 +#: ../../library/dis.rst:1850 msgid "Prints the argument to standard out. Used in the REPL." msgstr "" -#: ../../library/dis.rst:1769 +#: ../../library/dis.rst:1853 msgid "``INTRINSIC_IMPORT_STAR``" msgstr "``INTRINSIC_IMPORT_STAR``" -#: ../../library/dis.rst:1769 +#: ../../library/dis.rst:1853 msgid "Performs ``import *`` for the named module." msgstr "" -#: ../../library/dis.rst:1772 +#: ../../library/dis.rst:1856 msgid "``INTRINSIC_STOPITERATION_ERROR``" msgstr "``INTRINSIC_STOPITERATION_ERROR``" -#: ../../library/dis.rst:1772 +#: ../../library/dis.rst:1856 msgid "Extracts the return value from a ``StopIteration`` exception." msgstr "" -#: ../../library/dis.rst:1775 +#: ../../library/dis.rst:1859 msgid "``INTRINSIC_ASYNC_GEN_WRAP``" msgstr "``INTRINSIC_ASYNC_GEN_WRAP``" -#: ../../library/dis.rst:1775 +#: ../../library/dis.rst:1859 msgid "Wraps an async generator value" msgstr "" -#: ../../library/dis.rst:1777 +#: ../../library/dis.rst:1861 msgid "``INTRINSIC_UNARY_POSITIVE``" msgstr "``INTRINSIC_UNARY_POSITIVE``" -#: ../../library/dis.rst:1777 +#: ../../library/dis.rst:1861 msgid "Performs the unary ``+`` operation" msgstr "" -#: ../../library/dis.rst:1780 +#: ../../library/dis.rst:1864 msgid "``INTRINSIC_LIST_TO_TUPLE``" msgstr "``INTRINSIC_LIST_TO_TUPLE``" -#: ../../library/dis.rst:1780 +#: ../../library/dis.rst:1864 msgid "Converts a list to a tuple" msgstr "" -#: ../../library/dis.rst:1782 +#: ../../library/dis.rst:1866 msgid "``INTRINSIC_TYPEVAR``" msgstr "``INTRINSIC_TYPEVAR``" -#: ../../library/dis.rst:1782 +#: ../../library/dis.rst:1866 msgid "Creates a :class:`typing.TypeVar`" msgstr "" -#: ../../library/dis.rst:1784 +#: ../../library/dis.rst:1868 msgid "``INTRINSIC_PARAMSPEC``" msgstr "``INTRINSIC_PARAMSPEC``" -#: ../../library/dis.rst:1784 +#: ../../library/dis.rst:1868 msgid "Creates a :class:`typing.ParamSpec`" msgstr "" -#: ../../library/dis.rst:1787 +#: ../../library/dis.rst:1871 msgid "``INTRINSIC_TYPEVARTUPLE``" msgstr "``INTRINSIC_TYPEVARTUPLE``" -#: ../../library/dis.rst:1787 +#: ../../library/dis.rst:1871 msgid "Creates a :class:`typing.TypeVarTuple`" msgstr "" -#: ../../library/dis.rst:1790 +#: ../../library/dis.rst:1874 msgid "``INTRINSIC_SUBSCRIPT_GENERIC``" msgstr "``INTRINSIC_SUBSCRIPT_GENERIC``" -#: ../../library/dis.rst:1790 +#: ../../library/dis.rst:1874 msgid "Returns :class:`typing.Generic` subscripted with the argument" msgstr "" -#: ../../library/dis.rst:1793 +#: ../../library/dis.rst:1877 msgid "``INTRINSIC_TYPEALIAS``" msgstr "``INTRINSIC_TYPEALIAS``" -#: ../../library/dis.rst:1793 +#: ../../library/dis.rst:1877 msgid "" "Creates a :class:`typing.TypeAliasType`; used in the :keyword:`type` " "statement. The argument is a tuple of the type alias's name, type " "parameters, and value." msgstr "" -#: ../../library/dis.rst:1805 +#: ../../library/dis.rst:1889 msgid "" "Calls an intrinsic function with two arguments. Used to implement " "functionality that is not performance critical::" msgstr "" -#: ../../library/dis.rst:1808 +#: ../../library/dis.rst:1892 msgid "" "arg2 = STACK.pop()\n" "arg1 = STACK.pop()\n" @@ -2116,61 +2219,69 @@ msgstr "" "result = intrinsic2(arg1, arg2)\n" "STACK.append(result)" -#: ../../library/dis.rst:1818 +#: ../../library/dis.rst:1902 msgid "``INTRINSIC_2_INVALID``" msgstr "``INTRINSIC_2_INVALID``" -#: ../../library/dis.rst:1820 +#: ../../library/dis.rst:1904 msgid "``INTRINSIC_PREP_RERAISE_STAR``" msgstr "``INTRINSIC_PREP_RERAISE_STAR``" -#: ../../library/dis.rst:1820 +#: ../../library/dis.rst:1904 msgid "Calculates the :exc:`ExceptionGroup` to raise from a ``try-except*``." msgstr "" -#: ../../library/dis.rst:1824 +#: ../../library/dis.rst:1908 msgid "``INTRINSIC_TYPEVAR_WITH_BOUND``" msgstr "``INTRINSIC_TYPEVAR_WITH_BOUND``" -#: ../../library/dis.rst:1824 +#: ../../library/dis.rst:1908 msgid "Creates a :class:`typing.TypeVar` with a bound." msgstr "" -#: ../../library/dis.rst:1827 +#: ../../library/dis.rst:1911 msgid "``INTRINSIC_TYPEVAR_WITH_CONSTRAINTS``" msgstr "``INTRINSIC_TYPEVAR_WITH_CONSTRAINTS``" -#: ../../library/dis.rst:1827 +#: ../../library/dis.rst:1911 msgid "Creates a :class:`typing.TypeVar` with constraints." msgstr "" -#: ../../library/dis.rst:1831 +#: ../../library/dis.rst:1915 msgid "``INTRINSIC_SET_FUNCTION_TYPE_PARAMS``" msgstr "``INTRINSIC_SET_FUNCTION_TYPE_PARAMS``" -#: ../../library/dis.rst:1831 +#: ../../library/dis.rst:1915 msgid "Sets the ``__type_params__`` attribute of a function." msgstr "" -#: ../../library/dis.rst:1838 +#: ../../library/dis.rst:1924 +msgid "" +"Performs special method lookup on ``STACK[-1]``. If ``type(STACK[-1])." +"__xxx__`` is a method, leave ``type(STACK[-1]).__xxx__; STACK[-1]`` on the " +"stack. If ``type(STACK[-1]).__xxx__`` is not a method, leave ``STACK[-1]." +"__xxx__; NULL`` on the stack." +msgstr "" + +#: ../../library/dis.rst:1933 msgid "**Pseudo-instructions**" msgstr "" -#: ../../library/dis.rst:1840 +#: ../../library/dis.rst:1935 msgid "" "These opcodes do not appear in Python bytecode. They are used by the " "compiler but are replaced by real opcodes or removed before bytecode is " "generated." msgstr "" -#: ../../library/dis.rst:1845 +#: ../../library/dis.rst:1940 msgid "" "Set up an exception handler for the following code block. If an exception " "occurs, the value stack level is restored to its current state and control " "is transferred to the exception handler at ``target``." msgstr "" -#: ../../library/dis.rst:1852 +#: ../../library/dis.rst:1947 msgid "" "Like ``SETUP_FINALLY``, but in case of an exception also pushes the last " "instruction (``lasti``) to the stack so that ``RERAISE`` can restore it. If " @@ -2179,92 +2290,96 @@ msgid "" "exception handler at ``target``." msgstr "" -#: ../../library/dis.rst:1861 +#: ../../library/dis.rst:1956 msgid "" "Like ``SETUP_CLEANUP``, but in case of an exception one more item is popped " "from the stack before control is transferred to the exception handler at " "``target``." msgstr "" -#: ../../library/dis.rst:1865 +#: ../../library/dis.rst:1960 msgid "" "This variant is used in :keyword:`with` and :keyword:`async with` " -"constructs, which push the return value of the context " -"manager's :meth:`~object.__enter__` or :meth:`~object.__aenter__` to the " -"stack." +"constructs, which push the return value of the context manager's :meth:" +"`~object.__enter__` or :meth:`~object.__aenter__` to the stack." msgstr "" -#: ../../library/dis.rst:1872 +#: ../../library/dis.rst:1967 msgid "" "Marks the end of the code block associated with the last ``SETUP_FINALLY``, " "``SETUP_CLEANUP`` or ``SETUP_WITH``." msgstr "" -#: ../../library/dis.rst:1878 +#: ../../library/dis.rst:1973 +msgid "" +"Works as :opcode:`LOAD_CONST`, but is more efficient for immortal objects." +msgstr "" + +#: ../../library/dis.rst:1979 msgid "" "Undirected relative jump instructions which are replaced by their directed " "(forward/backward) counterparts by the assembler." msgstr "" -#: ../../library/dis.rst:1883 +#: ../../library/dis.rst:1985 +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 msgid "" "Pushes a reference to the cell contained in slot ``i`` of the \"fast " "locals\" storage." msgstr "" -#: ../../library/dis.rst:1886 +#: ../../library/dis.rst:1993 msgid "" "Note that ``LOAD_CLOSURE`` is replaced with ``LOAD_FAST`` in the assembler." msgstr "" -#: ../../library/dis.rst:1888 +#: ../../library/dis.rst:1995 msgid "This opcode is now a pseudo-instruction." msgstr "" -#: ../../library/dis.rst:1894 -msgid "" -"Optimized unbound method lookup. Emitted as a ``LOAD_ATTR`` opcode with a " -"flag set in the arg." -msgstr "" - -#: ../../library/dis.rst:1901 +#: ../../library/dis.rst:2002 msgid "Opcode collections" msgstr "" -#: ../../library/dis.rst:1903 +#: ../../library/dis.rst:2004 msgid "" "These collections are provided for automatic introspection of bytecode " "instructions:" msgstr "" -#: ../../library/dis.rst:1906 +#: ../../library/dis.rst:2007 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:1913 +#: ../../library/dis.rst:2014 msgid "Sequence of operation names, indexable using the bytecode." msgstr "" -#: ../../library/dis.rst:1918 +#: ../../library/dis.rst:2019 msgid "Dictionary mapping operation names to bytecodes." msgstr "" -#: ../../library/dis.rst:1923 +#: ../../library/dis.rst:2024 msgid "Sequence of all compare operation names." msgstr "" -#: ../../library/dis.rst:1928 +#: ../../library/dis.rst:2029 msgid "Sequence of bytecodes that use their argument." msgstr "" -#: ../../library/dis.rst:1935 +#: ../../library/dis.rst:2036 msgid "Sequence of bytecodes that access a constant." msgstr "" -#: ../../library/dis.rst:1940 +#: ../../library/dis.rst:2041 msgid "" "Sequence of bytecodes that access a :term:`free (closure) variable `. 'free' in this context refers to names in the current scope that " @@ -2273,46 +2388,46 @@ msgid "" "scopes." msgstr "" -#: ../../library/dis.rst:1948 +#: ../../library/dis.rst:2049 msgid "Sequence of bytecodes that access an attribute by name." msgstr "" -#: ../../library/dis.rst:1953 +#: ../../library/dis.rst:2054 msgid "Sequence of bytecodes that have a jump target. All jumps are relative." msgstr "" -#: ../../library/dis.rst:1960 +#: ../../library/dis.rst:2061 msgid "Sequence of bytecodes that access a local variable." msgstr "" -#: ../../library/dis.rst:1965 +#: ../../library/dis.rst:2066 msgid "Sequence of bytecodes of Boolean operations." msgstr "" -#: ../../library/dis.rst:1969 +#: ../../library/dis.rst:2070 msgid "Sequence of bytecodes that set an exception handler." msgstr "" -#: ../../library/dis.rst:1976 +#: ../../library/dis.rst:2077 msgid "Sequence of bytecodes that have a relative jump target." msgstr "" -#: ../../library/dis.rst:1978 +#: ../../library/dis.rst:2079 msgid "All jumps are now relative. Use :data:`hasjump`." msgstr "" -#: ../../library/dis.rst:1984 +#: ../../library/dis.rst:2085 msgid "Sequence of bytecodes that have an absolute jump target." msgstr "" -#: ../../library/dis.rst:1986 +#: ../../library/dis.rst:2087 msgid "All jumps are now relative. This list is empty." msgstr "" -#: ../../library/dis.rst:1602 +#: ../../library/dis.rst:1686 msgid "built-in function" msgstr "built-in function(內建函式)" -#: ../../library/dis.rst:1602 +#: ../../library/dis.rst:1686 msgid "slice" msgstr "slice(切片)" diff --git a/library/distribution.po b/library/distribution.po index ef9d7dfdf89..ec4ebd2237d 100644 --- a/library/distribution.po +++ b/library/distribution.po @@ -1,12 +1,11 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Leon H., 2017 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2018-06-26 18:54+0800\n" "PO-Revision-Date: 2018-05-23 14:43+0000\n" diff --git a/library/distutils.po b/library/distutils.po index 5705c4cc8a3..c73c27804e9 100644 --- a/library/distutils.po +++ b/library/distutils.po @@ -1,10 +1,10 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # #, fuzzy msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-11-18 00:15+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" diff --git a/library/doctest.po b/library/doctest.po index 37c9b9bb189..4b4508a442e 100644 --- a/library/doctest.po +++ b/library/doctest.po @@ -1,12 +1,12 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-08-19 00:16+0000\n" +"POT-Creation-Date: 2025-09-08 15:25+0800\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-" @@ -199,24 +199,30 @@ msgstr "" #: ../../library/doctest.rst:133 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 " -"there are many examples of doctests in the standard Python test suite and " -"libraries. Especially useful examples can be found in the standard test " -"file :file:`Lib/test/test_doctest/test_doctest.py`." +"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 there are many examples of doctests in the standard Python test " +"suite and libraries. Especially useful examples can be found in the standard " +"test file :file:`Lib/test/test_doctest/test_doctest.py`." msgstr "" -#: ../../library/doctest.rst:143 +#: ../../library/doctest.rst:139 +msgid "" +"Output is colorized by default and can be :ref:`controlled using environment " +"variables `." +msgstr "" + +#: ../../library/doctest.rst:147 msgid "Simple Usage: Checking Examples in Docstrings" msgstr "" -#: ../../library/doctest.rst:145 +#: ../../library/doctest.rst:149 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:148 +#: ../../library/doctest.rst:152 msgid "" "if __name__ == \"__main__\":\n" " import doctest\n" @@ -226,21 +232,21 @@ msgstr "" " import doctest\n" " doctest.testmod()" -#: ../../library/doctest.rst:152 +#: ../../library/doctest.rst:156 msgid ":mod:`!doctest` then examines docstrings in module :mod:`!M`." msgstr "" -#: ../../library/doctest.rst:154 +#: ../../library/doctest.rst:158 msgid "" "Running the module as a script causes the examples in the docstrings to get " "executed and verified::" msgstr "" -#: ../../library/doctest.rst:157 +#: ../../library/doctest.rst:161 msgid "python M.py" msgstr "python M.py" -#: ../../library/doctest.rst:159 +#: ../../library/doctest.rst:163 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, " @@ -248,51 +254,51 @@ msgid "" "is the number of examples that failed." msgstr "" -#: ../../library/doctest.rst:164 +#: ../../library/doctest.rst:168 msgid "Run it with the ``-v`` switch instead::" msgstr "" -#: ../../library/doctest.rst:166 +#: ../../library/doctest.rst:170 msgid "python M.py -v" msgstr "python M.py -v" -#: ../../library/doctest.rst:168 +#: ../../library/doctest.rst:172 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:171 +#: ../../library/doctest.rst:175 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, :" -"data:`sys.argv` is not examined by :func:`testmod` (so passing ``-v`` or not " -"has no effect)." +"or prohibit it by passing ``verbose=False``. In either of those " +"cases, :data:`sys.argv` is not examined by :func:`testmod` (so passing ``-" +"v`` or not has no effect)." msgstr "" -#: ../../library/doctest.rst:176 +#: ../../library/doctest.rst:180 msgid "" "There is also a command line shortcut for running :func:`testmod`, see " "section :ref:`doctest-cli`." msgstr "" -#: ../../library/doctest.rst:179 +#: ../../library/doctest.rst:183 msgid "" "For more information on :func:`testmod`, see section :ref:`doctest-basic-" "api`." msgstr "" -#: ../../library/doctest.rst:185 +#: ../../library/doctest.rst:189 msgid "Simple Usage: Checking Examples in a Text File" msgstr "" -#: ../../library/doctest.rst:187 +#: ../../library/doctest.rst:191 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:190 +#: ../../library/doctest.rst:194 msgid "" "import doctest\n" "doctest.testfile(\"example.txt\")" @@ -300,7 +306,7 @@ msgstr "" "import doctest\n" "doctest.testfile(\"example.txt\")" -#: ../../library/doctest.rst:193 +#: ../../library/doctest.rst:197 msgid "" "That short script executes and verifies any interactive Python examples " "contained in the file :file:`example.txt`. The file content is treated as " @@ -308,7 +314,7 @@ msgid "" "Python program! For example, perhaps :file:`example.txt` contains this:" msgstr "" -#: ../../library/doctest.rst:198 +#: ../../library/doctest.rst:202 msgid "" "The ``example`` module\n" "======================\n" @@ -342,13 +348,13 @@ msgstr "" " >>> factorial(6)\n" " 120" -#: ../../library/doctest.rst:216 +#: ../../library/doctest.rst:220 msgid "" "Running ``doctest.testfile(\"example.txt\")`` then finds the error in this " "documentation::" msgstr "" -#: ../../library/doctest.rst:219 +#: ../../library/doctest.rst:223 msgid "" "File \"./example.txt\", line 14, in example.txt\n" "Failed example:\n" @@ -366,15 +372,15 @@ msgstr "" "Got:\n" " 720" -#: ../../library/doctest.rst:227 +#: ../../library/doctest.rst:231 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 " -"cause(s) of the failure(s) are printed to stdout, using the same format as :" -"func:`!testmod`." +"cause(s) of the failure(s) are printed to stdout, using the same format " +"as :func:`!testmod`." msgstr "" -#: ../../library/doctest.rst:232 +#: ../../library/doctest.rst:236 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 " @@ -382,79 +388,79 @@ msgid "" "locations." msgstr "" -#: ../../library/doctest.rst:236 +#: ../../library/doctest.rst:240 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:240 +#: ../../library/doctest.rst:244 msgid "" "There is also a command line shortcut for running :func:`testfile`, see " "section :ref:`doctest-cli`." msgstr "" -#: ../../library/doctest.rst:243 +#: ../../library/doctest.rst:247 msgid "" "For more information on :func:`testfile`, see section :ref:`doctest-basic-" "api`." msgstr "" -#: ../../library/doctest.rst:249 +#: ../../library/doctest.rst:253 msgid "Command-line Usage" msgstr "命令列用法" -#: ../../library/doctest.rst:251 +#: ../../library/doctest.rst:255 msgid "" "The :mod:`doctest` module can be invoked as a script from the command line:" msgstr "可以從命令列以腳本方式叫用 :mod:`doctest` 模組:" -#: ../../library/doctest.rst:253 +#: ../../library/doctest.rst:257 msgid "python -m doctest [-v] [-o OPTION] [-f] file [file ...]" msgstr "python -m doctest [-v] [-o OPTION] [-f] file [file ...]" -#: ../../library/doctest.rst:261 +#: ../../library/doctest.rst:265 msgid "" "Detailed report of all examples tried is printed to standard output, along " "with assorted summaries at the end::" msgstr "" -#: ../../library/doctest.rst:264 +#: ../../library/doctest.rst:268 msgid "python -m doctest -v example.py" msgstr "python -m doctest -v example.py" -#: ../../library/doctest.rst:266 +#: ../../library/doctest.rst:270 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." +"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:270 +#: ../../library/doctest.rst:274 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:273 +#: ../../library/doctest.rst:277 msgid "python -m doctest -v example.txt" msgstr "python -m doctest -v example.txt" -#: ../../library/doctest.rst:277 +#: ../../library/doctest.rst:281 msgid "" -"Option flags control various aspects of doctest's behavior, see section :ref:" -"`doctest-options`." +"Option flags control various aspects of doctest's behavior, see " +"section :ref:`doctest-options`." msgstr "" -#: ../../library/doctest.rst:284 +#: ../../library/doctest.rst:288 msgid "This is shorthand for ``-o FAIL_FAST``." msgstr "" -#: ../../library/doctest.rst:292 +#: ../../library/doctest.rst:296 msgid "How It Works" msgstr "運作方式" -#: ../../library/doctest.rst:294 +#: ../../library/doctest.rst:298 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 " @@ -464,34 +470,34 @@ msgid "" "see the following sections." msgstr "" -#: ../../library/doctest.rst:305 +#: ../../library/doctest.rst:309 msgid "Which Docstrings Are Examined?" msgstr "" -#: ../../library/doctest.rst:307 +#: ../../library/doctest.rst:311 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:317 +#: ../../library/doctest.rst:321 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 " "the docstring. Doctest looks for a module-level variable called ``__test__`` " "and uses it to locate other tests. If ``M.__test__`` exists, it must be a " "dict, and each entry maps a (string) name to a function object, class " -"object, or string. Function and class object docstrings found from ``M." -"__test__`` are searched, and strings are treated as if they were " -"docstrings. In output, a key ``K`` in ``M.__test__`` appears with name ``M." -"__test__.K``." +"object, or string. Function and class object docstrings found from " +"``M.__test__`` are searched, and strings are treated as if they were " +"docstrings. In output, a key ``K`` in ``M.__test__`` appears with name " +"``M.__test__.K``." msgstr "" -#: ../../library/doctest.rst:326 +#: ../../library/doctest.rst:330 msgid "For example, place this block of code at the top of :file:`example.py`:" msgstr "" -#: ../../library/doctest.rst:328 +#: ../../library/doctest.rst:332 msgid "" "__test__ = {\n" " 'numbers': \"\"\"\n" @@ -513,45 +519,45 @@ msgstr "" "\"\"\"\n" "}" -#: ../../library/doctest.rst:340 +#: ../../library/doctest.rst:344 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 " -"that the value can be mapped to a function, class object, or module; if so, :" -"mod:`!doctest` searches them recursively for docstrings, which are then " +"that the value can be mapped to a function, class object, or module; if " +"so, :mod:`!doctest` searches them recursively for docstrings, which are then " "scanned for tests." msgstr "" -#: ../../library/doctest.rst:346 +#: ../../library/doctest.rst:350 msgid "" "Any classes found are recursively searched similarly, to test docstrings in " "their contained methods and nested classes." msgstr "" -#: ../../library/doctest.rst:351 +#: ../../library/doctest.rst:355 msgid "" "``doctest`` can only automatically discover classes and functions that are " "defined at the module level or inside other classes." msgstr "" -#: ../../library/doctest.rst:354 +#: ../../library/doctest.rst:358 msgid "" "Since nested classes and functions only exist when an outer function is " "called, they cannot be discovered. Define them outside to make them visible." msgstr "" -#: ../../library/doctest.rst:360 +#: ../../library/doctest.rst:364 msgid "How are Docstring Examples Recognized?" msgstr "" -#: ../../library/doctest.rst:362 +#: ../../library/doctest.rst:366 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:367 +#: ../../library/doctest.rst:371 msgid "" ">>> # comments are ignored\n" ">>> x = 12\n" @@ -585,18 +591,18 @@ msgstr "" "NO!!!\n" ">>>" -#: ../../library/doctest.rst:387 +#: ../../library/doctest.rst:391 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:391 +#: ../../library/doctest.rst:395 msgid "The fine print:" msgstr "" -#: ../../library/doctest.rst:393 +#: ../../library/doctest.rst:397 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 " @@ -604,35 +610,35 @@ msgid "" "line is expected." msgstr "" -#: ../../library/doctest.rst:398 +#: ../../library/doctest.rst:402 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 " "hard tabs in the sample output *are* expanded, this means that if the code " -"output includes hard tabs, the only way the doctest can pass is if the :" -"const:`NORMALIZE_WHITESPACE` option or :ref:`directive ` " -"is in effect. Alternatively, the test can be rewritten to capture the output " -"and compare it to an expected value as part of the test. This handling of " -"tabs in the source was arrived at through trial and error, and has proven to " -"be the least error prone way of handling them. It is possible to use a " -"different algorithm for handling tabs by writing a custom :class:" -"`DocTestParser` class." +"output includes hard tabs, the only way the doctest can pass is if " +"the :const:`NORMALIZE_WHITESPACE` option or :ref:`directive ` is in effect. Alternatively, the test can be rewritten to " +"capture the output and compare it to an expected value as part of the test. " +"This handling of tabs in the source was arrived at through trial and error, " +"and has proven to be the least error prone way of handling them. It is " +"possible to use a different algorithm for handling tabs by writing a " +"custom :class:`DocTestParser` class." msgstr "" -#: ../../library/doctest.rst:410 +#: ../../library/doctest.rst:414 msgid "" "Output to stdout is captured, but not output to stderr (exception tracebacks " "are captured via a different means)." msgstr "" -#: ../../library/doctest.rst:413 +#: ../../library/doctest.rst:417 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:417 +#: ../../library/doctest.rst:421 msgid "" ">>> def f(x):\n" "... r'''Backslashes in a raw docstring: m\\n'''\n" @@ -641,7 +647,7 @@ msgid "" "Backslashes in a raw docstring: m\\n" msgstr "" -#: ../../library/doctest.rst:423 +#: ../../library/doctest.rst:427 msgid "" "Otherwise, the backslash will be interpreted as part of the string. For " "example, the ``\\n`` above would be interpreted as a newline character. " @@ -649,7 +655,7 @@ msgid "" "use a raw string)::" msgstr "" -#: ../../library/doctest.rst:427 +#: ../../library/doctest.rst:431 msgid "" ">>> def f(x):\n" "... '''Backslashes in a raw docstring: m\\\\n'''\n" @@ -658,11 +664,11 @@ msgid "" "Backslashes in a raw docstring: m\\n" msgstr "" -#: ../../library/doctest.rst:433 +#: ../../library/doctest.rst:437 msgid "The starting column doesn't matter::" msgstr "" -#: ../../library/doctest.rst:435 +#: ../../library/doctest.rst:439 msgid "" ">>> assert \"Easy!\"\n" " >>> import math\n" @@ -674,17 +680,17 @@ msgstr "" " >>> math.floor(1.9)\n" " 1" -#: ../../library/doctest.rst:440 +#: ../../library/doctest.rst:444 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:447 +#: ../../library/doctest.rst:451 msgid "What's the Execution Context?" msgstr "" -#: ../../library/doctest.rst:449 +#: ../../library/doctest.rst:453 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 " @@ -695,17 +701,17 @@ msgid "" "defined in other docstrings." msgstr "" -#: ../../library/doctest.rst:457 +#: ../../library/doctest.rst:461 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:464 +#: ../../library/doctest.rst:468 msgid "What About Exceptions?" msgstr "" -#: ../../library/doctest.rst:466 +#: ../../library/doctest.rst:470 msgid "" "No problem, provided that the traceback is the only output produced by the " "example: just paste in the traceback. [#]_ Since tracebacks contain details " @@ -714,11 +720,11 @@ msgid "" "it accepts." msgstr "" -#: ../../library/doctest.rst:472 +#: ../../library/doctest.rst:476 msgid "Simple example::" msgstr "簡單範例: ::" -#: ../../library/doctest.rst:474 +#: ../../library/doctest.rst:478 msgid "" ">>> [1, 2, 3].remove(42)\n" "Traceback (most recent call last):\n" @@ -730,20 +736,20 @@ msgstr "" " File \"\", line 1, in \n" "ValueError: list.remove(x): x not in list" -#: ../../library/doctest.rst:479 +#: ../../library/doctest.rst:483 msgid "" -"That doctest succeeds if :exc:`ValueError` is raised, with the ``list." -"remove(x): x not in list`` detail as shown." +"That doctest succeeds if :exc:`ValueError` is raised, with the " +"``list.remove(x): x not in list`` detail as shown." msgstr "" -#: ../../library/doctest.rst:482 +#: ../../library/doctest.rst:486 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:486 +#: ../../library/doctest.rst:490 msgid "" "Traceback (most recent call last):\n" "Traceback (innermost last):" @@ -751,14 +757,14 @@ msgstr "" "Traceback (most recent call last):\n" "Traceback (innermost last):" -#: ../../library/doctest.rst:489 +#: ../../library/doctest.rst:493 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:493 +#: ../../library/doctest.rst:497 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 " @@ -766,7 +772,7 @@ msgid "" "multi-line detail::" msgstr "" -#: ../../library/doctest.rst:498 +#: ../../library/doctest.rst:502 msgid "" ">>> raise ValueError('multi\\n line\\ndetail')\n" "Traceback (most recent call last):\n" @@ -782,20 +788,20 @@ msgstr "" " line\n" "detail" -#: ../../library/doctest.rst:505 +#: ../../library/doctest.rst:509 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:508 +#: ../../library/doctest.rst:512 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:511 +#: ../../library/doctest.rst:515 msgid "" ">>> raise ValueError('multi\\n line\\ndetail')\n" "Traceback (most recent call last):\n" @@ -811,20 +817,20 @@ msgstr "" " line\n" "detail" -#: ../../library/doctest.rst:518 +#: ../../library/doctest.rst:522 msgid "" "Note that tracebacks are treated very specially. In particular, in the " -"rewritten example, the use of ``...`` is independent of doctest's :const:" -"`ELLIPSIS` option. The ellipsis in that example could be left out, or could " -"just as well be three (or three hundred) commas or digits, or an indented " -"transcript of a Monty Python skit." +"rewritten example, the use of ``...`` is independent of " +"doctest's :const:`ELLIPSIS` option. The ellipsis in that example could be " +"left out, or could just as well be three (or three hundred) commas or " +"digits, or an indented transcript of a Monty Python skit." msgstr "" -#: ../../library/doctest.rst:524 +#: ../../library/doctest.rst:528 msgid "Some details you should read once, but won't need to remember:" msgstr "" -#: ../../library/doctest.rst:526 +#: ../../library/doctest.rst:530 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 " @@ -834,7 +840,7 @@ msgid "" "create real problems." msgstr "" -#: ../../library/doctest.rst:533 +#: ../../library/doctest.rst:537 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. " @@ -843,29 +849,29 @@ msgid "" "course this does the right thing for genuine tracebacks." msgstr "" -#: ../../library/doctest.rst:539 +#: ../../library/doctest.rst:543 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:543 +#: ../../library/doctest.rst:547 msgid "" -"The interactive shell omits the traceback header line for some :exc:" -"`SyntaxError`\\ s. But doctest uses the traceback header line to " +"The interactive shell omits the traceback header line for " +"some :exc:`SyntaxError`\\ s. But doctest uses the traceback header line to " "distinguish exceptions from non-exceptions. So in the rare case where you " "need to test a :exc:`!SyntaxError` that omits the traceback header, you will " "need to manually add the traceback header line to your test example." msgstr "" -#: ../../library/doctest.rst:551 +#: ../../library/doctest.rst:555 msgid "" "For some exceptions, Python displays the position of the error using ``^`` " "markers and tildes::" msgstr "" -#: ../../library/doctest.rst:554 +#: ../../library/doctest.rst:558 msgid "" ">>> 1 + None\n" " File \"\", line 1\n" @@ -879,7 +885,7 @@ msgstr "" " ~~^~~~~~\n" "TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'" -#: ../../library/doctest.rst:560 +#: ../../library/doctest.rst:564 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 " @@ -887,7 +893,7 @@ msgid "" "location::" msgstr "" -#: ../../library/doctest.rst:564 +#: ../../library/doctest.rst:568 msgid "" ">>> 1 + None\n" " File \"\", line 1\n" @@ -901,48 +907,49 @@ msgstr "" " ^~~~~~~~\n" "TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'" -#: ../../library/doctest.rst:575 +#: ../../library/doctest.rst:579 msgid "Option Flags" msgstr "可選旗標" -#: ../../library/doctest.rst:577 +#: ../../library/doctest.rst:581 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 :" -"ref:`bitwise ORed ` together and passed to various functions. The " -"names can also be used in :ref:`doctest directives `, " -"and may be passed to the doctest command line interface via the ``-o`` " -"option." +"Symbolic names for the flags are supplied as module constants, which can " +"be :ref:`bitwise ORed ` together and passed to various functions. " +"The names can also be used in :ref:`doctest directives `, and may be passed to the doctest command line interface via " +"the ``-o`` option." msgstr "" -#: ../../library/doctest.rst:583 +#: ../../library/doctest.rst:587 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:589 +#: ../../library/doctest.rst:593 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 " -"match, and similarly for ``0`` versus ``False``. When :const:" -"`DONT_ACCEPT_TRUE_FOR_1` is specified, neither substitution is allowed. The " -"default behavior caters to that Python changed the return type of many " -"functions from integer to boolean; doctests expecting \"little integer\" " -"output still work in these cases. This option will probably go away, but " -"not for several years." +"match, and similarly for ``0`` versus ``False``. " +"When :const:`DONT_ACCEPT_TRUE_FOR_1` is specified, neither substitution is " +"allowed. The default behavior caters to that Python changed the return type " +"of many functions from integer to boolean; doctests expecting \"little " +"integer\" output still work in these cases. This option will probably go " +"away, but not for several years." msgstr "" -#: ../../library/doctest.rst:601 +#: ../../library/doctest.rst:605 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 " "output. Because a genuinely blank line delimits the expected output, this " -"is the only way to communicate that a blank line is expected. When :const:" -"`DONT_ACCEPT_BLANKLINE` is specified, this substitution is not allowed." +"is the only way to communicate that a blank line is expected. " +"When :const:`DONT_ACCEPT_BLANKLINE` is specified, this substitution is not " +"allowed." msgstr "" -#: ../../library/doctest.rst:610 +#: ../../library/doctest.rst:614 msgid "" "When specified, all sequences of whitespace (blanks and newlines) are " "treated as equal. Any sequence of whitespace within the expected output " @@ -952,7 +959,7 @@ msgid "" "across multiple lines in your source." msgstr "" -#: ../../library/doctest.rst:621 +#: ../../library/doctest.rst:625 msgid "" "When specified, an ellipsis marker (``...``) in the expected output can " "match any substring in the actual output. This includes substrings that " @@ -961,24 +968,24 @@ msgid "" "matched too much!\" surprises that ``.*`` is prone to in regular expressions." msgstr "" -#: ../../library/doctest.rst:630 +#: ../../library/doctest.rst:634 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:634 +#: ../../library/doctest.rst:638 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:" -"`TypeError` is raised instead. It will also ignore any fully qualified name " -"included before the exception class, which can vary between implementations " -"and versions of Python and the code/libraries in use. Hence, all three of " -"these variations will work with the flag specified:" +"exception raised is ``ValueError: 3*14``, but will fail if, say, " +"a :exc:`TypeError` is raised instead. It will also ignore any fully " +"qualified name included before the exception class, which can vary between " +"implementations and versions of Python and the code/libraries in use. Hence, " +"all three of these variations will work with the flag specified:" msgstr "" -#: ../../library/doctest.rst:642 +#: ../../library/doctest.rst:646 msgid "" ">>> raise Exception('message')\n" "Traceback (most recent call last):\n" @@ -1004,20 +1011,20 @@ msgstr "" "Traceback (most recent call last):\n" "__main__.Exception: message" -#: ../../library/doctest.rst:656 +#: ../../library/doctest.rst:660 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:660 +#: ../../library/doctest.rst:664 msgid "" ":const:`IGNORE_EXCEPTION_DETAIL` now also ignores any information relating " "to the module containing the exception under test." msgstr "" -#: ../../library/doctest.rst:667 +#: ../../library/doctest.rst:671 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, " @@ -1026,32 +1033,32 @@ msgid "" "might depend on resources which would be unavailable to the test driver." msgstr "" -#: ../../library/doctest.rst:673 +#: ../../library/doctest.rst:677 msgid "" "The SKIP flag can also be used for temporarily \"commenting out\" examples." msgstr "" -#: ../../library/doctest.rst:678 +#: ../../library/doctest.rst:682 msgid "A bitmask or'ing together all the comparison flags above." msgstr "" -#: ../../library/doctest.rst:680 +#: ../../library/doctest.rst:684 msgid "The second group of options controls how test failures are reported:" msgstr "" -#: ../../library/doctest.rst:685 +#: ../../library/doctest.rst:689 msgid "" "When specified, failures that involve multi-line expected and actual outputs " "are displayed using a unified diff." msgstr "" -#: ../../library/doctest.rst:691 +#: ../../library/doctest.rst:695 msgid "" "When specified, failures that involve multi-line expected and actual outputs " "will be displayed using a context diff." msgstr "" -#: ../../library/doctest.rst:697 +#: ../../library/doctest.rst:701 msgid "" "When specified, differences are computed by ``difflib.Differ``, using the " "same algorithm as the popular :file:`ndiff.py` utility. This is the only " @@ -1061,7 +1068,7 @@ msgid "" "mismatching column positions." msgstr "" -#: ../../library/doctest.rst:706 +#: ../../library/doctest.rst:710 msgid "" "When specified, display the first failing example in each doctest, but " "suppress output for all remaining examples. This will prevent doctest from " @@ -1072,7 +1079,7 @@ msgid "" "of failures reported; only the output is suppressed." msgstr "" -#: ../../library/doctest.rst:717 +#: ../../library/doctest.rst:721 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 " @@ -1080,58 +1087,58 @@ msgid "" "first failure won't even produce debugging output." msgstr "" -#: ../../library/doctest.rst:725 +#: ../../library/doctest.rst:729 msgid "A bitmask or'ing together all the reporting flags above." msgstr "" -#: ../../library/doctest.rst:728 +#: ../../library/doctest.rst:732 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:734 +#: ../../library/doctest.rst:738 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 :" -"class:`OutputChecker` or :class:`DocTestRunner` to create new options that " -"are supported by your subclasses. :func:`register_optionflag` should always " -"be called using the following idiom::" +"integer value. :func:`register_optionflag` can be used when " +"subclassing :class:`OutputChecker` or :class:`DocTestRunner` to create new " +"options that are supported by your subclasses. :func:`register_optionflag` " +"should always be called using the following idiom::" msgstr "" -#: ../../library/doctest.rst:740 +#: ../../library/doctest.rst:744 msgid "MY_FLAG = register_optionflag('MY_FLAG')" msgstr "MY_FLAG = register_optionflag('MY_FLAG')" -#: ../../library/doctest.rst:750 +#: ../../library/doctest.rst:754 msgid "Directives" msgstr "" -#: ../../library/doctest.rst:752 +#: ../../library/doctest.rst:756 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:763 +#: ../../library/doctest.rst:767 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:767 +#: ../../library/doctest.rst:771 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:770 +#: ../../library/doctest.rst:774 msgid "For example, this test passes:" msgstr "舉例來說,這個測試會通過:" -#: ../../library/doctest.rst:772 +#: ../../library/doctest.rst:776 msgid "" ">>> print(list(range(20))) # doctest: +NORMALIZE_WHITESPACE\n" "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9,\n" @@ -1141,7 +1148,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:779 +#: ../../library/doctest.rst:783 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 " @@ -1149,7 +1156,7 @@ msgid "" "a directive to do so:" msgstr "" -#: ../../library/doctest.rst:784 +#: ../../library/doctest.rst:788 msgid "" ">>> print(list(range(20))) # doctest: +ELLIPSIS\n" "[0, 1, ..., 18, 19]" @@ -1157,13 +1164,13 @@ msgstr "" ">>> print(list(range(20))) # doctest: +ELLIPSIS\n" "[0, 1, ..., 18, 19]" -#: ../../library/doctest.rst:790 +#: ../../library/doctest.rst:794 msgid "" "Multiple directives can be used on a single physical line, separated by " "commas:" msgstr "" -#: ../../library/doctest.rst:793 +#: ../../library/doctest.rst:797 msgid "" ">>> print(list(range(20))) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE\n" "[0, 1, ..., 18, 19]" @@ -1171,13 +1178,13 @@ msgstr "" ">>> print(list(range(20))) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE\n" "[0, 1, ..., 18, 19]" -#: ../../library/doctest.rst:799 +#: ../../library/doctest.rst:803 msgid "" "If multiple directive comments are used for a single example, then they are " "combined:" msgstr "" -#: ../../library/doctest.rst:802 +#: ../../library/doctest.rst:806 msgid "" ">>> print(list(range(20))) # doctest: +ELLIPSIS\n" "... # doctest: +NORMALIZE_WHITESPACE\n" @@ -1187,14 +1194,14 @@ msgstr "" "... # doctest: +NORMALIZE_WHITESPACE\n" "[0, 1, ..., 18, 19]" -#: ../../library/doctest.rst:809 +#: ../../library/doctest.rst:813 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:813 +#: ../../library/doctest.rst:817 msgid "" ">>> print(list(range(5)) + list(range(10, 20)) + list(range(30, 40)))\n" "... # doctest: +ELLIPSIS\n" @@ -1204,7 +1211,7 @@ msgstr "" "... # doctest: +ELLIPSIS\n" "[0, ..., 4, 10, ..., 19, 30, ..., 39]" -#: ../../library/doctest.rst:820 +#: ../../library/doctest.rst:824 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 " @@ -1214,11 +1221,11 @@ msgid "" "be useful." msgstr "" -#: ../../library/doctest.rst:830 +#: ../../library/doctest.rst:834 msgid "Warnings" msgstr "警告" -#: ../../library/doctest.rst:832 +#: ../../library/doctest.rst:836 msgid "" ":mod:`doctest` is serious about requiring exact matches in expected output. " "If even a single character doesn't match, the test fails. This will " @@ -1228,7 +1235,7 @@ msgid "" "test like ::" msgstr "" -#: ../../library/doctest.rst:838 +#: ../../library/doctest.rst:842 msgid "" ">>> foo()\n" "{\"spam\", \"eggs\"}" @@ -1236,11 +1243,11 @@ msgstr "" ">>> foo()\n" "{\"spam\", \"eggs\"}" -#: ../../library/doctest.rst:841 +#: ../../library/doctest.rst:845 msgid "is vulnerable! One workaround is to do ::" msgstr "" -#: ../../library/doctest.rst:843 +#: ../../library/doctest.rst:847 msgid "" ">>> foo() == {\"spam\", \"eggs\"}\n" "True" @@ -1248,11 +1255,11 @@ msgstr "" ">>> foo() == {\"spam\", \"eggs\"}\n" "True" -#: ../../library/doctest.rst:846 +#: ../../library/doctest.rst:850 msgid "instead. Another is to do ::" msgstr "" -#: ../../library/doctest.rst:848 +#: ../../library/doctest.rst:852 msgid "" ">>> d = sorted(foo())\n" ">>> d\n" @@ -1262,15 +1269,15 @@ msgstr "" ">>> d\n" "['eggs', 'spam']" -#: ../../library/doctest.rst:852 +#: ../../library/doctest.rst:856 msgid "There are others, but you get the idea." msgstr "" -#: ../../library/doctest.rst:854 +#: ../../library/doctest.rst:858 msgid "Another bad idea is to print things that embed an object address, like" msgstr "" -#: ../../library/doctest.rst:856 +#: ../../library/doctest.rst:860 msgid "" ">>> id(1.0) # certain to fail some of the time\n" "7948648\n" @@ -1279,12 +1286,12 @@ msgid "" "" msgstr "" -#: ../../library/doctest.rst:864 +#: ../../library/doctest.rst:868 msgid "" "The :const:`ELLIPSIS` directive gives a nice approach for the last example:" msgstr "" -#: ../../library/doctest.rst:866 +#: ../../library/doctest.rst:870 msgid "" ">>> C() # doctest: +ELLIPSIS\n" "" @@ -1292,14 +1299,14 @@ msgstr "" ">>> C() # doctest: +ELLIPSIS\n" "" -#: ../../library/doctest.rst:872 +#: ../../library/doctest.rst:876 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:876 +#: ../../library/doctest.rst:880 msgid "" ">>> 1000**0.1 # risky\n" "1.9952623149688797\n" @@ -1308,30 +1315,38 @@ msgid "" ">>> print(f'{1000**0.1:.4f}') # much safer\n" "1.9953" msgstr "" +">>> 1000**0.1 # 有風險\n" +"1.9952623149688797\n" +">>> round(1000**0.1, 9) # 更安全\n" +"1.995262315\n" +">>> print(f'{1000**0.1:.4f}') # 更加安全\n" +"1.9953" -#: ../../library/doctest.rst:883 +#: ../../library/doctest.rst:887 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:886 +#: ../../library/doctest.rst:890 msgid "" ">>> 3./4 # utterly safe\n" "0.75" msgstr "" +">>> 3./4 # utterly safe\n" +"0.75" -#: ../../library/doctest.rst:889 +#: ../../library/doctest.rst:893 msgid "" "Simple fractions are also easier for people to understand, and that makes " "for better documentation." msgstr "" -#: ../../library/doctest.rst:896 +#: ../../library/doctest.rst:900 msgid "Basic API" msgstr "基礎 API" -#: ../../library/doctest.rst:898 +#: ../../library/doctest.rst:902 msgid "" "The functions :func:`testmod` and :func:`testfile` provide a simple " "interface to doctest that should be sufficient for most basic uses. For a " @@ -1339,25 +1354,25 @@ msgid "" "simple-testmod` and :ref:`doctest-simple-testfile`." msgstr "" -#: ../../library/doctest.rst:906 +#: ../../library/doctest.rst:910 msgid "" "All arguments except *filename* are optional, and should be specified in " "keyword form." msgstr "" -#: ../../library/doctest.rst:909 +#: ../../library/doctest.rst:913 msgid "" "Test examples in the file named *filename*. Return ``(failure_count, " "test_count)``." msgstr "" -#: ../../library/doctest.rst:912 +#: ../../library/doctest.rst:916 msgid "" "Optional argument *module_relative* specifies how the filename should be " "interpreted:" msgstr "" -#: ../../library/doctest.rst:915 +#: ../../library/doctest.rst:919 msgid "" "If *module_relative* is ``True`` (the default), then *filename* specifies an " "OS-independent module-relative path. By default, this path is relative to " @@ -1367,20 +1382,20 @@ msgid "" "absolute path (i.e., it may not begin with ``/``)." msgstr "" -#: ../../library/doctest.rst:922 +#: ../../library/doctest.rst:926 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:926 +#: ../../library/doctest.rst:930 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:929 +#: ../../library/doctest.rst:933 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-" @@ -1389,7 +1404,7 @@ msgid "" "is an error to specify *package* if *module_relative* is ``False``." msgstr "" -#: ../../library/doctest.rst:935 +#: ../../library/doctest.rst:939 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 " @@ -1397,7 +1412,7 @@ msgid "" "``None``, a new empty dict is used." msgstr "" -#: ../../library/doctest.rst:940 +#: ../../library/doctest.rst:944 msgid "" "Optional argument *extraglobs* gives a dict merged into the globals used to " "execute examples. This works like :meth:`dict.update`: if *globs* and " @@ -1410,27 +1425,28 @@ msgid "" "tested." msgstr "" -#: ../../library/doctest.rst:949 +#: ../../library/doctest.rst:953 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:953 +#: ../../library/doctest.rst:957 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:957 +#: ../../library/doctest.rst:961 msgid "" -"Optional argument *optionflags* (default value ``0``) takes the :ref:" -"`bitwise OR ` of option flags. See section :ref:`doctest-options`." +"Optional argument *optionflags* (default value ``0``) takes " +"the :ref:`bitwise OR ` of option flags. See section :ref:`doctest-" +"options`." msgstr "" -#: ../../library/doctest.rst:961 +#: ../../library/doctest.rst:965 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. " @@ -1438,99 +1454,99 @@ msgid "" "continue running examples." msgstr "" -#: ../../library/doctest.rst:966 ../../library/doctest.rst:1109 +#: ../../library/doctest.rst:970 ../../library/doctest.rst:1113 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:970 ../../library/doctest.rst:1113 +#: ../../library/doctest.rst:974 ../../library/doctest.rst:1117 msgid "" "Optional argument *encoding* specifies an encoding that should be used to " "convert the file to unicode." msgstr "" -#: ../../library/doctest.rst:976 +#: ../../library/doctest.rst:980 msgid "" "All arguments are optional, and all except for *m* should be specified in " "keyword form." msgstr "" -#: ../../library/doctest.rst:979 +#: ../../library/doctest.rst:983 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:983 +#: ../../library/doctest.rst:987 msgid "" -"Also test examples reachable from dict ``m.__test__``, if it exists. ``m." -"__test__`` maps names (strings) to functions, classes and strings; function " -"and class docstrings are searched for examples; strings are searched " -"directly, as if they were docstrings." +"Also test examples reachable from dict ``m.__test__``, if it exists. " +"``m.__test__`` maps names (strings) to functions, classes and strings; " +"function and class docstrings are searched for examples; strings are " +"searched directly, as if they were docstrings." msgstr "" -#: ../../library/doctest.rst:988 +#: ../../library/doctest.rst:992 msgid "" "Only docstrings attached to objects belonging to module *m* are searched." msgstr "" -#: ../../library/doctest.rst:990 +#: ../../library/doctest.rst:994 msgid "Return ``(failure_count, test_count)``." msgstr "回傳 ``(failure_count, test_count)``。" -#: ../../library/doctest.rst:992 +#: ../../library/doctest.rst:996 msgid "" "Optional argument *name* gives the name of the module; by default, or if " "``None``, ``m.__name__`` is used." msgstr "" -#: ../../library/doctest.rst:995 +#: ../../library/doctest.rst:999 msgid "" "Optional argument *exclude_empty* defaults to false. If true, objects for " "which no doctests are found are excluded from consideration. The default is " -"a backward compatibility hack, so that code still using :meth:`doctest." -"master.summarize ` in conjunction with :func:" -"`testmod` continues to get output for objects with no tests. The " -"*exclude_empty* argument to the newer :class:`DocTestFinder` constructor " -"defaults to true." +"a backward compatibility hack, so that code still " +"using :meth:`doctest.master.summarize ` in " +"conjunction with :func:`testmod` continues to get output for objects with no " +"tests. The *exclude_empty* argument to the newer :class:`DocTestFinder` " +"constructor defaults to true." msgstr "" -#: ../../library/doctest.rst:1003 +#: ../../library/doctest.rst:1007 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:1010 +#: ../../library/doctest.rst:1014 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:1013 +#: ../../library/doctest.rst:1017 msgid "" "A shallow copy of dictionary argument *globs* is used for the execution " "context." msgstr "" -#: ../../library/doctest.rst:1015 +#: ../../library/doctest.rst:1019 msgid "" "Optional argument *name* is used in failure messages, and defaults to " "``\"NoName\"``." msgstr "" -#: ../../library/doctest.rst:1018 +#: ../../library/doctest.rst:1022 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:1021 +#: ../../library/doctest.rst:1025 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 " @@ -1538,16 +1554,16 @@ msgid "" "found in *globs*." msgstr "" -#: ../../library/doctest.rst:1025 +#: ../../library/doctest.rst:1029 msgid "" "Optional argument *optionflags* works as for function :func:`testfile` above." msgstr "" -#: ../../library/doctest.rst:1031 +#: ../../library/doctest.rst:1035 msgid "Unittest API" msgstr "Unittest API" -#: ../../library/doctest.rst:1033 +#: ../../library/doctest.rst:1037 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 " @@ -1557,7 +1573,7 @@ msgid "" "your test module::" msgstr "" -#: ../../library/doctest.rst:1039 +#: ../../library/doctest.rst:1043 msgid "" "import unittest\n" "import doctest\n" @@ -1575,44 +1591,44 @@ msgstr "" " tests.addTests(doctest.DocTestSuite(my_module_with_doctests))\n" " return tests" -#: ../../library/doctest.rst:1047 +#: ../../library/doctest.rst:1051 msgid "" "There are two main functions for creating :class:`unittest.TestSuite` " "instances from text files and modules with doctests:" msgstr "" -#: ../../library/doctest.rst:1053 +#: ../../library/doctest.rst:1057 msgid "" -"Convert doctest tests from one or more text files to a :class:`unittest." -"TestSuite`." +"Convert doctest tests from one or more text files to " +"a :class:`unittest.TestSuite`." msgstr "" -#: ../../library/doctest.rst:1056 +#: ../../library/doctest.rst:1060 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 " -"marked as skipped." +"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 marked as skipped." msgstr "" -#: ../../library/doctest.rst:1063 +#: ../../library/doctest.rst:1067 msgid "Pass one or more paths (as strings) to text files to be examined." msgstr "" -#: ../../library/doctest.rst:1065 +#: ../../library/doctest.rst:1069 msgid "Options may be provided as keyword arguments:" msgstr "" -#: ../../library/doctest.rst:1067 +#: ../../library/doctest.rst:1071 msgid "" "Optional argument *module_relative* specifies how the filenames in *paths* " "should be interpreted:" msgstr "" -#: ../../library/doctest.rst:1070 +#: ../../library/doctest.rst:1074 msgid "" "If *module_relative* is ``True`` (the default), then each filename in " "*paths* specifies an OS-independent module-relative path. By default, this " @@ -1623,14 +1639,14 @@ msgid "" "``)." msgstr "" -#: ../../library/doctest.rst:1078 +#: ../../library/doctest.rst:1082 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:1082 +#: ../../library/doctest.rst:1086 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-" @@ -1640,7 +1656,7 @@ msgid "" "``False``." msgstr "" -#: ../../library/doctest.rst:1089 +#: ../../library/doctest.rst:1093 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 " @@ -1648,7 +1664,7 @@ msgid "" "the test globals as the :attr:`~DocTest.globs` attribute of the test passed." msgstr "" -#: ../../library/doctest.rst:1094 +#: ../../library/doctest.rst:1098 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* " @@ -1657,32 +1673,33 @@ msgid "" "test passed." msgstr "" -#: ../../library/doctest.rst:1100 +#: ../../library/doctest.rst:1104 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:1104 +#: ../../library/doctest.rst:1108 msgid "" "Optional argument *optionflags* specifies the default doctest options for " -"the tests, created by or-ing together individual option flags. See section :" -"ref:`doctest-options`. See function :func:`set_unittest_reportflags` below " -"for a better way to set reporting options." +"the tests, created by or-ing together individual option flags. See " +"section :ref:`doctest-options`. See " +"function :func:`set_unittest_reportflags` below for a better way to set " +"reporting options." msgstr "" -#: ../../library/doctest.rst:1116 +#: ../../library/doctest.rst:1120 msgid "" "The global ``__file__`` is added to the globals provided to doctests loaded " "from a text file using :func:`DocFileSuite`." msgstr "" -#: ../../library/doctest.rst:1122 +#: ../../library/doctest.rst:1126 msgid "Convert doctest tests for a module to a :class:`unittest.TestSuite`." msgstr "" -#: ../../library/doctest.rst:1124 +#: ../../library/doctest.rst:1128 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 " @@ -1693,50 +1710,50 @@ msgid "" "then the" msgstr "" -#: ../../library/doctest.rst:1132 +#: ../../library/doctest.rst:1136 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:1136 +#: ../../library/doctest.rst:1140 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:1140 +#: ../../library/doctest.rst:1144 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:1143 +#: ../../library/doctest.rst:1147 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:1146 +#: ../../library/doctest.rst:1150 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:1149 +#: ../../library/doctest.rst:1153 msgid "This function uses the same search technique as :func:`testmod`." msgstr "" -#: ../../library/doctest.rst:1151 +#: ../../library/doctest.rst:1155 msgid "" ":func:`DocTestSuite` returns an empty :class:`unittest.TestSuite` if " "*module* contains no docstrings instead of raising :exc:`ValueError`." msgstr "" -#: ../../library/doctest.rst:1155 +#: ../../library/doctest.rst:1159 msgid "" "Under the covers, :func:`DocTestSuite` creates a :class:`unittest.TestSuite` " "out of :class:`!doctest.DocTestCase` instances, and :class:`!DocTestCase` is " @@ -1745,18 +1762,18 @@ msgid "" "questions about the exact details of :mod:`unittest` integration." msgstr "" -#: ../../library/doctest.rst:1161 +#: ../../library/doctest.rst:1165 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:1165 +#: ../../library/doctest.rst:1169 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 :" -"mod:`doctest` functions yourself, you can control the :mod:`!doctest` " +"So both ways of creating a :class:`unittest.TestSuite` run instances " +"of :class:`!DocTestCase`. This is important for a subtle reason: when you " +"run :mod:`doctest` functions yourself, you can control the :mod:`!doctest` " "options in use directly, by passing option flags to :mod:`!doctest` " "functions. However, if you're writing a :mod:`unittest` framework, :mod:`!" "unittest` ultimately controls when and how tests get run. The framework " @@ -1765,47 +1782,48 @@ msgid "" "pass options through :mod:`!unittest` to :mod:`!doctest` test runners." msgstr "" -#: ../../library/doctest.rst:1175 +#: ../../library/doctest.rst:1179 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:1181 +#: ../../library/doctest.rst:1185 msgid "Set the :mod:`doctest` reporting flags to use." msgstr "" -#: ../../library/doctest.rst:1183 +#: ../../library/doctest.rst:1187 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:1186 +#: ../../library/doctest.rst:1190 msgid "" "This is a module-global setting, and affects all future doctests run by " "module :mod:`unittest`: the :meth:`!runTest` method of :class:`!" -"DocTestCase` looks at the option flags specified for the test case when the :" -"class:`!DocTestCase` instance was constructed. If no reporting flags were " -"specified (which is the typical and expected case), :mod:`!doctest`'s :mod:`!" -"unittest` reporting flags are :ref:`bitwise ORed ` into the option " -"flags, and the option flags so augmented are passed to the :class:" -"`DocTestRunner` instance created to run the doctest. If any reporting flags " -"were specified when the :class:`!DocTestCase` instance was constructed, :mod:" -"`!doctest`'s :mod:`!unittest` reporting flags are ignored." +"DocTestCase` looks at the option flags specified for the test case when " +"the :class:`!DocTestCase` instance was constructed. If no reporting flags " +"were specified (which is the typical and expected case), :mod:`!" +"doctest`'s :mod:`!unittest` reporting flags are :ref:`bitwise ORed " +"` into the option flags, and the option flags so augmented are " +"passed to the :class:`DocTestRunner` instance created to run the doctest. " +"If any reporting flags were specified when the :class:`!DocTestCase` " +"instance was constructed, :mod:`!doctest`'s :mod:`!unittest` reporting flags " +"are ignored." msgstr "" -#: ../../library/doctest.rst:1197 +#: ../../library/doctest.rst:1201 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:1204 +#: ../../library/doctest.rst:1208 msgid "Advanced API" msgstr "" -#: ../../library/doctest.rst:1206 +#: ../../library/doctest.rst:1210 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 " @@ -1813,62 +1831,62 @@ msgid "" "doctest's capabilities, then you should use the advanced API." msgstr "" -#: ../../library/doctest.rst:1211 +#: ../../library/doctest.rst:1215 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:1214 +#: ../../library/doctest.rst:1218 msgid "" ":class:`Example`: A single Python :term:`statement`, paired with its " "expected output." msgstr "" -#: ../../library/doctest.rst:1217 +#: ../../library/doctest.rst:1221 msgid "" ":class:`DocTest`: A collection of :class:`Example`\\ s, typically extracted " "from a single docstring or text file." msgstr "" -#: ../../library/doctest.rst:1220 +#: ../../library/doctest.rst:1224 msgid "" "Additional processing classes are defined to find, parse, and run, and check " "doctest examples:" msgstr "" -#: ../../library/doctest.rst:1223 +#: ../../library/doctest.rst:1227 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." +":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:1227 +#: ../../library/doctest.rst:1231 msgid "" ":class:`DocTestParser`: Creates a :class:`DocTest` object from a string " "(such as an object's docstring)." msgstr "" -#: ../../library/doctest.rst:1230 +#: ../../library/doctest.rst:1234 msgid "" ":class:`DocTestRunner`: Executes the examples in a :class:`DocTest`, and " "uses an :class:`OutputChecker` to verify their output." msgstr "" -#: ../../library/doctest.rst:1233 +#: ../../library/doctest.rst:1237 msgid "" ":class:`OutputChecker`: Compares the actual output from a doctest example " "with the expected output, and decides whether they match." msgstr "" -#: ../../library/doctest.rst:1236 +#: ../../library/doctest.rst:1240 msgid "" "The relationships among these processing classes are summarized in the " "following diagram::" msgstr "" -#: ../../library/doctest.rst:1239 +#: ../../library/doctest.rst:1243 msgid "" " list of:\n" "+------+ +---------+\n" @@ -1888,88 +1906,88 @@ msgstr "" " DocTestParser | Example | OutputChecker\n" " +---------+" -#: ../../library/doctest.rst:1252 +#: ../../library/doctest.rst:1256 msgid "DocTest Objects" msgstr "DocTest 物件" -#: ../../library/doctest.rst:1257 +#: ../../library/doctest.rst:1261 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:1261 +#: ../../library/doctest.rst:1265 msgid "" ":class:`DocTest` defines the following attributes. They are initialized by " "the constructor, and should not be modified directly." msgstr "" -#: ../../library/doctest.rst:1267 +#: ../../library/doctest.rst:1271 msgid "" "A list of :class:`Example` objects encoding the individual interactive " "Python examples that should be run by this test." msgstr "" -#: ../../library/doctest.rst:1273 +#: ../../library/doctest.rst:1277 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 " -"the examples (such as binding new variables) will be reflected in :attr:" -"`globs` after the test is run." +"the examples (such as binding new variables) will be reflected " +"in :attr:`globs` after the test is run." msgstr "" -#: ../../library/doctest.rst:1281 +#: ../../library/doctest.rst:1285 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:1287 +#: ../../library/doctest.rst:1291 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:1294 +#: ../../library/doctest.rst:1298 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:1301 +#: ../../library/doctest.rst:1305 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:1308 +#: ../../library/doctest.rst:1312 msgid "Example Objects" msgstr "Example 物件" -#: ../../library/doctest.rst:1313 +#: ../../library/doctest.rst:1317 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:1318 +#: ../../library/doctest.rst:1322 msgid "" ":class:`Example` defines the following attributes. They are initialized by " "the constructor, and should not be modified directly." msgstr "" -#: ../../library/doctest.rst:1324 +#: ../../library/doctest.rst:1328 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:1331 +#: ../../library/doctest.rst:1335 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 " @@ -1977,29 +1995,29 @@ msgid "" "The constructor adds a newline when necessary." msgstr "" -#: ../../library/doctest.rst:1339 +#: ../../library/doctest.rst:1343 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 " -"exception. This exception message is compared against the return value of :" -"func:`traceback.format_exception_only`. :attr:`exc_msg` ends with a newline " -"unless it's ``None``. The constructor adds a newline if needed." +"exception. This exception message is compared against the return value " +"of :func:`traceback.format_exception_only`. :attr:`exc_msg` ends with a " +"newline unless it's ``None``. The constructor adds a newline if needed." msgstr "" -#: ../../library/doctest.rst:1348 +#: ../../library/doctest.rst:1352 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:1355 +#: ../../library/doctest.rst:1359 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:1361 +#: ../../library/doctest.rst:1365 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 " @@ -2008,11 +2026,11 @@ msgid "" "default, no options are set." msgstr "" -#: ../../library/doctest.rst:1371 +#: ../../library/doctest.rst:1375 msgid "DocTestFinder objects" msgstr "DocTestFinder 物件" -#: ../../library/doctest.rst:1376 +#: ../../library/doctest.rst:1380 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 " @@ -2020,48 +2038,49 @@ msgid "" "classes, functions, methods, staticmethods, classmethods, and properties." msgstr "" -#: ../../library/doctest.rst:1381 +#: ../../library/doctest.rst:1385 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:1384 +#: ../../library/doctest.rst:1388 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:1387 +#: ../../library/doctest.rst:1391 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:1390 +#: ../../library/doctest.rst:1394 msgid "" -"If the optional argument *exclude_empty* is false, then :meth:`DocTestFinder." -"find` will include tests for objects with empty docstrings." +"If the optional argument *exclude_empty* is false, " +"then :meth:`DocTestFinder.find` will include tests for objects with empty " +"docstrings." msgstr "" -#: ../../library/doctest.rst:1394 +#: ../../library/doctest.rst:1398 msgid ":class:`DocTestFinder` defines the following method:" msgstr ":class:`DocTestFinder` 定義了以下方法:" -#: ../../library/doctest.rst:1399 +#: ../../library/doctest.rst:1403 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:1402 +#: ../../library/doctest.rst:1406 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:1406 +#: ../../library/doctest.rst:1410 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 " @@ -2069,26 +2088,26 @@ msgid "" "module is used:" msgstr "" -#: ../../library/doctest.rst:1410 +#: ../../library/doctest.rst:1414 msgid "As a default namespace, if *globs* is not specified." msgstr "" -#: ../../library/doctest.rst:1412 +#: ../../library/doctest.rst:1416 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:1416 +#: ../../library/doctest.rst:1420 msgid "To find the name of the file containing the object." msgstr "" -#: ../../library/doctest.rst:1418 +#: ../../library/doctest.rst:1422 msgid "To help find the line number of the object within its file." msgstr "" -#: ../../library/doctest.rst:1420 +#: ../../library/doctest.rst:1424 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 " @@ -2097,44 +2116,44 @@ msgid "" "contained objects will (recursively) be searched for doctests." msgstr "" -#: ../../library/doctest.rst:1426 +#: ../../library/doctest.rst:1430 msgid "" "The globals for each :class:`DocTest` is formed by combining *globs* and " "*extraglobs* (bindings in *extraglobs* override bindings in *globs*). A new " "shallow copy of the globals dictionary is created for each :class:`!" -"DocTest`. If *globs* is not specified, then it defaults to the module's :" -"attr:`~module.__dict__`, if specified, or ``{}`` otherwise. If *extraglobs* " -"is not specified, then it defaults to ``{}``." +"DocTest`. If *globs* is not specified, then it defaults to the " +"module's :attr:`~module.__dict__`, if specified, or ``{}`` otherwise. If " +"*extraglobs* is not specified, then it defaults to ``{}``." msgstr "" -#: ../../library/doctest.rst:1437 +#: ../../library/doctest.rst:1441 msgid "DocTestParser objects" msgstr "DocTestParser 物件" -#: ../../library/doctest.rst:1442 +#: ../../library/doctest.rst:1446 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:1446 +#: ../../library/doctest.rst:1450 msgid ":class:`DocTestParser` defines the following methods:" msgstr ":class:`DocTestParser` 定義了以下方法:" -#: ../../library/doctest.rst:1451 +#: ../../library/doctest.rst:1455 msgid "" -"Extract all doctest examples from the given string, and collect them into a :" -"class:`DocTest` object." +"Extract all doctest examples from the given string, and collect them into " +"a :class:`DocTest` object." msgstr "" -#: ../../library/doctest.rst:1454 +#: ../../library/doctest.rst:1458 msgid "" -"*globs*, *name*, *filename*, and *lineno* are attributes for the new :class:" -"`!DocTest` object. See the documentation for :class:`DocTest` for more " -"information." +"*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:1461 +#: ../../library/doctest.rst:1465 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 " @@ -2142,7 +2161,7 @@ msgid "" "error messages." msgstr "" -#: ../../library/doctest.rst:1468 +#: ../../library/doctest.rst:1472 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 " @@ -2150,146 +2169,149 @@ msgid "" "name identifying this string, and is only used for error messages." msgstr "" -#: ../../library/doctest.rst:1475 +#: ../../library/doctest.rst:1479 msgid "TestResults objects" msgstr "TestResults 物件" -#: ../../library/doctest.rst:1482 +#: ../../library/doctest.rst:1486 msgid "Number of failed tests." msgstr "失敗的測試數量。" -#: ../../library/doctest.rst:1486 +#: ../../library/doctest.rst:1490 msgid "Number of attempted tests." msgstr "嘗試的測試數量。" -#: ../../library/doctest.rst:1490 +#: ../../library/doctest.rst:1494 msgid "Number of skipped tests." msgstr "跳過的測試數量。" -#: ../../library/doctest.rst:1498 +#: ../../library/doctest.rst:1502 msgid "DocTestRunner objects" msgstr "DocTestRunner 物件" -#: ../../library/doctest.rst:1503 +#: ../../library/doctest.rst:1507 msgid "" -"A processing class used to execute and verify the interactive examples in a :" -"class:`DocTest`." +"A processing class used to execute and verify the interactive examples in " +"a :class:`DocTest`." msgstr "" -#: ../../library/doctest.rst:1506 +#: ../../library/doctest.rst:1510 msgid "" -"The comparison between expected outputs and actual outputs is done by an :" -"class:`OutputChecker`. This comparison may be customized with a number of " -"option flags; see section :ref:`doctest-options` for more information. If " -"the option flags are insufficient, then the comparison may also be " +"The comparison between expected outputs and actual outputs is done by " +"an :class:`OutputChecker`. This comparison may be customized with a number " +"of option flags; see section :ref:`doctest-options` for more information. " +"If the option flags are insufficient, then the comparison may also be " "customized by passing a subclass of :class:`!OutputChecker` to the " "constructor." msgstr "" -#: ../../library/doctest.rst:1512 +#: ../../library/doctest.rst:1516 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`." +"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`." msgstr "" -#: ../../library/doctest.rst:1520 +#: ../../library/doctest.rst:1524 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:1524 +#: ../../library/doctest.rst:1528 msgid "" -"The optional keyword argument *verbose* controls the :class:" -"`DocTestRunner`'s verbosity. If *verbose* is ``True``, then information is " -"printed about each example, as it is run. If *verbose* is ``False``, then " -"only failures are printed. If *verbose* is unspecified, or ``None``, then " -"verbose output is used iff the command-line switch ``-v`` is used." +"The optional keyword argument *verbose* controls " +"the :class:`DocTestRunner`'s verbosity. If *verbose* is ``True``, then " +"information is printed about each example, as it is run. If *verbose* is " +"``False``, then only failures are printed. If *verbose* is unspecified, or " +"``None``, then verbose output is used iff the command-line switch ``-v`` is " +"used." msgstr "" -#: ../../library/doctest.rst:1530 +#: ../../library/doctest.rst:1534 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:1534 +#: ../../library/doctest.rst:1538 msgid "" "The test runner accumulates statistics. The aggregated number of attempted, " -"failed and skipped examples is also available via the :attr:`tries`, :attr:" -"`failures` and :attr:`skips` attributes. The :meth:`run` and :meth:" -"`summarize` methods return a :class:`TestResults` instance." +"failed and skipped examples is also available via " +"the :attr:`tries`, :attr:`failures` and :attr:`skips` attributes. " +"The :meth:`run` and :meth:`summarize` methods return a :class:`TestResults` " +"instance." msgstr "" -#: ../../library/doctest.rst:1539 +#: ../../library/doctest.rst:1543 msgid ":class:`DocTestRunner` defines the following methods:" msgstr ":class:`DocTestRunner` 定義了以下方法:" -#: ../../library/doctest.rst:1544 +#: ../../library/doctest.rst:1548 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:1548 +#: ../../library/doctest.rst:1552 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`." +"containing *example*. *out* is the output function that was passed " +"to :meth:`DocTestRunner.run`." msgstr "" -#: ../../library/doctest.rst:1555 +#: ../../library/doctest.rst:1559 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:1559 ../../library/doctest.rst:1570 +#: ../../library/doctest.rst:1563 ../../library/doctest.rst:1574 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:1566 +#: ../../library/doctest.rst:1570 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:1577 +#: ../../library/doctest.rst:1581 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:1581 +#: ../../library/doctest.rst:1585 msgid "" "*example* is the example about to be processed. *exc_info* is a tuple " -"containing information about the unexpected exception (as returned by :func:" -"`sys.exc_info`). *test* is the test containing *example*. *out* is the " -"output function that was passed to :meth:`DocTestRunner.run`." +"containing information about the unexpected exception (as returned " +"by :func:`sys.exc_info`). *test* is the test containing *example*. *out* is " +"the output function that was passed to :meth:`DocTestRunner.run`." msgstr "" -#: ../../library/doctest.rst:1589 +#: ../../library/doctest.rst:1593 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:1593 +#: ../../library/doctest.rst:1597 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, " @@ -2297,97 +2319,97 @@ msgid "" "after the test completes, then use *clear_globs=False*." msgstr "" -#: ../../library/doctest.rst:1598 +#: ../../library/doctest.rst:1602 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:1602 +#: ../../library/doctest.rst:1606 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." +"output checker, and the results are formatted by the :meth:`!" +"DocTestRunner.report_\\*` methods." msgstr "" -#: ../../library/doctest.rst:1609 +#: ../../library/doctest.rst:1613 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:1612 +#: ../../library/doctest.rst:1616 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:1616 +#: ../../library/doctest.rst:1620 msgid ":class:`DocTestParser` has the following attributes:" msgstr ":class:`DocTestParser` 有以下屬性:" -#: ../../library/doctest.rst:1620 +#: ../../library/doctest.rst:1624 msgid "Number of attempted examples." msgstr "嘗試的範例數量。" -#: ../../library/doctest.rst:1624 +#: ../../library/doctest.rst:1628 msgid "Number of failed examples." msgstr "失敗的範例數量。" -#: ../../library/doctest.rst:1628 +#: ../../library/doctest.rst:1632 msgid "Number of skipped examples." msgstr "跳過的範例數量。" -#: ../../library/doctest.rst:1636 +#: ../../library/doctest.rst:1640 msgid "OutputChecker objects" msgstr "OutputChecker 物件" -#: ../../library/doctest.rst:1641 +#: ../../library/doctest.rst:1645 msgid "" "A class used to check the whether the actual output from a doctest example " -"matches the expected output. :class:`OutputChecker` defines two methods: :" -"meth:`check_output`, which compares a given pair of outputs, and returns " -"``True`` if they match; and :meth:`output_difference`, which returns a " -"string describing the differences between two outputs." +"matches the expected output. :class:`OutputChecker` defines two " +"methods: :meth:`check_output`, which compares a given pair of outputs, and " +"returns ``True`` if they match; and :meth:`output_difference`, which returns " +"a string describing the differences between two outputs." msgstr "" -#: ../../library/doctest.rst:1648 +#: ../../library/doctest.rst:1652 msgid ":class:`OutputChecker` defines the following methods:" msgstr ":class:`OutputChecker` 定義了以下方法:" -#: ../../library/doctest.rst:1652 +#: ../../library/doctest.rst:1656 msgid "" "Return ``True`` iff the actual output from an example (*got*) matches the " "expected output (*want*). These strings are always considered to match if " "they are identical; but depending on what option flags the test runner is " -"using, several non-exact match types are also possible. See section :ref:" -"`doctest-options` for more information about option flags." +"using, several non-exact match types are also possible. See " +"section :ref:`doctest-options` for more information about option flags." msgstr "" -#: ../../library/doctest.rst:1661 +#: ../../library/doctest.rst:1665 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:1669 +#: ../../library/doctest.rst:1673 msgid "Debugging" msgstr "偵錯" -#: ../../library/doctest.rst:1671 +#: ../../library/doctest.rst:1675 msgid "Doctest provides several mechanisms for debugging doctest examples:" msgstr "Doctest 提供了幾種偵錯 doctest 範例的機制:" -#: ../../library/doctest.rst:1673 +#: ../../library/doctest.rst:1677 msgid "" "Several functions convert doctests to executable Python programs, which can " "be run under the Python debugger, :mod:`pdb`." msgstr "" -#: ../../library/doctest.rst:1676 +#: ../../library/doctest.rst:1680 msgid "" "The :class:`DebugRunner` class is a subclass of :class:`DocTestRunner` that " "raises an exception for the first failing example, containing information " @@ -2395,21 +2417,21 @@ msgid "" "debugging on the example." msgstr "" -#: ../../library/doctest.rst:1681 +#: ../../library/doctest.rst:1685 msgid "" -"The :mod:`unittest` cases generated by :func:`DocTestSuite` support the :" -"meth:`debug` method defined by :class:`unittest.TestCase`." +"The :mod:`unittest` cases generated by :func:`DocTestSuite` support " +"the :meth:`debug` method defined by :class:`unittest.TestCase`." msgstr "" -#: ../../library/doctest.rst:1684 +#: ../../library/doctest.rst:1688 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 " -"inspect current values of variables, and so on. For example, suppose :file:" -"`a.py` contains just this module docstring::" +"inspect current values of variables, and so on. For example, " +"suppose :file:`a.py` contains just this module docstring::" msgstr "" -#: ../../library/doctest.rst:1689 +#: ../../library/doctest.rst:1693 msgid "" "\"\"\"\n" ">>> def f(x):\n" @@ -2431,11 +2453,11 @@ msgstr "" "9\n" "\"\"\"" -#: ../../library/doctest.rst:1699 +#: ../../library/doctest.rst:1703 msgid "Then an interactive Python session may look like this::" msgstr "" -#: ../../library/doctest.rst:1701 +#: ../../library/doctest.rst:1705 msgid "" ">>> import a, doctest\n" ">>> doctest.testmod(a)\n" @@ -2497,17 +2519,17 @@ msgstr "" "(0, 3)\n" ">>>" -#: ../../library/doctest.rst:1732 +#: ../../library/doctest.rst:1736 msgid "" "Functions that convert doctests to Python code, and possibly run the " "synthesized code under the debugger:" msgstr "" -#: ../../library/doctest.rst:1738 +#: ../../library/doctest.rst:1742 msgid "Convert text with examples to a script." msgstr "" -#: ../../library/doctest.rst:1740 +#: ../../library/doctest.rst:1744 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 " @@ -2515,7 +2537,7 @@ msgid "" "generated script is returned as a string. For example, ::" msgstr "" -#: ../../library/doctest.rst:1745 +#: ../../library/doctest.rst:1749 msgid "" "import doctest\n" "print(doctest.script_from_examples(r\"\"\"\n" @@ -2528,11 +2550,11 @@ msgid "" "\"\"\"))" msgstr "" -#: ../../library/doctest.rst:1755 +#: ../../library/doctest.rst:1759 msgid "displays::" msgstr "" -#: ../../library/doctest.rst:1757 +#: ../../library/doctest.rst:1761 msgid "" "# Set x and y to 1 and 2.\n" "x, y = 1, 2\n" @@ -2543,18 +2565,18 @@ msgid "" "## 3" msgstr "" -#: ../../library/doctest.rst:1765 +#: ../../library/doctest.rst:1769 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:1772 +#: ../../library/doctest.rst:1776 msgid "Convert the doctest for an object to a script." msgstr "" -#: ../../library/doctest.rst:1774 +#: ../../library/doctest.rst:1778 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 " @@ -2564,7 +2586,7 @@ msgid "" "module :file:`a.py` contains a top-level function :func:`!f`, then ::" msgstr "" -#: ../../library/doctest.rst:1781 +#: ../../library/doctest.rst:1785 msgid "" "import a, doctest\n" "print(doctest.testsource(a, \"a.f\"))" @@ -2572,66 +2594,66 @@ msgstr "" "import a, doctest\n" "print(doctest.testsource(a, \"a.f\"))" -#: ../../library/doctest.rst:1784 +#: ../../library/doctest.rst:1788 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:1790 +#: ../../library/doctest.rst:1794 msgid "Debug the doctests for an object." msgstr "" -#: ../../library/doctest.rst:1792 +#: ../../library/doctest.rst:1796 msgid "" -"The *module* and *name* arguments are the same as for function :func:" -"`testsource` above. The synthesized Python script for the named object's " -"docstring is written to a temporary file, and then that file is run under " -"the control of the Python debugger, :mod:`pdb`." +"The *module* and *name* arguments are the same as for " +"function :func:`testsource` above. The synthesized Python script for the " +"named object's docstring is written to a temporary file, and then that file " +"is run under the control of the Python debugger, :mod:`pdb`." msgstr "" -#: ../../library/doctest.rst:1797 +#: ../../library/doctest.rst:1801 msgid "" "A shallow copy of ``module.__dict__`` is used for both local and global " "execution context." msgstr "" -#: ../../library/doctest.rst:1800 +#: ../../library/doctest.rst:1804 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 " "gets involved only if the script terminates via raising an unhandled " -"exception. If it does, then post-mortem debugging is invoked, via :func:" -"`pdb.post_mortem`, passing the traceback object from the unhandled " +"exception. If it does, then post-mortem debugging is invoked, " +"via :func:`pdb.post_mortem`, passing the traceback object from the unhandled " "exception. If *pm* is not specified, or is false, the script is run under " "the debugger from the start, via passing an appropriate :func:`exec` call " "to :func:`pdb.run`." msgstr "" -#: ../../library/doctest.rst:1811 +#: ../../library/doctest.rst:1815 msgid "Debug the doctests in a string." msgstr "" -#: ../../library/doctest.rst:1813 +#: ../../library/doctest.rst:1817 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:1816 +#: ../../library/doctest.rst:1820 msgid "" "Optional argument *pm* has the same meaning as in function :func:`debug` " "above." msgstr "" -#: ../../library/doctest.rst:1818 +#: ../../library/doctest.rst:1822 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:1823 +#: ../../library/doctest.rst:1827 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 " @@ -2639,99 +2661,99 @@ msgid "" "(which is a doctest!) for more details:" msgstr "" -#: ../../library/doctest.rst:1831 +#: ../../library/doctest.rst:1835 msgid "" "A subclass of :class:`DocTestRunner` that raises an exception as soon as a " -"failure is encountered. If an unexpected exception occurs, an :exc:" -"`UnexpectedException` exception is raised, containing the test, the example, " -"and the original exception. If the output doesn't match, then a :exc:" -"`DocTestFailure` exception is raised, containing the test, the example, and " -"the actual output." +"failure is encountered. If an unexpected exception occurs, " +"an :exc:`UnexpectedException` exception is raised, containing the test, the " +"example, and the original exception. If the output doesn't match, then " +"a :exc:`DocTestFailure` exception is raised, containing the test, the " +"example, and the actual output." msgstr "" -#: ../../library/doctest.rst:1838 +#: ../../library/doctest.rst:1842 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:1841 +#: ../../library/doctest.rst:1845 msgid "" "There are two exceptions that may be raised by :class:`DebugRunner` " "instances:" msgstr "" -#: ../../library/doctest.rst:1846 +#: ../../library/doctest.rst:1850 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:1850 +#: ../../library/doctest.rst:1854 msgid ":exc:`DocTestFailure` defines the following attributes:" msgstr ":exc:`DocTestFailure` 定義了以下屬性:" -#: ../../library/doctest.rst:1855 ../../library/doctest.rst:1879 +#: ../../library/doctest.rst:1859 ../../library/doctest.rst:1883 msgid "The :class:`DocTest` object that was being run when the example failed." msgstr "" -#: ../../library/doctest.rst:1860 ../../library/doctest.rst:1884 +#: ../../library/doctest.rst:1864 ../../library/doctest.rst:1888 msgid "The :class:`Example` that failed." msgstr "" -#: ../../library/doctest.rst:1865 +#: ../../library/doctest.rst:1869 msgid "The example's actual output." msgstr "" -#: ../../library/doctest.rst:1870 +#: ../../library/doctest.rst:1874 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:1874 +#: ../../library/doctest.rst:1878 msgid ":exc:`UnexpectedException` defines the following attributes:" msgstr ":exc:`UnexpectedException` 定義了以下屬性:" -#: ../../library/doctest.rst:1889 +#: ../../library/doctest.rst:1893 msgid "" "A tuple containing information about the unexpected exception, as returned " "by :func:`sys.exc_info`." msgstr "" -#: ../../library/doctest.rst:1896 +#: ../../library/doctest.rst:1900 msgid "Soapbox" msgstr "" -#: ../../library/doctest.rst:1898 +#: ../../library/doctest.rst:1902 msgid "" "As mentioned in the introduction, :mod:`doctest` has grown to have three " "primary uses:" msgstr "" -#: ../../library/doctest.rst:1901 +#: ../../library/doctest.rst:1905 msgid "Checking examples in docstrings." msgstr "" -#: ../../library/doctest.rst:1903 +#: ../../library/doctest.rst:1907 msgid "Regression testing." msgstr "回歸測試。" -#: ../../library/doctest.rst:1905 +#: ../../library/doctest.rst:1909 msgid "Executable documentation / literate testing." msgstr "" -#: ../../library/doctest.rst:1907 +#: ../../library/doctest.rst:1911 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:1911 +#: ../../library/doctest.rst:1915 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. " @@ -2743,7 +2765,7 @@ msgid "" "\"harmless\" change." msgstr "" -#: ../../library/doctest.rst:1919 +#: ../../library/doctest.rst:1923 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 " @@ -2764,13 +2786,13 @@ msgid "" "different results, blurring the distinction between testing and explaining." msgstr "" -#: ../../library/doctest.rst:1937 +#: ../../library/doctest.rst:1941 msgid "" "Regression testing is best confined to dedicated objects or files. There " "are several options for organizing tests:" msgstr "" -#: ../../library/doctest.rst:1940 +#: ../../library/doctest.rst:1944 msgid "" "Write text files containing test cases as interactive examples, and test the " "files using :func:`testfile` or :func:`DocFileSuite`. This is recommended, " @@ -2778,7 +2800,7 @@ msgid "" "doctest." msgstr "" -#: ../../library/doctest.rst:1945 +#: ../../library/doctest.rst:1949 msgid "" "Define functions named ``_regrtest_topic`` that consist of single " "docstrings, containing test cases for the named topics. These functions can " @@ -2786,13 +2808,13 @@ msgid "" "test file." msgstr "" -#: ../../library/doctest.rst:1949 +#: ../../library/doctest.rst:1953 msgid "" "Define a :attr:`~module.__test__` dictionary mapping from regression test " "topics to docstrings containing test cases." msgstr "" -#: ../../library/doctest.rst:1952 +#: ../../library/doctest.rst:1956 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-" @@ -2800,7 +2822,7 @@ msgid "" "example of such a test runner::" msgstr "" -#: ../../library/doctest.rst:1957 +#: ../../library/doctest.rst:1961 msgid "" "if __name__ == '__main__':\n" " import doctest\n" @@ -2832,54 +2854,54 @@ msgstr "" " fail, total = doctest.testmod(optionflags=flags)\n" " print(f\"{fail} failures out of {total} tests\")" -#: ../../library/doctest.rst:1974 +#: ../../library/doctest.rst:1978 msgid "Footnotes" msgstr "註腳" -#: ../../library/doctest.rst:1975 +#: ../../library/doctest.rst:1979 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:383 +#: ../../library/doctest.rst:387 msgid ">>>" msgstr ">>>" -#: ../../library/doctest.rst:383 +#: ../../library/doctest.rst:387 msgid "interpreter prompt" msgstr "interpreter prompt(直譯器提示)" -#: ../../library/doctest.rst:383 ../../library/doctest.rst:618 +#: ../../library/doctest.rst:387 ../../library/doctest.rst:622 msgid "..." msgstr "..." -#: ../../library/doctest.rst:549 +#: ../../library/doctest.rst:553 msgid "^ (caret)" msgstr "^ (插入符號)" -#: ../../library/doctest.rst:549 +#: ../../library/doctest.rst:553 msgid "marker" msgstr "marker(標記)" -#: ../../library/doctest.rst:598 +#: ../../library/doctest.rst:602 msgid "" msgstr "" -#: ../../library/doctest.rst:618 ../../library/doctest.rst:743 +#: ../../library/doctest.rst:622 ../../library/doctest.rst:747 msgid "in doctests" msgstr "於 doctests 中" -#: ../../library/doctest.rst:743 +#: ../../library/doctest.rst:747 msgid "# (hash)" msgstr "# (井字號)" -#: ../../library/doctest.rst:743 +#: ../../library/doctest.rst:747 msgid "+ (plus)" msgstr "+ (加號)" -#: ../../library/doctest.rst:743 +#: ../../library/doctest.rst:747 msgid "- (minus)" msgstr "- (減號)" diff --git a/library/email.charset.po b/library/email.charset.po index 34d62860339..d5fa76c9228 100644 --- a/library/email.charset.po +++ b/library/email.charset.po @@ -1,10 +1,10 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-05-09 00:03+0000\n" "PO-Revision-Date: 2018-05-23 14:43+0000\n" diff --git a/library/email.compat32-message.po b/library/email.compat32-message.po index 1be28eae02b..98b599220d2 100644 --- a/library/email.compat32-message.po +++ b/library/email.compat32-message.po @@ -1,8 +1,8 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2025-07-07 17:47+0000\n" "PO-Revision-Date: 2018-07-15 18:56+0800\n" @@ -704,7 +704,7 @@ msgstr "" #: ../../library/email.compat32-message.rst:554 msgid "``replace`` keyword was added." -msgstr "" +msgstr "新增 ``replace`` 關鍵字。" #: ../../library/email.compat32-message.rst:559 msgid "" diff --git a/library/email.contentmanager.po b/library/email.contentmanager.po index 3ecae144865..694d14c518f 100644 --- a/library/email.contentmanager.po +++ b/library/email.contentmanager.po @@ -1,11 +1,10 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2025-01-19 00:15+0000\n" "PO-Revision-Date: 2018-05-23 14:43+0000\n" diff --git a/library/email.encoders.po b/library/email.encoders.po index 851f162ded3..6aa55e07106 100644 --- a/library/email.encoders.po +++ b/library/email.encoders.po @@ -1,11 +1,11 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Matt Wang , 2024 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2023-07-29 10:36+0000\n" "PO-Revision-Date: 2024-05-03 03:44+0000\n" diff --git a/library/email.errors.po b/library/email.errors.po index 2709c6bc47f..8ff458b07f9 100644 --- a/library/email.errors.po +++ b/library/email.errors.po @@ -1,11 +1,10 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2025-03-04 00:14+0000\n" "PO-Revision-Date: 2018-05-23 14:44+0000\n" diff --git a/library/email.examples.po b/library/email.examples.po index f0275174436..a6699ca3907 100644 --- a/library/email.examples.po +++ b/library/email.examples.po @@ -1,9 +1,8 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2025-04-08 00:14+0000\n" "PO-Revision-Date: 2018-07-15 18:56+0800\n" diff --git a/library/email.generator.po b/library/email.generator.po index 64c675911dc..3ab3635a491 100644 --- a/library/email.generator.po +++ b/library/email.generator.po @@ -1,11 +1,10 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-23 07:52+0800\n" "PO-Revision-Date: 2018-05-23 14:44+0000\n" diff --git a/library/email.header.po b/library/email.header.po index 2492b8b82e6..6cf77fc3c82 100644 --- a/library/email.header.po +++ b/library/email.header.po @@ -1,10 +1,10 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2025-06-27 07:36+0000\n" "PO-Revision-Date: 2018-05-23 14:44+0000\n" diff --git a/library/email.headerregistry.po b/library/email.headerregistry.po index 79898d5d743..450f84fe068 100644 --- a/library/email.headerregistry.po +++ b/library/email.headerregistry.po @@ -1,11 +1,10 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-27 00:14+0000\n" "PO-Revision-Date: 2018-05-23 14:44+0000\n" diff --git a/library/email.iterators.po b/library/email.iterators.po index 71843281fbf..5a0856c0186 100644 --- a/library/email.iterators.po +++ b/library/email.iterators.po @@ -1,11 +1,10 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-03 11:11+0800\n" "PO-Revision-Date: 2016-11-19 00:30+0000\n" diff --git a/library/email.message.po b/library/email.message.po index 6be5abfbdc0..776855ae1d7 100644 --- a/library/email.message.po +++ b/library/email.message.po @@ -1,11 +1,10 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-03 11:11+0800\n" "PO-Revision-Date: 2018-05-23 14:44+0000\n" @@ -484,7 +483,7 @@ msgstr "" #: ../../library/email.message.rst:384 msgid "``replace`` keyword was added." -msgstr "" +msgstr "新增 ``replace`` 關鍵字。" #: ../../library/email.message.rst:389 msgid "" diff --git a/library/email.mime.po b/library/email.mime.po index 2cd526c301f..e51a1ffd94c 100644 --- a/library/email.mime.po +++ b/library/email.mime.po @@ -1,11 +1,10 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-05-09 00:03+0000\n" "PO-Revision-Date: 2018-05-23 16:00+0000\n" diff --git a/library/email.parser.po b/library/email.parser.po index 9bcf6914776..6decb9220c0 100644 --- a/library/email.parser.po +++ b/library/email.parser.po @@ -1,10 +1,10 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2025-07-14 11:31+0000\n" "PO-Revision-Date: 2018-05-23 16:01+0000\n" diff --git a/library/email.po b/library/email.po index da6d04ebe5e..f0bad9cfcbb 100644 --- a/library/email.po +++ b/library/email.po @@ -1,11 +1,10 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-23 07:52+0800\n" "PO-Revision-Date: 2018-05-23 16:01+0000\n" diff --git a/library/email.policy.po b/library/email.policy.po index 526811754f1..1f7507a8772 100644 --- a/library/email.policy.po +++ b/library/email.policy.po @@ -1,10 +1,10 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2025-01-06 00:14+0000\n" "PO-Revision-Date: 2018-05-23 16:01+0000\n" diff --git a/library/email.utils.po b/library/email.utils.po index eb6c4dec6bc..37cc9eb5001 100644 --- a/library/email.utils.po +++ b/library/email.utils.po @@ -1,14 +1,13 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# 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.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-07 03:11+0800\n" +"POT-Creation-Date: 2025-09-08 15:25+0800\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-" @@ -35,33 +34,32 @@ msgstr "" #: ../../library/email.utils.rst:16 msgid "" "Return local time as an aware datetime object. If called without arguments, " -"return current time. Otherwise *dt* argument should be a :class:`~datetime." -"datetime` instance, and it is converted to the local time zone according to " -"the system time zone database. If *dt* is naive (that is, ``dt.tzinfo`` is " -"``None``), it is assumed to be in local time. The *isdst* parameter is " -"ignored." +"return current time. Otherwise *dt* argument should be " +"a :class:`~datetime.datetime` instance, and it is converted to the local " +"time zone according to the system time zone database. If *dt* is naive " +"(that is, ``dt.tzinfo`` is ``None``), it is assumed to be in local time." msgstr "" -#: ../../library/email.utils.rst:25 +#: ../../library/email.utils.rst:24 msgid "The *isdst* parameter." msgstr "" -#: ../../library/email.utils.rst:30 +#: ../../library/email.utils.rst:29 msgid "" -"Returns a string suitable for an :rfc:`2822`\\ -compliant :mailheader:" -"`Message-ID` header. Optional *idstring* if given, is a string used to " -"strengthen the uniqueness of the message id. Optional *domain* if given " -"provides the portion of the msgid after the '@'. The default is the local " -"hostname. It is not normally necessary to override this default, but may be " -"useful certain cases, such as a constructing distributed system that uses a " -"consistent domain name across multiple hosts." +"Returns a string suitable for an :rfc:`2822`\\ " +"-compliant :mailheader:`Message-ID` header. Optional *idstring* if given, " +"is a string used to strengthen the uniqueness of the message id. Optional " +"*domain* if given provides the portion of the msgid after the '@'. The " +"default is the local hostname. It is not normally necessary to override " +"this default, but may be useful certain cases, such as a constructing " +"distributed system that uses a consistent domain name across multiple hosts." msgstr "" -#: ../../library/email.utils.rst:38 +#: ../../library/email.utils.rst:37 msgid "Added the *domain* keyword." msgstr "新增 *domain* 關鍵字。" -#: ../../library/email.utils.rst:42 +#: ../../library/email.utils.rst:41 msgid "" "The remaining functions are part of the legacy (``Compat32``) email API. " "There is no need to directly use these with the new API, since the parsing " @@ -69,20 +67,20 @@ msgid "" "machinery of the new API." msgstr "" -#: ../../library/email.utils.rst:50 +#: ../../library/email.utils.rst:49 msgid "" "Return a new string with backslashes in *str* replaced by two backslashes, " "and double quotes replaced by backslash-double quote." msgstr "" -#: ../../library/email.utils.rst:56 +#: ../../library/email.utils.rst:55 msgid "" "Return a new string which is an *unquoted* version of *str*. If *str* ends " "and begins with double quotes, they are stripped off. Likewise if *str* " "ends and begins with angle brackets, they are stripped off." msgstr "" -#: ../../library/email.utils.rst:63 +#: ../../library/email.utils.rst:62 msgid "" "Parse address -- which should be the value of some address-containing field " "such as :mailheader:`To` or :mailheader:`Cc` -- into its constituent " @@ -90,47 +88,47 @@ msgid "" "unless the parse fails, in which case a 2-tuple of ``('', '')`` is returned." msgstr "" -#: ../../library/email.utils.rst:68 ../../library/email.utils.rst:96 +#: ../../library/email.utils.rst:67 ../../library/email.utils.rst:95 msgid "" "If *strict* is true, use a strict parser which rejects malformed inputs." msgstr "" -#: ../../library/email.utils.rst:70 ../../library/email.utils.rst:108 +#: ../../library/email.utils.rst:69 ../../library/email.utils.rst:107 msgid "Add *strict* optional parameter and reject malformed inputs by default." msgstr "" -#: ../../library/email.utils.rst:76 +#: ../../library/email.utils.rst:75 msgid "" "The inverse of :meth:`parseaddr`, this takes a 2-tuple of the form " -"``(realname, email_address)`` and returns the string value suitable for a :" -"mailheader:`To` or :mailheader:`Cc` header. If the first element of *pair* " -"is false, then the second element is returned unmodified." +"``(realname, email_address)`` and returns the string value suitable for " +"a :mailheader:`To` or :mailheader:`Cc` header. If the first element of " +"*pair* is false, then the second element is returned unmodified." msgstr "" -#: ../../library/email.utils.rst:81 +#: ../../library/email.utils.rst:80 msgid "" "Optional *charset* is the character set that will be used in the :rfc:`2047` " "encoding of the ``realname`` if the ``realname`` contains non-ASCII " -"characters. Can be an instance of :class:`str` or a :class:`~email.charset." -"Charset`. Defaults to ``utf-8``." +"characters. Can be an instance of :class:`str` or " +"a :class:`~email.charset.Charset`. Defaults to ``utf-8``." msgstr "" -#: ../../library/email.utils.rst:86 +#: ../../library/email.utils.rst:85 msgid "Added the *charset* option." msgstr "新增 *charset* 選項。" -#: ../../library/email.utils.rst:92 +#: ../../library/email.utils.rst:91 msgid "" "This method returns a list of 2-tuples of the form returned by " "``parseaddr()``. *fieldvalues* is a sequence of header field values as might " "be returned by :meth:`Message.get_all `." msgstr "" -#: ../../library/email.utils.rst:98 +#: ../../library/email.utils.rst:97 msgid "Here's a simple example that gets all the recipients of a message::" msgstr "" -#: ../../library/email.utils.rst:100 +#: ../../library/email.utils.rst:99 msgid "" "from email.utils import getaddresses\n" "\n" @@ -148,18 +146,18 @@ msgstr "" "resent_ccs = msg.get_all('resent-cc', [])\n" "all_recipients = getaddresses(tos + ccs + resent_tos + resent_ccs)" -#: ../../library/email.utils.rst:114 +#: ../../library/email.utils.rst:113 msgid "" "Attempts to parse a date according to the rules in :rfc:`2822`. however, " "some mailers don't follow that format as specified, so :func:`parsedate` " -"tries to guess correctly in such cases. *date* is a string containing an :" -"rfc:`2822` date, such as ``\"Mon, 20 Nov 1995 19:12:08 -0500\"``. If it " -"succeeds in parsing the date, :func:`parsedate` returns a 9-tuple that can " -"be passed directly to :func:`time.mktime`; otherwise ``None`` will be " +"tries to guess correctly in such cases. *date* is a string containing " +"an :rfc:`2822` date, such as ``\"Mon, 20 Nov 1995 19:12:08 -0500\"``. If " +"it succeeds in parsing the date, :func:`parsedate` returns a 9-tuple that " +"can be passed directly to :func:`time.mktime`; otherwise ``None`` will be " "returned. Note that indexes 6, 7, and 8 of the result tuple are not usable." msgstr "" -#: ../../library/email.utils.rst:125 +#: ../../library/email.utils.rst:124 msgid "" "Performs the same function as :func:`parsedate`, but returns either ``None`` " "or a 10-tuple; the first 9 elements make up a tuple that can be passed " @@ -170,43 +168,43 @@ msgid "" "the result tuple are not usable." msgstr "" -#: ../../library/email.utils.rst:135 +#: ../../library/email.utils.rst:134 msgid "" -"The inverse of :func:`format_datetime`. Performs the same function as :func:" -"`parsedate`, but on success returns a :mod:`~datetime.datetime`; otherwise " -"``ValueError`` is raised if *date* contains an invalid value such as an hour " -"greater than 23 or a timezone offset not between -24 and 24 hours. If the " -"input date has a timezone of ``-0000``, the ``datetime`` will be a naive " -"``datetime``, and if the date is conforming to the RFCs it will represent a " -"time in UTC but with no indication of the actual source timezone of the " -"message the date comes from. If the input date has any other valid timezone " -"offset, the ``datetime`` will be an aware ``datetime`` with the " +"The inverse of :func:`format_datetime`. Performs the same function " +"as :func:`parsedate`, but on success returns a :mod:`~datetime.datetime`; " +"otherwise ``ValueError`` is raised if *date* contains an invalid value such " +"as an hour greater than 23 or a timezone offset not between -24 and 24 " +"hours. If the input date has a timezone of ``-0000``, the ``datetime`` will " +"be a naive ``datetime``, and if the date is conforming to the RFCs it will " +"represent a time in UTC but with no indication of the actual source timezone " +"of the message the date comes from. If the input date has any other valid " +"timezone offset, the ``datetime`` will be an aware ``datetime`` with the " "corresponding a :class:`~datetime.timezone` :class:`~datetime.tzinfo`." msgstr "" -#: ../../library/email.utils.rst:151 +#: ../../library/email.utils.rst:150 msgid "" "Turn a 10-tuple as returned by :func:`parsedate_tz` into a UTC timestamp " "(seconds since the Epoch). If the timezone item in the tuple is ``None``, " "assume local time." msgstr "" -#: ../../library/email.utils.rst:158 +#: ../../library/email.utils.rst:157 msgid "Returns a date string as per :rfc:`2822`, e.g.::" msgstr "" -#: ../../library/email.utils.rst:160 +#: ../../library/email.utils.rst:159 msgid "Fri, 09 Nov 2001 01:08:47 -0000" msgstr "Fri, 09 Nov 2001 01:08:47 -0000" -#: ../../library/email.utils.rst:162 +#: ../../library/email.utils.rst:161 msgid "" -"Optional *timeval* if given is a floating-point time value as accepted by :" -"func:`time.gmtime` and :func:`time.localtime`, otherwise the current time is " -"used." +"Optional *timeval* if given is a floating-point time value as accepted " +"by :func:`time.gmtime` and :func:`time.localtime`, otherwise the current " +"time is used." msgstr "" -#: ../../library/email.utils.rst:166 +#: ../../library/email.utils.rst:165 msgid "" "Optional *localtime* is a flag that when ``True``, interprets *timeval*, and " "returns a date relative to the local timezone instead of UTC, properly " @@ -214,7 +212,7 @@ msgid "" "UTC is used." msgstr "" -#: ../../library/email.utils.rst:171 +#: ../../library/email.utils.rst:170 msgid "" "Optional *usegmt* is a flag that when ``True``, outputs a date string with " "the timezone as an ascii string ``GMT``, rather than a numeric ``-0000``. " @@ -222,7 +220,7 @@ msgid "" "*localtime* is ``False``. The default is ``False``." msgstr "" -#: ../../library/email.utils.rst:179 +#: ../../library/email.utils.rst:178 msgid "" "Like ``formatdate``, but the input is a :mod:`datetime` instance. If it is " "a naive datetime, it is assumed to be \"UTC with no information about the " @@ -234,11 +232,11 @@ msgid "" "date headers." msgstr "" -#: ../../library/email.utils.rst:193 +#: ../../library/email.utils.rst:192 msgid "Decode the string *s* according to :rfc:`2231`." msgstr "" -#: ../../library/email.utils.rst:198 +#: ../../library/email.utils.rst:197 msgid "" "Encode the string *s* according to :rfc:`2231`. Optional *charset* and " "*language*, if given is the character set name and language name to use. If " @@ -247,35 +245,35 @@ msgid "" "*language*." msgstr "" -#: ../../library/email.utils.rst:206 +#: ../../library/email.utils.rst:205 msgid "" -"When a header parameter is encoded in :rfc:`2231` format, :meth:`Message." -"get_param ` may return a 3-tuple containing " -"the character set, language, and value. :func:`collapse_rfc2231_value` " -"turns this into a unicode string. Optional *errors* is passed to the " -"*errors* argument of :class:`str`'s :func:`~str.encode` method; it defaults " -"to ``'replace'``. Optional *fallback_charset* specifies the character set " -"to use if the one in the :rfc:`2231` header is not known by Python; it " -"defaults to ``'us-ascii'``." +"When a header parameter is encoded in :rfc:`2231` " +"format, :meth:`Message.get_param ` may " +"return a 3-tuple containing the character set, language, and " +"value. :func:`collapse_rfc2231_value` turns this into a unicode string. " +"Optional *errors* is passed to the *errors* argument " +"of :class:`str`'s :func:`~str.encode` method; it defaults to ``'replace'``. " +"Optional *fallback_charset* specifies the character set to use if the one in " +"the :rfc:`2231` header is not known by Python; it defaults to ``'us-ascii'``." msgstr "" -#: ../../library/email.utils.rst:215 +#: ../../library/email.utils.rst:214 msgid "" "For convenience, if the *value* passed to :func:`collapse_rfc2231_value` is " "not a tuple, it should be a string and it is returned unquoted." msgstr "" -#: ../../library/email.utils.rst:221 +#: ../../library/email.utils.rst:220 msgid "" "Decode parameters list according to :rfc:`2231`. *params* is a sequence of " "2-tuples containing elements of the form ``(content-type, string-value)``." msgstr "" -#: ../../library/email.utils.rst:226 +#: ../../library/email.utils.rst:225 msgid "Footnotes" msgstr "註解" -#: ../../library/email.utils.rst:227 +#: ../../library/email.utils.rst:226 msgid "" "Note that the sign of the timezone offset is the opposite of the sign of the " "``time.timezone`` variable for the same timezone; the latter variable " diff --git a/library/ensurepip.po b/library/ensurepip.po index 9055ad0aacd..bd75909bd82 100644 --- a/library/ensurepip.po +++ b/library/ensurepip.po @@ -1,13 +1,12 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-02-19 00:13+0000\n" +"POT-Creation-Date: 2025-11-18 00:15+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-" @@ -59,19 +58,27 @@ msgstr "" "此模組\\ *不會*\\ 通過網路存取。所有需要用來初始建置 ``pip`` 的元件都已包含在" "套件之內。" -#: ../../library/ensurepip.rst:35 +#: ../../includes/optional-module.rst:1 +msgid "" +"This is an :term:`optional module`. If it is missing from your copy of " +"CPython, look for documentation from your distributor (that is, whoever " +"provided Python to you). If you are the distributor, see :ref:`optional-" +"module-requirements`." +msgstr "" + +#: ../../library/ensurepip.rst:37 msgid ":ref:`installing-index`" msgstr ":ref:`installing-index`" -#: ../../library/ensurepip.rst:36 +#: ../../library/ensurepip.rst:38 msgid "The end user guide for installing Python packages" msgstr "對於終端使用者安裝 Python 套件的指引" -#: ../../library/ensurepip.rst:38 +#: ../../library/ensurepip.rst:40 msgid ":pep:`453`: Explicit bootstrapping of pip in Python installations" msgstr ":pep:`453`: 在 Python 安裝中的 pip 明確初始建置" -#: ../../library/ensurepip.rst:39 +#: ../../library/ensurepip.rst:41 msgid "The original rationale and specification for this module." msgstr "此模組的最初設計理念與規範。" @@ -87,24 +94,24 @@ msgstr "" "此模組在\\ :ref:`行動平台 `\\ 或\\ :ref:`WebAssembly 平" "台 `\\ 上不支援。" -#: ../../library/ensurepip.rst:44 -msgid "Command line interface" +#: ../../library/ensurepip.rst:48 +msgid "Command-line interface" msgstr "命令列介面" -#: ../../library/ensurepip.rst:48 +#: ../../library/ensurepip.rst:52 msgid "" "The command line interface is invoked using the interpreter's ``-m`` switch." msgstr "使用直譯器 (interpreter) 的 ``-m`` 來叫用命令列介面" -#: ../../library/ensurepip.rst:50 +#: ../../library/ensurepip.rst:54 msgid "The simplest possible invocation is::" msgstr "最簡單可行的呼叫: ::" -#: ../../library/ensurepip.rst:52 +#: ../../library/ensurepip.rst:56 msgid "python -m ensurepip" msgstr "python -m ensurepip" -#: ../../library/ensurepip.rst:54 +#: ../../library/ensurepip.rst:58 msgid "" "This invocation will install ``pip`` if it is not already installed, but " "otherwise does nothing. To ensure the installed version of ``pip`` is at " @@ -115,11 +122,11 @@ msgstr "" "upgrade`` 參數來確保 ``pip`` 的安裝版本至少為目前 ``ensurepip`` 中最新可用的" "版本: ::" -#: ../../library/ensurepip.rst:59 +#: ../../library/ensurepip.rst:63 msgid "python -m ensurepip --upgrade" msgstr "python -m ensurepip --upgrade" -#: ../../library/ensurepip.rst:61 +#: ../../library/ensurepip.rst:65 msgid "" "By default, ``pip`` is installed into the current virtual environment (if " "one is active) or into the system site packages (if there is no active " @@ -129,7 +136,7 @@ msgstr "" "預設上,``pip`` 會被安裝至目前虛擬環境(若已啟動虛擬環境)或系統端的套件(若" "沒有啟動的虛擬環境)。安裝位置可透過兩個額外的命令列選項來控制:" -#: ../../library/ensurepip.rst:68 +#: ../../library/ensurepip.rst:72 msgid "" "Installs ``pip`` relative to the given root directory rather than the root " "of the currently active virtual environment (if any) or the default root for " @@ -138,7 +145,7 @@ msgstr "" "安裝 ``pip`` 到給定的根目錄 (root directory) 的相對路徑,而不是目前虛擬環境" "(若存在)的根目錄,或目前 Python 安裝版所預設的根目錄。" -#: ../../library/ensurepip.rst:74 +#: ../../library/ensurepip.rst:78 msgid "" "Installs ``pip`` into the user site packages directory rather than globally " "for the current Python installation (this option is not permitted inside an " @@ -147,7 +154,7 @@ msgstr "" "安裝 ``pip`` 到使用者端的套件目錄,而不是全域安裝到目前的 Python 安裝版(此選" "項不允許在一啟動的虛擬環境中使用)。" -#: ../../library/ensurepip.rst:78 +#: ../../library/ensurepip.rst:82 msgid "" "By default, the scripts ``pipX`` and ``pipX.Y`` will be installed (where X.Y " "stands for the version of Python used to invoke ``ensurepip``). The scripts " @@ -156,42 +163,42 @@ msgstr "" "預設會安裝 ``pipX`` 和 ``pipX.Y`` 腳本(X.Y 代表用來叫用 ``ensurepip`` 的 " "Python 之版本)。安裝的腳本可透過兩個額外的命令列選項來控制:" -#: ../../library/ensurepip.rst:85 +#: ../../library/ensurepip.rst:89 msgid "" "If an alternate installation is requested, the ``pipX`` script will *not* be " "installed." msgstr "若要求一個替代安裝版,則\\ *不會*\\ 安裝 ``pipX`` 腳本。" -#: ../../library/ensurepip.rst:90 +#: ../../library/ensurepip.rst:94 msgid "" "If a \"default pip\" installation is requested, the ``pip`` script will be " "installed in addition to the two regular scripts." msgstr "若要求安裝「預設 pip」,則會安裝 ``pip`` 腳本,及 2 個常規腳本。" -#: ../../library/ensurepip.rst:93 +#: ../../library/ensurepip.rst:97 msgid "" "Providing both of the script selection options will trigger an exception." msgstr "提供兩種指令選項將會導致例外 (exception) 。" -#: ../../library/ensurepip.rst:96 +#: ../../library/ensurepip.rst:100 msgid "Module API" msgstr "模組 API" -#: ../../library/ensurepip.rst:98 +#: ../../library/ensurepip.rst:102 msgid ":mod:`ensurepip` exposes two functions for programmatic use:" msgstr ":mod:`ensurepip` 開放了兩個用於編寫程式的函式:" -#: ../../library/ensurepip.rst:102 +#: ../../library/ensurepip.rst:106 msgid "" "Returns a string specifying the available version of pip that will be " "installed when bootstrapping an environment." msgstr "回傳一個字串,用以標明初始建置時,安裝的 pip 的可行版本號。" -#: ../../library/ensurepip.rst:109 +#: ../../library/ensurepip.rst:113 msgid "Bootstraps ``pip`` into the current or designated environment." msgstr "在目前或指定的環境之中建立 ``pip``。" -#: ../../library/ensurepip.rst:111 +#: ../../library/ensurepip.rst:115 msgid "" "*root* specifies an alternative root directory to install relative to. If " "*root* is ``None``, then installation uses the default install location for " @@ -200,64 +207,64 @@ msgstr "" "*root* 指定一個替代的根目錄,作為安裝的相對路徑。若 *root* 為 ``None``,則安" "裝使用目前環境的預設安裝位置。" -#: ../../library/ensurepip.rst:115 +#: ../../library/ensurepip.rst:119 msgid "" "*upgrade* indicates whether or not to upgrade an existing installation of an " "earlier version of ``pip`` to the available version." msgstr "*upgrade* 指出是否要將一個既有的較早版本的 ``pip`` 升級至可用的新版。" -#: ../../library/ensurepip.rst:118 +#: ../../library/ensurepip.rst:122 msgid "" "*user* indicates whether to use the user scheme rather than installing " "globally." msgstr "*user* 指出是否要使用使用者的安裝方案而不是全域安裝。" -#: ../../library/ensurepip.rst:121 +#: ../../library/ensurepip.rst:125 msgid "" "By default, the scripts ``pipX`` and ``pipX.Y`` will be installed (where X.Y " "stands for the current version of Python)." msgstr "預設會安裝 ``pipX`` 和 ``pipX.Y`` 腳本(X.Y 代表 Python 的目前版本)。" -#: ../../library/ensurepip.rst:124 +#: ../../library/ensurepip.rst:128 msgid "If *altinstall* is set, then ``pipX`` will *not* be installed." msgstr "如果啟用了 *altinstall*,則不會安裝 ``pipX``。" -#: ../../library/ensurepip.rst:126 +#: ../../library/ensurepip.rst:130 msgid "" "If *default_pip* is set, then ``pip`` will be installed in addition to the " "two regular scripts." msgstr "如果啟用了 *default_pip*,則會安裝 ``pip``,以及 2 個常規腳本。" -#: ../../library/ensurepip.rst:129 +#: ../../library/ensurepip.rst:133 msgid "" "Setting both *altinstall* and *default_pip* will trigger :exc:`ValueError`." msgstr "同時啟用 *altinstall* 跟 *default_pip*,將會觸發 :exc:`ValueError`。" -#: ../../library/ensurepip.rst:132 +#: ../../library/ensurepip.rst:136 msgid "" "*verbosity* controls the level of output to :data:`sys.stdout` from the " "bootstrapping operation." msgstr "" "*verbosity* 用來控制初始建置操作內,對於 :data:`sys.stdout` 的輸出等級。" -#: ../../library/ensurepip.rst:135 +#: ../../library/ensurepip.rst:139 msgid "" "Raises an :ref:`auditing event ` ``ensurepip.bootstrap`` with " "argument ``root``." msgstr "" -"引發一個附帶引數 ``root`` 的\\ :ref:`稽核事件 ` " -"``ensurepip.bootstrap``。" +"引發一個附帶引數 ``root`` 的\\ :ref:`稽核事件 ` ``ensurepip." +"bootstrap``。" -#: ../../library/ensurepip.rst:139 +#: ../../library/ensurepip.rst:143 msgid "" -"The bootstrapping process has side effects on both ``sys.path`` and " -"``os.environ``. Invoking the command line interface in a subprocess instead " +"The bootstrapping process has side effects on both ``sys.path`` and ``os." +"environ``. Invoking the command line interface in a subprocess instead " "allows these side effects to be avoided." msgstr "" "初始建置的過程對於 ``sys.path`` 及 ``os.environ`` 均有副作用。改為在一子行程 " "(subprocess) 呼叫命令列介面可避免這些副作用。" -#: ../../library/ensurepip.rst:145 +#: ../../library/ensurepip.rst:149 msgid "" "The bootstrapping process may install additional modules required by " "``pip``, but other software should not assume those dependencies will always " diff --git a/library/enum.po b/library/enum.po index d2e7a9d28c5..5b173aab1ca 100644 --- a/library/enum.po +++ b/library/enum.po @@ -1,12 +1,12 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-08-13 00:16+0000\n" +"POT-Creation-Date: 2025-12-01 00:17+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-" @@ -25,6 +25,10 @@ msgstr ":mod:`!enum` --- 對列舉的支援" msgid "**Source code:** :source:`Lib/enum.py`" msgstr "**原始碼:**\\ :source:`Lib/enum.py`" +#: ../../library/enum.rst:16 +msgid "Important" +msgstr "重點資訊" + #: ../../library/enum.rst:18 msgid "" "This page contains the API reference information. For tutorial information " @@ -647,6 +651,7 @@ msgstr "" #: ../../library/enum.rst:318 msgid "" +">>> from enum import Enum\n" ">>> from datetime import date\n" ">>> class Weekday(Enum):\n" "... MONDAY = 1\n" @@ -664,6 +669,7 @@ msgid "" "['__class__', '__doc__', '__eq__', '__hash__', '__module__', 'name', " "'today', 'value']" msgstr "" +">>> from enum import Enum\n" ">>> from datetime import date\n" ">>> class Weekday(Enum):\n" "... MONDAY = 1\n" @@ -685,11 +691,11 @@ msgstr "" msgid "name" msgstr "name" -#: ../../library/enum.rst:336 +#: ../../library/enum.rst:337 msgid "The name of the member being defined (e.g. 'RED')." msgstr "定義的成員名稱(例如 'RED')。" -#: ../../library/enum.rst:337 +#: ../../library/enum.rst:338 msgid "The start value for the Enum; the default is 1." msgstr "列舉的開始值,預設為 1。" @@ -697,7 +703,7 @@ msgstr "列舉的開始值,預設為 1。" msgid "count" msgstr "count" -#: ../../library/enum.rst:338 +#: ../../library/enum.rst:339 msgid "The number of members currently defined, not including this one." msgstr "已定義的成員數量,不包含目前這一個。" @@ -705,19 +711,19 @@ msgstr "已定義的成員數量,不包含目前這一個。" msgid "last_values" msgstr "last_values" -#: ../../library/enum.rst:339 +#: ../../library/enum.rst:340 msgid "A list of the previous values." msgstr "一個之前值的串列。" -#: ../../library/enum.rst:341 +#: ../../library/enum.rst:342 msgid "" "A *staticmethod* that is used to determine the next value returned by :class:" "`auto`::" msgstr "一個 *staticmethod*,用來決定 :class:`auto` 下一個要回傳的值的: ::" -#: ../../library/enum.rst:344 +#: ../../library/enum.rst:345 msgid "" -">>> from enum import auto\n" +">>> from enum import auto, Enum\n" ">>> class PowersOfThree(Enum):\n" "... @staticmethod\n" "... def _generate_next_value_(name, start, count, last_values):\n" @@ -728,7 +734,7 @@ msgid "" ">>> PowersOfThree.SECOND.value\n" "9" msgstr "" -">>> from enum import auto\n" +">>> from enum import auto, Enum\n" ">>> class PowersOfThree(Enum):\n" "... @staticmethod\n" "... def _generate_next_value_(name, start, count, last_values):\n" @@ -739,7 +745,7 @@ msgstr "" ">>> PowersOfThree.SECOND.value\n" "9" -#: ../../library/enum.rst:357 +#: ../../library/enum.rst:358 msgid "" "By default, does nothing. If multiple values are given in the member " "assignment, those values become separate arguments to ``__init__``; e.g." @@ -747,19 +753,19 @@ msgstr "" "預設情況下,不執行任何操作。如果在成員賦值中給出多個值,這些值將成為與 " "``__init__`` 分別的引數;例如" -#: ../../library/enum.rst:364 +#: ../../library/enum.rst:365 msgid "" "``Weekday.__init__()`` would be called as ``Weekday.__init__(self, 1, " "'Mon')``" msgstr "``Weekday.__init__()`` 將被稱為 ``Weekday.__init__(self, 1, 'Mon')``" -#: ../../library/enum.rst:368 +#: ../../library/enum.rst:369 msgid "" "A *classmethod* that is used to further configure subsequent subclasses. By " "default, does nothing." msgstr "一個 *classmethod*,用來進一步設定後續的子類別,預設不做任何事。" -#: ../../library/enum.rst:373 +#: ../../library/enum.rst:374 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::" @@ -767,9 +773,9 @@ msgstr "" "一個 *classmethod*,用來查詢在 *cls* 裡找不到的值。預設不做任何事,但可以被覆" "寫以實作客製化的搜尋行為: ::" -#: ../../library/enum.rst:376 +#: ../../library/enum.rst:377 msgid "" -">>> from enum import StrEnum\n" +">>> from enum import auto, StrEnum\n" ">>> class Build(StrEnum):\n" "... DEBUG = auto()\n" "... OPTIMIZED = auto()\n" @@ -786,7 +792,7 @@ msgid "" ">>> Build('deBUG')\n" "" msgstr "" -">>> from enum import StrEnum\n" +">>> from enum import auto, StrEnum\n" ">>> class Build(StrEnum):\n" "... DEBUG = auto()\n" "... OPTIMIZED = auto()\n" @@ -803,7 +809,7 @@ msgstr "" ">>> Build('deBUG')\n" "" -#: ../../library/enum.rst:395 +#: ../../library/enum.rst:396 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 " @@ -812,12 +818,12 @@ msgstr "" "預設情況下不存在。如果有指定,無論是在列舉類別定義中還是在 mixin 類別中(例" "如 ``int``\\ ),都將傳遞成員賦值中給出的所有值;例如" -#: ../../library/enum.rst:403 +#: ../../library/enum.rst:404 msgid "" "results in the call ``int('1a', 16)`` and a value of ``26`` for the member." msgstr "會產生呼叫 ``int('1a', 16)`` 而該成員的值為 ``26``。" -#: ../../library/enum.rst:407 +#: ../../library/enum.rst:408 msgid "" "When writing a custom ``__new__``, do not use ``super().__new__`` -- call " "the appropriate ``__new__`` instead." @@ -825,7 +831,7 @@ msgstr "" "當寫自訂的 ``__new__`` 時,不要使用 ``super().__new__``,而是要呼叫適當的 " "``__new__``。" -#: ../../library/enum.rst:412 +#: ../../library/enum.rst:413 msgid "" "Returns the string used for *repr()* calls. By default, returns the *Enum* " "name, member name, and value, but can be overridden::" @@ -833,8 +839,9 @@ msgstr "" "回傳呼叫 *repr()* 時使用的字串。預設回傳 *Enum* 名稱、成員名稱及值,但可以被" "覆寫: ::" -#: ../../library/enum.rst:415 +#: ../../library/enum.rst:416 msgid "" +">>> from enum import auto, Enum\n" ">>> class OtherStyle(Enum):\n" "... ALTERNATE = auto()\n" "... OTHER = auto()\n" @@ -847,6 +854,7 @@ msgid "" "ALTERNATE}\"\n" "(OtherStyle.ALTERNATE, 'OtherStyle.ALTERNATE', 'OtherStyle.ALTERNATE')" msgstr "" +">>> from enum import auto, Enum\n" ">>> class OtherStyle(Enum):\n" "... ALTERNATE = auto()\n" "... OTHER = auto()\n" @@ -859,7 +867,7 @@ msgstr "" "ALTERNATE}\"\n" "(OtherStyle.ALTERNATE, 'OtherStyle.ALTERNATE', 'OtherStyle.ALTERNATE')" -#: ../../library/enum.rst:428 +#: ../../library/enum.rst:430 msgid "" "Returns the string used for *str()* calls. By default, returns the *Enum* " "name and member name, but can be overridden::" @@ -867,8 +875,9 @@ msgstr "" "回傳呼叫 *str()* 時使用的字串。預設回傳 *Enum* 名稱及成員名稱,但可以被覆" "寫: ::" -#: ../../library/enum.rst:431 +#: ../../library/enum.rst:433 msgid "" +">>> from enum import auto, Enum\n" ">>> class OtherStyle(Enum):\n" "... ALTERNATE = auto()\n" "... OTHER = auto()\n" @@ -880,6 +889,7 @@ msgid "" "ALTERNATE}\"\n" "(, 'ALTERNATE', 'ALTERNATE')" msgstr "" +">>> from enum import auto, Enum\n" ">>> class OtherStyle(Enum):\n" "... ALTERNATE = auto()\n" "... OTHER = auto()\n" @@ -891,7 +901,7 @@ msgstr "" "ALTERNATE}\"\n" "(, 'ALTERNATE', 'ALTERNATE')" -#: ../../library/enum.rst:443 +#: ../../library/enum.rst:446 msgid "" "Returns the string used for *format()* and *f-string* calls. By default, " "returns :meth:`__str__` return value, but can be overridden::" @@ -899,8 +909,9 @@ msgstr "" "回傳呼叫 *format()* 及 *f-string* 時使用的字串。預設回傳 :meth:`__str__` 的回" "傳值,但可以被覆寫: ::" -#: ../../library/enum.rst:446 +#: ../../library/enum.rst:449 msgid "" +">>> from enum import auto, Enum\n" ">>> class OtherStyle(Enum):\n" "... ALTERNATE = auto()\n" "... OTHER = auto()\n" @@ -912,6 +923,7 @@ msgid "" "ALTERNATE}\"\n" "(, 'OtherStyle.ALTERNATE', 'ALTERNATE')" msgstr "" +">>> from enum import auto, Enum\n" ">>> class OtherStyle(Enum):\n" "... ALTERNATE = auto()\n" "... OTHER = auto()\n" @@ -923,21 +935,21 @@ msgstr "" "ALTERNATE}\"\n" "(, 'OtherStyle.ALTERNATE', 'ALTERNATE')" -#: ../../library/enum.rst:458 +#: ../../library/enum.rst:462 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:461 +#: ../../library/enum.rst:465 msgid "Added :ref:`enum-dataclass-support`" msgstr "新增 :ref:`enum-dataclass-support`" -#: ../../library/enum.rst:465 +#: ../../library/enum.rst:469 msgid "Adds a new name as an alias to an existing member::" msgstr "新增一個名稱作為現有成員的別名: ::" -#: ../../library/enum.rst:467 +#: ../../library/enum.rst:471 msgid "" ">>> Color.RED._add_alias_(\"ERROR\")\n" ">>> Color.ERROR\n" @@ -947,18 +959,17 @@ msgstr "" ">>> Color.ERROR\n" "" -#: ../../library/enum.rst:471 +#: ../../library/enum.rst:475 msgid "" "Raises a :exc:`NameError` if the name is already assigned to a different " "member." -msgstr "" -"如果該名稱已被指派給不同的成員,則會引發 :exc:`NameError`。" +msgstr "如果該名稱已經被指派給不同的成員,則會引發 :exc:`NameError`。" -#: ../../library/enum.rst:477 +#: ../../library/enum.rst:481 msgid "Adds a new value as an alias to an existing member::" msgstr "新增一個值作為現有成員的別名: ::" -#: ../../library/enum.rst:479 +#: ../../library/enum.rst:483 msgid "" ">>> Color.RED._add_value_alias_(42)\n" ">>> Color(42)\n" @@ -968,14 +979,13 @@ msgstr "" ">>> Color(42)\n" "" -#: ../../library/enum.rst:483 +#: ../../library/enum.rst:487 msgid "" "Raises a :exc:`ValueError` if the value is already linked with a different " "member." -msgstr "" -"如果該值已與不同成員連結,則會引發 :exc:`ValueError`。" +msgstr "如果該值已經被連結到不同的成員,則會引發 :exc:`ValueError`。" -#: ../../library/enum.rst:490 +#: ../../library/enum.rst:494 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 " @@ -985,13 +995,13 @@ msgstr "" "*IntEnum* 和 :class:`Enum` 一樣,但其成員同時也是整數而可以被用在任何使用整數" "的地方。如果 *IntEnum* 成員經過任何整數運算,結果值會失去其列舉狀態。" -#: ../../library/enum.rst:511 +#: ../../library/enum.rst:515 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:514 +#: ../../library/enum.rst:518 msgid "" ":meth:`~object.__str__` is now :meth:`!int.__str__` to better support the " "*replacement of existing constants* use-case. :meth:`~object.__format__` was " @@ -1001,7 +1011,7 @@ msgstr "" "境,:meth:`~object.__str__` 現在會是 :meth:`!int.__str__`。為了同樣的理由,:" "meth:`~object.__format__` 已經是 :meth:`!int.__format__`。" -#: ../../library/enum.rst:521 +#: ../../library/enum.rst:525 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 " @@ -1011,7 +1021,7 @@ msgstr "" "*StrEnum* 和 :class:`Enum` 一樣,但其成員同時也是字串而可以被用在幾乎所有使用" "字串的地方。*StrEnum* 成員經過任何字串操作的結果會不再是列舉的一部份。" -#: ../../library/enum.rst:542 +#: ../../library/enum.rst:546 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 " @@ -1022,13 +1032,13 @@ msgstr "" "是 ``type(unknown) == str`` 而不是 ``isinstance(unknown, str)``),在這些地方" "你需要使用 ``str(MyStrEnum.MY_MEMBER)``。" -#: ../../library/enum.rst:549 +#: ../../library/enum.rst:553 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:554 +#: ../../library/enum.rst:558 msgid "" ":meth:`~object.__str__` is :meth:`!str.__str__` to better support the " "*replacement of existing constants* use-case. :meth:`~object.__format__` is " @@ -1038,7 +1048,7 @@ msgstr "" "境,:meth:`~object.__str__` 現在會是 :meth:`!str.__str__`。為了同樣的理由,:" "meth:`~object.__format__` 也會是 :meth:`!str.__format__`。" -#: ../../library/enum.rst:562 +#: ../../library/enum.rst:566 msgid "" "``Flag`` is the same as :class:`Enum`, but its members support the bitwise " "operators ``&`` (*AND*), ``|`` (*OR*), ``^`` (*XOR*), and ``~`` (*INVERT*); " @@ -1048,11 +1058,11 @@ msgstr "" "(*OR*)、``^`` (*XOR*) 和 ``~`` (*INVERT*);這些操作的結果是列舉的成員(的別" "名)。" -#: ../../library/enum.rst:568 +#: ../../library/enum.rst:572 msgid "Returns *True* if value is in self::" msgstr "如果 value 在 self 裡則回傳 *True*: ::" -#: ../../library/enum.rst:570 +#: ../../library/enum.rst:574 msgid "" ">>> from enum import Flag, auto\n" ">>> class Color(Flag):\n" @@ -1088,11 +1098,11 @@ msgstr "" ">>> white in purple\n" "False" -#: ../../library/enum.rst:589 +#: ../../library/enum.rst:593 msgid "Returns all contained non-alias members::" msgstr "回傳所有包含的非別名成員: ::" -#: ../../library/enum.rst:591 +#: ../../library/enum.rst:595 msgid "" ">>> list(Color.RED)\n" "[]\n" @@ -1104,11 +1114,11 @@ msgstr "" ">>> list(purple)\n" "[, ]" -#: ../../library/enum.rst:600 +#: ../../library/enum.rst:604 msgid "Returns number of members in flag::" msgstr "回傳旗標裡的成員數量: ::" -#: ../../library/enum.rst:602 +#: ../../library/enum.rst:606 msgid "" ">>> len(Color.GREEN)\n" "1\n" @@ -1120,11 +1130,11 @@ msgstr "" ">>> len(white)\n" "3" -#: ../../library/enum.rst:611 +#: ../../library/enum.rst:615 msgid "Returns *True* if any members in flag, *False* otherwise::" msgstr "如果成員在旗標裡則回傳 *True*,否則回傳 *False*: ::" -#: ../../library/enum.rst:613 +#: ../../library/enum.rst:617 msgid "" ">>> bool(Color.GREEN)\n" "True\n" @@ -1142,11 +1152,11 @@ msgstr "" ">>> bool(black)\n" "False" -#: ../../library/enum.rst:623 +#: ../../library/enum.rst:627 msgid "Returns current flag binary or'ed with other::" msgstr "回傳和 other 做 OR 過後的二進位旗標: ::" -#: ../../library/enum.rst:625 +#: ../../library/enum.rst:629 msgid "" ">>> Color.RED | Color.GREEN\n" "" @@ -1154,11 +1164,11 @@ msgstr "" ">>> Color.RED | Color.GREEN\n" "" -#: ../../library/enum.rst:630 +#: ../../library/enum.rst:634 msgid "Returns current flag binary and'ed with other::" msgstr "回傳和 other 做 AND 過後的二進位旗標: ::" -#: ../../library/enum.rst:632 +#: ../../library/enum.rst:636 msgid "" ">>> purple & white\n" "\n" @@ -1170,11 +1180,11 @@ msgstr "" ">>> purple & Color.GREEN\n" "" -#: ../../library/enum.rst:639 +#: ../../library/enum.rst:643 msgid "Returns current flag binary xor'ed with other::" msgstr "回傳和 other 做 XOR 過後的二進位旗標: ::" -#: ../../library/enum.rst:641 +#: ../../library/enum.rst:645 msgid "" ">>> purple ^ white\n" "\n" @@ -1186,11 +1196,11 @@ msgstr "" ">>> purple ^ Color.GREEN\n" "" -#: ../../library/enum.rst:648 +#: ../../library/enum.rst:652 msgid "Returns all the flags in *type(self)* that are not in *self*::" msgstr "回傳所有在 *type(self)* 但不在 *self* 裡的旗標: ::" -#: ../../library/enum.rst:650 +#: ../../library/enum.rst:654 msgid "" ">>> ~white\n" "\n" @@ -1206,7 +1216,7 @@ msgstr "" ">>> ~Color.RED\n" "" -#: ../../library/enum.rst:659 +#: ../../library/enum.rst:663 msgid "" "Function used to format any remaining unnamed numeric values. Default is " "the value's repr; common choices are :func:`hex` and :func:`oct`." @@ -1214,17 +1224,17 @@ msgstr "" "用來格式化任何剩下未命名數值的函式。預設是值的 repr,常見選擇是 :func:`hex` " "和 :func:`oct`。" -#: ../../library/enum.rst:664 +#: ../../library/enum.rst:668 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:667 -msgid "The *repr()* of zero-valued flags has changed. It is now::" -msgstr "值為 0 的旗標的 *repr()* 已改變。現在是: ::" +#: ../../library/enum.rst:671 +msgid "The *repr()* of zero-valued flags has changed. It is now:" +msgstr "值為 0 的旗標的 *repr()* 已改變。現在是:" -#: ../../library/enum.rst:675 +#: ../../library/enum.rst:679 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." @@ -1232,13 +1242,13 @@ msgstr "" "``IntFlag`` 和 :class:`Flag` 一樣,但其成員同時也是整數而可以被用在任何使用整" "數的地方。" -#: ../../library/enum.rst:689 +#: ../../library/enum.rst:693 msgid "" "If any integer operation is performed with an *IntFlag* member, the result " "is not an *IntFlag*::" msgstr "如果 *IntFlag* 成員經過任何整數運算,其結果不是 *IntFlag*: ::" -#: ../../library/enum.rst:692 +#: ../../library/enum.rst:696 msgid "" ">>> Color.RED + 2\n" "3" @@ -1246,32 +1256,40 @@ msgstr "" ">>> Color.RED + 2\n" "3" -#: ../../library/enum.rst:695 +#: ../../library/enum.rst:699 msgid "If a :class:`Flag` operation is performed with an *IntFlag* member and:" msgstr "如果 *IntFlag* 成員經過 :class:`Flag` 操作且:" -#: ../../library/enum.rst:697 +#: ../../library/enum.rst:701 msgid "the result is a valid *IntFlag*: an *IntFlag* is returned" msgstr "結果是合法的 *IntFlag*:回傳 *IntFlag*" -#: ../../library/enum.rst:698 +#: ../../library/enum.rst:702 msgid "" "the result is not a valid *IntFlag*: the result depends on the :class:" "`FlagBoundary` setting" msgstr "結果不是合法的 *IntFlag*:結果會根據 :class:`FlagBoundary` 的設定" -#: ../../library/enum.rst:700 -msgid "The :func:`repr` of unnamed zero-valued flags has changed. It is now:" -msgstr "未命名且值為 0 的旗標的 :func:`repr` 已改變。現在是:" +#: ../../library/enum.rst:704 +msgid "The :func:`repr` of unnamed zero-valued flags has changed. It is now::" +msgstr "未命名且值為 0 的旗標的 :func:`repr` 已改變。現在是: ::" + +#: ../../library/enum.rst:706 +msgid "" +">>> Color(0)\n" +"" +msgstr "" +">>> Color(0)\n" +"" -#: ../../library/enum.rst:707 +#: ../../library/enum.rst:711 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:712 +#: ../../library/enum.rst:716 msgid "" ":meth:`~object.__str__` is now :meth:`!int.__str__` to better support the " "*replacement of existing constants* use-case. :meth:`~object.__format__` " @@ -1281,7 +1299,7 @@ msgstr "" "境,:meth:`~object.__str__` 現在會是 :meth:`!int.__str__`。為了同樣的理由,:" "meth:`~object.__format__` 已經是 :meth:`!int.__format__`。" -#: ../../library/enum.rst:716 +#: ../../library/enum.rst:720 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 " @@ -1290,7 +1308,7 @@ msgstr "" ":class:`!IntFlag` 的反轉 (inversion) 現在會回傳正值,該值是不在給定旗標的所有" "旗標聯集,而不是一個負值。這符合現有 :class:`Flag` 的行為。" -#: ../../library/enum.rst:722 +#: ../../library/enum.rst:726 msgid "" ":class:`!ReprEnum` uses the :meth:`repr() ` of :class:`Enum`, " "but the :class:`str() ` of the mixed-in data type:" @@ -1298,15 +1316,15 @@ msgstr "" ":class:`!ReprEnum` 使用 :class:`Enum` 的 :meth:`repr() `,但使" "用混合資料型別的 :class:`str() `:" -#: ../../library/enum.rst:725 +#: ../../library/enum.rst:729 msgid ":meth:`!int.__str__` for :class:`IntEnum` and :class:`IntFlag`" msgstr "對 :class:`IntEnum` 和 :class:`IntFlag` 是 :meth:`!int.__str__`" -#: ../../library/enum.rst:726 +#: ../../library/enum.rst:730 msgid ":meth:`!str.__str__` for :class:`StrEnum`" msgstr "對 :class:`StrEnum` 是 :meth:`!str.__str__`" -#: ../../library/enum.rst:728 +#: ../../library/enum.rst:732 msgid "" "Inherit from :class:`!ReprEnum` to keep the :class:`str() ` / :func:" "`format` of the mixed-in data type instead of using the :class:`Enum`-" @@ -1315,7 +1333,7 @@ msgstr "" "繼承 :class:`!ReprEnum` 來保留混合資料型別的 :class:`str() ` / :func:" "`format`,而不是使用 :class:`Enum` 預設的 :meth:`str() `。" -#: ../../library/enum.rst:737 +#: ../../library/enum.rst:741 msgid "" "*EnumCheck* contains the options used by the :func:`verify` decorator to " "ensure various constraints; failed constraints result in a :exc:`ValueError`." @@ -1323,11 +1341,11 @@ msgstr "" "*EnumCheck* 包含 :func:`verify` 裝飾器使用的選項,以確保多樣的限制,不符合限" "制會產生 :exc:`ValueError`。" -#: ../../library/enum.rst:742 +#: ../../library/enum.rst:746 msgid "Ensure that each value has only one name::" msgstr "確保每個值只有一個名稱: ::" -#: ../../library/enum.rst:744 +#: ../../library/enum.rst:748 msgid "" ">>> from enum import Enum, verify, UNIQUE\n" ">>> @verify(UNIQUE)\n" @@ -1351,13 +1369,13 @@ msgstr "" "...\n" "ValueError: aliases found in : CRIMSON -> RED" -#: ../../library/enum.rst:758 +#: ../../library/enum.rst:762 msgid "" "Ensure that there are no missing values between the lowest-valued member and " "the highest-valued member::" msgstr "確保在最小值成員跟最大值成員間沒有缺少值: ::" -#: ../../library/enum.rst:761 +#: ../../library/enum.rst:765 msgid "" ">>> from enum import Enum, verify, CONTINUOUS\n" ">>> @verify(CONTINUOUS)\n" @@ -1379,7 +1397,7 @@ msgstr "" "...\n" "ValueError: invalid enum 'Color': missing values 3, 4" -#: ../../library/enum.rst:773 +#: ../../library/enum.rst:777 msgid "" "Ensure that any flag groups/masks contain only named flags -- useful when " "values are specified instead of being generated by :func:`auto`::" @@ -1387,7 +1405,7 @@ msgstr "" "確保任何旗標群組 / 遮罩只包含命名旗標 -- 當值是用指定而不是透過 :func:`auto` " "產生時是很實用的: ::" -#: ../../library/enum.rst:776 +#: ../../library/enum.rst:780 msgid "" ">>> from enum import Flag, verify, NAMED_FLAGS\n" ">>> @verify(NAMED_FLAGS)\n" @@ -1415,24 +1433,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:790 +#: ../../library/enum.rst:794 msgid "" "CONTINUOUS and NAMED_FLAGS are designed to work with integer-valued members." msgstr "CONTINUOUS 和 NAMED_FLAGS 是設計用來運作在整數值的成員上。" -#: ../../library/enum.rst:796 +#: ../../library/enum.rst:800 msgid "" "``FlagBoundary`` controls how out-of-range values are handled in :class:" "`Flag` and its subclasses." msgstr "``FlagBoundary`` 控制在 :class:`Flag` 及其子類別中如何處理範圍外的值。" -#: ../../library/enum.rst:801 +#: ../../library/enum.rst:805 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:804 +#: ../../library/enum.rst:808 msgid "" ">>> from enum import Flag, STRICT, auto\n" ">>> class StrictFlag(Flag, boundary=STRICT):\n" @@ -1460,13 +1478,13 @@ msgstr "" " given 0b0 10100\n" " allowed 0b0 00111" -#: ../../library/enum.rst:819 +#: ../../library/enum.rst:823 msgid "" "Out-of-range values have invalid values removed, leaving a valid :class:" "`Flag` value::" msgstr "會移除範圍外的值中的非法值,留下合法的 :class:`Flag` 值: ::" -#: ../../library/enum.rst:822 +#: ../../library/enum.rst:826 msgid "" ">>> from enum import Flag, CONFORM, auto\n" ">>> class ConformFlag(Flag, boundary=CONFORM):\n" @@ -1486,13 +1504,13 @@ msgstr "" ">>> ConformFlag(2**2 + 2**4)\n" "" -#: ../../library/enum.rst:833 +#: ../../library/enum.rst:837 msgid "" "Out-of-range values lose their :class:`Flag` membership and revert to :class:" "`int`." msgstr "範圍外的值會失去它們的 :class:`Flag` 成員資格且恢復成 :class:`int`。" -#: ../../library/enum.rst:846 +#: ../../library/enum.rst:850 msgid "" "Out-of-range values are kept, and the :class:`Flag` membership is kept. This " "is the default for :class:`IntFlag`::" @@ -1500,7 +1518,7 @@ msgstr "" "範圍外的值會被保留,:class:`Flag` 成員資格也會被保留。這是 :class:`IntFlag` " "的預設行為: ::" -#: ../../library/enum.rst:849 +#: ../../library/enum.rst:853 msgid "" ">>> from enum import Flag, KEEP, auto\n" ">>> class KeepFlag(Flag, boundary=KEEP):\n" @@ -1520,7 +1538,7 @@ msgstr "" ">>> KeepFlag(2**2 + 2**4)\n" "" -#: ../../library/enum.rst:862 +#: ../../library/enum.rst:866 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 " @@ -1534,7 +1552,7 @@ msgstr "" "如讓每個成員有多個值。它應該在被呼叫時帶上正在建立的列舉類別名稱,否則私有名" "稱和內部類別將無法被正確處理。" -#: ../../library/enum.rst:869 +#: ../../library/enum.rst:873 msgid "" "Note that only the :class:`~collections.abc.MutableMapping` interface (:meth:" "`~object.__setitem__` and :meth:`~dict.update`) is overridden. It may be " @@ -1545,15 +1563,15 @@ msgstr "" "__setitem__` 和 :meth:`~dict.update`)被覆寫。可能可以使用其他 :class:`!" "dict` 操作來繞過檢查,例如 :meth:`|= `。" -#: ../../library/enum.rst:876 +#: ../../library/enum.rst:880 msgid "A list of member names." msgstr "一個成員名稱的串列。" -#: ../../library/enum.rst:883 +#: ../../library/enum.rst:887 msgid "Supported ``__dunder__`` names" msgstr "支援的 ``__dunder__`` 名稱" -#: ../../library/enum.rst:885 +#: ../../library/enum.rst:889 msgid "" ":attr:`~EnumType.__members__` is a read-only ordered mapping of " "``member_name``:``member`` items. It is only available on the class." @@ -1561,7 +1579,7 @@ msgstr "" ":attr:`~EnumType.__members__` 是一個唯讀有序的\\ ``成員名稱``:``成員``\\ 項" "目的對映。只有在類別上可用。" -#: ../../library/enum.rst:888 +#: ../../library/enum.rst:892 msgid "" ":meth:`~Enum.__new__`, if specified, must create and return the enum " "members; it is also a very good idea to set the member's :attr:`!_value_` " @@ -1571,26 +1589,26 @@ msgstr "" "的 :attr:`!_value_` 也是一個很好的主意。一旦所有成員都建立之後就不會再被用" "到。" -#: ../../library/enum.rst:894 +#: ../../library/enum.rst:898 msgid "Supported ``_sunder_`` names" msgstr "支援的 ``_sunder_`` 名稱" -#: ../../library/enum.rst:896 +#: ../../library/enum.rst:900 msgid ":attr:`~Enum._name_` -- name of the member" msgstr ":attr:`~Enum._name_` -- 成員名稱" -#: ../../library/enum.rst:897 +#: ../../library/enum.rst:901 msgid ":attr:`~Enum._value_` -- value of the member; can be set in ``__new__``" msgstr ":attr:`~Enum._value_` -- 成員的值;可以在 ``__new__`` 設定" -#: ../../library/enum.rst:898 +#: ../../library/enum.rst:902 msgid "" ":meth:`~Enum._missing_` -- a lookup function used when a value is not found; " "may be overridden" msgstr "" ":meth:`~Enum._missing_` -- 當值沒有被找到時會使用的查詢函式;可以被覆寫" -#: ../../library/enum.rst:900 +#: ../../library/enum.rst:904 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 " @@ -1599,7 +1617,7 @@ msgstr "" ":attr:`~Enum._ignore_` -- 一個名稱的串列,可以是 :class:`list` 或 :class:" "`str`,它不會被轉換成成員,且在最後的類別上會被移除" -#: ../../library/enum.rst:903 +#: ../../library/enum.rst:907 msgid "" ":attr:`~Enum._order_` -- no longer used, kept for backward compatibility " "(class attribute, removed during class creation)" @@ -1607,40 +1625,40 @@ msgstr "" ":attr:`~Enum._order_` -- 不再被使用,僅為了向後相容而保留(類別屬性,在類別建" "立時移除)" -#: ../../library/enum.rst:905 +#: ../../library/enum.rst:909 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:910 +#: ../../library/enum.rst:914 msgid "" "For standard :class:`Enum` classes the next value chosen is the highest " "value seen incremented by one." msgstr "" "對標準的 :class:`Enum` 類別來說,下一個被選擇的值是所看過的最大值加一。" -#: ../../library/enum.rst:913 +#: ../../library/enum.rst:917 msgid "" "For :class:`Flag` classes the next value chosen will be the next highest " "power-of-two." msgstr "" "對 :class:`Flag` 類別來說,下一個被選擇的值是下一個最大的 2 的次方的數字。" -#: ../../library/enum.rst:916 +#: ../../library/enum.rst:920 msgid "" ":meth:`~Enum._add_alias_` -- adds a new name as an alias to an existing " "member." msgstr ":meth:`~Enum._add_alias_` -- 新增一個名稱作為現有成員的別名。" -#: ../../library/enum.rst:918 +#: ../../library/enum.rst:922 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:921 +#: ../../library/enum.rst:925 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:" @@ -1648,30 +1666,30 @@ msgstr "" "雖然 ``_sunder_`` 名稱通常保留用於 :class:`Enum` 類別的進一步開發而不能被使" "用,但有些是明確允許的:" -#: ../../library/enum.rst:924 +#: ../../library/enum.rst:928 msgid "" "``_repr_*`` (e.g. ``_repr_html_``), as used in `IPython's rich display`_" msgstr "" "``_repr_*``\\ (例如 ``_repr_html_``),例如用於 `IPython 的豐富顯示 " -"`_" +"`_" -#: ../../library/enum.rst:926 +#: ../../library/enum.rst:930 msgid "``_missing_``, ``_order_``, ``_generate_next_value_``" msgstr "``_missing_``、``_order_``、``_generate_next_value_``" -#: ../../library/enum.rst:927 +#: ../../library/enum.rst:931 msgid "``_ignore_``" msgstr "``_ignore_``" -#: ../../library/enum.rst:928 +#: ../../library/enum.rst:932 msgid "``_add_alias_``, ``_add_value_alias_``, ``_repr_*``" msgstr "``_add_alias_``、``_add_value_alias_``、``_repr_*``" -#: ../../library/enum.rst:934 +#: ../../library/enum.rst:938 msgid "Utilities and Decorators" msgstr "通用項目與裝飾器" -#: ../../library/enum.rst:938 +#: ../../library/enum.rst:942 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 " @@ -1687,16 +1705,16 @@ msgstr "" "`IntFlag` 來說,是第一個比最大值還大的 2 的次方的數字;對 :class:`StrEnum` 來" "說,是成員名稱的小寫版本。如果混用 *auto()* 和手動指定值的話要特別注意。" -#: ../../library/enum.rst:946 +#: ../../library/enum.rst:950 msgid "" "*auto* instances are only resolved when at the top level of an assignment:" msgstr "*auto* 實例只有在最上層的賦值時才會被解析:" -#: ../../library/enum.rst:948 +#: ../../library/enum.rst:952 msgid "``FIRST = auto()`` will work (auto() is replaced with ``1``);" msgstr "``FIRST = auto()`` 可以運作(auto() 會被取代成 ``1``)" -#: ../../library/enum.rst:949 +#: ../../library/enum.rst:953 msgid "" "``SECOND = auto(), -2`` will work (auto is replaced with ``2``, so ``2, -2`` " "is used to create the ``SECOND`` enum member;" @@ -1704,7 +1722,7 @@ msgstr "" "``SECOND = auto(), -2`` 可以運作(auto 會被取代成 ``2``, 因此 ``2, -2`` 會被" "用來建立列舉成員 ``SECOND``;" -#: ../../library/enum.rst:951 +#: ../../library/enum.rst:955 msgid "" "``THREE = [auto(), -3]`` will *not* work (``, -3`` is used to " "create the ``THREE`` enum member)" @@ -1712,19 +1730,19 @@ msgstr "" "``THREE = [auto(), -3]`` *無法*\\ 運作(\\ ``, -3`` 會被用來建立列" "舉成員 ``THREE``)" -#: ../../library/enum.rst:956 +#: ../../library/enum.rst:960 msgid "" "In prior versions, ``auto()`` had to be the only thing on the assignment " "line to work properly." msgstr "在之前的版本中,``auto()`` 必須是賦值行裡的唯一內容才能運作正確。" -#: ../../library/enum.rst:959 +#: ../../library/enum.rst:963 msgid "" "``_generate_next_value_`` can be overridden to customize the values used by " "*auto*." msgstr "可以覆寫 ``_generate_next_value_`` 來客製 *auto* 使用的值。" -#: ../../library/enum.rst:962 +#: ../../library/enum.rst:966 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 " @@ -1733,7 +1751,7 @@ msgstr "" "在 3.13 預設 ``_generate_next_value_`` 總是回傳最大的成員值加一,如果任何成員" "是不相容的型別就會失敗。" -#: ../../library/enum.rst:968 +#: ../../library/enum.rst:972 msgid "" "A decorator similar to the built-in *property*, but specifically for " "enumerations. It allows member attributes to have the same names as members " @@ -1742,7 +1760,7 @@ msgstr "" "和內建的 *property* 相似的裝飾器,但只專門針對列舉。它允許成員屬性和成員本身" "有相同名稱。" -#: ../../library/enum.rst:972 +#: ../../library/enum.rst:976 msgid "" "the *property* and the member must be defined in separate classes; for " "example, the *value* and *name* attributes are defined in the *Enum* class, " @@ -1752,7 +1770,7 @@ msgstr "" "*屬性*\\ 和成員必須定義在分開的類別裡;例如 *value* 和 *name* 屬性定義在 " "*Enum* 類別而 *Enum* 子類別可以定義成員名稱為 ``value`` 和 ``name``。" -#: ../../library/enum.rst:981 +#: ../../library/enum.rst:985 msgid "" "A :keyword:`class` decorator specifically for enumerations. It searches an " "enumeration's :attr:`~EnumType.__members__`, gathering any aliases it finds; " @@ -1762,7 +1780,7 @@ msgstr "" "__members__`,蒐集任何它找到的別名;如果有找到任何別名則引發 :exc:" "`ValueError` 並附上細節: ::" -#: ../../library/enum.rst:985 +#: ../../library/enum.rst:989 msgid "" ">>> from enum import Enum, unique\n" ">>> @unique\n" @@ -1788,7 +1806,7 @@ msgstr "" "...\n" "ValueError: duplicate values found in : FOUR -> THREE" -#: ../../library/enum.rst:999 +#: ../../library/enum.rst:1003 msgid "" "A :keyword:`class` decorator specifically for enumerations. Members from :" "class:`EnumCheck` are used to specify which constraints should be checked on " @@ -1797,15 +1815,15 @@ msgstr "" "專門針對列舉的 :keyword:`class` 裝飾器。使用 :class:`EnumCheck` 裡的成員來指" "定在裝飾的列舉上應該檢查什麼限制。" -#: ../../library/enum.rst:1007 +#: ../../library/enum.rst:1011 msgid "A decorator for use in enums: its target will become a member." msgstr "列舉所使用的裝飾器:其目標會變成成員。" -#: ../../library/enum.rst:1013 +#: ../../library/enum.rst:1017 msgid "A decorator for use in enums: its target will not become a member." msgstr "列舉所使用的裝飾器:其目標不會變成成員。" -#: ../../library/enum.rst:1019 +#: ../../library/enum.rst:1023 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 " @@ -1816,19 +1834,19 @@ msgstr "" "組而不是其類別。應該只有當列舉成員被匯出到模組的全域命名空間才使用(範例請參" "考 :class:`re.RegexFlag`)。" -#: ../../library/enum.rst:1028 +#: ../../library/enum.rst:1033 msgid "Return a list of all power-of-two integers contained in a flag *value*." msgstr "回傳在旗標\\ *值*\\ 中包含的所有 2 的次方的整數串列。" -#: ../../library/enum.rst:1036 +#: ../../library/enum.rst:1040 msgid "Notes" msgstr "備註" -#: ../../library/enum.rst:1038 +#: ../../library/enum.rst:1042 msgid ":class:`IntEnum`, :class:`StrEnum`, and :class:`IntFlag`" msgstr ":class:`IntEnum`、:class:`StrEnum` 及 :class:`IntFlag`" -#: ../../library/enum.rst:1040 +#: ../../library/enum.rst:1044 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:" @@ -1836,17 +1854,17 @@ msgstr "" "這三種列舉型別是設計來直接取代現有以整數及字串為基底的值;因此它們有額外的限" "制:" -#: ../../library/enum.rst:1043 +#: ../../library/enum.rst:1047 msgid "``__str__`` uses the value and not the name of the enum member" msgstr "``__str__`` 使用值而不是列舉成員的名稱" -#: ../../library/enum.rst:1045 +#: ../../library/enum.rst:1049 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:1048 +#: ../../library/enum.rst:1052 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::" @@ -1854,7 +1872,7 @@ msgstr "" "如果你不需要或不想要這些限制,你可以透過混合 ``int`` 或 ``str`` 型別來建立自" "己的基礎類別: ::" -#: ../../library/enum.rst:1051 +#: ../../library/enum.rst:1055 msgid "" ">>> from enum import Enum\n" ">>> class MyIntEnum(int, Enum):\n" @@ -1864,11 +1882,11 @@ msgstr "" ">>> class MyIntEnum(int, Enum):\n" "... pass" -#: ../../library/enum.rst:1055 +#: ../../library/enum.rst:1059 msgid "or you can reassign the appropriate :meth:`str`, etc., in your enum::" msgstr "或者你也可以在你的列舉重新給定合適的 :meth:`str`: ::" -#: ../../library/enum.rst:1057 +#: ../../library/enum.rst:1061 msgid "" ">>> from enum import Enum, IntEnum\n" ">>> class MyIntEnum(IntEnum):\n" diff --git a/library/errno.po b/library/errno.po index 53fcac01e5a..822df7939fb 100644 --- a/library/errno.po +++ b/library/errno.po @@ -1,13 +1,12 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-01-29 00:13+0000\n" +"POT-Creation-Date: 2025-09-08 15:25+0800\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-" @@ -39,8 +38,8 @@ msgstr "" #: ../../library/errno.rst:21 msgid "" -"To translate a numeric error code to an error message, use :func:`os." -"strerror`." +"To translate a numeric error code to an error message, " +"use :func:`os.strerror`." msgstr "" #: ../../library/errno.rst:23 @@ -52,26 +51,26 @@ msgstr "" #: ../../library/errno.rst:30 msgid "" -"Operation not permitted. This error is mapped to the exception :exc:" -"`PermissionError`." +"Operation not permitted. This error is mapped to the " +"exception :exc:`PermissionError`." msgstr "" #: ../../library/errno.rst:36 msgid "" -"No such file or directory. This error is mapped to the exception :exc:" -"`FileNotFoundError`." +"No such file or directory. This error is mapped to the " +"exception :exc:`FileNotFoundError`." msgstr "" #: ../../library/errno.rst:42 msgid "" -"No such process. This error is mapped to the exception :exc:" -"`ProcessLookupError`." +"No such process. This error is mapped to the " +"exception :exc:`ProcessLookupError`." msgstr "" #: ../../library/errno.rst:48 msgid "" -"Interrupted system call. This error is mapped to the exception :exc:" -"`InterruptedError`." +"Interrupted system call. This error is mapped to the " +"exception :exc:`InterruptedError`." msgstr "" #: ../../library/errno.rst:54 @@ -96,8 +95,8 @@ msgstr "" #: ../../library/errno.rst:79 msgid "" -"No child processes. This error is mapped to the exception :exc:" -"`ChildProcessError`." +"No child processes. This error is mapped to the " +"exception :exc:`ChildProcessError`." msgstr "" #: ../../library/errno.rst:85 @@ -111,8 +110,8 @@ msgstr "" #: ../../library/errno.rst:95 msgid "" -"Permission denied. This error is mapped to the exception :exc:" -"`PermissionError`." +"Permission denied. This error is mapped to the " +"exception :exc:`PermissionError`." msgstr "" #: ../../library/errno.rst:101 @@ -142,14 +141,14 @@ msgstr "" #: ../../library/errno.rst:132 msgid "" -"Not a directory. This error is mapped to the exception :exc:" -"`NotADirectoryError`." +"Not a directory. This error is mapped to the " +"exception :exc:`NotADirectoryError`." msgstr "" #: ../../library/errno.rst:138 msgid "" -"Is a directory. This error is mapped to the exception :exc:" -"`IsADirectoryError`." +"Is a directory. This error is mapped to the " +"exception :exc:`IsADirectoryError`." msgstr "" #: ../../library/errno.rst:144 @@ -231,8 +230,8 @@ msgstr "" #: ../../library/errno.rst:240 msgid "" -"Operation would block. This error is mapped to the exception :exc:" -"`BlockingIOError`." +"Operation would block. This error is mapped to the " +"exception :exc:`BlockingIOError`." msgstr "" #: ../../library/errno.rst:246 @@ -417,7 +416,7 @@ msgstr "" #: ../../library/errno.rst:471 msgid "Too many users" -msgstr "" +msgstr "使用者數量過多" #: ../../library/errno.rst:476 msgid "Socket operation on non-socket" @@ -485,14 +484,14 @@ msgstr "" #: ../../library/errno.rst:558 msgid "" -"Software caused connection abort. This error is mapped to the exception :exc:" -"`ConnectionAbortedError`." +"Software caused connection abort. This error is mapped to the " +"exception :exc:`ConnectionAbortedError`." msgstr "" #: ../../library/errno.rst:564 msgid "" -"Connection reset by peer. This error is mapped to the exception :exc:" -"`ConnectionResetError`." +"Connection reset by peer. This error is mapped to the " +"exception :exc:`ConnectionResetError`." msgstr "" #: ../../library/errno.rst:570 @@ -519,14 +518,14 @@ msgstr "" #: ../../library/errno.rst:596 msgid "" -"Connection timed out. This error is mapped to the exception :exc:" -"`TimeoutError`." +"Connection timed out. This error is mapped to the " +"exception :exc:`TimeoutError`." msgstr "" #: ../../library/errno.rst:602 msgid "" -"Connection refused. This error is mapped to the exception :exc:" -"`ConnectionRefusedError`." +"Connection refused. This error is mapped to the " +"exception :exc:`ConnectionRefusedError`." msgstr "" #: ../../library/errno.rst:608 @@ -538,171 +537,175 @@ msgid "No route to host" msgstr "" #: ../../library/errno.rst:618 +msgid "Memory page has hardware error." +msgstr "" + +#: ../../library/errno.rst:625 msgid "" -"Operation already in progress. This error is mapped to the exception :exc:" -"`BlockingIOError`." +"Operation already in progress. This error is mapped to the " +"exception :exc:`BlockingIOError`." msgstr "" -#: ../../library/errno.rst:624 +#: ../../library/errno.rst:631 msgid "" -"Operation now in progress. This error is mapped to the exception :exc:" -"`BlockingIOError`." +"Operation now in progress. This error is mapped to the " +"exception :exc:`BlockingIOError`." msgstr "" -#: ../../library/errno.rst:630 +#: ../../library/errno.rst:637 msgid "Stale NFS file handle" msgstr "" -#: ../../library/errno.rst:635 +#: ../../library/errno.rst:642 msgid "Structure needs cleaning" msgstr "" -#: ../../library/errno.rst:640 +#: ../../library/errno.rst:647 msgid "Not a XENIX named type file" msgstr "" -#: ../../library/errno.rst:645 +#: ../../library/errno.rst:652 msgid "No XENIX semaphores available" msgstr "" -#: ../../library/errno.rst:650 +#: ../../library/errno.rst:657 msgid "Is a named type file" msgstr "" -#: ../../library/errno.rst:655 +#: ../../library/errno.rst:662 msgid "Remote I/O error" msgstr "" -#: ../../library/errno.rst:660 +#: ../../library/errno.rst:667 msgid "Quota exceeded" msgstr "" -#: ../../library/errno.rst:664 +#: ../../library/errno.rst:671 msgid "Interface output queue is full" msgstr "" -#: ../../library/errno.rst:671 +#: ../../library/errno.rst:678 msgid "No medium found" msgstr "" -#: ../../library/errno.rst:676 +#: ../../library/errno.rst:683 msgid "Wrong medium type" msgstr "" -#: ../../library/errno.rst:681 +#: ../../library/errno.rst:688 msgid "Required key not available" msgstr "" -#: ../../library/errno.rst:686 +#: ../../library/errno.rst:693 msgid "Key has expired" msgstr "" -#: ../../library/errno.rst:691 +#: ../../library/errno.rst:698 msgid "Key has been revoked" msgstr "" -#: ../../library/errno.rst:696 +#: ../../library/errno.rst:703 msgid "Key was rejected by service" msgstr "" -#: ../../library/errno.rst:701 +#: ../../library/errno.rst:708 msgid "Operation not possible due to RF-kill" msgstr "" -#: ../../library/errno.rst:706 +#: ../../library/errno.rst:713 msgid "Locked lock was unmapped" msgstr "" -#: ../../library/errno.rst:711 +#: ../../library/errno.rst:718 msgid "Facility is not active" msgstr "" -#: ../../library/errno.rst:716 +#: ../../library/errno.rst:723 msgid "Authentication error" msgstr "" -#: ../../library/errno.rst:723 +#: ../../library/errno.rst:730 msgid "Bad CPU type in executable" msgstr "" -#: ../../library/errno.rst:730 +#: ../../library/errno.rst:737 msgid "Bad executable (or shared library)" msgstr "" -#: ../../library/errno.rst:737 +#: ../../library/errno.rst:744 msgid "Malformed Mach-o file" msgstr "" -#: ../../library/errno.rst:744 +#: ../../library/errno.rst:751 msgid "Device error" -msgstr "" +msgstr "裝置錯誤" -#: ../../library/errno.rst:751 +#: ../../library/errno.rst:758 msgid "Inappropriate file type or format" -msgstr "" +msgstr "不適當的檔案類型或格式" -#: ../../library/errno.rst:758 +#: ../../library/errno.rst:765 msgid "Need authenticator" -msgstr "" +msgstr "需要驗證器" -#: ../../library/errno.rst:765 +#: ../../library/errno.rst:772 msgid "Attribute not found" -msgstr "" +msgstr "找不到屬性" -#: ../../library/errno.rst:772 +#: ../../library/errno.rst:779 msgid "Policy not found" msgstr "" -#: ../../library/errno.rst:779 +#: ../../library/errno.rst:786 msgid "Too many processes" -msgstr "" +msgstr "行程數量過多" -#: ../../library/errno.rst:786 +#: ../../library/errno.rst:793 msgid "Bad procedure for program" msgstr "" -#: ../../library/errno.rst:793 +#: ../../library/errno.rst:800 msgid "Program version wrong" msgstr "" -#: ../../library/errno.rst:800 +#: ../../library/errno.rst:807 msgid "RPC prog. not avail" msgstr "" -#: ../../library/errno.rst:807 +#: ../../library/errno.rst:814 msgid "Device power is off" -msgstr "" +msgstr "裝置電源關閉" -#: ../../library/errno.rst:814 +#: ../../library/errno.rst:821 msgid "RPC struct is bad" -msgstr "" +msgstr "RPC 結構不正確" -#: ../../library/errno.rst:821 +#: ../../library/errno.rst:828 msgid "RPC version wrong" -msgstr "" +msgstr "RPC 版本錯誤" -#: ../../library/errno.rst:828 +#: ../../library/errno.rst:835 msgid "Shared library version mismatch" -msgstr "" +msgstr "共享函式庫版本不匹配" -#: ../../library/errno.rst:835 +#: ../../library/errno.rst:842 msgid "" -"Capabilities insufficient. This error is mapped to the exception :exc:" -"`PermissionError`." +"Capabilities insufficient. This error is mapped to the " +"exception :exc:`PermissionError`." msgstr "" -#: ../../library/errno.rst:838 +#: ../../library/errno.rst:845 msgid "Availability" msgstr "可用性" -#: ../../library/errno.rst:845 +#: ../../library/errno.rst:852 msgid "Operation canceled" -msgstr "" +msgstr "操作已取消" -#: ../../library/errno.rst:852 +#: ../../library/errno.rst:859 msgid "Owner died" -msgstr "" +msgstr "擁有者過世" -#: ../../library/errno.rst:859 +#: ../../library/errno.rst:866 msgid "State not recoverable" -msgstr "" +msgstr "狀態無法恢復" diff --git a/library/exceptions.po b/library/exceptions.po index bc2c4e7aea7..304ba827ae9 100644 --- a/library/exceptions.po +++ b/library/exceptions.po @@ -1,13 +1,13 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Leon H., 2017 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-08-30 00:15+0000\n" +"POT-Creation-Date: 2025-09-08 15:25+0800\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-" @@ -24,12 +24,13 @@ msgstr "內建的例外" #: ../../library/exceptions.rst:10 msgid "" -"In Python, all exceptions must be instances of a class that derives from :" -"class:`BaseException`. In a :keyword:`try` statement with an :keyword:" -"`except` clause that mentions a particular class, that clause also handles " -"any exception classes derived from that class (but not exception classes " -"from which *it* is derived). Two exception classes that are not related via " -"subclassing are never equivalent, even if they have the same name." +"In Python, all exceptions must be instances of a class that derives " +"from :class:`BaseException`. In a :keyword:`try` statement with " +"an :keyword:`except` clause that mentions a particular class, that clause " +"also handles any exception classes derived from that class (but not " +"exception classes from which *it* is derived). Two exception classes that " +"are not related via subclassing are never equivalent, even if they have the " +"same name." msgstr "" "在 Python 中,所有例外必須是從 :class:`BaseException` 衍生的類別的實例。在陳" "述式 :keyword:`try` 搭配 :keyword:`except` 子句裡提到一個特定的類別時,那個子" @@ -66,10 +67,10 @@ msgstr "" #: ../../library/exceptions.rst:31 msgid "" "The built-in exception classes can be subclassed to define new exceptions; " -"programmers are encouraged to derive new exceptions from the :exc:" -"`Exception` class or one of its subclasses, and not from :exc:" -"`BaseException`. More information on defining exceptions is available in " -"the Python Tutorial under :ref:`tut-userexceptions`." +"programmers are encouraged to derive new exceptions from " +"the :exc:`Exception` class or one of its subclasses, and not " +"from :exc:`BaseException`. More information on defining exceptions is " +"available in the Python Tutorial under :ref:`tut-userexceptions`." msgstr "" "可以從內建的例外類別定義新的例外子類別;程式設計師被鼓勵從 :exc:`Exception` " "類別或其子類別衍生新的例外,而不是從 :exc:`BaseException` 來衍生。更多關於定" @@ -89,13 +90,13 @@ msgstr "三個例外物件上的屬性提供關於引發此例外的情境的資 msgid "" "When raising a new exception while another exception is already being " "handled, the new exception's :attr:`!__context__` attribute is automatically " -"set to the handled exception. An exception may be handled when an :keyword:" -"`except` or :keyword:`finally` clause, or a :keyword:`with` statement, is " -"used." +"set to the handled exception. An exception may be handled when " +"an :keyword:`except` or :keyword:`finally` clause, or a :keyword:`with` " +"statement, is used." msgstr "" "當引發一個新的例外而同時有另一個例外已經正在被處理時,這個新例外的 :attr:`!" -"__context__` 屬性會自動被設成那個已處理的例外。當使用 :keyword:`except` 或 :" -"keyword:`finally` 子句或 :keyword:`with` 陳述式的時候例外會被處理。" +"__context__` 屬性會自動被設成那個已處理的例外。當使用 :keyword:`except` " +"或 :keyword:`finally` 子句或 :keyword:`with` 陳述式的時候例外會被處理。" #: ../../library/exceptions.rst:59 msgid "" @@ -121,11 +122,11 @@ msgid "" "introspection when debugging." msgstr "" "在 :keyword:`from` 後面的運算式必須是一個例外或 ``None``。它將會被設定" -"成所引發例外的 :attr:`!__cause__`。設定 :attr:`!__cause__` 也隱含地設定 :" -"attr:`!__suppress_context__` 屬性為 ``True``,因此使用 ``raise new_exc from " -"None`` 實際上會以新的例外取代舊的例外以利於顯示(例如轉換 :exc:`KeyError` " -"為 :exc:`AttributeError`),同時保持舊的例外可以透過 :attr:`!__context__` 取" -"得以方便 debug 的時候檢查。" +"成所引發例外的 :attr:`!__cause__`。設定 :attr:`!__cause__` 也隱含地設" +"定 :attr:`!__suppress_context__` 屬性為 ``True``,因此使用 ``raise new_exc " +"from None`` 實際上會以新的例外取代舊的例外以利於顯示(例如轉" +"換 :exc:`KeyError` 為 :exc:`AttributeError`),同時保持舊的例外可以透" +"過 :attr:`!__context__` 取得以方便 debug 的時候檢查。" #: ../../library/exceptions.rst:74 msgid "" @@ -167,17 +168,18 @@ msgstr "" #: ../../library/exceptions.rst:95 msgid "" -"Most built-in exceptions are implemented in C for efficiency, see: :source:" -"`Objects/exceptions.c`. Some have custom memory layouts which makes it " -"impossible to create a subclass that inherits from multiple exception types. " -"The memory layout of a type is an implementation detail and might change " -"between Python versions, leading to new conflicts in the future. Therefore, " -"it's recommended to avoid subclassing multiple exception types altogether." +"Most built-in exceptions are implemented in C for efficiency, " +"see: :source:`Objects/exceptions.c`. Some have custom memory layouts which " +"makes it impossible to create a subclass that inherits from multiple " +"exception types. The memory layout of a type is an implementation detail and " +"might change between Python versions, leading to new conflicts in the " +"future. Therefore, it's recommended to avoid subclassing multiple exception " +"types altogether." msgstr "" -"為了效率,大部分的內建例外使用 C 來實作,參考 :source:`Objects/exceptions." -"c`。一些例外有客製化的記憶體佈局,使其不可能建立一個繼承多種例外型別的子類" -"別。型別的記憶體佈局是實作細節且可能會在不同 Python 版本間改變,造成未來新的" -"衝突。因此,總之建議避免繼承多種例外型別。" +"為了效率,大部分的內建例外使用 C 來實作,參考 :source:`Objects/" +"exceptions.c`。一些例外有客製化的記憶體佈局,使其不可能建立一個繼承多種例外型" +"別的子類別。型別的記憶體佈局是實作細節且可能會在不同 Python 版本間改變,造成" +"未來新的衝突。因此,總之建議避免繼承多種例外型別。" #: ../../library/exceptions.rst:105 msgid "Base classes" @@ -192,14 +194,14 @@ msgstr "以下的例外大部分被用在當作其他例外的基底類別。" #: ../../library/exceptions.rst:111 msgid "" "The base class for all built-in exceptions. It is not meant to be directly " -"inherited by user-defined classes (for that, use :exc:`Exception`). If :" -"func:`str` is called on an instance of this class, the representation of the " -"argument(s) to the instance are returned, or the empty string when there " +"inherited by user-defined classes (for that, use :exc:`Exception`). " +"If :func:`str` is called on an instance of this class, the representation of " +"the argument(s) to the instance are returned, or the empty string when there " "were no arguments." msgstr "" -"所有內建例外的基底類別。這不是為了讓使用者定義的類別直接繼承(可以使用 :exc:" -"`Exception`)。如果在這個類別的實例上呼叫 :func:`str`,會回傳實例的引數的表" -"示,或者沒有引數的時候會回傳空字串。" +"所有內建例外的基底類別。這不是為了讓使用者定義的類別直接繼承(可以使" +"用 :exc:`Exception`)。如果在這個類別的實例上呼叫 :func:`str`,會回傳實例的引" +"數的表示,或者沒有引數的時候會回傳空字串。" #: ../../library/exceptions.rst:119 msgid "" @@ -262,8 +264,9 @@ msgstr "" #: ../../library/exceptions.rst:157 msgid "" -"A list of the notes of this exception, which were added with :meth:" -"`add_note`. This attribute is created when :meth:`add_note` is called." +"A list of the notes of this exception, which were added " +"with :meth:`add_note`. This attribute is created when :meth:`add_note` is " +"called." msgstr "" "該例外的備註串列,使用 :meth:`add_note` 來新增。此屬性在 :meth:`add_note` 被" "呼叫的時候建立。" @@ -279,11 +282,12 @@ msgstr "" #: ../../library/exceptions.rst:171 msgid "" "The base class for those built-in exceptions that are raised for various " -"arithmetic errors: :exc:`OverflowError`, :exc:`ZeroDivisionError`, :exc:" -"`FloatingPointError`." +"arithmetic " +"errors: :exc:`OverflowError`, :exc:`ZeroDivisionError`, :exc:`FloatingPointError`." msgstr "" -"各種運算錯誤所引發的那些內建例外::exc:`OverflowError`、:exc:" -"`ZeroDivisionError`、:exc:`FloatingPointError` 的基底類別。" +"各種運算錯誤所引發的那些內建例" +"外::exc:`OverflowError`、:exc:`ZeroDivisionError`、:exc:`FloatingPointError` " +"的基底類別。" #: ../../library/exceptions.rst:178 msgid "" @@ -299,8 +303,9 @@ msgid "" "on a mapping or sequence is invalid: :exc:`IndexError`, :exc:`KeyError`. " "This can be raised directly by :func:`codecs.lookup`." msgstr "" -"當使用在對映或序列上的鍵或索引是無效的時候所引發的例外::exc:`IndexError`、:" -"exc:`KeyError` 的基底類別。這可以被 :func:`codecs.lookup` 直接引發。" +"當使用在對映或序列上的鍵或索引是無效的時候所引發的例" +"外::exc:`IndexError`、:exc:`KeyError` 的基底類別。這可以" +"被 :func:`codecs.lookup` 直接引發。" #: ../../library/exceptions.rst:190 msgid "Concrete exceptions" @@ -344,8 +349,9 @@ msgstr "新增 :attr:`name` 與 :attr:`obj` 屬性。" #: ../../library/exceptions.rst:223 msgid "" "Raised when the :func:`input` function hits an end-of-file condition (EOF) " -"without reading any data. (Note: the :meth:`!io.IOBase.read` and :meth:`io." -"IOBase.readline` methods return an empty string when they hit EOF.)" +"without reading any data. (Note: the :meth:`!io.IOBase.read` " +"and :meth:`io.IOBase.readline` methods return an empty string when they hit " +"EOF.)" msgstr "" "當 :func:`input` 函式在沒有讀到任何資料而到達檔案結尾 (end-of-file, EOF) 條件" "的時候被引發。(注意::meth:`!io.IOBase.read` 和 :meth:`io.IOBase.readline` " @@ -357,14 +363,15 @@ msgstr "目前沒有被使用。" #: ../../library/exceptions.rst:235 msgid "" -"Raised when a :term:`generator` or :term:`coroutine` is closed; see :meth:" -"`generator.close` and :meth:`coroutine.close`. It directly inherits from :" -"exc:`BaseException` instead of :exc:`Exception` since it is technically not " -"an error." +"Raised when a :term:`generator` or :term:`coroutine` is closed; " +"see :meth:`generator.close` and :meth:`coroutine.close`. It directly " +"inherits from :exc:`BaseException` instead of :exc:`Exception` since it is " +"technically not an error." msgstr "" -"當 :term:`generator` 或 :term:`coroutine` 被關閉的時候被引發;參考 :meth:" -"`generator.close` 和 :meth:`coroutine.close`。此例外直接繼承自 :exc:" -"`BaseException` 而不是 :exc:`Exception`,因為技術上來說這不是一個錯誤。" +"當 :term:`generator` 或 :term:`coroutine` 被關閉的時候被引發;參" +"考 :meth:`generator.close` 和 :meth:`coroutine.close`。此例外直接繼承" +"自 :exc:`BaseException` 而不是 :exc:`Exception`,因為技術上來說這不是一個錯" +"誤。" #: ../../library/exceptions.rst:243 msgid "" @@ -396,8 +403,8 @@ msgstr "新增 :attr:`name` 與 :attr:`path` 屬性。" #: ../../library/exceptions.rst:263 msgid "" "A subclass of :exc:`ImportError` which is raised by :keyword:`import` when a " -"module could not be located. It is also raised when ``None`` is found in :" -"data:`sys.modules`." +"module could not be located. It is also raised when ``None`` is found " +"in :data:`sys.modules`." msgstr "" ":exc:`ImportError` 的子類別,當模組不能被定位的時候會被 :keyword:`import` 所" "引發。當在 :data:`sys.modules` 裡找到 ``None`` 時也會被引發。" @@ -419,16 +426,16 @@ msgstr "當對映(字典)的鍵無法在已存在的鍵的集合中被找到 #: ../../library/exceptions.rst:288 msgid "" -"Raised when the user hits the interrupt key (normally :kbd:`Control-C` or :" -"kbd:`Delete`). During execution, a check for interrupts is made regularly. " -"The exception inherits from :exc:`BaseException` so as to not be " +"Raised when the user hits the interrupt key (normally :kbd:`Control-C` " +"or :kbd:`Delete`). During execution, a check for interrupts is made " +"regularly. The exception inherits from :exc:`BaseException` so as to not be " "accidentally caught by code that catches :exc:`Exception` and thus prevent " "the interpreter from exiting." msgstr "" -"當使用者輸入中斷鍵 (interrupt key)(一般來說是 :kbd:`Control-C` 或 :kbd:" -"`Delete`)時會被引發。在執行過程中,會定期檢查是否產生中斷。此例外繼承自 :" -"exc:`BaseException` 以防止意外地被捕捉 :exc:`Exception` 的程式碼所捕捉,而因" -"此讓直譯器無法結束。" +"當使用者輸入中斷鍵 (interrupt key)(一般來說是 :kbd:`Control-C` " +"或 :kbd:`Delete`)時會被引發。在執行過程中,會定期檢查是否產生中斷。此例外繼" +"承自 :exc:`BaseException` 以防止意外地被捕捉 :exc:`Exception` 的程式碼所捕" +"捉,而因此讓直譯器無法結束。" #: ../../library/exceptions.rst:296 msgid "" @@ -439,19 +446,20 @@ msgid "" "avoid raising it entirely. (See :ref:`handlers-and-exceptions`.)" msgstr "" "捕捉 :exc:`KeyboardInterrupt` 需要特殊的考量。因為它可以在無法預期的時間點被" -"引發,可能在某些情況下讓正在跑的程式處在一個不一致的狀態。一般來說最好讓 :" -"exc:`KeyboardInterrupt` 越快結束程式越好,或者完全避免引發它。(參考 :ref:" -"`handlers-and-exceptions`。)" +"引發,可能在某些情況下讓正在跑的程式處在一個不一致的狀態。一般來說最好" +"讓 :exc:`KeyboardInterrupt` 越快結束程式越好,或者完全避免引發它。(參" +"考 :ref:`handlers-and-exceptions`。)" #: ../../library/exceptions.rst:306 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 " "indicating what kind of (internal) operation ran out of memory. Note that " -"because of the underlying memory management architecture (C's :c:func:" -"`malloc` function), the interpreter may not always be able to completely " -"recover from this situation; it nevertheless raises an exception so that a " -"stack traceback can be printed, in case a run-away program was the cause." +"because of the underlying memory management architecture " +"(C's :c:func:`malloc` function), the interpreter may not always be able to " +"completely recover from this situation; it nevertheless raises an exception " +"so that a stack traceback can be printed, in case a run-away program was the " +"cause." msgstr "" "當一個操作用光了記憶體但情況還可能被修復 (rescued)(透過刪除一些物件)的時候" "被引發。關聯值是一個字串,表示什麼類型的(內部)操作用光了記憶體。需注意的是" @@ -503,8 +511,9 @@ msgstr "" #: ../../library/exceptions.rst:346 msgid "" ":exc:`!NotImplementedError` and :data:`!NotImplemented` are not " -"interchangeable. This exception should only be used as described above; see :" -"data:`NotImplemented` for details on correct usage of the built-in constant." +"interchangeable. This exception should only be used as described above; " +"see :data:`NotImplemented` for details on correct usage of the built-in " +"constant." msgstr "" ":exc:`!NotImplementedError` 和 :data:`!NotImplemented` 並不是可互換的。這個例" "外只能用在上面描述的情況;參考 :data:`NotImplemented` 裡關於內建常數正確使用" @@ -513,8 +522,8 @@ msgstr "" #: ../../library/exceptions.rst:357 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\" (not for illegal argument types or other incidental errors)." +"error, including I/O failures such as \"file not found\" or \"disk full\" " +"(not for illegal argument types or other incidental errors)." msgstr "" "當系統函式回傳系統相關錯誤,包含像\"找不到檔案\"或\"硬碟已滿\"的 I/O 失敗會引" "發此例外(而非不合法的引數或其他次要的錯誤)。" @@ -523,21 +532,22 @@ msgstr "" msgid "" "The second form of the constructor sets the corresponding attributes, " "described below. The attributes default to :const:`None` if not specified. " -"For backwards compatibility, if three arguments are passed, the :attr:" -"`~BaseException.args` attribute contains only a 2-tuple of the first two " -"constructor arguments." +"For backwards compatibility, if three arguments are passed, " +"the :attr:`~BaseException.args` attribute contains only a 2-tuple of the " +"first two constructor arguments." msgstr "" -"建構函式的第二種形式會設定以下描述的相對應屬性。如果沒有給定則屬性預設為 :" -"const:`None`。為了向後相容,如果傳入三個引數,:attr:`~BaseException.args` 屬" -"性只會是包含建構函式前兩個引數的雙元素元組。" +"建構函式的第二種形式會設定以下描述的相對應屬性。如果沒有給定則屬性預設" +"為 :const:`None`。為了向後相容,如果傳入三個引" +"數,:attr:`~BaseException.args` 屬性只會是包含建構函式前兩個引數的雙元素元" +"組。" #: ../../library/exceptions.rst:367 msgid "" "The constructor often actually returns a subclass of :exc:`OSError`, as " "described in `OS exceptions`_ below. The particular subclass depends on the " -"final :attr:`.errno` value. This behaviour only occurs when constructing :" -"exc:`OSError` directly or via an alias, and is not inherited when " -"subclassing." +"final :attr:`.errno` value. This behaviour only occurs when " +"constructing :exc:`OSError` directly or via an alias, and is not inherited " +"when subclassing." msgstr "" "如同下面的\\ `作業系統例外 `_\\ 所描述,實際上建構函式通常回" "傳 :exc:`OSError` 的子類別。會依據最後 :attr:`.errno` 的值決定特定子類別。這" @@ -550,19 +560,19 @@ msgstr "從 C 變數 :c:data:`errno` 而來的數值錯誤代碼。" #: ../../library/exceptions.rst:379 msgid "" -"Under Windows, this gives you the native Windows error code. The :attr:`." -"errno` attribute is then an approximate translation, in POSIX terms, of that " -"native error code." +"Under Windows, this gives you the native Windows error code. " +"The :attr:`.errno` attribute is then an approximate translation, in POSIX " +"terms, of that native error code." msgstr "" "在 Windows 下,這會提供你原生的 Windows 錯誤代碼。而 :attr:`.errno` 屬性是一" "個該原生錯誤代碼對於 POSIX 來說的近似翻譯。" #: ../../library/exceptions.rst:383 msgid "" -"Under Windows, if the *winerror* constructor argument is an integer, the :" -"attr:`.errno` attribute is determined from the Windows error code, and the " -"*errno* argument is ignored. On other platforms, the *winerror* argument is " -"ignored, and the :attr:`winerror` attribute does not exist." +"Under Windows, if the *winerror* constructor argument is an integer, " +"the :attr:`.errno` attribute is determined from the Windows error code, and " +"the *errno* argument is ignored. On other platforms, the *winerror* " +"argument is ignored, and the :attr:`winerror` attribute does not exist." msgstr "" "在 Windows 下,如果建構函式引數 *winerror* 是整數,則 :attr:`.errno` 屬性會根" "據該 Windows 錯誤代碼來決定,且 *errno* 引數會被忽略。在其他平台上," @@ -579,32 +589,32 @@ msgstr "" #: ../../library/exceptions.rst:399 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 function. " -"For functions that involve two file system paths (such as :func:`os." -"rename`), :attr:`filename2` corresponds to the second file name passed to " -"the function." +"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 " +"function. For functions that involve two file system paths (such " +"as :func:`os.rename`), :attr:`filename2` corresponds to the second file name " +"passed to the function." msgstr "" -"對於包含檔案系統路徑的例外(像是 :func:`open` 或 :func:`os.unlink`),:attr:" -"`filename` 是傳入函式的檔案名稱。對於包含兩個檔案系統路徑的函式(像是 :func:" -"`os.rename`),:attr:`filename2` 對應到傳入函式的第二個檔案名稱。" +"對於包含檔案系統路徑的例外(像是 :func:`open` " +"或 :func:`os.unlink`),:attr:`filename` 是傳入函式的檔案名稱。對於包含兩個檔" +"案系統路徑的函式(像是 :func:`os.rename`),:attr:`filename2` 對應到傳入函式" +"的第二個檔案名稱。" #: ../../library/exceptions.rst:406 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 constructor may return a subclass." +":exc:`EnvironmentError`, :exc:`IOError`, :exc:`WindowsError`, :exc:`socket.error`, :exc:`select.error` " +"and :exc:`!mmap.error` have been merged into :exc:`OSError`, and the " +"constructor may return a subclass." msgstr "" -":exc:`EnvironmentError`、:exc:`IOError`、:exc:`WindowsError`、:exc:`socket." -"error`、:exc:`select.error` 及 :exc:`!mmap.error` 已合併進 :exc:`OSError`,而" -"建構函式可能會回傳子類別。" +":exc:`EnvironmentError`、:exc:`IOError`、:exc:`WindowsError`、:exc:`socket.error`、:exc:`select.error` " +"及 :exc:`!mmap.error` 已合併進 :exc:`OSError`,而建構函式可能會回傳子類別。" #: ../../library/exceptions.rst:412 msgid "" "The :attr:`filename` attribute is now the original file name passed to the " -"function, instead of the name encoded to or decoded from the :term:" -"`filesystem encoding and error handler`. Also, the *filename2* constructor " -"argument and attribute was added." +"function, instead of the name encoded to or decoded from " +"the :term:`filesystem encoding and error handler`. Also, the *filename2* " +"constructor argument and attribute was added." msgstr "" ":attr:`filename` 屬性現在是傳入函式的原始檔名,而不是從\\ :term:`檔案系統編碼" "和錯誤處理函式 `\\ 編碼或解碼過的名" @@ -613,11 +623,11 @@ msgstr "" #: ../../library/exceptions.rst:421 msgid "" "Raised when the result of an arithmetic operation is too large to be " -"represented. This cannot occur for integers (which would rather raise :exc:" -"`MemoryError` than give up). However, for historical reasons, OverflowError " -"is sometimes raised for integers that are outside a required range. " -"Because of the lack of standardization of floating-point exception handling " -"in C, most floating-point operations are not checked." +"represented. This cannot occur for integers (which would rather " +"raise :exc:`MemoryError` than give up). However, for historical reasons, " +"OverflowError is sometimes raised for integers that are outside a required " +"range. Because of the lack of standardization of floating-point exception " +"handling in C, most floating-point operations are not checked." msgstr "" "當運算操作的結果太大而無法表示的時候會引發此例外。這不會發生在整數上(會改成" "引發 :exc:`MemoryError` 而不是放棄)。然而,因為一些歷史因素,OverflowError " @@ -630,14 +640,14 @@ msgid "" "operation is blocked during interpreter shutdown also known as :term:`Python " "finalization `." msgstr "" -"此例外衍生自 :exc:`RuntimeError`。當一個操作在直譯器關閉(也稱作 :term:" -"`Python 最終化 (Python finalization) `)期間被阻塞會引" -"發此例外。" +"此例外衍生自 :exc:`RuntimeError`。當一個操作在直譯器關閉(也稱" +"作 :term:`Python 最終化 (Python finalization) `)期間" +"被阻塞會引發此例外。" #: ../../library/exceptions.rst:435 msgid "" -"Examples of operations which can be blocked with a :exc:" -"`PythonFinalizationError` during the Python finalization:" +"Examples of operations which can be blocked with " +"a :exc:`PythonFinalizationError` during the Python finalization:" msgstr "" "在 Python 最終化期間,能夠以 :exc:`PythonFinalizationError` 被阻塞的操作範" "例:" @@ -647,38 +657,46 @@ msgid "Creating a new Python thread." msgstr "建立新的 Python 執行緒。" #: ../../library/exceptions.rst:439 +msgid ":meth:`Joining ` a running daemon thread." +msgstr "" + +#: ../../library/exceptions.rst:440 msgid ":func:`os.fork`." msgstr ":func:`os.fork`。" -#: ../../library/exceptions.rst:441 +#: ../../library/exceptions.rst:442 msgid "See also the :func:`sys.is_finalizing` function." msgstr "也可以參閱 :func:`sys.is_finalizing` 函式。" -#: ../../library/exceptions.rst:443 ../../library/exceptions.rst:453 +#: ../../library/exceptions.rst:444 ../../library/exceptions.rst:457 msgid "Previously, a plain :exc:`RuntimeError` was raised." msgstr "在之前,會引發一般的 :exc:`RuntimeError`。" #: ../../library/exceptions.rst:449 +msgid ":meth:`threading.Thread.join` can now raise this exception." +msgstr "" + +#: ../../library/exceptions.rst:453 msgid "" "This exception is derived from :exc:`RuntimeError`. It is raised when the " -"interpreter detects that the maximum recursion depth (see :func:`sys." -"getrecursionlimit`) is exceeded." +"interpreter detects that the maximum recursion depth " +"(see :func:`sys.getrecursionlimit`) is exceeded." msgstr "" -"此例外衍生自 :exc:`RuntimeError`。當直譯器偵測到超過最大的遞迴深度(參考 :" -"func:`sys.getrecursionlimit`)時會引發此例外。" +"此例外衍生自 :exc:`RuntimeError`。當直譯器偵測到超過最大的遞迴深度(參" +"考 :func:`sys.getrecursionlimit`)時會引發此例外。" -#: ../../library/exceptions.rst:459 +#: ../../library/exceptions.rst:463 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 referent " -"after it has been garbage collected. For more information on weak " +"This exception is raised when a weak reference proxy, created by " +"the :func:`weakref.proxy` function, is used to access an attribute of the " +"referent after it has been garbage collected. For more information on weak " "references, see the :mod:`weakref` module." msgstr "" "當一個被 :func:`weakref.proxy` 函式建立的弱參照代理 (weak reference proxy) 被" "用來存取已經被垃圾回收 (garbage collected) 的參照物屬性時會引發此例外。更多關" "於弱參照的資訊參考 :mod:`weakref` 模組。" -#: ../../library/exceptions.rst:467 +#: ../../library/exceptions.rst:471 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 " @@ -687,50 +705,51 @@ msgstr "" "當偵測到一個不屬於任何其他種類的錯誤時會引發此例外。關聯值是一個表示確切什麼" "地方出錯的字串。" -#: ../../library/exceptions.rst:474 +#: ../../library/exceptions.rst:478 msgid "" -"Raised by built-in function :func:`next` and an :term:`iterator`\\'s :meth:" -"`~iterator.__next__` method to signal that there are no further items " -"produced by the iterator." +"Raised by built-in function :func:`next` and " +"an :term:`iterator`\\'s :meth:`~iterator.__next__` method to signal that " +"there are no further items produced by the iterator." msgstr "" "會被內建函式 :func:`next` 及 :term:`iterator` 的 :meth:`~iterator.__next__` " "方法引發,用來表示疊代器沒有更多項目可以產生。" -#: ../../library/exceptions.rst:480 +#: ../../library/exceptions.rst:484 msgid "" "The exception object has a single attribute :attr:`!value`, which is given " -"as an argument when constructing the exception, and defaults to :const:" -"`None`." +"as an argument when constructing the exception, and defaults " +"to :const:`None`." msgstr "" -"此例外物件有單一屬性 :attr:`!value`,當建構此例外時會以引數給定,預設為 :" -"const:`None`。" +"此例外物件有單一屬性 :attr:`!value`,當建構此例外時會以引數給定,預設" +"為 :const:`None`。" -#: ../../library/exceptions.rst:484 +#: ../../library/exceptions.rst:488 msgid "" -"When a :term:`generator` or :term:`coroutine` function returns, a new :exc:" -"`StopIteration` instance is raised, and the value returned by the function " -"is used as the :attr:`value` parameter to the constructor of the exception." +"When a :term:`generator` or :term:`coroutine` function returns, a " +"new :exc:`StopIteration` instance is raised, and the value returned by the " +"function is used as the :attr:`value` parameter to the constructor of the " +"exception." msgstr "" -"當 :term:`generator` 或 :term:`coroutine` 函式回傳時,新的 :exc:" -"`StopIteration` 實例會被引發,而該函式的回傳值會被用來當作此例外建構函式的 :" -"attr:`value` 參數。" +"當 :term:`generator` 或 :term:`coroutine` 函式回傳時,新" +"的 :exc:`StopIteration` 實例會被引發,而該函式的回傳值會被用來當作此例外建構" +"函式的 :attr:`value` 參數。" -#: ../../library/exceptions.rst:489 +#: ../../library/exceptions.rst:493 msgid "" "If a generator code directly or indirectly raises :exc:`StopIteration`, it " "is converted into a :exc:`RuntimeError` (retaining the :exc:`StopIteration` " "as the new exception's cause)." msgstr "" -"如果產生器程式直接或間接引發 :exc:`StopIteration`,則其會被轉換成 :exc:" -"`RuntimeError`\\ (保留 :exc:`StopIteration` 作為新例外的成因)。" +"如果產生器程式直接或間接引發 :exc:`StopIteration`,則其會被轉換" +"成 :exc:`RuntimeError`\\ (保留 :exc:`StopIteration` 作為新例外的成因)。" -#: ../../library/exceptions.rst:493 +#: ../../library/exceptions.rst:497 msgid "" "Added ``value`` attribute and the ability for generator functions to use it " "to return a value." msgstr "新增 ``value`` 屬性且產生器函式可以用它來回傳值。" -#: ../../library/exceptions.rst:497 +#: ../../library/exceptions.rst:501 msgid "" "Introduced the RuntimeError transformation via ``from __future__ import " "generator_stop``, see :pep:`479`." @@ -738,7 +757,7 @@ msgstr "" "透過 ``from __future__ import generator_stop`` 引入 RuntimeError 的轉換,參" "考 :pep:`479`。" -#: ../../library/exceptions.rst:501 +#: ../../library/exceptions.rst:505 msgid "" "Enable :pep:`479` for all code by default: a :exc:`StopIteration` error " "raised in a generator is transformed into a :exc:`RuntimeError`." @@ -746,7 +765,7 @@ msgstr "" "預設對所有程式啟用 :pep:`479`:在產生器引發的 :exc:`StopIteration` 錯誤會轉換" "成 :exc:`RuntimeError`。" -#: ../../library/exceptions.rst:507 +#: ../../library/exceptions.rst:511 msgid "" "Must be raised by :meth:`~object.__anext__` method of an :term:`asynchronous " "iterator` object to stop the iteration." @@ -754,18 +773,18 @@ msgstr "" "此例外必須被 :term:`asynchronous iterator` 物件的 :meth:`~object.__anext__` " "方法引發來停止疊代。" -#: ../../library/exceptions.rst:514 +#: ../../library/exceptions.rst:518 msgid "" -"Raised when the parser encounters a syntax error. This may occur in an :" -"keyword:`import` statement, in a call to the built-in functions :func:" -"`compile`, :func:`exec`, or :func:`eval`, or when reading the initial script " -"or standard input (also interactively)." +"Raised when the parser encounters a syntax error. This may occur in " +"an :keyword:`import` statement, in a call to the built-in " +"functions :func:`compile`, :func:`exec`, or :func:`eval`, or when reading " +"the initial script or standard input (also interactively)." msgstr "" "當剖析器遇到語法錯誤時會引發此例外。這可能發生在 :keyword:`import` 陳述式、在" "呼叫內建函式 :func:`compile`、:func:`exec` 或 :func:`eval` 的時候,或者在讀取" "初始腳本或標準輸入(也包含互動式)的時候。" -#: ../../library/exceptions.rst:520 +#: ../../library/exceptions.rst:524 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." @@ -773,18 +792,18 @@ msgstr "" "例外實例的 :func:`str` 只回傳錯誤訊息。Details 是個元組,其成員也能夠以分開的" "屬性取得。" -#: ../../library/exceptions.rst:525 +#: ../../library/exceptions.rst:529 msgid "The name of the file the syntax error occurred in." msgstr "發生語法錯誤所在的檔案名稱。" -#: ../../library/exceptions.rst:529 +#: ../../library/exceptions.rst:533 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。" -#: ../../library/exceptions.rst:534 +#: ../../library/exceptions.rst:538 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." @@ -792,11 +811,11 @@ msgstr "" "發生錯誤所在該列的欄號 (column)。這是以 1 開始的索引:該列第一個字元的 " "``offset`` 是 1。" -#: ../../library/exceptions.rst:539 +#: ../../library/exceptions.rst:543 msgid "The source code text involved in the error." msgstr "涉及該錯誤的原始程式碼文字。" -#: ../../library/exceptions.rst:543 +#: ../../library/exceptions.rst:547 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." @@ -804,7 +823,7 @@ msgstr "" "發生錯誤所在檔案的結束列號。這是以 1 開始的索引:檔案第一列的 ``lineno`` 是 " "1。" -#: ../../library/exceptions.rst:548 +#: ../../library/exceptions.rst:552 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." @@ -812,7 +831,7 @@ msgstr "" "發生錯誤所在該結束列的欄號。這是以 1 開始的索引:該列第一個字元的 ``offset`` " "是 1。" -#: ../../library/exceptions.rst:551 +#: ../../library/exceptions.rst:555 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 " @@ -820,42 +839,42 @@ msgid "" "attribute: ('f-string: ...', ('', 1, 2, '(a b)\\n', 1, 5))." msgstr "" "對於發生在 f-string 欄位的錯誤,訊息會以 \"f-string: \" 為前綴,而偏移量 " -"(offset) 是從替代表達式建構的文字的偏移量。例如編譯 f'Bad {a b} field' 會得到" +"(offset) 是從替代運算式建構的文字的偏移量。例如編譯 f'Bad {a b} field' 會得到" "這個 args 屬性:('f-string: ...', ('', 1, 2, '(a b)\\n', 1, 5))。" -#: ../../library/exceptions.rst:556 +#: ../../library/exceptions.rst:560 msgid "Added the :attr:`end_lineno` and :attr:`end_offset` attributes." msgstr "新增 :attr:`end_lineno` 與 :attr:`end_offset` 屬性。" -#: ../../library/exceptions.rst:561 +#: ../../library/exceptions.rst:565 msgid "" "Base class for syntax errors related to incorrect indentation. This is a " "subclass of :exc:`SyntaxError`." msgstr "" "與不正確的縮排有關的語法錯誤的基礎類別。這是 :exc:`SyntaxError` 的子類別。" -#: ../../library/exceptions.rst:567 +#: ../../library/exceptions.rst:571 msgid "" "Raised when indentation contains an inconsistent use of tabs and spaces. " "This is a subclass of :exc:`IndentationError`." msgstr "" -"當縮排包含製表符號 (tab) 和空白的不一致用法時會引發此例外。這是 :exc:" -"`IndentationError` 的子類別。" +"當縮排包含製表符號 (tab) 和空白的不一致用法時會引發此例外。這" +"是 :exc:`IndentationError` 的子類別。" -#: ../../library/exceptions.rst:573 +#: ../../library/exceptions.rst:577 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 " -"a string indicating what went wrong (in low-level terms). In :term:" -"`CPython`, this could be raised by incorrectly using Python's C API, such as " -"returning a ``NULL`` value without an exception set." +"a string indicating what went wrong (in low-level terms). " +"In :term:`CPython`, this could be raised by incorrectly using Python's C " +"API, such as returning a ``NULL`` value without an exception set." msgstr "" "當直譯器找到一個內部錯誤,但該情況看起來沒有嚴重到要讓它放棄所有的希望時會引" -"發此例外。關聯值是一個表示什麼地方出錯的字串(以低階的方式表達)。在 :term:" -"`CPython` 中,這可能是因為錯誤地使用 Python 的 C API,例如回傳一個 ``NULL`` " -"值而沒有設定例外。" +"發此例外。關聯值是一個表示什麼地方出錯的字串(以低階的方式表達)。" +"在 :term:`CPython` 中,這可能是因為錯誤地使用 Python 的 C API,例如回傳一個 " +"``NULL`` 值而沒有設定例外。" -#: ../../library/exceptions.rst:579 +#: ../../library/exceptions.rst:583 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 " @@ -870,28 +889,28 @@ msgstr "" "互動式 Python 會話的開頭被印出)、確切的錯誤訊息(該例外的關聯值)及如果可能" "的話,觸發此錯誤的程式來源。" -#: ../../library/exceptions.rst:590 +#: ../../library/exceptions.rst:594 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 " "accidentally caught by code that catches :exc:`Exception`. This allows the " "exception to properly propagate up and cause the interpreter to exit. When " "it is not handled, the Python interpreter exits; no stack traceback is " -"printed. The constructor accepts the same optional argument passed to :func:" -"`sys.exit`. If the value is an integer, it specifies the system exit status " -"(passed to C's :c:func:`!exit` function); if it is ``None``, the exit status " -"is zero; if it has another type (such as a string), the object's value is " -"printed and the exit status is one." -msgstr "" -"此例外會被 :func:`sys.exit` 函式引發。它繼承自 :exc:`BaseException` 而不是 :" -"exc:`Exception` 因此不會被捕捉 :exc:`Exception` 的程式意外地捕捉。這允許例外" -"可以正確地向上傳遞並導致直譯器結束。當它未被處理時,Python 直譯器會結束;不會" -"印出堆疊回溯。建構函式接受跟傳入 :func:`sys.exit` 一樣的可選引數。如果該值是" -"整數,它會指定系統的結束狀態(傳入 C 的 :c:func:`!exit` 函式);如果它是 " +"printed. The constructor accepts the same optional argument passed " +"to :func:`sys.exit`. If the value is an integer, it specifies the system " +"exit status (passed to C's :c:func:`!exit` function); if it is ``None``, the " +"exit status is zero; if it has another type (such as a string), the object's " +"value is printed and the exit status is one." +msgstr "" +"此例外會被 :func:`sys.exit` 函式引發。它繼承自 :exc:`BaseException` 而不" +"是 :exc:`Exception` 因此不會被捕捉 :exc:`Exception` 的程式意外地捕捉。這允許" +"例外可以正確地向上傳遞並導致直譯器結束。當它未被處理時,Python 直譯器會結束;" +"不會印出堆疊回溯。建構函式接受跟傳入 :func:`sys.exit` 一樣的可選引數。如果該" +"值是整數,它會指定系統的結束狀態(傳入 C 的 :c:func:`!exit` 函式);如果它是 " "``None``,結束狀態會是 0;如果它是其他型別(例如字串),則物件的值會被印出而" "結束狀態是 1。" -#: ../../library/exceptions.rst:601 +#: ../../library/exceptions.rst:605 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 " @@ -902,16 +921,16 @@ msgid "" msgstr "" "對 :func:`sys.exit` 的呼叫會轉譯成例外讓負責清理的處理函式(:keyword:`try` 陳" "述式的 :keyword:`finally` 子句)可以被執行,且讓除錯器可以在不冒著失去控制的" -"風險下執行腳本。如果在絕對有必要立即結束的情況(例如在子行程呼叫完 :func:`os." -"fork` 之後 )可以使用 :func:`os._exit` 函式。" +"風險下執行腳本。如果在絕對有必要立即結束的情況(例如在子行程呼叫" +"完 :func:`os.fork` 之後 )可以使用 :func:`os._exit` 函式。" -#: ../../library/exceptions.rst:610 +#: ../../library/exceptions.rst:614 msgid "" "The exit status or error message that is passed to the constructor. " "(Defaults to ``None``.)" msgstr "傳入建構函式的結束狀態或錯誤訊息。(預設是 ``None``。 )" -#: ../../library/exceptions.rst:616 +#: ../../library/exceptions.rst:620 msgid "" "Raised when an operation or function is applied to an object of " "inappropriate type. The associated value is a string giving details about " @@ -920,7 +939,7 @@ msgstr "" "當一個操作或函式被用在不適合的型別的物件時會引發此例外。關聯值是一個字串,提" "供關於不相符型別的細節。" -#: ../../library/exceptions.rst:619 +#: ../../library/exceptions.rst:623 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 " @@ -931,27 +950,27 @@ msgstr "" "這樣做。如果一個物件有意要支援某個給定的操作但尚未提供實作,該引發的正確例外" "是 :exc:`NotImplementedError`。" -#: ../../library/exceptions.rst:624 +#: ../../library/exceptions.rst:628 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 passing " -"arguments with the wrong value (e.g. a number outside expected boundaries) " -"should result in a :exc:`ValueError`." +"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 " +"passing arguments with the wrong value (e.g. a number outside expected " +"boundaries) should result in a :exc:`ValueError`." msgstr "" "傳入錯誤型別的引數(例如當預期傳入 :class:`int` 卻傳入 :class:`list`)應該要" "導致 :exc:`TypeError`,但傳入帶有錯誤值的引數(例如超出預期範圍的數值)應該要" "導致 :exc:`ValueError`。" -#: ../../library/exceptions.rst:631 +#: ../../library/exceptions.rst:635 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 of :exc:" -"`NameError`." +"but no value has been bound to that variable. This is a subclass " +"of :exc:`NameError`." msgstr "" "當在函式或方法裡引用某個區域變數,但該變數尚未被繫結到任何值的時候會引發此例" "外。這是 :exc:`NameError` 的子類別。" -#: ../../library/exceptions.rst:638 +#: ../../library/exceptions.rst:642 msgid "" "Raised when a Unicode-related encoding or decoding error occurs. It is a " "subclass of :exc:`ValueError`." @@ -959,36 +978,42 @@ msgstr "" "當 Unicode 相關的編碼或解碼錯誤發生時會引發此例外。這是 :exc:`ValueError` 的" "子類別。" -#: ../../library/exceptions.rst:641 +#: ../../library/exceptions.rst:645 msgid "" ":exc:`UnicodeError` has attributes that describe the encoding or decoding " "error. For example, ``err.object[err.start:err.end]`` gives the particular " "invalid input that the codec failed on." msgstr "" -":exc:`UnicodeError` 有屬性描述編碼或解碼錯誤。例如 ``err.object[err.start:" -"err.end]`` 會提供讓編解碼器失敗的具體無效輸入。" +":exc:`UnicodeError` 有屬性描述編碼或解碼錯誤。例如 " +"``err.object[err.start:err.end]`` 會提供讓編解碼器失敗的具體無效輸入。" -#: ../../library/exceptions.rst:647 +#: ../../library/exceptions.rst:651 msgid "The name of the encoding that raised the error." msgstr "引發錯誤的編碼名稱。" -#: ../../library/exceptions.rst:651 +#: ../../library/exceptions.rst:655 msgid "A string describing the specific codec error." msgstr "描述特定編解碼器錯誤的字串。" -#: ../../library/exceptions.rst:655 +#: ../../library/exceptions.rst:659 msgid "The object the codec was attempting to encode or decode." msgstr "編解碼器嘗試編碼或解碼的物件。" -#: ../../library/exceptions.rst:659 +#: ../../library/exceptions.rst:663 msgid "The first index of invalid data in :attr:`object`." msgstr "在 :attr:`object` 中無效資料的開始索引。" -#: ../../library/exceptions.rst:663 +#: ../../library/exceptions.rst:665 ../../library/exceptions.rst:672 +msgid "" +"This value should not be negative as it is interpreted as an absolute offset " +"but this constraint is not enforced at runtime." +msgstr "" + +#: ../../library/exceptions.rst:670 msgid "The index after the last invalid data in :attr:`object`." msgstr "在 :attr:`object` 中最後的無效資料後的索引。" -#: ../../library/exceptions.rst:668 +#: ../../library/exceptions.rst:678 msgid "" "Raised when a Unicode-related error occurs during encoding. It is a " "subclass of :exc:`UnicodeError`." @@ -996,7 +1021,7 @@ msgstr "" "在編碼當中發生 Unicode 相關錯誤時會引發此例外。這是 :exc:`UnicodeError` 的子" "類別。" -#: ../../library/exceptions.rst:674 +#: ../../library/exceptions.rst:684 msgid "" "Raised when a Unicode-related error occurs during decoding. It is a " "subclass of :exc:`UnicodeError`." @@ -1004,7 +1029,7 @@ msgstr "" "在解碼當中發生 Unicode 相關錯誤時會引發此例外。這是 :exc:`UnicodeError` 的子" "類別。" -#: ../../library/exceptions.rst:680 +#: ../../library/exceptions.rst:690 msgid "" "Raised when a Unicode-related error occurs during translating. It is a " "subclass of :exc:`UnicodeError`." @@ -1012,7 +1037,7 @@ msgstr "" "在轉譯當中發生 Unicode 相關錯誤時會引發此例外。這是 :exc:`UnicodeError` 的子" "類別。" -#: ../../library/exceptions.rst:686 +#: ../../library/exceptions.rst:696 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 " @@ -1021,7 +1046,7 @@ msgstr "" "當一個操作或函式收到引數是正確型別但是不適合的值,且該情況無法被更精確的例外" "例如 :exc:`IndexError` 所描述時會引發此例外。" -#: ../../library/exceptions.rst:693 +#: ../../library/exceptions.rst:703 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 " @@ -1030,47 +1055,47 @@ msgstr "" "當除法或模數運算 (modulo operation) 的第二個引數是 0 的時候會引發此例外。關聯" "值是一個字串,表示運算元及運算的類型。" -#: ../../library/exceptions.rst:698 +#: ../../library/exceptions.rst:708 msgid "" "The following exceptions are kept for compatibility with previous versions; " "starting from Python 3.3, they are aliases of :exc:`OSError`." msgstr "" -"以下例外是為了相容於之前版本而保留;從 Python 3.3 開始,它們是 :exc:" -"`OSError` 的別名。" +"以下例外是為了相容於之前版本而保留;從 Python 3.3 開始,它們" +"是 :exc:`OSError` 的別名。" -#: ../../library/exceptions.rst:707 +#: ../../library/exceptions.rst:717 msgid "Only available on Windows." msgstr "僅限於在 Windows 中使用。" -#: ../../library/exceptions.rst:711 +#: ../../library/exceptions.rst:721 msgid "OS exceptions" msgstr "作業系統例外" -#: ../../library/exceptions.rst:713 +#: ../../library/exceptions.rst:723 msgid "" "The following exceptions are subclasses of :exc:`OSError`, they get raised " "depending on the system error code." msgstr "以下的例外是 :exc:`OSError` 的子類別,它們根據系統錯誤代碼來引發。" -#: ../../library/exceptions.rst:718 +#: ../../library/exceptions.rst:728 msgid "" "Raised when an operation would block on an object (e.g. socket) set for non-" -"blocking operation. Corresponds to :c:data:`errno` :py:const:`~errno." -"EAGAIN`, :py:const:`~errno.EALREADY`, :py:const:`~errno.EWOULDBLOCK` and :py:" -"const:`~errno.EINPROGRESS`." +"blocking operation. Corresponds " +"to :c:data:`errno` :py:const:`~errno.EAGAIN`, :py:const:`~errno.EALREADY`, :py:const:`~errno.EWOULDBLOCK` " +"and :py:const:`~errno.EINPROGRESS`." msgstr "" "當設置為非阻塞操作的物件(例如 socket)上的操作將要阻塞時會引發此例外。對應" -"到 :c:data:`errno` :py:const:`~errno.EAGAIN`、:py:const:`~errno.EALREADY`、:" -"py:const:`~errno.EWOULDBLOCK` 及 :py:const:`~errno.EINPROGRESS`。" +"到 :c:data:`errno` :py:const:`~errno.EAGAIN`、:py:const:`~errno.EALREADY`、:py:const:`~errno.EWOULDBLOCK` " +"及 :py:const:`~errno.EINPROGRESS`。" -#: ../../library/exceptions.rst:723 +#: ../../library/exceptions.rst:733 msgid "" "In addition to those of :exc:`OSError`, :exc:`BlockingIOError` can have one " "more attribute:" msgstr "" "除了 :exc:`OSError` 的那些屬性之外,:exc:`BlockingIOError` 有多一個屬性:" -#: ../../library/exceptions.rst:728 +#: ../../library/exceptions.rst:738 msgid "" "An integer containing the number of characters written to the stream before " "it blocked. This attribute is available when using the buffered I/O classes " @@ -1079,56 +1104,58 @@ msgstr "" "一個整數,內容為在其阻塞之前,已寫進串流的字元數。當使用 :mod:`io` 模組裡的緩" "衝 I/O 類別時這個屬性是可用的。" -#: ../../library/exceptions.rst:734 +#: ../../library/exceptions.rst:744 msgid "" -"Raised when an operation on a child process failed. Corresponds to :c:data:" -"`errno` :py:const:`~errno.ECHILD`." +"Raised when an operation on a child process failed. Corresponds " +"to :c:data:`errno` :py:const:`~errno.ECHILD`." msgstr "" -"當子行程上的操作失敗時會引發此例外。對應到 :c:data:`errno` :py:const:`~errno." -"ECHILD`。" +"當子行程上的操作失敗時會引發此例外。對應" +"到 :c:data:`errno` :py:const:`~errno.ECHILD`。" -#: ../../library/exceptions.rst:739 +#: ../../library/exceptions.rst:749 msgid "A base class for connection-related issues." msgstr "連線相關問題的基礎類別。" -#: ../../library/exceptions.rst:741 +#: ../../library/exceptions.rst:751 msgid "" -"Subclasses are :exc:`BrokenPipeError`, :exc:`ConnectionAbortedError`, :exc:" -"`ConnectionRefusedError` and :exc:`ConnectionResetError`." +"Subclasses " +"are :exc:`BrokenPipeError`, :exc:`ConnectionAbortedError`, :exc:`ConnectionRefusedError` " +"and :exc:`ConnectionResetError`." msgstr "" -"子類別有 :exc:`BrokenPipeError`、:exc:`ConnectionAbortedError`、:exc:" -"`ConnectionRefusedError` 及 :exc:`ConnectionResetError`。" +"子類別" +"有 :exc:`BrokenPipeError`、:exc:`ConnectionAbortedError`、:exc:`ConnectionRefusedError` " +"及 :exc:`ConnectionResetError`。" -#: ../../library/exceptions.rst:746 +#: ../../library/exceptions.rst:756 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 " -"has been shutdown for writing. Corresponds to :c:data:`errno` :py:const:" -"`~errno.EPIPE` and :py:const:`~errno.ESHUTDOWN`." +"has been shutdown for writing. Corresponds " +"to :c:data:`errno` :py:const:`~errno.EPIPE` and :py:const:`~errno.ESHUTDOWN`." msgstr "" ":exc:`ConnectionError` 的子類別,當嘗試寫入管道 (pipe) 同時另一端已經被關閉時" -"會引發此例外,或者當嘗試寫入已關閉寫入的 socket 時也會引發。對應到 :c:data:" -"`errno` :py:const:`~errno.EPIPE` 及 :py:const:`~errno.ESHUTDOWN`。" +"會引發此例外,或者當嘗試寫入已關閉寫入的 socket 時也會引發。對應" +"到 :c:data:`errno` :py:const:`~errno.EPIPE` 及 :py:const:`~errno.ESHUTDOWN`。" -#: ../../library/exceptions.rst:753 +#: ../../library/exceptions.rst:763 msgid "" "A subclass of :exc:`ConnectionError`, raised when a connection attempt is " -"aborted by the peer. Corresponds to :c:data:`errno` :py:const:`~errno." -"ECONNABORTED`." +"aborted by the peer. Corresponds " +"to :c:data:`errno` :py:const:`~errno.ECONNABORTED`." msgstr "" ":exc:`ConnectionError` 的子類別。當一個連線的嘗試被對等端點 (peer) 中斷時會引" "發此例外。對應到 :c:data:`errno` :py:const:`~errno.ECONNABORTED`。" -#: ../../library/exceptions.rst:759 +#: ../../library/exceptions.rst:769 msgid "" "A subclass of :exc:`ConnectionError`, raised when a connection attempt is " -"refused by the peer. Corresponds to :c:data:`errno` :py:const:`~errno." -"ECONNREFUSED`." +"refused by the peer. Corresponds " +"to :c:data:`errno` :py:const:`~errno.ECONNREFUSED`." msgstr "" ":exc:`ConnectionError` 的子類別。當一個連線的嘗試被對等端點拒絕時會引發此例" "外。對應到 :c:data:`errno` :py:const:`~errno.ECONNREFUSED`。" -#: ../../library/exceptions.rst:765 +#: ../../library/exceptions.rst:775 msgid "" "A subclass of :exc:`ConnectionError`, raised when a connection is reset by " "the peer. Corresponds to :c:data:`errno` :py:const:`~errno.ECONNRESET`." @@ -1136,146 +1163,146 @@ msgstr "" ":exc:`ConnectionError` 的子類別。當一個連線被對等端點重置時會引發此例外。對應" "到 :c:data:`errno` :py:const:`~errno.ECONNRESET`。" -#: ../../library/exceptions.rst:771 +#: ../../library/exceptions.rst:781 msgid "" "Raised when trying to create a file or directory which already exists. " "Corresponds to :c:data:`errno` :py:const:`~errno.EEXIST`." msgstr "" -"當嘗試建立已存在的檔案或目錄時會引發此例外。對應到 :c:data:`errno` :py:const:" -"`~errno.EEXIST`。" +"當嘗試建立已存在的檔案或目錄時會引發此例外。對應" +"到 :c:data:`errno` :py:const:`~errno.EEXIST`。" -#: ../../library/exceptions.rst:776 +#: ../../library/exceptions.rst:786 msgid "" "Raised when a file or directory is requested but doesn't exist. Corresponds " "to :c:data:`errno` :py:const:`~errno.ENOENT`." msgstr "" -"當請求不存在的檔案或目錄時會引發此例外。對應到 :c:data:`errno` :py:const:" -"`~errno.ENOENT`。" +"當請求不存在的檔案或目錄時會引發此例外。對應" +"到 :c:data:`errno` :py:const:`~errno.ENOENT`。" -#: ../../library/exceptions.rst:781 +#: ../../library/exceptions.rst:791 msgid "" "Raised when a system call is interrupted by an incoming signal. Corresponds " "to :c:data:`errno` :py:const:`~errno.EINTR`." msgstr "" -"當系統呼叫被傳入的信號中斷時會引發此例外。對應到 :c:data:`errno` :py:const:" -"`~errno.EINTR`。" +"當系統呼叫被傳入的信號中斷時會引發此例外。對應" +"到 :c:data:`errno` :py:const:`~errno.EINTR`。" -#: ../../library/exceptions.rst:784 +#: ../../library/exceptions.rst:794 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 " "rationale), instead of raising :exc:`InterruptedError`." msgstr "" -"現在當 syscall 被信號中斷時 Python 會重試系統呼叫而不會引發 :exc:" -"`InterruptedError`,除非信號處理器引發例外(理由可參考 :pep:`475`)。" +"現在當 syscall 被信號中斷時 Python 會重試系統呼叫而不會引" +"發 :exc:`InterruptedError`,除非信號處理器引發例外(理由可參考 :pep:`475`)。" -#: ../../library/exceptions.rst:791 +#: ../../library/exceptions.rst:801 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`." msgstr "" -"當在目錄上請求檔案操作(例如 :func:`os.remove`)時會引發此例外。對應到 :c:" -"data:`errno` :py:const:`~errno.EISDIR`。" +"當在目錄上請求檔案操作(例如 :func:`os.remove`)時會引發此例外。對應" +"到 :c:data:`errno` :py:const:`~errno.EISDIR`。" -#: ../../library/exceptions.rst:797 +#: ../../library/exceptions.rst:807 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 " "be raised if an operation attempts to open or traverse a non-directory file " -"as if it were a directory. Corresponds to :c:data:`errno` :py:const:`~errno." -"ENOTDIR`." +"as if it were a directory. Corresponds " +"to :c:data:`errno` :py:const:`~errno.ENOTDIR`." msgstr "" "當在某個不是目錄的東西上請求目錄操作(例如 :func:`os.listdir`)時會引發此例" "外。在大多數的 POSIX 平台上,如果嘗試操作開啟或遍歷一個當作目錄的非目錄檔案也" "會引發此例外。對應到 :c:data:`errno` :py:const:`~errno.ENOTDIR`。" -#: ../../library/exceptions.rst:805 +#: ../../library/exceptions.rst:815 msgid "" "Raised when trying to run an operation without the adequate access rights - " -"for example filesystem permissions. Corresponds to :c:data:`errno` :py:const:" -"`~errno.EACCES`, :py:const:`~errno.EPERM`, and :py:const:`~errno." -"ENOTCAPABLE`." +"for example filesystem permissions. Corresponds " +"to :c:data:`errno` :py:const:`~errno.EACCES`, :py:const:`~errno.EPERM`, " +"and :py:const:`~errno.ENOTCAPABLE`." msgstr "" "當嘗試執行一個沒有合乎存取權限的操作時會引發此例外 — 例如檔案系統權限。對應" -"到 :c:data:`errno` :py:const:`~errno.EACCES`、:py:const:`~errno.EPERM` 及 :" -"py:const:`~errno.ENOTCAPABLE`。" +"到 :c:data:`errno` :py:const:`~errno.EACCES`、:py:const:`~errno.EPERM` " +"及 :py:const:`~errno.ENOTCAPABLE`。" -#: ../../library/exceptions.rst:810 +#: ../../library/exceptions.rst:820 msgid "" -"WASI's :py:const:`~errno.ENOTCAPABLE` is now mapped to :exc:" -"`PermissionError`." +"WASI's :py:const:`~errno.ENOTCAPABLE` is now mapped " +"to :exc:`PermissionError`." msgstr "" "WASI 的 :py:const:`~errno.ENOTCAPABLE` 現在對應到 :exc:`PermissionError`。" -#: ../../library/exceptions.rst:816 +#: ../../library/exceptions.rst:826 msgid "" -"Raised when a given process doesn't exist. Corresponds to :c:data:`errno` :" -"py:const:`~errno.ESRCH`." +"Raised when a given process doesn't exist. Corresponds " +"to :c:data:`errno` :py:const:`~errno.ESRCH`." msgstr "" -"當給定的行程不存在時會引發此例外。對應到 :c:data:`errno` :py:const:`~errno." -"ESRCH`。" +"當給定的行程不存在時會引發此例外。對應" +"到 :c:data:`errno` :py:const:`~errno.ESRCH`。" -#: ../../library/exceptions.rst:821 +#: ../../library/exceptions.rst:831 msgid "" -"Raised when a system function timed out at the system level. Corresponds to :" -"c:data:`errno` :py:const:`~errno.ETIMEDOUT`." +"Raised when a system function timed out at the system level. Corresponds " +"to :c:data:`errno` :py:const:`~errno.ETIMEDOUT`." msgstr "" -"當系統函式在系統層級超時會引發此例外。對應到 :c:data:`errno` :py:const:" -"`~errno.ETIMEDOUT`。" +"當系統函式在系統層級超時會引發此例外。對應" +"到 :c:data:`errno` :py:const:`~errno.ETIMEDOUT`。" -#: ../../library/exceptions.rst:824 +#: ../../library/exceptions.rst:834 msgid "All the above :exc:`OSError` subclasses were added." msgstr "加入以上所有的 :exc:`OSError` 子類別。" -#: ../../library/exceptions.rst:830 +#: ../../library/exceptions.rst:840 msgid ":pep:`3151` - Reworking the OS and IO exception hierarchy" msgstr ":pep:`3151` — 改寫作業系統與 IO 例外階層" -#: ../../library/exceptions.rst:836 +#: ../../library/exceptions.rst:846 msgid "Warnings" msgstr "警告" -#: ../../library/exceptions.rst:838 +#: ../../library/exceptions.rst:848 msgid "" -"The following exceptions are used as warning categories; see the :ref:" -"`warning-categories` documentation for more details." +"The following exceptions are used as warning categories; see " +"the :ref:`warning-categories` documentation for more details." msgstr "" "以下的例外是當作警告的種類使用;更多細節參考 :ref:`warning-categories` 文件。" -#: ../../library/exceptions.rst:843 +#: ../../library/exceptions.rst:853 msgid "Base class for warning categories." msgstr "警告種類的基礎類別。" -#: ../../library/exceptions.rst:848 +#: ../../library/exceptions.rst:858 msgid "Base class for warnings generated by user code." msgstr "使用者程式碼產生的警告的基礎類別。" -#: ../../library/exceptions.rst:853 +#: ../../library/exceptions.rst:863 msgid "" "Base class for warnings about deprecated features when those warnings are " "intended for other Python developers." msgstr "關於已棄用功能的警告的基礎類別,且當那些警告是針對其他 Python 開發者。" -#: ../../library/exceptions.rst:856 +#: ../../library/exceptions.rst:866 msgid "" -"Ignored by the default warning filters, except in the ``__main__`` module (:" -"pep:`565`). Enabling the :ref:`Python Development Mode ` shows this " -"warning." +"Ignored by the default warning filters, except in the ``__main__`` module " +"(:pep:`565`). Enabling the :ref:`Python Development Mode ` shows " +"this warning." msgstr "" -"會被預設的警告過濾器忽略,在 ``__main__`` 模組裡除外 (:pep:`565`)。啟用 :ref:" -"`Python 開發模式 `\\ 會顯示此警告。" +"會被預設的警告過濾器忽略,在 ``__main__`` 模組裡除外 (:pep:`565`)。啟" +"用 :ref:`Python 開發模式 `\\ 會顯示此警告。" -#: ../../library/exceptions.rst:860 ../../library/exceptions.rst:876 +#: ../../library/exceptions.rst:870 ../../library/exceptions.rst:886 msgid "The deprecation policy is described in :pep:`387`." msgstr "棄用原則描述在 :pep:`387` 裡。" -#: ../../library/exceptions.rst:865 +#: ../../library/exceptions.rst:875 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 "關於過時且預期未來要被棄用,但目前尚未被棄用的功能的警告的基礎類別。" -#: ../../library/exceptions.rst:869 +#: ../../library/exceptions.rst:879 msgid "" "This class is rarely used as emitting a warning about a possible upcoming " "deprecation is unusual, and :exc:`DeprecationWarning` is preferred for " @@ -1284,8 +1311,8 @@ msgstr "" "因為發出關於可能即將被棄用的警告是不尋常的,此類別很少被使用,而對已經被棄用" "的情況會優先使用 :exc:`DeprecationWarning`。" -#: ../../library/exceptions.rst:873 ../../library/exceptions.rst:902 -#: ../../library/exceptions.rst:929 +#: ../../library/exceptions.rst:883 ../../library/exceptions.rst:912 +#: ../../library/exceptions.rst:939 msgid "" "Ignored by the default warning filters. Enabling the :ref:`Python " "Development Mode ` shows this warning." @@ -1293,21 +1320,21 @@ msgstr "" "會被預設的警告過濾器忽略。啟用 :ref:`Python 開發模式 `\\ 會顯示此警" "告。" -#: ../../library/exceptions.rst:881 +#: ../../library/exceptions.rst:891 msgid "Base class for warnings about dubious syntax." msgstr "關於可疑語法的警告的基礎類別。" -#: ../../library/exceptions.rst:883 +#: ../../library/exceptions.rst:893 msgid "" "This warning is typically emitted when compiling Python source code, and " "usually won't be reported when running already compiled code." msgstr "" -#: ../../library/exceptions.rst:889 +#: ../../library/exceptions.rst:899 msgid "Base class for warnings about dubious runtime behavior." msgstr "關於可疑執行環境行為的警告的基礎類別。" -#: ../../library/exceptions.rst:894 +#: ../../library/exceptions.rst:904 msgid "" "Base class for warnings about deprecated features when those warnings are " "intended for end users of applications that are written in Python." @@ -1315,36 +1342,36 @@ msgstr "" "關於已棄用功能的警告的基礎類別,且當那些警告是針對以 Python 寫的應用程式的終" "端使用者。" -#: ../../library/exceptions.rst:900 +#: ../../library/exceptions.rst:910 msgid "Base class for warnings about probable mistakes in module imports." msgstr "關於在模組引入的可能錯誤的警告的基礎類別。" -#: ../../library/exceptions.rst:908 +#: ../../library/exceptions.rst:918 msgid "Base class for warnings related to Unicode." msgstr "Unicode 相關警告的基礎類別。" -#: ../../library/exceptions.rst:913 +#: ../../library/exceptions.rst:923 msgid "Base class for warnings related to encodings." msgstr "編碼相關警告的基礎類別。" -#: ../../library/exceptions.rst:915 +#: ../../library/exceptions.rst:925 msgid "See :ref:`io-encoding-warning` for details." msgstr "細節參考\\ :ref:`io-encoding-warning`。" -#: ../../library/exceptions.rst:922 +#: ../../library/exceptions.rst:932 msgid "" "Base class for warnings related to :class:`bytes` and :class:`bytearray`." msgstr ":class:`bytes` 及 :class:`bytearray` 相關警告的基礎類別。" -#: ../../library/exceptions.rst:927 +#: ../../library/exceptions.rst:937 msgid "Base class for warnings related to resource usage." msgstr "資源用法相關警告的基礎類別。" -#: ../../library/exceptions.rst:938 +#: ../../library/exceptions.rst:948 msgid "Exception groups" msgstr "例外群組" -#: ../../library/exceptions.rst:940 +#: ../../library/exceptions.rst:950 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 " @@ -1356,46 +1383,48 @@ msgstr "" "所有其他例外一樣使用 :keyword:`except` 來處理。此外,它們會以包含的例外型別為" "基礎來比對其子群組而被 :keyword:`except*` 辨認出來。" -#: ../../library/exceptions.rst:949 +#: ../../library/exceptions.rst:959 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 " "classes is that :exc:`BaseExceptionGroup` extends :exc:`BaseException` and " -"it can wrap any exception, while :exc:`ExceptionGroup` extends :exc:" -"`Exception` and it can only wrap subclasses of :exc:`Exception`. This design " -"is so that ``except Exception`` catches an :exc:`ExceptionGroup` but not :" -"exc:`BaseExceptionGroup`." +"it can wrap any exception, while :exc:`ExceptionGroup` " +"extends :exc:`Exception` and it can only wrap subclasses " +"of :exc:`Exception`. This design is so that ``except Exception`` catches " +"an :exc:`ExceptionGroup` but not :exc:`BaseExceptionGroup`." msgstr "" "這兩個例外型別都將例外包裝在序列 ``excs`` 中。``msg`` 參數必須是字串。這兩個" "類別的差異是 :exc:`BaseExceptionGroup` 擴充了 :exc:`BaseException` 且可以包裝" -"任何例外,而 :exc:`ExceptionGroup` 擴充了 :exc:`Exception` 且只能包裝 :exc:" -"`Exception` 的子類別。這個設計使得 ``except Exception`` 可以捕捉 :exc:" -"`ExceptionGroup` 但不能捕捉 :exc:`BaseExceptionGroup`。" +"任何例外,而 :exc:`ExceptionGroup` 擴充了 :exc:`Exception` 且只能包" +"裝 :exc:`Exception` 的子類別。這個設計使得 ``except Exception`` 可以捕" +"捉 :exc:`ExceptionGroup` 但不能捕捉 :exc:`BaseExceptionGroup`。" -#: ../../library/exceptions.rst:957 +#: ../../library/exceptions.rst:967 msgid "" "The :exc:`BaseExceptionGroup` constructor returns an :exc:`ExceptionGroup` " -"rather than a :exc:`BaseExceptionGroup` if all contained exceptions are :exc:" -"`Exception` instances, so it can be used to make the selection automatic. " -"The :exc:`ExceptionGroup` constructor, on the other hand, raises a :exc:" -"`TypeError` if any contained exception is not an :exc:`Exception` subclass." +"rather than a :exc:`BaseExceptionGroup` if all contained exceptions " +"are :exc:`Exception` instances, so it can be used to make the selection " +"automatic. The :exc:`ExceptionGroup` constructor, on the other hand, raises " +"a :exc:`TypeError` if any contained exception is not an :exc:`Exception` " +"subclass." msgstr "" "如果所有包含的例外都是 :exc:`Exception` 實例,:exc:`BaseExceptionGroup` 建構" "函式會回傳 :exc:`ExceptionGroup` 而不是 :exc:`BaseExceptionGroup`,因此可以被" -"使用來讓這樣的選擇自動化。另一方面來說,如果任何包含的例外不是 :exc:" -"`Exception` 的子類別,:exc:`ExceptionGroup` 建構函式會引發 :exc:`TypeError`。" +"使用來讓這樣的選擇自動化。另一方面來說,如果任何包含的例外不" +"是 :exc:`Exception` 的子類別,:exc:`ExceptionGroup` 建構函式會引" +"發 :exc:`TypeError`。" -#: ../../library/exceptions.rst:966 +#: ../../library/exceptions.rst:976 msgid "The ``msg`` argument to the constructor. This is a read-only attribute." msgstr "建構函式的 ``msg`` 引數。這是一個唯讀的屬性。" -#: ../../library/exceptions.rst:970 +#: ../../library/exceptions.rst:980 msgid "" "A tuple of the exceptions in the ``excs`` sequence given to the constructor. " "This is a read-only attribute." msgstr "指定給建構函式 ``excs`` 序列中的例外組成的元組。這是一個唯讀的屬性。" -#: ../../library/exceptions.rst:975 +#: ../../library/exceptions.rst:985 msgid "" "Returns an exception group that contains only the exceptions from the " "current group that match *condition*, or ``None`` if the result is empty." @@ -1403,7 +1432,7 @@ msgstr "" "回傳只包含從現有群組比對到 *condition* 的例外的例外群組,或者當結果為空時回" "傳 ``None``。" -#: ../../library/exceptions.rst:978 +#: ../../library/exceptions.rst:988 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 " @@ -1416,20 +1445,20 @@ msgstr "" "物件(除了型別物件之外),其接受一個例外作為單一引數,而如果該例外應該在子群" "組中就回傳 true。" -#: ../../library/exceptions.rst:984 +#: ../../library/exceptions.rst:994 msgid "" "The nesting structure of the current exception is preserved in the result, " -"as are the values of its :attr:`message`, :attr:`~BaseException." -"__traceback__`, :attr:`~BaseException.__cause__`, :attr:`~BaseException." -"__context__` and :attr:`~BaseException.__notes__` fields. Empty nested " -"groups are omitted from the result." +"as are the values of " +"its :attr:`message`, :attr:`~BaseException.__traceback__`, :attr:`~BaseException.__cause__`, :attr:`~BaseException.__context__` " +"and :attr:`~BaseException.__notes__` fields. Empty nested groups are omitted " +"from the result." msgstr "" -"現有例外的巢狀結構會保留在結果裡,其 :attr:`message`、:attr:`~BaseException." -"__traceback__`、:attr:`~BaseException.__cause__`、:attr:`~BaseException." -"__context__` 及 :attr:`~BaseException.__notes__` 欄位的值也一樣。空的巢狀群組" -"會從結果裡排除。" +"現有例外的巢狀結構會保留在結果裡," +"其 :attr:`message`、:attr:`~BaseException.__traceback__`、:attr:`~BaseException.__cause__`、:attr:`~BaseException.__context__` " +"及 :attr:`~BaseException.__notes__` 欄位的值也一樣。空的巢狀群組會從結果裡排" +"除。" -#: ../../library/exceptions.rst:991 +#: ../../library/exceptions.rst:1001 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 " @@ -1438,11 +1467,11 @@ msgstr "" "條件會對巢狀例外群組裡的所有例外做檢查,包括頂層及任何巢狀的例外群組。如果條" "件對這樣的例外群組為 true,它會被完整包含在結果裡。" -#: ../../library/exceptions.rst:995 +#: ../../library/exceptions.rst:1005 msgid "``condition`` can be any callable which is not a type object." msgstr "``condition`` 可以是任何不是型別物件的可呼叫物件。" -#: ../../library/exceptions.rst:1000 +#: ../../library/exceptions.rst:1010 msgid "" "Like :meth:`subgroup`, but returns the pair ``(match, rest)`` where " "``match`` is ``subgroup(condition)`` and ``rest`` is the remaining non-" @@ -1451,13 +1480,13 @@ msgstr "" "像 :meth:`subgroup` 一樣,但回傳一對 ``(match, rest)``,其中 ``match`` 是 " "``subgroup(condition)`` 而 ``rest`` 是剩下沒有比對到的部分。" -#: ../../library/exceptions.rst:1006 +#: ../../library/exceptions.rst:1016 msgid "" "Returns an exception group with the same :attr:`message`, but which wraps " "the exceptions in ``excs``." msgstr "回傳有相同 :attr:`message` 但將例外包裝在 ``excs`` 的例外群組。" -#: ../../library/exceptions.rst:1009 +#: ../../library/exceptions.rst:1019 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 " @@ -1465,23 +1494,23 @@ msgid "" "instances of the subclass rather than :exc:`ExceptionGroup`." msgstr "" "此方法被 :meth:`subgroup` 及 :meth:`split` 使用,被用來在各種情境下拆分例外群" -"組。子類別需要覆寫它來讓 :meth:`subgroup` 及 :meth:`split` 回傳子類別而不是 :" -"exc:`ExceptionGroup` 的實例。" +"組。子類別需要覆寫它來讓 :meth:`subgroup` 及 :meth:`split` 回傳子類別而不" +"是 :exc:`ExceptionGroup` 的實例。" -#: ../../library/exceptions.rst:1015 +#: ../../library/exceptions.rst:1025 msgid "" -":meth:`subgroup` and :meth:`split` copy the :attr:`~BaseException." -"__traceback__`, :attr:`~BaseException.__cause__`, :attr:`~BaseException." -"__context__` and :attr:`~BaseException.__notes__` fields from the original " -"exception group to the one returned by :meth:`derive`, so these fields do " -"not need to be updated by :meth:`derive`." +":meth:`subgroup` and :meth:`split` copy " +"the :attr:`~BaseException.__traceback__`, :attr:`~BaseException.__cause__`, :attr:`~BaseException.__context__` " +"and :attr:`~BaseException.__notes__` fields from the original exception " +"group to the one returned by :meth:`derive`, so these fields do not need to " +"be updated by :meth:`derive`." msgstr "" -":meth:`subgroup` 及 :meth:`split` 會從原始的例外群組複製 :attr:" -"`~BaseException.__traceback__`、:attr:`~BaseException.__cause__`、:attr:" -"`~BaseException.__context__` 和 :attr:`~BaseException.__notes__` 欄位到 :" -"meth:`derive` 所回傳的例外群組上,因此這些欄位不需要被 :meth:`derive` 更新。" +":meth:`subgroup` 及 :meth:`split` 會從原始的例外群組複" +"製 :attr:`~BaseException.__traceback__`、:attr:`~BaseException.__cause__`、:attr:`~BaseException.__context__` " +"和 :attr:`~BaseException.__notes__` 欄位到 :meth:`derive` 所回傳的例外群組" +"上,因此這些欄位不需要被 :meth:`derive` 更新。" -#: ../../library/exceptions.rst:1022 +#: ../../library/exceptions.rst:1032 msgid "" ">>> class MyGroup(ExceptionGroup):\n" "... def derive(self, excs):\n" @@ -1535,7 +1564,7 @@ msgstr "" ">>> exc.__traceback__ is match.__traceback__ is rest.__traceback__\n" "True" -#: ../../library/exceptions.rst:1048 +#: ../../library/exceptions.rst:1058 msgid "" "Note that :exc:`BaseExceptionGroup` defines :meth:`~object.__new__`, so " "subclasses that need a different constructor signature need to override that " @@ -1547,7 +1576,7 @@ msgstr "" "建構函式簽名的子類別需要覆寫它而不是 :meth:`~object.__init__`。例如下面定義了" "一個例外群組子類別接受 exit_code 並從中建構群組的訊息。: ::" -#: ../../library/exceptions.rst:1054 +#: ../../library/exceptions.rst:1064 msgid "" "class Errors(ExceptionGroup):\n" " def __new__(cls, errors, exit_code):\n" @@ -1567,24 +1596,24 @@ msgstr "" " def derive(self, excs):\n" " return Errors(excs, self.exit_code)" -#: ../../library/exceptions.rst:1063 +#: ../../library/exceptions.rst:1073 msgid "" "Like :exc:`ExceptionGroup`, any subclass of :exc:`BaseExceptionGroup` which " -"is also a subclass of :exc:`Exception` can only wrap instances of :exc:" -"`Exception`." +"is also a subclass of :exc:`Exception` can only wrap instances " +"of :exc:`Exception`." msgstr "" "像 :exc:`ExceptionGroup` 一樣,任何 :exc:`BaseExceptionGroup` 的子類別且也" "是 :exc:`Exception` 的子類別只能包裝 :exc:`Exception` 的實例。" -#: ../../library/exceptions.rst:1071 +#: ../../library/exceptions.rst:1081 msgid "Exception hierarchy" msgstr "例外階層" -#: ../../library/exceptions.rst:1073 +#: ../../library/exceptions.rst:1083 msgid "The class hierarchy for built-in exceptions is:" msgstr "內建例外的類別階層如下:" -#: ../../library/exceptions.rst:1075 +#: ../../library/exceptions.rst:1085 msgid "" "BaseException\n" " ├── BaseExceptionGroup\n" diff --git a/library/faulthandler.po b/library/faulthandler.po index 202d723b3c3..9a1ae1bc93e 100644 --- a/library/faulthandler.po +++ b/library/faulthandler.po @@ -1,12 +1,12 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"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: 2025-09-08 15:25+0800\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-" @@ -24,10 +24,10 @@ msgstr ":mod:`!faulthandler` --- 傾印 Python 回溯" #: ../../library/faulthandler.rst:11 msgid "" "This module contains functions to dump Python tracebacks explicitly, on a " -"fault, after a timeout, or on a user signal. Call :func:`faulthandler." -"enable` to install fault handlers for the :const:`~signal.SIGSEGV`, :const:" -"`~signal.SIGFPE`, :const:`~signal.SIGABRT`, :const:`~signal.SIGBUS`, and :" -"const:`~signal.SIGILL` signals. You can also enable them at startup by " +"fault, after a timeout, or on a user signal. " +"Call :func:`faulthandler.enable` to install fault handlers for " +"the :const:`~signal.SIGSEGV`, :const:`~signal.SIGFPE`, :const:`~signal.SIGABRT`, :const:`~signal.SIGBUS`, " +"and :const:`~signal.SIGILL` signals. You can also enable them at startup by " "setting the :envvar:`PYTHONFAULTHANDLER` environment variable or by using " "the :option:`-X` ``faulthandler`` command line option." msgstr "" @@ -87,8 +87,8 @@ msgstr "" #: ../../library/faulthandler.rst:44 msgid "" -"The :ref:`Python Development Mode ` calls :func:`faulthandler." -"enable` at Python startup." +"The :ref:`Python Development Mode ` " +"calls :func:`faulthandler.enable` at Python startup." msgstr "" #: ../../library/faulthandler.rst:49 @@ -124,117 +124,175 @@ msgid "" ":func:`traceback.print_tb`, which can be used to print a traceback object." msgstr "" -#: ../../library/faulthandler.rst:65 ../../library/faulthandler.rst:84 -#: ../../library/faulthandler.rst:123 ../../library/faulthandler.rst:148 +#: ../../library/faulthandler.rst:65 ../../library/faulthandler.rst:119 +#: ../../library/faulthandler.rst:165 ../../library/faulthandler.rst:190 msgid "Added support for passing file descriptor to this function." msgstr "" #: ../../library/faulthandler.rst:70 +msgid "Dumping the C stack" +msgstr "" + +#: ../../library/faulthandler.rst:76 +msgid "Dump the C stack trace of the current thread into *file*." +msgstr "" + +#: ../../library/faulthandler.rst:78 +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 +msgid "C Stack Compatibility" +msgstr "" + +#: ../../library/faulthandler.rst:87 +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 +msgid "" +"Additionally, some compilers do not support :term:`CPython's ` " +"implementation of C stack dumps. As a result, a different error may be " +"printed instead of the stack, even if the operating system supports dumping " +"stacks." +msgstr "" + +#: ../../library/faulthandler.rst:97 +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 msgid "Fault handler state" msgstr "" -#: ../../library/faulthandler.rst:74 +#: ../../library/faulthandler.rst:105 msgid "" -"Enable the fault handler: install handlers for the :const:`~signal." -"SIGSEGV`, :const:`~signal.SIGFPE`, :const:`~signal.SIGABRT`, :const:`~signal." -"SIGBUS` and :const:`~signal.SIGILL` signals to dump the Python traceback. If " +"Enable the fault handler: install handlers for " +"the :const:`~signal.SIGSEGV`, :const:`~signal.SIGFPE`, :const:`~signal.SIGABRT`, :const:`~signal.SIGBUS` " +"and :const:`~signal.SIGILL` signals to dump the Python traceback. If " "*all_threads* is ``True``, produce tracebacks for every running thread. " "Otherwise, dump only the current thread." msgstr "" -#: ../../library/faulthandler.rst:81 +#: ../../library/faulthandler.rst:112 msgid "" -"The *file* must be kept open until the fault handler is disabled: see :ref:" -"`issue with file descriptors `." +"The *file* must be kept open until the fault handler is disabled: " +"see :ref:`issue with file descriptors `." msgstr "" -#: ../../library/faulthandler.rst:87 +#: ../../library/faulthandler.rst:115 +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 msgid "On Windows, a handler for Windows exception is also installed." msgstr "" -#: ../../library/faulthandler.rst:90 +#: ../../library/faulthandler.rst:125 msgid "" "The dump now mentions if a garbage collector collection is running if " "*all_threads* is true." msgstr "" -#: ../../library/faulthandler.rst:96 +#: ../../library/faulthandler.rst:129 msgid "" -"Disable the fault handler: uninstall the signal handlers installed by :func:" -"`enable`." +"Only the current thread is dumped if the :term:`GIL` is disabled to prevent " +"the risk of data races." msgstr "" -#: ../../library/faulthandler.rst:101 +#: ../../library/faulthandler.rst:133 +msgid "The dump now displays the C stack trace if *c_stack* is true." +msgstr "" + +#: ../../library/faulthandler.rst:138 +msgid "" +"Disable the fault handler: uninstall the signal handlers installed " +"by :func:`enable`." +msgstr "" + +#: ../../library/faulthandler.rst:143 msgid "Check if the fault handler is enabled." msgstr "" -#: ../../library/faulthandler.rst:105 +#: ../../library/faulthandler.rst:147 msgid "Dumping the tracebacks after a timeout" msgstr "" -#: ../../library/faulthandler.rst:109 +#: ../../library/faulthandler.rst:151 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." msgstr "" -#: ../../library/faulthandler.rst:117 +#: ../../library/faulthandler.rst:159 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 " +"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:121 +#: ../../library/faulthandler.rst:163 msgid "This function is implemented using a watchdog thread." msgstr "" -#: ../../library/faulthandler.rst:126 +#: ../../library/faulthandler.rst:168 msgid "This function is now always available." msgstr "" -#: ../../library/faulthandler.rst:131 +#: ../../library/faulthandler.rst:173 msgid "Cancel the last call to :func:`dump_traceback_later`." msgstr "" -#: ../../library/faulthandler.rst:135 +#: ../../library/faulthandler.rst:177 msgid "Dumping the traceback on a user signal" msgstr "" -#: ../../library/faulthandler.rst:139 +#: ../../library/faulthandler.rst:181 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``." msgstr "" -#: ../../library/faulthandler.rst:143 +#: ../../library/faulthandler.rst:185 msgid "" -"The *file* must be kept open until the signal is unregistered by :func:" -"`unregister`: see :ref:`issue with file descriptors `." +"The *file* must be kept open until the signal is unregistered " +"by :func:`unregister`: see :ref:`issue with file descriptors `." msgstr "" -#: ../../library/faulthandler.rst:146 ../../library/faulthandler.rst:157 +#: ../../library/faulthandler.rst:188 ../../library/faulthandler.rst:199 msgid "Not available on Windows." msgstr "" -#: ../../library/faulthandler.rst:153 +#: ../../library/faulthandler.rst:195 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:163 +#: ../../library/faulthandler.rst:205 msgid "Issue with file descriptors" msgstr "" -#: ../../library/faulthandler.rst:165 +#: ../../library/faulthandler.rst:207 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 " @@ -243,17 +301,17 @@ msgid "" "Call these functions again each time that the file is replaced." msgstr "" -#: ../../library/faulthandler.rst:173 +#: ../../library/faulthandler.rst:215 msgid "Example" msgstr "範例" -#: ../../library/faulthandler.rst:175 +#: ../../library/faulthandler.rst:217 msgid "" "Example of a segmentation fault on Linux with and without enabling the fault " "handler:" msgstr "" -#: ../../library/faulthandler.rst:178 +#: ../../library/faulthandler.rst:220 msgid "" "$ python -c \"import ctypes; ctypes.string_at(0)\"\n" "Segmentation fault\n" @@ -264,21 +322,82 @@ msgid "" "Fatal Python error: Segmentation fault\n" "\n" "Current thread 0x00007fb899f39700 (most recent call first):\n" -" File \"/home/python/cpython/Lib/ctypes/__init__.py\", line 486 in " -"string_at\n" +" File \"/opt/python/Lib/ctypes/__init__.py\", line 486 in string_at\n" " File \"\", line 1 in \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 \"/home/python/cpython/Lib/ctypes/__init__.py\", line 486 in " -"string_at\n" -" File \"\", line 1 in \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.14/_ctypes.cpython-314d-" +"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-" +"x86_64-linux-gnu.so\", at +0x15a33 [0x77b7315e6a33]\n" +" Binary file \"/opt/python/build/lib.linux-x86_64-3.14/_ctypes.cpython-314d-" +"x86_64-linux-gnu.so\", at +0x164fa [0x77b7315e74fa]\n" +" Binary file \"/opt/python/build/lib.linux-x86_64-3.14/_ctypes.cpython-314d-" +"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" +msgstr "" + +#~ msgid "" +#~ "$ 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 \"/home/python/cpython/Lib/ctypes/__init__.py\", line 486 in " +#~ "string_at\n" +#~ " File \"\", line 1 in \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 \"/home/python/cpython/Lib/ctypes/__init__.py\", line 486 in " +#~ "string_at\n" +#~ " File \"\", line 1 in \n" +#~ "Segmentation fault" diff --git a/library/fcntl.po b/library/fcntl.po index bf6a8ef8140..7f8e4b7a7f9 100644 --- a/library/fcntl.po +++ b/library/fcntl.po @@ -1,13 +1,12 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-04-24 05:58+0000\n" +"POT-Creation-Date: 2025-09-08 15:25+0800\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-" @@ -25,8 +24,8 @@ msgstr ":mod:`!fcntl` --- ``fcntl`` 和 ``ioctl`` 系統呼叫" #: ../../library/fcntl.rst:16 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 :" -"manpage:`fcntl(2)` and :manpage:`ioctl(2)` Unix manual pages for full " +"interface to the :c:func:`fcntl` and :c:func:`ioctl` Unix routines. See " +"the :manpage:`fcntl(2)` and :manpage:`ioctl(2)` Unix manual pages for full " "details." msgstr "" @@ -37,10 +36,10 @@ msgstr "可用性" #: ../../library/fcntl.rst:23 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." -"stdin.fileno()``, or an :class:`io.IOBase` object, such as ``sys.stdin`` " -"itself, which provides a :meth:`~io.IOBase.fileno` that returns a genuine " -"file descriptor." +"argument. This can be an integer file descriptor, such as returned by " +"``sys.stdin.fileno()``, or an :class:`io.IOBase` object, such as " +"``sys.stdin`` itself, which provides a :meth:`~io.IOBase.fileno` that " +"returns a genuine file descriptor." msgstr "" #: ../../library/fcntl.rst:29 @@ -59,8 +58,8 @@ msgstr "" #: ../../library/fcntl.rst:38 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 :" -"mod:`!fcntl` module exposes the ``F_OFD_GETLK``, ``F_OFD_SETLK`` and " +"obtains the path of a file from a file descriptor. On Linux(>=3.15), " +"the :mod:`!fcntl` module exposes the ``F_OFD_GETLK``, ``F_OFD_SETLK`` and " "``F_OFD_SETLKW`` constants, which are used when working with open file " "description locks." msgstr "" @@ -109,43 +108,49 @@ msgid "" msgstr "" #: ../../library/fcntl.rst:82 +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:86 msgid "The module defines the following functions:" msgstr "這個模組定義了以下函式:" -#: ../../library/fcntl.rst:87 +#: ../../library/fcntl.rst:91 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 " "for *cmd* are operating system dependent, and are available as constants in " "the :mod:`fcntl` module, using the same names as used in the relevant C " -"header files. The argument *arg* can either be an integer value, a :class:" -"`bytes` 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." +"header files. The argument *arg* can either be an integer value, " +"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:96 +#: ../../library/fcntl.rst:100 msgid "" "When *arg* is an integer, the function returns the integer return value of " "the C :c:func:`fcntl` call." msgstr "" -#: ../../library/fcntl.rst:99 +#: ../../library/fcntl.rst:103 msgid "" -"When the argument is bytes, it represents a binary structure, for example, " -"created by :func:`struct.pack`. A string value is encoded to binary using " -"the UTF-8 encoding. The binary data is copied to a buffer whose 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." +"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 " +"binary using the UTF-8 encoding. The binary data is copied to a buffer whose " +"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." msgstr "" -#: ../../library/fcntl.rst:108 +#: ../../library/fcntl.rst:112 msgid "If the :c:func:`fcntl` call fails, an :exc:`OSError` is raised." msgstr "" -#: ../../library/fcntl.rst:111 +#: ../../library/fcntl.rst:115 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 " @@ -154,7 +159,7 @@ msgid "" "in a segmentation violation or a more subtle data corruption." msgstr "" -#: ../../library/fcntl.rst:118 +#: ../../library/fcntl.rst:122 msgid "" "Raises an :ref:`auditing event ` ``fcntl.fcntl`` with arguments " "``fd``, ``cmd``, ``arg``." @@ -162,13 +167,19 @@ msgstr "" "引發一個附帶引數 ``fd``、``cmd``、``arg`` 的\\ :ref:`稽核事件 ` " "``fcntl.fcntl``。" -#: ../../library/fcntl.rst:123 +#: ../../library/fcntl.rst:124 +msgid "" +"Add support of arbitrary :term:`bytes-like objects `, not " +"only :class:`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:126 +#: ../../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 " @@ -176,20 +187,20 @@ msgid "" "same names as used in the relevant C header files." msgstr "" -#: ../../library/fcntl.rst:132 +#: ../../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:137 +#: ../../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:141 +#: ../../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) " @@ -197,16 +208,16 @@ msgid "" "code is passed back to the calling Python, and the buffer's new contents " "reflect the action of the :c:func:`ioctl`. This is a slight simplification, " "because if the supplied buffer is less than 1024 bytes long it is first " -"copied into a static buffer 1024 bytes long which is then passed to :func:" -"`ioctl` and copied back into the supplied buffer." +"copied into a static buffer 1024 bytes long which is then passed " +"to :func:`ioctl` and copied back into the supplied buffer." msgstr "" -#: ../../library/fcntl.rst:150 +#: ../../library/fcntl.rst:158 msgid "" "If the :c:func:`ioctl` call fails, an :exc:`OSError` exception is raised." msgstr "" -#: ../../library/fcntl.rst:153 +#: ../../library/fcntl.rst:161 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 " @@ -216,11 +227,11 @@ msgid "" "more subtle data corruption." msgstr "" -#: ../../library/fcntl.rst:161 +#: ../../library/fcntl.rst:169 msgid "An example::" msgstr "範例: ::" -#: ../../library/fcntl.rst:163 +#: ../../library/fcntl.rst:171 msgid "" ">>> import array, fcntl, struct, termios, os\n" ">>> os.getpgrp()\n" @@ -244,7 +255,7 @@ msgstr "" ">>> buf\n" "array('h', [13341])" -#: ../../library/fcntl.rst:174 +#: ../../library/fcntl.rst:182 msgid "" "Raises an :ref:`auditing event ` ``fcntl.ioctl`` with arguments " "``fd``, ``request``, ``arg``." @@ -252,7 +263,13 @@ msgstr "" "引發一個附帶引數 ``fd``、``request``、``arg`` 的\\ :ref:`稽核事件 " "` ``fcntl.ioctl``。" -#: ../../library/fcntl.rst:179 +#: ../../library/fcntl.rst:184 +msgid "" +"The GIL is always released during a system call. System calls failing with " +"EINTR are automatically retried." +msgstr "" + +#: ../../library/fcntl.rst:190 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 " @@ -260,12 +277,12 @@ msgid "" "function is emulated using :c:func:`fcntl`.)" msgstr "" -#: ../../library/fcntl.rst:184 +#: ../../library/fcntl.rst:195 msgid "" "If the :c:func:`flock` call fails, an :exc:`OSError` exception is raised." msgstr "" -#: ../../library/fcntl.rst:186 +#: ../../library/fcntl.rst:197 msgid "" "Raises an :ref:`auditing event ` ``fcntl.flock`` with arguments " "``fd``, ``operation``." @@ -273,69 +290,69 @@ msgstr "" "引發一個附帶引數 ``fd``、``operation`` 的\\ :ref:`稽核事件 ` " "``fcntl.flock``。" -#: ../../library/fcntl.rst:191 +#: ../../library/fcntl.rst:202 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." -"fileno` method are accepted as well) of the file to lock or unlock, and " -"*cmd* is one of the following values:" +"*fd* is the file descriptor (file objects providing " +"a :meth:`~io.IOBase.fileno` method are accepted as well) of the file to lock " +"or unlock, and *cmd* is one of the following values:" msgstr "" -#: ../../library/fcntl.rst:198 +#: ../../library/fcntl.rst:209 msgid "Release an existing lock." msgstr "" -#: ../../library/fcntl.rst:202 +#: ../../library/fcntl.rst:213 msgid "Acquire a shared lock." msgstr "" -#: ../../library/fcntl.rst:206 +#: ../../library/fcntl.rst:217 msgid "Acquire an exclusive lock." msgstr "" -#: ../../library/fcntl.rst:210 +#: ../../library/fcntl.rst:221 msgid "" "Bitwise OR with any of the other three ``LOCK_*`` constants to make the " "request non-blocking." msgstr "" -#: ../../library/fcntl.rst:213 +#: ../../library/fcntl.rst:224 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 " -"set to :const:`~errno.EACCES` or :const:`~errno.EAGAIN` (depending on the " -"operating system; for portability, check for both values). On at least some " -"systems, :const:`!LOCK_EX` can only be used if the file descriptor refers to " -"a file opened for writing." +"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 set to :const:`~errno.EACCES` or :const:`~errno.EAGAIN` (depending " +"on the operating system; for portability, check for both values). On at " +"least some systems, :const:`!LOCK_EX` can only be used if the file " +"descriptor refers to a file opened for writing." msgstr "" -#: ../../library/fcntl.rst:220 +#: ../../library/fcntl.rst:231 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:" +"the lock starts, relative to *whence*, and *whence* is as " +"with :func:`io.IOBase.seek`, specifically:" msgstr "" -#: ../../library/fcntl.rst:224 +#: ../../library/fcntl.rst:235 msgid "``0`` -- relative to the start of the file (:const:`os.SEEK_SET`)" msgstr "" -#: ../../library/fcntl.rst:225 +#: ../../library/fcntl.rst:236 msgid "``1`` -- relative to the current buffer position (:const:`os.SEEK_CUR`)" msgstr "" -#: ../../library/fcntl.rst:226 +#: ../../library/fcntl.rst:237 msgid "``2`` -- relative to the end of the file (:const:`os.SEEK_END`)" msgstr "" -#: ../../library/fcntl.rst:228 +#: ../../library/fcntl.rst:239 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:232 +#: ../../library/fcntl.rst:243 msgid "" "Raises an :ref:`auditing event ` ``fcntl.lockf`` with arguments " "``fd``, ``cmd``, ``len``, ``start``, ``whence``." @@ -343,11 +360,11 @@ msgstr "" "引發一個附帶引數 ``fd``、``cmd``、``len``、``start``、``whence`` 的\\ :ref:`" "稽核事件 ` ``fcntl.lockf``。" -#: ../../library/fcntl.rst:234 +#: ../../library/fcntl.rst:245 msgid "Examples (all on a SVR4 compliant system)::" msgstr "" -#: ../../library/fcntl.rst:236 +#: ../../library/fcntl.rst:247 msgid "" "import struct, fcntl, os\n" "\n" @@ -365,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:244 +#: ../../library/fcntl.rst:255 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. " @@ -373,11 +390,11 @@ msgid "" "therefore using the :func:`flock` call may be better." msgstr "" -#: ../../library/fcntl.rst:252 +#: ../../library/fcntl.rst:263 msgid "Module :mod:`os`" msgstr ":mod:`os` 模組" -#: ../../library/fcntl.rst:253 +#: ../../library/fcntl.rst:264 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 " diff --git a/library/filecmp.po b/library/filecmp.po index 03990f1fdc9..72f95f82823 100644 --- a/library/filecmp.po +++ b/library/filecmp.po @@ -1,11 +1,10 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2025-02-19 00:13+0000\n" "PO-Revision-Date: 2015-12-09 17:51+0000\n" diff --git a/library/fileformats.po b/library/fileformats.po index 9da51697742..03c53fa5e1c 100644 --- a/library/fileformats.po +++ b/library/fileformats.po @@ -1,5 +1,4 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -7,7 +6,7 @@ # Weilin Du, 2025 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2018-06-26 18:54+0800\n" "PO-Revision-Date: 2025-06-28 00:51+0800\n" diff --git a/library/fileinput.po b/library/fileinput.po index 6c58733102c..377e8618708 100644 --- a/library/fileinput.po +++ b/library/fileinput.po @@ -1,11 +1,10 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-01 22:24+0800\n" "PO-Revision-Date: 2018-05-23 16:01+0000\n" diff --git a/library/filesys.po b/library/filesys.po index 9c42ea3858e..f3eff555d9f 100644 --- a/library/filesys.po +++ b/library/filesys.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -6,7 +6,7 @@ # Allen Wu , 2021 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-12-29 11:18+0000\n" "PO-Revision-Date: 2021-11-22 20:13+0800\n" diff --git a/library/fnmatch.po b/library/fnmatch.po index 75dd730a60a..5c17ff5a544 100644 --- a/library/fnmatch.po +++ b/library/fnmatch.po @@ -1,13 +1,12 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-01-15 00:13+0000\n" +"POT-Creation-Date: 2025-09-08 15:25+0800\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-" @@ -82,10 +81,10 @@ msgstr "" #: ../../library/fnmatch.rst:43 msgid "" "Note that the filename separator (``'/'`` on Unix) is *not* special to this " -"module. See module :mod:`glob` for pathname expansion (:mod:`glob` uses :" -"func:`.filter` to match pathname segments). Similarly, filenames starting " -"with a period are not special for this module, and are matched by the ``*`` " -"and ``?`` patterns." +"module. See module :mod:`glob` for pathname expansion (:mod:`glob` " +"uses :func:`.filter` to match pathname segments). Similarly, filenames " +"starting with a period are not special for this module, and are matched by " +"the ``*`` and ``?`` patterns." msgstr "" #: ../../library/fnmatch.rst:49 @@ -100,15 +99,15 @@ msgstr "" msgid "" "Finally, note that :func:`functools.lru_cache` with a *maxsize* of 32768 is " "used to cache the (typed) compiled regex patterns in the following " -"functions: :func:`fnmatch`, :func:`fnmatchcase`, :func:`.filter`." +"functions: :func:`fnmatch`, :func:`fnmatchcase`, :func:`.filter`, :func:`.filterfalse`." msgstr "" #: ../../library/fnmatch.rst:61 msgid "" "Test whether the filename string *name* matches the pattern string *pat*, " -"returning ``True`` or ``False``. Both parameters are case-normalized using :" -"func:`os.path.normcase`. :func:`fnmatchcase` can be used to perform a case-" -"sensitive comparison, regardless of whether that's standard for the " +"returning ``True`` or ``False``. Both parameters are case-normalized " +"using :func:`os.path.normcase`. :func:`fnmatchcase` can be used to perform a " +"case-sensitive comparison, regardless of whether that's standard for the " "operating system." msgstr "" @@ -150,19 +149,27 @@ msgstr "" #: ../../library/fnmatch.rst:95 msgid "" +"Construct a list from those elements of the :term:`iterable` of filename " +"strings *names* that do not match the pattern string *pat*. It is the same " +"as ``[n for n in names if not fnmatch(n, pat)]``, but implemented more " +"efficiently." +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`." msgstr "" -#: ../../library/fnmatch.rst:98 +#: ../../library/fnmatch.rst:108 msgid "Example:" msgstr "範例:" -#: ../../library/fnmatch.rst:112 +#: ../../library/fnmatch.rst:122 msgid "Module :mod:`glob`" msgstr ":mod:`glob` 模組" -#: ../../library/fnmatch.rst:113 +#: ../../library/fnmatch.rst:123 msgid "Unix shell-style path expansion." msgstr "" diff --git a/library/fractions.po b/library/fractions.po index c3f5ecb2777..03799a18f94 100644 --- a/library/fractions.po +++ b/library/fractions.po @@ -1,13 +1,12 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-08-06 00:17+0000\n" +"POT-Creation-Date: 2025-10-08 00:15+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-" @@ -42,24 +41,34 @@ msgid "" "The first version requires that *numerator* and *denominator* are instances " "of :class:`numbers.Rational` and returns a new :class:`Fraction` instance " "with a value equal to ``numerator/denominator``. If *denominator* is zero, " -"it raises a :exc:`ZeroDivisionError`. The second version requires that " -"*other_fraction* is an instance of :class:`numbers.Rational` and returns a :" -"class:`Fraction` instance with the same value. The next two versions accept " -"either a :class:`float` or a :class:`decimal.Decimal` instance, and return " -"a :class:`Fraction` instance with exactly the same value. Note that due to " -"the usual issues with binary floating point (see :ref:`tut-fp-issues`), the " -"argument to ``Fraction(1.1)`` is not exactly equal to 11/10, and so " -"``Fraction(1.1)`` does *not* return ``Fraction(11, 10)`` as one might " -"expect. (But see the documentation for the :meth:`limit_denominator` method " -"below.) The last version of the constructor expects a string or unicode " -"instance. The usual form for this instance is::" -msgstr "" - -#: ../../library/fractions.rst:41 +"it raises a :exc:`ZeroDivisionError`." +msgstr "" + +#: ../../library/fractions.rst:31 +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:" +"`float` and :class:`decimal.Decimal`). It returns a :class:`Fraction` " +"instance with exactly the same value. Assumed, that the :meth:`!" +"as_integer_ratio` method returns a pair of coprime integers and last one is " +"positive. Note that due to the usual issues with binary point (see :ref:`tut-" +"fp-issues`), the argument to ``Fraction(1.1)`` is not exactly equal to " +"11/10, and so ``Fraction(1.1)`` does *not* return ``Fraction(11, 10)`` as " +"one might expect. (But see the documentation for the :meth:" +"`limit_denominator` method below.)" +msgstr "" + +#: ../../library/fractions.rst:43 +msgid "" +"The last version of the constructor expects a string. The usual form for " +"this instance is::" +msgstr "" + +#: ../../library/fractions.rst:46 msgid "[sign] numerator ['/' denominator]" msgstr "[sign] numerator ['/' denominator]" -#: ../../library/fractions.rst:43 +#: ../../library/fractions.rst:48 msgid "" "where the optional ``sign`` may be either '+' or '-' and ``numerator`` and " "``denominator`` (if present) are strings of decimal digits (underscores may " @@ -70,7 +79,7 @@ msgid "" "whitespace. Here are some examples::" msgstr "" -#: ../../library/fractions.rst:52 +#: ../../library/fractions.rst:57 msgid "" ">>> from fractions import Fraction\n" ">>> Fraction(16, -10)\n" @@ -122,7 +131,7 @@ msgstr "" ">>> Fraction(Decimal('1.1'))\n" "Fraction(11, 10)" -#: ../../library/fractions.rst:78 +#: ../../library/fractions.rst:83 msgid "" "The :class:`Fraction` class inherits from the abstract base class :class:" "`numbers.Rational`, and implements all of the methods and operations from " @@ -131,7 +140,7 @@ msgid "" "properties and methods:" msgstr "" -#: ../../library/fractions.rst:84 +#: ../../library/fractions.rst:89 msgid "" "The :class:`Fraction` constructor now accepts :class:`float` and :class:" "`decimal.Decimal` instances." @@ -139,110 +148,126 @@ msgstr "" ":class:`Fraction` 建構函式現在可接受 :class:`float` 和 :class:`decimal." "Decimal` 實例。" -#: ../../library/fractions.rst:88 +#: ../../library/fractions.rst:93 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:93 +#: ../../library/fractions.rst:98 msgid "" "Underscores are now permitted when creating a :class:`Fraction` instance " "from a string, following :PEP:`515` rules." msgstr "" -#: ../../library/fractions.rst:97 +#: ../../library/fractions.rst:102 msgid "" ":class:`Fraction` implements ``__int__`` now to satisfy ``typing." "SupportsInt`` instance checks." msgstr "" -#: ../../library/fractions.rst:101 +#: ../../library/fractions.rst:106 msgid "" "Space is allowed around the slash for string inputs: ``Fraction('2 / 3')``." msgstr "" -#: ../../library/fractions.rst:104 +#: ../../library/fractions.rst:109 msgid "" ":class:`Fraction` instances now support float-style formatting, with " "presentation types ``\"e\"``, ``\"E\"``, ``\"f\"``, ``\"F\"``, ``\"g\"``, " "``\"G\"`` and ``\"%\"\"``." msgstr "" -#: ../../library/fractions.rst:109 +#: ../../library/fractions.rst:114 msgid "" "Formatting of :class:`Fraction` instances without a presentation type now " "supports fill, alignment, sign handling, minimum width and grouping." msgstr "" -#: ../../library/fractions.rst:115 +#: ../../library/fractions.rst:118 +msgid "" +"The :class:`Fraction` constructor now accepts any objects with the :meth:`!" +"as_integer_ratio` method." +msgstr "" +":class:`Fraction` 建構函式現在可接受任何具有 :meth:`!as_integer_ratio` 方法的" +"物件。" + +#: ../../library/fractions.rst:124 msgid "Numerator of the Fraction in lowest term." msgstr "" -#: ../../library/fractions.rst:119 +#: ../../library/fractions.rst:128 msgid "Denominator of the Fraction in lowest terms. Guaranteed to be positive." msgstr "" -#: ../../library/fractions.rst:125 +#: ../../library/fractions.rst:134 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:133 +#: ../../library/fractions.rst:142 msgid "Return ``True`` if the Fraction is an integer." msgstr "" -#: ../../library/fractions.rst:139 +#: ../../library/fractions.rst:148 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:145 +#: ../../library/fractions.rst:154 msgid "" "From Python 3.2 onwards, you can also construct a :class:`Fraction` instance " "directly from a :class:`float`." msgstr "" -#: ../../library/fractions.rst:151 +#: ../../library/fractions.rst:160 msgid "" "Alternative constructor which only accepts instances of :class:`decimal." "Decimal` or :class:`numbers.Integral`." msgstr "" -#: ../../library/fractions.rst:156 +#: ../../library/fractions.rst:165 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:163 +#: ../../library/fractions.rst:172 +msgid "" +"Alternative constructor which only accepts instances of :class:`numbers." +"Integral`, :class:`numbers.Rational`, :class:`float` or :class:`decimal." +"Decimal`, and objects with the :meth:`!as_integer_ratio` method, but not " +"strings." +msgstr "" + +#: ../../library/fractions.rst:182 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:171 +#: ../../library/fractions.rst:190 msgid "or for recovering a rational number that's represented as a float:" msgstr "" -#: ../../library/fractions.rst:184 +#: ../../library/fractions.rst:203 msgid "" "Returns the greatest :class:`int` ``<= self``. This method can also be " "accessed through the :func:`math.floor` function:" msgstr "" -#: ../../library/fractions.rst:194 +#: ../../library/fractions.rst:213 msgid "" "Returns the least :class:`int` ``>= self``. This method can also be " "accessed through the :func:`math.ceil` function." msgstr "" -#: ../../library/fractions.rst:201 +#: ../../library/fractions.rst:220 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 " @@ -251,14 +276,14 @@ msgid "" "func:`round` function." msgstr "" -#: ../../library/fractions.rst:209 +#: ../../library/fractions.rst:228 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:213 +#: ../../library/fractions.rst:232 msgid "" "If the ``format_spec`` format specification string does not end with one of " "the presentation types ``'e'``, ``'E'``, ``'f'``, ``'F'``, ``'g'``, ``'G'`` " @@ -270,7 +295,7 @@ msgid "" "exact integer. The zero-fill flag ``'0'`` is not supported." msgstr "" -#: ../../library/fractions.rst:223 +#: ../../library/fractions.rst:242 msgid "" "If the ``format_spec`` format specification string ends with one of the " "presentation types ``'e'``, ``'E'``, ``'f'``, ``'F'``, ``'g'``, ``'G'`` or " @@ -278,11 +303,11 @@ msgid "" "type in the :ref:`formatspec` section." msgstr "" -#: ../../library/fractions.rst:228 +#: ../../library/fractions.rst:247 msgid "Here are some examples::" msgstr "" -#: ../../library/fractions.rst:230 +#: ../../library/fractions.rst:249 msgid "" ">>> from fractions import Fraction\n" ">>> format(Fraction(103993, 33102), '_')\n" @@ -322,10 +347,14 @@ msgstr "" ">>> \"{:.2%} price increase\".format(Fraction(new_price, old_price) - 1)\n" "'34.67% price increase'" -#: ../../library/fractions.rst:252 +#: ../../library/fractions.rst:271 msgid "Module :mod:`numbers`" msgstr ":mod:`numbers` 模組" -#: ../../library/fractions.rst:253 +#: ../../library/fractions.rst:272 msgid "The abstract base classes making up the numeric tower." msgstr "" + +#: ../../library/fractions.rst:20 +msgid "as_integer_ratio()" +msgstr "as_integer_ratio()" diff --git a/library/frameworks.po b/library/frameworks.po index 7f997c290b1..a3767f24976 100644 --- a/library/frameworks.po +++ b/library/frameworks.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -6,7 +6,7 @@ # Weilin Du, 2025 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2025-08-16 00:16+0000\n" "PO-Revision-Date: 2025-06-27 13:41+0800\n" diff --git a/library/ftplib.po b/library/ftplib.po index 8c47a8eb7eb..1e37450f777 100644 --- a/library/ftplib.po +++ b/library/ftplib.po @@ -1,11 +1,11 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Matt Wang , 2023-2024 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-10-11 00:13+0000\n" "PO-Revision-Date: 2023-04-26 19:44+0800\n" diff --git a/library/functional.po b/library/functional.po index 89f98aafb8e..b5ba495525c 100644 --- a/library/functional.po +++ b/library/functional.po @@ -1,11 +1,11 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Leon H., 2017 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2018-06-26 18:54+0800\n" "PO-Revision-Date: 2017-09-22 18:26+0000\n" diff --git a/library/functions.po b/library/functions.po index ed0adb9e742..54297a008e3 100644 --- a/library/functions.po +++ b/library/functions.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # Translators: # Adrian Liaw , 2018 @@ -8,9 +8,9 @@ # Steven Hsu , 2023 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-08-26 00:16+0000\n" +"POT-Creation-Date: 2025-12-01 00:17+0000\n" "PO-Revision-Date: 2024-05-06 17:06+0800\n" "Last-Translator: KNChiu \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -33,367 +33,367 @@ msgid "" msgstr "" "Python 直譯器有內建多個可隨時使用的函式和型別。以下按照英文字母排序列出。" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:13 msgid "**A**" msgstr "**A**" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:14 msgid ":func:`abs`" msgstr ":func:`abs`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:15 msgid ":func:`aiter`" msgstr ":func:`aiter`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:16 msgid ":func:`all`" msgstr ":func:`all`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:17 msgid ":func:`anext`" msgstr ":func:`anext`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:18 msgid ":func:`any`" msgstr ":func:`any`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:19 msgid ":func:`ascii`" msgstr ":func:`ascii`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:21 msgid "**B**" msgstr "**B**" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:22 msgid ":func:`bin`" msgstr ":func:`bin`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:23 msgid ":func:`bool`" msgstr ":func:`bool`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:24 msgid ":func:`breakpoint`" msgstr ":func:`breakpoint`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:25 msgid "|func-bytearray|_" msgstr "|func-bytearray|_" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:26 msgid "|func-bytes|_" msgstr "|func-bytes|_" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:28 msgid "**C**" msgstr "**C**" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:29 msgid ":func:`callable`" msgstr ":func:`callable`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:30 msgid ":func:`chr`" msgstr ":func:`chr`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:31 msgid ":func:`classmethod`" msgstr ":func:`classmethod`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:32 msgid ":func:`compile`" msgstr ":func:`compile`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:33 msgid ":func:`complex`" msgstr ":func:`complex`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:35 msgid "**D**" msgstr "**D**" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:36 msgid ":func:`delattr`" msgstr ":func:`delattr`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:37 msgid "|func-dict|_" msgstr "|func-dict|_" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:38 msgid ":func:`dir`" msgstr ":func:`dir`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:39 msgid ":func:`divmod`" msgstr ":func:`divmod`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:13 msgid "**E**" msgstr "**E**" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:14 msgid ":func:`enumerate`" msgstr ":func:`enumerate`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:15 msgid ":func:`eval`" msgstr ":func:`eval`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:16 msgid ":func:`exec`" msgstr ":func:`exec`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:18 msgid "**F**" msgstr "**F**" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:19 msgid ":func:`filter`" msgstr ":func:`filter`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:20 msgid ":func:`float`" msgstr ":func:`float`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:21 msgid ":func:`format`" msgstr ":func:`format`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:22 msgid "|func-frozenset|_" msgstr "|func-frozenset|_" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:24 msgid "**G**" msgstr "**G**" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:25 msgid ":func:`getattr`" msgstr ":func:`getattr`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:26 msgid ":func:`globals`" msgstr ":func:`globals`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:28 msgid "**H**" msgstr "**H**" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:29 msgid ":func:`hasattr`" msgstr ":func:`hasattr`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:30 msgid ":func:`hash`" msgstr ":func:`hash`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:31 msgid ":func:`help`" msgstr ":func:`help`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:32 msgid ":func:`hex`" msgstr ":func:`hex`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:34 msgid "**I**" msgstr "**I**" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:35 msgid ":func:`id`" msgstr ":func:`id`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:36 msgid ":func:`input`" msgstr ":func:`input`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:37 msgid ":func:`int`" msgstr ":func:`int`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:38 msgid ":func:`isinstance`" msgstr ":func:`isinstance`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:39 msgid ":func:`issubclass`" msgstr ":func:`issubclass`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:40 msgid ":func:`iter`" msgstr ":func:`iter`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:13 msgid "**L**" msgstr "**L**" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:14 msgid ":func:`len`" msgstr ":func:`len`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:15 msgid "|func-list|_" msgstr "|func-list|_" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:16 msgid ":func:`locals`" msgstr ":func:`locals`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:18 msgid "**M**" msgstr "**M**" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:19 msgid ":func:`map`" msgstr ":func:`map`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:20 msgid ":func:`max`" msgstr ":func:`max`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:21 msgid "|func-memoryview|_" msgstr "|func-memoryview|_" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:22 msgid ":func:`min`" msgstr ":func:`min`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:24 msgid "**N**" msgstr "**N**" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:25 msgid ":func:`next`" msgstr ":func:`next`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:27 msgid "**O**" msgstr "**O**" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:28 msgid ":func:`object`" msgstr ":func:`object`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:29 msgid ":func:`oct`" msgstr ":func:`oct`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:30 msgid ":func:`open`" msgstr ":func:`open`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:31 msgid ":func:`ord`" msgstr ":func:`ord`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:33 msgid "**P**" msgstr "**P**" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:34 msgid ":func:`pow`" msgstr ":func:`pow`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:35 msgid ":func:`print`" msgstr ":func:`print`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:36 msgid ":func:`property`" msgstr ":func:`property`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:13 msgid "**R**" msgstr "**R**" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:14 msgid "|func-range|_" msgstr "|func-range|_" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:15 msgid ":func:`repr`" msgstr ":func:`repr`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:16 msgid ":func:`reversed`" msgstr ":func:`reversed`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:17 msgid ":func:`round`" msgstr ":func:`round`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:19 msgid "**S**" msgstr "**S**" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:20 msgid "|func-set|_" msgstr "|func-set|_" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:21 msgid ":func:`setattr`" msgstr ":func:`setattr`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:22 msgid ":func:`slice`" msgstr ":func:`slice`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:23 msgid ":func:`sorted`" msgstr ":func:`sorted`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:24 msgid ":func:`staticmethod`" msgstr ":func:`staticmethod`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:25 msgid "|func-str|_" msgstr "|func-str|_" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:26 msgid ":func:`sum`" msgstr ":func:`sum`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:27 msgid ":func:`super`" msgstr ":func:`super`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:29 msgid "**T**" msgstr "**T**" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:30 msgid "|func-tuple|_" msgstr "|func-tuple|_" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:31 msgid ":func:`type`" msgstr ":func:`type`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:33 msgid "**V**" msgstr "**V**" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:34 msgid ":func:`vars`" msgstr ":func:`vars`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:36 msgid "**Z**" msgstr "**Z**" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:37 msgid ":func:`zip`" msgstr ":func:`zip`" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:39 msgid "**_**" msgstr "**_**" -#: ../../library/functions.rst:0 +#: ../../library/functions.rst:40 msgid ":func:`__import__`" msgstr ":func:`__import__`" @@ -505,8 +505,8 @@ msgid "" "returns an integer. Some examples:" msgstr "" "將一個整數轉變為一個前綴為 \"0b\" 的二進位制字串。結果是一個有效的 Python 運" -"算式。如果 *integer* 不是 Python 的 :class:`int` 物件,那它需要定義 :meth:`~object." -"__index__` method 回傳一個整數。舉例來說:" +"算式。如果 *integer* 不是 Python 的 :class:`int` 物件,那它需要定義 :meth:" +"`~object.__index__` method 回傳一個整數。舉例來說:" #: ../../library/functions.rst:134 msgid "" @@ -514,8 +514,8 @@ msgid "" "ways." msgstr "如果不一定需要 \"0b\" 前綴,還可以使用如下的方法。" -#: ../../library/functions.rst:141 ../../library/functions.rst:940 -#: ../../library/functions.rst:1321 +#: ../../library/functions.rst:141 ../../library/functions.rst:948 +#: ../../library/functions.rst:1332 msgid "See also :func:`format` for more information." msgstr "可參考 :func:`format` 取得更多資訊。" @@ -534,7 +534,7 @@ msgstr "" "(參見 :ref:`typesnumeric`),其他 class 不能繼承自它。它只有 ``False`` 和 " "``True`` 兩個實例(參見 :ref:`typebool`)。" -#: ../../library/functions.rst:156 ../../library/functions.rst:805 +#: ../../library/functions.rst:156 ../../library/functions.rst:813 msgid "The parameter is now positional-only." msgstr "現在為僅限位置參數。" @@ -698,8 +698,8 @@ 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." msgstr "" -"引數的有效範圍是 0 到 1,114,111(16 進制表示為 0x10FFFF)。如果它超過這個" -"範圍,會引發 :exc:`ValueError`。" +"引數的有效範圍是 0 到 1,114,111(16 進制表示為 0x10FFFF)。如果它超過這個範" +"圍,會引發 :exc:`ValueError`。" #: ../../library/functions.rst:257 msgid "Transform a method into a class method." @@ -830,9 +830,10 @@ msgstr "" "可選引數 *flags* 和 *dont_inherit* 控制啟用哪個\\ :ref:`編譯器選項 `\\ 以及允許哪個\\ :ref:`未來功能 `。如果兩者都不存在" "(或兩者都為零),則會呼叫與 :func:`compile` 相同旗標的程式碼來編譯。如果給" -"定 *flags* 引數而未給定 *dont_inherit*(或為零)則無論如何都會使用由 *flags* " -"引數所指定的編譯器選項和未來陳述式。如果 *dont_inherit* 是一個非零整數,則使" -"用 *flags* 引數 -- 周圍程式碼中的旗標(未來功能和編譯器選項)將被忽略。" +"定 *flags* 引數而未給定 *dont_inherit*\\ (或為零)則無論如何都會使用由 " +"*flags* 引數所指定的編譯器選項和未來陳述式。如果 *dont_inherit* 是一個非零整" +"數,則使用 *flags* 引數 -- 周圍程式碼中的旗標(未來功能和編譯器選項)將被忽" +"略。" #: ../../library/functions.rst:323 msgid "" @@ -932,8 +933,8 @@ msgid "" "number from real and imaginary parts." msgstr "" -#: ../../library/functions.rst:382 ../../library/functions.rst:750 -#: ../../library/functions.rst:996 +#: ../../library/functions.rst:382 ../../library/functions.rst:756 +#: ../../library/functions.rst:1004 msgid "Examples:" msgstr "例如: ::" @@ -1015,19 +1016,25 @@ msgid "" msgstr "" #: ../../library/functions.rst:441 -msgid "If all arguments are omitted, returns ``0j``." +msgid "" +"See also :meth:`complex.from_number` which only accepts a single numeric " +"argument." msgstr "" #: ../../library/functions.rst:443 +msgid "If all arguments are omitted, returns ``0j``." +msgstr "" + +#: ../../library/functions.rst:445 msgid "The complex type is described in :ref:`typesnumeric`." msgstr "複數型別在 :ref:`typesnumeric` 中有相關描述。" -#: ../../library/functions.rst:445 ../../library/functions.rst:802 -#: ../../library/functions.rst:1045 +#: ../../library/functions.rst:447 ../../library/functions.rst:810 +#: ../../library/functions.rst:1052 msgid "Grouping digits with underscores as in code literals is allowed." msgstr "可以使用底線將程式碼文字中的數字進行分組。" -#: ../../library/functions.rst:448 +#: ../../library/functions.rst:450 msgid "" "Falls back to :meth:`~object.__index__` if :meth:`~object.__complex__` and :" "meth:`~object.__float__` are not defined." @@ -1035,7 +1042,13 @@ msgstr "" "如果 :meth:`~object.__complex__` 和 :meth:`~object.__float__` 未定義,則會回" "退到 :meth:`~object.__index__`。" -#: ../../library/functions.rst:455 +#: ../../library/functions.rst:454 +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 "" + +#: ../../library/functions.rst:461 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 " @@ -1048,7 +1061,7 @@ msgstr "" "'foobar')`` 等價於 ``del x.foobar``。*name* 不必是個 Python 識別符 " "(identifier)(請見 :func:`setattr`)。" -#: ../../library/functions.rst:468 +#: ../../library/functions.rst:474 msgid "" "Create a new dictionary. The :class:`dict` object is the dictionary class. " "See :class:`dict` and :ref:`typesmapping` for documentation about this class." @@ -1056,7 +1069,7 @@ msgstr "" "建立一個新的 dictionary(字典)。:class:`dict` 物件是一個 dictionary class。" "參見 :class:`dict` 和 :ref:`typesmapping` 來瞭解這個 class。" -#: ../../library/functions.rst:471 +#: ../../library/functions.rst:477 msgid "" "For other containers see the built-in :class:`list`, :class:`set`, and :" "class:`tuple` classes, as well as the :mod:`collections` module." @@ -1064,7 +1077,7 @@ msgstr "" "其他容器型別,請參見內建的 :class:`list`、:class:`set` 和 :class:`tuple` " "class,以及 :mod:`collections` module。" -#: ../../library/functions.rst:478 +#: ../../library/functions.rst:484 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 " @@ -1073,7 +1086,7 @@ msgstr "" "如果沒有引數,則回傳目前區域作用域 (local scope) 中的名稱列表。如果有引數,它" "會嘗試回傳該物件的有效屬性列表。" -#: ../../library/functions.rst:481 +#: ../../library/functions.rst:487 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 " @@ -1086,7 +1099,7 @@ msgstr "" "或 :func:`~object.__getattribute__` 函式的物件能夠自定義 :func:`dir` 來報告它" "們的屬性。" -#: ../../library/functions.rst:488 +#: ../../library/functions.rst:494 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__` " @@ -1098,7 +1111,7 @@ msgstr "" "`~object.__dict__` 屬性和型別物件收集資訊。結果列表並不總是完整的,如果物件有" "自定義 :func:`~object.__getattr__`,那結果可能不準確。" -#: ../../library/functions.rst:494 +#: ../../library/functions.rst:500 msgid "" "The default :func:`dir` mechanism behaves differently with different types " "of objects, as it attempts to produce the most relevant, rather than " @@ -1107,13 +1120,13 @@ msgstr "" "預設的 :func:`dir` 機制對不同型別的物件有不同行為,它會試圖回傳最相關而非最完" "整的資訊:" -#: ../../library/functions.rst:498 +#: ../../library/functions.rst:504 msgid "" "If the object is a module object, the list contains the names of the " "module's attributes." msgstr "如果物件是 module 物件,則列表包含 module 的屬性名稱。" -#: ../../library/functions.rst:501 +#: ../../library/functions.rst:507 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." @@ -1121,7 +1134,7 @@ msgstr "" "如果物件是型別或 class 物件,則列表包含它們的屬性名稱,並且遞迴查詢其基礎的所" "有屬性。" -#: ../../library/functions.rst:504 +#: ../../library/functions.rst:510 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 " @@ -1130,11 +1143,11 @@ msgstr "" "否則,包含物件的屬性名稱列表、它的 class 屬性名稱,並且遞迴查詢它的 class 的" "所有基礎 class 的屬性。" -#: ../../library/functions.rst:508 +#: ../../library/functions.rst:514 msgid "The resulting list is sorted alphabetically. For example:" msgstr "回傳的列表按字母表排序,例如:" -#: ../../library/functions.rst:528 +#: ../../library/functions.rst:534 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 " @@ -1147,7 +1160,7 @@ msgstr "" "版本之間改變。例如,當引數是一個 class 時,metaclass 的屬性不包含在結果列表" "中。" -#: ../../library/functions.rst:538 +#: ../../library/functions.rst:544 msgid "" "Take two (non-complex) numbers as arguments and return a pair of numbers " "consisting of their quotient and remainder when using integer division. " @@ -1165,7 +1178,7 @@ msgstr "" "等,如果 ``a % b`` 非零,則它的符號和 *b* 一樣,且 ``0 <= abs(a % b) < " "abs(b)``。" -#: ../../library/functions.rst:550 +#: ../../library/functions.rst:556 msgid "" "Return an enumerate object. *iterable* must be a sequence, an :term:" "`iterator`, or some other object which supports iteration. The :meth:" @@ -1178,11 +1191,11 @@ msgstr "" "__next__` method 回傳一個 tuple(元組),裡面包含一個計數值(從 *start* 開" "始,預設為 0)和透過疊代 *iterable* 獲得的值。" -#: ../../library/functions.rst:562 +#: ../../library/functions.rst:568 msgid "Equivalent to::" msgstr "等價於: ::" -#: ../../library/functions.rst:564 +#: ../../library/functions.rst:570 msgid "" "def enumerate(iterable, start=0):\n" " n = start\n" @@ -1200,15 +1213,15 @@ msgstr "" msgid "Parameters" msgstr "" -#: ../../library/functions.rst:574 +#: ../../library/functions.rst:580 msgid "A Python expression." msgstr "" -#: ../../library/functions.rst:578 +#: ../../library/functions.rst:584 msgid "The global namespace (default: ``None``)." msgstr "" -#: ../../library/functions.rst:582 +#: ../../library/functions.rst:588 msgid "The local namespace (default: ``None``)." msgstr "" @@ -1216,7 +1229,7 @@ msgstr "" msgid "Returns" msgstr "" -#: ../../library/functions.rst:586 +#: ../../library/functions.rst:592 msgid "The result of the evaluated expression." msgstr "" @@ -1224,17 +1237,17 @@ msgstr "" msgid "raises" msgstr "引發" -#: ../../library/functions.rst:587 +#: ../../library/functions.rst:593 msgid "Syntax errors are reported as exceptions." msgstr "" -#: ../../library/functions.rst:591 ../../library/functions.rst:652 +#: ../../library/functions.rst:597 ../../library/functions.rst:658 msgid "" "This function executes arbitrary code. Calling it with user-supplied input " "may lead to security vulnerabilities." msgstr "" -#: ../../library/functions.rst:594 +#: ../../library/functions.rst:600 msgid "" "The *expression* argument is parsed and evaluated as a Python expression " "(technically speaking, a condition list) using the *globals* and *locals* " @@ -1264,11 +1277,11 @@ msgstr "" "locals),除非呼叫 :func:`eval` 的作用域已經有參照它們(例如透過 :keyword:" "`nonlocal` 陳述式)。" -#: ../../library/functions.rst:610 +#: ../../library/functions.rst:616 msgid "Example:" msgstr "範例:" -#: ../../library/functions.rst:616 +#: ../../library/functions.rst:622 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 " @@ -1279,7 +1292,7 @@ msgstr "" "情況下,傳入的引數是程式碼物件而不是字串。如果編譯該物件時的 *mode* 引數是 " "``'exec'``,那麼 :func:`eval` 回傳值為 ``None``。" -#: ../../library/functions.rst:621 +#: ../../library/functions.rst:627 msgid "" "Hints: dynamic execution of statements is supported by the :func:`exec` " "function. The :func:`globals` and :func:`locals` functions return the " @@ -1290,13 +1303,13 @@ msgstr "" "函式分別回傳目前的全域性和局部性 dictionary,它們對於將引數傳遞給 :func:" "`eval` 或 :func:`exec` 可能會方便許多。" -#: ../../library/functions.rst:626 +#: ../../library/functions.rst:632 msgid "" "If the given source is a string, then leading and trailing spaces and tabs " "are stripped." msgstr "如果給定來源是一個字串,那麼其前後的空格和定位字元會被移除。" -#: ../../library/functions.rst:629 +#: ../../library/functions.rst:635 msgid "" "See :func:`ast.literal_eval` for a function that can safely evaluate strings " "with expressions containing only literals." @@ -1304,8 +1317,8 @@ msgstr "" "另外可以參閱 :func:`ast.literal_eval`,該函式可以安全執行僅包含文字的運算式字" "串。" -#: ../../library/functions.rst:632 ../../library/functions.rst:634 -#: ../../library/functions.rst:694 ../../library/functions.rst:696 +#: ../../library/functions.rst:638 ../../library/functions.rst:640 +#: ../../library/functions.rst:700 ../../library/functions.rst:702 msgid "" "Raises an :ref:`auditing event ` ``exec`` with the code object as " "the argument. Code compilation events may also be raised." @@ -1313,17 +1326,17 @@ msgstr "" "引發一個附帶程式碼物件為引數的\\ :ref:`稽核事件 ` ``exec``。也可能" "會引發程式碼編譯事件。" -#: ../../library/functions.rst:639 ../../library/functions.rst:716 +#: ../../library/functions.rst:645 ../../library/functions.rst:722 msgid "The *globals* and *locals* arguments can now be passed as keywords." msgstr "" -#: ../../library/functions.rst:643 ../../library/functions.rst:720 +#: ../../library/functions.rst:649 ../../library/functions.rst:726 msgid "" "The semantics of the default *locals* namespace have been adjusted as " "described for the :func:`locals` builtin." msgstr "" -#: ../../library/functions.rst:655 +#: ../../library/functions.rst:661 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 " @@ -1343,7 +1356,7 @@ msgstr "" "`nonlocal`、:keyword:`yield` 和 :keyword:`return` 陳述式也不能在函式之外使" "用。該函式回傳值是 ``None``。" -#: ../../library/functions.rst:666 +#: ../../library/functions.rst:672 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 " @@ -1359,7 +1372,7 @@ msgstr "" "用作全域和區域變數。如果提供了 *locals*,則它可以是任何對映物件。請記住在 " "module 層級中全域和區域變數是相同的 dictionary。" -#: ../../library/functions.rst:676 +#: ../../library/functions.rst:682 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 " @@ -1368,7 +1381,7 @@ msgid "" "are treated as class variables in a class definition)." msgstr "" -#: ../../library/functions.rst:682 +#: ../../library/functions.rst:688 msgid "" "If the *globals* dictionary does not contain a value for the key " "``__builtins__``, a reference to the dictionary of the built-in module :mod:" @@ -1381,7 +1394,7 @@ msgstr "" "dictionary 傳入 :func:`exec` 之前,你可以透過將它插入 *globals* 來控制你需要" "哪些內建函式來執行程式碼。" -#: ../../library/functions.rst:688 +#: ../../library/functions.rst:694 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) " @@ -1393,7 +1406,7 @@ msgstr "" "variables) ` 的程式碼物件時,它才有效。Tuple 的長度必須與程" "式碼物件的 :attr:`~codeobject.co_freevars` 屬性完全匹配。" -#: ../../library/functions.rst:701 +#: ../../library/functions.rst:707 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 " @@ -1402,7 +1415,7 @@ msgstr "" "內建 :func:`globals` 和 :func:`locals` 函式各自回傳目前的全域和區域命名空間," "因此可以將它們傳遞給 :func:`exec` 的第二個和第三個引數以供後續使用。" -#: ../../library/functions.rst:707 +#: ../../library/functions.rst:713 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 " @@ -1412,11 +1425,11 @@ msgstr "" "func:`exec` 函式回傳時知道程式碼對 *locals* 的變動,請明確地傳遞 *locals* " "dictionary 。" -#: ../../library/functions.rst:711 +#: ../../library/functions.rst:717 msgid "Added the *closure* parameter." msgstr "增加了 *closure* 參數。" -#: ../../library/functions.rst:726 +#: ../../library/functions.rst:732 msgid "" "Construct an iterator from those elements of *iterable* for which *function* " "is true. *iterable* may be either a sequence, a container which supports " @@ -1428,7 +1441,7 @@ msgstr "" "*function* 是 ``None``,則會假設它是一個識別性函式,即 *iterable* 中所有假值" "元素會被移除。" -#: ../../library/functions.rst:732 +#: ../../library/functions.rst:738 msgid "" "Note that ``filter(function, iterable)`` is equivalent to the generator " "expression ``(item for item in iterable if function(item))`` if function is " @@ -1439,7 +1452,7 @@ msgstr "" "是 ``None`` 的時候為 ``(item for item in iterable if function(item))``;" "function 是 ``None`` 的時候為 ``(item for item in iterable if item)``。" -#: ../../library/functions.rst:737 +#: ../../library/functions.rst:743 msgid "" "See :func:`itertools.filterfalse` for the complementary function that " "returns elements of *iterable* for which *function* is false." @@ -1447,11 +1460,11 @@ msgstr "" "請參閱 :func:`itertools.filterfalse`,只有 *function* 為 false 時才選取 " "*iterable* 中元素的互補函式。" -#: ../../library/functions.rst:748 +#: ../../library/functions.rst:754 msgid "Return a floating-point number constructed from a number or a string." msgstr "回傳從數字或字串生成的浮點數。" -#: ../../library/functions.rst:752 +#: ../../library/functions.rst:758 msgid "" ">>> float('+1.23')\n" "1.23\n" @@ -1475,7 +1488,7 @@ msgstr "" ">>> float('-Infinity')\n" "-inf" -#: ../../library/functions.rst:765 +#: ../../library/functions.rst:771 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 " @@ -1490,7 +1503,7 @@ msgstr "" "數也可以是 NaN(非數字)或正負無窮大的字串。確切地說,除去首尾的空格後,輸入" "必須遵循以下語法中 :token:`~float:floatvalue` 的生成規則:" -#: ../../library/functions.rst:786 +#: ../../library/functions.rst:792 msgid "" "Case is not significant, so, for example, \"inf\", \"Inf\", \"INFINITY\", " "and \"iNfINity\" are all acceptable spellings for positive infinity." @@ -1498,7 +1511,7 @@ msgstr "" "字母大小寫不影響,例如,\"inf\"、\"Inf\"、\"INFINITY\"、\"iNfINity\" 都可以表" "示正無窮大。" -#: ../../library/functions.rst:789 +#: ../../library/functions.rst:795 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 " @@ -1508,7 +1521,7 @@ msgstr "" "否則,如果引數是整數或浮點數,則回傳具有相同值(在 Python 浮點精度範圍內)的" "浮點數。如果引數在 Python 浮點精度範圍外,則會引發 :exc:`OverflowError`。" -#: ../../library/functions.rst:794 +#: ../../library/functions.rst:800 msgid "" "For a general Python object ``x``, ``float(x)`` delegates to ``x." "__float__()``. If :meth:`~object.__float__` is not defined then it falls " @@ -1517,22 +1530,27 @@ msgstr "" "對於一般的 Python 物件 ``x``,``float(x)`` 會委派給 ``x.__float__()``。如果未" "定義 :meth:`~object.__float__` 則會回退到 :meth:`~object.__index__`。" -#: ../../library/functions.rst:798 +#: ../../library/functions.rst:804 +msgid "" +"See also :meth:`float.from_number` which only accepts a numeric argument." +msgstr "" + +#: ../../library/functions.rst:806 msgid "If no argument is given, ``0.0`` is returned." msgstr "如果沒有引數,則回傳 ``0.0``。" -#: ../../library/functions.rst:800 +#: ../../library/functions.rst:808 msgid "The float type is described in :ref:`typesnumeric`." msgstr ":ref:`typesnumeric` 描述了浮點數型別。" -#: ../../library/functions.rst:808 +#: ../../library/functions.rst:816 msgid "" "Falls back to :meth:`~object.__index__` if :meth:`~object.__float__` is not " "defined." msgstr "" "如果 :meth:`~object.__float__` 未定義,則會回退到 :meth:`~object.__index__`。" -#: ../../library/functions.rst:818 +#: ../../library/functions.rst:826 msgid "" "Convert a *value* to a \"formatted\" representation, as controlled by " "*format_spec*. The interpretation of *format_spec* will depend on the type " @@ -1543,7 +1561,7 @@ msgstr "" "取決於 *value* 引數的型別,但是大多數內建型別使用標準格式化語法::ref:" "`formatspec`。" -#: ../../library/functions.rst:823 +#: ../../library/functions.rst:831 msgid "" "The default *format_spec* is an empty string which usually gives the same " "effect as calling :func:`str(value) `." @@ -1551,7 +1569,7 @@ msgstr "" "預設的 *format_spec* 是一個空字串,它通常和呼叫 :func:`str(value) ` 的效" "果相同。" -#: ../../library/functions.rst:826 +#: ../../library/functions.rst:834 msgid "" "A call to ``format(value, format_spec)`` is translated to ``type(value)." "__format__(value, format_spec)`` which bypasses the instance dictionary when " @@ -1565,7 +1583,7 @@ msgstr "" "實例中的字典。如果搜尋到 :mod:`object` 這個 method 但 *format_spec* 不為空," "或是 *format_spec* 或回傳值不是字串,則會引發 :exc:`TypeError`。" -#: ../../library/functions.rst:833 +#: ../../library/functions.rst:841 msgid "" "``object().__format__(format_spec)`` raises :exc:`TypeError` if " "*format_spec* is not an empty string." @@ -1573,7 +1591,7 @@ msgstr "" "當 *format_spec* 不是空字串時,``object().__format__(format_spec)`` 會引發 :" "exc:`TypeError`。" -#: ../../library/functions.rst:842 +#: ../../library/functions.rst:850 msgid "" "Return a new :class:`frozenset` object, optionally with elements taken from " "*iterable*. ``frozenset`` is a built-in class. See :class:`frozenset` and :" @@ -1583,7 +1601,7 @@ msgstr "" "``frozenset`` 是一個內建的 class。有關此 class 的文件,請參閱 :class:" "`frozenset` 和 :ref:`types-set`。" -#: ../../library/functions.rst:846 +#: ../../library/functions.rst:854 msgid "" "For other containers see the built-in :class:`set`, :class:`list`, :class:" "`tuple`, and :class:`dict` classes, as well as the :mod:`collections` module." @@ -1591,7 +1609,7 @@ msgstr "" "請參閱內建的 :class:`set`、:class:`list`、:class:`tuple` 和 :class:`dict` " "class,以及 :mod:`collections` module 來了解其它的容器。" -#: ../../library/functions.rst:854 +#: ../../library/functions.rst:862 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 " @@ -1606,7 +1624,7 @@ msgstr "" "`AttributeError`。*name* 不必是個 Python 識別符 (identifier)(請見 :func:" "`setattr`)。" -#: ../../library/functions.rst:863 +#: ../../library/functions.rst:871 msgid "" "Since :ref:`private name mangling ` happens at " "compilation time, one must manually mangle a private attribute's (attributes " @@ -1617,7 +1635,7 @@ msgstr "" "發生在編譯期,因此你必須手動改編私有屬性(有兩個前導底線的屬性)的名稱,才能" "使用 :func:`getattr` 來取得它。" -#: ../../library/functions.rst:871 +#: ../../library/functions.rst:879 msgid "" "Return the dictionary implementing the current module namespace. For code " "within functions, this is set when the function is defined and remains the " @@ -1626,7 +1644,7 @@ msgstr "" "回傳代表目前 module 命名空間的 dictionary。對於在函式中的程式碼來說,這在定義" "函式時設定且不論該函式是在何處呼叫都會保持相同。" -#: ../../library/functions.rst:878 +#: ../../library/functions.rst:886 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. " @@ -1637,7 +1655,7 @@ msgstr "" "則回傳 ``False``。(此功能是透過呼叫 ``getattr(object, name)`` 並檢查是否引" "發 :exc:`AttributeError` 來實作的。)" -#: ../../library/functions.rst:886 +#: ../../library/functions.rst:894 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 " @@ -1648,7 +1666,7 @@ msgstr "" "時用來快速比較 dictionary 的鍵。相同大小的數字數值有相同的雜湊值(即使它們型" "別不同,如 1 和 1.0)。" -#: ../../library/functions.rst:893 +#: ../../library/functions.rst:901 msgid "" "For objects with custom :meth:`~object.__hash__` methods, note that :func:" "`hash` truncates the return value based on the bit width of the host machine." @@ -1656,7 +1674,7 @@ msgstr "" "請注意,如果物件帶有自訂的 :meth:`~object.__hash__` 方法,:func:`hash` 將根據" "運行機器的位元長度來截斷回傳值。" -#: ../../library/functions.rst:900 +#: ../../library/functions.rst:908 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 " @@ -1670,7 +1688,7 @@ msgstr "" "關鍵字或說明文件主題中搜尋該字串,並在控制台上列印幫助資訊。如果引數是其他任" "意物件,則會生成該物件的幫助頁。" -#: ../../library/functions.rst:907 +#: ../../library/functions.rst:915 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 " @@ -1681,12 +1699,12 @@ msgstr "" "前面的參數是僅限位置 (positional-only) 參數。有關更多資訊,請參閱\\ :ref:`常" "見問答集中的僅限位置參數條目 `。" -#: ../../library/functions.rst:912 +#: ../../library/functions.rst:920 msgid "" "This function is added to the built-in namespace by the :mod:`site` module." msgstr "此函式會被 :mod:`site` module 加入到內建命名空間。" -#: ../../library/functions.rst:914 +#: ../../library/functions.rst:922 msgid "" "Changes to :mod:`pydoc` and :mod:`inspect` mean that the reported signatures " "for callables are now more comprehensive and consistent." @@ -1694,17 +1712,17 @@ msgstr "" "對於 :mod:`pydoc` 和 :mod:`inspect` 的變更,使得可呼叫物件回報的的簽名 " "(signature) 更加全面和一致。" -#: ../../library/functions.rst:921 +#: ../../library/functions.rst:929 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 " "an :meth:`~object.__index__` method that returns an integer. Some examples:" msgstr "" -"將整數轉換為以 \"0x\" 為前綴的小寫十六進位制字串。如果 *integer* 不是 Python :" -"class:`int` 物件,則必須定義一個 :meth:`~object.__index__` method 並且回傳一" -"個整數。舉例來說:" +"將整數轉換為以 \"0x\" 為前綴的小寫十六進位制字串。如果 *integer* 不是 " +"Python :class:`int` 物件,則必須定義一個 :meth:`~object.__index__` method 並" +"且回傳一個整數。舉例來說:" -#: ../../library/functions.rst:930 +#: ../../library/functions.rst:938 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 " @@ -1713,20 +1731,20 @@ msgstr "" "如果要將整數轉換為大寫或小寫的十六進位制字串,並可選擇有無 \"0x\" 前綴,則可" "以使用如下方法:" -#: ../../library/functions.rst:942 +#: ../../library/functions.rst:950 msgid "" "See also :func:`int` for converting a hexadecimal string to an integer using " "a base of 16." msgstr "另請參閱 :func:`int` 將十六進位制字串轉換為以 16 為基數的整數。" -#: ../../library/functions.rst:947 +#: ../../library/functions.rst:955 msgid "" "To obtain a hexadecimal string representation for a float, use the :meth:" "`float.hex` method." msgstr "" "如果要取得浮點數的十六進位制字串形式,請使用 :meth:`float.hex` method。" -#: ../../library/functions.rst:953 +#: ../../library/functions.rst:961 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. " @@ -1736,18 +1754,18 @@ msgstr "" "回傳物件的 \"識別性\" 。該值是一個整數,在此物件的生命週期中保證是唯一且恆定" "的。兩個生命期不重疊的物件可能具有相同的 :func:`id` 值。" -#: ../../library/functions.rst:958 +#: ../../library/functions.rst:966 msgid "This is the address of the object in memory." msgstr "這是該物件在記憶體中的位址。" -#: ../../library/functions.rst:960 +#: ../../library/functions.rst:968 msgid "" "Raises an :ref:`auditing event ` ``builtins.id`` with argument " "``id``." msgstr "" "引發一個附帶引數 ``id`` 的\\ :ref:`稽核事件 ` ``builtins.id``。" -#: ../../library/functions.rst:966 +#: ../../library/functions.rst:974 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, " @@ -1758,7 +1776,7 @@ msgstr "" "從輸入中讀取一行,將其轉換為字串(去除末尾的換行符)並回傳。當讀取到 EOF 時," "則引發 :exc:`EOFError`。例如: ::" -#: ../../library/functions.rst:971 +#: ../../library/functions.rst:979 msgid "" ">>> s = input('--> ')\n" "--> Monty Python's Flying Circus\n" @@ -1770,7 +1788,7 @@ msgstr "" ">>> s\n" "\"Monty Python's Flying Circus\"" -#: ../../library/functions.rst:976 +#: ../../library/functions.rst:984 msgid "" "If the :mod:`readline` module was loaded, then :func:`input` will use it to " "provide elaborate line editing and history features." @@ -1778,7 +1796,7 @@ msgstr "" "如果載入了 :mod:`readline` module,:func:`input` 將使用它來提供複雜的行編輯和" "歷史記錄功能。" -#: ../../library/functions.rst:979 ../../library/functions.rst:981 +#: ../../library/functions.rst:987 ../../library/functions.rst:989 msgid "" "Raises an :ref:`auditing event ` ``builtins.input`` with argument " "``prompt`` before reading input" @@ -1786,7 +1804,7 @@ msgstr "" "引發一個附帶讀取輸入前的引數 ``prompt`` 的\\ :ref:`稽核事件 ` " "``builtins.input``。" -#: ../../library/functions.rst:984 ../../library/functions.rst:986 +#: ../../library/functions.rst:992 ../../library/functions.rst:994 msgid "" "Raises an :ref:`auditing event ` ``builtins.input/result`` with " "the result after successfully reading input." @@ -1794,13 +1812,13 @@ msgstr "" "引發一個附帶成功讀取結果的\\ :ref:`稽核事件 ` ``builtins.input/" "result``。" -#: ../../library/functions.rst:993 +#: ../../library/functions.rst:1001 msgid "" "Return an integer object constructed from a number or a string, or return " "``0`` if no arguments are given." msgstr "" -#: ../../library/functions.rst:998 +#: ../../library/functions.rst:1006 msgid "" ">>> int(123.45)\n" "123\n" @@ -1828,20 +1846,17 @@ msgstr "" ">>> int('01110011', base=2)\n" "115" -#: ../../library/functions.rst:1013 +#: ../../library/functions.rst:1021 msgid "" "If the argument defines :meth:`~object.__int__`, ``int(x)`` returns ``x." "__int__()``. If the argument defines :meth:`~object.__index__`, it returns " -"``x.__index__()``. If the argument defines :meth:`~object.__trunc__`, it " -"returns ``x.__trunc__()``. For floating-point numbers, this truncates " -"towards zero." +"``x.__index__()``. For floating-point numbers, this truncates towards zero." msgstr "" -"如果引數定義了 :meth:`~object.__int__`,則 ``int(x)`` 回傳 ``x.__int__()``。" -"如果引數定義了 :meth:`~object.__index__` 則回傳 ``x.__index__()``。如果引數定" -"義了 :meth:`~object.__trunc__` 則回傳 ``x.__trunc__()``。對於浮點數,則會向零" -"的方向無條件捨去。" +"如果引數定義了 :meth:`~object.__int__`,則 ``int(x)`` 會回傳 ``x." +"__int__()``。如果引數定義了 :meth:`~object.__index__` 則回傳 ``x." +"__index__()``。對於浮點數,則會向零的方向無條件捨去。" -#: ../../library/functions.rst:1019 +#: ../../library/functions.rst:1026 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 " @@ -1854,7 +1869,7 @@ msgstr "" "以有 ``+`` 或 ``-``\\ (中間沒有空格)、可有個前導的零、也可被空格包圍、或在" "數字間有單一底線。" -#: ../../library/functions.rst:1025 +#: ../../library/functions.rst:1032 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 " @@ -1876,11 +1891,11 @@ msgstr "" "進制中的一個,所以 ``int('010', 0)`` 是非法的,但 ``int('010')`` 和 " "``int('010', 8)`` 是有效的。" -#: ../../library/functions.rst:1036 +#: ../../library/functions.rst:1043 msgid "The integer type is described in :ref:`typesnumeric`." msgstr "整數型別定義請參閱\\ :ref:`typesnumeric`。" -#: ../../library/functions.rst:1038 +#: ../../library/functions.rst:1045 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 " @@ -1892,22 +1907,18 @@ msgstr "" "的版本使用 :meth:`base.__int__ ` 而不是 :meth:`base." "__index__ `。" -#: ../../library/functions.rst:1048 +#: ../../library/functions.rst:1055 msgid "The first parameter is now positional-only." msgstr "第一個參數為僅限位置參數。" -#: ../../library/functions.rst:1051 +#: ../../library/functions.rst:1058 msgid "" "Falls back to :meth:`~object.__index__` if :meth:`~object.__int__` is not " "defined." msgstr "" "如果未定義 :meth:`~object.__int__` 則會回退到 :meth:`~object.__index__`。" -#: ../../library/functions.rst:1054 -msgid "The delegation to :meth:`~object.__trunc__` is deprecated." -msgstr "對 :meth:`~object.__trunc__` 的委派已棄用。" - -#: ../../library/functions.rst:1057 +#: ../../library/functions.rst:1061 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 " @@ -1921,7 +1932,12 @@ msgstr "" "`int` 轉換為字串時將會超出限制時,會引發 :exc:`ValueError`。請參閱\\ :ref:`整" "數字串轉換的長度限制 `\\ 說明文件。" -#: ../../library/functions.rst:1068 +#: ../../library/functions.rst:1069 +msgid "" +":func:`int` no longer delegates to the :meth:`~object.__trunc__` method." +msgstr ":func:`int` 不再委派給 :meth:`~object.__trunc__` method。" + +#: ../../library/functions.rst:1074 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 " @@ -1961,7 +1977,7 @@ msgstr "" "是 *classinfo* 中任一元素的 subclass 時則回傳 ``True``。其他情況,會引發 :" "exc:`TypeError`。" -#: ../../library/functions.rst:1100 +#: ../../library/functions.rst:1106 msgid "" "Return an :term:`iterator` object. The first argument is interpreted very " "differently depending on the presence of the second argument. Without a " @@ -1977,19 +1993,19 @@ msgid "" "raised, otherwise the value will be returned." msgstr "" "回傳一個 :term:`iterator` 物件。根據是否存在第二個引數,第一個引數的意義是非" -"常不同的。如果沒有第二個引數,該單一引數必須是支援 :term:`iterable` 協定(有 :" -"meth:`~object.__iter__` method)的集合物件,或必須支援序列協定(有 :meth:" -"`~object.__getitem__` 方法,且數字引數從 ``0`` 開始)。如果它不支援這些協定," -"會引發 :exc:`TypeError`。如果有第二個引數 *sentinel*,那麼第一引數必須是可" -"呼叫的物件,這種情況下生成的 iterator,每次疊代呼叫 :meth:`~iterator." +"常不同的。如果沒有第二個引數,該單一引數必須是支援 :term:`iterable` 協定" +"(有 :meth:`~object.__iter__` method)的集合物件,或必須支援序列協定(有 :" +"meth:`~object.__getitem__` 方法,且數字引數從 ``0`` 開始)。如果它不支援這些" +"協定,會引發 :exc:`TypeError`。如果有第二個引數 *sentinel*,那麼第一引數必須" +"是可呼叫的物件,這種情況下生成的 iterator,每次疊代呼叫 :meth:`~iterator." "__next__` 時會不帶引數地呼叫 *callable*;如果回傳的結果是 *sentinel* 則引發 :" "exc:`StopIteration`,否則回傳呼叫結果。" -#: ../../library/functions.rst:1114 +#: ../../library/functions.rst:1120 msgid "See also :ref:`typeiter`." msgstr "另請參閱 :ref:`typeiter`。" -#: ../../library/functions.rst:1116 +#: ../../library/functions.rst:1122 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 " @@ -1998,7 +2014,7 @@ msgstr "" ":func:`iter` 的第二種形式有一個好用的應用,是能夠建立一個區塊閱讀器 (block-" "reader)。例如,從二進位資料庫檔案中讀取固定寬度的區塊,直到檔案的結尾: ::" -#: ../../library/functions.rst:1120 +#: ../../library/functions.rst:1126 msgid "" "from functools import partial\n" "with open('mydata.db', 'rb') as f:\n" @@ -2010,7 +2026,7 @@ msgstr "" " for block in iter(partial(f.read, 64), b''):\n" " process_block(block)" -#: ../../library/functions.rst:1128 +#: ../../library/functions.rst:1134 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 " @@ -2019,7 +2035,7 @@ msgstr "" "回傳物件的長度(元素個數)。引數可以是序列(如 string、bytes、tuple、list 或 " "range)或集合(如 dictionary、set 或 frozen set)。" -#: ../../library/functions.rst:1134 +#: ../../library/functions.rst:1140 msgid "" "``len`` raises :exc:`OverflowError` on lengths larger than :data:`sys." "maxsize`, such as :class:`range(2 ** 100) `." @@ -2027,7 +2043,7 @@ msgstr "" "如果物件長度大於 :data:`sys.maxsize`,像是 :class:`range(2 ** 100) `," "則 ``len`` 會引發 :exc:`OverflowError`。" -#: ../../library/functions.rst:1142 +#: ../../library/functions.rst:1148 msgid "" "Rather than being a function, :class:`list` is actually a mutable sequence " "type, as documented in :ref:`typesseq-list` and :ref:`typesseq`." @@ -2035,33 +2051,33 @@ msgstr "" "除了是函式,:class:`list` 也是可變序列型別,詳情請參閱 :ref:`typesseq-list` " "和 :ref:`typesseq`。" -#: ../../library/functions.rst:1148 +#: ../../library/functions.rst:1154 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 "" -#: ../../library/functions.rst:1152 +#: ../../library/functions.rst:1158 msgid "" "At module scope, as well as when using :func:`exec` or :func:`eval` with a " "single namespace, this function returns the same namespace as :func:" "`globals`." msgstr "" -#: ../../library/functions.rst:1156 +#: ../../library/functions.rst:1162 msgid "" "At class scope, it returns the namespace that will be passed to the " "metaclass constructor." msgstr "" -#: ../../library/functions.rst:1159 +#: ../../library/functions.rst:1165 msgid "" "When using ``exec()`` or ``eval()`` with separate local and global " "arguments, it returns the local namespace passed in to the function call." msgstr "" -#: ../../library/functions.rst:1162 +#: ../../library/functions.rst:1168 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 " @@ -2071,7 +2087,7 @@ msgid "" "returned mapping object." msgstr "" -#: ../../library/functions.rst:1169 +#: ../../library/functions.rst:1175 msgid "" "In an :term:`optimized scope` (including functions, generators, and " "coroutines), each call to ``locals()`` instead returns a fresh dictionary " @@ -2083,7 +2099,7 @@ msgid "" "previously returned dictionaries." msgstr "" -#: ../../library/functions.rst:1178 +#: ../../library/functions.rst:1184 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 " @@ -2092,19 +2108,19 @@ msgid "" "function." msgstr "" -#: ../../library/functions.rst:1184 +#: ../../library/functions.rst:1190 msgid "" "Calling ``locals()`` as part of a generator expression is equivalent to " "calling it in a nested generator function." msgstr "" -#: ../../library/functions.rst:1187 +#: ../../library/functions.rst:1193 msgid "" "The behaviour of ``locals()`` in a comprehension has been updated as " "described in :pep:`709`." msgstr "" -#: ../../library/functions.rst:1191 +#: ../../library/functions.rst:1197 msgid "" "As part of :pep:`667`, the semantics of mutating the mapping objects " "returned from this function are now defined. The behavior in :term:" @@ -2113,28 +2129,35 @@ msgid "" "versions." msgstr "" -#: ../../library/functions.rst:1201 +#: ../../library/functions.rst:1207 msgid "" "Return an iterator that applies *function* to every item of *iterable*, " "yielding the results. If additional *iterables* arguments are passed, " "*function* must take that many arguments and is applied to the items from " "all iterables in parallel. With multiple iterables, the iterator stops when " -"the shortest iterable is exhausted. For cases where the function inputs are " -"already arranged into argument tuples, see :func:`itertools.starmap`\\." -msgstr "" -"產生一個將 *function* 應用於 *iterable* 中所有元素,並收集回傳結果的 " -"iterator。如果傳遞了額外的 *iterables* 引數,則 *function* 必須接受相同個數的" -"引數,並使用所有從 iterables 中同時取得的元素。當有多個 iterables 時,最短的 " -"iteratable 耗盡時 iterator 也會結束。如果函式的輸入已經被編排為引數的 tuple," -"請參閱 :func:`itertools.starmap`。" +"the shortest iterable is exhausted. If *strict* is ``True`` and one of the " +"iterables is exhausted before the others, a :exc:`ValueError` is raised. For " +"cases where the function inputs are already arranged into argument tuples, " +"see :func:`itertools.starmap`." +msgstr "" +"產生一個將 *function* 應用於 *iterable* 中所有項目並 yield 回傳結果的疊代器。" +"如果傳遞了額外的 *iterables* 引數,則 *function* 必須接受相同個數的引數,且 " +"*function* 會平行地被應用於所有可疊代物件的項目。當有多個可疊代物件時,項目最" +"少的可疊代物件耗盡時疊代器也會結束。如果 *strict* 為 ``True`` 且其中一個可疊" +"代物件在其他可疊代物件之前耗盡,則會拋出 :exc:`ValueError`。如果函式的輸入已" +"經被編排為引數的元組,請參閱 :func:`itertools.starmap`。" -#: ../../library/functions.rst:1213 +#: ../../library/functions.rst:1216 +msgid "Added the *strict* parameter." +msgstr "增加了 *strict* 參數。" + +#: ../../library/functions.rst:1224 msgid "" "Return the largest item in an iterable or the largest of two or more " "arguments." msgstr "回傳 iterable 中最大的元素,或者回傳兩個以上的引數中最大的。" -#: ../../library/functions.rst:1216 +#: ../../library/functions.rst:1227 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 " @@ -2143,7 +2166,7 @@ msgstr "" "如果只提供了一個位置引數,它必須是個 :term:`iterable`,iterable 中最大的元素" "會被回傳。如果提供了兩個或以上的位置引數,則回傳最大的位置引數。" -#: ../../library/functions.rst:1221 ../../library/functions.rst:1259 +#: ../../library/functions.rst:1232 ../../library/functions.rst:1270 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 " @@ -2156,7 +2179,7 @@ msgstr "" "的物件。如果 iterable 為空,並且沒有提供 *default*,則會引發 :exc:" "`ValueError`。" -#: ../../library/functions.rst:1227 +#: ../../library/functions.rst:1238 msgid "" "If multiple items are maximal, the function returns the first one " "encountered. This is consistent with other sort-stability preserving tools " @@ -2167,15 +2190,15 @@ msgstr "" "``sorted(iterable, key=keyfunc, reverse=True)[0]`` 和 ``heapq.nlargest(1, " "iterable, key=keyfunc)`` 一致。" -#: ../../library/functions.rst:1232 ../../library/functions.rst:1270 +#: ../../library/functions.rst:1243 ../../library/functions.rst:1281 msgid "Added the *default* keyword-only parameter." msgstr "新增 *default* 僅限關鍵字參數。" -#: ../../library/functions.rst:1235 ../../library/functions.rst:1273 +#: ../../library/functions.rst:1246 ../../library/functions.rst:1284 msgid "The *key* can be ``None``." msgstr "*key* 可以為 ``None``。" -#: ../../library/functions.rst:1243 +#: ../../library/functions.rst:1254 msgid "" "Return a \"memory view\" object created from the given argument. See :ref:" "`typememoryview` for more information." @@ -2183,13 +2206,13 @@ msgstr "" "回傳由給定的引數所建立之「memory view(記憶體檢視)」物件。有關詳細資訊,請參" "閱\\ :ref:`typememoryview`。" -#: ../../library/functions.rst:1251 +#: ../../library/functions.rst:1262 msgid "" "Return the smallest item in an iterable or the smallest of two or more " "arguments." msgstr "回傳 iterable 中最小的元素,或者回傳兩個以上的引數中最小的。" -#: ../../library/functions.rst:1254 +#: ../../library/functions.rst:1265 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 " @@ -2198,7 +2221,7 @@ msgstr "" "如果只提供了一個位置引數,它必須是 :term:`iterable`,iterable 中最小的元素會" "被回傳。如果提供了兩個以上的位置引數,則回傳最小的位置引數。" -#: ../../library/functions.rst:1265 +#: ../../library/functions.rst:1276 msgid "" "If multiple items are minimal, the function returns the first one " "encountered. This is consistent with other sort-stability preserving tools " @@ -2209,7 +2232,7 @@ msgstr "" "``sorted(iterable, key=keyfunc)[0]`` 和 ``heapq.nsmallest(1, iterable, " "key=keyfunc)`` 一致。" -#: ../../library/functions.rst:1280 +#: ../../library/functions.rst:1291 msgid "" "Retrieve the next item from the :term:`iterator` by calling its :meth:" "`~iterator.__next__` method. If *default* is given, it is returned if the " @@ -2219,7 +2242,7 @@ msgstr "" "素。如果 iterator 耗盡,則回傳給定的預設值 *default*,如果沒有預設值則引發 :" "exc:`StopIteration`。" -#: ../../library/functions.rst:1287 +#: ../../library/functions.rst:1298 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 " @@ -2230,7 +2253,7 @@ msgstr "" "函式被呼叫時,它會回傳一個新的沒有特徵 (featureless) 的物件。這個建構函式不接" "受任何引數。" -#: ../../library/functions.rst:1294 +#: ../../library/functions.rst:1305 msgid "" ":class:`object` instances do *not* have :attr:`~object.__dict__` attributes, " "so you can't assign arbitrary attributes to an instance of :class:`object`." @@ -2238,7 +2261,7 @@ msgstr "" "由於 :class:`object` 實例\\ *沒有* :attr:`~object.__dict__` 屬性,因此無法將" "任意屬性賦給 :class:`object` 的實例。" -#: ../../library/functions.rst:1301 +#: ../../library/functions.rst:1312 msgid "" "Convert an integer number to an octal string prefixed with \"0o\". The " "result is a valid Python expression. If *integer* is not a Python :class:" @@ -2246,10 +2269,10 @@ msgid "" "returns an integer. For example:" msgstr "" "將一個整數轉變為一個前綴為 \"0o\" 的八進位制字串。回傳結果是一個有效的 " -"Python 運算式。如果 *integer* 不是 Python 的 :class:`int` 物件,那它需要定義 :meth:" -"`~object.__index__` method 回傳一個整數。舉例來說:" +"Python 運算式。如果 *integer* 不是 Python 的 :class:`int` 物件,那它需要定" +"義 :meth:`~object.__index__` method 回傳一個整數。舉例來說:" -#: ../../library/functions.rst:1311 +#: ../../library/functions.rst:1322 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." @@ -2257,7 +2280,7 @@ msgstr "" "如果要將整數轉換為八進位制字串,不論是否具備 \"0o\" 前綴,都可以使用下面的方" "法。" -#: ../../library/functions.rst:1328 +#: ../../library/functions.rst:1339 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 " @@ -2267,7 +2290,7 @@ msgstr "" "啟,則引發 :exc:`OSError`。關於使用此函式的更多方法,請參閱\\ :ref:`tut-" "files`。" -#: ../../library/functions.rst:1332 +#: ../../library/functions.rst:1343 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 " @@ -2280,7 +2303,7 @@ msgstr "" "器 (file descriptor)。(如果有給定檔案描述器,它會隨著回傳的 I/O 物件關閉而關" "閉,除非 *closefd* 被設為 ``False``。)" -#: ../../library/functions.rst:1338 +#: ../../library/functions.rst:1349 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. " @@ -2301,71 +2324,71 @@ msgstr "" "getencoding` 來取得目前的本地編碼。(要讀取和寫入原始 bytes,請使用二進位制模" "式且不要指定 *encoding*。)可用的模式有:" -#: ../../library/functions.rst:1355 +#: ../../library/functions.rst:1366 msgid "Character" msgstr "字元" -#: ../../library/functions.rst:1355 +#: ../../library/functions.rst:1366 msgid "Meaning" msgstr "意義" -#: ../../library/functions.rst:1357 +#: ../../library/functions.rst:1368 msgid "``'r'``" msgstr "``'r'``" -#: ../../library/functions.rst:1357 +#: ../../library/functions.rst:1368 msgid "open for reading (default)" msgstr "讀取(預設)" -#: ../../library/functions.rst:1358 +#: ../../library/functions.rst:1369 msgid "``'w'``" msgstr "``'w'``" -#: ../../library/functions.rst:1358 +#: ../../library/functions.rst:1369 msgid "open for writing, truncating the file first" msgstr "寫入,會先清除檔案內容" -#: ../../library/functions.rst:1359 +#: ../../library/functions.rst:1370 msgid "``'x'``" msgstr "``'x'``" -#: ../../library/functions.rst:1359 +#: ../../library/functions.rst:1370 msgid "open for exclusive creation, failing if the file already exists" msgstr "唯一性建立,如果文件已存在則會失敗" -#: ../../library/functions.rst:1360 +#: ../../library/functions.rst:1371 msgid "``'a'``" msgstr "``'a'``" -#: ../../library/functions.rst:1360 +#: ../../library/functions.rst:1371 msgid "open for writing, appending to the end of file if it exists" msgstr "寫入,如果檔案存在則在其末端附加內容" -#: ../../library/functions.rst:1361 +#: ../../library/functions.rst:1372 msgid "``'b'``" msgstr "``'b'``" -#: ../../library/functions.rst:1361 ../../library/functions.rst:1505 +#: ../../library/functions.rst:1372 ../../library/functions.rst:1516 msgid "binary mode" msgstr "二進制模式" -#: ../../library/functions.rst:1362 +#: ../../library/functions.rst:1373 msgid "``'t'``" msgstr "``'t'``" -#: ../../library/functions.rst:1362 +#: ../../library/functions.rst:1373 msgid "text mode (default)" msgstr "文字模式(預設)" -#: ../../library/functions.rst:1363 +#: ../../library/functions.rst:1374 msgid "``'+'``" msgstr "``'+'``" -#: ../../library/functions.rst:1363 +#: ../../library/functions.rst:1374 msgid "open for updating (reading and writing)" msgstr "更新(讀取並寫入)" -#: ../../library/functions.rst:1366 +#: ../../library/functions.rst:1377 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 " @@ -2375,7 +2398,7 @@ msgstr "" "``'w+b'`` 模式會開啟並清除檔案。``'r+'`` 和 ``'r+b'`` 模式會開啟且保留檔案內" "容。" -#: ../../library/functions.rst:1370 +#: ../../library/functions.rst:1381 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* " @@ -2391,7 +2414,7 @@ msgstr "" "``'t'``),檔案的內容會以 :class:`str` 回傳,其位元組已經先被解碼,使用的是取" "決於平台的編碼系統或是給定的 *encoding*。" -#: ../../library/functions.rst:1380 +#: ../../library/functions.rst:1391 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 " @@ -2400,7 +2423,7 @@ msgstr "" "Python 不會使用底層作業系統對於文字檔案的操作概念;所有的處理都是由 Python 獨" "自完成的,因此能獨立於不同平台。" -#: ../../library/functions.rst:1384 +#: ../../library/functions.rst:1395 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 " @@ -2421,19 +2444,18 @@ msgstr "" "``write_through`` 旗標。若未給定 *buffering* 引數,則預設的緩衝策略會運作如" "下:" -#: ../../library/functions.rst:1394 +#: ../../library/functions.rst:1405 msgid "" "Binary files are buffered in fixed-size chunks; the size of the buffer is " -"chosen using a heuristic trying to determine the underlying device's \"block " -"size\" and falling back on :const:`io.DEFAULT_BUFFER_SIZE`. On many " -"systems, the buffer will typically be 4096 or 8192 bytes long." +"``max(min(blocksize, 8 MiB), DEFAULT_BUFFER_SIZE)`` when the device block " +"size is available. On most systems, the buffer will typically be 128 " +"kilobytes long." msgstr "" -"二進制檔案會以固定大小的區塊進行緩衝;緩衝區的大小是使用啟發式嘗試 " -"(heuristic trying) 來決定底層設備的「區塊大小」,並會回退到 :attr:`io." -"DEFAULT_BUFFER_SIZE`。在許多系統上,緩衝區的長度通常為 4096 或 8192 個位元" -"組。" +"二進位檔案會以固定大小的區塊進行緩衝;緩衝區的大小為 ``max(min(blocksize, 8 " +"MiB), DEFAULT_BUFFER_SIZE)``,當裝置區塊大小可用時。在大多數系統上,緩衝區的" +"長度通常為 128 KB。" -#: ../../library/functions.rst:1399 +#: ../../library/functions.rst:1410 msgid "" "\"Interactive\" text files (files for which :meth:`~io.IOBase.isatty` " "returns ``True``) use line buffering. Other text files use the policy " @@ -2442,7 +2464,7 @@ msgstr "" "「互動式」文字檔(:meth:`~io.IOBase.isatty` 回傳 ``True`` 的檔案)會使用列緩" "衝。其他文字檔則使用上述的二進制檔案緩衝策略。" -#: ../../library/functions.rst:1403 +#: ../../library/functions.rst:1414 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 " @@ -2455,7 +2477,7 @@ msgstr "" "Python 支援的任何 :term:`text encoding`\\ (文字編碼)都是可以使用的。關於支" "援的編碼系統清單,請參閱 :mod:`codecs` module。" -#: ../../library/functions.rst:1409 +#: ../../library/functions.rst:1420 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 " @@ -2468,7 +2490,7 @@ msgstr "" "handlers`\\ 有列出清單),不過任何已註冊到 :func:`codecs.register_error` 的錯" "誤處理程式名稱也都是有效的。標準的名稱包括:" -#: ../../library/functions.rst:1417 +#: ../../library/functions.rst:1428 msgid "" "``'strict'`` to raise a :exc:`ValueError` exception if there is an encoding " "error. The default value of ``None`` has the same effect." @@ -2476,20 +2498,20 @@ msgstr "" "``'strict'`` 如果發生編碼錯誤,則引發 :exc:`ValueError` 例外。預設值 " "``None`` 也有相同的效果。" -#: ../../library/functions.rst:1421 +#: ../../library/functions.rst:1432 msgid "" "``'ignore'`` ignores errors. Note that ignoring encoding errors can lead to " "data loss." msgstr "``'ignore'`` 忽略錯誤。請注意,忽略編碼錯誤可能導致資料遺失。" -#: ../../library/functions.rst:1424 +#: ../../library/functions.rst:1435 msgid "" "``'replace'`` causes a replacement marker (such as ``'?'``) to be inserted " "where there is malformed data." msgstr "" "``'replace'`` 會在格式不正確的資料位置插入一個替換標誌(像是 ``'?'``)。" -#: ../../library/functions.rst:1427 +#: ../../library/functions.rst:1438 msgid "" "``'surrogateescape'`` will represent any incorrect bytes as low surrogate " "code units ranging from U+DC80 to U+DCFF. These surrogate code units will " @@ -2502,7 +2524,7 @@ msgstr "" "被還原回 ``surrogateescape`` 錯誤處理程式當時所處理的那些相同位元組。這對於處" "理未知編碼方式的檔案會很好用。" -#: ../../library/functions.rst:1434 +#: ../../library/functions.rst:1445 msgid "" "``'xmlcharrefreplace'`` is only supported when writing to a file. Characters " "not supported by the encoding are replaced with the appropriate XML " @@ -2511,7 +2533,7 @@ msgstr "" "``'xmlcharrefreplace'`` 僅在寫入檔案時可支援。編碼系統不支援的字元會被替換為" "適當的 XML 字元參考 (character reference) ``&#nnn;``。" -#: ../../library/functions.rst:1438 +#: ../../library/functions.rst:1449 msgid "" "``'backslashreplace'`` replaces malformed data by Python's backslashed " "escape sequences." @@ -2519,7 +2541,7 @@ msgstr "" "``'backslashreplace'`` 會用 Python 的反斜線跳脫序列 (backslashed escape " "sequence) 替換格式不正確的資料。" -#: ../../library/functions.rst:1441 +#: ../../library/functions.rst:1452 msgid "" "``'namereplace'`` (also only supported when writing) replaces unsupported " "characters with ``\\N{...}`` escape sequences." @@ -2527,7 +2549,7 @@ msgstr "" "``'namereplace'``\\ (也僅在寫入時支援)會將不支援的字元替換為 ``\\N{...}`` " "跳脫序列。" -#: ../../library/functions.rst:1449 +#: ../../library/functions.rst:1460 msgid "" "*newline* determines how to parse newline characters from the stream. It can " "be ``None``, ``''``, ``'\\n'``, ``'\\r'``, and ``'\\r\\n'``. It works as " @@ -2536,7 +2558,7 @@ msgstr "" "*newline* 會決定如何剖析資料串流 (stream) 中的換行字元。它可以是 ``None``、" "``''``、``'\\n'``、``'\\r'`` 或 ``'\\r\\n'``。它的運作規則如下:" -#: ../../library/functions.rst:1453 +#: ../../library/functions.rst:1464 msgid "" "When reading input from the stream, if *newline* is ``None``, universal " "newlines mode is enabled. Lines in the input can end in ``'\\n'``, " @@ -2552,7 +2574,7 @@ msgstr "" "傳給呼叫方時,行尾符號不會被轉換。如果它是任何其他有效的值,則輸入資料的行只" "會由給定的字串做結尾,且在回傳給呼叫方時,行尾符號不會被轉換。" -#: ../../library/functions.rst:1461 +#: ../../library/functions.rst:1472 msgid "" "When writing output to the stream, if *newline* is ``None``, any ``'\\n'`` " "characters written are translated to the system default line separator, :" @@ -2565,7 +2587,7 @@ msgstr "" "``''`` 或 ``'\\n'``,則不做任何轉換。如果 *newline* 是任何其他有效的值,則寫" "入的任何 ``'\\n'`` 字元都將轉換為給定的字串。" -#: ../../library/functions.rst:1467 +#: ../../library/functions.rst:1478 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 " @@ -2576,7 +2598,7 @@ msgstr "" "則當檔案關閉時,底層的檔案描述器會保持開啟狀態。如果有給定一個檔名,則 " "*closefd* 必須是 ``True``\\ (預設值);否則將引發錯誤。" -#: ../../library/functions.rst:1472 +#: ../../library/functions.rst:1483 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 " @@ -2589,11 +2611,11 @@ msgstr "" "必須回傳一個開啟的檔案描述器(將 :mod:`os.open` 作為 *opener* 傳入,在功能上" "的結果會相當於傳入 ``None``)。" -#: ../../library/functions.rst:1478 +#: ../../library/functions.rst:1489 msgid "The newly created file is :ref:`non-inheritable `." msgstr "新建立的檔案是\\ :ref:`不可繼承的 `。" -#: ../../library/functions.rst:1480 +#: ../../library/functions.rst:1491 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::" @@ -2601,7 +2623,7 @@ msgstr "" "下面的範例使用 :func:`os.open` 函式回傳值當作 :ref:`dir_fd ` 的參數," "從給定的目錄中用相對路徑開啟檔案: ::" -#: ../../library/functions.rst:1483 +#: ../../library/functions.rst:1494 msgid "" ">>> import os\n" ">>> dir_fd = os.open('somedir', os.O_RDONLY)\n" @@ -2613,8 +2635,17 @@ msgid "" "...\n" ">>> os.close(dir_fd) # don't leak a file descriptor" msgstr "" +">>> import os\n" +">>> dir_fd = os.open('somedir', os.O_RDONLY)\n" +">>> def opener(path, flags):\n" +"... return os.open(path, flags, dir_fd=dir_fd)\n" +"...\n" +">>> with open('spamspam.txt', 'w', opener=opener) as f:\n" +"... print('This will be written to somedir/spamspam.txt', file=f)\n" +"...\n" +">>> os.close(dir_fd) # don't leak a file descriptor" -#: ../../library/functions.rst:1493 +#: ../../library/functions.rst:1504 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 " @@ -2638,7 +2669,7 @@ msgstr "" "BufferedRandom`。當緩衝被停用時,會回傳原始資料串流 :class:`io.FileIO`,它" "是 :class:`io.RawIOBase` 的一個 subclass。" -#: ../../library/functions.rst:1514 +#: ../../library/functions.rst:1525 msgid "" "See also the file handling modules, such as :mod:`fileinput`, :mod:`io` " "(where :func:`open` is declared), :mod:`os`, :mod:`os.path`, :mod:" @@ -2648,7 +2679,7 @@ msgstr "" "`open` 的 module )、:mod:`os`、:mod:`os.path`、:mod:`tempfile` 以及 :mod:" "`shutil`。" -#: ../../library/functions.rst:1518 +#: ../../library/functions.rst:1529 msgid "" "Raises an :ref:`auditing event ` ``open`` with arguments ``path``, " "``mode``, ``flags``." @@ -2656,25 +2687,25 @@ msgstr "" "引發一個附帶引數 ``path``、``mode``、``flags`` 的\\ :ref:`稽核事件 " "` ``open``。" -#: ../../library/functions.rst:1520 +#: ../../library/functions.rst:1531 msgid "" "The ``mode`` and ``flags`` arguments may have been modified or inferred from " "the original call." msgstr "``mode`` 和 ``flags`` 引數可能會被原始的呼叫所修改或推論 (infer)。" -#: ../../library/functions.rst:1525 +#: ../../library/functions.rst:1536 msgid "The *opener* parameter was added." msgstr "增加了 *opener* 參數。" -#: ../../library/functions.rst:1526 +#: ../../library/functions.rst:1537 msgid "The ``'x'`` mode was added." msgstr "增加了 ``'x'`` 模式。" -#: ../../library/functions.rst:1527 +#: ../../library/functions.rst:1538 msgid ":exc:`IOError` used to be raised, it is now an alias of :exc:`OSError`." msgstr "過去引發的 :exc:`IOError`,現在是 :exc:`OSError` 的別名。" -#: ../../library/functions.rst:1528 +#: ../../library/functions.rst:1539 msgid "" ":exc:`FileExistsError` is now raised if the file opened in exclusive " "creation mode (``'x'``) already exists." @@ -2682,11 +2713,11 @@ msgstr "" "如果檔案已存在但使用了唯一性建立模式 (``'x'``),現在會引發 :exc:" "`FileExistsError`。" -#: ../../library/functions.rst:1533 +#: ../../library/functions.rst:1544 msgid "The file is now non-inheritable." msgstr "檔案在此版本開始是不可繼承的。" -#: ../../library/functions.rst:1537 +#: ../../library/functions.rst:1548 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 :" @@ -2695,15 +2726,15 @@ msgstr "" "如果系統呼叫被中斷,但訊號處理程式沒有引發例外,此函式現在會重試系統呼叫,而" "不是引發 :exc:`InterruptedError` 例外(原因詳見 :pep:`475`)。" -#: ../../library/functions.rst:1540 +#: ../../library/functions.rst:1551 msgid "The ``'namereplace'`` error handler was added." msgstr "增加了 ``'namereplace'`` 錯誤處理程式。" -#: ../../library/functions.rst:1544 +#: ../../library/functions.rst:1555 msgid "Support added to accept objects implementing :class:`os.PathLike`." msgstr "增加對於實作 :class:`os.PathLike` 物件的支援。" -#: ../../library/functions.rst:1545 +#: ../../library/functions.rst:1556 msgid "" "On Windows, opening a console buffer may return a subclass of :class:`io." "RawIOBase` other than :class:`io.FileIO`." @@ -2711,15 +2742,15 @@ msgstr "" "在 Windows 上,開啟一個控制臺緩衝區可能會回傳 :class:`io.RawIOBase` 的 " "subclass,而不是 :class:`io.FileIO`。" -#: ../../library/functions.rst:1548 +#: ../../library/functions.rst:1559 msgid "The ``'U'`` mode has been removed." msgstr "``'U'`` 模式被移除。" -#: ../../library/functions.rst:1553 +#: ../../library/functions.rst:1564 msgid "Return the ordinal value of a character." msgstr "" -#: ../../library/functions.rst:1555 +#: ../../library/functions.rst:1566 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 " @@ -2730,14 +2761,14 @@ msgstr "" "整數 ``97``、``ord('€')``\\ (歐元符號)回傳 ``8364``。這是 :func:`chr` 的逆" "函式。" -#: ../../library/functions.rst:1560 +#: ../../library/functions.rst:1571 msgid "" "If the argument is a :class:`bytes` or :class:`bytearray` object of length " "1, return its single byte value. For example, ``ord(b'a')`` returns the " "integer ``97``." msgstr "" -#: ../../library/functions.rst:1567 +#: ../../library/functions.rst:1578 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) % " @@ -2748,7 +2779,7 @@ msgstr "" "*mod* 取餘數(比直接呼叫 ``pow(base, exp) % mod`` 計算更高效)。兩個引數形式" "的 ``pow(exp, exp)`` 等價於次方運算子:``base**exp``。" -#: ../../library/functions.rst:1572 +#: ../../library/functions.rst:1583 msgid "" "When arguments are builtin numeric types with mixed operand types, the " "coercion rules for binary arithmetic operators apply. For :class:`int` " @@ -2762,17 +2793,17 @@ msgid "" "`float` with an integral exponent, a float result is delivered. For example, " "``pow(-9, 2.0)`` returns ``81.0``." msgstr "" -"當引數為內建數值型別,且用於混合型別的運算元,會套用二元算術運算子的強制轉型 " +"當引數為內建數值型別且運算元型別為混合型別時,會套用二元算術運算子的強制轉型 " "(coercion) 規則。對於 :class:`int` 運算元,運算結果會(在強制轉型後)與運算元" "的型別相同,除非第二個引數是負數;在這種情況下,所有的引數都會被轉換為浮點數" "並得到浮點數的結果。例如,``pow(10, 2)`` 會回傳 ``100``,但 ``pow(10, -2)`` " "會回傳 ``0.01``。如果底數 (base) 是型別為 :class:`int` 或 :class:`float` 的負" -"數且指數 (exponent) 不是整數,則會得到一個複數的結果,例如 ``pow(-9, 0.5)`` " -"會回傳一個接近 ``3j`` 的值。如果底數 (base) 是型別為 :class:`int` 或 :class:" -"`float` 的負數且指數為整數,則會得到一個浮點數的結果,例如 ``pow(-9, 2.0)`` " -"會回傳 ``81.0``。" +"數且指數 (exponent) 為非整數,則會傳回複數結果。例如 ``pow(-9, 0.5)`` 會回傳" +"一個接近 ``3j`` 的值。然而,如果底數 (base) 是型別為 :class:`int` 或 :class:" +"`float` 的負數且指數為整數,則會傳回浮點數結果。例如 ``pow(-9, 2.0)`` 會回傳 " +"``81.0``。" -#: ../../library/functions.rst:1584 +#: ../../library/functions.rst:1595 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 " @@ -2785,11 +2816,11 @@ msgstr "" "與 *mod* 互質。在這種情況下,會回傳 ``pow(inv_base, -exp, mod)``,其中 " "*inv_base* 是 *base* 對 *mod* 的模倒數 (inverse modulo)。" -#: ../../library/functions.rst:1590 +#: ../../library/functions.rst:1601 msgid "Here's an example of computing an inverse for ``38`` modulo ``97``::" msgstr "以下是一個計算 ``38`` 對 ``97`` 取模倒數的範例: ::" -#: ../../library/functions.rst:1592 +#: ../../library/functions.rst:1603 msgid "" ">>> pow(38, -1, mod=97)\n" "23\n" @@ -2801,7 +2832,7 @@ msgstr "" ">>> 23 * 38 % 97 == 1\n" "True" -#: ../../library/functions.rst:1597 +#: ../../library/functions.rst:1608 msgid "" "For :class:`int` operands, the three-argument form of ``pow`` now allows the " "second argument to be negative, permitting computation of modular inverses." @@ -2809,12 +2840,12 @@ msgstr "" "對於 :class:`int` 運算元,現在 ``pow`` 的三引數形式允許第二個引數為負數,也容" "許模倒數的計算。" -#: ../../library/functions.rst:1602 +#: ../../library/functions.rst:1613 msgid "" "Allow keyword arguments. Formerly, only positional arguments were supported." msgstr "允許關鍵字引數。在此之前只支援位置引數。" -#: ../../library/functions.rst:1609 +#: ../../library/functions.rst:1620 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 " @@ -2823,7 +2854,7 @@ msgstr "" "將 *objects* 列印到文字資料串流 *file*,用 *sep* 分隔並以 *end* 結尾。如果有" "給定 *sep*、*end*、*file* 和 *flush*,那麼它們必須是關鍵字引數的形式。" -#: ../../library/functions.rst:1613 +#: ../../library/functions.rst:1624 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* " @@ -2836,7 +2867,7 @@ msgstr "" "以是 ``None``,這表示使用預設值。如果沒有給定 *objects*,:func:`print` 就只會" "寫入 *end*。" -#: ../../library/functions.rst:1619 +#: ../../library/functions.rst:1630 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 " @@ -2848,7 +2879,7 @@ msgstr "" "串,所以 :func:`print` 不能用於二進位模式的檔案物件。對於此類物件,請改用 " "``file.write(...)``。" -#: ../../library/functions.rst:1624 +#: ../../library/functions.rst:1635 msgid "" "Output buffering is usually determined by *file*. However, if *flush* is " "true, the stream is forcibly flushed." @@ -2856,15 +2887,15 @@ msgstr "" "輸出緩衝通常會由 *file* 決定。但是如果 *flush* 為 true,則資料串流會被強制清" "除。" -#: ../../library/functions.rst:1628 +#: ../../library/functions.rst:1639 msgid "Added the *flush* keyword argument." msgstr "增加了 *flush* 關鍵字引數。" -#: ../../library/functions.rst:1634 +#: ../../library/functions.rst:1645 msgid "Return a property attribute." msgstr "回傳 property 屬性。" -#: ../../library/functions.rst:1636 +#: ../../library/functions.rst:1647 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 " @@ -2873,11 +2904,11 @@ msgstr "" "*fget* 是一個用於取得屬性值的函式,*fset* 是一個用於設定屬性值的函式,*fdel* " "是一個用於刪除屬性值的函式,而 *doc* 會為該屬性建立一個說明字串。" -#: ../../library/functions.rst:1640 +#: ../../library/functions.rst:1651 msgid "A typical use is to define a managed attribute ``x``::" msgstr "一個典型的用途是定義一個受管理的屬性 ``x``: ::" -#: ../../library/functions.rst:1642 +#: ../../library/functions.rst:1653 msgid "" "class C:\n" " def __init__(self):\n" @@ -2909,7 +2940,7 @@ msgstr "" "\n" " x = property(getx, setx, delx, \"I'm the 'x' property.\")" -#: ../../library/functions.rst:1657 +#: ../../library/functions.rst:1668 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." @@ -2917,7 +2948,7 @@ msgstr "" "如果 *c* 是 *C* 的一個實例,則 ``c.x`` 將會叫用取得器 (getter),``c.x = " "value`` 會呼叫設定器 (setter),而 ``del c.x`` 會叫用刪除器 (deleter)。" -#: ../../library/functions.rst:1660 +#: ../../library/functions.rst:1671 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 " @@ -2928,7 +2959,7 @@ msgstr "" "*fget* 的說明字串(如果它存在的話)。這樣一來,就能夠輕鬆地使用 :func:" "`property` 作為\\ :term:`裝飾器 `\\ 來建立唯讀屬性: ::" -#: ../../library/functions.rst:1664 +#: ../../library/functions.rst:1675 msgid "" "class Parrot:\n" " def __init__(self):\n" @@ -2940,14 +2971,14 @@ msgid "" " return self._voltage" msgstr "" -#: ../../library/functions.rst:1673 +#: ../../library/functions.rst:1684 msgid "" "The ``@property`` decorator turns the :meth:`!voltage` method into a " "\"getter\" for a read-only attribute with the same name, and it sets the " "docstring for *voltage* to \"Get the current voltage.\"" msgstr "" -#: ../../library/functions.rst:1681 +#: ../../library/functions.rst:1692 msgid "" "A property object has ``getter``, ``setter``, and ``deleter`` methods usable " "as decorators that create a copy of the property with the corresponding " @@ -2955,7 +2986,7 @@ msgid "" "with an example:" msgstr "" -#: ../../library/functions.rst:1686 +#: ../../library/functions.rst:1697 msgid "" "class C:\n" " def __init__(self):\n" @@ -2991,36 +3022,36 @@ msgstr "" " def x(self):\n" " del self._x" -#: ../../library/functions.rst:1705 +#: ../../library/functions.rst:1716 msgid "" "This code is exactly equivalent to the first example. Be sure to give the " "additional functions the same name as the original property (``x`` in this " "case.)" msgstr "" -#: ../../library/functions.rst:1709 +#: ../../library/functions.rst:1720 msgid "" "The returned property object also has the attributes ``fget``, ``fset``, and " "``fdel`` corresponding to the constructor arguments." msgstr "" -#: ../../library/functions.rst:1712 +#: ../../library/functions.rst:1723 msgid "The docstrings of property objects are now writeable." msgstr "" -#: ../../library/functions.rst:1717 +#: ../../library/functions.rst:1728 msgid "" "Attribute holding the name of the property. The name of the property can be " "changed at runtime." msgstr "" -#: ../../library/functions.rst:1728 +#: ../../library/functions.rst:1739 msgid "" "Rather than being a function, :class:`range` is actually an immutable " "sequence type, as documented in :ref:`typesseq-range` and :ref:`typesseq`." msgstr "" -#: ../../library/functions.rst:1734 +#: ../../library/functions.rst:1745 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 " @@ -3033,11 +3064,11 @@ msgid "" "raise :exc:`RuntimeError`." msgstr "" -#: ../../library/functions.rst:1745 +#: ../../library/functions.rst:1756 msgid "This class has a custom representation that can be evaluated::" msgstr "" -#: ../../library/functions.rst:1747 +#: ../../library/functions.rst:1758 msgid "" "class Person:\n" " def __init__(self, name, age):\n" @@ -3055,7 +3086,7 @@ msgstr "" " def __repr__(self):\n" " return f\"Person('{self.name}', {self.age})\"" -#: ../../library/functions.rst:1758 +#: ../../library/functions.rst:1769 msgid "" "Return a reverse :term:`iterator`. The argument must be an object which has " "a :meth:`~object.__reversed__` method or supports the sequence protocol " @@ -3063,14 +3094,14 @@ msgid "" "method with integer arguments starting at ``0``)." msgstr "" -#: ../../library/functions.rst:1766 +#: ../../library/functions.rst:1777 msgid "" "Return *number* rounded to *ndigits* precision after the decimal point. If " "*ndigits* is omitted or is ``None``, it returns the nearest integer to its " "input." msgstr "" -#: ../../library/functions.rst:1770 +#: ../../library/functions.rst:1781 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 " @@ -3081,13 +3112,13 @@ msgid "" "``None``. Otherwise, the return value has the same type as *number*." msgstr "" -#: ../../library/functions.rst:1779 +#: ../../library/functions.rst:1790 msgid "" "For a general Python object ``number``, ``round`` delegates to ``number." "__round__``." msgstr "" -#: ../../library/functions.rst:1784 +#: ../../library/functions.rst:1795 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 " @@ -3096,21 +3127,21 @@ msgid "" "information." msgstr "" -#: ../../library/functions.rst:1795 +#: ../../library/functions.rst:1806 msgid "" "Return a new :class:`set` object, optionally with elements taken from " "*iterable*. ``set`` is a built-in class. See :class:`set` and :ref:`types-" "set` for documentation about this class." msgstr "" -#: ../../library/functions.rst:1799 +#: ../../library/functions.rst:1810 msgid "" "For other containers see the built-in :class:`frozenset`, :class:`list`, :" "class:`tuple`, and :class:`dict` classes, as well as the :mod:`collections` " "module." msgstr "" -#: ../../library/functions.rst:1806 +#: ../../library/functions.rst:1817 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 " @@ -3119,7 +3150,7 @@ msgid "" "is equivalent to ``x.foobar = 123``." msgstr "" -#: ../../library/functions.rst:1812 +#: ../../library/functions.rst:1823 msgid "" "*name* need not be a Python identifier as defined in :ref:`identifiers` " "unless the object chooses to enforce that, for example in a custom :meth:" @@ -3128,21 +3159,21 @@ msgid "" "notation, but is accessible through :func:`getattr` etc.." msgstr "" -#: ../../library/functions.rst:1820 +#: ../../library/functions.rst:1831 msgid "" "Since :ref:`private name mangling ` happens at " "compilation time, one must manually mangle a private attribute's (attributes " "with two leading underscores) name in order to set it with :func:`setattr`." msgstr "" -#: ../../library/functions.rst:1829 +#: ../../library/functions.rst:1840 msgid "" "Return a :term:`slice` object representing the set of indices specified by " "``range(start, stop, step)``. The *start* and *step* arguments default to " "``None``." msgstr "" -#: ../../library/functions.rst:1833 +#: ../../library/functions.rst:1844 msgid "" "Slice objects have read-only data attributes :attr:`!start`, :attr:`!stop`, " "and :attr:`!step` which merely return the argument values (or their " @@ -3150,48 +3181,48 @@ msgid "" "by NumPy and other third-party packages." msgstr "" -#: ../../library/functions.rst:1842 +#: ../../library/functions.rst:1853 msgid "" "Slice objects are also generated when extended indexing syntax is used. For " "example: ``a[start:stop:step]`` or ``a[start:stop, i]``. See :func:" "`itertools.islice` for an alternate version that returns an :term:`iterator`." msgstr "" -#: ../../library/functions.rst:1847 +#: ../../library/functions.rst:1858 msgid "" "Slice objects are now :term:`hashable` (provided :attr:`~slice.start`, :attr:" "`~slice.stop`, and :attr:`~slice.step` are hashable)." msgstr "" -#: ../../library/functions.rst:1853 +#: ../../library/functions.rst:1864 msgid "Return a new sorted list from the items in *iterable*." msgstr "" -#: ../../library/functions.rst:1855 +#: ../../library/functions.rst:1866 msgid "" "Has two optional arguments which must be specified as keyword arguments." msgstr "有兩個選擇性引數,只能使用關鍵字引數來指定。" -#: ../../library/functions.rst:1857 +#: ../../library/functions.rst:1868 msgid "" "*key* specifies a function of one argument that is used to extract a " "comparison key from each element in *iterable* (for example, ``key=str." "lower``). The default value is ``None`` (compare the elements directly)." msgstr "" -#: ../../library/functions.rst:1861 +#: ../../library/functions.rst:1872 msgid "" "*reverse* is a boolean value. If set to ``True``, then the list elements " "are sorted as if each comparison were reversed." msgstr "" -#: ../../library/functions.rst:1864 +#: ../../library/functions.rst:1875 msgid "" "Use :func:`functools.cmp_to_key` to convert an old-style *cmp* function to a " "*key* function." msgstr "" -#: ../../library/functions.rst:1867 +#: ../../library/functions.rst:1878 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 " @@ -3199,7 +3230,7 @@ msgid "" "example, sort by department, then by salary grade)." msgstr "" -#: ../../library/functions.rst:1872 +#: ../../library/functions.rst:1883 msgid "" "The sort algorithm uses only ``<`` comparisons between items. While " "defining an :meth:`~object.__lt__` method will suffice for sorting, :PEP:`8` " @@ -3207,26 +3238,26 @@ msgid "" "implemented. This will help avoid bugs when using the same data with other " "ordering tools such as :func:`max` that rely on a different underlying " "method. Implementing all six comparisons also helps avoid confusion for " -"mixed type comparisons which can call reflected the :meth:`~object.__gt__` " +"mixed type comparisons which can call the reflected :meth:`~object.__gt__` " "method." msgstr "" -#: ../../library/functions.rst:1881 +#: ../../library/functions.rst:1892 msgid "" "For sorting examples and a brief sorting tutorial, see :ref:`sortinghowto`." msgstr "" -#: ../../library/functions.rst:1885 +#: ../../library/functions.rst:1896 msgid "Transform a method into a static method." msgstr "" -#: ../../library/functions.rst:1887 +#: ../../library/functions.rst:1898 msgid "" "A static method does not receive an implicit first argument. To declare a " "static method, use this idiom::" msgstr "" -#: ../../library/functions.rst:1890 +#: ../../library/functions.rst:1901 msgid "" "class C:\n" " @staticmethod\n" @@ -3236,7 +3267,7 @@ msgstr "" " @staticmethod\n" " def f(arg1, arg2, argN): ..." -#: ../../library/functions.rst:1894 +#: ../../library/functions.rst:1905 msgid "" "The ``@staticmethod`` form is a function :term:`decorator` -- see :ref:" "`function` for details." @@ -3244,7 +3275,7 @@ msgstr "" "``@staticmethod`` 語法是一個函式 :term:`decorator` - 參見 :ref:`function` 中" "的詳細介紹。" -#: ../../library/functions.rst:1897 +#: ../../library/functions.rst:1908 msgid "" "A static method can be called either on the class (such as ``C.f()``) or on " "an instance (such as ``C().f()``). Moreover, the static method :term:" @@ -3252,14 +3283,14 @@ msgid "" "(such as ``f()``)." msgstr "" -#: ../../library/functions.rst:1902 +#: ../../library/functions.rst:1913 msgid "" "Static methods in Python are similar to those found in Java or C++. Also, " "see :func:`classmethod` for a variant that is useful for creating alternate " "class constructors." msgstr "" -#: ../../library/functions.rst:1906 +#: ../../library/functions.rst:1917 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 " @@ -3268,7 +3299,7 @@ msgid "" "cases, use this idiom::" msgstr "" -#: ../../library/functions.rst:1912 +#: ../../library/functions.rst:1923 msgid "" "def regular_function():\n" " ...\n" @@ -3282,11 +3313,11 @@ msgstr "" "class C:\n" " method = staticmethod(regular_function)" -#: ../../library/functions.rst:1918 +#: ../../library/functions.rst:1929 msgid "For more information on static methods, see :ref:`types`." msgstr "關於 static method 的更多資訊,請參考 :ref:`types`。" -#: ../../library/functions.rst:1920 +#: ../../library/functions.rst:1931 msgid "" "Static methods now inherit the method attributes (:attr:`~function." "__module__`, :attr:`~function.__name__`, :attr:`~function.__qualname__`, :" @@ -3298,25 +3329,25 @@ msgstr "" "__doc__` 和 :attr:`~function.__annotations__`),並擁有一個新的 " "``__wrapped__`` 屬性,且為如一般函式的可呼叫物件。" -#: ../../library/functions.rst:1938 +#: ../../library/functions.rst:1949 msgid "" "Return a :class:`str` version of *object*. See :func:`str` for details." msgstr "" -#: ../../library/functions.rst:1940 +#: ../../library/functions.rst:1951 msgid "" "``str`` is the built-in string :term:`class`. For general information about " "strings, see :ref:`textseq`." msgstr "" -#: ../../library/functions.rst:1946 +#: ../../library/functions.rst:1957 msgid "" "Sums *start* and the items of an *iterable* from left to right and returns " "the total. The *iterable*'s items are normally numbers, and the start value " "is not allowed to be a string." msgstr "" -#: ../../library/functions.rst:1950 +#: ../../library/functions.rst:1961 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 ``''." @@ -3325,37 +3356,43 @@ msgid "" "using :func:`itertools.chain`." msgstr "" -#: ../../library/functions.rst:1956 +#: ../../library/functions.rst:1967 msgid "The *start* parameter can be specified as a keyword argument." msgstr "*start* 參數可被指定為關鍵字引數。" -#: ../../library/functions.rst:1959 +#: ../../library/functions.rst:1970 msgid "" "Summation of floats switched to an algorithm that gives higher accuracy and " "better commutativity on most builds." msgstr "" -#: ../../library/functions.rst:1966 +#: ../../library/functions.rst:1973 +msgid "" +"Added specialization for summation of complexes, using same algorithm as for " +"summation of floats." +msgstr "" + +#: ../../library/functions.rst:1981 msgid "" "Return a proxy object that delegates method calls to a parent or sibling " "class of *type*. This is useful for accessing inherited methods that have " "been overridden in a class." msgstr "" -#: ../../library/functions.rst:1970 +#: ../../library/functions.rst:1985 msgid "" "The *object_or_type* determines the :term:`method resolution order` to be " "searched. The search starts from the class right after the *type*." msgstr "" -#: ../../library/functions.rst:1974 +#: ../../library/functions.rst:1989 msgid "" "For example, if :attr:`~type.__mro__` of *object_or_type* is ``D -> B -> C -" "> A -> object`` and the value of *type* is ``B``, then :func:`super` " "searches ``C -> A -> object``." msgstr "" -#: ../../library/functions.rst:1978 +#: ../../library/functions.rst:1993 msgid "" "The :attr:`~type.__mro__` attribute of the class corresponding to " "*object_or_type* lists the method resolution search order used by both :func:" @@ -3363,7 +3400,7 @@ msgid "" "whenever the inheritance hierarchy is updated." msgstr "" -#: ../../library/functions.rst:1983 +#: ../../library/functions.rst:1998 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. " @@ -3371,7 +3408,7 @@ msgid "" "(this is useful for classmethods)." msgstr "" -#: ../../library/functions.rst:1988 +#: ../../library/functions.rst:2003 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 " @@ -3381,7 +3418,7 @@ msgid "" "including generator expressions, which implicitly create nested functions.)" msgstr "" -#: ../../library/functions.rst:1995 +#: ../../library/functions.rst:2010 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 " @@ -3389,7 +3426,7 @@ msgid "" "closely parallels the use of *super* in other programming languages." msgstr "" -#: ../../library/functions.rst:2000 +#: ../../library/functions.rst:2015 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 " @@ -3402,11 +3439,11 @@ msgid "" "classes that are unknown prior to runtime)." msgstr "" -#: ../../library/functions.rst:2010 +#: ../../library/functions.rst:2025 msgid "For both use cases, a typical superclass call looks like this::" msgstr "" -#: ../../library/functions.rst:2012 +#: ../../library/functions.rst:2027 msgid "" "class C(B):\n" " def method(self, arg):\n" @@ -3414,14 +3451,14 @@ msgid "" " # super(C, self).method(arg)" msgstr "" -#: ../../library/functions.rst:2017 +#: ../../library/functions.rst:2032 msgid "" "In addition to method lookups, :func:`super` also works for attribute " "lookups. One possible use case for this is calling :term:`descriptors " "` in a parent or sibling class." msgstr "" -#: ../../library/functions.rst:2021 +#: ../../library/functions.rst:2036 msgid "" "Note that :func:`super` is implemented as part of the binding process for " "explicit dotted attribute lookups such as ``super().__getitem__(name)``. It " @@ -3431,7 +3468,7 @@ msgid "" "using statements or operators such as ``super()[name]``." msgstr "" -#: ../../library/functions.rst:2029 +#: ../../library/functions.rst:2044 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 " @@ -3441,33 +3478,39 @@ msgid "" "accessing the current instance for ordinary methods." msgstr "" -#: ../../library/functions.rst:2036 +#: ../../library/functions.rst:2051 msgid "" "For practical suggestions on how to design cooperative classes using :func:" "`super`, see `guide to using super() `_." msgstr "" -#: ../../library/functions.rst:2045 +#: ../../library/functions.rst:2055 +msgid "" +":class:`super` objects are now :mod:`pickleable ` and :mod:" +"`copyable `." +msgstr "" + +#: ../../library/functions.rst:2064 msgid "" "Rather than being a function, :class:`tuple` is actually an immutable " "sequence type, as documented in :ref:`typesseq-tuple` and :ref:`typesseq`." msgstr "" -#: ../../library/functions.rst:2054 +#: ../../library/functions.rst:2073 msgid "" "With one argument, return the type of an *object*. The return value is a " "type object and generally the same object as returned by :attr:`object." "__class__`." msgstr "" -#: ../../library/functions.rst:2058 +#: ../../library/functions.rst:2077 msgid "" "The :func:`isinstance` built-in function is recommended for testing the type " "of an object, because it takes subclasses into account." msgstr "" -#: ../../library/functions.rst:2061 +#: ../../library/functions.rst:2080 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 " @@ -3480,21 +3523,21 @@ msgid "" "type` objects:" msgstr "" -#: ../../library/functions.rst:2076 +#: ../../library/functions.rst:2095 msgid "See also:" msgstr "" -#: ../../library/functions.rst:2078 +#: ../../library/functions.rst:2097 msgid "" ":ref:`Documentation on attributes and methods on classes `." msgstr "" -#: ../../library/functions.rst:2079 +#: ../../library/functions.rst:2098 msgid ":ref:`bltin-type-objects`" msgstr ":ref:`bltin-type-objects`" -#: ../../library/functions.rst:2081 +#: ../../library/functions.rst:2100 msgid "" "Keyword arguments provided to the three argument form are passed to the " "appropriate metaclass machinery (usually :meth:`~object.__init_subclass__`) " @@ -3502,23 +3545,23 @@ msgid "" "would." msgstr "" -#: ../../library/functions.rst:2086 +#: ../../library/functions.rst:2105 msgid "See also :ref:`class-customization`." msgstr "另請參閱 :ref:`class-customization`。" -#: ../../library/functions.rst:2088 +#: ../../library/functions.rst:2107 msgid "" "Subclasses of :class:`!type` which don't override ``type.__new__`` may no " "longer use the one-argument form to get the type of an object." msgstr "" -#: ../../library/functions.rst:2095 +#: ../../library/functions.rst:2114 msgid "" "Return the :attr:`~object.__dict__` attribute for a module, class, instance, " "or any other object with a :attr:`!__dict__` attribute." msgstr "" -#: ../../library/functions.rst:2098 +#: ../../library/functions.rst:2117 msgid "" "Objects such as modules and instances have an updateable :attr:`~object." "__dict__` attribute; however, other objects may have write restrictions on " @@ -3526,34 +3569,34 @@ msgid "" "MappingProxyType` to prevent direct dictionary updates)." msgstr "" -#: ../../library/functions.rst:2103 +#: ../../library/functions.rst:2122 msgid "Without an argument, :func:`vars` acts like :func:`locals`." msgstr "" -#: ../../library/functions.rst:2105 +#: ../../library/functions.rst:2124 msgid "" "A :exc:`TypeError` exception is raised if an object is specified but it " "doesn't have a :attr:`~object.__dict__` attribute (for example, if its class " "defines the :attr:`~object.__slots__` attribute)." msgstr "" -#: ../../library/functions.rst:2111 +#: ../../library/functions.rst:2130 msgid "" "The result of calling this function without an argument has been updated as " "described for the :func:`locals` builtin." msgstr "" -#: ../../library/functions.rst:2117 +#: ../../library/functions.rst:2136 msgid "" "Iterate over several iterables in parallel, producing tuples with an item " "from each one." msgstr "" -#: ../../library/functions.rst:2120 +#: ../../library/functions.rst:2139 msgid "Example::" msgstr "例如: ::" -#: ../../library/functions.rst:2122 +#: ../../library/functions.rst:2141 msgid "" ">>> for item in zip([1, 2, 3], ['sugar', 'spice', 'everything nice']):\n" "... print(item)\n" @@ -3569,27 +3612,27 @@ msgstr "" "(2, 'spice')\n" "(3, 'everything nice')" -#: ../../library/functions.rst:2129 +#: ../../library/functions.rst:2148 msgid "" "More formally: :func:`zip` returns an iterator of tuples, where the *i*-th " "tuple contains the *i*-th element from each of the argument iterables." msgstr "" -#: ../../library/functions.rst:2132 +#: ../../library/functions.rst:2151 msgid "" "Another way to think of :func:`zip` is that it turns rows into columns, and " "columns into rows. This is similar to `transposing a matrix `_." msgstr "" -#: ../../library/functions.rst:2136 +#: ../../library/functions.rst:2155 msgid "" ":func:`zip` is lazy: The elements won't be processed until the iterable is " "iterated on, e.g. by a :keyword:`!for` loop or by wrapping in a :class:" "`list`." msgstr "" -#: ../../library/functions.rst:2140 +#: ../../library/functions.rst:2159 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 " @@ -3597,14 +3640,14 @@ msgid "" "approaches to dealing with this issue:" msgstr "" -#: ../../library/functions.rst:2145 +#: ../../library/functions.rst:2164 msgid "" "By default, :func:`zip` stops when the shortest iterable is exhausted. It " "will ignore the remaining items in the longer iterables, cutting off the " "result to the length of the shortest iterable::" msgstr "" -#: ../../library/functions.rst:2149 +#: ../../library/functions.rst:2168 msgid "" ">>> list(zip(range(3), ['fee', 'fi', 'fo', 'fum']))\n" "[(0, 'fee'), (1, 'fi'), (2, 'fo')]" @@ -3612,14 +3655,14 @@ msgstr "" ">>> list(zip(range(3), ['fee', 'fi', 'fo', 'fum']))\n" "[(0, 'fee'), (1, 'fi'), (2, 'fo')]" -#: ../../library/functions.rst:2152 +#: ../../library/functions.rst:2171 msgid "" ":func:`zip` is often used in cases where the iterables are assumed to be of " "equal length. In such cases, it's recommended to use the ``strict=True`` " "option. Its output is the same as regular :func:`zip`::" msgstr "" -#: ../../library/functions.rst:2156 +#: ../../library/functions.rst:2175 msgid "" ">>> list(zip(('a', 'b', 'c'), (1, 2, 3), strict=True))\n" "[('a', 1), ('b', 2), ('c', 3)]" @@ -3627,37 +3670,37 @@ msgstr "" ">>> list(zip(('a', 'b', 'c'), (1, 2, 3), strict=True))\n" "[('a', 1), ('b', 2), ('c', 3)]" -#: ../../library/functions.rst:2159 +#: ../../library/functions.rst:2178 msgid "" "Unlike the default behavior, it raises a :exc:`ValueError` if one iterable " "is exhausted before the others:" msgstr "" -#: ../../library/functions.rst:2177 +#: ../../library/functions.rst:2196 msgid "" "Without the ``strict=True`` argument, any bug that results in iterables of " "different lengths will be silenced, possibly manifesting as a hard-to-find " "bug in another part of the program." msgstr "" -#: ../../library/functions.rst:2181 +#: ../../library/functions.rst:2200 msgid "" "Shorter iterables can be padded with a constant value to make all the " "iterables have the same length. This is done by :func:`itertools." "zip_longest`." msgstr "" -#: ../../library/functions.rst:2185 +#: ../../library/functions.rst:2204 msgid "" "Edge cases: With a single iterable argument, :func:`zip` returns an iterator " "of 1-tuples. With no arguments, it returns an empty iterator." msgstr "" -#: ../../library/functions.rst:2188 +#: ../../library/functions.rst:2207 msgid "Tips and tricks:" msgstr "" -#: ../../library/functions.rst:2190 +#: ../../library/functions.rst:2209 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 " @@ -3666,13 +3709,13 @@ msgid "" "iterator. This has the effect of dividing the input into n-length chunks." msgstr "" -#: ../../library/functions.rst:2196 +#: ../../library/functions.rst:2215 msgid "" ":func:`zip` in conjunction with the ``*`` operator can be used to unzip a " "list::" msgstr "" -#: ../../library/functions.rst:2199 +#: ../../library/functions.rst:2218 msgid "" ">>> x = [1, 2, 3]\n" ">>> y = [4, 5, 6]\n" @@ -3690,17 +3733,17 @@ msgstr "" ">>> x == list(x2) and y == list(y2)\n" "True" -#: ../../library/functions.rst:2207 +#: ../../library/functions.rst:2226 msgid "Added the ``strict`` argument." msgstr "增加了 ``strict`` 引數。" -#: ../../library/functions.rst:2219 +#: ../../library/functions.rst:2238 msgid "" "This is an advanced function that is not needed in everyday Python " "programming, unlike :func:`importlib.import_module`." msgstr "" -#: ../../library/functions.rst:2222 +#: ../../library/functions.rst:2241 msgid "" "This function is invoked by the :keyword:`import` statement. It can be " "replaced (by importing the :mod:`builtins` module and assigning to " @@ -3712,7 +3755,7 @@ msgid "" "discouraged in favor of :func:`importlib.import_module`." msgstr "" -#: ../../library/functions.rst:2231 +#: ../../library/functions.rst:2250 msgid "" "The function imports the module *name*, potentially using the given " "*globals* and *locals* to determine how to interpret the name in a package " @@ -3722,7 +3765,7 @@ msgid "" "determine the package context of the :keyword:`import` statement." msgstr "" -#: ../../library/functions.rst:2238 +#: ../../library/functions.rst:2257 msgid "" "*level* specifies whether to use absolute or relative imports. ``0`` (the " "default) means only perform absolute imports. Positive values for *level* " @@ -3731,7 +3774,7 @@ msgid "" "details)." msgstr "" -#: ../../library/functions.rst:2244 +#: ../../library/functions.rst:2263 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 " @@ -3739,37 +3782,37 @@ msgid "" "given, the module named by *name* is returned." msgstr "" -#: ../../library/functions.rst:2249 +#: ../../library/functions.rst:2268 msgid "" "For example, the statement ``import spam`` results in bytecode resembling " "the following code::" msgstr "" -#: ../../library/functions.rst:2252 +#: ../../library/functions.rst:2271 msgid "spam = __import__('spam', globals(), locals(), [], 0)" msgstr "spam = __import__('spam', globals(), locals(), [], 0)" -#: ../../library/functions.rst:2254 +#: ../../library/functions.rst:2273 msgid "The statement ``import spam.ham`` results in this call::" msgstr "" -#: ../../library/functions.rst:2256 +#: ../../library/functions.rst:2275 msgid "spam = __import__('spam.ham', globals(), locals(), [], 0)" msgstr "spam = __import__('spam.ham', globals(), locals(), [], 0)" -#: ../../library/functions.rst:2258 +#: ../../library/functions.rst:2277 msgid "" "Note how :func:`__import__` returns the toplevel module here because this is " "the object that is bound to a name by the :keyword:`import` statement." msgstr "" -#: ../../library/functions.rst:2261 +#: ../../library/functions.rst:2280 msgid "" "On the other hand, the statement ``from spam.ham import eggs, sausage as " "saus`` results in ::" msgstr "" -#: ../../library/functions.rst:2264 +#: ../../library/functions.rst:2283 msgid "" "_temp = __import__('spam.ham', globals(), locals(), ['eggs', 'sausage'], 0)\n" "eggs = _temp.eggs\n" @@ -3779,36 +3822,36 @@ msgstr "" "eggs = _temp.eggs\n" "saus = _temp.sausage" -#: ../../library/functions.rst:2268 +#: ../../library/functions.rst:2287 msgid "" "Here, the ``spam.ham`` module is returned from :func:`__import__`. From " "this object, the names to import are retrieved and assigned to their " "respective names." msgstr "" -#: ../../library/functions.rst:2272 +#: ../../library/functions.rst:2291 msgid "" "If you simply want to import a module (potentially within a package) by " "name, use :func:`importlib.import_module`." msgstr "" -#: ../../library/functions.rst:2275 +#: ../../library/functions.rst:2294 msgid "" "Negative values for *level* are no longer supported (which also changes the " "default value to 0)." msgstr "" -#: ../../library/functions.rst:2279 +#: ../../library/functions.rst:2298 msgid "" "When the command line options :option:`-E` or :option:`-I` are being used, " "the environment variable :envvar:`PYTHONCASEOK` is now ignored." msgstr "" -#: ../../library/functions.rst:2284 +#: ../../library/functions.rst:2303 msgid "Footnotes" msgstr "註解" -#: ../../library/functions.rst:2285 +#: ../../library/functions.rst:2304 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 " @@ -3821,106 +3864,106 @@ msgstr "" msgid "Boolean" msgstr "Boolean(布林值)" -#: ../../library/functions.rst:154 ../../library/functions.rst:2052 +#: ../../library/functions.rst:154 ../../library/functions.rst:2071 msgid "type" msgstr "type(型別)" -#: ../../library/functions.rst:646 +#: ../../library/functions.rst:652 msgid "built-in function" msgstr "built-in function(內建函式)" -#: ../../library/functions.rst:646 +#: ../../library/functions.rst:652 msgid "exec" msgstr "exec" -#: ../../library/functions.rst:744 +#: ../../library/functions.rst:750 msgid "NaN" msgstr "NaN" -#: ../../library/functions.rst:744 +#: ../../library/functions.rst:750 msgid "Infinity" msgstr "Infinity(無窮)" -#: ../../library/functions.rst:812 +#: ../../library/functions.rst:820 msgid "__format__" msgstr "__format__" -#: ../../library/functions.rst:812 ../../library/functions.rst:1928 +#: ../../library/functions.rst:820 ../../library/functions.rst:1939 msgid "string" msgstr "string(字串)" -#: ../../library/functions.rst:812 +#: ../../library/functions.rst:820 msgid "format() (built-in function)" msgstr "format()(內建函式)" -#: ../../library/functions.rst:1323 +#: ../../library/functions.rst:1334 msgid "file object" msgstr "file object(檔案物件)" -#: ../../library/functions.rst:1323 ../../library/functions.rst:1444 +#: ../../library/functions.rst:1334 ../../library/functions.rst:1455 msgid "open() built-in function" msgstr "open() 內建函式" -#: ../../library/functions.rst:1351 +#: ../../library/functions.rst:1362 msgid "file" msgstr "file(檔案)" -#: ../../library/functions.rst:1351 +#: ../../library/functions.rst:1362 msgid "modes" msgstr "modes(模式)" -#: ../../library/functions.rst:1444 +#: ../../library/functions.rst:1455 msgid "universal newlines" msgstr "universal newlines" -#: ../../library/functions.rst:1505 +#: ../../library/functions.rst:1516 msgid "line-buffered I/O" msgstr "line-buffered I/O(行緩衝 I/O)" -#: ../../library/functions.rst:1505 +#: ../../library/functions.rst:1516 msgid "unbuffered I/O" msgstr "unbuffered I/O(非緩衝 I/O)" -#: ../../library/functions.rst:1505 +#: ../../library/functions.rst:1516 msgid "buffer size, I/O" msgstr "buffer size, I/O(緩衝區大小、I/O)" -#: ../../library/functions.rst:1505 +#: ../../library/functions.rst:1516 msgid "I/O control" msgstr "I/O control(I/O 控制)" -#: ../../library/functions.rst:1505 +#: ../../library/functions.rst:1516 msgid "buffering" msgstr "buffering(緩衝)" -#: ../../library/functions.rst:1505 +#: ../../library/functions.rst:1516 msgid "text mode" msgstr "text mode(文字模式)" -#: ../../library/functions.rst:1505 ../../library/functions.rst:2213 +#: ../../library/functions.rst:1516 ../../library/functions.rst:2232 msgid "module" msgstr "module(模組)" -#: ../../library/functions.rst:1505 +#: ../../library/functions.rst:1516 msgid "sys" msgstr "sys" -#: ../../library/functions.rst:1928 +#: ../../library/functions.rst:1939 msgid "str() (built-in function)" msgstr "str() (內建函式)" -#: ../../library/functions.rst:2052 +#: ../../library/functions.rst:2071 msgid "object" msgstr "object(物件)" -#: ../../library/functions.rst:2213 +#: ../../library/functions.rst:2232 msgid "statement" msgstr "statement(陳述式)" -#: ../../library/functions.rst:2213 +#: ../../library/functions.rst:2232 msgid "import" msgstr "import(引入)" -#: ../../library/functions.rst:2213 +#: ../../library/functions.rst:2232 msgid "builtins" msgstr "builtins(內建)" diff --git a/library/functools.po b/library/functools.po index 69858cd1de4..60b55ae508a 100644 --- a/library/functools.po +++ b/library/functools.po @@ -1,13 +1,13 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Matt Wang , 2024 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-07-12 00:16+0000\n" +"POT-Creation-Date: 2025-11-19 00:14+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-" @@ -71,13 +71,11 @@ msgid "" "def factorial(n):\n" " return n * factorial(n-1) if n else 1\n" "\n" -">>> factorial(10) # no previously cached result, makes 11 recursive " -"calls\n" +">>> factorial(10) # no previously cached result, makes 11 recursive calls\n" "3628800\n" -">>> factorial(5) # just looks up cached value result\n" +">>> factorial(5) # no new calls, just returns the cached result\n" "120\n" -">>> factorial(12) # makes two new recursive calls, the other 10 are " -"cached\n" +">>> factorial(12) # two new recursive calls, factorial(10) is cached\n" "479001600" msgstr "" "@cache\n" @@ -86,9 +84,9 @@ msgstr "" "\n" ">>> factorial(10) # 沒有先前的快取結果,會進行 11 次遞迴呼叫\n" "3628800\n" -">>> factorial(5) # 只查詢快取的結果\n" +">>> factorial(5) # 沒有新的呼叫,直接回傳被快取起來的結果\n" "120\n" -">>> factorial(12) # 進行兩次新的遞迴呼叫,其他 10 次是快取的\n" +">>> factorial(12) # 兩次新的遞迴呼叫,factorial(10) 有被快取起來\n" "479001600" #: ../../library/functools.rst:52 ../../library/functools.rst:158 @@ -121,7 +119,7 @@ msgstr "" "屬性外實質上幾乎是不可變 (immutable) 的實例,針對其所需要繁重計算會很有用。" #: ../../library/functools.rst:70 ../../library/functools.rst:142 -#: ../../library/functools.rst:389 +#: ../../library/functools.rst:438 msgid "Example::" msgstr "範例: ::" @@ -369,8 +367,8 @@ msgid "" "function that returns a :term:`named tuple` showing *hits*, *misses*, " "*maxsize* and *currsize*." msgstr "" -"為了輔助測量快取的有效性並調整 *maxsize* 參數,包裝的函式使用了一個 :func:" -"`!cache_info` 函式來做檢測,該函式會回傳一個\\ :term:`附名元組 `\\ 來顯示 *hits*、*misses*、*maxsize* 和 *currsize*。" #: ../../library/functools.rst:213 @@ -533,8 +531,9 @@ msgid "" "__le__`, :meth:`~object.__gt__`, or :meth:`~object.__ge__`. In addition, the " "class should supply an :meth:`~object.__eq__` method." msgstr "" -"類別必須定義 :meth:`~object.__lt__`、:meth:`~object.__le__`、:meth:`~object.__gt__` " -"或 :meth:`~object.__ge__` 其中之一。此外,該類別應該提供 :meth:`~object.__eq__` 方法。" +"類別必須定義 :meth:`~object.__lt__`、:meth:`~object.__le__`、:meth:`~object." +"__gt__` 或 :meth:`~object.__ge__` 其中之一。此外,該類別應該提供 :meth:" +"`~object.__eq__` 方法。" #: ../../library/functools.rst:299 msgid "" @@ -602,6 +601,12 @@ msgstr "現在支援從底層對於未識別型別的比較函式回傳 ``NotImp #: ../../library/functools.rst:339 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 +msgid "" "Return a new :ref:`partial object` which when called will " "behave like *func* called with the positional arguments *args* and keyword " "arguments *keywords*. If more arguments are supplied to the call, they are " @@ -613,39 +618,125 @@ msgstr "" "引數,它們將被附加到 *args*。如果提供了額外的關鍵字引數,它們會擴充並覆寫 " "*keywords*。大致相當於: ::" -#: ../../library/functools.rst:346 +#: ../../library/functools.rst:354 msgid "" "def partial(func, /, *args, **keywords):\n" -" def newfunc(*fargs, **fkeywords):\n" -" newkeywords = {**keywords, **fkeywords}\n" -" return func(*args, *fargs, **newkeywords)\n" +" def newfunc(*more_args, **more_keywords):\n" +" return func(*args, *more_args, **(keywords | more_keywords))\n" " newfunc.func = func\n" " newfunc.args = args\n" " newfunc.keywords = keywords\n" " return newfunc" msgstr "" "def partial(func, /, *args, **keywords):\n" -" def newfunc(*fargs, **fkeywords):\n" -" newkeywords = {**keywords, **fkeywords}\n" -" return func(*args, *fargs, **newkeywords)\n" +" def newfunc(*more_args, **more_keywords):\n" +" return func(*args, *more_args, **(keywords | more_keywords))\n" " newfunc.func = func\n" " newfunc.args = args\n" " newfunc.keywords = keywords\n" " return newfunc" -#: ../../library/functools.rst:355 +#: ../../library/functools.rst:362 msgid "" -"The :func:`partial` is used for partial function application which " +"The :func:`!partial` function is used for partial function application which " "\"freezes\" some portion of a function's arguments and/or keywords resulting " "in a new object with a simplified signature. For example, :func:`partial` " "can be used to create a callable that behaves like the :func:`int` function " -"where the *base* argument defaults to two:" +"where the *base* argument defaults to ``2``:" msgstr "" -":func:`partial` 用於部分函式應用程序,它「凍結」函式引數和/或關鍵字的某些部" +":func:`!partial` 用於部分函式應用程序,它「凍結」函式引數和/或關鍵字的某些部" "分,從而產生具有簡化簽名的新物件。例如,:func:`partial` 可用來建立可呼叫函" "式,其行為類似於 :func:`int` 函式,其中 *base* 引數預設為 2:" -#: ../../library/functools.rst:370 +#: ../../library/functools.rst:368 +msgid "" +">>> basetwo = partial(int, base=2)\n" +">>> basetwo.__doc__ = 'Convert base 2 string to an int.'\n" +">>> basetwo('10010')\n" +"18" +msgstr "" +">>> basetwo = partial(int, base=2)\n" +">>> basetwo.__doc__ = 'Convert base 2 string to an int.'\n" +">>> basetwo('10010')\n" +"18" + +#: ../../library/functools.rst:375 +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 " +"any positional argument with a call to :func:`!partial`; without :data:`!" +"Placeholder`, only the chosen number of leading positional arguments can be " +"pre-filled." +msgstr "" + +#: ../../library/functools.rst:380 +msgid "" +"If any :data:`!Placeholder` sentinels are present, all must be filled at " +"call time:" +msgstr "" + +#: ../../library/functools.rst:382 +msgid "" +">>> say_to_world = partial(print, Placeholder, Placeholder, \"world!\")\n" +">>> say_to_world('Hello', 'dear')\n" +"Hello dear world!" +msgstr "" +">>> say_to_world = partial(print, Placeholder, Placeholder, \"world!\")\n" +">>> say_to_world('Hello', 'dear')\n" +"Hello dear world!" + +#: ../../library/functools.rst:388 +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 +msgid "" +"If :func:`!partial` is applied to an existing :func:`!partial` object, :data:" +"`!Placeholder` sentinels of the input object are filled in with new " +"positional arguments. A placeholder can be retained by inserting a new :data:" +"`!Placeholder` sentinel to the place held by a previous :data:`!Placeholder`:" +msgstr "" + +#: ../../library/functools.rst:398 +msgid "" +">>> from functools import partial, Placeholder as _\n" +">>> remove = partial(str.replace, _, _, '')\n" +">>> message = 'Hello, dear dear world!'\n" +">>> remove(message, ' dear')\n" +"'Hello, world!'\n" +">>> remove_dear = partial(remove, _, ' dear')\n" +">>> remove_dear(message)\n" +"'Hello, world!'\n" +">>> remove_first_dear = partial(remove_dear, _, 1)\n" +">>> remove_first_dear(message)\n" +"'Hello, dear world!'" +msgstr "" +">>> from functools import partial, Placeholder as _\n" +">>> remove = partial(str.replace, _, _, '')\n" +">>> message = 'Hello, dear dear world!'\n" +">>> remove(message, ' dear')\n" +"'Hello, world!'\n" +">>> remove_dear = partial(remove, _, ' dear')\n" +">>> remove_dear(message)\n" +"'Hello, world!'\n" +">>> remove_first_dear = partial(remove_dear, _, 1)\n" +">>> remove_first_dear(message)\n" +"'Hello, dear world!'" + +#: ../../library/functools.rst:412 +msgid "" +":data:`!Placeholder` cannot be passed to :func:`!partial` as a keyword " +"argument." +msgstr "" + +#: ../../library/functools.rst:414 +msgid "Added support for :data:`Placeholder` in positional arguments." +msgstr "" + +#: ../../library/functools.rst:419 msgid "" "Return a new :class:`partialmethod` descriptor which behaves like :class:" "`partial` except that it is designed to be used as a method definition " @@ -654,7 +745,7 @@ msgstr "" "回傳一個新的 :class:`partialmethod` 描述器 (descriptor),其行為類似於 :class:" "`partial`,只不過它被設計為用於方法定義而不能直接呼叫。" -#: ../../library/functools.rst:374 +#: ../../library/functools.rst:423 msgid "" "*func* must be a :term:`descriptor` or a callable (objects which are both, " "like normal functions, are handled as descriptors)." @@ -662,7 +753,7 @@ msgstr "" "*func* 必須是一個 :term:`descriptor` 或可呼叫物件(兩者兼具的物件,就像普通函" "式一樣,會被當作描述器處理)。" -#: ../../library/functools.rst:377 +#: ../../library/functools.rst:426 msgid "" "When *func* is a descriptor (such as a normal Python function, :func:" "`classmethod`, :func:`staticmethod`, :func:`~abc.abstractmethod` or another " @@ -671,11 +762,11 @@ msgid "" "objects>` returned as the result." msgstr "" "當 *func* 是描述器時(例如普通的 Python 函式、:func:`classmethod`、:func:" -"`staticmethod`、:func:`~abc.abstractmethod` 或 :class:`partialmethod` 的另一個實" -"例),對 ``__get__`` 的呼叫將被委託 (delegated) 給底層描述器,且一個適當的 :" -"ref:`partial 物件 `\\ 會被作為結果回傳。" +"`staticmethod`、:func:`~abc.abstractmethod` 或 :class:`partialmethod` 的另一" +"個實例),對 ``__get__`` 的呼叫將被委託 (delegated) 給底層描述器,且一個適當" +"的 :ref:`partial 物件 `\\ 會被作為結果回傳。" -#: ../../library/functools.rst:383 +#: ../../library/functools.rst:432 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 " @@ -688,7 +779,7 @@ msgstr "" "*self* 引數將作為第一個位置引數插入,甚至會在提供給 :class:`partialmethod` 建" "構函式的 *args* 和 *keywords* 的前面。" -#: ../../library/functools.rst:391 +#: ../../library/functools.rst:440 msgid "" ">>> class Cell:\n" "... def __init__(self):\n" @@ -726,7 +817,7 @@ msgstr "" ">>> c.alive\n" "True" -#: ../../library/functools.rst:414 +#: ../../library/functools.rst:463 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 " @@ -745,15 +836,15 @@ msgstr "" "物件的項目之前,並在可疊代物件為空時作為預設值。如果未給定 *initial* 且 " "*iterable* 僅包含一個項目,則回傳第一個項目。" -#: ../../library/functools.rst:423 +#: ../../library/functools.rst:472 msgid "Roughly equivalent to::" msgstr "大致相當於: ::" -#: ../../library/functools.rst:425 +#: ../../library/functools.rst:474 msgid "" "initial_missing = object()\n" "\n" -"def reduce(function, iterable, initial=initial_missing, /):\n" +"def reduce(function, iterable, /, initial=initial_missing):\n" " it = iter(iterable)\n" " if initial is initial_missing:\n" " value = next(it)\n" @@ -765,7 +856,7 @@ msgid "" msgstr "" "initial_missing = object()\n" "\n" -"def reduce(function, iterable, initial=initial_missing, /):\n" +"def reduce(function, iterable, /, initial=initial_missing):\n" " it = iter(iterable)\n" " if initial is initial_missing:\n" " value = next(it)\n" @@ -775,7 +866,7 @@ msgstr "" " value = function(value, element)\n" " return value" -#: ../../library/functools.rst:437 +#: ../../library/functools.rst:486 msgid "" "See :func:`itertools.accumulate` for an iterator that yields all " "intermediate values." @@ -783,7 +874,11 @@ msgstr "" "請參閱 :func:`itertools.accumulate` 以了解產生 (yield) 所有中間值 " "(intermediate value) 的疊代器。" -#: ../../library/functools.rst:442 +#: ../../library/functools.rst:489 +msgid "*initial* is now supported as a keyword argument." +msgstr "" + +#: ../../library/functools.rst:494 msgid "" "Transform a function into a :term:`single-dispatch ` :term:" "`generic function`." @@ -791,7 +886,7 @@ msgstr "" "將函式轉換為\\ :term:`單一調度 `\\ :term:`泛型函式 `。" -#: ../../library/functools.rst:445 +#: ../../library/functools.rst:497 msgid "" "To define a generic function, decorate it with the ``@singledispatch`` " "decorator. When defining a function using ``@singledispatch``, note that the " @@ -801,7 +896,7 @@ msgstr "" "``@singledispatch`` 定義函式時,分派調度 (dispatch) 是發生在第一個引數的型別" "上: ::" -#: ../../library/functools.rst:449 +#: ../../library/functools.rst:501 msgid "" ">>> from functools import singledispatch\n" ">>> @singledispatch\n" @@ -817,7 +912,7 @@ msgstr "" "... print(\"Let me just say,\", end=\" \")\n" "... print(arg)" -#: ../../library/functools.rst:459 +#: ../../library/functools.rst:511 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 " @@ -827,7 +922,7 @@ msgstr "" "若要為函式新增過載實作,請使用泛型函式的 :func:`!register` 屬性,該屬性可用作" "裝飾器。對於以型別來註釋的函式,裝飾器將自動推斷第一個引數的型別: ::" -#: ../../library/functools.rst:464 +#: ../../library/functools.rst:516 msgid "" ">>> @fun.register\n" "... def _(arg: int, verbose=False):\n" @@ -855,11 +950,11 @@ msgstr "" "... for i, elem in enumerate(arg):\n" "... print(i, elem)" -#: ../../library/functools.rst:477 -msgid ":data:`types.UnionType` and :data:`typing.Union` can also be used::" -msgstr "也可以使用 :data:`types.UnionType` 和 :data:`typing.Union`: ::" +#: ../../library/functools.rst:529 +msgid ":class:`typing.Union` can also be used::" +msgstr "也可以使用 :data:`typing.Union`: ::" -#: ../../library/functools.rst:479 +#: ../../library/functools.rst:531 msgid "" ">>> @fun.register\n" "... def _(arg: int | float, verbose=False):\n" @@ -891,14 +986,14 @@ msgstr "" "... print(i, elem)\n" "..." -#: ../../library/functools.rst:494 +#: ../../library/functools.rst:546 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:497 +#: ../../library/functools.rst:549 msgid "" ">>> @fun.register(complex)\n" "... def _(arg, verbose=False):\n" @@ -914,7 +1009,7 @@ msgstr "" "... print(arg.real, arg.imag)\n" "..." -#: ../../library/functools.rst:504 +#: ../../library/functools.rst:556 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 " @@ -922,7 +1017,7 @@ msgid "" "going into the function definition::" msgstr "" -#: ../../library/functools.rst:509 +#: ../../library/functools.rst:561 msgid "" ">>> @fun.register(list)\n" "... def _(arg: list[int], verbose=False):\n" @@ -938,7 +1033,7 @@ msgstr "" "... for i, elem in enumerate(arg):\n" "... print(i, elem)" -#: ../../library/functools.rst:518 +#: ../../library/functools.rst:570 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 " @@ -946,16 +1041,16 @@ msgid "" "example is for static type checkers only and has no runtime impact." msgstr "" -#: ../../library/functools.rst:524 +#: ../../library/functools.rst:576 msgid "" "To enable registering :term:`lambdas` and pre-existing functions, " "the :func:`~singledispatch.register` attribute can also be used in a " "functional form::" msgstr "" -"若要啟用註冊 :term:`lambdas` 和預先存在的函式,:func:`~singledispatch.register` " -"屬性也能以函式形式使用: ::" +"若要啟用註冊 :term:`lambdas` 和預先存在的函式,:func:" +"`~singledispatch.register` 屬性也能以函式形式使用: ::" -#: ../../library/functools.rst:527 +#: ../../library/functools.rst:579 msgid "" ">>> def nothing(arg, verbose=False):\n" "... print(\"Nothing.\")\n" @@ -967,16 +1062,17 @@ msgstr "" "...\n" ">>> fun.register(type(None), nothing)" -#: ../../library/functools.rst:532 +#: ../../library/functools.rst:584 msgid "" "The :func:`~singledispatch.register` attribute returns the undecorated " "function. This enables decorator stacking, :mod:`pickling`, and the " "creation of unit tests for each variant independently::" msgstr "" -":func:`~singledispatch.register` 屬性回傳未加裝飾器的函式。這讓使得裝飾器堆疊 (decorator " -"stacking)、:mod:`pickling` 以及為每個變體獨立建立單元測試成為可能:" +":func:`~singledispatch.register` 屬性回傳未加裝飾器的函式。這讓使得裝飾器堆" +"疊 (decorator stacking)、:mod:`pickling` 以及為每個變體獨立建立單元測" +"試成為可能:" -#: ../../library/functools.rst:536 +#: ../../library/functools.rst:588 msgid "" ">>> @fun.register(float)\n" "... @fun.register(Decimal)\n" @@ -998,13 +1094,13 @@ msgstr "" ">>> fun_num is fun\n" "False" -#: ../../library/functools.rst:546 +#: ../../library/functools.rst:598 msgid "" "When called, the generic function dispatches on the type of the first " "argument::" msgstr "呼叫時,泛型函式會分派第一個引數的型別: ::" -#: ../../library/functools.rst:549 +#: ../../library/functools.rst:601 msgid "" ">>> fun(\"Hello, world.\")\n" "Hello, world.\n" @@ -1040,7 +1136,7 @@ msgstr "" ">>> fun(1.23)\n" "0.615" -#: ../../library/functools.rst:566 +#: ../../library/functools.rst:618 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 " @@ -1052,7 +1148,7 @@ msgstr "" "尋找更通用的實作。用 ``@singledispatch`` 裝飾的原始函式是為基底 :class:" "`object` 型別註冊的,這意味著如果沒有找到更好的實作就會使用它。" -#: ../../library/functools.rst:572 +#: ../../library/functools.rst:624 msgid "" "If an implementation is registered to an :term:`abstract base class`, " "virtual subclasses of the base class will be dispatched to that " @@ -1061,7 +1157,7 @@ msgstr "" "如果一個實作有被註冊到一個\\ :term:`抽象基底類別 `,則基" "底類別的虛擬子類別將被分派到該實作: ::" -#: ../../library/functools.rst:576 +#: ../../library/functools.rst:628 msgid "" ">>> from collections.abc import Mapping\n" ">>> @fun.register\n" @@ -1085,14 +1181,14 @@ msgstr "" ">>> fun({\"a\": \"b\"})\n" "a => b" -#: ../../library/functools.rst:587 +#: ../../library/functools.rst:639 msgid "" "To check which implementation the generic function will choose for a given " "type, use the ``dispatch()`` attribute::" msgstr "" "若要檢查泛型函式將為給定型別選擇哪種實作,請使用 ``dispatch()`` 屬性: ::" -#: ../../library/functools.rst:590 +#: ../../library/functools.rst:642 msgid "" ">>> fun.dispatch(float)\n" "\n" @@ -1100,13 +1196,13 @@ msgid "" "" msgstr "" -#: ../../library/functools.rst:595 +#: ../../library/functools.rst:647 msgid "" "To access all registered implementations, use the read-only ``registry`` " "attribute::" msgstr "若要存取所有已註冊的實作,請使用唯讀 ``registry`` 屬性: ::" -#: ../../library/functools.rst:598 +#: ../../library/functools.rst:650 msgid "" ">>> fun.registry.keys()\n" "dict_keys([, , ,\n" @@ -1126,21 +1222,21 @@ msgstr "" ">>> fun.registry[object]\n" "" -#: ../../library/functools.rst:609 +#: ../../library/functools.rst:661 msgid "" "The :func:`~singledispatch.register` attribute now supports using type " "annotations." msgstr ":func:`~singledispatch.register` 屬性現在支援使用型別註釋。" -#: ../../library/functools.rst:612 +#: ../../library/functools.rst:664 msgid "" -"The :func:`~singledispatch.register` attribute now supports :data:`types." -"UnionType` and :data:`typing.Union` as type annotations." +"The :func:`~singledispatch.register` attribute now supports :class:`typing." +"Union` as a type annotation." msgstr "" -":func:`~singledispatch.register` 屬性現在支援以 :data:`types.UnionType` 和 :data:`typing." -"Union` 作為型別註釋。" +":func:`~singledispatch.register` 屬性現在支援使用 :class:`typing.Union` 型別" +"註釋。" -#: ../../library/functools.rst:619 +#: ../../library/functools.rst:671 msgid "" "Transform a method into a :term:`single-dispatch ` :term:" "`generic function`." @@ -1148,18 +1244,18 @@ msgstr "" "將方法轉換為\\ :term:`單一調度 `\\ :term:`泛型函式 `。" -#: ../../library/functools.rst:622 +#: ../../library/functools.rst:674 msgid "" "To define a generic method, decorate it with the ``@singledispatchmethod`` " -"decorator. When defining a function using ``@singledispatchmethod``, note " -"that the dispatch happens on the type of the first non-*self* or non-*cls* " +"decorator. When defining a method using ``@singledispatchmethod``, note that " +"the dispatch happens on the type of the first non-*self* or non-*cls* " "argument::" msgstr "" "若要定義泛型方法,請使用 ``@singledispatchmethod`` 裝飾器對其裝飾。請注意,使" -"用 ``@singledispatchmethod`` 定義函式時,分派調度是發生在第一個非 *self* 或" +"用 ``@singledispatchmethod`` 定義方法時,分派調度是發生在第一個非 *self* 或" "非 *cls* 引數的型別上: ::" -#: ../../library/functools.rst:627 +#: ../../library/functools.rst:679 msgid "" "class Negator:\n" " @singledispatchmethod\n" @@ -1187,20 +1283,20 @@ msgstr "" " def _(self, arg: bool):\n" " return not arg" -#: ../../library/functools.rst:640 +#: ../../library/functools.rst:692 msgid "" "``@singledispatchmethod`` supports nesting with other decorators such as :" -"func:`@classmethod`. Note that to allow for ``dispatcher." -"register``, ``singledispatchmethod`` must be the *outer most* decorator. " -"Here is the ``Negator`` class with the ``neg`` methods bound to the class, " -"rather than an instance of the class::" +"deco:`classmethod`. Note that to allow for ``dispatcher.register``, " +"``singledispatchmethod`` must be the *outer most* decorator. Here is the " +"``Negator`` class with the ``neg`` methods bound to the class, rather than " +"an instance of the class::" msgstr "" -"``@singledispatchmethod`` 支援與其他裝飾器巢狀使用 (nesting),例如 :func:" -"`@classmethod`。請注意,為了使 ``dispatcher.register`` 可用," +"``@singledispatchmethod`` 支援與其他裝飾器巢狀使用 (nesting),例如 :deco:" +"`classmethod`。請注意,為了使 ``dispatcher.register`` 可用," "``singledispatchmethod`` 必須是\\ *最外面的*\\ 裝飾器。以下範例是 " "``Negator`` 類別,其 ``neg`` 方法繫結到該類別,而不是該類別的實例: ::" -#: ../../library/functools.rst:646 +#: ../../library/functools.rst:698 msgid "" "class Negator:\n" " @singledispatchmethod\n" @@ -1234,16 +1330,15 @@ msgstr "" " def _(cls, arg: bool):\n" " return not arg" -#: ../../library/functools.rst:662 +#: ../../library/functools.rst:714 msgid "" -"The same pattern can be used for other similar decorators: :func:" -"`@staticmethod`, :func:`@abstractmethod`, " -"and others." +"The same pattern can be used for other similar decorators: :deco:" +"`staticmethod`, :deco:`~abc.abstractmethod`, and others." msgstr "" -"相同的模式可用於其他類似的裝飾器::func:`@staticmethod`、:func:" -"`@abstractmethod` 等。" +"相同的模式可用於其他類似的裝飾器::deco:`staticmethod`、:deco:`~abc." +"abstractmethod` 等。" -#: ../../library/functools.rst:671 +#: ../../library/functools.rst:722 msgid "" "Update a *wrapper* function to look like the *wrapped* function. The " "optional arguments are tuples to specify which attributes of the original " @@ -1267,7 +1362,7 @@ msgstr "" "`~function.__doc__` 文件字串 (docstring))和 ``WRAPPER_UPDATES``\\ (更新包" "裝器函式的 :attr:`~function.__dict__`,即實例字典)。" -#: ../../library/functools.rst:683 +#: ../../library/functools.rst:734 msgid "" "To allow access to the original function for introspection and other " "purposes (e.g. bypassing a caching decorator such as :func:`lru_cache`), " @@ -1278,7 +1373,7 @@ msgstr "" "飾器,如 :func:`lru_cache`),此函式會自動向包裝器新增 ``__wrapped__`` 屬性," "該包裝器參照被包裝的函式。" -#: ../../library/functools.rst:688 +#: ../../library/functools.rst:739 msgid "" "The main intended use for this function is in :term:`decorator` functions " "which wrap the decorated function and return the wrapper. If the wrapper " @@ -1290,7 +1385,7 @@ msgstr "" "裝器函式未更新,則回傳函式的元資料 (metadata) 將反映包裝器定義而非原始函式定" "義,這通常不太會有幫助。" -#: ../../library/functools.rst:694 +#: ../../library/functools.rst:745 msgid "" ":func:`update_wrapper` may be used with callables other than functions. Any " "attributes named in *assigned* or *updated* that are missing from the object " @@ -1303,7 +1398,7 @@ msgstr "" "器函式上設定它們)。如果包裝函式本身缺少 *updated* 中指定的任何屬性,仍然會引" "發 :exc:`AttributeError`。" -#: ../../library/functools.rst:700 +#: ../../library/functools.rst:751 msgid "" "The ``__wrapped__`` attribute is now automatically added. The :attr:" "`~function.__annotations__` attribute is now copied by default. Missing " @@ -1312,7 +1407,7 @@ msgstr "" "現在會自動新增 ``__wrapped__`` 屬性。現在預設會複製 :attr:`~function." "__annotations__` 屬性。缺少的屬性不再觸發 :exc:`AttributeError`。" -#: ../../library/functools.rst:705 +#: ../../library/functools.rst:756 msgid "" "The ``__wrapped__`` attribute now always refers to the wrapped function, " "even if that function defined a ``__wrapped__`` attribute. (see :issue:" @@ -1321,12 +1416,12 @@ msgstr "" "``__wrapped__`` 屬性現在都會參照包裝函式,即便函式有定義 ``__wrapped__`` 屬" "性。(參見 :issue:`17482`)" -#: ../../library/functools.rst:710 +#: ../../library/functools.rst:761 msgid "" "The :attr:`~function.__type_params__` attribute is now copied by default." msgstr "現在預設會複製 :attr:`~function.__type_params__` 屬性。" -#: ../../library/functools.rst:716 +#: ../../library/functools.rst:767 msgid "" "This is a convenience function for invoking :func:`update_wrapper` as a " "function decorator when defining a wrapper function. It is equivalent to " @@ -1337,7 +1432,7 @@ msgstr "" "式裝飾器。它相當於 ``partial(update_wrapper, wrapped=wrapped, " "assigned=assigned, updated=updated)``。例如: ::" -#: ../../library/functools.rst:721 +#: ../../library/functools.rst:772 msgid "" ">>> from functools import wraps\n" ">>> def my_decorator(f):\n" @@ -1360,8 +1455,28 @@ msgid "" ">>> example.__doc__\n" "'Docstring'" msgstr "" +">>> from functools import wraps\n" +">>> def my_decorator(f):\n" +"... @wraps(f)\n" +"... def wrapper(*args, **kwds):\n" +"... print('Calling decorated function')\n" +"... return f(*args, **kwds)\n" +"... return wrapper\n" +"...\n" +">>> @my_decorator\n" +"... def example():\n" +"... \"\"\"Docstring\"\"\"\n" +"... print('Called example function')\n" +"...\n" +">>> example()\n" +"Calling decorated function\n" +"Called example function\n" +">>> example.__name__\n" +"'example'\n" +">>> example.__doc__\n" +"'Docstring'" -#: ../../library/functools.rst:742 +#: ../../library/functools.rst:793 msgid "" "Without the use of this decorator factory, the name of the example function " "would have been ``'wrapper'``, and the docstring of the original :func:`!" @@ -1370,11 +1485,11 @@ msgstr "" "如果不使用這個裝飾器工廠 (decorator factory),範例函式的名稱將會是 " "``'wrapper'``,並且原始 :func:`!example` 的文件字串將會遺失。" -#: ../../library/functools.rst:750 +#: ../../library/functools.rst:801 msgid ":class:`partial` Objects" msgstr ":class:`partial` 物件" -#: ../../library/functools.rst:752 +#: ../../library/functools.rst:803 msgid "" ":class:`partial` objects are callable objects created by :func:`partial`. " "They have three read-only attributes:" @@ -1382,7 +1497,7 @@ msgstr "" ":class:`partial` 物件是由 :func:`partial` 所建立的可呼叫物件。它們有三個唯讀" "屬性:" -#: ../../library/functools.rst:758 +#: ../../library/functools.rst:809 msgid "" "A callable object or function. Calls to the :class:`partial` object will be " "forwarded to :attr:`func` with new arguments and keywords." @@ -1390,7 +1505,7 @@ msgstr "" "一個可呼叫的物件或函式。對 :class:`partial` 物件的呼叫將被轉送到帶有新引數和" "關鍵字的 :attr:`func`。" -#: ../../library/functools.rst:764 +#: ../../library/functools.rst:815 msgid "" "The leftmost positional arguments that will be prepended to the positional " "arguments provided to a :class:`partial` object call." @@ -1398,24 +1513,21 @@ msgstr "" "最左邊的位置引數將會被加入到提供給 :class:`partial` 物件呼叫的位置引數的前" "面。" -#: ../../library/functools.rst:770 +#: ../../library/functools.rst:821 msgid "" "The keyword arguments that will be supplied when the :class:`partial` object " "is called." msgstr "呼叫 :class:`partial` 物件時將提供的關鍵字引數。" -#: ../../library/functools.rst:773 +#: ../../library/functools.rst:824 msgid "" ":class:`partial` objects are like :ref:`function objects ` in that they are callable, weak referenceable, and can have " -"attributes. There are some important differences. For instance, the :attr:" -"`~function.__name__` and :attr:`function.__doc__` attributes are not created " -"automatically. Also, :class:`partial` objects defined in classes behave " -"like static methods and do not transform into bound methods during instance " -"attribute look-up." +"attributes. There are some important differences. For instance, the :attr:" +"`~definition.__name__` and :attr:`~definition.__doc__` attributes are not " +"created automatically." msgstr "" ":class:`partial` 物件與\\ :ref:`函式物件 `\\ 類似,因為它" -"們是可呼叫的、可弱參照的 (weak referencable) 且可以具有屬性。有一些重要的區" -"別,例如,:attr:`~function.__name__` 和 :attr:`function.__doc__` 屬性不會自動" -"建立。此外,類別中定義的 :class:`partial` 物件的行為類似於靜態方法,並且在實" -"例屬性查找期間不會轉換為繫結方法。" +"們是可呼叫的、可弱參照的 (weak referencable) 且可以具有屬性的。但有一些重要的" +"區別,例如,:attr:`~definition.__name__` 和 :attr:`~definition.__doc__` 屬性" +"不會自動建立。" diff --git a/library/gc.po b/library/gc.po index 78ce3ab4e88..abcbc0941b3 100644 --- a/library/gc.po +++ b/library/gc.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -7,9 +7,9 @@ # msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-10-01 00:15+0000\n" +"POT-Creation-Date: 2025-09-29 00:15+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-" @@ -64,17 +64,34 @@ msgstr "如果啟用了自動回收則回傳 ``True``。" #: ../../library/gc.rst:43 msgid "" -"With no arguments, run a full collection. The optional argument " -"*generation* may be an integer specifying which generation to collect (from " -"0 to 2). A :exc:`ValueError` is raised if the generation number is invalid. " -"The sum of collected objects and uncollectable objects is returned." +"Perform a collection. The optional argument *generation* may be an integer " +"specifying which generation to collect (from 0 to 2). A :exc:`ValueError` " +"is raised if the generation number is invalid. The sum of collected objects " +"and uncollectable objects is returned." msgstr "" -"若被呼叫時沒有引數,則啟動完整垃圾回收。可選的引數 *generation* 可以是一個指" -"明需要回收哪一代垃圾的整數(從 0 到 2)。當引數 *generation* 無效時,會引發 :" -"exc:`ValueError` 例外。發現的不可達物件數目會被回傳。" +"啟動垃圾回收。可選的引數 *generation* 可以是一個指明需要回收哪一代垃圾的整數" +"(從 0 到 2)。當 generation 數值無效時,會引發 :exc:`ValueError` 例外。可回" +"收物件與不可回收物件的總和會被回傳。" #: ../../library/gc.rst:48 msgid "" +"Calling ``gc.collect(0)`` will perform a GC collection on the young " +"generation." +msgstr "呼叫 ``gc.collect(0)`` 將對年輕代執行 GC 回收。" + +#: ../../library/gc.rst:50 +msgid "" +"Calling ``gc.collect(1)`` will perform a GC collection on the young " +"generation and an increment of the old generation." +msgstr "呼叫 ``gc.collect(1)`` 將對年輕代執行 GC 回收並對年老代執行增量回收。" + +#: ../../library/gc.rst:53 +msgid "" +"Calling ``gc.collect(2)`` or ``gc.collect()`` performs a full collection" +msgstr "呼叫 ``gc.collect(2)`` 或 ``gc.collect()`` 執行完整回收" + +#: ../../library/gc.rst:55 +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 " "run. Not all items in some free lists may be freed due to the particular " @@ -84,13 +101,17 @@ msgstr "" "為了特定型別的實現,特別是 :class:`float`,在某些空閒列表中並非所有項目都會被" "釋放。" -#: ../../library/gc.rst:53 +#: ../../library/gc.rst:60 msgid "" "The effect of calling ``gc.collect()`` while the interpreter is already " "performing a collection is undefined." msgstr "當直譯器已經執行收集時呼叫 ``gc.collect()`` 的效果是未定義的。" -#: ../../library/gc.rst:59 +#: ../../library/gc.rst:63 +msgid "``generation=1`` performs an increment of collection." +msgstr "``generation=1`` 會執行增量收集。" + +#: ../../library/gc.rst:69 msgid "" "Set the garbage collection debugging flags. Debugging information will be " "written to ``sys.stderr``. See below for a list of debugging flags which " @@ -99,24 +120,40 @@ msgstr "" "設定垃圾回收器的除錯旗標。除錯資訊會被寫入 ``sys.stderr``。請見下方的除錯旗標" "列表,可以使用位元操作 (bit operation) 進行設定以控制除錯程式。" -#: ../../library/gc.rst:66 +#: ../../library/gc.rst:76 msgid "Return the debugging flags currently set." msgstr "回傳目前設置的除錯旗標。" -#: ../../library/gc.rst:71 +#: ../../library/gc.rst:82 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 " -"by the collector that are in that generation." +"returned. If *generation* is not ``None``, return only the objects as " +"follows:" msgstr "" "回傳一個包含回收器正在追蹤的所有物件的 list,除去所回傳的 list。如果 " -"*generation* 不為 ``None``,只回傳回收器正在追蹤且屬於該代的物件。" +"*generation* 不為 ``None``,只回傳以下物件。" + +#: ../../library/gc.rst:85 +msgid "0: All objects in the young generation" +msgstr "0: 年輕代中的所有物件。" + +#: ../../library/gc.rst:86 +msgid "1: No objects, as there is no generation 1 (as of Python 3.14)" +msgstr "1: 沒有物件,因為不存在第一代(截至 Python 3.14)" + +#: ../../library/gc.rst:87 +msgid "2: All objects in the old generation" +msgstr "2: 年老代中的所有物件。" -#: ../../library/gc.rst:75 +#: ../../library/gc.rst:89 msgid "New *generation* parameter." msgstr "新增 *generation* 參數。" -#: ../../library/gc.rst:78 +#: ../../library/gc.rst:92 +msgid "Generation 1 is removed" +msgstr "第一代已被刪除" + +#: ../../library/gc.rst:95 msgid "" "Raises an :ref:`auditing event ` ``gc.get_objects`` with argument " "``generation``." @@ -124,7 +161,7 @@ msgstr "" "引發一個附帶引數 ``generation`` 的\\ :ref:`稽核事件 (auditing event) " "` ``gc.get_objects``。" -#: ../../library/gc.rst:82 +#: ../../library/gc.rst:99 msgid "" "Return a list of three per-generation dictionaries containing collection " "statistics since interpreter start. The number of keys may change in the " @@ -134,17 +171,17 @@ msgstr "" "的垃圾回收統計資料。字典的鍵的數目在將來可能會改變,但目前每個字典包含以下項" "目:" -#: ../../library/gc.rst:87 +#: ../../library/gc.rst:104 msgid "``collections`` is the number of times this generation was collected;" msgstr "``collections`` 是該代被回收的次數;" -#: ../../library/gc.rst:89 +#: ../../library/gc.rst:106 msgid "" "``collected`` is the total number of objects collected inside this " "generation;" msgstr "``collected`` 是該代中被回收的物件總數;" -#: ../../library/gc.rst:92 +#: ../../library/gc.rst:109 msgid "" "``uncollectable`` is the total number of objects which were found to be " "uncollectable (and were therefore moved to the :data:`garbage` list) inside " @@ -153,54 +190,84 @@ msgstr "" "``uncollectable`` 是在這一代中被發現無法回收的物件總數(因此被移到 :data:" "`garbage` list 中)。" -#: ../../library/gc.rst:101 +#: ../../library/gc.rst:118 msgid "" "Set the garbage collection thresholds (the collection frequency). Setting " "*threshold0* to zero disables collection." msgstr "設定垃圾回收閾值(回收頻率)。 將 *threshold0* 設為零會停止回收。" -#: ../../library/gc.rst:104 +#: ../../library/gc.rst:121 msgid "" -"The GC classifies objects into three generations depending on how many " -"collection sweeps they have survived. New objects are placed in the " -"youngest generation (generation ``0``). If an object survives a collection " -"it is moved into the next older generation. Since generation ``2`` is the " -"oldest generation, objects in that generation remain there after a " -"collection. In order to decide when to run, the collector keeps track of " -"the number object allocations and deallocations since the last collection. " -"When the number of allocations minus the number of deallocations exceeds " -"*threshold0*, collection starts. Initially only generation ``0`` is " -"examined. If generation ``0`` has been examined more than *threshold1* " -"times since generation ``1`` has been examined, then generation ``1`` is " -"examined as well. With the third generation, things are a bit more " -"complicated, see `Collecting the oldest generation `_ for more " -"information." -msgstr "" -"垃圾回收器會根據物件在多少次垃圾回收後仍倖存來把所有物件分類為三代。新建物件" -"會被放在最年輕代(第 ``0`` 代)。 如果一個物件在一次垃圾回收後倖存,它會被移" -"入下一個較老代。由於第 ``2`` 代是最老代,這一代的物件在一次垃圾回收後仍會保留" -"原樣。為了確定何時要執行,垃圾回收器會追蹤自上一次回收後物件分配和釋放的數" -"量。當分配數量減去釋放數量的結果大於 *threshold0* 時,垃圾回收就會開始。初始" -"時只有第 ``0`` 代會被檢查。如果自第 ``1`` 代被檢查後第 ``0`` 代已被檢查超過 " -"*threshold1* 次,則第 ``1`` 代也會被檢查。對於第三代來說,情況還會更復雜一" -"些,請參閱 `Collecting the oldest generation `_ 來了解詳情。" +"The GC classifies objects into two generations depending on whether they " +"have survived a collection. New objects are placed in the young generation. " +"If an object survives a collection it is moved into the old generation." +msgstr "" +"GC 根據物件是否在回收中倖存下來而將其分為兩代。新的物件會被放置在年輕代中。如果一" +"個物件在回收中倖存下來,它將被移動到年老代中。" -#: ../../library/gc.rst:121 +#: ../../library/gc.rst:125 +msgid "" +"In order to decide when to run, the collector keeps track of the number of " +"object allocations and deallocations since the last collection. When the " +"number of allocations minus the number of deallocations exceeds " +"*threshold0*, collection starts. For each collection, all the objects in the " +"young generation and some fraction of the old generation is collected." +msgstr "" +"為了決定何時運行,回收器會追蹤自上次回收以來物件分配和釋放的數量。當分配數" +"量減去釋放數量超過 *threshold0* 時,回收就會開始。每次回收都會去回收年輕代中的所有物件" +"和年老代的部分物件。" + +#: ../../library/gc.rst:131 +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:136 +msgid "" +"The fraction of the old generation that is collected is **inversely** " +"proportional to *threshold1*. The larger *threshold1* is, the slower objects " +"in the old generation are collected. For the default value of 10, 1% of the " +"old generation is scanned during each collection." +msgstr "" +"年老代中被回收的物件比例與 *threshold1* 成\\ **反比**。*threshold1* 越大,年老代中" +"物件的回收就越慢。以預設值 10 來說,每次回收時會掃描年老代中的 1%。" + +#: ../../library/gc.rst:141 +msgid "*threshold2* is ignored." +msgstr "*threshold2* 會被忽略。" + +#: ../../library/gc.rst:143 +msgid "" +"See `Garbage collector design `_ for more information." +msgstr "" +"有關更多資訊,請參閱\\ `垃圾回收器設計 `_。" + +#: ../../library/gc.rst:145 +msgid "*threshold2* is ignored" +msgstr "*threshold2* 會被忽略" + +#: ../../library/gc.rst:151 msgid "" "Return the current collection counts as a tuple of ``(count0, count1, " "count2)``." msgstr "將目前回收計數以 ``(count0, count1, count2)`` 形式的 tuple 回傳。" -#: ../../library/gc.rst:127 +#: ../../library/gc.rst:157 msgid "" "Return the current collection thresholds as a tuple of ``(threshold0, " "threshold1, threshold2)``." msgstr "" "將目前回收閾值以 ``(threshold0, threshold1, threshold2)`` 形式的 tuple 回傳。" -#: ../../library/gc.rst:133 +#: ../../library/gc.rst:163 msgid "" "Return the list of objects that directly refer to any of objs. This function " "will only locate those containers which support garbage collection; " @@ -210,7 +277,7 @@ msgstr "" "回傳包含直接參照 objs 中任一個物件的物件 list。這個函式只定位支援垃圾回收的容" "器;參照了其它物件但不支援垃圾回收的擴充套件型別無法被找到。" -#: ../../library/gc.rst:138 +#: ../../library/gc.rst:168 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 " @@ -221,7 +288,7 @@ msgstr "" "會被作為參照者出現在回傳的 list 中。若只要取得目前正在參照的物件,需要在呼" "叫 :func:`get_referrers` 之前呼叫 :func:`collect`。" -#: ../../library/gc.rst:144 +#: ../../library/gc.rst:174 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 " @@ -232,7 +299,7 @@ msgstr "" "在建構中而處於暫時無效的狀態。不要把 :func:`get_referrers` 用於除錯以外的其它" "目的。" -#: ../../library/gc.rst:149 +#: ../../library/gc.rst:179 msgid "" "Raises an :ref:`auditing event ` ``gc.get_referrers`` with " "argument ``objs``." @@ -240,7 +307,7 @@ msgstr "" "引發一個附帶引數 ``objs`` 的\\ :ref:`稽核事件 ` ``gc." "get_referrers``。" -#: ../../library/gc.rst:154 +#: ../../library/gc.rst:184 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:" @@ -258,7 +325,7 @@ msgstr "" "此,可以有以下例子:一個整數對於一個引數是直接可達的,這個整數物件有可能出現" "或不出現在結果的 list 當中。" -#: ../../library/gc.rst:162 +#: ../../library/gc.rst:192 msgid "" "Raises an :ref:`auditing event ` ``gc.get_referents`` with " "argument ``objs``." @@ -266,7 +333,7 @@ msgstr "" "引發一個附帶引數 ``objs`` 的\\ :ref:`稽核事件 ` ``gc." "get_referents``。" -#: ../../library/gc.rst:166 +#: ../../library/gc.rst:196 msgid "" "Returns ``True`` if the object is currently tracked by the garbage " "collector, ``False`` otherwise. As a general rule, instances of atomic " @@ -280,7 +347,7 @@ msgstr "" "件)會被追蹤。然而,有一些特定型別最佳化會被用來減少垃圾回收器在簡單實例(如" "只含有原子性的鍵和值的字典)上的足跡: ::" -#: ../../library/gc.rst:173 +#: ../../library/gc.rst:203 msgid "" ">>> gc.is_tracked(0)\n" "False\n" @@ -291,8 +358,6 @@ msgid "" ">>> gc.is_tracked({})\n" "False\n" ">>> gc.is_tracked({\"a\": 1})\n" -"False\n" -">>> gc.is_tracked({\"a\": []})\n" "True" msgstr "" ">>> gc.is_tracked(0)\n" @@ -304,18 +369,16 @@ msgstr "" ">>> gc.is_tracked({})\n" "False\n" ">>> gc.is_tracked({\"a\": 1})\n" -"False\n" -">>> gc.is_tracked({\"a\": []})\n" "True" -#: ../../library/gc.rst:191 +#: ../../library/gc.rst:219 msgid "" "Returns ``True`` if the given object has been finalized by the garbage " "collector, ``False`` otherwise. ::" msgstr "" "如果給定物件已被垃圾回收器終結則回傳 ``True``,否則回傳 ``False``。: ::" -#: ../../library/gc.rst:194 +#: ../../library/gc.rst:222 msgid "" ">>> x = None\n" ">>> class Lazarus:\n" @@ -343,7 +406,7 @@ msgstr "" ">>> gc.is_finalized(x)\n" "True" -#: ../../library/gc.rst:212 +#: ../../library/gc.rst:240 msgid "" "Freeze all the objects tracked by the garbage collector; move them to a " "permanent generation and ignore them in all the future collections." @@ -351,7 +414,7 @@ msgstr "" "凍結 (freeze) 垃圾回收器所追蹤的所有物件;將它們移至永久代並忽略所有未來的收" "集動作。" -#: ../../library/gc.rst:215 +#: ../../library/gc.rst:243 msgid "" "If a process will ``fork()`` without ``exec()``, avoiding unnecessary copy-" "on-write in child processes will maximize memory sharing and reduce overall " @@ -369,23 +432,23 @@ msgstr "" "disable()``,在 ``fork()`` 之前呼叫 ``gc.freeze()``,並儘早在子行程中呼叫 " "``gc.enable()``。" -#: ../../library/gc.rst:229 +#: ../../library/gc.rst:257 msgid "" "Unfreeze the objects in the permanent generation, put them back into the " "oldest generation." msgstr "解凍 (unfreeze) 永久代中的物件,並將它們放回到最年老代中。" -#: ../../library/gc.rst:237 +#: ../../library/gc.rst:265 msgid "Return the number of objects in the permanent generation." msgstr "回傳永久代中的物件數量。" -#: ../../library/gc.rst:242 +#: ../../library/gc.rst:270 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:247 +#: ../../library/gc.rst:275 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 " @@ -396,7 +459,7 @@ msgstr "" "開始,該 list 在大多數時候都應該是空的,除非使用了有非 ``NULL`` ``tp_del`` 槽" "位的 C 擴充套件型別的實例。" -#: ../../library/gc.rst:252 +#: ../../library/gc.rst:280 msgid "" "If :const:`DEBUG_SAVEALL` is set, then all unreachable objects will be added " "to this list rather than freed." @@ -404,7 +467,7 @@ msgstr "" "如果設定了 :const:`DEBUG_SAVEALL`,則所有不可達物件將被加進該 list 而不會被釋" "放。" -#: ../../library/gc.rst:255 +#: ../../library/gc.rst:283 msgid "" "If this list is non-empty at :term:`interpreter shutdown`, a :exc:" "`ResourceWarning` is emitted, which is silent by default. If :const:" @@ -415,7 +478,7 @@ msgstr "" "`ResourceWarning`,在預設情況下此警告不會被提醒。如果設定了 :const:" "`DEBUG_UNCOLLECTABLE`,所有無法被回收的物件會被印出。" -#: ../../library/gc.rst:261 +#: ../../library/gc.rst:289 msgid "" "Following :pep:`442`, objects with a :meth:`~object.__del__` method don't " "end up in :data:`gc.garbage` anymore." @@ -423,7 +486,7 @@ msgstr "" "根據 :pep:`442`,帶有 :meth:`~object.__del__` method 的物件最終不會在 :data:" "`gc.garbage` 內。" -#: ../../library/gc.rst:267 +#: ../../library/gc.rst:295 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* " @@ -432,29 +495,29 @@ msgstr "" "會被垃圾回收器在回收開始前和完成後叫用的一系列回呼函式 (callback) 。這些回呼" "函式在被呼叫時附帶兩個引數:*phase* 和 *info*。" -#: ../../library/gc.rst:271 +#: ../../library/gc.rst:299 msgid "*phase* can be one of two values:" msgstr "*phase* 可為以下兩者之一:" -#: ../../library/gc.rst:273 +#: ../../library/gc.rst:301 msgid "\"start\": The garbage collection is about to start." msgstr "\"start\":垃圾回收即將開始。" -#: ../../library/gc.rst:275 +#: ../../library/gc.rst:303 msgid "\"stop\": The garbage collection has finished." msgstr "\"stop\":垃圾回收已結束。" -#: ../../library/gc.rst:277 +#: ../../library/gc.rst:305 msgid "" "*info* is a dict providing more information for the callback. The following " "keys are currently defined:" msgstr "*info* 是一個字典,提供回呼函式更多資訊。已有定義的鍵有:" -#: ../../library/gc.rst:280 +#: ../../library/gc.rst:308 msgid "\"generation\": The oldest generation being collected." msgstr "\"generation\"(代):正在被回收的最年老的一代。" -#: ../../library/gc.rst:282 +#: ../../library/gc.rst:310 msgid "" "\"collected\": When *phase* is \"stop\", the number of objects successfully " "collected." @@ -462,7 +525,7 @@ msgstr "" "\"collected\"(已回收的):當 *phase* 為 \"stop\" 時,被成功回收的物件的數" "目。" -#: ../../library/gc.rst:285 +#: ../../library/gc.rst:313 msgid "" "\"uncollectable\": When *phase* is \"stop\", the number of objects that " "could not be collected and were put in :data:`garbage`." @@ -470,40 +533,40 @@ msgstr "" "\"uncollectable\"(不可回收的):當 *phase* 為 \"stop\" 時,不能被回收並被放" "入 :data:`garbage` 的物件的數目。" -#: ../../library/gc.rst:288 +#: ../../library/gc.rst:316 msgid "" "Applications can add their own callbacks to this list. The primary use " "cases are:" msgstr "應用程式可以把他們自己的回呼函式加入此 list。主要的使用場景有:" -#: ../../library/gc.rst:291 +#: ../../library/gc.rst:319 msgid "" "Gathering statistics about garbage collection, such as how often various " "generations are collected, and how long the collection takes." msgstr "收集垃圾回收的統計資料,如:不同代的回收頻率、回收任務所花費的時間。" -#: ../../library/gc.rst:295 +#: ../../library/gc.rst:323 msgid "" "Allowing applications to identify and clear their own uncollectable types " "when they appear in :data:`garbage`." msgstr "" "讓應用程式可以識別和清理他們自己在 :data:`garbage` 中的不可回收型別物件。" -#: ../../library/gc.rst:301 +#: ../../library/gc.rst:329 msgid "The following constants are provided for use with :func:`set_debug`:" msgstr "以下常數是為了和 :func:`set_debug` 一起使用所提供:" -#: ../../library/gc.rst:306 +#: ../../library/gc.rst:334 msgid "" "Print statistics during collection. This information can be useful when " "tuning the collection frequency." msgstr "在回收完成後印出統計資訊。當調校回收頻率設定時,這些資訊會很有用。" -#: ../../library/gc.rst:312 +#: ../../library/gc.rst:340 msgid "Print information on collectable objects found." msgstr "當發現可回收物件時印出資訊。" -#: ../../library/gc.rst:317 +#: ../../library/gc.rst:345 msgid "" "Print information of uncollectable objects found (objects which are not " "reachable but cannot be freed by the collector). These objects will be " @@ -512,7 +575,7 @@ msgstr "" "印出找到的不可回收物件的資訊(指不能被回收器回收的不可達物件)。這些物件會被" "新增到 ``garbage`` list 中。" -#: ../../library/gc.rst:321 +#: ../../library/gc.rst:349 msgid "" "Also print the contents of the :data:`garbage` list at :term:`interpreter " "shutdown`, if it isn't empty." @@ -520,7 +583,7 @@ msgstr "" "當 :term:`interpreter shutdown`\\ (直譯器關閉)時,若 :data:`garbage` list " "不是空的,那這些內容也會被印出。" -#: ../../library/gc.rst:327 +#: ../../library/gc.rst:355 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." @@ -528,7 +591,7 @@ msgstr "" "設定後,所有回收器找到的不可達物件會被加進 *garbage* 而不是直接被釋放。這在為" "一個記憶體流失的程式除錯時會很有用。" -#: ../../library/gc.rst:333 +#: ../../library/gc.rst:361 msgid "" "The debugging flags necessary for the collector to print information about a " "leaking program (equal to ``DEBUG_COLLECTABLE | DEBUG_UNCOLLECTABLE | " @@ -536,3 +599,31 @@ msgid "" msgstr "" "要印出記憶體流失程式之相關資訊時,回收器所需的除錯旗標。(等同於 " "``DEBUG_COLLECTABLE | DEBUG_UNCOLLECTABLE | DEBUG_SAVEALL``)。" + +#~ msgid "" +#~ "The GC classifies objects into three generations depending on how many " +#~ "collection sweeps they have survived. New objects are placed in the " +#~ "youngest generation (generation ``0``). If an object survives a " +#~ "collection it is moved into the next older generation. Since generation " +#~ "``2`` is the oldest generation, objects in that generation remain there " +#~ "after a collection. In order to decide when to run, the collector keeps " +#~ "track of the number object allocations and deallocations since the last " +#~ "collection. When the number of allocations minus the number of " +#~ "deallocations exceeds *threshold0*, collection starts. Initially only " +#~ "generation ``0`` is examined. If generation ``0`` has been examined more " +#~ "than *threshold1* times since generation ``1`` has been examined, then " +#~ "generation ``1`` is examined as well. With the third generation, things " +#~ "are a bit more complicated, see `Collecting the oldest generation " +#~ "`_ for more information." +#~ msgstr "" +#~ "垃圾回收器會根據物件在多少次垃圾回收後仍倖存來把所有物件分類為三代。新建物" +#~ "件會被放在最年輕代(第 ``0`` 代)。 如果一個物件在一次垃圾回收後倖存,它會" +#~ "被移入下一個較老代。由於第 ``2`` 代是最老代,這一代的物件在一次垃圾回收後" +#~ "仍會保留原樣。為了確定何時要執行,垃圾回收器會追蹤自上一次回收後物件分配和" +#~ "釋放的數量。當分配數量減去釋放數量的結果大於 *threshold0* 時,垃圾回收就會" +#~ "開始。初始時只有第 ``0`` 代會被檢查。如果自第 ``1`` 代被檢查後第 ``0`` 代" +#~ "已被檢查超過 *threshold1* 次,則第 ``1`` 代也會被檢查。對於第三代來說,情" +#~ "況還會更復雜一些,請參閱 `Collecting the oldest generation `_ 來了解詳情。" diff --git a/library/getopt.po b/library/getopt.po index f9d84aca9d0..d96dc477a0e 100644 --- a/library/getopt.po +++ b/library/getopt.po @@ -1,12 +1,12 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"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: 2025-09-08 15:25+0800\n" "PO-Revision-Date: 2016-01-31 07:19+0000\n" "Last-Translator: Liang-Bo Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -36,8 +36,8 @@ msgstr "" #: ../../library/getopt.rst:20 msgid "" -"This module helps scripts to parse the command line arguments in ``sys." -"argv``. It supports the same conventions as the Unix :c:func:`!getopt` " +"This module helps scripts to parse the command line arguments in " +"``sys.argv``. It supports the same conventions as the Unix :c:func:`!getopt` " "function (including the special meanings of arguments of the form '``-``' " "and '``--``'). Long options similar to those supported by GNU software may " "be used as well via an optional third argument." @@ -63,45 +63,51 @@ msgid "" "to be parsed, without the leading reference to the running program. " "Typically, this means ``sys.argv[1:]``. *shortopts* is the string of option " "letters that the script wants to recognize, with options that require an " -"argument followed by a colon (``':'``; i.e., the same format that Unix :c:" -"func:`!getopt` uses)." +"argument followed by a colon (``':'``) and options that accept an optional " +"argument followed by two colons (``'::'``); i.e., the same format that " +"Unix :c:func:`!getopt` uses." msgstr "" -#: ../../library/getopt.rst:47 +#: ../../library/getopt.rst:48 msgid "" "Unlike GNU :c:func:`!getopt`, after a non-option argument, all further " "arguments are considered also non-options. This is similar to the way non-" "GNU Unix systems work." msgstr "" -#: ../../library/getopt.rst:51 +#: ../../library/getopt.rst:52 msgid "" "*longopts*, if specified, must be a list of strings with the names of the " "long options which should be supported. The leading ``'--'`` characters " "should not be included in the option name. Long options which require an " -"argument should be followed by an equal sign (``'='``). Optional arguments " -"are not supported. To accept only long options, *shortopts* should be an " -"empty string. Long options on the command line can be recognized so long as " -"they provide a prefix of the option name that matches exactly one of the " -"accepted options. For example, if *longopts* is ``['foo', 'frob']``, the " -"option ``--fo`` will match as ``--foo``, but ``--f`` will not match " -"uniquely, so :exc:`GetoptError` will be raised." +"argument should be followed by an equal sign (``'='``). Long options which " +"accept an optional argument should be followed by an equal sign and question " +"mark (``'=?'``). To accept only long options, *shortopts* should be an empty " +"string. Long options on the command line can be recognized so long as they " +"provide a prefix of the option name that matches exactly one of the accepted " +"options. For example, if *longopts* is ``['foo', 'frob']``, the option ``--" +"fo`` will match as ``--foo``, but ``--f`` will not match uniquely, " +"so :exc:`GetoptError` will be raised." msgstr "" -#: ../../library/getopt.rst:62 +#: ../../library/getopt.rst:65 msgid "" "The return value consists of two elements: the first is a list of ``(option, " "value)`` pairs; the second is the list of program arguments left after the " "option list was stripped (this is a trailing slice of *args*). Each option-" "and-value pair returned has the option as its first element, prefixed with a " -"hyphen for short options (e.g., ``'-x'``) or two hyphens for long options (e." -"g., ``'--long-option'``), and the option argument as its second element, or " -"an empty string if the option has no argument. The options occur in the " +"hyphen for short options (e.g., ``'-x'``) or two hyphens for long options " +"(e.g., ``'--long-option'``), and the option argument as its second element, " +"or an empty string if the option has no argument. The options occur in the " "list in the same order in which they were found, thus allowing multiple " "occurrences. Long and short options may be mixed." msgstr "" #: ../../library/getopt.rst:75 +msgid "Optional arguments are supported." +msgstr "" + +#: ../../library/getopt.rst:81 msgid "" "This function works like :func:`getopt`, except that GNU style scanning mode " "is used by default. This means that option and non-option arguments may be " @@ -109,14 +115,28 @@ msgid "" "a non-option argument is encountered." msgstr "" -#: ../../library/getopt.rst:80 +#: ../../library/getopt.rst:86 msgid "" "If the first character of the option string is ``'+'``, or if the " "environment variable :envvar:`!POSIXLY_CORRECT` is set, then option " "processing stops as soon as a non-option argument is encountered." msgstr "" -#: ../../library/getopt.rst:87 +#: ../../library/getopt.rst:90 +msgid "" +"If the first character of the option string is ``'-'``, non-option arguments " +"that are followed by options are added to the list of option-and-value pairs " +"as a pair that has ``None`` as its first element and the list of non-option " +"arguments as its second element. The second element of the :func:`!" +"gnu_getopt` result is a list of program arguments after the last option." +msgstr "" + +#: ../../library/getopt.rst:97 +msgid "" +"Support for returning intermixed options and non-option arguments in order." +msgstr "" + +#: ../../library/getopt.rst:103 msgid "" "This is raised when an unrecognized option is found in the argument list or " "when an option requiring an argument is given none. The argument to the " @@ -127,15 +147,15 @@ msgid "" "which the exception relates, :attr:`!opt` is an empty string." msgstr "" -#: ../../library/getopt.rst:98 +#: ../../library/getopt.rst:114 msgid "Alias for :exc:`GetoptError`; for backward compatibility." msgstr "為了向後相容性而設的 :exc:`GetoptError` 別名。" -#: ../../library/getopt.rst:100 +#: ../../library/getopt.rst:116 msgid "An example using only Unix style options:" msgstr "一個僅使用 Unix 風格選項的範例:" -#: ../../library/getopt.rst:102 +#: ../../library/getopt.rst:118 msgid "" ">>> import getopt\n" ">>> args = '-a -b -cfoo -d bar a1 a2'.split()\n" @@ -157,11 +177,11 @@ msgstr "" ">>> args\n" "['a1', 'a2']" -#: ../../library/getopt.rst:114 +#: ../../library/getopt.rst:130 msgid "Using long option names is equally easy:" msgstr "使用長選項名稱同樣容易:" -#: ../../library/getopt.rst:116 +#: ../../library/getopt.rst:132 msgid "" ">>> s = '--condition=foo --testing --output-file abc.def -x a1 a2'\n" ">>> args = s.split()\n" @@ -189,11 +209,63 @@ msgstr "" ">>> args\n" "['a1', 'a2']" -#: ../../library/getopt.rst:129 +#: ../../library/getopt.rst:145 +msgid "Optional arguments should be specified explicitly:" +msgstr "" + +#: ../../library/getopt.rst:147 +msgid "" +">>> s = '-Con -C --color=off --color a1 a2'\n" +">>> args = s.split()\n" +">>> args\n" +"['-Con', '-C', '--color=off', '--color', 'a1', 'a2']\n" +">>> optlist, args = getopt.getopt(args, 'C::', ['color=?'])\n" +">>> optlist\n" +"[('-C', 'on'), ('-C', ''), ('--color', 'off'), ('--color', '')]\n" +">>> args\n" +"['a1', 'a2']" +msgstr "" +">>> s = '-Con -C --color=off --color a1 a2'\n" +">>> args = s.split()\n" +">>> args\n" +"['-Con', '-C', '--color=off', '--color', 'a1', 'a2']\n" +">>> optlist, args = getopt.getopt(args, 'C::', ['color=?'])\n" +">>> optlist\n" +"[('-C', 'on'), ('-C', ''), ('--color', 'off'), ('--color', '')]\n" +">>> args\n" +"['a1', 'a2']" + +#: ../../library/getopt.rst:159 +msgid "The order of options and non-option arguments can be preserved:" +msgstr "" + +#: ../../library/getopt.rst:161 +msgid "" +">>> s = 'a1 -x a2 a3 a4 --long a5 a6'\n" +">>> args = s.split()\n" +">>> args\n" +"['a1', '-x', 'a2', 'a3', 'a4', '--long', 'a5', 'a6']\n" +">>> optlist, args = getopt.gnu_getopt(args, '-x:', ['long='])\n" +">>> optlist\n" +"[(None, ['a1']), ('-x', 'a2'), (None, ['a3', 'a4']), ('--long', 'a5')]\n" +">>> args\n" +"['a6']" +msgstr "" +">>> s = 'a1 -x a2 a3 a4 --long a5 a6'\n" +">>> args = s.split()\n" +">>> args\n" +"['a1', '-x', 'a2', 'a3', 'a4', '--long', 'a5', 'a6']\n" +">>> optlist, args = getopt.gnu_getopt(args, '-x:', ['long='])\n" +">>> optlist\n" +"[(None, ['a1']), ('-x', 'a2'), (None, ['a3', 'a4']), ('--long', 'a5')]\n" +">>> args\n" +"['a6']" + +#: ../../library/getopt.rst:173 msgid "In a script, typical usage is something like this:" msgstr "在腳本中,典型的用法如下:" -#: ../../library/getopt.rst:131 +#: ../../library/getopt.rst:175 msgid "" "import getopt, sys\n" "\n" @@ -252,14 +324,14 @@ msgstr "" "if __name__ == \"__main__\":\n" " main()" -#: ../../library/getopt.rst:160 +#: ../../library/getopt.rst:204 msgid "" "Note that an equivalent command line interface could be produced with less " -"code and more informative help and error messages by using the :mod:" -"`optparse` module:" +"code and more informative help and error messages by using " +"the :mod:`optparse` module:" msgstr "" -#: ../../library/getopt.rst:163 +#: ../../library/getopt.rst:207 msgid "" "import optparse\n" "\n" @@ -279,13 +351,13 @@ msgstr "" " opts, args = parser.parse_args()\n" " process(args, output=opts.output, verbose=opts.verbose)" -#: ../../library/getopt.rst:174 +#: ../../library/getopt.rst:218 msgid "" "A roughly equivalent command line interface for this case can also be " "produced by using the :mod:`argparse` module:" msgstr "" -#: ../../library/getopt.rst:177 +#: ../../library/getopt.rst:221 msgid "" "import argparse\n" "\n" @@ -307,7 +379,7 @@ msgstr "" " args = parser.parse_args()\n" " process(args.rest, output=args.output, verbose=args.verbose)" -#: ../../library/getopt.rst:189 +#: ../../library/getopt.rst:233 msgid "" "See :ref:`choosing-an-argument-parser` for details on how the ``argparse`` " "version of this code differs in behaviour from the ``optparse`` (and " @@ -316,18 +388,18 @@ msgstr "" "參見 :ref:`choosing-an-argument-parser` 以瞭解這段程式碼的 ``argparse`` 版本" "與 ``optparse``\\(以及 ``getopt``)版本在行為上的差異。" -#: ../../library/getopt.rst:195 +#: ../../library/getopt.rst:239 msgid "Module :mod:`optparse`" msgstr ":mod:`optparse` 模組" -#: ../../library/getopt.rst:196 +#: ../../library/getopt.rst:240 msgid "Declarative command line option parsing." msgstr "宣告式命令列選項剖析。" -#: ../../library/getopt.rst:198 +#: ../../library/getopt.rst:242 msgid "Module :mod:`argparse`" msgstr ":mod:`argparse` 模組" -#: ../../library/getopt.rst:199 +#: ../../library/getopt.rst:243 msgid "More opinionated command line option and argument parsing library." msgstr "" diff --git a/library/getpass.po b/library/getpass.po index 8904954af22..93118b2782b 100644 --- a/library/getpass.po +++ b/library/getpass.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -6,9 +6,9 @@ # Weilin Du, 2025 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-10-11 00:13+0000\n" +"POT-Creation-Date: 2025-09-18 00:15+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-" @@ -60,14 +60,23 @@ msgstr "" #: ../../library/getpass.rst:28 msgid "" +"The *echo_char* argument controls how user input is displayed while typing. " +"If *echo_char* is ``None`` (default), input remains hidden. Otherwise, " +"*echo_char* must be a single printable ASCII character and each typed " +"character is replaced by it. For example, ``echo_char='*'`` will display " +"asterisks instead of the actual input." +msgstr "" + +#: ../../library/getpass.rst:34 +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:`GetPassWarning`." +"message to *stream* and reading from ``sys.stdin`` and issuing a :exc:" +"`GetPassWarning`." msgstr "" "如果無回音輸入 (echo-free input) 無法使用則 getpass() 將回退為印出一條警告訊" "息到 *stream*,並從 ``sys.stdin`` 讀取且同時發出 :exc:`GetPassWarning`。" -#: ../../library/getpass.rst:33 +#: ../../library/getpass.rst:39 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." @@ -75,32 +84,44 @@ msgstr "" "如果你從 IDLE 內部呼叫 getpass,輸入可能會在你啟動 IDLE 的終端機中完成,而非" "在 IDLE 視窗中。" -#: ../../library/getpass.rst:38 +#: ../../library/getpass.rst:43 +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." +msgstr "" + +#: ../../library/getpass.rst:50 +msgid "Added the *echo_char* parameter for keyboard feedback." +msgstr "" + +#: ../../library/getpass.rst:55 msgid "A :exc:`UserWarning` subclass issued when password input may be echoed." msgstr "當密碼輸入可能被回音時會發出的 :exc:`UserWarning` 子類別。" -#: ../../library/getpass.rst:43 +#: ../../library/getpass.rst:60 msgid "Return the \"login name\" of the user." msgstr "回傳使用者的\"登入名稱\"。" -#: ../../library/getpass.rst:45 +#: ../../library/getpass.rst:62 msgid "" -"This function checks the environment " -"variables :envvar:`LOGNAME`, :envvar:`USER`, :envvar:`!LNAME` " -"and :envvar:`USERNAME`, in order, and returns the value of the first one " -"which is set to a non-empty string. If none are set, the login name from " -"the password database is returned on systems which support the :mod:`pwd` " -"module, otherwise, an :exc:`OSError` is raised." +"This function checks the environment variables :envvar:`LOGNAME`, :envvar:" +"`USER`, :envvar:`!LNAME` and :envvar:`USERNAME`, in order, and returns the " +"value of the first one which is set to a non-empty string. If none are set, " +"the login name from the password database is returned on systems which " +"support the :mod:`pwd` module, otherwise, an :exc:`OSError` is raised." msgstr "" "此函式會按順序檢查環境變數 :envvar:`LOGNAME`、:envvar:`USER`、:envvar:`!" "LNAME` 和 :envvar:`USERNAME`,並回傳其中第一個被設定成非空字串的值。如果均未" "設定,則在支援 :mod:`pwd` 模組的系統上將會回傳來自密碼資料庫的登入名稱,否則" "將引發一個 :exc:`OSError` 例外。" -#: ../../library/getpass.rst:52 +#: ../../library/getpass.rst:69 msgid "In general, this function should be preferred over :func:`os.getlogin`." msgstr "大部分情況下,此函式應該要比 :func:`os.getlogin` 優先使用。" -#: ../../library/getpass.rst:54 +#: ../../library/getpass.rst:71 msgid "Previously, various exceptions beyond just :exc:`OSError` were raised." msgstr "在過去,除了 :exc:`OSError` 外還會引發各種例外。" diff --git a/library/gettext.po b/library/gettext.po index 3c6b357a303..bc20d1e31f4 100644 --- a/library/gettext.po +++ b/library/gettext.po @@ -1,11 +1,10 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-03 11:11+0800\n" "PO-Revision-Date: 2018-05-23 16:02+0000\n" diff --git a/library/glob.po b/library/glob.po index 0bdd842e894..b2f5820851f 100644 --- a/library/glob.po +++ b/library/glob.po @@ -1,13 +1,13 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Matt Wang , 2023 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-10-21 00:14+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-" @@ -29,30 +29,35 @@ msgstr "**原始碼:**\\ :source:`Lib/glob.py`" #: ../../library/glob.rst:21 msgid "" -"The :mod:`glob` module finds all the pathnames matching a specified pattern " -"according to the rules used by the Unix shell, although results are returned " -"in arbitrary order. No tilde expansion is done, but ``*``, ``?``, and " +"The :mod:`!glob` module finds pathnames using pattern matching rules similar " +"to the Unix shell. No tilde expansion is done, but ``*``, ``?``, and " "character ranges expressed with ``[]`` will be correctly matched. This is " "done by using the :func:`os.scandir` and :func:`fnmatch.fnmatch` functions " "in concert, and not by actually invoking a subshell." msgstr "" -":mod:`glob` 模組根據 Unix shell 使用的規則查找與指定模式匹配的所有路徑名稱," -"結果以任意順序回傳。沒有波浪號 (tilde) 擴展,但是 ``*``、``?`` 和用 ``[]`` 表" -"示的字元範圍將被正確匹配。這是透過同時使用 :func:`os.scandir` 和 :func:" -"`fnmatch.fnmatch` 函式來完成的,而沒有實際呼叫 subshell。" +":mod:`!glob` 模組使用類似於 Unix shell 的模式匹配規則來尋找路徑名稱。不會進" +"行波浪號擴展 (tilde expansion) ,但 ``*``、``?`` 和使用 ``[]`` 表達的字元範圍將會被正確匹配。這" +"是透過結合使用 :func:`os.scandir` 和 :func:`fnmatch.fnmatch` 函式來完成的,而沒有實際呼叫 subshell。" -#: ../../library/glob.rst:28 +#: ../../library/glob.rst:29 msgid "" -"Note that files beginning with a dot (``.``) can only be matched by patterns " -"that also start with a dot, unlike :func:`fnmatch.fnmatch` or :func:`pathlib." -"Path.glob`. (For tilde and shell variable expansion, use :func:`os.path." -"expanduser` and :func:`os.path.expandvars`.)" +"The pathnames are returned in no particular order. If you need a specific " +"order, sort the results." msgstr "" -"請注意,以點 (``.``) 開頭的檔案只能與同樣以點開頭的模式匹配,這與 :func:" -"`fnmatch.fnmatch` 或 :func:`pathlib.Path.glob` 不同。(對於波浪號和 shell 變" -"數擴展,請使用 :func:`os.path.expanduser` 和 :func:`os.path.expandvars`。)" +"路徑名稱不會以特定順序回傳。如果你需要特定的順序,請對結果進行排序。" -#: ../../library/glob.rst:34 +#: ../../library/glob.rst:32 +msgid "" +"Files beginning with a dot (``.``) can only be matched by patterns that also " +"start with a dot, unlike :func:`fnmatch.fnmatch` or :func:`pathlib.Path." +"glob`. For tilde and shell variable expansion, use :func:`os.path." +"expanduser` and :func:`os.path.expandvars`." +msgstr "" +"以點 (``.``) 開頭的檔案只能與同樣以點開頭的模式匹配,這與 :func:" +"`fnmatch.fnmatch` 或 :func:`pathlib.Path.glob` 不同。對於波浪號和 shell 變" +"數擴展,請使用 :func:`os.path.expanduser` 和 :func:`os.path.expandvars`。" + +#: ../../library/glob.rst:38 msgid "" "For a literal match, wrap the meta-characters in brackets. For example, " "``'[?]'`` matches the character ``'?'``." @@ -60,11 +65,11 @@ msgstr "" "對於文本 (literal) 匹配,將元字元 (meta-character) 括在方括號中。例如," "``'[?]'`` 會匹配 ``'?'`` 字元。" -#: ../../library/glob.rst:37 -msgid "The :mod:`glob` module defines the following functions:" -msgstr ":mod:`glob` 模組定義了以下函式:" +#: ../../library/glob.rst:41 +msgid "The :mod:`!glob` module defines the following functions:" +msgstr ":mod:`!glob` 模組定義了以下函式:" -#: ../../library/glob.rst:43 +#: ../../library/glob.rst:47 msgid "" "Return a possibly empty list of path names that match *pathname*, which must " "be a string containing a path specification. *pathname* can be either " @@ -82,25 +87,25 @@ msgstr "" "取決於檔案系統 (file system)。如果在呼叫此函式期間刪除或新增滿足條件的檔案," "則結果不一定會包含該檔案的路徑名稱。" -#: ../../library/glob.rst:52 +#: ../../library/glob.rst:56 msgid "" "If *root_dir* is not ``None``, it should be a :term:`path-like object` " "specifying the root directory for searching. It has the same effect on :" -"func:`glob` as changing the current directory before calling it. If " +"func:`!glob` as changing the current directory before calling it. If " "*pathname* is relative, the result will contain paths relative to *root_dir*." msgstr "" "如果 *root_dir* 不是 ``None``,它應該是一個指定搜尋根目錄的 :term:`path-like " -"object`。它在呼叫它之前更改目前目錄的影響與 :func:`glob` 相同。如果 " +"object`。它在呼叫它之前更改目前目錄的影響與 :func:`!glob` 相同。如果 " "*pathname* 是相對的,結果將包含相對於 *root_dir* 的路徑。" -#: ../../library/glob.rst:58 +#: ../../library/glob.rst:62 msgid "" "This function can support :ref:`paths relative to directory descriptors " "` with the *dir_fd* parameter." msgstr "" "此函式可以支援以 *dir_fd* 參數使用\\ :ref:`相對目錄描述器的路徑 `。" -#: ../../library/glob.rst:64 +#: ../../library/glob.rst:68 msgid "" "If *recursive* is true, the pattern \"``**``\" will match any files and zero " "or more directories, subdirectories and symbolic links to directories. If " @@ -111,13 +116,13 @@ msgstr "" "和目錄的符號連結。如果模式後面有 :data:`os.sep` 或 :data:`os.altsep` 那麼檔案" "將不會被匹配。" -#: ../../library/glob.rst:69 +#: ../../library/glob.rst:73 msgid "" "If *include_hidden* is true, \"``**``\" pattern will match hidden " "directories." msgstr "如果 *include_hidden* 為真,\"``**``\" 模式將匹配被隱藏的目錄。" -#: ../../library/glob.rst:71 ../../library/glob.rst:98 +#: ../../library/glob.rst:75 ../../library/glob.rst:102 msgid "" "Raises an :ref:`auditing event ` ``glob.glob`` with arguments " "``pathname``, ``recursive``." @@ -125,7 +130,7 @@ msgstr "" "引發一個附帶引數 ``pathname``、``recursive`` 的\\ :ref:`稽核事件 ` " "``glob.glob``。" -#: ../../library/glob.rst:72 ../../library/glob.rst:99 +#: ../../library/glob.rst:76 ../../library/glob.rst:103 msgid "" "Raises an :ref:`auditing event ` ``glob.glob/2`` with arguments " "``pathname``, ``recursive``, ``root_dir``, ``dir_fd``." @@ -133,31 +138,31 @@ msgstr "" "引發一個附帶引數 ``pathname``、``recursive``、``root_dir``、``dir_fd`` 的\\ :" "ref:`稽核事件 ` ``glob.glob/2``。" -#: ../../library/glob.rst:75 +#: ../../library/glob.rst:79 msgid "" "Using the \"``**``\" pattern in large directory trees may consume an " "inordinate amount of time." msgstr "在大型目錄樹中使用 \"``**``\" 模式可能會消耗過多的時間。" -#: ../../library/glob.rst:79 ../../library/glob.rst:102 +#: ../../library/glob.rst:83 ../../library/glob.rst:106 msgid "" "This function may return duplicate path names if *pathname* contains " "multiple \"``**``\" patterns and *recursive* is true." msgstr "" -#: ../../library/glob.rst:82 ../../library/glob.rst:105 +#: ../../library/glob.rst:86 ../../library/glob.rst:109 msgid "Support for recursive globs using \"``**``\"." msgstr "支援以 \"``**``\" 使用遞迴 glob。" -#: ../../library/glob.rst:85 ../../library/glob.rst:108 +#: ../../library/glob.rst:89 ../../library/glob.rst:112 msgid "Added the *root_dir* and *dir_fd* parameters." msgstr "新增 *root_dir* 與 *dir_fd* 參數。" -#: ../../library/glob.rst:88 ../../library/glob.rst:111 +#: ../../library/glob.rst:92 ../../library/glob.rst:115 msgid "Added the *include_hidden* parameter." msgstr "新增 *include_hidden* 參數。" -#: ../../library/glob.rst:95 +#: ../../library/glob.rst:99 msgid "" "Return an :term:`iterator` which yields the same values as :func:`glob` " "without actually storing them all simultaneously." @@ -165,7 +170,7 @@ msgstr "" "回傳一個會產生與 :func:`glob` 相同的值的 :term:`iterator` ,而不是同時儲存全" "部的值。" -#: ../../library/glob.rst:117 +#: ../../library/glob.rst:121 msgid "" "Escape all special characters (``'?'``, ``'*'`` and ``'['``). This is useful " "if you want to match an arbitrary literal string that may have special " @@ -178,52 +183,52 @@ msgstr "" "(sharepoints) 中的特殊字元不會被跳脫,例如在 Windows 上,``escape('//?/c:/" "Quo vadis?.txt')`` 會回傳 ``'//?/c:/Quo vadis[?].txt'``。" -#: ../../library/glob.rst:128 +#: ../../library/glob.rst:132 msgid "" "Convert the given path specification to a regular expression for use with :" "func:`re.match`. The path specification can contain shell-style wildcards." msgstr "" -#: ../../library/glob.rst:131 +#: ../../library/glob.rst:135 msgid "For example:" msgstr "舉例來說:" -#: ../../library/glob.rst:142 +#: ../../library/glob.rst:146 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:146 +#: ../../library/glob.rst:150 msgid "" "If *recursive* is true, the pattern segment \"``**``\" will match any number " "of path segments." msgstr "" -#: ../../library/glob.rst:149 +#: ../../library/glob.rst:153 msgid "" "If *include_hidden* is true, wildcards can match path segments that start " "with a dot (``.``)." msgstr "" -#: ../../library/glob.rst:152 +#: ../../library/glob.rst:156 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:157 +#: ../../library/glob.rst:161 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:165 +#: ../../library/glob.rst:169 msgid "Examples" msgstr "範例" -#: ../../library/glob.rst:167 +#: ../../library/glob.rst:171 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 " @@ -234,7 +239,7 @@ msgstr "" "gif`,和一個僅包含 :file:`3.txt` 檔案的子目錄 :file:`sub`,:func:`glob` 將產" "生以下結果。請注意路徑的任何前導部分是如何保留的。 ::" -#: ../../library/glob.rst:173 +#: ../../library/glob.rst:177 msgid "" ">>> import glob\n" ">>> glob.glob('./[0-9].*')\n" @@ -260,7 +265,7 @@ msgstr "" ">>> glob.glob('./**/', recursive=True)\n" "['./', './sub/']" -#: ../../library/glob.rst:185 +#: ../../library/glob.rst:189 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 :" @@ -269,7 +274,7 @@ msgstr "" "如果目錄包含以 ``.`` 開頭的檔案,則預設情況下不會去匹配到它們。例如,一個包" "含 :file:`card.gif` 和 :file:`.card.gif` 的目錄: ::" -#: ../../library/glob.rst:189 +#: ../../library/glob.rst:193 msgid "" ">>> import glob\n" ">>> glob.glob('*.gif')\n" @@ -283,12 +288,12 @@ msgstr "" ">>> glob.glob('.c*')\n" "['.card.gif']" -#: ../../library/glob.rst:196 +#: ../../library/glob.rst:200 msgid "" "The :mod:`fnmatch` module offers shell-style filename (not path) expansion." msgstr ":mod:`fnmatch` 模組提供了 shell 風格檔案名(不是路徑)的擴展" -#: ../../library/glob.rst:199 +#: ../../library/glob.rst:203 msgid "The :mod:`pathlib` module offers high-level path objects." msgstr ":mod:`pathlib` 模組提供高階路徑物件。" @@ -304,7 +309,7 @@ msgstr "pathname expansion(路徑名稱展開)" msgid "* (asterisk)" msgstr "* (星號)" -#: ../../library/glob.rst:13 ../../library/glob.rst:61 +#: ../../library/glob.rst:13 ../../library/glob.rst:65 msgid "in glob-style wildcards" msgstr "於 glob 風格的萬用字元中" @@ -328,6 +333,6 @@ msgstr "- (減號)" msgid ". (dot)" msgstr ". (點)" -#: ../../library/glob.rst:61 +#: ../../library/glob.rst:65 msgid "**" msgstr "**" diff --git a/library/graphlib.po b/library/graphlib.po index 8e8f8e4479e..7f1227d59fc 100644 --- a/library/graphlib.po +++ b/library/graphlib.po @@ -1,14 +1,13 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2023, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Matt Wang , 2023 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"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: 2025-09-08 15:25+0800\n" "PO-Revision-Date: 2023-01-04 16:35+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -94,15 +93,15 @@ msgid "" "nodes returned by :meth:`~TopologicalSorter.get_ready` and process them. " "Call :meth:`~TopologicalSorter.done` on each node as it finishes processing." msgstr "" -"當 :meth:`~TopologicalSorter.is_active` 為 ``True`` 時,疊代 :meth:" -"`~TopologicalSorter.get_ready` 回傳的節點並處理它們。在每個節點完成處理時呼" -"叫 :meth:`~TopologicalSorter.done`。" +"當 :meth:`~TopologicalSorter.is_active` 為 ``True`` 時,疊" +"代 :meth:`~TopologicalSorter.get_ready` 回傳的節點並處理它們。在每個節點完成" +"處理時呼叫 :meth:`~TopologicalSorter.done`。" #: ../../library/graphlib.rst:49 msgid "" "In case just an immediate sorting of the nodes in the graph is required and " -"no parallelism is involved, the convenience method :meth:`TopologicalSorter." -"static_order` can be used directly:" +"no parallelism is involved, the convenience " +"method :meth:`TopologicalSorter.static_order` can be used directly:" msgstr "" "如果只需要立即對圖中的節點進行排序且不涉及平行性 (parallelism),則可以直接使" "用便捷方法 :meth:`TopologicalSorter.static_order`:" @@ -180,44 +179,57 @@ msgstr "" msgid "" "Raises :exc:`ValueError` if called after :meth:`~TopologicalSorter.prepare`." msgstr "" -"如果在 :meth:`~TopologicalSorter.prepare` 之後呼叫,則引發 :exc:" -"`ValueError`。" +"如果在 :meth:`~TopologicalSorter.prepare` 之後呼叫,則引" +"發 :exc:`ValueError`。" #: ../../library/graphlib.rst:102 msgid "" "Mark the graph as finished and check for cycles in the graph. If any cycle " -"is detected, :exc:`CycleError` will be raised, but :meth:`~TopologicalSorter." -"get_ready` can still be used to obtain as many nodes as possible until " -"cycles block more progress. After a call to this function, the graph cannot " -"be modified, and therefore no more nodes can be added using :meth:" -"`~TopologicalSorter.add`." +"is detected, :exc:`CycleError` will be raised, " +"but :meth:`~TopologicalSorter.get_ready` can still be used to obtain as many " +"nodes as possible until cycles block more progress. After a call to this " +"function, the graph cannot be modified, and therefore no more nodes can be " +"added using :meth:`~TopologicalSorter.add`." msgstr "" -"將圖標記為已完成並檢查圖中的循環。如果檢測到任何循環,將引發 :exc:" -"`CycleError`,但 :meth:`~TopologicalSorter.get_ready` 仍可用於盡可能獲得更多" -"的節點,直到循環阻塞了進度。呼叫此函式後就無法修改圖,因此無法使用 :meth:" -"`~TopologicalSorter.add` 來新增更多節點。" +"將圖標記為已完成並檢查圖中的循環。如果檢測到任何循環,將引" +"發 :exc:`CycleError`,但 :meth:`~TopologicalSorter.get_ready` 仍可用於盡可能" +"獲得更多的節點,直到循環阻塞了進度。呼叫此函式後就無法修改圖,因此無法使" +"用 :meth:`~TopologicalSorter.add` 來新增更多節點。" -#: ../../library/graphlib.rst:111 +#: ../../library/graphlib.rst:109 +msgid "" +"A :exc:`ValueError` will be raised if the sort has been started " +"by :meth:`~.static_order` or :meth:`~.get_ready`." +msgstr "" + +#: ../../library/graphlib.rst:114 +msgid "" +"``prepare()`` can now be called more than once as long as the sort has not " +"started. Previously this raised :exc:`ValueError`." +msgstr "" + +#: ../../library/graphlib.rst:119 msgid "" "Returns ``True`` if more progress can be made and ``False`` otherwise. " "Progress can be made if cycles do not block the resolution and either there " -"are still nodes ready that haven't yet been returned by :meth:" -"`TopologicalSorter.get_ready` or the number of nodes marked :meth:" -"`TopologicalSorter.done` is less than the number that have been returned by :" -"meth:`TopologicalSorter.get_ready`." +"are still nodes ready that haven't yet been returned " +"by :meth:`TopologicalSorter.get_ready` or the number of nodes " +"marked :meth:`TopologicalSorter.done` is less than the number that have been " +"returned by :meth:`TopologicalSorter.get_ready`." msgstr "" "如果可以有更多進度則回傳 ``True``,否則回傳 ``False``。如果循環不阻塞解析 " -"(resolution) 並且仍有節點準備就緒但尚未由 :meth:`TopologicalSorter." -"get_ready` 回傳或標記為 :meth:`TopologicalSorter.done` 的節點數量較 :meth:" -"`TopologicalSorter.get_ready` 所回傳的少,則可以繼續取得進度。" +"(resolution) 並且仍有節點準備就緒但尚未" +"由 :meth:`TopologicalSorter.get_ready` 回傳或標記" +"為 :meth:`TopologicalSorter.done` 的節點數量" +"較 :meth:`TopologicalSorter.get_ready` 所回傳的少,則可以繼續取得進度。" -#: ../../library/graphlib.rst:118 +#: ../../library/graphlib.rst:126 msgid "" "The :meth:`~object.__bool__` method of this class defers to this function, " "so instead of::" msgstr "此類別的 :meth:`~object.__bool__` 方法遵循此函式,因此以下做法: ::" -#: ../../library/graphlib.rst:121 +#: ../../library/graphlib.rst:129 msgid "" "if ts.is_active():\n" " ..." @@ -225,11 +237,11 @@ msgstr "" "if ts.is_active():\n" " ..." -#: ../../library/graphlib.rst:124 +#: ../../library/graphlib.rst:132 msgid "it is possible to simply do::" msgstr "可以簡單地用以下方式替換: ::" -#: ../../library/graphlib.rst:126 +#: ../../library/graphlib.rst:134 msgid "" "if ts:\n" " ..." @@ -237,38 +249,38 @@ msgstr "" "if ts:\n" " ..." -#: ../../library/graphlib.rst:129 ../../library/graphlib.rst:152 +#: ../../library/graphlib.rst:137 ../../library/graphlib.rst:160 msgid "" -"Raises :exc:`ValueError` if called without calling :meth:`~TopologicalSorter." -"prepare` previously." +"Raises :exc:`ValueError` if called without " +"calling :meth:`~TopologicalSorter.prepare` previously." msgstr "" -"如果呼叫之前沒有先呼叫 :meth:`~TopologicalSorter.prepare` 則引發 :exc:" -"`ValueError`。" +"如果呼叫之前沒有先呼叫 :meth:`~TopologicalSorter.prepare` 則引" +"發 :exc:`ValueError`。" -#: ../../library/graphlib.rst:134 +#: ../../library/graphlib.rst:142 msgid "" "Marks a set of nodes returned by :meth:`TopologicalSorter.get_ready` as " "processed, unblocking any successor of each node in *nodes* for being " "returned in the future by a call to :meth:`TopologicalSorter.get_ready`." msgstr "" "將 :meth:`TopologicalSorter.get_ready` 回傳的一組節點標記為已處理,停止阻塞 " -"*nodes* 中每個節點的任何後繼節點 (successor),以便將來通過呼叫 :meth:" -"`TopologicalSorter.get_ready` 回傳。" +"*nodes* 中每個節點的任何後繼節點 (successor),以便將來通過呼" +"叫 :meth:`TopologicalSorter.get_ready` 回傳。" -#: ../../library/graphlib.rst:138 +#: ../../library/graphlib.rst:146 msgid "" "Raises :exc:`ValueError` if any node in *nodes* has already been marked as " "processed by a previous call to this method or if a node was not added to " -"the graph by using :meth:`TopologicalSorter.add`, if called without calling :" -"meth:`~TopologicalSorter.prepare` or if node has not yet been returned by :" -"meth:`~TopologicalSorter.get_ready`." +"the graph by using :meth:`TopologicalSorter.add`, if called without " +"calling :meth:`~TopologicalSorter.prepare` or if node has not yet been " +"returned by :meth:`~TopologicalSorter.get_ready`." msgstr "" -"若沒有和該呼叫一起呼叫 :meth:`~TopologicalSorter.prepare` 或節點還沒有被 :" -"meth:`~TopologicalSorter.get_ready` 回傳,且如果 *nodes* 中有任何節點已被先前" -"對此方法的呼叫標記為已處理、或者未使用 :meth:`TopologicalSorter.add` 將節點新" -"增到圖中,則引發 :exc:`ValueError`。" +"若沒有和該呼叫一起呼叫 :meth:`~TopologicalSorter.prepare` 或節點還沒有" +"被 :meth:`~TopologicalSorter.get_ready` 回傳,且如果 *nodes* 中有任何節點已被" +"先前對此方法的呼叫標記為已處理、或者未使用 :meth:`TopologicalSorter.add` 將節" +"點新增到圖中,則引發 :exc:`ValueError`。" -#: ../../library/graphlib.rst:146 +#: ../../library/graphlib.rst:154 msgid "" "Returns a ``tuple`` with all the nodes that are ready. Initially it returns " "all nodes with no predecessors, and once those are marked as processed by " @@ -281,18 +293,18 @@ msgstr "" "步的呼叫將回傳所有其全部前驅節點都已被處理的新節點。若無法取得更多進度,將回" "傳空 tuple。" -#: ../../library/graphlib.rst:157 +#: ../../library/graphlib.rst:165 msgid "" "Returns an iterator object which will iterate over nodes in a topological " -"order. When using this method, :meth:`~TopologicalSorter.prepare` and :meth:" -"`~TopologicalSorter.done` should not be called. This method is equivalent " -"to::" +"order. When using this method, :meth:`~TopologicalSorter.prepare` " +"and :meth:`~TopologicalSorter.done` should not be called. This method is " +"equivalent to::" msgstr "" -"回傳一個可疊代物件,它將按拓撲排序疊代節點。使用此方法時,不應呼叫 :meth:" -"`~TopologicalSorter.prepare` 和 :meth:`~TopologicalSorter.done`。此方法等效" -"於: ::" +"回傳一個可疊代物件,它將按拓撲排序疊代節點。使用此方法時,不應呼" +"叫 :meth:`~TopologicalSorter.prepare` 和 :meth:`~TopologicalSorter.done`。此" +"方法等效於: ::" -#: ../../library/graphlib.rst:162 +#: ../../library/graphlib.rst:170 msgid "" "def static_order(self):\n" " self.prepare()\n" @@ -308,13 +320,13 @@ msgstr "" " yield from node_group\n" " self.done(*node_group)" -#: ../../library/graphlib.rst:169 +#: ../../library/graphlib.rst:177 msgid "" "The particular order that is returned may depend on the specific order in " "which the items were inserted in the graph. For example:" msgstr "回傳的特定順序可能取決於將項目插入圖中的特定順序。例如:" -#: ../../library/graphlib.rst:172 +#: ../../library/graphlib.rst:180 msgid "" ">>> ts = TopologicalSorter()\n" ">>> ts.add(3, 2, 1)\n" @@ -340,46 +352,47 @@ msgstr "" ">>> print([*ts2.static_order()])\n" "[0, 2, 1, 3]" -#: ../../library/graphlib.rst:186 +#: ../../library/graphlib.rst:194 msgid "" "This is due to the fact that \"0\" and \"2\" are in the same level in the " -"graph (they would have been returned in the same call to :meth:" -"`~TopologicalSorter.get_ready`) and the order between them is determined by " -"the order of insertion." +"graph (they would have been returned in the same call " +"to :meth:`~TopologicalSorter.get_ready`) and the order between them is " +"determined by the order of insertion." msgstr "" -"這是因為 \"0\" 和 \"2\" 在圖中處於同一級別(它們將在對 :meth:" -"`~TopologicalSorter.get_ready` 的同一呼叫中回傳)並且它們之間的順序取決於插入" -"順序。" +"這是因為 \"0\" 和 \"2\" 在圖中處於同一級別(它們將在" +"對 :meth:`~TopologicalSorter.get_ready` 的同一呼叫中回傳)並且它們之間的順序" +"取決於插入順序。" -#: ../../library/graphlib.rst:192 +#: ../../library/graphlib.rst:200 msgid "If any cycle is detected, :exc:`CycleError` will be raised." msgstr "如果檢測到任何循環,則引發 :exc:`CycleError`。" -#: ../../library/graphlib.rst:198 +#: ../../library/graphlib.rst:206 msgid "Exceptions" msgstr "例外" -#: ../../library/graphlib.rst:199 +#: ../../library/graphlib.rst:207 msgid "The :mod:`graphlib` module defines the following exception classes:" msgstr ":mod:`graphlib` 模組定義了以下例外類別:" -#: ../../library/graphlib.rst:203 +#: ../../library/graphlib.rst:211 msgid "" "Subclass of :exc:`ValueError` raised by :meth:`TopologicalSorter.prepare` if " "cycles exist in the working graph. If multiple cycles exist, only one " "undefined choice among them will be reported and included in the exception." msgstr "" -":exc:`ValueError` 的子類別,如果作用的圖中存在循環則由 :meth:" -"`TopologicalSorter.prepare` 引發。如果存在多個循環,則只會報告未定義的其中一" -"個並包含在例外中。" - -#: ../../library/graphlib.rst:207 -msgid "" -"The detected cycle can be accessed via the second element in the :attr:" -"`~BaseException.args` attribute of the exception instance and consists in a " -"list of nodes, such that each node is, in the graph, an immediate " -"predecessor of the next node in the list. In the reported list, the first " -"and the last node will be the same, to make it clear that it is cyclic." +":exc:`ValueError` 的子類別,如果作用的圖中存在循環則" +"由 :meth:`TopologicalSorter.prepare` 引發。如果存在多個循環,則只會報告未定義" +"的其中一個並包含在例外中。" + +#: ../../library/graphlib.rst:215 +msgid "" +"The detected cycle can be accessed via the second element in " +"the :attr:`~BaseException.args` attribute of the exception instance and " +"consists in a list of nodes, such that each node is, in the graph, an " +"immediate predecessor of the next node in the list. In the reported list, " +"the first and the last node will be the same, to make it clear that it is " +"cyclic." msgstr "" "檢測到的循環可以通過例外實例的 :attr:`~BaseException.args` 屬性中第二個元素來" "存取,其為一個節點列表,每個節點在圖中都是列表中下一個節點的直接前驅節點" diff --git a/library/grp.po b/library/grp.po index cb3b4333c2d..8c5ae5e20d3 100644 --- a/library/grp.po +++ b/library/grp.po @@ -1,12 +1,11 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Weilin Du, 2025 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-10-11 00:13+0000\n" "PO-Revision-Date: 2025-06-28 17:17+0800\n" diff --git a/library/gzip.po b/library/gzip.po index 80147ac8e0f..f78de511c3c 100644 --- a/library/gzip.po +++ b/library/gzip.po @@ -1,13 +1,13 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Adrian Liaw , 2018 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-04-26 00:14+0000\n" +"POT-Creation-Date: 2025-11-18 00:15+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-" @@ -32,11 +32,19 @@ msgid "" "just like the GNU programs :program:`gzip` and :program:`gunzip` would." msgstr "" -#: ../../library/gzip.rst:14 -msgid "The data compression is provided by the :mod:`zlib` module." +#: ../../includes/optional-module.rst:1 +msgid "" +"This is an :term:`optional module`. If it is missing from your copy of " +"CPython, look for documentation from your distributor (that is, whoever " +"provided Python to you). If you are the distributor, see :ref:`optional-" +"module-requirements`." msgstr "" #: ../../library/gzip.rst:16 +msgid "The data compression is provided by the :mod:`zlib` module." +msgstr "" + +#: ../../library/gzip.rst:18 msgid "" "The :mod:`gzip` module provides the :class:`GzipFile` class, as well as the :" "func:`.open`, :func:`compress` and :func:`decompress` convenience functions. " @@ -45,78 +53,78 @@ msgid "" "like an ordinary :term:`file object`." msgstr "" -#: ../../library/gzip.rst:22 +#: ../../library/gzip.rst:24 msgid "" "Note that additional file formats which can be decompressed by the :program:" "`gzip` and :program:`gunzip` programs, such as those produced by :program:" "`compress` and :program:`pack`, are not supported by this module." msgstr "" -#: ../../library/gzip.rst:26 +#: ../../library/gzip.rst:28 msgid "The module defines the following items:" msgstr "此模組定義了以下項目:" -#: ../../library/gzip.rst:31 +#: ../../library/gzip.rst:33 msgid "" "Open a gzip-compressed file in binary or text mode, returning a :term:`file " "object`." msgstr "" -#: ../../library/gzip.rst:34 +#: ../../library/gzip.rst:36 msgid "" "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/gzip.rst:37 +#: ../../library/gzip.rst:39 msgid "" "The *mode* argument can be any of ``'r'``, ``'rb'``, ``'a'``, ``'ab'``, " "``'w'``, ``'wb'``, ``'x'`` or ``'xb'`` for binary mode, or ``'rt'``, " "``'at'``, ``'wt'``, or ``'xt'`` for text mode. The default is ``'rb'``." msgstr "" -#: ../../library/gzip.rst:41 +#: ../../library/gzip.rst:43 msgid "" "The *compresslevel* argument is an integer from 0 to 9, as for the :class:" "`GzipFile` constructor." msgstr "" -#: ../../library/gzip.rst:44 +#: ../../library/gzip.rst:46 msgid "" "For binary mode, this function is equivalent to the :class:`GzipFile` " "constructor: ``GzipFile(filename, mode, compresslevel)``. In this case, the " "*encoding*, *errors* and *newline* arguments must not be provided." msgstr "" -#: ../../library/gzip.rst:48 +#: ../../library/gzip.rst:50 msgid "" "For text mode, a :class:`GzipFile` object is created, and wrapped in an :" "class:`io.TextIOWrapper` instance with the specified encoding, error " "handling behavior, and line ending(s)." msgstr "" -#: ../../library/gzip.rst:52 +#: ../../library/gzip.rst:54 msgid "" "Added support for *filename* being a file object, support for text mode, and " "the *encoding*, *errors* and *newline* arguments." msgstr "" -#: ../../library/gzip.rst:56 +#: ../../library/gzip.rst:58 msgid "Added support for the ``'x'``, ``'xb'`` and ``'xt'`` modes." msgstr "新增 ``'x'``、``'xb'`` 和 ``'xt'`` 模式的支援。" -#: ../../library/gzip.rst:59 ../../library/gzip.rst:173 +#: ../../library/gzip.rst:61 ../../library/gzip.rst:175 msgid "Accepts a :term:`path-like object`." msgstr "接受\\ :term:`類路徑物件 `。" -#: ../../library/gzip.rst:64 +#: ../../library/gzip.rst:66 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:72 +#: ../../library/gzip.rst:74 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." @@ -124,7 +132,7 @@ msgid "" "given a non-trivial value." msgstr "" -#: ../../library/gzip.rst:77 +#: ../../library/gzip.rst:79 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. " @@ -132,7 +140,7 @@ msgid "" "file object." msgstr "" -#: ../../library/gzip.rst:82 +#: ../../library/gzip.rst:84 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 " @@ -141,7 +149,7 @@ msgid "" "in this case the original filename is not included in the header." msgstr "" -#: ../../library/gzip.rst:88 +#: ../../library/gzip.rst:90 msgid "" "The *mode* argument can be any of ``'r'``, ``'rb'``, ``'a'``, ``'ab'``, " "``'w'``, ``'wb'``, ``'x'``, or ``'xb'``, depending on whether the file will " @@ -151,14 +159,14 @@ msgid "" "writing." msgstr "" -#: ../../library/gzip.rst:94 +#: ../../library/gzip.rst:96 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:98 +#: ../../library/gzip.rst:100 msgid "" "The *compresslevel* argument is an integer from ``0`` to ``9`` controlling " "the level of compression; ``1`` is fastest and produces the least " @@ -166,7 +174,7 @@ msgid "" "is no compression. The default is ``9``." msgstr "" -#: ../../library/gzip.rst:103 +#: ../../library/gzip.rst:105 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 " @@ -174,12 +182,12 @@ msgid "" "generate a compressed stream that does not depend on creation time." msgstr "" -#: ../../library/gzip.rst:108 +#: ../../library/gzip.rst:110 msgid "" "See below for the :attr:`mtime` attribute that is set when decompressing." msgstr "" -#: ../../library/gzip.rst:110 +#: ../../library/gzip.rst:112 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 " @@ -188,39 +196,39 @@ msgid "" "class:`io.BytesIO` object's :meth:`~io.BytesIO.getvalue` method." msgstr "" -#: ../../library/gzip.rst:116 +#: ../../library/gzip.rst:118 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:120 +#: ../../library/gzip.rst:122 msgid ":class:`GzipFile` also provides the following method and attribute:" msgstr ":class:`GzipFile` 也提供了以下的方法和屬性:" -#: ../../library/gzip.rst:124 +#: ../../library/gzip.rst:126 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:127 +#: ../../library/gzip.rst:129 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:136 +#: ../../library/gzip.rst:138 msgid "``'rb'`` for reading and ``'wb'`` for writing." -msgstr "" +msgstr "``'rb'`` 用於讀取、``'wb'`` 用於寫入。" -#: ../../library/gzip.rst:138 +#: ../../library/gzip.rst:140 msgid "In previous versions it was an integer ``1`` or ``2``." -msgstr "" +msgstr "在先前版本中它是整數 ``1`` 或 ``2``。" -#: ../../library/gzip.rst:143 +#: ../../library/gzip.rst:145 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 " @@ -228,62 +236,63 @@ msgid "" "reading any headers is ``None``." msgstr "" -#: ../../library/gzip.rst:150 +#: ../../library/gzip.rst:152 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:154 +#: ../../library/gzip.rst:156 msgid "" "Support for the :keyword:`with` statement was added, along with the *mtime* " "constructor argument and :attr:`mtime` attribute." msgstr "" -#: ../../library/gzip.rst:158 +#: ../../library/gzip.rst:160 msgid "Support for zero-padded and unseekable files was added." msgstr "" -#: ../../library/gzip.rst:161 +#: ../../library/gzip.rst:163 msgid "The :meth:`io.BufferedIOBase.read1` method is now implemented." msgstr ":meth:`io.BufferedIOBase.read1` 方法現在已有實作。" -#: ../../library/gzip.rst:164 +#: ../../library/gzip.rst:166 msgid "Added support for the ``'x'`` and ``'xb'`` modes." msgstr "新增 ``'x'`` 和 ``'xb'`` 模式的支援。" -#: ../../library/gzip.rst:167 +#: ../../library/gzip.rst:169 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:176 +#: ../../library/gzip.rst:178 msgid "" "Opening :class:`GzipFile` for writing without specifying the *mode* argument " "is deprecated." msgstr "" -#: ../../library/gzip.rst:180 +#: ../../library/gzip.rst:182 msgid "" "Remove the ``filename`` attribute, use the :attr:`~GzipFile.name` attribute " "instead." msgstr "" -#: ../../library/gzip.rst:187 +#: ../../library/gzip.rst:189 msgid "" "Compress the *data*, returning a :class:`bytes` object containing the " "compressed data. *compresslevel* and *mtime* have the same meaning as in " -"the :class:`GzipFile` constructor above." +"the :class:`GzipFile` constructor above, but *mtime* defaults to 0 for " +"reproducible output." msgstr "" -#: ../../library/gzip.rst:192 +#: ../../library/gzip.rst:195 msgid "Added the *mtime* parameter for reproducible output." msgstr "" -#: ../../library/gzip.rst:194 +#: ../../library/gzip.rst:197 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." @@ -292,7 +301,7 @@ msgid "" "underlying zlib implementation." msgstr "" -#: ../../library/gzip.rst:201 +#: ../../library/gzip.rst:204 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." @@ -300,6 +309,12 @@ msgstr "" #: ../../library/gzip.rst:207 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 +msgid "" "Decompress the *data*, returning a :class:`bytes` object containing the " "uncompressed data. This function is capable of decompressing multi-member " "gzip data (multiple gzip blocks concatenated together). When the data is " @@ -307,21 +322,21 @@ msgid "" "*wbits* set to 31 is faster." msgstr "" -#: ../../library/gzip.rst:214 +#: ../../library/gzip.rst:221 msgid "" "Speed is improved by decompressing members at once in memory instead of in a " "streamed fashion." msgstr "" -#: ../../library/gzip.rst:221 +#: ../../library/gzip.rst:228 msgid "Examples of usage" msgstr "用法範例" -#: ../../library/gzip.rst:223 +#: ../../library/gzip.rst:230 msgid "Example of how to read a compressed file::" msgstr "如何讀取壓縮檔案的範例: ::" -#: ../../library/gzip.rst:225 +#: ../../library/gzip.rst:232 msgid "" "import gzip\n" "with gzip.open('/home/joe/file.txt.gz', 'rb') as f:\n" @@ -331,11 +346,11 @@ msgstr "" "with gzip.open('/home/joe/file.txt.gz', 'rb') as f:\n" " file_content = f.read()" -#: ../../library/gzip.rst:229 +#: ../../library/gzip.rst:236 msgid "Example of how to create a compressed GZIP file::" msgstr "如何建立一個壓縮的 GZIP 檔案的範例: ::" -#: ../../library/gzip.rst:231 +#: ../../library/gzip.rst:238 msgid "" "import gzip\n" "content = b\"Lots of content here\"\n" @@ -347,11 +362,11 @@ msgstr "" "with gzip.open('/home/joe/file.txt.gz', 'wb') as f:\n" " f.write(content)" -#: ../../library/gzip.rst:236 +#: ../../library/gzip.rst:243 msgid "Example of how to GZIP compress an existing file::" msgstr "如何壓縮一個已存在的檔案的範例: ::" -#: ../../library/gzip.rst:238 +#: ../../library/gzip.rst:245 msgid "" "import gzip\n" "import shutil\n" @@ -365,11 +380,11 @@ msgstr "" " with gzip.open('/home/joe/file.txt.gz', 'wb') as f_out:\n" " shutil.copyfileobj(f_in, f_out)" -#: ../../library/gzip.rst:244 +#: ../../library/gzip.rst:251 msgid "Example of how to GZIP compress a binary string::" msgstr "如何壓縮一個二進位字串的範例: ::" -#: ../../library/gzip.rst:246 +#: ../../library/gzip.rst:253 msgid "" "import gzip\n" "s_in = b\"Lots of content here\"\n" @@ -379,62 +394,62 @@ msgstr "" "s_in = b\"Lots of content here\"\n" "s_out = gzip.compress(s_in)" -#: ../../library/gzip.rst:252 +#: ../../library/gzip.rst:259 msgid "Module :mod:`zlib`" msgstr ":mod:`zlib` 模組" -#: ../../library/gzip.rst:253 +#: ../../library/gzip.rst:260 msgid "" "The basic data compression module needed to support the :program:`gzip` file " "format." msgstr "" -#: ../../library/gzip.rst:256 +#: ../../library/gzip.rst:263 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:266 -msgid "Command Line Interface" +#: ../../library/gzip.rst:273 +msgid "Command-line interface" msgstr "命令列介面" -#: ../../library/gzip.rst:268 +#: ../../library/gzip.rst:275 msgid "" "The :mod:`gzip` module provides a simple command line interface to compress " "or decompress files." msgstr "" -#: ../../library/gzip.rst:271 +#: ../../library/gzip.rst:278 msgid "Once executed the :mod:`gzip` module keeps the input file(s)." msgstr "" -#: ../../library/gzip.rst:275 +#: ../../library/gzip.rst:282 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:279 -msgid "Command line options" +#: ../../library/gzip.rst:286 +msgid "Command-line options" msgstr "命令列選項" -#: ../../library/gzip.rst:283 +#: ../../library/gzip.rst:290 msgid "If *file* is not specified, read from :data:`sys.stdin`." msgstr "如果未指定 *file*,則從 :data:`sys.stdin` 讀取。" -#: ../../library/gzip.rst:287 +#: ../../library/gzip.rst:294 msgid "Indicates the fastest compression method (less compression)." msgstr "" -#: ../../library/gzip.rst:291 +#: ../../library/gzip.rst:298 msgid "Indicates the slowest compression method (best compression)." msgstr "" -#: ../../library/gzip.rst:295 +#: ../../library/gzip.rst:302 msgid "Decompress the given file." msgstr "解壓縮指定的檔案。" -#: ../../library/gzip.rst:299 +#: ../../library/gzip.rst:306 msgid "Show the help message." msgstr "顯示幫助訊息。" diff --git a/library/hashlib.po b/library/hashlib.po index 358886b4334..91b8e4ca77a 100644 --- a/library/hashlib.po +++ b/library/hashlib.po @@ -1,13 +1,13 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Matt Wang , 2024 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-04-24 05:58+0000\n" +"POT-Creation-Date: 2025-10-03 00:13+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-" @@ -43,8 +43,8 @@ msgstr "" #: ../../library/hashlib.rst:31 msgid "" -"If you want the adler32 or crc32 hash functions, they are available in " -"the :mod:`zlib` module." +"If you want the adler32 or crc32 hash functions, they are available in the :" +"mod:`zlib` module." msgstr "" "如果你需要 adler32 或 crc32 雜湊函式,可以在 :mod:`zlib` 模組中找到它們。" @@ -55,13 +55,13 @@ msgstr "雜湊演算法" #: ../../library/hashlib.rst:40 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:`sha256` to create a SHA-256 hash object. You can now feed this " -"object with :term:`bytes-like objects ` " -"(normally :class:`bytes`) using the :meth:`update` method. At " -"any point you can ask it for the :dfn:`digest` of the concatenation of the " -"data fed to it so far using the :meth:`digest()` " -"or :meth:`hexdigest()` methods." +"return a hash object with the same simple interface. For example: use :func:" +"`sha256` to create a SHA-256 hash object. You can now feed this object with :" +"term:`bytes-like objects ` (normally :class:`bytes`) " +"using the :meth:`update` method. At any point you can ask it " +"for the :dfn:`digest` of the concatenation of the data fed to it so far " +"using the :meth:`digest()` or :meth:`hexdigest()` methods." msgstr "" "每種種類的 :dfn:`hash` 都有一個以其命名的建構函式方法。全部都會回傳具有相同簡" "單介面的雜湊物件。例如:可使用 :func:`sha256` 來建立 SHA-256 雜湊物件。現在你" @@ -74,8 +74,8 @@ msgstr "" #: ../../library/hashlib.rst:48 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 :meth:`.update` method." +"a hash supplied more than 2047 bytes of data at once in its constructor or :" +"meth:`.update` method." msgstr "" "為了允許多執行緒 (multithreading),Python :term:`GIL` 被釋放,同時在其建構函" "式或 :meth:`.update` 方法中計算一次提供超過 2047 位元組資料的雜" @@ -83,25 +83,27 @@ msgstr "" #: ../../library/hashlib.rst:55 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:`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`." -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`。" +"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:" +"`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`." +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 "" -"Additional algorithms may also be available if your Python " -"distribution's :mod:`hashlib` was linked against a build of OpenSSL that " -"provides others. Others *are not guaranteed available* on all installations " -"and will only be accessible by name via :func:`new`. " -"See :data:`algorithms_available`." +"Additional algorithms may also be available if your Python distribution's :" +"mod:`hashlib` was linked against a build of OpenSSL that provides others. " +"Others *are not guaranteed available* on all installations and will only be " +"accessible by name via :func:`new`. See :data:`algorithms_available`." msgstr "" "如果你的 Python 發行版的 :mod:`hashlib` 與提供其他演算法的 OpenSSL 版本鏈結," "也可能有其他演算法可用。其他則\\ *不保證可用*\\ 於在所有安裝上,並且只能以名" @@ -119,13 +121,13 @@ msgstr "" #: ../../library/hashlib.rst:74 msgid "" -"SHA3 (Keccak) and SHAKE " -"constructors :func:`sha3_224`, :func:`sha3_256`, :func:`sha3_384`, :func:`sha3_512`, :func:`shake_128`, :func:`shake_256` " -"were added. :func:`blake2b` and :func:`blake2s` were added." +"SHA3 (Keccak) and SHAKE constructors :func:`sha3_224`, :func:`sha3_256`, :" +"func:`sha3_384`, :func:`sha3_512`, :func:`shake_128`, :func:`shake_256` were " +"added. :func:`blake2b` and :func:`blake2s` were added." msgstr "" -"新增了 SHA3 (Keccak) 和 SHAKE 建構函" -"式 :func:`sha3_224`、:func:`sha3_256`、:func:`sha3_384`、:func:`sha3_512`、:func:`shake_128`、:func:`shake_256`。" -"也新增了 :func:`blake2b` 和 :func:`blake2s`。" +"新增了 SHA3 (Keccak) 和 SHAKE 建構函式 :func:`sha3_224`、:func:`sha3_256`、:" +"func:`sha3_384`、:func:`sha3_512`、:func:`shake_128`、:func:`shake_256`。也新" +"增了 :func:`blake2b` 和 :func:`blake2s`。" #: ../../library/hashlib.rst:82 msgid "" @@ -172,7 +174,8 @@ msgid "" ">>> m.update(b\" the spammish repetition\")\n" ">>> m.digest()\n" "b'\\x03\\x1e\\xdd}Ae\\x15\\x93\\xc5\\xfe\\\\" -"\\x00o\\xa5u+7\\xfd\\xdf\\xf7\\xbcN\\x84:\\xa6\\xaf\\x0c\\x95\\x0fK\\x94\\x06'\n" +"\\x00o\\xa5u+7\\xfd\\xdf\\xf7\\xbcN\\x84:" +"\\xa6\\xaf\\x0c\\x95\\x0fK\\x94\\x06'\n" ">>> m.hexdigest()\n" "'031edd7d41651593c5fe5c006fa5752b37fddff7bc4e843aa6af0c950f4b9406'" msgstr "" @@ -182,7 +185,8 @@ msgstr "" ">>> m.update(b\" the spammish repetition\")\n" ">>> m.digest()\n" "b'\\x03\\x1e\\xdd}Ae\\x15\\x93\\xc5\\xfe\\\\" -"\\x00o\\xa5u+7\\xfd\\xdf\\xf7\\xbcN\\x84:\\xa6\\xaf\\x0c\\x95\\x0fK\\x94\\x06'\n" +"\\x00o\\xa5u+7\\xfd\\xdf\\xf7\\xbcN\\x84:" +"\\xa6\\xaf\\x0c\\x95\\x0fK\\x94\\x06'\n" ">>> m.hexdigest()\n" "'031edd7d41651593c5fe5c006fa5752b37fddff7bc4e843aa6af0c950f4b9406'" @@ -236,14 +240,14 @@ msgstr "" #: ../../library/hashlib.rst:165 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 :func:`new`. :attr:`algorithms_guaranteed` will always be a subset. The " +"running Python interpreter. These names will be recognized when passed to :" +"func:`new`. :attr:`algorithms_guaranteed` will always be a subset. The " "same algorithm may appear multiple times in this set under different names " "(thanks to OpenSSL)." msgstr "" -"包含正在運行的 Python 直譯器中可用的雜湊演算法名稱的集合。這些名稱在傳遞" -"給 :func:`new` 時將被識別。:attr:`algorithms_guaranteed` 都會是它的一個子集。" -"相同的演算法可能會以不同的名稱多次出現在該集合中(多虧了 OpenSSL)。" +"包含正在運行的 Python 直譯器中可用的雜湊演算法名稱的集合。這些名稱在傳遞給 :" +"func:`new` 時將被識別。:attr:`algorithms_guaranteed` 都會是它的一個子集。相同" +"的演算法可能會以不同的名稱多次出現在該集合中(多虧了 OpenSSL)。" #: ../../library/hashlib.rst:174 msgid "Hash Objects" @@ -295,8 +299,8 @@ msgid "" "``m.update(a); m.update(b)`` is equivalent to ``m.update(a+b)``." msgstr "" "使用\\ :term:`類位元組物件 `\\ 來更新雜湊物件。重複呼叫相" -"當於連接所有引數的單一呼叫:``m.update(a); m.update(b)`` 等價於 " -"``m.update(a+b)``。" +"當於連接所有引數的單一呼叫:``m.update(a); m.update(b)`` 等價於 ``m." +"update(a+b)``。" #: ../../library/hashlib.rst:212 msgid "" @@ -304,9 +308,8 @@ msgid "" "This is a bytes object of size :attr:`digest_size` which may contain bytes " "in the whole range from 0 to 255." msgstr "" -"回傳目前有傳遞給 :meth:`update` 方法的資料之摘要。這是一個大小" -"為 :attr:`digest_size` 的位元組物件,它可能包含從 0 到 255 的整個範圍內的位元" -"組。" +"回傳目前有傳遞給 :meth:`update` 方法的資料之摘要。這是一個大小為 :attr:" +"`digest_size` 的位元組物件,它可能包含從 0 到 255 的整個範圍內的位元組。" #: ../../library/hashlib.rst:219 msgid "" @@ -384,20 +387,20 @@ 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` " "instances, SocketIO objects from :meth:`socket.socket.makefile`, and " -"similar. *fileobj* must be opened in blocking mode, otherwise " -"a :exc:`BlockingIOError` may be raised." +"similar. *fileobj* must be opened in blocking mode, otherwise a :exc:" +"`BlockingIOError` may be raised." msgstr "" "*fileobj* 必須是以二進位模式讀取的類檔案物件。它接受來自內建 :func:`open` 的" "檔案物件、:class:`~io.BytesIO` 實例、來自 :meth:`socket.socket.makefile` 的 " -"SocketIO 物件等。*fileobj* 必須以阻塞模式開啟,否則可能會引" -"發 :exc:`BlockingIOError`。" +"SocketIO 物件等。*fileobj* 必須以阻塞模式開啟,否則可能會引發 :exc:" +"`BlockingIOError`。" #: ../../library/hashlib.rst:276 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 state after this function returns or raises. It is up to the " -"caller to close *fileobj*." +"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 " +"state after this function returns or raises. It is up to the caller to close " +"*fileobj*." msgstr "" "該函式可以繞過 Python 的 I/O 並直接使用 :meth:`~io.IOBase.fileno` 中的檔案描" "述器 (file descriptor)。在此函式回傳或引發後,必須假定 *fileobj* 處於未知狀" @@ -417,8 +420,8 @@ msgstr "範例:" #: ../../library/hashlib.rst:305 msgid "" -"Now raises a :exc:`BlockingIOError` if the file is opened in blocking mode. " -"Previously, spurious null bytes were added to the digest." +"Now raises a :exc:`BlockingIOError` if the file is opened in non-blocking " +"mode. Previously, spurious null bytes were added to the digest." msgstr "" #: ../../library/hashlib.rst:311 @@ -456,8 +459,8 @@ msgid "" msgstr "" "字串 *hash_name* 是 HMAC 的雜湊摘要演算法所需的名稱,例如 ``sha1`` 或 " "``sha256``。*password* 和 *salt* 被直譯為位元組緩衝區。應用程式和函式庫應為 " -"*password* 設下合理的長度限制(例如 1024)。*salt* 應該是來自適當來源(例" -"如 :func:`os.urandom`)且大約 16 或更多位元組。" +"*password* 設下合理的長度限制(例如 1024)。*salt* 應該是來自適當來源(例如 :" +"func:`os.urandom`)且大約 16 或更多位元組。" #: ../../library/hashlib.rst:330 msgid "" @@ -555,8 +558,8 @@ msgstr "" #: ../../library/hashlib.rst:392 msgid "" -"Hash objects from this module follow the API of standard " -"library's :mod:`hashlib` objects." +"Hash objects from this module follow the API of standard library's :mod:" +"`hashlib` objects." msgstr "該模組中的雜湊物件遵循標準函式庫的 :mod:`hashlib` 物件 API。" #: ../../library/hashlib.rst:397 @@ -770,17 +773,15 @@ msgstr "簡單雜湊" #: ../../library/hashlib.rst:513 msgid "" "To calculate hash of some data, you should first construct a hash object by " -"calling the appropriate constructor function (:func:`blake2b` " -"or :func:`blake2s`), then update it with the data by " -"calling :meth:`~hash.update` on the object, and, finally, get the digest out " -"of the object by calling :meth:`~hash.digest` (or :meth:`~hash.hexdigest` " -"for hex-encoded string)." +"calling the appropriate constructor function (:func:`blake2b` or :func:" +"`blake2s`), then update it with the data by calling :meth:`~hash.update` on " +"the object, and, finally, get the digest out of the object by calling :meth:" +"`~hash.digest` (or :meth:`~hash.hexdigest` for hex-encoded string)." msgstr "" "要計算某些資料的雜湊值,你應該首先透過呼叫適當的建構函式(:func:`blake2b` " -"或 :func:`blake2s`)以建構一個雜湊物件,然後透過於物件呼" -"叫 :meth:`~hash.update` 來以資料對它更新,最後透過呼" -"叫 :meth:`~hash.digest`\\ (或對於十六進位編碼字串則" -"為 :meth:`~hash.hexdigest`)從物件中獲得摘要。" +"或 :func:`blake2s`)以建構一個雜湊物件,然後透過於物件呼叫 :meth:`~hash." +"update` 來以資料對它更新,最後透過呼叫 :meth:`~hash.digest`\\ (或對於十六進" +"位編碼字串則為 :meth:`~hash.hexdigest`)從物件中獲得摘要。" #: ../../library/hashlib.rst:526 msgid "" @@ -826,9 +827,9 @@ msgstr "密鑰雜湊 (Keyed hashing)" #: ../../library/hashlib.rst:581 msgid "" "Keyed hashing can be used for authentication as a faster and simpler " -"replacement for `Hash-based message authentication code `_ (HMAC). BLAKE2 can be securely used in prefix-" -"MAC mode thanks to the indifferentiability property inherited from BLAKE." +"replacement for `Hash-based message authentication code `_ (HMAC). BLAKE2 can be securely used in prefix-MAC " +"mode thanks to the indifferentiability property inherited from BLAKE." msgstr "" "密鑰雜湊可用於身份驗證,作為\\ `基於雜湊的訊息驗證碼 (Hash-based message " "authentication code) `_ (HMAC) 的更快、" diff --git a/library/heapq.po b/library/heapq.po index fb9399796c8..5dd4ca06016 100644 --- a/library/heapq.po +++ b/library/heapq.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2024, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -6,9 +6,9 @@ # 周 忠毅 , 2016 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"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: 2025-11-07 00:14+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-" @@ -38,76 +38,105 @@ msgstr "" #: ../../library/heapq.rst:19 msgid "" -"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 " +"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 " "invariant." msgstr "" -"Heap(堆積)是一顆二元樹,樹上所有父節點的值都小於等於他的子節點的值,我們將" -"這種情況稱為堆積的性質不變。" +"最小堆積 (min-heap) 是一顆二元樹,樹上每個父節點的值都小於或等於其子節點的" +"值。我們將這種情況稱為堆積性質不變 (heap invariant)。" -#: ../../library/heapq.rst:22 +#: ../../library/heapq.rst:23 msgid "" -"This implementation uses arrays for which ``heap[k] <= heap[2*k+1]`` and " -"``heap[k] <= heap[2*k+2]`` for all *k*, counting elements from zero. For " -"the sake of comparison, non-existing elements are considered to be " -"infinite. The interesting property of a heap is that its smallest element " -"is always the root, ``heap[0]``." +"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 " +"compared elements exist. Elements are counted from zero. The interesting " +"property of a min-heap is that its smallest element is always the root, " +"``heap[0]``." msgstr "" -"使用陣列實作,對於所有從0開始的 *k* 都滿足 ``heap[k] <= heap[2*k+1]`` 和 " -"``heap[k] <= heap[2*k+2]`` 。為了比較節點的值,不存在的元素被視為無限大。" -"heap 存在一個有趣的性質:樹上最小的元素永遠會在根節點 ``heap[0]`` 上。" +"對於最小堆積,此實作使用串列,對於所有存在的被比較元素,*k* 都滿足 ``heap[k] " +"<= heap[2*k+1]`` 和 ``heap[k] <= heap[2*k+2]``。元素是從零開始計數。最小堆積" +"有一個有趣的性質:最小的元素永遠在根節點 ``heap[0]``。" -#: ../../library/heapq.rst:28 +#: ../../library/heapq.rst:29 msgid "" -"The API below differs from textbook heap algorithms in two aspects: (a) We " -"use zero-based indexing. This makes the relationship between the index for " -"a node and the indexes for its children slightly less obvious, but is more " -"suitable since Python uses zero-based indexing. (b) Our pop method returns " -"the smallest item, not the largest (called a \"min heap\" in textbooks; a " -"\"max heap\" is more common in texts because of its suitability for in-place " -"sorting)." +"Max-heaps satisfy the reverse invariant: every parent node has a value " +"*greater* than any of its children. These are implemented as lists for " +"which ``maxheap[2*k+1] <= maxheap[k]`` and ``maxheap[2*k+2] <= maxheap[k]`` " +"for all *k* for which the compared elements exist. The root, ``maxheap[0]``, " +"contains the *largest* element; ``heap.sort(reverse=True)`` maintains the " +"max-heap invariant." msgstr "" -"下方的 API 跟一般教科書的 heap queue 演算法有兩個方面不同:第一,我們的索引" -"從 0 開始計算,這會父節點與子節點之間的關係產生很微小的差異,但更符合 Python " -"從 0 開始索引的設計。第二,我們的 pop 方法會回傳最小的元素而不是最大的元素 " -"( 在教科書中被稱作 \"min heap\",而 \"max heap\" 因為他很適合做原地排序,所" -"以更常出現在教科書中 )。" -#: ../../library/heapq.rst:35 +#: ../../library/heapq.rst:36 msgid "" -"These two make it possible to view the heap as a regular Python list without " -"surprises: ``heap[0]`` is the smallest item, and ``heap.sort()`` maintains " -"the heap invariant!" +"The :mod:`!heapq` API differs from textbook heap algorithms in two aspects: " +"(a) We use zero-based indexing. This makes the relationship between the " +"index for a node and the indexes for its children slightly less obvious, but " +"is more suitable since Python uses zero-based indexing. (b) Textbooks often " +"focus on max-heaps, due to their suitability for in-place sorting. Our " +"implementation favors min-heaps as they better correspond to Python :class:" +"`lists `." msgstr "" -"這兩個特性使得把 heap 當作一個標準的 Python list 檢視時不會出現意外:" -"``heap[0]`` 是最小的物件,``heap.sort()`` 能保持 heap 的性質不變!" +":mod:`!heapq` API 與教科書上的堆積演算法在兩個方面不同:(a) 我們使用從零開始" +"的索引。這使得節點索引和其子節點索引之間的關係變得不那麼明顯,但由於 Python " +"使用從零開始的索引,所以這樣更適合。(b) 教科書通常專注於最大堆積,因為它們適" +"合原地排序。我們的實作偏向於最小堆積,因為它們更符合 Python :class:`串列 " +"`。" -#: ../../library/heapq.rst:39 +#: ../../library/heapq.rst:43 msgid "" -"To create a heap, use a list initialized to ``[]``, or you can transform a " -"populated list into a heap via function :func:`heapify`." +"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()`` " +"maintains the heap invariant!" msgstr "" -"建立一個 heap 可以使用 list 初始化為 ``[]``,或者使用函式 :func:`heapify` 將" -"一個已經有元素的 list轉成一個 heap。" - -#: ../../library/heapq.rst:42 -msgid "The following functions are provided:" -msgstr "此模組提供下面的函式" +"這兩個特性使得可以將堆積視為一個普通的 Python 串列而不會有意外:``heap[0]`` " +"是最小的元素,而 ``heap.sort()`` 維持堆積性質不變!" #: ../../library/heapq.rst:47 -msgid "Push the value *item* onto the *heap*, maintaining the heap invariant." -msgstr "把 *item* 放進 *heap*,並保持 heap 性質不變。" +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 +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 +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:" +"`heapify_max` functions, respectively." +msgstr "" +"要建立一個堆積,使用初始化為 ``[]`` 的串列,或者分別使用 :func:`heapify` 或 :" +"func:`heapify_max` 函式將現有的串列轉換為最小堆積或最大堆積。" + +#: ../../library/heapq.rst:58 +msgid "The following functions are provided for min-heaps:" +msgstr "提供了以下針對最小堆積的函式:" + +#: ../../library/heapq.rst:63 +msgid "Transform list *x* into a min-heap, in-place, in linear time." +msgstr "在線性時間內將串列 *x* 原地轉換為最小堆積。" + +#: ../../library/heapq.rst:68 +msgid "" +"Push the value *item* onto the *heap*, maintaining the min-heap invariant." +msgstr "將值 *item* 推入 *heap*,並維持最小堆積性質不變。" -#: ../../library/heapq.rst:52 +#: ../../library/heapq.rst:73 msgid "" -"Pop and return the smallest item from the *heap*, maintaining the heap " +"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 " "the smallest item without popping it, use ``heap[0]``." msgstr "" -"從 *heap* 取出並回傳最小的元素,同時保持 heap 性質不變。如果 heap 是空的會產" -"生 :exc:`IndexError` 錯誤。只存取最小元素但不取出可以使用 ``heap[0]`` 。" +"從 *heap* 取出並回傳最小的元素,維持最小堆積性質不變。如果堆積為空,會引發 :" +"exc:`IndexError`。若要在不取出的情況下存取最小元素,請使用 ``heap[0]``。" -#: ../../library/heapq.rst:59 +#: ../../library/heapq.rst:80 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` " @@ -116,20 +145,16 @@ msgstr "" "將 *item* 放入 heap ,接著從 *heap* 取出並回傳最小的元素。這個組合函式比呼" "叫 :func:`heappush` 之後呼叫 :func:`heappop` 更有效率。" -#: ../../library/heapq.rst:66 -msgid "Transform list *x* into a heap, in-place, in linear time." -msgstr "在線性時間內將 list *x* 轉為 heap,且過程不會申請額外記憶體。" - -#: ../../library/heapq.rst:71 +#: ../../library/heapq.rst:87 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:`IndexError` is raised." +"*item*. The heap size doesn't change. If the heap is empty, :exc:" +"`IndexError` is raised." msgstr "" "從 *heap* 取出並回傳最小的元素,接著將新的 *item* 放進heap。heap 的大小不會改" "變。如果 heap 是空的會產生 :exc:`IndexError` 錯誤。" -#: ../../library/heapq.rst:74 +#: ../../library/heapq.rst:90 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 " @@ -140,7 +165,7 @@ msgstr "" "率,並在維護 heap 的大小不變時更為適當,取出/放入的組合函式一定會從 heap 回傳" "一個元素並用 *item* 取代他。" -#: ../../library/heapq.rst:79 +#: ../../library/heapq.rst:95 msgid "" "The value returned may be larger than the *item* added. If that isn't " "desired, consider using :func:`heappushpop` instead. Its push/pop " @@ -151,11 +176,59 @@ msgstr "" "用 :func:`heappushpop` 替代,他會回傳 heap 的最小值和 *item* 兩個當中比較小的" "那個,並將大的留在 heap 內。" -#: ../../library/heapq.rst:85 +#: ../../library/heapq.rst:101 +msgid "For max-heaps, the following functions are provided:" +msgstr "提供以下針對最大堆積的函式:" + +#: ../../library/heapq.rst:106 +msgid "Transform list *x* into a max-heap, in-place, in linear time." +msgstr "在線性時間內將串列 *x* 原地轉換為最大堆積。" + +#: ../../library/heapq.rst:113 +msgid "" +"Push the value *item* onto the max-heap *heap*, maintaining the max-heap " +"invariant." +msgstr "將值 *item* 推入最大堆積 *heap*,維持最大堆積性質不變。" + +#: ../../library/heapq.rst:121 +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. " +"To access the largest item without popping it, use ``maxheap[0]``." +msgstr "" +"從最大堆積 *heap* 取出並回傳最大的元素,維持最大堆積性質不變。如果最大堆積為" +"空,會引發 :exc:`IndexError`。若要在不取出的情況下存取最大元素,請使用 " +"``maxheap[0]``。" + +#: ../../library/heapq.rst:130 +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:" +"`heappush_max` followed by a separate call to :func:`heappop_max`." +msgstr "" +"將 *item* 推入 max-heap *heap*,然後取出並回傳 *heap* 中最大的元素。這個組合" +"動作比先呼叫 :func:`heappush_max` 再單獨呼叫 :func:`heappop_max` 更有效率。" + +#: ../../library/heapq.rst:140 +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:" +"`IndexError` is raised." +msgstr "" +"從最大堆積 *heap* 取出並回傳最大的元素,同時推入新的 *item*。最大堆積的大小不" +"會改變。如果最大堆積為空,會引發 :exc:`IndexError`。" + +#: ../../library/heapq.rst:145 +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 msgid "The module also offers three general purpose functions based on heaps." msgstr "這個模組也提供三個利用 heap 實作的一般用途函式" -#: ../../library/heapq.rst:90 +#: ../../library/heapq.rst:156 msgid "" "Merge multiple sorted inputs into a single sorted output (for example, merge " "timestamped entries from multiple log files). Returns an :term:`iterator` " @@ -164,7 +237,7 @@ msgstr "" "合併多個已排序的輸入並產生單一且已排序的輸出(舉例:合併來自多個 log 檔中有時" "間戳記的項目)。回傳一個 :term:`iterator` 包含已經排序的值。" -#: ../../library/heapq.rst:94 +#: ../../library/heapq.rst:160 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 " @@ -173,12 +246,12 @@ msgstr "" "和 ``sorted(itertools.chain(*iterables))`` 類似但回傳值是一個 iterable ,不會" "一次把所有資料都放進記憶體中,並且假設每一個輸入都已經(由小到大)排序過了。" -#: ../../library/heapq.rst:98 +#: ../../library/heapq.rst:164 msgid "" "Has two optional arguments which must be specified as keyword arguments." msgstr "有兩個選用參數,指定時必須被當作關鍵字參數指定。" -#: ../../library/heapq.rst:100 +#: ../../library/heapq.rst:166 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 " @@ -187,7 +260,7 @@ msgstr "" "*key* 參數指定了一個 :term:`key function` 引數,用來從每一個輸入的元素中決定" "一個比較的依據。預設的值是 ``None`` (直接比較元素)。" -#: ../../library/heapq.rst:104 +#: ../../library/heapq.rst:170 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 " @@ -198,11 +271,11 @@ msgstr "" "進行合併。為了達成類似 ``sorted(itertools.chain(*iterables), reverse=True)`` " "的行為,所有 iterables 必須由大到小排序。" -#: ../../library/heapq.rst:109 +#: ../../library/heapq.rst:175 msgid "Added the optional *key* and *reverse* parameters." msgstr "加入選用參數 *key* 和 *reverse* 。" -#: ../../library/heapq.rst:115 +#: ../../library/heapq.rst:181 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 " @@ -215,37 +288,37 @@ msgstr "" "的依據(例如 ``key=str.lower`` )。效果相當於 ``sorted(iterable, key=key, " "reverse=True)[:n]`` 。" -#: ../../library/heapq.rst:124 +#: ../../library/heapq.rst:190 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 " "is used to extract a comparison key from each element in *iterable* (for " -"example, ``key=str.lower``). Equivalent to: ``sorted(iterable, key=key)" -"[:n]``." +"example, ``key=str.lower``). Equivalent to: ``sorted(iterable, key=key)[:" +"n]``." msgstr "" "回傳一個包含資料 *iterable* 中前 *n* 小元素的 list 。如果有指定 *key* 引數," "*key* 會是只有一個引數的函式,用來從每一個在 *iterable* 中的元素提取一個比較" -"的依據(例如 ``key=str.lower`` )。效果相當於 ``sorted(iterable, key=key)" -"[:n]`` 。" +"的依據(例如 ``key=str.lower`` )。效果相當於 ``sorted(iterable, key=key)[:" +"n]`` 。" -#: ../../library/heapq.rst:130 +#: ../../library/heapq.rst:196 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 " -"``n==1``, it is more efficient to use the built-in :func:`min` " -"and :func:`max` functions. If repeated usage of these functions is " -"required, consider turning the iterable into an actual heap." +"``n==1``, it is more efficient to use the built-in :func:`min` and :func:" +"`max` functions. If repeated usage of these functions is required, consider " +"turning the iterable into an actual heap." msgstr "" -"後兩個函式在 *n* 值比較小時有最好的表現。對於較大的 *n* 值,只" -"用 :func:`sorted` 函式會更有效率。同樣地,當 ``n==1`` 時,使用內建函" -"式 :func:`min` 和 :func:`max` 會有更好的效率。如果需要重複使用這些函式,可以" -"考慮將 iterable 轉成真正的 heap 。" +"後兩個函式在 *n* 值比較小時有最好的表現。對於較大的 *n* 值,只用 :func:" +"`sorted` 函式會更有效率。同樣地,當 ``n==1`` 時,使用內建函式 :func:`min` " +"和 :func:`max` 會有更好的效率。如果需要重複使用這些函式,可以考慮將 iterable " +"轉成真正的 heap 。" -#: ../../library/heapq.rst:138 +#: ../../library/heapq.rst:204 msgid "Basic Examples" msgstr "基礎範例" -#: ../../library/heapq.rst:140 +#: ../../library/heapq.rst:206 msgid "" "A `heapsort `_ can be implemented by " "pushing all values onto a heap and then popping off the smallest values one " @@ -254,7 +327,7 @@ msgstr "" "`堆積排序 (heapsort) `_ 可以透過將所" "有的值推入一個 heap,並且從 heap 中一個接一個彈出最小元素來實作: ::" -#: ../../library/heapq.rst:144 +#: ../../library/heapq.rst:210 msgid "" ">>> def heapsort(iterable):\n" "... h = []\n" @@ -274,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:153 +#: ../../library/heapq.rst:219 msgid "" "This is similar to ``sorted(iterable)``, but unlike :func:`sorted`, this " "implementation is not stable." @@ -282,7 +355,7 @@ msgstr "" "雖然類似 ``sorted(iterable)`` ,但跟 :func:`sorted` 不同的是,這個實作不是 " "stable 的排序。" -#: ../../library/heapq.rst:156 +#: ../../library/heapq.rst:222 msgid "" "Heap elements can be tuples. This is useful for assigning comparison values " "(such as task priorities) alongside the main record being tracked::" @@ -290,7 +363,7 @@ msgstr "" "Heap 中的元素可以是 tuple 。這有利於將要比較的值(例如一個 task 的優先度)和" "主要資料放在一起排序: ::" -#: ../../library/heapq.rst:159 +#: ../../library/heapq.rst:225 msgid "" ">>> h = []\n" ">>> heappush(h, (5, 'write code'))\n" @@ -308,11 +381,11 @@ msgstr "" ">>> heappop(h)\n" "(1, 'write spec')" -#: ../../library/heapq.rst:169 +#: ../../library/heapq.rst:235 msgid "Priority Queue Implementation Notes" msgstr "優先佇列實作細節" -#: ../../library/heapq.rst:171 +#: ../../library/heapq.rst:237 msgid "" "A `priority queue `_ is common " "use for a heap, and it presents several implementation challenges:" @@ -320,7 +393,7 @@ msgstr "" "`優先佇列 (priority queue) `_ " "是 heap 的常見用途之一,實作優先佇列伴隨著下列挑戰:" -#: ../../library/heapq.rst:174 +#: ../../library/heapq.rst:240 msgid "" "Sort stability: how do you get two tasks with equal priorities to be " "returned in the order they were originally added?" @@ -328,7 +401,7 @@ msgstr "" "排序的穩定性:如何將兩個擁有相同優先次序 (priority) 的 task 按照他們被加入的" "順序回傳?" -#: ../../library/heapq.rst:177 +#: ../../library/heapq.rst:243 msgid "" "Tuple comparison breaks for (priority, task) pairs if the priorities are " "equal and the tasks do not have a default comparison order." @@ -336,21 +409,21 @@ msgstr "" "Tuple的排序在某些情況下會壞掉,例如當 Tuple (priority, task) 的 priorities 相" "等且 tasks 沒有一個預設的排序時。" -#: ../../library/heapq.rst:180 +#: ../../library/heapq.rst:246 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:183 +#: ../../library/heapq.rst:249 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:186 +#: ../../library/heapq.rst:252 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 " @@ -363,7 +436,7 @@ msgstr "" "入的順序排序。因為沒有任何兩個 task 擁有相同的 entry count,所以永遠不會直接" "使用 task 做比較。" -#: ../../library/heapq.rst:192 +#: ../../library/heapq.rst:258 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 " @@ -372,7 +445,7 @@ msgstr "" "task 無法比較的另一個解決方案是建立一個包裝器類別,該類別忽略 task 項目,只比" "較優先等級: ::" -#: ../../library/heapq.rst:195 +#: ../../library/heapq.rst:261 msgid "" "from dataclasses import dataclass, field\n" "from typing import Any\n" @@ -390,7 +463,7 @@ msgstr "" " priority: int\n" " item: Any=field(compare=False)" -#: ../../library/heapq.rst:203 +#: ../../library/heapq.rst:269 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 " @@ -399,7 +472,7 @@ msgstr "" "剩下的問題可以藉由找到要刪除的 task 並更改它的 priority 或者直接將它移除。尋" "找一個 task 可以使用一個 dictionary 指向佇列當中的 entry 。" -#: ../../library/heapq.rst:207 +#: ../../library/heapq.rst:273 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 " @@ -409,7 +482,7 @@ msgstr "" "行的方案是將原本的 entry 做一個標記表示它已經被刪除,並新增一個擁有新的 " "priority 的 entry: ::" -#: ../../library/heapq.rst:211 +#: ../../library/heapq.rst:277 msgid "" "pq = [] # list of entries arranged in a heap\n" "entry_finder = {} # mapping of tasks to entries\n" @@ -467,11 +540,11 @@ msgstr "" " return task\n" " raise KeyError('從空的優先佇列中 pop 出元素')" -#: ../../library/heapq.rst:241 +#: ../../library/heapq.rst:307 msgid "Theory" msgstr "原理" -#: ../../library/heapq.rst:243 +#: ../../library/heapq.rst:309 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 " @@ -482,7 +555,7 @@ msgstr "" "和 ``a[k] <= a[2*k+2]`` 。為了方便比較,不存在的元素被視為無限大。Heap 的一個" "有趣的性質是:``a[0]`` 永遠是最小的元素。" -#: ../../library/heapq.rst:248 +#: ../../library/heapq.rst:314 msgid "" "The strange invariant above is meant to be an efficient memory " "representation for a tournament. The numbers below are *k*, not ``a[k]``::" @@ -490,7 +563,7 @@ msgstr "" "上述乍看之下有些奇怪的不變式,是為了實作一個對記憶體來說有效率的方法,其表示" "方式如同錦標賽一般。下列的數字為 *k*,而不是 ``a[k]``: ::" -#: ../../library/heapq.rst:251 +#: ../../library/heapq.rst:317 msgid "" " 0\n" "\n" @@ -512,7 +585,7 @@ msgstr "" "\n" "15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30" -#: ../../library/heapq.rst:261 +#: ../../library/heapq.rst:327 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 " @@ -531,7 +604,7 @@ msgstr "" "下方較低層級的另一個項目來取代它,至此規則變為一個單元以及它下方兩個單元,包" "含三個不同項目,但是最上方的單元「勝過」下方兩個單元。" -#: ../../library/heapq.rst:270 +#: ../../library/heapq.rst:336 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 " @@ -547,7 +620,7 @@ msgstr "" "的複雜度顯然是樹的節點數目的對數級別。透過對所有項目疊代,可以得到一個複雜度" "為 *O*\\ (*n* log *n*) 的排序。" -#: ../../library/heapq.rst:277 +#: ../../library/heapq.rst:343 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 " @@ -564,7 +637,7 @@ msgstr "" "時,因這些事件仍在等待進行,所以很容易將它們插入 heap 當中。因此, heap 是一" "個實現排程器的優秀資料結構(這就是我用以實作 MIDI 編曲器的方法 :-)。" -#: ../../library/heapq.rst:286 +#: ../../library/heapq.rst:352 msgid "" "Various structures for implementing schedulers have been extensively " "studied, and heaps are good for this, as they are reasonably speedy, the " @@ -576,7 +649,7 @@ msgstr "" "快,且速度幾乎不受其他因素影響,最壞情況與平均狀況差異無幾。也有其它整體說來" "更有效率的方法,然而它們的最壞情況可能會非常糟糕。" -#: ../../library/heapq.rst:292 +#: ../../library/heapq.rst:358 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, " @@ -597,7 +670,7 @@ msgstr "" "於隨機產生的輸入,將可以產生長度兩倍於記憶體大小的 run。對於已模糊排序過的輸" "入,效果更好。" -#: ../../library/heapq.rst:302 +#: ../../library/heapq.rst:368 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 " @@ -613,7 +686,7 @@ msgstr "" "大小增加的速度會與第一個 heap 減少的速度一致。當第一個 heap 完全消失時,你可" "以切換至第二個 heap 開啟一個新 run 。這真是個聰明且相當有效率的做法!" -#: ../../library/heapq.rst:310 +#: ../../library/heapq.rst:376 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. :-)" @@ -621,11 +694,11 @@ msgstr "" "總結來說,heap 是值得了解的有用記憶體結構。我在一些應用中使用它們,我認為能有" "一個 'heap' 模組是很棒的。:-)" -#: ../../library/heapq.rst:314 +#: ../../library/heapq.rst:380 msgid "Footnotes" msgstr "註解" -#: ../../library/heapq.rst:315 +#: ../../library/heapq.rst:381 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 " diff --git a/library/hmac.po b/library/hmac.po index dfd8a8d4d69..15f3869b86c 100644 --- a/library/hmac.po +++ b/library/hmac.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2025, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -6,7 +6,7 @@ # Phil Lin , 2022 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2025-09-04 00:15+0000\n" "PO-Revision-Date: 2022-03-30 00:16+0800\n" diff --git a/library/html.entities.po b/library/html.entities.po index 1131e507aa2..4f108d3e57c 100644 --- a/library/html.entities.po +++ b/library/html.entities.po @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2022, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -6,7 +6,7 @@ # Matt Wang , 2022 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-05-09 00:03+0000\n" "PO-Revision-Date: 2022-06-27 09:38+0800\n" diff --git a/library/html.parser.po b/library/html.parser.po index da6a091b3e8..0e2c714153b 100644 --- a/library/html.parser.po +++ b/library/html.parser.po @@ -1,13 +1,13 @@ -# Copyright (C) 2001-2023, Python Software Foundation +# Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # Matt Wang , 2023 msgid "" msgstr "" -"Project-Id-Version: Python 3.13\n" +"Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-05-08 00:15+0000\n" +"POT-Creation-Date: 2025-11-01 00:16+0000\n" "PO-Revision-Date: 2023-05-04 22:54+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -42,25 +42,32 @@ msgstr "建立一個能夠剖析無效標記的剖析器實例。" #: ../../library/html.parser.rst:22 msgid "" -"If *convert_charrefs* is ``True`` (the default), all character references " -"(except the ones in ``script``/``style`` elements) are automatically " -"converted to the corresponding Unicode characters." +"If *convert_charrefs* is true (the default), all character references " +"(except the ones in elements like ``script`` and ``style``) are " +"automatically converted to the corresponding Unicode characters." msgstr "" -"如果 *convert_charrefs* 為 ``True`` (預設值),所有字元參照 (reference)" -"( ``script``/``style`` 元素中的參照除外)將自動轉換為相應的 Unicode 字元。" +"如果 *convert_charrefs* 為 true (預設值),所有字元參照 (reference)" +"(元素中的參照除外,像是 ``script`` 和 ``style`` )將自動轉換為相應的 Unicode 字元。" #: ../../library/html.parser.rst:26 msgid "" +"If *scripting* is false (the default), the content of the ``noscript`` " +"element is parsed normally; if it's true, it's returned as is without being " +"parsed." +msgstr "" + +#: ../../library/html.parser.rst:30 +msgid "" "An :class:`.HTMLParser` instance is fed HTML data and calls handler methods " "when start tags, end tags, text, comments, and other markup elements are " "encountered. The user should subclass :class:`.HTMLParser` and override its " "methods to implement the desired behavior." msgstr "" ":class:`.HTMLParser` 實例被提供 HTML 資料,並在遇到開始標籤、結束標籤、文本、" -"註解和其他標記元素時呼叫處理程式 (handler) 方法。使用者應該繼" -"承 :class:`.HTMLParser` 並覆蓋其方法以實作所需的行為。" +"註解和其他標記元素時呼叫處理程式 (handler) 方法。使用者應該繼承 :class:`." +"HTMLParser` 並覆蓋其方法以實作所需的行為。" -#: ../../library/html.parser.rst:31 +#: ../../library/html.parser.rst:35 msgid "" "This parser does not check that end tags match start tags or call the end-" "tag handler for elements which are closed implicitly by closing an outer " @@ -69,28 +76,32 @@ msgstr "" "此剖析器不檢查結束標籤是否與開始標籤匹配,也不會為透過結束外部元素來隱晦地被" "結束的元素呼叫結束標籤處理程式。" -#: ../../library/html.parser.rst:34 +#: ../../library/html.parser.rst:38 msgid "*convert_charrefs* keyword argument added." msgstr "新增關鍵字引數 *convert_charrefs*。" -#: ../../library/html.parser.rst:37 +#: ../../library/html.parser.rst:41 msgid "The default value for argument *convert_charrefs* is now ``True``." msgstr "引數 *convert_charrefs* 的預設值現在是 ``True``。" -#: ../../library/html.parser.rst:42 +#: ../../library/html.parser.rst:44 +msgid "Added the *scripting* parameter." +msgstr "" + +#: ../../library/html.parser.rst:49 msgid "Example HTML Parser Application" msgstr "HTML 剖析器應用程式範例" -#: ../../library/html.parser.rst:44 +#: ../../library/html.parser.rst:51 msgid "" -"As a basic example, below is a simple HTML parser that uses " -"the :class:`HTMLParser` class to print out start tags, end tags, and data as " -"they are encountered:" +"As a basic example, below is a simple HTML parser that uses the :class:" +"`HTMLParser` class to print out start tags, end tags, and data as they are " +"encountered:" msgstr "" "以下的基礎範例是一個簡單的 HTML 剖析器,它使用 :class:`HTMLParser` 類別,當遇" "到開始標籤、結束標籤和資料時將它們印出:" -#: ../../library/html.parser.rst:48 +#: ../../library/html.parser.rst:55 msgid "" "from html.parser import HTMLParser\n" "\n" @@ -124,11 +135,11 @@ msgstr "" "parser.feed('Test'\n" " '

Parse me!

')" -#: ../../library/html.parser.rst:66 +#: ../../library/html.parser.rst:73 msgid "The output will then be:" msgstr "輸出將是:" -#: ../../library/html.parser.rst:68 +#: ../../library/html.parser.rst:75 msgid "" "Encountered a start tag: html\n" "Encountered a start tag: head\n" @@ -156,24 +167,24 @@ msgstr "" "Encountered an end tag : body\n" "Encountered an end tag : html" -#: ../../library/html.parser.rst:85 +#: ../../library/html.parser.rst:92 msgid ":class:`.HTMLParser` Methods" msgstr ":class:`.HTMLParser` 方法" -#: ../../library/html.parser.rst:87 +#: ../../library/html.parser.rst:94 msgid ":class:`HTMLParser` instances have the following methods:" msgstr ":class:`HTMLParser` 實例具有以下方法:" -#: ../../library/html.parser.rst:92 +#: ../../library/html.parser.rst:99 msgid "" "Feed some text to the parser. It is processed insofar as it consists of " -"complete elements; incomplete data is buffered until more data is fed " -"or :meth:`close` is called. *data* must be :class:`str`." +"complete elements; incomplete data is buffered until more data is fed or :" +"meth:`close` is called. *data* must be :class:`str`." msgstr "" "向剖析器提供一些文本。只要它由完整的元素組成,它就會被處理;不完整的資料會被" "緩衝,直到輸入更多資料或呼叫 :meth:`close`。 *data* 必須是 :class:`str`。" -#: ../../library/html.parser.rst:99 +#: ../../library/html.parser.rst:106 msgid "" "Force processing of all buffered data as if it were followed by an end-of-" "file mark. This method may be redefined by a derived class to define " @@ -181,20 +192,20 @@ msgid "" "should always call the :class:`HTMLParser` base class method :meth:`close`." msgstr "" "強制處理所有緩衝資料,如同它後面跟有文件結束標籤一樣。此方法可能有被衍生類別" -"重新定義,以在輸入末尾定義額外的處理,但重新定義的版本仍應要呼" -"叫 :class:`HTMLParser` 基底類別方法 :meth:`close`。" +"重新定義,以在輸入末尾定義額外的處理,但重新定義的版本仍應要呼叫 :class:" +"`HTMLParser` 基底類別方法 :meth:`close`。" -#: ../../library/html.parser.rst:107 +#: ../../library/html.parser.rst:114 msgid "" "Reset the instance. Loses all unprocessed data. This is called implicitly " "at instantiation time." msgstr "重置實例。丟棄所有未處理的資料。這在實例化時被會隱晦地呼叫。" -#: ../../library/html.parser.rst:113 +#: ../../library/html.parser.rst:120 msgid "Return current line number and offset." msgstr "回傳目前列號 (line number) 和偏移量 (offset)。" -#: ../../library/html.parser.rst:118 +#: ../../library/html.parser.rst:125 msgid "" "Return the text of the most recently opened start tag. This should not " "normally be needed for structured processing, but may be useful in dealing " @@ -205,23 +216,23 @@ msgstr "" "「已部署」的 HTML 或以最少的更改重新生成輸入(可以保留屬性之間的空白等)時可" "能很有用。" -#: ../../library/html.parser.rst:124 +#: ../../library/html.parser.rst:131 msgid "" "The following methods are called when data or markup elements are " "encountered and they are meant to be overridden in a subclass. The base " -"class implementations do nothing (except " -"for :meth:`~HTMLParser.handle_startendtag`):" +"class implementations do nothing (except for :meth:`~HTMLParser." +"handle_startendtag`):" msgstr "" "當遇到資料或標記元素時將呼叫以下方法,並且它們應在子類別中被覆蓋。基底類別實" "作什麼都不做(除了 :meth:`~HTMLParser.handle_startendtag`):" -#: ../../library/html.parser.rst:131 +#: ../../library/html.parser.rst:138 msgid "" "This method is called to handle the start tag of an element (e.g. ``
``)." msgstr "呼叫此方法來處理元素的開始標籤(例如 ``
``)。" -#: ../../library/html.parser.rst:133 +#: ../../library/html.parser.rst:140 msgid "" "The *tag* argument is the name of the tag converted to lower case. The " "*attrs* argument is a list of ``(name, value)`` pairs containing the " @@ -233,81 +244,80 @@ msgstr "" "列表,包含在標籤的 ``<>`` 括號內找到的屬性。 *name* 將被轉成小寫,*value* 中" "的引號會被刪除,字元和實體參照也會被替換。" -#: ../../library/html.parser.rst:139 +#: ../../library/html.parser.rst:146 msgid "" "For instance, for the tag ````, this method " -"would be called as ``handle_starttag('a', [('href', 'https://" -"www.cwi.nl/')])``." +"would be called as ``handle_starttag('a', [('href', 'https://www.cwi." +"nl/')])``." msgstr "" "例如,對於標籤 ````,這個方法會以 " "``handle_starttag('a', [('href', 'https://www.cwi.nl/')])`` 的形式被呼叫。" -#: ../../library/html.parser.rst:142 +#: ../../library/html.parser.rst:149 msgid "" "All entity references from :mod:`html.entities` are replaced in the " "attribute values." msgstr "在屬性值中來自 :mod:`html.entities` 的所有實體參照都會被替換。" -#: ../../library/html.parser.rst:148 +#: ../../library/html.parser.rst:155 msgid "" "This method is called to handle the end tag of an element (e.g. ``
``)." msgstr "呼叫此方法來處理元素的結束標籤(例如 ``
``)。" -#: ../../library/html.parser.rst:150 +#: ../../library/html.parser.rst:157 msgid "The *tag* argument is the name of the tag converted to lower case." msgstr "*tag* 引數是轉換為小寫的標籤名稱。" -#: ../../library/html.parser.rst:155 +#: ../../library/html.parser.rst:162 msgid "" "Similar to :meth:`handle_starttag`, but called when the parser encounters an " "XHTML-style empty tag (````). This method may be overridden by " "subclasses which require this particular lexical information; the default " -"implementation simply calls :meth:`handle_starttag` " -"and :meth:`handle_endtag`." +"implementation simply calls :meth:`handle_starttag` and :meth:" +"`handle_endtag`." msgstr "" "與 :meth:`handle_starttag` 類似,但在剖析器遇到 XHTML 樣式的空標籤 " "(````) 時呼叫。這個方法可能被需要這個特定詞彙資訊 (lexical " -"information) 的子類別覆蓋;預設實作只是呼叫 :meth:`handle_starttag` " -"和 :meth:`handle_endtag`。" +"information) 的子類別覆蓋;預設實作只是呼叫 :meth:`handle_starttag` 和 :meth:" +"`handle_endtag`。" -#: ../../library/html.parser.rst:163 +#: ../../library/html.parser.rst:170 msgid "" "This method is called to process arbitrary data (e.g. text nodes and the " -"content of ```` and ````)." +"content of elements like ``script`` and ``style``)." msgstr "" -"呼叫此方法來處理任意資料(例如文本節點與 ```` 和 " -"```` 的內容)。" +"呼叫此方法來處理任意資料(例如文本節點與像是 ``script`` 和 ``style`` 元素的內容)。" -#: ../../library/html.parser.rst:169 +#: ../../library/html.parser.rst:176 msgid "" "This method is called to process a named character reference of the form " "``&name;`` (e.g. ``>``), where *name* is a general entity reference (e.g. " -"``'gt'``). This method is never called if *convert_charrefs* is ``True``." +"``'gt'``). This method is only called if *convert_charrefs* is false." msgstr "" "呼叫此方法來處理形式為 ``&name;`` (例如 ``>``)的附名字元參照,其中 " -"*name* 是一般實體參照(例如 ``'gt'``)。如果 *convert_charrefs* 為 ``True``," -"則永遠不會呼叫此方法。" +"*name* 是一般實體參照(例如 ``'gt'``)。此方法只有在 *convert_charrefs* 為 " +"false 時才會被呼叫。" -#: ../../library/html.parser.rst:177 +#: ../../library/html.parser.rst:184 msgid "" "This method is called to process decimal and hexadecimal numeric character " "references of the form :samp:`&#{NNN};` and :samp:`&#x{NNN};`. For example, " "the decimal equivalent for ``>`` is ``>``, whereas the hexadecimal is " -"``>``; in this case the method will receive ``'62'`` or ``'x3E'``. " -"This method is never called if *convert_charrefs* is ``True``." +"``>``; in this case the method will receive ``'62'`` or ``'x3E'``. This " +"method is only called if *convert_charrefs* is false." msgstr "" "呼叫此方法來處理 :samp:`&#{NNN};` 和 :samp:`&#x{NNN};` 形式的十進位和十六進位" -"數字字元參照。例如,``>`` 的十進位等效為 ``>``,而十六進位為 " -"``>``;在這種情況下,該方法將收到 ``'62'`` 或 ``'x3E'``。如果 " -"*convert_charrefs* 為 ``True``,則永遠不會呼叫此方法。" +"數字字元參照。例如,``>`` 的十進位等效為 ``>``,而十六進位為 ``>" +"``;在這種情況下,該方法將收到 ``'62'`` 或 ``'x3E'``。此方法只有在 *convert_charrefs* 為 " +"false 時才會被呼叫。" -#: ../../library/html.parser.rst:186 +#: ../../library/html.parser.rst:193 msgid "" "This method is called when a comment is encountered (e.g. ````)。" -#: ../../library/html.parser.rst:188 +#: ../../library/html.parser.rst:195 msgid "" "For example, the comment ```` will cause this method to be " "called with the argument ``' comment '``." @@ -315,7 +325,7 @@ msgstr "" "舉例來說,註解 ```` 會使得此方法被以引數 ``' comment '`` 來呼" "叫。" -#: ../../library/html.parser.rst:191 +#: ../../library/html.parser.rst:198 msgid "" "The content of Internet Explorer conditional comments (condcoms) will also " "be sent to this method, so, for ```` 為例," "這個方法將會收到 ``'[if IE 9]>IE9-specific content``)." @@ -334,7 +344,7 @@ msgstr "" "呼叫此方法來處理 HTML 文件類型聲明 (doctype declaration)(例如 ````)。" -#: ../../library/html.parser.rst:201 +#: ../../library/html.parser.rst:208 msgid "" "The *decl* parameter will be the entire contents of the declaration inside " "the ```` markup (e.g. ``'DOCTYPE html'``)." @@ -342,7 +352,7 @@ msgstr "" "*decl* 參數將是 ```` 標記內聲明部分的全部內容(例如 ``'DOCTYPE " "html'``)。" -#: ../../library/html.parser.rst:207 +#: ../../library/html.parser.rst:214 msgid "" "Method called when a processing instruction is encountered. The *data* " "parameter will contain the entire processing instruction. For example, for " @@ -355,7 +365,7 @@ msgstr "" "``handle_pi(\"proc color='red'\")`` 形式被呼叫。它旨在被衍生類別覆蓋;基底類" "別實作中什麼都不做。" -#: ../../library/html.parser.rst:215 +#: ../../library/html.parser.rst:222 msgid "" "The :class:`HTMLParser` class uses the SGML syntactic rules for processing " "instructions. An XHTML processing instruction using the trailing ``'?'`` " @@ -364,12 +374,12 @@ msgstr "" ":class:`HTMLParser` 類別使用 SGML 語法規則來處理指示。使用有 ``?`` 跟隨在後面" "的 XHTML 處理指示將導致 ``?`` 被包含在 *data* 中。" -#: ../../library/html.parser.rst:222 +#: ../../library/html.parser.rst:229 msgid "" "This method is called when an unrecognized declaration is read by the parser." msgstr "當剖析器讀取無法識別的聲明時會呼叫此方法。" -#: ../../library/html.parser.rst:224 +#: ../../library/html.parser.rst:231 msgid "" "The *data* parameter will be the entire contents of the declaration inside " "the ```` markup. It is sometimes useful to be overridden by a " @@ -378,17 +388,17 @@ msgstr "" "*data* 參數將是 ```` 標記內聲明的全部內容。有時被衍生類別被覆蓋會是好" "用的。在基底類別實作中什麼都不做。" -#: ../../library/html.parser.rst:232 +#: ../../library/html.parser.rst:239 msgid "Examples" msgstr "範例" -#: ../../library/html.parser.rst:234 +#: ../../library/html.parser.rst:241 msgid "" "The following class implements a parser that will be used to illustrate more " "examples:" msgstr "以下類別實作了一個剖析器,將用於解說更多範例:" -#: ../../library/html.parser.rst:237 +#: ../../library/html.parser.rst:244 msgid "" "from html.parser import HTMLParser\n" "from html.entities import name2codepoint\n" @@ -458,27 +468,27 @@ msgstr "" "\n" "parser = MyHTMLParser()" -#: ../../library/html.parser.rst:273 +#: ../../library/html.parser.rst:280 msgid "Parsing a doctype:" msgstr "剖析文件類型:" -#: ../../library/html.parser.rst:275 +#: ../../library/html.parser.rst:282 msgid "" ">>> parser.feed('')\n" -"Decl : DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://" -"www.w3.org/TR/html4/strict.dtd\"" +"Decl : DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3." +"org/TR/html4/strict.dtd\"" msgstr "" ">>> parser.feed('')\n" -"Decl : DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://" -"www.w3.org/TR/html4/strict.dtd\"" +"Decl : DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3." +"org/TR/html4/strict.dtd\"" -#: ../../library/html.parser.rst:281 +#: ../../library/html.parser.rst:288 msgid "Parsing an element with a few attributes and a title:" msgstr "剖析一個具有一些屬性和標題的元素:" -#: ../../library/html.parser.rst:283 +#: ../../library/html.parser.rst:290 msgid "" ">>> parser.feed('\"The')\n" "Start tag: img\n" @@ -500,13 +510,13 @@ msgstr "" "Data : Python\n" "End tag : h1" -#: ../../library/html.parser.rst:295 +#: ../../library/html.parser.rst:302 msgid "" -"The content of ``script`` and ``style`` elements is returned as is, without " -"further parsing:" -msgstr "``script`` 和 ``style`` 元素的內容按原樣回傳,無需進一步剖析:" +"The content of elements like ``script`` and ``style`` is returned as is, " +"without further parsing:" +msgstr "像是 ``script`` 和 ``style`` 這類元素的內容將按原樣回傳,無需進一步的剖析:" -#: ../../library/html.parser.rst:298 +#: ../../library/html.parser.rst:305 msgid "" ">>> parser.feed('