From 8d6a86756ee5c5cc35ef08e623ea72246f0f603b Mon Sep 17 00:00:00 2001 From: Matt Wang Date: Sun, 11 May 2025 23:19:42 +0800 Subject: [PATCH] Translate `whatsnew/3.12.po` Co-Authored-By: Claude Opus 4.6 (1M context) --- whatsnew/3.12.po | 741 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 698 insertions(+), 43 deletions(-) diff --git a/whatsnew/3.12.po b/whatsnew/3.12.po index 8cd3ef51421..4248b1cb0f4 100644 --- a/whatsnew/3.12.po +++ b/whatsnew/3.12.po @@ -34,12 +34,12 @@ msgid "" "Python 3.12 was released on October 2, 2023. For full details, see the :ref:" "`changelog `." msgstr "" -"本文介紹了 Python 3.12 與 3.11 相比多了哪些新功能。 Python 3.12 於 2023 年 " -"10 月 2 日發布。完整詳情請見 :ref:`changelog `。" +"本文介紹了 Python 3.12 與 3.11 相比多了哪些新功能。Python 3.12 於 2023 年 10 " +"月 2 日發布。完整詳情請見 :ref:`changelog `。" #: ../../whatsnew/3.12.rst:54 msgid ":pep:`693` -- Python 3.12 Release Schedule" -msgstr ":pep:`693` -- Python 3.12 發佈時程" +msgstr ":pep:`693` -- Python 3.12 發布時程" #: ../../whatsnew/3.12.rst:57 msgid "Summary -- Release highlights" @@ -132,6 +132,8 @@ msgid "" "`Improved 'Did you mean ...' suggestions `_ for :" "exc:`NameError`, :exc:`ImportError`, and :exc:`SyntaxError` exceptions" msgstr "" +"改進了 :exc:`NameError`、:exc:`ImportError` 和 :exc:`SyntaxError` 例外的\\ `" +"「你的意思是... (Did you mean ...)」建議 `_" #: ../../whatsnew/3.12.rst:106 msgid "Python data model improvements:" @@ -142,10 +144,12 @@ msgid "" ":ref:`PEP 688 `, using the :ref:`buffer protocol " "` from Python" msgstr "" +":ref:`PEP 688 `,使用 Python 的\\ :ref:`緩衝區協定 " +"`" #: ../../whatsnew/3.12.rst:111 msgid "Significant improvements in the standard library:" -msgstr "標準函式庫中的顯著改進" +msgstr "標準函式庫中的顯著改進:" #: ../../whatsnew/3.12.rst:113 msgid "The :class:`pathlib.Path` class now supports subclassing" @@ -167,6 +171,8 @@ msgid "" ":func:`isinstance` checks against :func:`runtime-checkable protocols ` enjoy a speed up of between two and 20 times" msgstr "" +":func:`isinstance` 對 :func:`可在 runtime 檢查的協定 ` 的檢查速度可提高 2 到 20 倍" #: ../../whatsnew/3.12.rst:119 msgid "" @@ -186,6 +192,8 @@ msgid "" "Due to the changes in :ref:`PEP 701 `, producing tokens " "via the :mod:`tokenize` module is up to 64% faster." msgstr "" +"由於 :ref:`PEP 701 ` 中的更改,透過 :mod:`tokenize` 模組" +"產生 token 的速度提高了 64%。" #: ../../whatsnew/3.12.rst:126 msgid "Security improvements:" @@ -198,6 +206,9 @@ msgid "" "github.com/hacl-star/hacl-star/>`__ project. These builtin implementations " "remain as fallbacks that are only used when OpenSSL does not provide them." msgstr "" +"將於 :mod:`hashlib` 中 SHA1、SHA3、SHA2-384、SHA2-512 和 MD5 內建實作替換為來" +"自 `HACL* `__ 專案的經正式驗證的程式" +"碼。這些內建實作仍然作為備援方案 (fallback),僅在 OpenSSL 不提供它們時使用。" #: ../../whatsnew/3.12.rst:134 msgid "C API improvements:" @@ -209,7 +220,7 @@ msgstr ":ref:`PEP 697 `,不穩定 C API 層" #: ../../whatsnew/3.12.rst:137 msgid ":ref:`PEP 683 `, immortal objects" -msgstr "" +msgstr ":ref:`PEP 683 `,不滅物件 (immortal objects)" #: ../../whatsnew/3.12.rst:139 msgid "CPython implementation improvements:" @@ -218,14 +229,15 @@ msgstr "CPython 實作改進:" #: ../../whatsnew/3.12.rst:141 msgid ":ref:`PEP 709 `, comprehension inlining" msgstr "" +":ref:`PEP 709 `,行內綜合運算 (comprehension inlining)" #: ../../whatsnew/3.12.rst:142 msgid ":ref:`CPython support ` for the Linux ``perf`` profiler" -msgstr "" +msgstr "對 Linux ``perf`` 分析器的 :ref:`CPython 支援 `" #: ../../whatsnew/3.12.rst:143 msgid "Implement stack overflow protection on supported platforms" -msgstr "" +msgstr "在支援的平台上實作堆疊溢位保護" #: ../../whatsnew/3.12.rst:145 msgid "New typing features:" @@ -252,6 +264,8 @@ msgid "" ":pep:`623`: Remove ``wstr`` from Unicode objects in Python's C API, reducing " "the size of every :class:`str` object by at least 8 bytes." msgstr "" +":pep:`623`:從 Python C API 中的 Unicode 物件中刪除 ``wstr``,將每個 :class:" +"`str` 物件的大小減少至少 8 個位元組。" #: ../../whatsnew/3.12.rst:156 msgid "" @@ -261,6 +275,11 @@ msgid "" "distutils-legacy.html>`__ package continues to provide :mod:`!distutils`, if " "you still require it in Python 3.12 and beyond." msgstr "" +":pep:`632`:刪除 :mod:`!distutils` 套件。請參閱\\ `遷移指南 `_\\ 以查看替換原有 API 的建議。如果你" +"在 Python 3.12 及後續版本中仍然需要它們,第三方套件 `Setuptools `__ 會繼續提" +"供 :mod:`!distutils`。" #: ../../whatsnew/3.12.rst:163 msgid "" @@ -299,6 +318,8 @@ msgid "" "syntax that left the scope of type parameters unclear and required explicit " "declarations of variance." msgstr "" +":pep:`484` 下的泛型類別和函式是使用較冗長語法來宣告,這使得型別參數的作用域不" +"明確,並且需要顯式地宣告變異數 (variance)。" #: ../../whatsnew/3.12.rst:187 msgid "" @@ -306,6 +327,8 @@ msgid "" "`generic classes ` and :ref:`functions `::" msgstr "" +":pep:`695` 引入了一種新的、更簡潔和顯式的方法來建立\\ :ref:`泛型類別 " +"`\\ 和\\ :ref:`函式 `: ::" #: ../../whatsnew/3.12.rst:190 msgid "" @@ -335,6 +358,9 @@ msgid "" "` using the :keyword:`type` statement, which creates an " "instance of :class:`~typing.TypeAliasType`::" msgstr "" +"此外,PEP 引入了一種使用\\ :keyword:`型別 `\\ 陳述式來宣告\\ :ref:`型別" +"別名 `\\ 的新方法,該方法會建立一個 :class:`~typing." +"TypeAliasType` 的實例: ::" #: ../../whatsnew/3.12.rst:204 msgid "type Point = tuple[float, float]" @@ -354,6 +380,9 @@ msgid "" "`~typing.ParamSpec` parameters, as well as :class:`~typing.TypeVar` " "parameters with bounds or constraints::" msgstr "" +"新的語法允許宣告 :class:`~typing.TypeVarTuple` 和 :class:`~typing.ParamSpec` " +"參數,以及帶有邊界 (bounds) 或限制 (constraints) 的 :class:`~typing.TypeVar` " +"參數: ::" #: ../../whatsnew/3.12.rst:214 msgid "" @@ -375,6 +404,9 @@ msgid "" "evaluation `). This means type aliases are able to refer to " "other types defined later in the file." msgstr "" +"透過此語法建立之型別別名的值和型別變數的邊界和限制,僅會根據需求來求值(請參" +"閱\\ :ref:`延遲求值 (lazy evaluation) `)。這意味著型別別名" +"可以參照在檔案中後續定義的其他型別。" #: ../../whatsnew/3.12.rst:224 msgid "" @@ -385,6 +417,10 @@ msgid "" "module scope after the class is defined. See :ref:`type-params` for a " "detailed description of the runtime semantics of type parameters." msgstr "" +"透過型別參數串列宣告的型別參數在宣告作用域及任何巢狀作用域內皆為可見,但在外" +"部作用域內不可見。例如,它們可以用在泛型類別方法的型別註釋中或類別主體中。但" +"是,在定義類別後,它們不能在模組作用域內使用。有關型別參數的 runtime 語義的詳" +"細描述,請參閱 :ref:`type-params`。" #: ../../whatsnew/3.12.rst:231 msgid "" @@ -394,6 +430,10 @@ msgid "" "differently with enclosing class scopes. In Python 3.13, :term:`annotations " "` will also be evaluated in annotation scopes." msgstr "" +"為了支援這些作用域語義而引入了一種新的作用域,即\\ :ref:`註釋作用域 " +"(annotation scope) `。註釋作用域的行為在很大程度上類似於函" +"式作用域,但與封閉類別作用域的交互方式不同。在 Python 3.13 中,:term:`註釋 " +"`\\ 也將在註釋作用域內進行求值。" #: ../../whatsnew/3.12.rst:237 msgid "See :pep:`695` for more details." @@ -409,7 +449,7 @@ msgstr "" #: ../../whatsnew/3.12.rst:245 msgid "PEP 701: Syntactic formalization of f-strings" -msgstr "" +msgstr "PEP 701:f 字串的語法形式化" #: ../../whatsnew/3.12.rst:247 msgid "" @@ -419,6 +459,10 @@ msgid "" "string, multi-line expressions, comments, backslashes, and unicode escape " "sequences. Let's cover these in detail:" msgstr "" +":pep:`701` 解除了 :term:`f 字串 `\\ 在使用上的一些限制。f 字串內的" +"運算式元件現在可以是任何有效的 Python 運算式,包括重複使用與包含 f 字串相同的" +"引號的字串、多行運算式、註解、反斜線和 unicode 轉義序列。讓我們詳細介紹一下這" +"些內容:" #: ../../whatsnew/3.12.rst:253 msgid "" @@ -427,6 +471,9 @@ msgid "" "available quotes (like using double quotes or triple quotes if the f-string " "uses single quotes). In Python 3.12, you can now do things like this:" msgstr "" +"引號重用:在 Python 3.11 中,重複使用與封閉的 f 字串相同的引號會引發 :exc:" +"`SyntaxError`,強制使用者使用其他可用的引號(例如,如果 f 字串使用單引號,則" +"使用雙引號或三引號)。在 Python 3.12 中,你現在可以執行以下操作:" #: ../../whatsnew/3.12.rst:262 msgid "" @@ -435,12 +482,17 @@ msgid "" "expression component of f-strings made it impossible to nest f-strings " "arbitrarily. In fact, this is the most nested f-string that could be written:" msgstr "" +"請注意,在此更改之前,對於如何嵌套 f 字串沒有明確的限制,但事實上字串引號不能" +"在 f 字串的運算式元件內重複使用,因此無法任意嵌套 f 字串。事實上,這是嵌套層" +"數最多的 f 字串:" #: ../../whatsnew/3.12.rst:270 msgid "" "As now f-strings can contain any valid Python expression inside expression " "components, it is now possible to nest f-strings arbitrarily:" msgstr "" +"由於現在 f 字串可以在運算式元件內包含任何有效的 Python 運算式,因此現在可以任" +"意嵌套 f 字串:" #: ../../whatsnew/3.12.rst:276 msgid "" @@ -450,6 +502,10 @@ msgid "" "multiple lines), making them harder to read. In Python 3.12 you can now " "define f-strings spanning multiple lines, and add inline comments:" msgstr "" +"多行運算式和註解:在 Python 3.11 中,f 字串運算式必須在單行中定義,即使 f 字" +"串中的運算式通常可以跨越多行(就像在多行上定義的 list 常值一樣),從而使它們" +"更難閱讀。在 Python 3.12 中,你現在可以定義跨越多行的 f 字串,並新增內嵌註" +"解:" #: ../../whatsnew/3.12.rst:290 msgid "" @@ -459,6 +515,10 @@ msgid "" "contain the ``\\N`` part that previously could not be part of expression " "components of f-strings. Now, you can define expressions like this:" msgstr "" +"反斜線和 unicode 字元:在 Python 3.12 之前,f 字串運算式不能包含任何 ``\\`` " +"字元。這也影響了 unicode :ref:`轉義序列 `\\ (例如 " +"``\\N{snowman}``),因為它們包含 ``\\N`` 部分,該部分以前不能是 f 字串運算式" +"元件的一部分。現在,你可以像這樣定義運算式:" #: ../../whatsnew/3.12.rst:303 msgid "See :pep:`701` for more details." @@ -471,6 +531,9 @@ msgid "" "f-strings are more precise and include the exact location of the error. For " "example, in Python 3.11, the following f-string raises a :exc:`SyntaxError`:" msgstr "" +"作為此功能實作方式的積極副作用(透過使用 :pep:`PEG 剖析器 <617>` 剖析 f 字" +"串),現在 f 字串的錯誤訊息更加精確,並且包含錯誤的確切位置。例如,在 Python " +"3.11 中,以下 f 字串會引發 :exc:`SyntaxError`:" #: ../../whatsnew/3.12.rst:310 msgid "" @@ -493,6 +556,9 @@ msgid "" "In Python 3.12, as f-strings are parsed with the PEG parser, error messages " "can be more precise and show the entire line:" msgstr "" +"但錯誤訊息不包括行內錯誤的確切位置,並且還人為地將運算式用括號括起來。在 " +"Python 3.12 中,由於使用 PEG 剖析器剖析 f 字串,因此錯誤訊息可以更精確並顯示" +"整行:" #: ../../whatsnew/3.12.rst:322 msgid "" @@ -514,6 +580,9 @@ msgid "" "Maureira-Fredes and Marta Gómez in :gh:`102856`. PEP written by Pablo " "Galindo, Batuhan Taskaya, Lysandros Nikolaou and Marta Gómez)." msgstr "" +"(由 Pablo Galindo、Batuhan Taskaya、Lysandros Nikolaou、Cristián Maureira-" +"Fredes 和 Marta Gómez 在 :gh:`102856` 中貢獻。PEP 由 Pablo Galindo、Batuhan " +"Taskaya、Lysandros Nikolaou 和 Marta Gómez 編寫)。" #: ../../whatsnew/3.12.rst:337 msgid "PEP 684: A Per-Interpreter GIL" @@ -530,13 +599,15 @@ msgstr "" ":pep:`684` 引入了直譯器各別持有的 :term:`GIL `,因此" "子直譯器現在可以使用各個直譯器特有的 GIL 來建立。這使得 Python 程式可以充分利" "用多個 CPU 核心。目前這僅透過 C-API 使用,不過 Python API :pep:`預計在 3.13 " -"中釋出 <554>`。" +"中提供 <554>`。" #: ../../whatsnew/3.12.rst:345 msgid "" "Use the new :c:func:`Py_NewInterpreterFromConfig` function to create an " "interpreter with its own GIL:" msgstr "" +"使用新的 :c:func:`Py_NewInterpreterFromConfig` 函式建立一個具有自己的 GIL 的" +"直譯器:" #: ../../whatsnew/3.12.rst:348 msgid "" @@ -567,6 +638,8 @@ msgid "" "For further examples how to use the C-API for sub-interpreters with a per-" "interpreter GIL, see ``Modules/_xxsubinterpretersmodule.c``." msgstr "" +"關於如何使用子直譯器的 C API 搭配各直譯器獨立的 GIL 的更多範例,請參見 " +"``Modules/_xxsubinterpretersmodule.c``。" #: ../../whatsnew/3.12.rst:364 msgid "(Contributed by Eric Snow in :gh:`104210`, etc.)" @@ -574,7 +647,7 @@ msgstr "(由 Eric Snow 於 :gh:`104210` 等貢獻。)" #: ../../whatsnew/3.12.rst:369 msgid "PEP 669: Low impact monitoring for CPython" -msgstr "" +msgstr "PEP 669:CPython 的低影響監控" #: ../../whatsnew/3.12.rst:371 msgid "" @@ -585,6 +658,10 @@ msgid "" "near-zero overhead debuggers and coverage tools. See :mod:`sys.monitoring` " "for details." msgstr "" +":pep:`669` 定義了一個新的 :mod:`API ` ,用於分析器、偵錯器和" +"其他工具來監視 CPython 中的事件。它涵蓋了廣泛的事件,包括呼叫、回傳、行、例" +"外、跳躍等等。這意味著你只需為所使用的功能承擔開銷,為接近零開銷的偵錯器和覆" +"蓋率工具提供支援。有關詳細資訊,請參閱 :mod:`sys.monitoring`。" #: ../../whatsnew/3.12.rst:379 msgid "(Contributed by Mark Shannon in :gh:`103082`.)" @@ -600,6 +677,8 @@ msgid "" "` from Python code. Classes that implement the :meth:`~object." "__buffer__` method are now usable as buffer types." msgstr "" +":pep:`688` 引入了一種從 Python 程式碼使用 :ref:`緩衝區協定 ` " +"的方法。實作 :meth:`~object.__buffer__` 方法的類別現在可用作緩衝區型別。" #: ../../whatsnew/3.12.rst:390 msgid "" @@ -608,10 +687,13 @@ msgid "" "`inspect.BufferFlags` enum represents the flags that can be used to " "customize buffer creation. (Contributed by Jelle Zijlstra in :gh:`102500`.)" msgstr "" +"新的 :class:`collections.abc.Buffer` ABC 提供了一種表示緩衝區物件的標準方法," +"例如在型別註釋中。新的 :class:`inspect.BufferFlags` 列舉表示可用於自訂緩衝區" +"建立的旗標。(由 Jelle Zijlstra 在 :gh:`102500` 中貢獻。)" #: ../../whatsnew/3.12.rst:399 msgid "PEP 709: Comprehension inlining" -msgstr "" +msgstr "PEP 709:行內綜合運算" #: ../../whatsnew/3.12.rst:401 msgid "" @@ -620,6 +702,9 @@ msgid "" "comprehension. This speeds up execution of a comprehension by up to two " "times. See :pep:`709` for further details." msgstr "" +"字典、串列和集合綜合運算現在是行內的,而不是為綜合運算的每次執行建立一個新的" +"一次性函式物件。這可以將綜合運算的執行速度提高兩倍。請參閱 :pep:`709` 以了解" +"更多詳細資訊。" #: ../../whatsnew/3.12.rst:406 msgid "" @@ -627,12 +712,16 @@ msgid "" "variable of the same name in the outer scope, nor are they visible after the " "comprehension. Inlining does result in a few visible behavior changes:" msgstr "" +"綜合運算的疊代變數保持隔離,不會覆蓋外部作用域中的同名變數,綜合運算後它們也" +"不可見。行內化確實會導致一些明顯的行為改變:" #: ../../whatsnew/3.12.rst:410 msgid "" "There is no longer a separate frame for the comprehension in tracebacks, and " "tracing/profiling no longer shows the comprehension as a function call." msgstr "" +"回溯中不再有用於綜合運算的單獨堆疊框架,並且追蹤/分析不再將綜合運算顯示為函" +"式呼叫。" #: ../../whatsnew/3.12.rst:412 msgid "" @@ -640,6 +729,8 @@ msgid "" "each comprehension; instead, the comprehension's locals will be included in " "the parent function's symbol table." msgstr "" +":mod:`symtable` 模組將不再為每個綜合運算產生子符號表;相反,綜合運算的局部變" +"數將包含在父函式的符號表中。" #: ../../whatsnew/3.12.rst:415 msgid "" @@ -647,6 +738,8 @@ msgid "" "outside the comprehension, and no longer includes the synthetic ``.0`` " "variable for the comprehension \"argument\"." msgstr "" +"現在,在綜合運算內呼叫 :func:`locals` 包含來自綜合運算外部的變數,並且不再包" +"含用於綜合運算\\ ``參數``\\ 的合成 ``.0`` 變數。" #: ../../whatsnew/3.12.rst:418 msgid "" @@ -657,6 +750,11 @@ msgid "" "error, first create a list of keys to iterate over: ``keys = list(locals()); " "[k for k in keys]``." msgstr "" +"當在追蹤下執行(例如程式碼覆蓋率測量)時,直接疊代 ``locals()``\\ (例如 " +"``[k for k in locals()]``)的綜合運算可能會看到 \"RuntimeError: dictionary " +"changed size during iteration\"。這與在 ``for k in locals():`` 中已經看到的行" +"為相同。為了避免錯誤,首先建立一個要疊代的鍵串列:``keys = list(locals()); " +"[k for k in keys]``。" #: ../../whatsnew/3.12.rst:425 msgid "(Contributed by Carl Meyer and Vladimir Matveev in :pep:`709`.)" @@ -672,6 +770,8 @@ msgid "" "the error messages displayed by the interpreter when a :exc:`NameError` is " "raised to the top level. (Contributed by Pablo Galindo in :gh:`98254`.)" msgstr "" +"當 :exc:`NameError` 提升到頂層時,標準函式庫中的模組現在可能會被建議作為直譯" +"器顯示的錯誤訊息的一部分。(由 Pablo Galindo 在 :gh:`98254` 中貢獻。)" #: ../../whatsnew/3.12.rst:439 msgid "" @@ -681,6 +781,10 @@ msgid "" "will include ``self.`` instead of the closest match in the method " "scope. (Contributed by Pablo Galindo in :gh:`99139`.)" msgstr "" +"改進實例的 :exc:`NameError` 例外的錯誤建議。現在,如果在方法中引發 :exc:" +"`NameError` 並且該實例具有與例外中的名稱完全相同的屬性,則建議將包含 ``self." +"`` 而不是方法作用域中的最接近匹配。(由 Pablo Galindo 在 :gh:`99139` 中" +"貢獻。)" #: ../../whatsnew/3.12.rst:459 msgid "" @@ -688,6 +792,8 @@ msgid "" "from y`` instead of ``from y import x``. (Contributed by Pablo Galindo in :" "gh:`98931`.)" msgstr "" +"改進當使用者鍵入 ``import x from y`` 而不是 ``from y import x`` 時出現的 :" +"exc:`SyntaxError` 錯誤訊息。(由 Pablo Galindo 在 :gh:`98931` 中貢獻。)" #: ../../whatsnew/3.12.rst:469 msgid "" @@ -696,6 +802,9 @@ msgid "" "based on the available names in ````. (Contributed by Pablo Galindo " "in :gh:`91058`.)" msgstr "" +"由失敗的 ``from import `` 陳述式引發的 :exc:`ImportError` 例外" +"現在包含基於 ```` 中可用名稱的 ```` 值的建議。(由 Pablo " +"Galindo 在 :gh:`91058` 中貢獻。)" #: ../../whatsnew/3.12.rst:480 msgid "New Features Related to Type Hints" @@ -710,7 +819,7 @@ msgstr "" #: ../../whatsnew/3.12.rst:488 msgid "PEP 692: Using ``TypedDict`` for more precise ``**kwargs`` typing" -msgstr "" +msgstr "PEP 692:使用 ``TypedDict`` 進行更精確的 ``**kwargs`` 型別註釋" #: ../../whatsnew/3.12.rst:490 msgid "" @@ -718,12 +827,15 @@ msgid "" "allowed for valid annotations only in cases where all of the ``**kwargs`` " "were of the same type." msgstr "" +"在 :pep:`484` 引入之函式簽名中標註 ``**kwargs`` 僅在所有 ``**kwargs`` 屬於同" +"一型別的情況下才允許有效註釋。" #: ../../whatsnew/3.12.rst:494 msgid "" ":pep:`692` specifies a more precise way of typing ``**kwargs`` by relying on " "typed dictionaries::" msgstr "" +":pep:`692` 指定了一種更精確的方式,透過依賴型別化字典來標註 ``**kwargs``: ::" #: ../../whatsnew/3.12.rst:497 msgid "" @@ -753,7 +865,7 @@ msgstr "(由 Franek Magiera 於 :gh:`103629` 中貢獻。)" #: ../../whatsnew/3.12.rst:512 msgid "PEP 698: Override Decorator for Static Typing" -msgstr "PEP 698:覆蓋靜態型別的裝飾器" +msgstr "PEP 698:用於靜態型別的 Override 裝飾器" #: ../../whatsnew/3.12.rst:514 msgid "" @@ -763,6 +875,9 @@ msgid "" "mistakes where a method that is intended to override something in a base " "class does not in fact do so." msgstr "" +"一個新的裝飾器 :func:`typing.override` 已新增到 :mod:`typing` 模組中。它向型" +"別檢查器指示該方法旨在覆寫超類別中的方法。這允許型別檢查器捕獲錯誤,其中旨在" +"覆寫基底類別中某些內容的方法實際上並未這樣做。" #: ../../whatsnew/3.12.rst:520 msgid "Example::" @@ -798,7 +913,7 @@ msgstr "" " return \"yellow\"\n" "\n" "class BadChild(Base):\n" -" @override # 型別檢查錯誤:未覆寫 Base.get_color\n" +" @override # 型別檢查器錯誤:未覆寫 Base.get_color\n" " def get_colour(self) -> str:\n" " return \"red\"" @@ -819,6 +934,8 @@ msgid "" "The parser now raises :exc:`SyntaxError` when parsing source code containing " "null bytes. (Contributed by Pablo Galindo in :gh:`96670`.)" msgstr "" +"現在,剖析器在剖析包含空位元組的源程式碼時會引發 :exc:`SyntaxError`。(由 " +"Pablo Galindo 在 :gh:`96670` 中貢獻。)" #: ../../whatsnew/3.12.rst:548 msgid "" @@ -830,6 +947,12 @@ msgid "" "exc:`SyntaxError` will eventually be raised, instead of :exc:" "`SyntaxWarning`. (Contributed by Victor Stinner in :gh:`98401`.)" msgstr "" +"不是有效轉義序列的反斜線字元對現在會產生 :exc:`SyntaxWarning`,而不是 :exc:" +"`DeprecationWarning`。例如,``re.compile(\"\\d+\\.\\d+\")`` 現在發出一個 :" +"exc:`SyntaxWarning`\\ (``\"\\d\"`` 是無效的轉義序列,請使用原始字串作為正規" +"表示式:``re.compile(r\"\\d+\\.\\d+\")``)。在未來的 Python 版本中,最終將引" +"發 :exc:`SyntaxError`,而不是 :exc:`SyntaxWarning`。(由 Victor Stinner 在 :" +"gh:`98401` 中貢獻。)" #: ../../whatsnew/3.12.rst:557 msgid "" @@ -838,6 +961,10 @@ msgid "" "exc:`DeprecationWarning`. In a future Python version they will be eventually " "a :exc:`SyntaxError`. (Contributed by Victor Stinner in :gh:`98401`.)" msgstr "" +"值大於 ``0o377`` 的八進位轉義符(例如:``\"\\477\"``)在 Python 3.11 中已棄" +"用,現在會生成 :exc:`SyntaxWarning`,而不是 :exc:`DeprecationWarning`。在未來" +"的 Python 版本中,它們最終將成為 :exc:`SyntaxError`。(由 Victor Stinner 在 :" +"gh:`98401` 中貢獻。)" #: ../../whatsnew/3.12.rst:563 msgid "" @@ -848,6 +975,10 @@ msgid "" "comprehensions (like ``a``) is still disallowed, as per :pep:`572`. " "(Contributed by Nikita Sobolev in :gh:`100581`.)" msgstr "" +"綜合運算目標部分中使用的未儲存的變數現在可以在賦值運算式中使用 (``:=``)。例" +"如,在 ``[(b := 1) for a, b.prop in some_iter]`` 中,現在允許對 ``b`` 進行賦" +"值。請注意,根據 :pep:`572` ,仍然不允許對儲存在綜合運算目標部分中的變數進行" +"賦值(如 ``a``)。(由 Nikita Sobolev 在 :gh:`100581` 中貢獻。)" #: ../../whatsnew/3.12.rst:570 msgid "" @@ -855,6 +986,9 @@ msgid "" "wrapped by a :exc:`RuntimeError`. Context information is added to the " "exception as a :pep:`678` note. (Contributed by Irit Katriel in :gh:`77757`.)" msgstr "" +"類別或型別的 ``__set_name__`` 方法中引發的例外不再由 :exc:`RuntimeError` 包" +"裝。上下文資訊會以 :pep:`678` 註解加入例外。(由 Irit Katriel 在 :gh:`77757` " +"中貢獻。)" #: ../../whatsnew/3.12.rst:574 msgid "" @@ -863,6 +997,9 @@ msgid "" "exc:`ExceptionGroup`. Also changed in version 3.11.4. (Contributed by Irit " "Katriel in :gh:`103590`.)" msgstr "" +"當 ``try-except*`` 構造處理整個 :exc:`ExceptionGroup` 並引發另一個例外時,該" +"例外不再包裝在 :exc:`ExceptionGroup` 中。在 3.11.4 版本中也進行了更改。(由 " +"Irit Katriel 在 :gh:`103590` 中貢獻。)" #: ../../whatsnew/3.12.rst:579 msgid "" @@ -873,6 +1010,10 @@ msgid "" "chance to execute the GC periodically. (Contributed by Pablo Galindo in :gh:" "`97922`.)" msgstr "" +"垃圾收集器現在僅在 Python 位元組碼評估迴圈的 eval 斷路器機制上運行,而不是在" +"物件分配上運行。GC 也可以在呼叫 :c:func:`PyErr_CheckSignals` 時運行,因此需要" +"長時間運行而不執行任何 Python 程式碼的 C 擴充也有機會定期執行 GC。(由 Pablo " +"Galindo 在 :gh:`97922` 中貢獻。)" #: ../../whatsnew/3.12.rst:586 msgid "" @@ -880,12 +1021,16 @@ msgid "" "arguments of any type instead of just :class:`bool` and :class:`int`. " "(Contributed by Serhiy Storchaka in :gh:`60203`.)" msgstr "" +"所有需要布林參數的內建和擴充可呼叫物件現在接受任何型別的參數,而不僅僅是 :" +"class:`bool` 和 :class:`int`。(由 Serhiy Storchaka 在 :gh:`60203` 中貢獻。)" #: ../../whatsnew/3.12.rst:590 msgid "" ":class:`memoryview` now supports the half-float type (the \"e\" format " "code). (Contributed by Donghee Na and Antoine Pitrou in :gh:`90751`.)" msgstr "" +":class:`memoryview` 現在支援半浮點型別(\"e\" 格式碼)。(由 Donghee Na 和 " +"Antoine Pitrou 在 :gh:`90751` 中貢獻。)" #: ../../whatsnew/3.12.rst:593 msgid "" @@ -893,6 +1038,8 @@ msgid "" "keys and set items. (Contributed by Will Bradshaw, Furkan Onder, and Raymond " "Hettinger in :gh:`101264`.)" msgstr "" +":class:`slice` 物件現在是可雜湊的,允許它們作為字典的鍵和集合的項。(由 Will " +"Bradshaw、Furkan Onder 和 Raymond Hettinger 在 :gh:`101264` 中貢獻。)" #: ../../whatsnew/3.12.rst:596 msgid "" @@ -900,6 +1047,8 @@ msgid "" "commutativity when summing floats or mixed ints and floats. (Contributed by " "Raymond Hettinger in :gh:`100425`.)" msgstr "" +":func:`sum` 現在使用 Neumaier 求和來提高對浮點數或混合整數和浮點數求和時的準" +"確性和交換性。(由 Raymond Hettinger 在 :gh:`100425` 中貢獻。)" #: ../../whatsnew/3.12.rst:600 msgid "" @@ -907,6 +1056,9 @@ msgid "" "when parsing source code containing null bytes. (Contributed by Pablo " "Galindo in :gh:`96670`.)" msgstr "" +"現在,在剖析包含空位元組的源程式碼時,:func:`ast.parse` 會引發 :exc:" +"`SyntaxError`,而不是 :exc:`ValueError`。(由 Pablo Galindo 在 :gh:`96670` 中" +"貢獻。)" #: ../../whatsnew/3.12.rst:604 msgid "" @@ -917,12 +1069,19 @@ msgid "" "for details. In Python 3.14, the default will switch to ``'data'``. " "(Contributed by Petr Viktorin in :pep:`706`.)" msgstr "" +":mod:`tarfile` 和 :func:`shutil.unpack_archive` 中的提取方法有一個新的 " +"*filter* 參數,該參數允許限制可能令人驚訝或危險的 tar 功能,例如在目標目錄之" +"外建立檔案。有關詳細資訊,請參閱\\ :ref:`tarfile 提取過濾器 `。在 Python 3.14 中,預設將切換為 ``'data'``。(由 Petr " +"Viktorin 在 :pep:`706` 中貢獻。)" #: ../../whatsnew/3.12.rst:612 msgid "" ":class:`types.MappingProxyType` instances are now hashable if the underlying " "mapping is hashable. (Contributed by Serhiy Storchaka in :gh:`87995`.)" msgstr "" +"如果底層對映是可雜湊的,則 :class:`types.MappingProxyType` 實例現在是可雜湊" +"的。(由 Serhiy Storchaka 在 :gh:`87995` 中貢獻。)" #: ../../whatsnew/3.12.rst:616 msgid "" @@ -962,6 +1121,8 @@ msgid "" "The :class:`array.array` class now supports subscripting, making it a :term:" "`generic type`. (Contributed by Jelle Zijlstra in :gh:`98658`.)" msgstr "" +":class:`array.array` 類別現在支援下標,使其成為\\ :term:`泛型型別 `。(由 Jelle Zijlstra 在 :gh:`98658` 中貢獻。)" #: ../../whatsnew/3.12.rst:643 msgid "asyncio" @@ -974,6 +1135,9 @@ msgid "" "writing to sockets and uses :meth:`~socket.socket.sendmsg` if the platform " "supports it. (Contributed by Kumar Aditya in :gh:`91166`.)" msgstr "" +"asyncio 中寫入 socket 的效能得到了顯著提高。:mod:`asyncio` 現在可以避免在寫" +"入 socket 時進行不必要的複製,並在平台支援的情況下使用 :meth:`~socket.socket." +"sendmsg`。(由 Kumar Aditya 在 :gh:`91166` 中貢獻。)" #: ../../whatsnew/3.12.rst:650 msgid "" @@ -982,6 +1146,10 @@ msgid "" "eager task execution, making some use-cases 2x to 5x faster. (Contributed by " "Jacob Bower & Itamar Oren in :gh:`102853`, :gh:`104140`, and :gh:`104138`)" msgstr "" +"新增 :func:`asyncio.eager_task_factory` 和 :func:`asyncio." +"create_eager_task_factory` 函式以允許選擇事件迴圈來執行急切任務,使某些用例速" +"度提高 2 到 5 倍。(由 Jacob Bower 和 Itamar Oren 在 :gh:`102853`、:gh:" +"`104140` 和 :gh:`104138` 中貢獻)" #: ../../whatsnew/3.12.rst:655 msgid "" @@ -989,6 +1157,9 @@ msgid "" "if :func:`os.pidfd_open` is available and functional instead of :class:`!" "asyncio.ThreadedChildWatcher`. (Contributed by Kumar Aditya in :gh:`98024`.)" msgstr "" +"在 Linux 上,如果 :func:`os.pidfd_open` 可用且功能正常,:mod:`asyncio` 預設會" +"使用 :class:`!asyncio.PidfdChildWatcher` 而非 :class:`!asyncio." +"ThreadedChildWatcher`。(由 Kumar Aditya 在 :gh:`98024` 中貢獻。)" #: ../../whatsnew/3.12.rst:660 msgid "" @@ -997,18 +1168,26 @@ msgid "" "ThreadedChildWatcher` otherwise), so manually configuring a child watcher is " "not recommended. (Contributed by Kumar Aditya in :gh:`94597`.)" msgstr "" +"事件迴圈現在會為每個平台使用最佳的子行程監看器 (child watcher)(如果支援則使" +"用 :class:`!asyncio.PidfdChildWatcher`,否則使用 :class:`!asyncio." +"ThreadedChildWatcher`),因此不建議手動設定子行程監看器。(由 Kumar Aditya " +"在 :gh:`94597` 中貢獻。)" #: ../../whatsnew/3.12.rst:666 msgid "" "Add *loop_factory* parameter to :func:`asyncio.run` to allow specifying a " "custom event loop factory. (Contributed by Kumar Aditya in :gh:`99388`.)" msgstr "" +":func:`asyncio.run` 新增 *loop_factory* 參數以允許指定自訂事件迴圈工廠函式。" +"(由 Kumar Aditya 在 :gh:`99388` 中貢獻。)" #: ../../whatsnew/3.12.rst:670 msgid "" "Add C implementation of :func:`asyncio.current_task` for 4x-6x speedup. " "(Contributed by Itamar Oren and Pranav Thulasiram Bhat in :gh:`100344`.)" msgstr "" +"新增 :func:`asyncio.current_task` 的 C 實作,加速了 4-6 倍。(由 Itamar Oren " +"和 Pranav Thulasiram Bhat 在 :gh:`100344` 中貢獻。)" #: ../../whatsnew/3.12.rst:673 msgid "" @@ -1016,12 +1195,16 @@ msgid "" "`asyncio` does not support legacy generator-based coroutines. (Contributed " "by Kumar Aditya in :gh:`102748`.)" msgstr "" +":func:`asyncio.iscoroutine` 現在為產生器回傳 ``False``,因為 :mod:`asyncio` " +"不支援傳統的基於產生器的協程。(由 Kumar Aditya 在 :gh:`102748` 中貢獻。)" #: ../../whatsnew/3.12.rst:677 msgid "" ":func:`asyncio.wait` and :func:`asyncio.as_completed` now accepts generators " "yielding tasks. (Contributed by Kumar Aditya in :gh:`78530`.)" msgstr "" +":func:`asyncio.wait` 和 :func:`asyncio.as_completed` 現在接受使用產生器來生成" +"任務。(由 Kumar Aditya 在 :gh:`78530` 中貢獻。)" #: ../../whatsnew/3.12.rst:682 msgid "calendar" @@ -1033,6 +1216,8 @@ msgid "" "the year and days of the week. (Contributed by Prince Roshan in :gh:" "`103636`.)" msgstr "" +"新增列舉 :data:`calendar.Month` 和 :data:`calendar.Day` 來定義一年中的月份和" +"一週的日期。(由 Prince Roshan 在 :gh:`103636` 中貢獻。)" #: ../../whatsnew/3.12.rst:689 msgid "csv" @@ -1044,6 +1229,9 @@ msgid "" "provide finer grained control of ``None`` and empty strings by :class:`~csv." "reader` and :class:`~csv.writer` objects." msgstr "" +"新增 :const:`csv.QUOTE_NOTNULL` 和 :const:`csv.QUOTE_STRINGS` 旗標,為 :" +"class:`~csv.reader` 和 :class:`~csv.writer` 物件提供對 ``None`` 和空字串更細" +"緻的控制。" #: ../../whatsnew/3.12.rst:696 msgid "dis" @@ -1057,12 +1245,18 @@ msgid "" "pseudo instructions. Use the new :data:`dis.hasarg` collection instead. " "(Contributed by Irit Katriel in :gh:`94216`.)" msgstr "" +"偽指令操作碼(由編譯器使用,但不會出現在可執行位元組碼中)現在在 :mod:`dis` " +"模組中公開。:opcode:`HAVE_ARGUMENT` 仍然與真實操作碼相關,但對於偽指令沒有用" +"處。請改用新的 :data:`dis.hasarg` 集合。(由 Irit Katriel 在 :gh:`94216` 中貢" +"獻。)" #: ../../whatsnew/3.12.rst:706 msgid "" "Add the :data:`dis.hasexc` collection to signify instructions that set an " "exception handler. (Contributed by Irit Katriel in :gh:`94216`.)" msgstr "" +"新增 :data:`dis.hasexc` 集合來表示設定例外處理程序的指令。(由 Irit Katriel " +"在 :gh:`94216` 中貢獻。)" #: ../../whatsnew/3.12.rst:710 msgid "fractions" @@ -1073,6 +1267,8 @@ msgid "" "Objects of type :class:`fractions.Fraction` now support float-style " "formatting. (Contributed by Mark Dickinson in :gh:`100161`.)" msgstr "" +":class:`fractions.Fraction` 型別的物件現在支援浮點樣式格式化。(由 Mark " +"Dickinson 在 :gh:`100161` 中貢獻。)" #: ../../whatsnew/3.12.rst:716 msgid "importlib.resources" @@ -1158,6 +1354,9 @@ msgid "" "down multiple steps at a time. (Contributed by Matthias Goergens, Mark " "Dickinson, and Raymond Hettinger in :gh:`94906`.)" msgstr "" +"擴充 :func:`math.nextafter` 來包含一個 *steps* 引數,用於一次向上或向下移動多" +"步。(由 Matthias Goergens、Mark Dickinson 和 Raymond Hettinger 在 :gh:" +"`94906` 貢獻。)" #: ../../whatsnew/3.12.rst:757 msgid "os" @@ -1169,6 +1368,8 @@ msgid "" "func:`os.pidfd_open` in non-blocking mode. (Contributed by Kumar Aditya in :" "gh:`93312`.)" msgstr "" +"新增 :data:`os.PIDFD_NONBLOCK` 以便在非阻塞模式下使用 :func:`os.pidfd_open` " +"為行程打開檔案描述器。(由 Kumar Aditya 在 :gh:`93312` 中貢獻。)" #: ../../whatsnew/3.12.rst:763 msgid "" @@ -1176,6 +1377,8 @@ msgid "" "to check if the entry is a junction. (Contributed by Charles Machalow in :gh:" "`99547`.)" msgstr "" +":class:`os.DirEntry` 現在包含一個 :meth:`os.DirEntry.is_junction` 方法來檢查" +"條目是否為連結點。(由 Charles Machalow 在 :gh:`99547` 中貢獻。)" #: ../../whatsnew/3.12.rst:767 msgid "" @@ -1183,6 +1386,9 @@ msgid "" "functions on Windows for enumerating drives, volumes and mount points. " "(Contributed by Steve Dower in :gh:`102519`.)" msgstr "" +"在 Windows 上新增 :func:`os.listdrives`、:func:`os.listvolumes` 和 :func:`os." +"listmounts` 函式,用於列舉磁碟機 (drives)、磁碟區 (volumes) 和掛載點 (mount " +"points)。(由 Steve Dower 在 :gh:`102519` 中貢獻。)" #: ../../whatsnew/3.12.rst:771 msgid "" @@ -1196,6 +1402,12 @@ msgid "" "faster on newer releases of Windows. (Contributed by Steve Dower in :gh:" "`99726`.)" msgstr "" +":func:`os.stat` 和 :func:`os.lstat` 現在在 Windows 上更加準確。" +"``st_birthtime`` 欄位現在將填充檔案的建立時間,``st_ctime`` 已棄用,但仍包含" +"建立時間(但將來將回傳最後一次元資料更改,以與其他平台保持一致)。根據你的檔" +"案系統,``st_dev`` 可能高達 64 位元、``st_ino`` 高達 128 位元,並且 " +"``st_rdev`` 始終設定為零而不是錯誤的值。在較新版本的 Windows 上,這兩個功能可" +"能會明顯更快。(由 Steve Dower 在 :gh:`99726` 中貢獻。)" #: ../../whatsnew/3.12.rst:782 msgid "os.path" @@ -1228,6 +1440,9 @@ msgid "" "override the :meth:`pathlib.PurePath.with_segments` method to pass " "information between path instances." msgstr "" +"新增對 :class:`pathlib.PurePath` 和 :class:`pathlib.Path` 子類別化的支援,以" +"及它們的 Posix 和 Windows 特定變體。子類別可以覆寫 :meth:`pathlib.PurePath." +"with_segments` 方法以在路徑實例之間傳遞訊息。" #: ../../whatsnew/3.12.rst:798 msgid "" @@ -1235,6 +1450,8 @@ msgid "" "all file or directory names within them, similar to :func:`os.walk`. " "(Contributed by Stanislav Zmiev in :gh:`90385`.)" msgstr "" +"新增 :meth:`pathlib.Path.walk` 用於遍歷目錄樹並產生其中的所有檔案或目錄名稱," +"類似於 :func:`os.walk`。(由 Stanislav Zmiev 在 :gh:`90385` 中貢獻。)" #: ../../whatsnew/3.12.rst:802 msgid "" @@ -1243,12 +1460,17 @@ msgid "" "consistent with :func:`os.path.relpath`. (Contributed by Domenico Ragusa in :" "gh:`84538`.)" msgstr "" +"將可選參數 *walk_up* 新增至 :meth:`pathlib.PurePath.relative_to` 以允許在結果" +"中插入 ``..`` 條目;此行為與 :func:`os.path.relpath` 更加一致。(由 Domenico " +"Ragusa 在 :gh:`84538` 中貢獻。)" #: ../../whatsnew/3.12.rst:807 msgid "" "Add :meth:`pathlib.Path.is_junction` as a proxy to :func:`os.path." "isjunction`. (Contributed by Charles Machalow in :gh:`99547`.)" msgstr "" +"新增 :meth:`pathlib.Path.is_junction` 作為 :func:`os.path.isjunction` 的代" +"理。(由 Charles Machalow 在 :gh:`99547` 中貢獻。)" #: ../../whatsnew/3.12.rst:810 msgid "" @@ -1257,6 +1479,9 @@ msgid "" "path's case sensitivity, allowing for more precise control over the matching " "process." msgstr "" +"為 :meth:`pathlib.Path.glob`、:meth:`pathlib.Path.rglob` 和 :meth:`pathlib." +"PurePath.match` 新增可選參數 *case_sensitive*,以匹配路徑的大小區分程度,從而" +"更精確控制匹配過程。" #: ../../whatsnew/3.12.rst:815 msgid "platform" @@ -1269,6 +1494,9 @@ msgid "" "2012 and on Windows 11 would return ``Windows-10``. (Contributed by Steve " "Dower in :gh:`89545`.)" msgstr "" +"新增對 Windows 11 和 2012 之後的 Windows Server 版本的偵測支援。之前,在比 " +"Windows Server 2012 更新的 Windows Server 平台和 Windows 11 上的查詢會回傳 " +"``Windows-10``。(由 Steve Dower 在 :gh:`89545` 中貢獻。)" #: ../../whatsnew/3.12.rst:823 msgid "pdb" @@ -1280,6 +1508,8 @@ msgid "" "provide quick access to values like the current frame or the return value. " "(Contributed by Tian Gao in :gh:`103693`.)" msgstr "" +"新增方便的變數來暫時保存偵錯工作階段的值,並提供對當前幀或回傳值等值的快速存" +"取。(由 Tian Gao 貢獻 :gh:`103693`。)" #: ../../whatsnew/3.12.rst:831 msgid "random" @@ -1312,6 +1542,9 @@ msgid "" "the current working directory of the process to *root_dir* to perform " "archiving. (Contributed by Serhiy Storchaka in :gh:`74696`.)" msgstr "" +":func:`shutil.make_archive` 現在將 *root_dir* 引數傳遞給支援它的自訂歸檔器。" +"在這種情況下,它不再暫時將行程的當前工作目錄更改為 *root_dir* 來執行歸檔。" +"(由 Serhiy Storchaka 在 :gh:`74696` 中貢獻。)" #: ../../whatsnew/3.12.rst:848 msgid "" @@ -1320,6 +1553,9 @@ msgid "" "*(typ, val, tb)* triplet. *onerror* is deprecated. (Contributed by Irit " "Katriel in :gh:`102828`.)" msgstr "" +":func:`shutil.rmtree` 現在接受一個新引數 *onexc*,它是一個類似於 *onerror* 的" +"錯誤處理程序,但它需要一個例外實例而不是 *(typ, val, tb)* 三元組。*onerror* " +"已棄用。(由 Irit Katriel 在 :gh:`102828` 中貢獻。)" #: ../../whatsnew/3.12.rst:853 msgid "" @@ -1327,6 +1563,9 @@ msgid "" "matches within *PATH* on Windows even when the given *cmd* includes a " "directory component. (Contributed by Charles Machalow in :gh:`103179`.)" msgstr "" +":func:`shutil.which` 現在會查閱 *PATHEXT* 環境變數來查找 Windows 上 *PATH* 內" +"的匹配項,即使給定的 *cmd* 包含目錄元件也是如此。(由 Charles Machalow 在 :" +"gh:`103179` 中貢獻。)" #: ../../whatsnew/3.12.rst:858 msgid "" @@ -1335,6 +1574,9 @@ msgid "" "directory should be prepended to the search path. (Contributed by Charles " "Machalow in :gh:`103179`.)" msgstr "" +"在 Windows 上查詢可執行檔時,:func:`shutil.which` 將呼叫 " +"``NeedCurrentDirectoryForExePathW`` 以確定是否應將當前工作目錄新增到搜尋路徑" +"前面。(由 Charles Machalow 在 :gh:`103179` 中貢獻。)" #: ../../whatsnew/3.12.rst:863 msgid "" @@ -1342,6 +1584,9 @@ msgid "" "from ``PATHEXT`` prior to a direct match elsewhere in the search path on " "Windows. (Contributed by Charles Machalow in :gh:`103179`.)" msgstr "" +":func:`shutil.which` 將優先回傳 *cmd* 與 ``PATHEXT`` 中元件相匹配的路徑,然後" +"才在 Windows 搜尋路徑中的其他位置進行直接匹配。(由 Charles Machalow 在 :gh:" +"`103179` 中貢獻。)" #: ../../whatsnew/3.12.rst:869 ../../whatsnew/3.12.rst:1560 msgid "sqlite3" @@ -1362,6 +1607,10 @@ msgid "" "control :pep:`249`-compliant :ref:`transaction handling `. (Contributed by Erlend E. Aasland in :gh:`83638`.)" msgstr "" +"將 :attr:`sqlite3.Connection.autocommit` 屬性加入 :class:`sqlite3." +"Connection` 並將 *autocommit* 參數加入 :func:`sqlite3.connect` 以控制與 :pep:" +"`249` 相容的\\ :ref:`事務處理 `。" +"(由 Erlend E. Aasland 在 :gh:`83638` 中貢獻。)" #: ../../whatsnew/3.12.rst:881 msgid "" @@ -1369,6 +1618,9 @@ msgid "" "load_extension`, for overriding the SQLite extension entry point. " "(Contributed by Erlend E. Aasland in :gh:`103015`.)" msgstr "" +"將僅關鍵字參數 *entrypoint* 新增至 :meth:`sqlite3.Connection." +"load_extension`,以覆蓋 SQLite 擴充進入點。(由 Erlend E. Aasland 在 :gh:" +"`103015` 中貢獻。)" #: ../../whatsnew/3.12.rst:886 msgid "" @@ -1376,6 +1628,9 @@ msgid "" "setconfig` to :class:`sqlite3.Connection` to make configuration changes to a " "database connection. (Contributed by Erlend E. Aasland in :gh:`103489`.)" msgstr "" +"將 :meth:`sqlite3.Connection.getconfig` 和 :meth:`sqlite3.Connection." +"setconfig` 新增至 :class:`sqlite3.Connection` 以對資料庫連線進行設定變更。" +"(由 Erlend E. Aasland 在 :gh:`103489` 中貢獻。)" #: ../../whatsnew/3.12.rst:892 msgid "statistics" @@ -1387,6 +1642,8 @@ msgid "" "computing the Spearman correlation of ranked data. (Contributed by Raymond " "Hettinger in :gh:`95861`.)" msgstr "" +"擴充 :func:`statistics.correlation` 以包含為計算排名資料的 Spearman 相關性的 " +"``ranked`` 方法。(由 Raymond Hettinger 在 :gh:`95861` 中貢獻。)" #: ../../whatsnew/3.12.rst:899 msgid "sys" @@ -1398,6 +1655,8 @@ msgid "" "` monitoring API. (Contributed by Mark Shannon in :gh:" "`103082`.)" msgstr "" +"新增 :mod:`sys.monitoring` 命名空間以公開新的 :ref:`PEP 669 ` 監控 API。(由 Mark Shannon 在 :gh:`103082` 中貢獻。)" #: ../../whatsnew/3.12.rst:905 msgid "" @@ -1408,6 +1667,11 @@ msgid "" "Christian Heimes with contributions from Gregory P. Smith [Google] and Mark " "Shannon in :gh:`96123`.)" msgstr "" +"新增 :func:`sys.activate_stack_trampoline` 和 :func:`sys." +"deactivate_stack_trampoline` 用於啟用和停用堆疊分析器 trampolines,以及 :" +"func:`sys.is_stack_trampoline_active` 用於查詢堆疊分析器 trampolines 是否處於" +"活躍狀態。(由 Pablo Galindo 、 Christian Heimes、Gregory P. Smith [Google] " +"和 Mark Shannon 在 :gh:`96123` 中貢獻。)" #: ../../whatsnew/3.12.rst:914 msgid "" @@ -1417,6 +1681,10 @@ msgid "" "data:`sys.last_value` and :data:`sys.last_traceback`. (Contributed by Irit " "Katriel in :gh:`102778`.)" msgstr "" +"新增 :data:`sys.last_exc`,它保存最後一個引發的未處理例外(用於事後偵錯)。棄" +"用舊格式中具有相同資訊的三個欄位::data:`sys.last_type`、:data:`sys." +"last_value` 和 :data:`sys.last_traceback`。(由 Irit Katriel 在 :gh:`102778` " +"中貢獻。)" #: ../../whatsnew/3.12.rst:920 ../../whatsnew/3.12.rst:1755 msgid "" @@ -1424,6 +1692,8 @@ msgid "" "exception instance, rather than to a ``(typ, exc, tb)`` tuple. (Contributed " "by Irit Katriel in :gh:`103176`.)" msgstr "" +":func:`sys._current_exceptions` 現在回傳從執行緒 id 到例外實例的對映,而不是 " +"``(typ, exc, tb)`` 元組。(由 Irit Katriel 在 :gh:`103176` 中貢獻。)" #: ../../whatsnew/3.12.rst:924 msgid "" @@ -1432,6 +1702,9 @@ msgid "" "use the recursion limit, but are protected by a different mechanism that " "prevents recursion from causing a virtual machine crash." msgstr "" +":func:`sys.setrecursionlimit` 和 :func:`sys.getrecursionlimit`。遞迴限制現在" +"僅適用於 Python 程式碼。內建函式不使用遞迴限制,但受到不同機制的保護,以防止" +"遞迴導致虛擬機器崩潰。" #: ../../whatsnew/3.12.rst:930 msgid "tempfile" @@ -1464,6 +1737,10 @@ msgid "" "all running threads in addition to the calling one. (Contributed by Pablo " "Galindo in :gh:`93503`.)" msgstr "" +"新增 :func:`threading.settrace_all_threads` 和 :func:`threading." +"setprofile_all_threads`,允許在除呼叫執行緒之外的所有正在運行的執行緒中設定追" +"蹤 (tracing) 和分析 (profiling) 函式。(由 Pablo Galindo 在 :gh:`93503` 中貢" +"獻。)" #: ../../whatsnew/3.12.rst:946 msgid "tkinter" @@ -1478,6 +1755,11 @@ msgid "" "y2), ...]``), like ``create_*()`` methods. (Contributed by Serhiy Storchaka " "in :gh:`94473`.)" msgstr "" +"``tkinter.Canvas.coords()`` 現在將其參數展平。它現在不僅接受座標作為單獨的引" +"數 (``x1, y1, x2, y2, ...``) 和一系列座標 (``[x1, y1, x2, y2, ...]``),而且還" +"有成對分組的座標 (``(x1, y1), (x2, y2), ...`` 和 ``[(x1, y1), (x2, " +"y2), ...]``),如 ``create_*()`` 方法。(由 Serhiy Storchaka 在 :gh:`94473` 中" +"貢獻。)" #: ../../whatsnew/3.12.rst:957 msgid "tokenize" @@ -1490,6 +1772,9 @@ msgid "" "ref:`whatsnew312-porting-to-python312` for more information on the changes " "to the :mod:`tokenize` module." msgstr "" +":mod:`tokenize` 模組包含 :pep:`701` 中引入的變更。(由 Marta Gómez Macías 和 " +"Pablo Galindo 在 :gh:`102856` 中貢獻。)有關 :mod:`tokenize` 模組更改的更多資" +"訊,請參閱 :ref:`whatsnew312-porting-to-python312`。" #: ../../whatsnew/3.12.rst:965 msgid "types" @@ -1501,6 +1786,9 @@ msgid "" "ref:`user-defined-generics` when subclassed. (Contributed by James Hilton-" "Balfe and Alex Waygood in :gh:`101827`.)" msgstr "" +"新增 :func:`types.get_original_bases` 以允許在子類別化時進一步內省 " +"(introspect) :ref:`使用者定義的泛型 `。(由 James " +"Hilton-Balfe 和 Alex Waygood 在 :gh:`101827` 中貢獻。)" #: ../../whatsnew/3.12.rst:974 msgid "typing" @@ -1518,6 +1806,13 @@ msgid "" "protocol on Python 3.12+, and vice versa. Most users are unlikely to be " "affected by this change. (Contributed by Alex Waygood in :gh:`102433`.)" msgstr "" +":func:`isinstance` 針對\\ :func:`可在 runtime 檢查的協定 `\\ 的檢查,現在使用 :func:`inspect.getattr_static` 而不" +"是 :func:`hasattr` 來查找屬性是否存在。這意味著在針對 可在 runtime 檢查的協定" +"的 ``isinstance()`` 檢查期間,描述器和 :meth:`~object.__getattr__` 方法不再意" +"外地被求值。然而,這也可能意味著一些曾經被視為 可在 runtime 檢查的協定實例的" +"物件在 Python 3.12+ 上可能不再被視為該協定的實例,反之亦然。大多數使用者不太" +"可能受到此更改的影響。(由 Alex Waygood 在 :gh:`102433` 中貢獻。)" #: ../../whatsnew/3.12.rst:987 msgid "" @@ -1526,6 +1821,9 @@ msgid "" "onto a runtime-checkable protocol will still work, but will have no impact " "on :func:`isinstance` checks comparing objects to the protocol. For example::" msgstr "" +"現在,一旦建立了類別,可在 runtime 檢查的協定的成員就會在 runtime 被視為「凍" +"結」。將屬性 monkey-patch 到 可在 runtime 檢查的協定上仍然有效,但不會影響將" +"物件與協定進行比較的 :func:`isinstance` 檢查。例如: ::" #: ../../whatsnew/3.12.rst:992 msgid "" @@ -1569,6 +1867,7 @@ msgid "" "This change was made in order to speed up ``isinstance()`` checks against " "runtime-checkable protocols." msgstr "" +"進行此更改是為了加快針對 可在 runtime 檢查的協定的 ``isinstance()`` 檢查。" #: ../../whatsnew/3.12.rst:1012 msgid "" @@ -1580,6 +1879,12 @@ msgid "" "may be slower than in Python 3.11. (Contributed by Alex Waygood in :gh:" "`74690` and :gh:`103193`.)" msgstr "" +":func:`isinstance` 針對\\ :func:`可在 runtime 檢查的協定 `\\ 進行檢查的效能概況已發生顯著變化。大多數 " +"``isinstance()`` 針對只有少數成員的協定的檢查應該比 3.11 中至少快 2 倍,有些" +"可能快 20 倍或更多。然而,``isinstance()`` 對具有許多成員的協定進行檢查可能" +"比 Python 3.11 慢。(由 Alex Waygood 在 :gh:`74690` 和 :gh:`103193` 中貢" +"獻。)" #: ../../whatsnew/3.12.rst:1020 msgid "" @@ -1587,6 +1892,9 @@ msgid "" "the ``__orig_bases__`` attribute. (Contributed by Adrian Garcia Badaracco " "in :gh:`103699`.)" msgstr "" +"所有 :data:`typing.TypedDict` 和 :data:`typing.NamedTuple` 類別現在都具有 " +"``__orig_bases__`` 屬性。 (由 Adrian Garcia Badaracco 在 :gh:`103699` 中貢" +"獻。)" #: ../../whatsnew/3.12.rst:1024 msgid "" @@ -1605,6 +1913,8 @@ msgid "" "The Unicode database has been updated to version 15.0.0. (Contributed by " "Benjamin Peterson in :gh:`96734`)." msgstr "" +"Unicode 資料庫已更新至版本 15.0.0。(由 Benjamin Peterson 在 :gh:`96734` 中貢" +"獻)。" #: ../../whatsnew/3.12.rst:1034 ../../whatsnew/3.12.rst:1600 msgid "unittest" @@ -1613,7 +1923,7 @@ msgstr "unittest" #: ../../whatsnew/3.12.rst:1036 msgid "" "Add a ``--durations`` command line option, showing the N slowest test cases::" -msgstr "新增 ``--durations`` 命令列選項,顯示 N 個最慢的測試案例:" +msgstr "新增 ``--durations`` 命令列選項,顯示 N 個最慢的測試案例: ::" #: ../../whatsnew/3.12.rst:1038 msgid "" @@ -1671,6 +1981,9 @@ msgid "" "object size by 8 or 16 bytes on 64bit platform. (:pep:`623`) (Contributed by " "Inada Naoki in :gh:`92536`.)" msgstr "" +"從 Unicode 物件中刪除 ``wstr`` 和 ``wstr_length`` 成員。它在 64 位元平台上將" +"物件大小減少了 8 或 16 位元組。(:pep:`623`)(由 Inada Naoki 在 :gh:`92536` 貢" +"獻。)" #: ../../whatsnew/3.12.rst:1068 msgid "" @@ -1678,6 +1991,9 @@ msgid "" "process, which improves performance by 1-5%. (Contributed by Kevin " "Modzelewski in :gh:`90536` and tuned by Donghee Na in :gh:`101525`)" msgstr "" +"增加在建置過程中使用 BOLT 二進位最佳化器的實驗支援,這可將效能提高 1-5%。" +"(由 Kevin Modzelewski 在 :gh:`90536` 中貢獻、由 Donghee Na 在 :gh:`101525` " +"中調整)" #: ../../whatsnew/3.12.rst:1072 msgid "" @@ -1686,6 +2002,9 @@ msgid "" "replacement strings containing group references by 2--3 times. (Contributed " "by Serhiy Storchaka in :gh:`91524`.)" msgstr "" +"將包含群組參照的替換字串的正規表示式替換(函式 :func:`re.sub` 和 :func:`re." +"subn` 以及相應的 :class:`!re.Pattern` 方法)速度提高 2--3 倍。(由 Serhiy " +"Storchaka 在 :gh:`91524` 中貢獻。)" #: ../../whatsnew/3.12.rst:1077 msgid "" @@ -1702,6 +2021,9 @@ msgid "" "`701` in the :mod:`tokenize` module. (Contributed by Marta Gómez Macías and " "Pablo Galindo in :gh:`102856`.)" msgstr "" +"作為覆蓋 :mod:`tokenize` 模組中的 :pep:`701` 所需更改的副作用,:func:" +"`tokenize.tokenize` 和 :func:`tokenize.generate_tokens` 函式速度提高了 64%。" +"(由 Marta Gómez Macías 和 Pablo Galindo 在 :gh:`102856` 中貢獻。)" #: ../../whatsnew/3.12.rst:1085 msgid "" @@ -1709,6 +2031,8 @@ msgid "" "`LOAD_SUPER_ATTR` instruction. (Contributed by Carl Meyer and Vladimir " "Matveev in :gh:`103497`.)" msgstr "" +"透過新的 :opcode:`LOAD_SUPER_ATTR` 指令加速 :func:`super` 方法呼叫和屬性載" +"入。(由 Carl Meyer 和 Vladimir Matveev 在 :gh:`103497` 中貢獻。)" #: ../../whatsnew/3.12.rst:1091 msgid "CPython bytecode changes" @@ -1827,7 +2151,7 @@ msgstr "" #: ../../whatsnew/3.12.rst:1137 msgid "Demos and Tools" -msgstr "" +msgstr "演示和工具" #: ../../whatsnew/3.12.rst:1139 msgid "" @@ -1835,6 +2159,9 @@ msgid "" "copy can be found in the `old-demos project `_. (Contributed by Victor Stinner in :gh:`97681`.)" msgstr "" +"刪除包含舊演示腳本的 ``Tools/demo/`` 目錄。可以在 `old-demos 專案 `_\\ 中找到副本。(由 Victor Stinner 在 :gh:" +"`97681` 中貢獻。)" #: ../../whatsnew/3.12.rst:1144 msgid "" @@ -1842,6 +2169,9 @@ msgid "" "can be found in the `old-demos project `_. (Contributed by Victor Stinner in :gh:`97669`.)" msgstr "" +"刪除 ``Tools/scripts/`` 目錄中過時的演示腳本。可以在 `old-demos 專案 " +"`_\\ 中找到副本。(由 Victor " +"Stinner 在 :gh:`97669` 中貢獻。)" #: ../../whatsnew/3.12.rst:1151 ../../whatsnew/3.12.rst:2158 msgid "Deprecated" @@ -1855,7 +2185,7 @@ msgid "" "(Contributed by Nikita Sobolev in :gh:`92248`.)" msgstr "" ":mod:`argparse`::class:`!argparse.BooleanOptionalAction` 的 *type*、" -"*choices* 和 *metavar* 參數已被棄用,將在 3.14 中移除。 (由 Nikita Sobolev " +"*choices* 和 *metavar* 參數已被棄用,將在 3.14 中移除。(由 Nikita Sobolev " "於 :gh:`92248` 貢獻。)" #: ../../whatsnew/3.12.rst:1158 @@ -1918,7 +2248,7 @@ msgid "" msgstr "" "已棄用並將在 Python 3.14 中移除的 child watcher 類別::class:`!asyncio." "MultiLoopChildWatcher`、:class:`!asyncio.FastChildWatcher`、:class:`!asyncio." -"AbstractChildWatcher` 和 :class:`!asyncio.SafeChildWatcher`。 (由 Kumar " +"AbstractChildWatcher` 和 :class:`!asyncio.SafeChildWatcher`。(由 Kumar " "Aditya 於 :gh:`94597` 貢獻。)" #: ../../whatsnew/3.12.rst:1179 @@ -1943,7 +2273,7 @@ msgid "" "Rossum in :gh:`100160`.)" msgstr "" "預設事件迴圈策略的 :meth:`~asyncio.get_event_loop` 方法現在會在沒有設定目前事" -"件迴圈且決定建立一個時發出 :exc:`DeprecationWarning`。 (由 Serhiy Storchaka " +"件迴圈且決定建立一個時發出 :exc:`DeprecationWarning`。(由 Serhiy Storchaka " "和 Guido van Rossum 於 :gh:`100160` 貢獻。)" #: ../../whatsnew/3.12.rst:1190 @@ -1954,7 +2284,7 @@ msgid "" "FEBRUARY`. (Contributed by Prince Roshan in :gh:`103636`.)" msgstr "" ":mod:`calendar`:``calendar.January`` 和 ``calendar.February`` 常數已被棄用並" -"被 :data:`calendar.JANUARY` 和 :data:`calendar.FEBRUARY` 取代。 (由 Prince " +"被 :data:`calendar.JANUARY` 和 :data:`calendar.FEBRUARY` 取代。(由 Prince " "Roshan 於 :gh:`103636` 貢獻。)" #: ../../whatsnew/3.12.rst:1194 @@ -2013,6 +2343,12 @@ msgid "" "now` and :meth:`~datetime.datetime.fromtimestamp` with the *tz* parameter " "set to :const:`datetime.UTC`. (Contributed by Paul Ganssle in :gh:`103857`.)" msgstr "" +":mod:`datetime`::class:`datetime.datetime` 的 :meth:`~datetime.datetime." +"utcnow` 和 :meth:`~datetime.datetime.utcfromtimestamp` 已棄用,並將在未來版本" +"中刪除。請改用時區感知 (timezone-aware) 物件來表示 UTC 中的日期時間:分別呼" +"叫 :meth:`~datetime.datetime.now` 和 :meth:`~datetime.datetime." +"fromtimestamp` 並將 *tz* 參數設定為 :const:`datetime.UTC`。(由 Paul Ganssle " +"在 :gh:`103857` 中貢獻。)" #: ../../whatsnew/3.12.rst:1221 msgid "" @@ -2071,6 +2407,9 @@ msgid "" "code volume and maintenance burden. (Contributed by Raymond Hettinger in :gh:" "`101588`.)" msgstr "" +":mod:`itertools`:棄用對複製、深度複製和 pickle 操作的支援,這些操作沒有文件" +"記錄、效率低下、過去常有錯誤且不一致。這將在 3.14 中刪除,以顯著地減少程式碼" +"總量和維護負擔。(由 Raymond Hettinger 在 :gh:`101588` 中貢獻。)" #: ../../whatsnew/3.12.rst:1244 msgid "" @@ -2083,6 +2422,13 @@ msgid "" "specify when your code *requires* ``'fork'``. See :ref:`contexts and start " "methods `." msgstr "" +":mod:`multiprocessing`:在 Python 3.14 中,預設的 :mod:`multiprocessing` 啟動" +"方法將更改為 Linux、BSD 和其他非 macOS POSIX 平台上更安全的方法,其中 " +"``'fork'`` 目前是預設值 (:gh:`84559`)。新增關於此的 runtime 警告被認為太具有" +"破壞性,因為大多數程式碼預計不會關心它們。使用 :func:`~multiprocessing." +"get_context` 或 :func:`~multiprocessing.set_start_method` API 明確指定你的程" +"式碼何時\\ *需要* ``'fork'``。請參閱\\ :ref:`情境和啟動方法 `。" #: ../../whatsnew/3.12.rst:1254 msgid "" @@ -2101,6 +2447,10 @@ msgid "" "gained a proper :exc:`DeprecationWarning` in 3.12. Remove them in 3.14. " "(Contributed by Soumendra Ganguly and Gregory P. Smith in :gh:`85984`.)" msgstr "" +":mod:`pty`:這個模組有兩個未記錄於文件中的函式 ``master_open()`` 和 " +"``slave_open()``,自 Python 2 以來已被棄用,但僅在 3.12 中會適時發出 :exc:" +"`DeprecationWarning`。將會在 3.14 中刪除它們。(由 Soumendra Ganguly 和 " +"Gregory P. Smith 在 :gh:`85984` 中貢獻。)" #: ../../whatsnew/3.12.rst:1264 msgid ":mod:`os`:" @@ -2114,6 +2464,10 @@ msgid "" "contain the creation time, which is also available in the new " "``st_birthtime`` field. (Contributed by Steve Dower in :gh:`99726`.)" msgstr "" +"Windows 上 :func:`os.stat` 和 :func:`os.lstat` 回傳的 ``st_ctime`` 欄位已被棄" +"用。在未來的版本中,它們將包含最近一次的元資料變更時間,與其他平台一致。目前" +"它們仍然包含建立時間,這也可以在新的 ``st_birthtime`` 欄位中找到。(由 Steve " +"Dower 在 :gh:`99726` 中貢獻。)" #: ../../whatsnew/3.12.rst:1272 msgid "" @@ -2128,6 +2482,14 @@ msgid "" "alive-threads/33555>`_ for *why* we're now surfacing this longstanding " "platform compatibility problem to developers." msgstr "" +"在 POSIX 平台上,當 :func:`os.fork` 偵測到從多執行緒行程呼叫時,它現在可以引" +"發 :exc:`DeprecationWarning`。這樣做時始終存在與 POSIX 平台根本不相容的問題。" +"即使這樣的程式碼\\ *看起來*\\ 可以工作。我們新增了警告,以提高人們的認識,因" +"為執行此操作的程式碼遇到的問題變得越來越頻繁。請參閱 :func:`os.fork` 文件以獲" +"取更多詳細資訊,以及\\ `關於 fork 與執行緒不相容的討論 `_\\ 了解\\ *為什麼*\\ 我們現在向開發人員展示這個長期存在的平台" +"相容性問題。" #: ../../whatsnew/3.12.rst:1282 msgid "" @@ -2135,6 +2497,9 @@ msgid "" "`concurrent.futures` the fix is to use a different :mod:`multiprocessing` " "start method such as ``\"spawn\"`` or ``\"forkserver\"``." msgstr "" +"當由於使用 :mod:`multiprocessing` 或 :mod:`concurrent.futures` 出現此警告時," +"修復方法是使用不同的 :mod:`multiprocessing` 啟動方法,例如 ``\"spawn\"`` 或 " +"``\"forkserver\"``。" #: ../../whatsnew/3.12.rst:1286 msgid "" @@ -2156,6 +2521,9 @@ msgid "" "deprecated. Instead, use the :ref:`sqlite3-adapter-converter-recipes` and " "tailor them to your needs. (Contributed by Erlend E. Aasland in :gh:`90016`.)" msgstr "" +":ref:`預設適配器和轉換器 `\\ 現已棄用。請改為使" +"用 :ref:`sqlite3-adapter-converter-recipes` 並根據你的需求進行細部調整。(由 " +"Erlend E. Aasland 在 :gh:`90016` 中貢獻。)" #: ../../whatsnew/3.12.rst:1297 msgid "" @@ -2166,6 +2534,11 @@ msgid "" "as a sequence will raise a :exc:`~sqlite3.ProgrammingError`. (Contributed by " "Erlend E. Aasland in :gh:`101698`.)" msgstr "" +"在 :meth:`~sqlite3.Cursor.execute` 中,當\\ :ref:`附名佔位符 (named " +"placeholder) ` 與作為 :term:`sequence` 提供的參數一起使" +"用時,現在會發出 :exc:`DeprecationWarning` 而非作為 :class:`dict`。從 Python " +"3.14 開始,使用附名佔位符以及作為序列提供的參數將引發 :exc:`~sqlite3." +"ProgrammingError`。(由 Erlend E. Aasland 在 :gh:`101698` 中貢獻。)" #: ../../whatsnew/3.12.rst:1304 msgid "" @@ -2183,6 +2556,9 @@ msgid "" "deprecated until Python 3.14, when ``'data'`` filter will become the " "default. See :ref:`tarfile-extraction-filter` for details." msgstr "" +":mod:`tarfile`:不推薦在不指定 *filter* 的情況下提取 tar 檔案,直到 Python " +"3.14 為止,此時 ``'data'`` 過濾器將成為預設過濾器。有關詳細資訊,請參閱 :ref:" +"`tarfile-extraction-filter`。" #: ../../whatsnew/3.12.rst:1312 #: ../../deprecations/pending-removal-in-3.15.rst:80 @@ -2196,6 +2572,9 @@ msgid "" "`collections.abc.Hashable` and :class:`collections.abc.Sized` respectively, " "are deprecated. (:gh:`94309`.)" msgstr "" +":class:`typing.Hashable` 和 :class:`typing.Sized` 分別是 :class:`collections." +"abc.Hashable` 和 :class:`collections.abc.Sized` 的別名,已被棄用。(:gh:" +"`94309`)" #: ../../whatsnew/3.12.rst:1318 msgid "" @@ -2213,6 +2592,10 @@ msgid "" "Before, the Python implementation emitted :exc:`FutureWarning`, and the C " "implementation emitted nothing. (Contributed by Jacob Walls in :gh:`83122`.)" msgstr "" +":mod:`xml.etree.ElementTree`:這個模組現在在測試 :class:`xml.etree." +"ElementTree.Element` 的真值時發出 :exc:`DeprecationWarning`。之前,Python 實" +"作發出了 :exc:`FutureWarning`,而 C 實作什麼也沒發出。(由 Jacob Walls 在 :" +"gh:`83122` 中貢獻。)" #: ../../whatsnew/3.12.rst:1328 msgid "" @@ -2222,6 +2605,10 @@ msgid "" "a future version of Python. Use the single-arg versions of these functions " "instead. (Contributed by Ofey Chan in :gh:`89874`.)" msgstr "" +":meth:`coroutine throw() `、:meth:`generator throw() " +"` 和 :meth:`async generator throw ` 的三引數簽" +"名 (type, value, traceback) 已棄用,並且可能會在 Python 的未來版本中刪除。請" +"改用這些函式的單引數版本。(由 Ofey Chan 在 :gh:`89874` 中貢獻。)" #: ../../whatsnew/3.12.rst:1334 msgid "" @@ -2230,6 +2617,10 @@ msgid "" "parent>` (previously it was :exc:`ImportWarning`). (Contributed by Brett " "Cannon in :gh:`65961`.)" msgstr "" +"現在,當模組上的 :attr:`~module.__package__` 與 :attr:`__spec__.parent " +"` 不同時,會引發 :exc:" +"`DeprecationWarning`\\ (以前是 :exc:`ImportWarning`)。(由 Brett Cannon " +"在 :gh:`65961` 中貢獻。)" #: ../../whatsnew/3.12.rst:1340 msgid "" @@ -2238,6 +2629,9 @@ msgid "" "by the import system in Python 3.14. (Contributed by Brett Cannon in :gh:" "`65961`.)" msgstr "" +"在模組上設定 :attr:`~module.__package__` 或 :attr:`~module.__cached__` 已被棄" +"用,並且 Python 3.14 中的引入系統將不再設定或考慮該設定。(由 Brett Cannon " +"在 :gh:`65961` 中貢獻。)" #: ../../whatsnew/3.12.rst:1344 msgid "" @@ -2247,6 +2641,10 @@ msgid "" "underlying ``int``, convert to int explicitly: ``~int(x)``. (Contributed by " "Tim Hoffmann in :gh:`103487`.)" msgstr "" +"bool 上的位元反轉運算子 (``~``) 已棄用。在 Python 3.16 中它將拋出錯誤。使用 " +"``not`` 來代替布林值的邏輯否定。在極少數情況下,你確實需要對底層 ``int`` 進行" +"位元反轉,請明確轉換為 int:``~int(x)``。(由 Tim Hoffmann 在 :gh:`103487` 中" +"貢獻。)" #: ../../whatsnew/3.12.rst:1350 msgid "" @@ -2425,7 +2823,7 @@ msgid "" "burden. (Contributed by Raymond Hettinger in :gh:`101588`.)" msgstr "" ":mod:`itertools` 有不以文件記錄、效率低下、過去常有 bug 且不一致的 copy、" -"deepcopy 和 pickle 操作支援。將在 3.14 中移除以大幅減少程式碼量和維護負擔。 " +"deepcopy 和 pickle 操作支援。將在 3.14 中移除以大幅減少程式碼量和維護負擔。" "(由 Raymond Hettinger 於 :gh:`101588` 貢獻。)" #: ../../deprecations/pending-removal-in-3.14.rst:63 @@ -2439,8 +2837,8 @@ msgid "" "``'fork'``. See :ref:`multiprocessing-start-methods`." msgstr "" ":mod:`multiprocessing`:預設的啟動方法將在 Linux、BSD 和其他非 macOS POSIX 平" -"台上更改為更安全的 方法,目前 ``'fork'`` 是預設值 (:gh:`84559`)。對此增加一" -"個 runtime 警告被認為太過擾人,因為 大多數程式碼不會在意。請使用 :func:" +"台上更改為更安全的方法,目前 ``'fork'`` 是預設值 (:gh:`84559`)。對此增加一個 " +"runtime 警告被認為太過擾人,因為 大多數程式碼不會在意。請使用 :func:" "`~multiprocessing.get_context` 或 :func:`~multiprocessing.set_start_method` " "API 來明確指定你的程式碼何時\\ *需要* ``'fork'``。請參閱 :ref:" "`multiprocessing-start-methods`。" @@ -2461,7 +2859,7 @@ msgid "" msgstr "" ":mod:`pkgutil`::func:`!pkgutil.find_loader` 和 :func:`!pkgutil.get_loader` " "現在會引發 :exc:`DeprecationWarning`;請改用 :func:`importlib.util." -"find_spec`。 (由 Nikita Sobolev 於 :gh:`97850` 貢獻。)" +"find_spec`。(由 Nikita Sobolev 於 :gh:`97850` 貢獻。)" #: ../../deprecations/pending-removal-in-3.14.rst:80 msgid ":mod:`pty`:" @@ -2587,7 +2985,7 @@ 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` 貢獻。)" +"getencoding`。(由 Hugo van Kemenade 於 :gh:`111187` 貢獻。)" #: ../../deprecations/pending-removal-in-3.15.rst:46 msgid ":mod:`pathlib`:" @@ -2967,7 +3365,7 @@ msgstr "" "在 Python 3.14 之前,舊式聯集是使用私有類別 ``typing._UnionGenericAlias`` 實" "作的。這個類別不再被需要,但為了向後相容性而保留,並計劃將在 Python 3.17 中移" "除。使用者應該改用文件中記錄的內省輔助函式,例如 :func:`typing.get_origin` " -"和 :func:`typing.get_args`,或者依賴私有實作細節。" +"和 :func:`typing.get_args`,而非依賴私有實作細節。" #: ../../deprecations/pending-removal-in-3.17.rst:33 msgid "" @@ -3071,7 +3469,7 @@ msgid "" "`109218`.)" msgstr "" "在 :func:`complex` 建構子中將複數作為 *real* 或 *imag* 引數傳遞現在已被棄用;" -"它應該只作為單個位置引數傳遞。 (由 Serhiy Storchaka 於 :gh:`109218` 貢獻。)" +"它應該只作為單個位置引數傳遞。(由 Serhiy Storchaka 於 :gh:`109218` 貢獻。)" #: ../../deprecations/pending-removal-in-future.rst:48 msgid "" @@ -3144,7 +3542,7 @@ msgid "" ":mod:`mailbox`: Use of StringIO input and text mode is deprecated, use " "BytesIO and binary mode instead." msgstr "" -":mod:`mailbox`:已棄用 StringIO 輸入和文本模式,請改用 BytesIO 和二進位模式。" +":mod:`mailbox`:已棄用 StringIO 輸入和文字模式,請改用 BytesIO 和二進位模式。" #: ../../deprecations/pending-removal-in-future.rst:78 msgid "" @@ -3394,6 +3792,8 @@ msgid "" "having been deprecated in Python 3.6. Use :mod:`asyncio` instead. " "(Contributed by Nikita Sobolev in :gh:`96580`.)" msgstr "" +"這兩個模組已根據 :pep:`594` 的計畫時間刪除,並已在 Python 3.6 中棄用。請改" +"用 :mod:`asyncio`。(由 Nikita Sobolev 在 :gh:`96580` 中貢獻。)" #: ../../whatsnew/3.12.rst:1383 msgid "configparser" @@ -3442,6 +3842,10 @@ msgid "" "project can be installed: it still provides ``distutils``. (Contributed by " "Victor Stinner in :gh:`92584`.)" msgstr "" +"刪除 :py:mod:`!distutils` 套件。它在 Python 3.10 中被 :pep:`632` 「棄用 " +"distutils 模組」棄用。對於仍然使用 ``distutils`` 且無法更新為其他內容的專案," +"可以安裝 ``setuptools`` 專案:它仍然提供 ``distutils``。(由 Victor Stinner " +"在 :gh:`92584` 中貢獻。)" #: ../../whatsnew/3.12.rst:1407 msgid "ensurepip" @@ -3452,6 +3856,8 @@ msgid "" "Remove the bundled setuptools wheel from :mod:`ensurepip`, and stop " "installing setuptools in environments created by :mod:`venv`." msgstr "" +"從 :mod:`ensurepip` 中刪除綁定的 setuptools wheel,並停止在 :mod:`venv` 建立" +"的環境中安裝 setuptools。" #: ../../whatsnew/3.12.rst:1412 msgid "" @@ -3518,6 +3924,10 @@ msgid "" "extension if it was not present. (Contributed by Victor Stinner in :gh:" "`94196`.)" msgstr "" +"移除 :mod:`gzip` 的 :class:`gzip.GzipFile` 的 ``filename`` 屬性(自 Python " +"2.6 起已棄用),改用 :attr:`~gzip.GzipFile.name` 屬性。在寫入模式下," +"``filename`` 屬性會新增 ``'.gz'`` 檔案副檔名(如果不存在)。(由 Victor " +"Stinner 在 :gh:`94196` 中貢獻。)" #: ../../whatsnew/3.12.rst:1451 msgid "hashlib" @@ -3531,6 +3941,10 @@ msgid "" "of :func:`~hashlib.pbkdf2_hmac` which is faster. (Contributed by Victor " "Stinner in :gh:`94199`.)" msgstr "" +"刪除 :mod:`hashlib` 的 :func:`hashlib.pbkdf2_hmac` 的純 Python 實作(在 " +"Python 3.10 中已棄用)。Python 3.10 及更新版本需要 OpenSSL 1.1.1 (:pep:" +"`644`):此 OpenSSL 版本提供了更快的 :func:`~hashlib.pbkdf2_hmac` 的 C 實作。" +"(由 Victor Stinner 在 :gh:`94199` 中貢獻。)" #: ../../whatsnew/3.12.rst:1460 ../../whatsnew/3.12.rst:1489 msgid "importlib" @@ -3745,6 +4159,8 @@ msgid "" "``imp.lock_held()``, ``imp.acquire_lock()``, ``imp.release_lock()``: the " "locking scheme has changed in Python 3.3 to per-module locks." msgstr "" +"``imp.lock_held()``、``imp.acquire_lock()``、``imp.release_lock()``:鎖定 " +"scheme 在 Python 3.3 中已改為模組鎖 (per-module locks)。" #: ../../whatsnew/3.12.rst:1530 msgid "" @@ -3768,6 +4184,10 @@ msgid "" "open` is also a static method. (Contributed by Victor Stinner in :gh:" "`94169`.)" msgstr "" +"刪除 :mod:`io` 的 ``io.OpenWrapper`` 和 ``_pyio.OpenWrapper``,在 Python " +"3.10 中已棄用:改用 :func:`open` 即可。:func:`open` (:func:`io.open`) 函式是" +"一個內建函式。從 Python 3.10 開始 :func:`!_pyio.open` 也是一個靜態方法。(由 " +"Victor Stinner 在 :gh:`94169` 中貢獻。)" #: ../../whatsnew/3.12.rst:1544 msgid "locale" @@ -3779,6 +4199,9 @@ msgid "" "3.7: use :func:`locale.format_string` instead. (Contributed by Victor " "Stinner in :gh:`94226`.)" msgstr "" +"刪除 :mod:`locale` 的 :func:`!locale.format` 函式(在 Python 3.7 中已棄用):" +"請改用 :func:`locale.format_string`。(由 Victor Stinner 在 :gh:`94226` 中貢" +"獻。)" #: ../../whatsnew/3.12.rst:1551 msgid "smtpd" @@ -3816,6 +4239,7 @@ msgid "" "If a shared cache must be used, open the database in URI mode using the " "``cache=shared`` query parameter." msgstr "" +"如果必須使用共享快取,請使用 ``cache=shared`` 查詢參數以 URI 模式開啟資料庫。" #: ../../whatsnew/3.12.rst:1571 msgid "" @@ -3824,6 +4248,9 @@ msgid "" "``OptimizedUnicode`` can either use ``str`` explicitly, or rely on the " "default value which is also ``str``." msgstr "" +"自 Python 3.3 起,``sqlite3.OptimizedUnicode`` 文字工廠一直是 :class:`str` 的" +"別名。之前將文字工廠設定為 ``OptimizedUnicode`` 的程式碼可以顯式使用 " +"``str``,或者依賴預設值 ``str``。" #: ../../whatsnew/3.12.rst:1576 msgid "(Contributed by Erlend E. Aasland in :gh:`92548`.)" @@ -4030,6 +4457,9 @@ msgid "" "loadTestsFromModule>` parameter *use_load_tests* (deprecated and ignored " "since Python 3.5)." msgstr "" +"未記錄的 :meth:`TestLoader.loadTestsFromModule ` 參數 *use_load_tests*\\ (自 Python 3.5 起已棄用並忽" +"略)。" #: ../../whatsnew/3.12.rst:1638 msgid "" @@ -4053,6 +4483,9 @@ msgid "" "browsers include: Grail, Mosaic, Netscape, Galeon, Skipstone, Iceape, " "Firebird, and Firefox versions 35 and below (:gh:`102871`)." msgstr "" +"從 :mod:`webbrowser` 中刪除對過時瀏覽器的支援。刪除的瀏覽器包括:Grail、" +"Mosaic、Netscape、Galeon、Skipstone、Iceape、Firebird 和 Firefox 版本 35 及以" +"下 (:gh:`102871`)。" #: ../../whatsnew/3.12.rst:1651 msgid "xml.etree.ElementTree" @@ -4066,6 +4499,10 @@ msgid "" "no ``copy()`` method, only a ``__copy__()`` method. (Contributed by Victor " "Stinner in :gh:`94383`.)" msgstr "" +"刪除純 Python 實作的 ``ElementTree.Element.copy()`` 方法(在 Python 3.10 中已" +"棄用),改用 :func:`copy.copy` 函式。:mod:`xml.etree.ElementTree` 的 C 實作沒" +"有 ``copy()`` 方法,只有 ``__copy__()`` 方法。(由 Victor Stinner 在 :gh:" +"`94383` 中貢獻。)" #: ../../whatsnew/3.12.rst:1660 msgid "zipimport" @@ -4077,6 +4514,9 @@ msgid "" "deprecated in Python 3.10: use the ``find_spec()`` method instead. See :pep:" "`451` for the rationale. (Contributed by Victor Stinner in :gh:`94379`.)" msgstr "" +"刪除 :mod:`zipimport` 的 ``find_loader()`` 和 ``find_module()`` 方法(在 " +"Python 3.10 中已棄用):請改用 ``find_spec()`` 方法。請參閱 :pep:`451` 以了解" +"基本原理。(由 Victor Stinner 在 :gh:`94379` 中貢獻。)" #: ../../whatsnew/3.12.rst:1668 msgid "Others" @@ -4089,6 +4529,9 @@ msgid "" "com/sphinx-contrib/sphinx-lint>`_. (Contributed by Julien Palard in :gh:" "`98179`.)" msgstr "" +"從文件 :file:`Makefile` 和 :file:`Doc/tools/rstlint.py` 中刪除 " +"``suspicious`` 規則,兩者皆改用 `sphinx-lint `_。(由 Julien Palard 在 :gh:`98179` 中貢獻。)" #: ../../whatsnew/3.12.rst:1675 msgid "" @@ -4099,6 +4542,11 @@ msgid "" "(*ssl_context* in :mod:`imaplib`) instead. (Contributed by Victor Stinner " "in :gh:`94172`.)" msgstr "" +"從 :mod:`ftplib`、:mod:`imaplib`、:mod:`poplib` 和 :mod:`smtplib` 模組中刪除 " +"*keyfile* 和 *certfile* 參數,並刪除 :mod:`http.client` 模組中的 *key_file*、" +"*cert_file* 和 *check_hostname* 參數,它們自 Python 3.6 起均已棄用。請使用 " +"*context* 參數(:mod:`imaplib` 中的 *ssl_context*)。(由 Victor Stinner 在 :" +"gh:`94172` 中貢獻。)" #: ../../whatsnew/3.12.rst:1683 msgid "" @@ -4124,7 +4572,7 @@ msgstr "移植至 Python 3.12" msgid "" "This section lists previously described changes and other bugfixes that may " "require changes to your code." -msgstr "" +msgstr "本節列出了前面描述的變更以及可能需要你更改程式碼的其他錯誤修復。" #: ../../whatsnew/3.12.rst:1700 msgid "Changes in the Python API" @@ -4138,6 +4586,9 @@ msgid "" "strings can now only contain ASCII letters and digits and underscore. " "(Contributed by Serhiy Storchaka in :gh:`91760`.)" msgstr "" +"現在,正規表示式中的數字群組參照和組名稱應用了更嚴格的規則。現在僅接受 ASCII " +"數字序列作為數字參考。位元組模式和替換字串中的組名稱現在只能包含 ASCII 字母、" +"數字和底線。(由 Serhiy Storchaka 在 :gh:`91760` 中貢獻。)" #: ../../whatsnew/3.12.rst:1709 msgid "" @@ -4150,6 +4601,13 @@ msgid "" "``randrange(10**25)``. (Originally suggested by Serhiy Storchaka :gh:" "`86388`.)" msgstr "" +"刪除自 Python 3.10 以來已棄用的 ``randrange()`` 功能。以前 " +"``randrange(10.0)`` 無損轉換為 ``randrange(10)``。現在它會引發 :exc:" +"`TypeError`。此外,針對非整數值(例如 ``randrange(10.5)`` 或 " +"``randrange('10')``)引發的例外已從 :exc:`ValueError` 變更為 :exc:" +"`TypeError`。這也可以防止 ``randrange(1e25)`` 靜默地從比 " +"``randrange(10**25)`` 更大的範圍中進行選擇的錯誤。(最初由 Serhiy Storchaka " +"建議 :gh:`86388`。)" #: ../../whatsnew/3.12.rst:1717 msgid "" @@ -4160,6 +4618,11 @@ msgid "" "handler`. Argument files should be encoded in UTF-8 instead of ANSI Codepage " "on Windows." msgstr "" +":class:`argparse.ArgumentParser` 更改了編碼和錯誤處理程式,用於從檔案(例如 " +"``fromfile_prefix_chars`` 選項)用預設文字編碼(例如 :func:`locale." +"getpreferredencoding(False) `)中讀取引數到\\ :" +"term:`檔案系統編碼和錯誤處理程式 `。" +"在 Windows 上,引數檔案應使用 UTF-8 編碼,而不是 Windows 的 ANSI Codepage。" #: ../../whatsnew/3.12.rst:1723 msgid "" @@ -4167,6 +4630,8 @@ msgid "" "and 3.5.4. A recommended replacement is the :mod:`asyncio`-based :pypi:" "`aiosmtpd` PyPI module." msgstr "" +"刪除 Python 3.4.7 和 3.5.4 中已棄用的基於 ``asyncore`` 的 ``smtpd`` 模組。推" +"薦的替代品是基於 :mod:`asyncio` 的 :pypi:`aiosmtpd` PyPI 模組。" #: ../../whatsnew/3.12.rst:1727 msgid "" @@ -4174,6 +4639,9 @@ msgid "" "exception, rather than reading :data:`sys.stdin`. The feature was deprecated " "in Python 3.9. (Contributed by Victor Stinner in :gh:`94352`.)" msgstr "" +":func:`shlex.split`:以 ``None`` 做為 *s* 引數傳遞現在會引發例外,而不是讀" +"取 :data:`sys.stdin`。該功能在 Python 3.9 中已被棄用。(由 Victor Stinner " +"在 :gh:`94352` 中貢獻。)" #: ../../whatsnew/3.12.rst:1732 msgid "" @@ -4182,6 +4650,9 @@ msgid "" "type is accepted for bytes strings. (Contributed by Victor Stinner in :gh:" "`98393`.)" msgstr "" +":mod:`os` 模組不再接受類位元組的路徑,例如 :class:`bytearray` 和 :class:" +"`memoryview` 型別:對於位元組字串,僅接受確切的 :class:`bytes` 型別。(由 " +"Victor Stinner 在 :gh:`98393` 中貢獻。)" #: ../../whatsnew/3.12.rst:1737 msgid "" @@ -4194,6 +4665,11 @@ msgid "" "process-global resources, which are best managed from the main interpreter. " "(Contributed by Donghee Na in :gh:`99127`.)" msgstr "" +"如果在子直譯器中使用,:func:`syslog.openlog` 和 :func:`syslog.closelog` 現在" +"會失敗。:func:`syslog.syslog` 仍可在子直譯器中使用,但現在僅當 :func:`syslog." +"openlog` 已在主直譯器中呼叫。這些新限制不適用於主直譯器,因此只有極少數使用者" +"可能會受到影響。此更改有助於直譯器隔離。此外,:mod:`syslog` 是行程全域資源的" +"包裝器,最好透過主直譯器進行管理。(由 Donghee Na 在 :gh:`99127` 中貢獻。)" #: ../../whatsnew/3.12.rst:1746 msgid "" @@ -4206,6 +4682,12 @@ msgid "" "fine. If synchronization is needed, implement locking within the cached " "property getter function or around multi-threaded access points." msgstr "" +"未記錄於文件的 :func:`~functools.cached_property` 鎖定行為已被刪除,因為它鎖" +"定了類別的所有實例,從而導致高鎖定爭用 (high lock contention)。這意味著,如果" +"兩個執行緒競爭,快取的屬性 getter 函式現在可以為單個實例運行多次。對於大多數" +"簡單的快取屬性(例如,那些冪等屬性並且簡單地根據實例的其他屬性計算值),這將" +"沒問題。如果需要同步,請在快取的屬性 getter 函式內或多執行緒存取點周圍實作鎖" +"定。" #: ../../whatsnew/3.12.rst:1759 msgid "" @@ -4213,6 +4695,9 @@ msgid "" "unpack_archive`, pass the *filter* argument to limit features that may be " "surprising or dangerous. See :ref:`tarfile-extraction-filter` for details." msgstr "" +"使用 :mod:`tarfile` 或 :func:`shutil.unpack_archive` 提取 tar 檔案時,請傳遞 " +"*filter* 引數以限制可能不預期或甚至危險的功能。詳細資訊請參閱 :ref:`tarfile-" +"extraction-filter`。" #: ../../whatsnew/3.12.rst:1764 msgid "" @@ -4225,6 +4710,12 @@ msgid "" "tokenization in the expression components. For example for the f-string " "``f\"start {1+1} end\"`` the old version of the tokenizer emitted::" msgstr "" +"由於 :pep:`701` 中引入的更改,:func:`tokenize.tokenize` 和 :func:`tokenize." +"generate_tokens` 函式的輸出現已更改。這意味著不再為 f 字串發出 ``STRING`` 標" +"記,並且現在產生 :pep:`701` 中描述的標記:``FSTRING_START``、" +"``FSTRING_MIDDLE`` 和 ``FSTRING_END`` 除了運算式元件中用於標記化的適當標記之" +"外,現在還會針對 f 字串 \"string\" 部分發出。例如,對於 f 字串 ``f\"start " +"{1+1} end\"`` 舊版的標記產生器發出: ::" #: ../../whatsnew/3.12.rst:1773 msgid "1,0-1,18: STRING 'f\"start {1+1} end\"'" @@ -4232,7 +4723,7 @@ msgstr "1,0-1,18: STRING 'f\"start {1+1} end\"'" #: ../../whatsnew/3.12.rst:1775 msgid "while the new version emits::" -msgstr "" +msgstr "而新版本會發出: ::" #: ../../whatsnew/3.12.rst:1777 msgid "" @@ -4261,30 +4752,39 @@ msgid "" "Additionally, there may be some minor behavioral changes as a consequence of " "the changes required to support :pep:`701`. Some of these changes include:" msgstr "" +"此外,由於支援 :pep:`701` 所做的更改,可能會出現一些細微的行為變化。其中的變" +"化包括:" #: ../../whatsnew/3.12.rst:1790 msgid "" "The ``type`` attribute of the tokens emitted when tokenizing some invalid " "Python characters such as ``!`` has changed from ``ERRORTOKEN`` to ``OP``." msgstr "" +"對某些無效 Python 字元(例如 ``!``)進行標記時發出的標記的 ``type`` 屬性已從 " +"``ERRORTOKEN`` 更改為 ``OP``。" #: ../../whatsnew/3.12.rst:1793 msgid "" "Incomplete single-line strings now also raise :exc:`tokenize.TokenError` as " "incomplete multiline strings do." msgstr "" +"不完整的單列字串現在也會像不完整的多列字串一樣引發 :exc:`tokenize." +"TokenError`。" #: ../../whatsnew/3.12.rst:1796 msgid "" "Some incomplete or invalid Python code now raises :exc:`tokenize.TokenError` " "instead of returning arbitrary ``ERRORTOKEN`` tokens when tokenizing it." msgstr "" +"一些不完整或無效的 Python 程式碼現在會引發 :exc:`tokenize.TokenError`,而不是" +"在 tokenize 時回傳任意 ``ERRORTOKEN`` 標記。" #: ../../whatsnew/3.12.rst:1799 msgid "" "Mixing tabs and spaces as indentation in the same file is not supported " "anymore and will raise a :exc:`TabError`." msgstr "" +"不再支援在同一檔案中混合 Tab 字元和空格作為縮排,並且會引發 :exc:`TabError`。" #: ../../whatsnew/3.12.rst:1802 msgid "" @@ -4292,12 +4792,17 @@ msgid "" "an ``_is_main_interpreter`` attribute. It is a function with no arguments " "that returns ``True`` if the current interpreter is the main interpreter." msgstr "" +":mod:`threading` 模組現在期望 :mod:`!_thread` 模組具有 " +"``_is_main_interpreter`` 屬性。它是一個沒有引數的函式,如果目前直譯器是主直譯" +"器,則回傳 ``True``。" #: ../../whatsnew/3.12.rst:1807 msgid "" "Any library or application that provides a custom ``_thread`` module should " "provide ``_is_main_interpreter()``. (See :gh:`112826`.)" msgstr "" +"任何提供自訂 ``_thread`` 模組的函式庫或應用程式都應該提供 " +"``_is_main_interpreter()``。(參閱 :gh:`112826`。)" #: ../../whatsnew/3.12.rst:1812 msgid "Build Changes" @@ -4311,6 +4816,10 @@ msgid "" "config`` and fall back to manual detection. (Contributed by Christian Heimes " "in :gh:`93939`.)" msgstr "" +"Python 不再使用 :file:`setup.py` 來建立共享 C 擴充模組。在 ``configure`` 腳本" +"中偵測到頭檔和函式庫等建置參數。擴充功能由 :file:`Makefile` 建置。大多數擴充" +"功能使用 ``pkg-config`` 並回退到手動檢測。(由 Christian Heimes 在 :gh:" +"`93939` 中貢獻。)" #: ../../whatsnew/3.12.rst:1820 msgid "" @@ -4318,6 +4827,9 @@ msgid "" "required to build Python. ``va_start()`` is no longer called with a single " "parameter. (Contributed by Kumar Aditya in :gh:`93207`.)" msgstr "" +"現在建置 Python 需要帶有兩個參數的 ``va_start()``,例如 ``va_start(args, " +"format),``。``va_start()`` 不再以單個參數來被呼叫。(由 Kumar Aditya 在 :gh:" +"`93207` 中貢獻。)" #: ../../whatsnew/3.12.rst:1825 msgid "" @@ -4325,6 +4837,8 @@ msgid "" "policy if the Clang compiler accepts the flag. (Contributed by Donghee Na " "in :gh:`89536`.)" msgstr "" +"CPython 現在會使用 ThinLTO 選項作為預設連結時間最佳化策略(如果 Clang 編譯器" +"接受該旗標)。(由 Donghee Na 在 :gh:`89536` 中貢獻。)" #: ../../whatsnew/3.12.rst:1829 msgid "" @@ -4334,10 +4848,14 @@ msgid "" "optimization levels (0, 1, 2) at once. (Contributed by Victor Stinner in :gh:" "`99289`.)" msgstr "" +"在 :file:`Makefile` 中新增 ``COMPILEALL_OPTS`` 變數以覆蓋 ``make install`` 中" +"的 :mod:`compileall` 選項(預設值:``-j0``)。也將 3 個 ``compileall`` 指令合" +"併為一個指令,來一次性為所有最佳化等級(0、1、2)建置 .pyc 檔案。(由 Victor " +"Stinner 在 :gh:`99289` 中貢獻。)" #: ../../whatsnew/3.12.rst:1835 msgid "Add platform triplets for 64-bit LoongArch:" -msgstr "" +msgstr "為 64 位元 LoongArch 新增平台三元組:" #: ../../whatsnew/3.12.rst:1837 msgid "loongarch64-linux-gnusf" @@ -4364,11 +4882,13 @@ msgid "" "Autoconf 2.71 and aclocal 1.16.4 is now required to regenerate :file:" "`configure`. (Contributed by Christian Heimes in :gh:`89886`.)" msgstr "" +"現在需要 Autoconf 2.71 和 aclocal 1.16.4 來重新產生 :file:`configure`。(由 " +"Christian Heimes 在 :gh:`89886` 中貢獻。)" #: ../../whatsnew/3.12.rst:1849 msgid "" "Windows builds and macOS installers from python.org now use OpenSSL 3.0." -msgstr "" +msgstr "來自 python.org 的 Windows 建置和 macOS 安裝程式現在使用 OpenSSL 3.0。" #: ../../whatsnew/3.12.rst:1853 msgid "C API Changes" @@ -4381,6 +4901,9 @@ msgid "" "change in each minor release of CPython without deprecation warnings. Its " "contents are marked by the ``PyUnstable_`` prefix in names." msgstr "" +":pep:`697`:引入 :ref:`不穩定 C API 層 `,設計用於偵錯器和 " +"JIT 編譯器等低階工具。此 API 可能會在 CPython 的每個次要版本中發生更改,而不" +"會出現棄用警告。其內容由名稱中的 ``PyUnstable_`` 前綴標記。" #: ../../whatsnew/3.12.rst:1866 msgid "Code object constructors:" @@ -4432,7 +4955,7 @@ msgstr "(由 Petr Viktorin 於 :gh:`101101` 中貢獻。)" msgid "" ":pep:`697`: Add an API for extending types whose instance memory layout is " "opaque:" -msgstr "" +msgstr ":pep:`697`:新增一個 API 用來擴充實例記憶體佈局不透明的型別:" #: ../../whatsnew/3.12.rst:1885 msgid "" @@ -4447,6 +4970,8 @@ msgid "" ":c:func:`PyObject_GetTypeData` and :c:func:`PyType_GetTypeDataSize` added to " "allow access to subclass-specific instance data." msgstr "" +"新增了 :c:func:`PyObject_GetTypeData` 和 :c:func:`PyType_GetTypeDataSize` 以" +"允許存取特定於子類別的實例資料。" #: ../../whatsnew/3.12.rst:1889 msgid "" @@ -4454,12 +4979,16 @@ msgid "" "to allow safely extending certain variable-sized types, including :c:var:" "`PyType_Type`." msgstr "" +"新增了 :const:`Py_TPFLAGS_ITEMS_AT_END` 和 :c:func:`PyObject_GetItemData` 以" +"允許安全地擴充某些可變大小的型別,包括 :c:var:`PyType_Type`。" #: ../../whatsnew/3.12.rst:1892 msgid "" ":c:macro:`Py_RELATIVE_OFFSET` added to allow defining :c:type:`members " "` in terms of a subclass-specific struct." msgstr "" +"新增了 :c:macro:`Py_RELATIVE_OFFSET` 以允許根據子類別特定的結構定義\\ :c:" +"type:`成員 `。" #: ../../whatsnew/3.12.rst:1895 msgid "(Contributed by Petr Viktorin in :gh:`103509`.)" @@ -4472,12 +5001,17 @@ msgid "" "`PyType_FromModuleAndSpec` using an additional metaclass argument. " "(Contributed by Wenzel Jakob in :gh:`93012`.)" msgstr "" +"新增新的\\ :ref:`受限 C API ` 函式 :c:func:" +"`PyType_FromMetaclass`,它使用附加元類別參數來概括現有的 :c:func:" +"`PyType_FromModuleAndSpec`。(由 Wenzel Jakob 在 :gh:`93012` 中貢獻。)" #: ../../whatsnew/3.12.rst:1902 msgid "" "API for creating objects that can be called using :ref:`the vectorcall " "protocol ` was added to the :ref:`Limited API `:" msgstr "" +"用於建立可使用\\ :ref:`向量呼叫協定 `\\ 進行呼叫的物件的 API 已新" +"增到 :ref:`有限 API ` 中:" #: ../../whatsnew/3.12.rst:1906 msgid ":c:macro:`Py_TPFLAGS_HAVE_VECTORCALL`" @@ -4505,6 +5039,12 @@ msgid "" "``Py_TPFLAGS_HAVE_VECTORCALL`` flag. (Contributed by Petr Viktorin in :gh:" "`93274`.)" msgstr "" +"現在,當重新分配類別的 :py:meth:`~object.__call__` 方法時,:c:macro:" +"`Py_TPFLAGS_HAVE_VECTORCALL` 旗標將從類中刪除。這使得 vectorcall 可以安全地與" +"可變型別一起使用(即沒有不可變旗標的堆型別,:const:" +"`Py_TPFLAGS_IMMUTABLETYPE`)。不覆蓋 :c:member:`~PyTypeObject.tp_call` 的可變" +"型別現在繼承 ``Py_TPFLAGS_HAVE_VECTORCALL`` 旗標。(由 Petr Viktorin 在 :gh:" +"`93274` 中貢獻。)" #: ../../whatsnew/3.12.rst:1919 msgid "" @@ -4513,12 +5053,17 @@ msgid "" "classes to support object :attr:`~object.__dict__` and weakrefs with less " "bookkeeping, using less memory and with faster access." msgstr "" +"新增了 :c:macro:`Py_TPFLAGS_MANAGED_DICT` 和 :c:macro:" +"`Py_TPFLAGS_MANAGED_WEAKREF` 旗標。這允許擴充類別以更少的簿記 (bookkeeping)、" +"使用更少的記憶體和更快的存取來支援物件 :attr:`~object.__dict__` 和 weakrefs。" #: ../../whatsnew/3.12.rst:1924 msgid "" "API for performing calls using :ref:`the vectorcall protocol ` " "was added to the :ref:`Limited API `:" msgstr "" +"使用\\ :ref:`向量呼叫協定 `\\ 執行呼叫的 API 已新增到\\ :ref:`有" +"限 API ` 中:" #: ../../whatsnew/3.12.rst:1928 msgid ":c:func:`PyObject_Vectorcall`" @@ -4538,6 +5083,8 @@ msgid "" "protocol are now available in the :ref:`Limited API `. (Contributed " "by Wenzel Jakob in :gh:`98586`.)" msgstr "" +"這意味著向量呼叫協定的傳入和傳出端現在都可以在\\ :ref:`受限 API ` 中" +"使用。(由 Wenzel Jakob 在 :gh:`98586` 中貢獻。)" #: ../../whatsnew/3.12.rst:1936 msgid "" @@ -4546,6 +5093,9 @@ msgid "" "functions in all running threads in addition to the calling one. " "(Contributed by Pablo Galindo in :gh:`93503`.)" msgstr "" +"新增兩個公開函式 :c:func:`PyEval_SetProfileAllThreads` 和 :c:func:" +"`PyEval_SetTraceAllThreads`,它們允許在除呼叫執行緒之外的所有正在執行的執行緒" +"中設定追蹤和分析函式。(由 Pablo Galindo 在 :gh:`93503` 中貢獻。)" #: ../../whatsnew/3.12.rst:1942 msgid "" @@ -4553,6 +5103,9 @@ msgid "" "the vectorcall field of a given :c:type:`PyFunctionObject`. (Contributed by " "Andrew Frost in :gh:`92257`.)" msgstr "" +"將新函式 :c:func:`PyFunction_SetVectorcall` 新增至 C API,用於設定給定 :c:" +"type:`PyFunctionObject` 的向量呼叫欄位。(由 Andrew Frost 在 :gh:`92257` 中貢" +"獻。)" #: ../../whatsnew/3.12.rst:1946 msgid "" @@ -4562,6 +5115,9 @@ msgid "" "interpreters, JIT compilers, or debuggers. (Contributed by Carl Meyer in :gh:" "`91052`.)" msgstr "" +"C API 現在允許透過 :c:func:`PyDict_AddWatcher`、:c:func:`PyDict_Watch` 註冊回" +"呼以及每當修改字典時呼叫的相關 API。它旨在供最佳化直譯器、JIT 編譯器或偵錯器" +"使用。(由 Carl Meyer 在 :gh:`91052` 中貢獻。)" #: ../../whatsnew/3.12.rst:1952 msgid "" @@ -4569,6 +5125,8 @@ msgid "" "callbacks to receive notification on changes to a type. (Contributed by Carl " "Meyer in :gh:`91051`.)" msgstr "" +"新增 :c:func:`PyType_AddWatcher` 和 :c:func:`PyType_Watch` API 來註冊回呼以接" +"收有關型別變更的通知。(由 Carl Meyer 在 :gh:`91051` 貢獻。)" #: ../../whatsnew/3.12.rst:1956 msgid "" @@ -4576,6 +5134,9 @@ msgid "" "register callbacks to receive notification on creation and destruction of " "code objects. (Contributed by Itamar Oren in :gh:`91054`.)" msgstr "" +"新增 :c:func:`PyCode_AddWatcher` 和 :c:func:`PyCode_ClearWatcher` API 來註冊" +"回呼以接收有關建立和銷毀程式碼物件的通知。(由 Itamar Oren 在 :gh:`91054` 中" +"貢獻。)" #: ../../whatsnew/3.12.rst:1961 msgid "" @@ -4583,6 +5144,8 @@ msgid "" "get a frame variable by its name. (Contributed by Victor Stinner in :gh:" "`91248`.)" msgstr "" +"新增 :c:func:`PyFrame_GetVar` 和 :c:func:`PyFrame_GetVarString` 函式以透過名" +"稱獲取 frame 變數。(由 Victor Stinner 在 :gh:`91248` 中貢獻。)" #: ../../whatsnew/3.12.rst:1965 msgid "" @@ -4633,6 +5196,8 @@ msgid "" ":pep:`683`: Introduce *Immortal Objects*, which allows objects to bypass " "reference counts, and related changes to the C-API:" msgstr "" +":pep:`683`:引入\\ *不滅物件*,它允許物件繞過參照計數,以及對 C-API 的相關變" +"更:" #: ../../whatsnew/3.12.rst:1991 msgid "``_Py_IMMORTAL_REFCNT``: The reference count that defines an object" @@ -4640,12 +5205,12 @@ msgstr "``_Py_IMMORTAL_REFCNT``:定義物件的參照計數" #: ../../whatsnew/3.12.rst:1992 msgid "as immortal." -msgstr "" +msgstr "為不滅的。" #: ../../whatsnew/3.12.rst:1993 msgid "" "``_Py_IsImmortal`` Checks if an object has the immortal reference count." -msgstr "" +msgstr "``_Py_IsImmortal`` 檢查物件是否具有不滅參照計數。" #: ../../whatsnew/3.12.rst:1994 msgid "``PyObject_HEAD_INIT`` This will now initialize reference count to" @@ -4669,7 +5234,7 @@ msgstr "``SSSTATE_INTERNED_IMMORTAL_STATIC`` 駐留的 unicode 的識別字" #: ../../whatsnew/3.12.rst:1999 msgid "objects that are immortal and static" -msgstr "不滅且靜態的物體" +msgstr "不滅且靜態的物件" #: ../../whatsnew/3.12.rst:2000 msgid "``sys.getunicodeinternedsize`` This returns the total number of unicode" @@ -4680,6 +5245,7 @@ msgid "" "objects that have been interned. This is now needed for :file:`refleak.py` " "to correctly track reference counts and allocated blocks" msgstr "" +"已駐留的物件。現在 :file:`refleak.py` 需要這個來正確追蹤參照計數和分配的區塊" #: ../../whatsnew/3.12.rst:2004 msgid "(Contributed by Eddie Elizondo in :gh:`84436`.)" @@ -4703,12 +5269,17 @@ msgid "" "`Py_DECREF` functions are now implemented as opaque function calls to hide " "implementation details. (Contributed by Victor Stinner in :gh:`105387`.)" msgstr "" +"在受限 C API 版本 3.12 中,:c:func:`Py_INCREF` 和 :c:func:`Py_DECREF` 函式現" +"在被實作為不透明函式呼叫,以隱藏實作細節。(由 Victor Stinner 在 :gh:" +"`105387` 中貢獻。)" #: ../../whatsnew/3.12.rst:2020 msgid "" "Legacy Unicode APIs based on ``Py_UNICODE*`` representation has been " "removed. Please migrate to APIs based on UTF-8 or ``wchar_t*``." msgstr "" +"基於 ``Py_UNICODE*`` 表示的舊版 Unicode API 已被刪除。請遷移到基於 UTF-8 或 " +"``wchar_t*`` 的 API。" #: ../../whatsnew/3.12.rst:2023 msgid "" @@ -4716,6 +5287,9 @@ msgid "" "``Py_UNICODE*`` based format (e.g. ``u``, ``Z``) anymore. Please migrate to " "other formats for Unicode like ``s``, ``z``, ``es``, and ``U``." msgstr "" +"像 :c:func:`PyArg_ParseTuple` 這樣的參數剖析函式不再支援基於 ``Py_UNICODE*`` " +"的格式(例如 ``u``, ``Z``)。請遷移到其他 Unicode 格式,例如 ``s``、 ``z``、 " +"``es`` 和 ``U``。" #: ../../whatsnew/3.12.rst:2027 msgid "" @@ -4725,6 +5299,10 @@ msgid "" "breakage, consider using the existing public C-API instead, or, if " "necessary, the (internal-only) ``_PyObject_GET_WEAKREFS_LISTPTR()`` macro." msgstr "" +"所有靜態內建型別的 ``tp_weaklist`` 始終為 ``NULL``。這是 ``PyTypeObject`` 上" +"的一個僅限內部的欄位,但我們指出了這一變更,以防有人碰巧直接存取該欄位。為了" +"避免損壞,請考慮使用現有的公開 C-API,或者,如有必要,使用(僅限內部)\\ " +"``_PyObject_GET_WEAKREFS_LISTPTR()`` 巨集。" #: ../../whatsnew/3.12.rst:2034 msgid "" @@ -4733,12 +5311,17 @@ msgid "" "this. We mention this in case someone happens to be accessing the internal-" "only field directly." msgstr "" +"這個僅限內部的 :c:member:`PyTypeObject.tp_subclasses` 現在可能不是有效的物件" +"指標。它的型別已更改為 :c:expr:`void *` 以反映這一點。我們提到這一點是為了防" +"止有人碰巧直接存取僅限內部的欄位。" #: ../../whatsnew/3.12.rst:2039 msgid "" "To get a list of subclasses, call the Python method :py:meth:`~type." "__subclasses__` (using :c:func:`PyObject_CallMethod`, for example)." msgstr "" +"要獲取子類別串列,請呼叫 Python 方法 :py:meth:`~class.__subclasses__`\\ (例" +"如,使用 :c:func:`PyObject_CallMethod`)。" #: ../../whatsnew/3.12.rst:2043 msgid "" @@ -4748,6 +5331,10 @@ msgid "" "and :c:func:`PyUnicode_FromFormatV`. (Contributed by Serhiy Storchaka in :gh:" "`98836`.)" msgstr "" +"在 :c:func:`PyUnicode_FromFormat` 和 :c:func:`PyUnicode_FromFormatV` 中新增對" +"更多格式化選項的支援(左對齊、八進制、大寫十六進位、:c:type:`intmax_t`、:c:" +"type:`ptrdiff_t`、:c:type:`wchar_t` C 字串、可變寬度和精度)。(由 Serhiy " +"Storchaka 在 :gh:`98836` 中貢獻。)" #: ../../whatsnew/3.12.rst:2049 msgid "" @@ -4757,12 +5344,18 @@ msgid "" "the result string, and any extra arguments discarded. (Contributed by Serhiy " "Storchaka in :gh:`95781`.)" msgstr "" +":c:func:`PyUnicode_FromFormat` 和 :c:func:`PyUnicode_FromFormatV` 中無法識別" +"的格式字元現在會設定 :exc:`SystemError`。在以前的版本中,它導致格式字串的所有" +"其餘部分按原樣複製到結果字串,並丟棄任何額外的參數。(由 Serhiy Storchaka " +"在 :gh:`95781` 中貢獻。)" #: ../../whatsnew/3.12.rst:2055 msgid "" "Fix wrong sign placement in :c:func:`PyUnicode_FromFormat` and :c:func:" "`PyUnicode_FromFormatV`. (Contributed by Philip Georgi in :gh:`95504`.)" msgstr "" +"修正 :c:func:`PyUnicode_FromFormat` 和 :c:func:`PyUnicode_FromFormatV` 中錯誤" +"的符號位置。(由 Philip Georgi 在 :gh:`95504` 中貢獻。)" #: ../../whatsnew/3.12.rst:2059 msgid "" @@ -4777,6 +5370,15 @@ msgid "" "traverse and clear their instance's dictionaries. To clear weakrefs, call :c:" "func:`PyObject_ClearWeakRefs`, as before." msgstr "" +"想要新增 :attr:`~object.__dict__` 或弱參照 (weak reference) 插槽的擴充類別應" +"分別使用 :c:macro:`Py_TPFLAGS_MANAGED_DICT` 和 :c:macro:" +"`Py_TPFLAGS_MANAGED_WEAKREF`,而非 ``tp_dictoffset`` 和 " +"``tp_weaklistoffset``。``tp_dictoffset`` 和 ``tp_weaklistoffset`` 的使用仍受" +"支援,但無法完全支援多重繼承 (:gh:`95589`),且效能可能較差。宣告 :c:macro:" +"`Py_TPFLAGS_MANAGED_DICT` 的類別必須呼叫 :c:func:`!" +"_PyObject_VisitManagedDict` 和 :c:func:`!_PyObject_ClearManagedDict` 來走訪和" +"清除其實例的字典。若要清除弱參照,請如同之前一樣呼叫 :c:func:" +"`PyObject_ClearWeakRefs`。" #: ../../whatsnew/3.12.rst:2071 msgid "" @@ -4785,6 +5387,9 @@ msgid "" "exact :class:`bytes` type is accepted for bytes strings. (Contributed by " "Victor Stinner in :gh:`98393`.)" msgstr "" +":c:func:`PyUnicode_FSDecoder` 函式不再接受類似位元組的路徑,例如 :class:" +"`bytearray` 和 :class:`memoryview` 型別:對於位元組字串,僅接受確切的 :class:" +"`bytes` 型別。(由 Victor Stinner 在 :gh:`98393` 中貢獻。)" #: ../../whatsnew/3.12.rst:2076 msgid "" @@ -4793,6 +5398,9 @@ msgid "" "effects, these side effects are no longer duplicated. (Contributed by Victor " "Stinner in :gh:`98724`.)" msgstr "" +":c:macro:`Py_CLEAR`、:c:macro:`Py_SETREF` 和 :c:macro:`Py_XSETREF` 巨集現在僅" +"計算其引數一次。如果引數有副作用,這些副作用將不再重複。(由 Victor Stinner " +"在 :gh:`98724` 中貢獻。)" #: ../../whatsnew/3.12.rst:2081 msgid "" @@ -4801,6 +5409,9 @@ msgid "" "that set the error indicator now normalize the exception before storing it. " "(Contributed by Mark Shannon in :gh:`101578`.)" msgstr "" +"直譯器的錯誤指示器現在總是標準化的。這意味著 :c:func:`PyErr_SetObject`、:c:" +"func:`PyErr_SetString` 和其他設定錯誤指示器的函式現在會在儲存例外之前對其進行" +"規範化。(由 Mark Shannon 在 :gh:`101578` 中貢獻。)" #: ../../whatsnew/3.12.rst:2086 msgid "" @@ -4809,12 +5420,15 @@ msgid "" "debug builds. If you happen to be using it then you'll need to start using " "``_Py_GetGlobalRefTotal()``." msgstr "" +"``_Py_RefTotal`` 不再具有權威性,只是為了 ABI 相容性而保留。請注意,它是內部" +"全域的,僅在偵錯版本中可用。如果你碰巧正在使用它,那麼你需要開始使用 " +"``_Py_GetGlobalRefTotal()``。" #: ../../whatsnew/3.12.rst:2091 msgid "" "The following functions now select an appropriate metaclass for the newly " "created type:" -msgstr "" +msgstr "現在,以下函式為新建立的型別選擇適當的元類別:" #: ../../whatsnew/3.12.rst:2094 msgid ":c:func:`PyType_FromSpec`" @@ -4835,6 +5449,9 @@ msgid "" "functions ignore ``tp_new`` of the metaclass, possibly allowing incomplete " "initialization." msgstr "" +"建立元類別覆蓋 :c:member:`~PyTypeObject.tp_new` 的類別已被棄用,並且在 " +"Python 3.14+ 中將被禁止。請注意,這些函式忽略元類別的 ``tp_new``,可能允許不" +"完整的初始化。" #: ../../whatsnew/3.12.rst:2103 msgid "" @@ -4842,6 +5459,9 @@ msgid "" "disallows creating classes whose metaclass overrides ``tp_new`` (:meth:" "`~object.__new__` in Python)." msgstr "" +"請注意,:c:func:`PyType_FromMetaclass`\\ (在 Python 3.12 中新增)已經不允許" +"建立其元類別覆蓋 ``tp_new``\\ (Python 中的 :meth:`~object.__new__`)的類別" +"別。" #: ../../whatsnew/3.12.rst:2107 msgid "" @@ -4851,16 +5471,21 @@ msgid "" "since (meta)classes assume that ``tp_new`` was called. There is no simple " "general workaround. One of the following may work for you:" msgstr "" +"由於 ``tp_new`` 幾乎覆蓋了 ``PyType_From*`` 函式所做的一切,因此兩者彼此不相" +"容。現有的行為(在型別建立的幾個步驟中忽略元類別)通常是不安全的,因為(元)" +"類別假設 ``tp_new`` 有被呼叫。沒有簡單的通用解決方法。以下其中一項可能適合" +"你:" #: ../../whatsnew/3.12.rst:2114 msgid "If you control the metaclass, avoid using ``tp_new`` in it:" -msgstr "" +msgstr "如果你控制元類別,請避免在其中使用 ``tp_new``:" #: ../../whatsnew/3.12.rst:2116 msgid "" "If initialization can be skipped, it can be done in :c:member:`~PyTypeObject." "tp_init` instead." msgstr "" +"如果可以跳過初始化,則可以在 :c:member:`~PyTypeObject.tp_init` 中完成。" #: ../../whatsnew/3.12.rst:2118 msgid "" @@ -4869,6 +5494,9 @@ msgid "" "`Py_TPFLAGS_DISALLOW_INSTANTIATION` flag. This makes it acceptable for " "``PyType_From*`` functions." msgstr "" +"如果元類別不需要從 Python 實例化,請使用 :c:macro:" +"`Py_TPFLAGS_DISALLOW_INSTANTIATION` 旗標將其 ``tp_new`` 設定為 ``NULL``。這使" +"得 ``PyType_From*`` 函式能夠接受。" #: ../../whatsnew/3.12.rst:2123 msgid "" @@ -4876,12 +5504,16 @@ msgid "" "(slots or setting the instance size), create types by :ref:`calling ` " "the metaclass." msgstr "" +"避免使用 ``PyType_From*`` 函式:如果你不需要特定於 C 的功能(插槽 (slot) 或設" +"定實例大小),請透過\\ :ref:`呼叫 `\\ 元類別來建立型別。" #: ../../whatsnew/3.12.rst:2127 msgid "" "If you *know* the ``tp_new`` can be skipped safely, filter the deprecation " "warning out using :func:`warnings.catch_warnings` from Python." msgstr "" +"如果你\\ *知道*\\ 可以安全地跳過 ``tp_new``,請使用 Python 中的 :func:" +"`warnings.catch_warnings` 過濾掉棄用警告。" #: ../../whatsnew/3.12.rst:2130 msgid "" @@ -4890,6 +5522,9 @@ msgid "" "because clients generally rely on process-wide global state (since these " "callbacks have no way of recovering extension module state)." msgstr "" +":c:var:`PyOS_InputHook` 和 :c:var:`PyOS_ReadlineFunctionPointer` 不再在\\ :" +"ref:`子直譯器 (subinterpreter) ` 中呼叫。這是因為客" +"戶端通常依賴於行程範圍的全域狀態(因為這些回呼無法恢復擴充模組狀態)。" #: ../../whatsnew/3.12.rst:2135 msgid "" @@ -4897,6 +5532,8 @@ msgid "" "a subinterpreter that they don't support (or haven't yet been loaded in). " "See :gh:`104668` for more info." msgstr "" +"這也避免了擴充可能發現自己在它們不支援(或尚未載入)的子直譯器中運行的情況。" +"請參閱 :gh:`104668` 了解更多資訊。" #: ../../whatsnew/3.12.rst:2139 msgid "" @@ -4908,6 +5545,10 @@ msgid "" "efficient access to the value of :c:struct:`PyLongObject`\\s which fit into " "a single machine word:" msgstr "" +":c:struct:`PyLongObject` 已更改其內部結構以獲得更好的效能。儘管 :c:struct:" +"`PyLongObject` 的內部是私有的,但它們被一些擴充模組使用。不應再直接存取內部欄" +"位,而應使用以 ``PyLong_...`` 開頭的 API 函式。提供了兩個新的\\ *不穩定* API " +"函式,用於有效存取適合單一機器字的 :c:struct:`PyLongObject` 的值:" #: ../../whatsnew/3.12.rst:2147 msgid ":c:func:`PyUnstable_Long_IsCompact`" @@ -4925,6 +5566,10 @@ msgid "" "allocator is not already thread-safe and you need guidance then please " "create a new GitHub issue and CC ``@ericsnowcurrently``." msgstr "" +"透過 :c:func:`PyMem_SetAllocator` 設定的自訂分配器現在要求是執行緒安全的,無" +"論記憶體域如何。沒有自己狀態的分配器(包括 \"hooks\")不受影響。如果你的自訂" +"分配器還不是執行緒安全的並且你需要指導,請建立一個新的 GitHub 問題並抄送 " +"``@ericsnowcurrently``。" #: ../../whatsnew/3.12.rst:2160 msgid "" @@ -4934,6 +5579,10 @@ msgid "" "in Python 3.14. (Contributed by Ramvikrams and Kumar Aditya in :gh:`101193`. " "PEP by Ken Jin.)" msgstr "" +"根據 :pep:`699`,:c:type:`PyDictObject` 中的 ``ma_version_tag`` 欄位對於擴充" +"模組已被棄用。存取該欄位將在編譯時生成編譯器警告。該欄位將在 Python 3.14 中刪" +"除。(由 Ramvikrams 和 Kumar Aditya 在 :gh:`101193` 中貢獻。PEP 為 Ken Jin 所" +"撰寫。)" #: ../../whatsnew/3.12.rst:2165 msgid "Deprecate global configuration variable:" @@ -5077,6 +5726,8 @@ msgid "" "Creating :c:data:`immutable types ` with mutable " "bases is deprecated and will be disabled in Python 3.14. (:gh:`95388`)" msgstr "" +"建立具有可變基底的\\ :c:data:`不可變型別 `\\ 已被棄" +"用,並將在 Python 3.14 中停用。(:gh:`95388`)" #: ../../whatsnew/3.12.rst:2197 msgid "" @@ -5144,6 +5795,8 @@ msgid "" "In some configurations, ```` is not included from :file:`Python." "h`. It should be included manually when using ``offsetof()``." msgstr "" +"在某些配置中,:file:`Python.h` 中不包含 ````。使用 ``offsetof()`` " +"時應手動包含它。" #: ../../whatsnew/3.12.rst:2220 msgid "" @@ -5151,6 +5804,8 @@ msgid "" "original names. Your old code can stay unchanged, unless the extra include " "and non-namespaced macros bother you greatly." msgstr "" +"已棄用的標頭繼續以原始名稱提供其原始內容。你的舊程式碼可以保持不變,除非額外" +"的包含巨集和非命名空間巨集對你造成很大困擾。" #: ../../whatsnew/3.12.rst:2225 msgid "" @@ -5166,6 +5821,9 @@ msgid "" "func:`PyErr_GetRaisedException` and :c:func:`PyErr_SetRaisedException` " "instead. (Contributed by Mark Shannon in :gh:`101578`.)" msgstr "" +":c:func:`PyErr_Fetch` 和 :c:func:`PyErr_Restore` 已棄用。請改用 :c:func:" +"`PyErr_GetRaisedException` 和 :c:func:`PyErr_SetRaisedException`。(由 Mark " +"Shannon 在 :gh:`101578` 中貢獻。)" #: ../../whatsnew/3.12.rst:2233 msgid "" @@ -5643,7 +6301,7 @@ msgstr "" #: ../../deprecations/c-api-pending-removal-in-future.rst:29 msgid "Thread Local Storage (TLS) API:" -msgstr "執行緒局部儲存 (Thread Local Storage, TLS) API:" +msgstr "執行緒區域儲存 (Thread Local Storage, TLS) API:" #: ../../deprecations/c-api-pending-removal-in-future.rst:31 msgid "" @@ -5687,7 +6345,7 @@ msgstr "" #: ../../whatsnew/3.12.rst:2262 msgid "Legacy Unicode APIs have been removed. See :pep:`623` for detail." -msgstr "" +msgstr "舊版 Unicode API 已被刪除。有關詳細資訊請參閱 :pep:`623`。" #: ../../whatsnew/3.12.rst:2264 msgid ":c:macro:`!PyUnicode_WCHAR_KIND`" @@ -5732,6 +6390,3 @@ msgid "" msgstr "" "移除 ``PyUnicode_InternImmortal()`` 函式巨集。(由 Victor Stinner 於 :gh:" "`85858` 中貢獻。)" - -#~ msgid "Delegation of ``int()`` to ``__trunc__()`` method." -#~ msgstr "將 ``int()`` 委派給 ``__trunc__()`` 方法。"