diff --git a/about.po b/about.po index 34c5041570..73207a19f7 100644 --- a/about.po +++ b/about.po @@ -14,7 +14,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-08-05 00:19+0000\n" +"POT-Creation-Date: 2025-02-07 08:41+0000\n" "PO-Revision-Date: 2022-05-12 00:11+0800\n" "Last-Translator: hsiao yi \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -27,18 +27,21 @@ msgstr "" "X-Generator: Poedit 3.0.1\n" #: ../../about.rst:3 -msgid "About these documents" +#, fuzzy +msgid "About this documentation" msgstr "關於這些說明文件" #: ../../about.rst:6 +#, fuzzy msgid "" -"These documents are generated from `reStructuredText`_ sources by `Sphinx`_, " -"a document processor specifically written for the Python documentation." +"Python's documentation is generated from `reStructuredText`_ sources using " +"`Sphinx`_, a documentation generator originally created for Python and now " +"maintained as an independent project." msgstr "" "這些說明文件是透過 `Sphinx`_ (一個專為 Python 說明文件所撰寫的文件處理器)將" "使用 `reStructuredText`_ 撰寫的原始檔轉換而成。" -#: ../../about.rst:15 +#: ../../about.rst:16 msgid "" "Development of the documentation and its toolchain is an entirely volunteer " "effort, just like Python itself. If you want to contribute, please take a " @@ -49,18 +52,19 @@ msgstr "" "報臭蟲,請見 :ref:`reporting-bugs` 頁面,內含相關資訊。我們永遠歡迎新的自願者" "加入!" -#: ../../about.rst:20 +#: ../../about.rst:21 msgid "Many thanks go to:" msgstr "致謝:" -#: ../../about.rst:22 +#: ../../about.rst:23 +#, fuzzy msgid "" "Fred L. Drake, Jr., the creator of the original Python documentation toolset " -"and writer of much of the content;" +"and author of much of the content;" msgstr "" "Fred L. Drake, Jr.,原始 Python 文件工具集的創造者以及一大部份內容的作者;" -#: ../../about.rst:24 +#: ../../about.rst:25 msgid "" "the `Docutils `_ project for creating " "reStructuredText and the Docutils suite;" @@ -68,7 +72,7 @@ msgstr "" "創造 reStructuredText 和 Docutils 工具組的 `Docutils `_ 專案;" -#: ../../about.rst:26 +#: ../../about.rst:27 msgid "" "Fredrik Lundh for his Alternative Python Reference project from which Sphinx " "got many good ideas." @@ -76,11 +80,12 @@ msgstr "" "Fredrik Lundh 先生,Sphinx 從他的 Alternative Python Reference 計劃中獲得許多" "的好主意。" -#: ../../about.rst:31 -msgid "Contributors to the Python Documentation" +#: ../../about.rst:32 +#, fuzzy +msgid "Contributors to the Python documentation" msgstr "Python 文件的貢獻者們" -#: ../../about.rst:33 +#: ../../about.rst:34 msgid "" "Many people have contributed to the Python language, the Python standard " "library, and the Python documentation. See :source:`Misc/ACKS` in the " @@ -89,7 +94,7 @@ msgstr "" "許多人都曾為 Python 這門語言、Python 標準函式庫和 Python 說明文件貢獻過。" "Python 所發佈的原始碼中含有部份貢獻者的清單,請見 :source:`Misc/ACKS` 。" -#: ../../about.rst:37 +#: ../../about.rst:38 msgid "" "It is only with the input and contributions of the Python community that " "Python has such wonderful documentation -- Thank You!" diff --git a/c-api/allocation.po b/c-api/allocation.po index c4605012ef..d0b999e6c0 100644 --- a/c-api/allocation.po +++ b/c-api/allocation.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-08-09 00:03+0000\n" +"POT-Creation-Date: 2025-04-24 05:56+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-" @@ -27,18 +27,17 @@ msgid "Allocating Objects on the Heap" msgstr "在 heap 上分配物件" #: ../../c-api/allocation.rst:17 +#, fuzzy msgid "" "Initialize a newly allocated object *op* with its type and initial " -"reference. Returns the initialized object. If *type* indicates that the " -"object participates in the cyclic garbage detector, it is added to the " -"detector's set of observed objects. Other fields of the object are not " -"affected." +"reference. Returns the initialized object. Other fields of the object are " +"not affected." msgstr "" "用它的型別和初始參照來初始化新分配物件 *op*。已初始化的物件會被回傳。如果 " "*type* 表示了該物件參與迴圈垃圾檢查器,則將其新增到檢查器的觀察物件集合中。物" "件的其他欄位不受影響。" -#: ../../c-api/allocation.rst:26 +#: ../../c-api/allocation.rst:24 msgid "" "This does everything :c:func:`PyObject_Init` does, and also initializes the " "length information for a variable-size object." @@ -46,7 +45,7 @@ msgstr "" "它會做到 :c:func:`PyObject_Init` 的所有功能,並且會初始化一個大小可變物件的長" "度資訊。" -#: ../../c-api/allocation.rst:32 +#: ../../c-api/allocation.rst:30 msgid "" "Allocate a new Python object using the C structure type *TYPE* and the " "Python type object *typeobj* (``PyTypeObject*``). Fields not defined by the " @@ -60,7 +59,14 @@ msgstr "" "化;呼叫者會擁有那個對於物件的唯一參照(物件的參照計數為一)。記憶體分配大小" "由 type 物件的 :c:member:`~PyTypeObject.tp_basicsize` 欄位來指定。" -#: ../../c-api/allocation.rst:43 +#: ../../c-api/allocation.rst:38 +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." +msgstr "" + +#: ../../c-api/allocation.rst:45 msgid "" "Allocate a new Python object using the C structure type *TYPE* and the " "Python type object *typeobj* (``PyTypeObject*``). Fields not defined by the " @@ -79,7 +85,14 @@ msgstr "" "於實現如 tuple 這種能夠在建立期間決定自己大小的物件是很實用的。將欄位的陣列嵌" "入到相同的記憶體分配中可以減少記憶體分配的次數,這提高了記憶體管理的效率。" -#: ../../c-api/allocation.rst:57 +#: ../../c-api/allocation.rst:56 +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." +msgstr "" + +#: ../../c-api/allocation.rst:63 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:" @@ -92,7 +105,7 @@ msgstr "" "handler 中呼叫。呼叫這個函式以後,物件的各欄位都不可以被存取,因為原本分配的" "記憶體已不再是一個有效的 Python 物件。" -#: ../../c-api/allocation.rst:66 +#: ../../c-api/allocation.rst:72 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 " @@ -101,10 +114,10 @@ msgstr "" "這個物件像是 Python 中的 ``None``。它只應該透過 :c:macro:`Py_None` 巨集來存" "取,該巨集的拿到指向該物件的指標。" -#: ../../c-api/allocation.rst:73 +#: ../../c-api/allocation.rst:79 msgid ":c:func:`PyModule_Create`" msgstr ":c:func:`PyModule_Create`" -#: ../../c-api/allocation.rst:74 +#: ../../c-api/allocation.rst:80 msgid "To allocate and create extension modules." msgstr "分配記憶體和建立擴充模組。" diff --git a/c-api/arg.po b/c-api/arg.po index f62175c411..c11820292c 100644 --- a/c-api/arg.po +++ b/c-api/arg.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-05-04 20:08+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-" @@ -25,7 +25,7 @@ msgstr "剖析引數與建置數值" #: ../../c-api/arg.rst:8 msgid "" -"These functions are useful when creating your own extensions functions and " +"These functions are useful when creating your own extension functions and " "methods. Additional information and examples are available in :ref:" "`extending-index`." msgstr "" @@ -177,7 +177,7 @@ msgid "" "encoding." msgstr "" -#: ../../c-api/arg.rst:113 ../../c-api/arg.rst:581 +#: ../../c-api/arg.rst:113 ../../c-api/arg.rst:593 msgid "``z`` (:class:`str` or ``None``) [const char \\*]" msgstr "``z``\\ (:class:`str` 或 ``None``)[const char \\*]" @@ -417,38 +417,58 @@ msgid "Numbers" msgstr "數字" #: ../../c-api/arg.rst:232 +msgid "" +"These formats allow representing Python numbers or single characters as C " +"numbers. Formats that require :class:`int`, :class:`float` or :class:" +"`complex` can also use the corresponding special methods :meth:`~object." +"__index__`, :meth:`~object.__float__` or :meth:`~object.__complex__` to " +"convert the Python object to the required type." +msgstr "" + +#: ../../c-api/arg.rst:238 +msgid "" +"For signed integer formats, :exc:`OverflowError` is raised if the value is " +"out of range for the C type. For unsigned integer formats, no range checking " +"is done --- the most significant bits are silently truncated when the " +"receiving field is too small to receive the value." +msgstr "" + +#: ../../c-api/arg.rst:244 msgid "``b`` (:class:`int`) [unsigned char]" msgstr "``b`` (:class:`int`) [unsigned char]" -#: ../../c-api/arg.rst:233 +#: ../../c-api/arg.rst:245 +#, fuzzy msgid "" -"Convert a nonnegative Python integer to an unsigned tiny int, stored in a C :" -"c:expr:`unsigned char`." -msgstr "" +"Convert a nonnegative Python integer to an unsigned tiny integer, stored in " +"a C :c:expr:`unsigned char`." +msgstr "將一個 Python 整數轉換成 C 的 :c:expr:`int`。" -#: ../../c-api/arg.rst:236 ../../c-api/arg.rst:615 +#: ../../c-api/arg.rst:248 ../../c-api/arg.rst:627 msgid "``B`` (:class:`int`) [unsigned char]" msgstr "``B`` (:class:`int`) [unsigned char]" -#: ../../c-api/arg.rst:237 +#: ../../c-api/arg.rst:249 +#, fuzzy msgid "" -"Convert a Python integer to a tiny int without overflow checking, stored in " -"a C :c:expr:`unsigned char`." +"Convert a Python integer to a tiny integer without overflow checking, stored " +"in a C :c:expr:`unsigned char`." msgstr "" +"將一個 Python 整數轉換成 C 的 :c:expr:`unsigned int`,轉換過程無溢位檢查。" -#: ../../c-api/arg.rst:240 ../../c-api/arg.rst:609 +#: ../../c-api/arg.rst:252 ../../c-api/arg.rst:621 msgid "``h`` (:class:`int`) [short int]" msgstr "``h`` (:class:`int`) [short int]" -#: ../../c-api/arg.rst:241 +#: ../../c-api/arg.rst:253 msgid "Convert a Python integer to a C :c:expr:`short int`." msgstr "將一個 Python 整數轉換成 C 的 :c:expr:`short int`。" -#: ../../c-api/arg.rst:243 ../../c-api/arg.rst:618 +#: ../../c-api/arg.rst:255 ../../c-api/arg.rst:630 msgid "``H`` (:class:`int`) [unsigned short int]" msgstr "``H`` (:class:`int`) [unsigned short int]" -#: ../../c-api/arg.rst:244 +#: ../../c-api/arg.rst:256 msgid "" "Convert a Python integer to a C :c:expr:`unsigned short int`, without " "overflow checking." @@ -456,57 +476,57 @@ msgstr "" "將一個 Python 整數轉換成 C 的 :c:expr:`unsigned short int`,轉換過程無溢位檢" "查。" -#: ../../c-api/arg.rst:247 ../../c-api/arg.rst:603 +#: ../../c-api/arg.rst:259 ../../c-api/arg.rst:615 msgid "``i`` (:class:`int`) [int]" msgstr "``i`` (:class:`int`) [int]" -#: ../../c-api/arg.rst:248 +#: ../../c-api/arg.rst:260 msgid "Convert a Python integer to a plain C :c:expr:`int`." msgstr "將一個 Python 整數轉換成 C 的 :c:expr:`int`。" -#: ../../c-api/arg.rst:250 ../../c-api/arg.rst:621 +#: ../../c-api/arg.rst:262 ../../c-api/arg.rst:633 msgid "``I`` (:class:`int`) [unsigned int]" msgstr "``I`` (:class:`int`) [unsigned int]" -#: ../../c-api/arg.rst:251 +#: ../../c-api/arg.rst:263 msgid "" "Convert a Python integer to a C :c:expr:`unsigned int`, without overflow " "checking." msgstr "" "將一個 Python 整數轉換成 C 的 :c:expr:`unsigned int`,轉換過程無溢位檢查。" -#: ../../c-api/arg.rst:254 ../../c-api/arg.rst:612 +#: ../../c-api/arg.rst:266 ../../c-api/arg.rst:624 msgid "``l`` (:class:`int`) [long int]" msgstr "``l`` (:class:`int`) [long int]" -#: ../../c-api/arg.rst:255 +#: ../../c-api/arg.rst:267 msgid "Convert a Python integer to a C :c:expr:`long int`." msgstr "將一個 Python 整數轉換成 C 的 :c:expr:`long int`。" -#: ../../c-api/arg.rst:257 ../../c-api/arg.rst:624 +#: ../../c-api/arg.rst:269 ../../c-api/arg.rst:636 msgid "``k`` (:class:`int`) [unsigned long]" msgstr "``k`` (:class:`int`) [unsigned long]" -#: ../../c-api/arg.rst:258 +#: ../../c-api/arg.rst:270 msgid "" "Convert a Python integer to a C :c:expr:`unsigned long` without overflow " "checking." msgstr "" "將一個 Python 整數轉換成 C 的 :c:expr:`unsigned long`,轉換過程無溢位檢查。" -#: ../../c-api/arg.rst:261 ../../c-api/arg.rst:627 +#: ../../c-api/arg.rst:273 ../../c-api/arg.rst:639 msgid "``L`` (:class:`int`) [long long]" msgstr "``L`` (:class:`int`) [long long]" -#: ../../c-api/arg.rst:262 +#: ../../c-api/arg.rst:274 msgid "Convert a Python integer to a C :c:expr:`long long`." msgstr "將一個 Python 整數轉換成 C 的 :c:expr:`long long`。" -#: ../../c-api/arg.rst:264 ../../c-api/arg.rst:630 +#: ../../c-api/arg.rst:276 ../../c-api/arg.rst:644 msgid "``K`` (:class:`int`) [unsigned long long]" msgstr "``K`` (:class:`int`) [unsigned long long]" -#: ../../c-api/arg.rst:265 +#: ../../c-api/arg.rst:277 msgid "" "Convert a Python integer to a C :c:expr:`unsigned long long` without " "overflow checking." @@ -514,71 +534,71 @@ msgstr "" "將一個 Python 整數轉換成 C 的 :c:expr:`unsigned long long`,轉換過程無溢位檢" "查。" -#: ../../c-api/arg.rst:268 ../../c-api/arg.rst:633 +#: ../../c-api/arg.rst:280 ../../c-api/arg.rst:647 msgid "``n`` (:class:`int`) [:c:type:`Py_ssize_t`]" msgstr "``n`` (:class:`int`) [:c:type:`Py_ssize_t`]" -#: ../../c-api/arg.rst:269 +#: ../../c-api/arg.rst:281 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:271 +#: ../../c-api/arg.rst:283 msgid "``c`` (:class:`bytes` or :class:`bytearray` of length 1) [char]" msgstr "``c``\\ (:class:`bytes` 或長度為 1 的 :class:`bytearray`)[char]" -#: ../../c-api/arg.rst:272 +#: ../../c-api/arg.rst:284 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:275 +#: ../../c-api/arg.rst:287 msgid "Allow :class:`bytearray` objects." msgstr "允許 :class:`bytearray` 物件。" -#: ../../c-api/arg.rst:278 ../../c-api/arg.rst:640 +#: ../../c-api/arg.rst:290 ../../c-api/arg.rst:654 msgid "``C`` (:class:`str` of length 1) [int]" msgstr "``C``\\ (長度為 1 的 :class:`str`)[int]" -#: ../../c-api/arg.rst:279 +#: ../../c-api/arg.rst:291 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:282 ../../c-api/arg.rst:647 +#: ../../c-api/arg.rst:294 ../../c-api/arg.rst:661 msgid "``f`` (:class:`float`) [float]" msgstr "``f`` (:class:`float`) [float]" -#: ../../c-api/arg.rst:283 +#: ../../c-api/arg.rst:295 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:285 ../../c-api/arg.rst:644 +#: ../../c-api/arg.rst:297 ../../c-api/arg.rst:658 msgid "``d`` (:class:`float`) [double]" msgstr "``d`` (:class:`float`) [double]" -#: ../../c-api/arg.rst:286 +#: ../../c-api/arg.rst:298 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:288 +#: ../../c-api/arg.rst:300 msgid "``D`` (:class:`complex`) [Py_complex]" msgstr "``D`` (:class:`complex`) [Py_complex]" -#: ../../c-api/arg.rst:289 +#: ../../c-api/arg.rst:301 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:292 +#: ../../c-api/arg.rst:304 msgid "Other objects" msgstr "其他物件" -#: ../../c-api/arg.rst:294 ../../c-api/arg.rst:653 +#: ../../c-api/arg.rst:306 ../../c-api/arg.rst:667 msgid "``O`` (object) [PyObject \\*]" msgstr "``O``\\ (物件)[PyObject \\*]" -#: ../../c-api/arg.rst:295 +#: ../../c-api/arg.rst:307 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:" @@ -586,11 +606,11 @@ msgid "" "not increased). The pointer stored is not ``NULL``." msgstr "" -#: ../../c-api/arg.rst:301 +#: ../../c-api/arg.rst:313 msgid "``O!`` (object) [*typeobject*, PyObject \\*]" msgstr "``O!``\\ (物件)[*typeobject*, PyObject \\*]" -#: ../../c-api/arg.rst:302 +#: ../../c-api/arg.rst:314 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 " @@ -599,11 +619,12 @@ msgid "" "required type, :exc:`TypeError` is raised." msgstr "" -#: ../../c-api/arg.rst:310 ../../c-api/arg.rst:671 -msgid "``O&`` (object) [*converter*, *anything*]" +#: ../../c-api/arg.rst:322 +#, fuzzy +msgid "``O&`` (object) [*converter*, *address*]" msgstr "``O&``\\ (物件)[*converter*, *anything*]" -#: ../../c-api/arg.rst:311 +#: ../../c-api/arg.rst:323 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 " @@ -611,11 +632,11 @@ msgid "" "*converter* function in turn is called as follows::" msgstr "" -#: ../../c-api/arg.rst:316 +#: ../../c-api/arg.rst:328 msgid "status = converter(object, address);" msgstr "status = converter(object, address);" -#: ../../c-api/arg.rst:318 +#: ../../c-api/arg.rst:330 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 " @@ -625,24 +646,31 @@ msgid "" "unmodified." msgstr "" -#: ../../c-api/arg.rst:324 +#: ../../c-api/arg.rst:339 msgid "" -"If the *converter* returns ``Py_CLEANUP_SUPPORTED``, it may get called a " -"second time if the argument parsing eventually fails, giving the converter a " -"chance to release any memory that it had already allocated. In this second " -"call, the *object* parameter will be ``NULL``; *address* will have the same " -"value as in the original call." +"If the *converter* returns :c:macro:`!Py_CLEANUP_SUPPORTED`, it may get " +"called a second time if the argument parsing eventually fails, giving the " +"converter a chance to release any memory that it had already allocated. In " +"this second call, the *object* parameter will be ``NULL``; *address* will " +"have the same value as in the original call." msgstr "" -#: ../../c-api/arg.rst:330 -msgid "``Py_CLEANUP_SUPPORTED`` was added." +#: ../../c-api/arg.rst:345 +msgid "" +"Examples of converters: :c:func:`PyUnicode_FSConverter` and :c:func:" +"`PyUnicode_FSDecoder`." +msgstr "" + +#: ../../c-api/arg.rst:348 +#, fuzzy +msgid ":c:macro:`!Py_CLEANUP_SUPPORTED` was added." msgstr "加入 ``Py_CLEANUP_SUPPORTED``。" -#: ../../c-api/arg.rst:333 +#: ../../c-api/arg.rst:351 msgid "``p`` (:class:`bool`) [int]" msgstr "``p`` (:class:`bool`) [int]" -#: ../../c-api/arg.rst:334 +#: ../../c-api/arg.rst:352 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 " @@ -651,37 +679,28 @@ msgid "" "how Python tests values for truth." msgstr "" -#: ../../c-api/arg.rst:342 ../../c-api/arg.rst:677 +#: ../../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:343 +#: ../../c-api/arg.rst:361 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." msgstr "" -#: ../../c-api/arg.rst:347 -msgid "" -"It is possible to pass \"long\" integers (integers whose value exceeds the " -"platform's :c:macro:`LONG_MAX`) however no proper range checking is done --- " -"the most significant bits are silently truncated when the receiving field is " -"too small to receive the value (actually, the semantics are inherited from " -"downcasts in C --- your mileage may vary)." -msgstr "" - -#: ../../c-api/arg.rst:353 +#: ../../c-api/arg.rst:365 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:356 +#: ../../c-api/arg.rst:368 msgid "``|``" msgstr "``|``" -#: ../../c-api/arg.rst:357 +#: ../../c-api/arg.rst:369 msgid "" "Indicates that the remaining arguments in the Python argument list are " "optional. The C variables corresponding to optional arguments should be " @@ -690,11 +709,11 @@ msgid "" "corresponding C variable(s)." msgstr "" -#: ../../c-api/arg.rst:363 +#: ../../c-api/arg.rst:375 msgid "``$``" msgstr "``$``" -#: ../../c-api/arg.rst:364 +#: ../../c-api/arg.rst:376 msgid "" ":c:func:`PyArg_ParseTupleAndKeywords` only: Indicates that the remaining " "arguments in the Python argument list are keyword-only. Currently, all " @@ -702,36 +721,36 @@ msgid "" "be specified before ``$`` in the format string." msgstr "" -#: ../../c-api/arg.rst:372 +#: ../../c-api/arg.rst:384 msgid "``:``" msgstr "``:``" -#: ../../c-api/arg.rst:373 +#: ../../c-api/arg.rst:385 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:377 +#: ../../c-api/arg.rst:389 msgid "``;``" msgstr "``;``" -#: ../../c-api/arg.rst:378 +#: ../../c-api/arg.rst:390 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:382 +#: ../../c-api/arg.rst:394 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:386 +#: ../../c-api/arg.rst:398 msgid "" "Additional arguments passed to these functions must be addresses of " "variables whose type is determined by the format string; these are used to " @@ -741,7 +760,7 @@ msgid "" "unit in that case." msgstr "" -#: ../../c-api/arg.rst:392 +#: ../../c-api/arg.rst:404 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 " @@ -751,24 +770,24 @@ msgid "" "the following format units are left untouched." msgstr "" -#: ../../c-api/arg.rst:401 +#: ../../c-api/arg.rst:413 msgid "API Functions" msgstr "API 函式" -#: ../../c-api/arg.rst:405 +#: ../../c-api/arg.rst:417 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:412 +#: ../../c-api/arg.rst:424 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:418 +#: ../../c-api/arg.rst:430 msgid "" "Parse the parameters of a function that takes both positional and keyword " "parameters into local variables. The *keywords* argument is a ``NULL``-" @@ -778,51 +797,51 @@ msgid "" "failure, it returns false and raises the appropriate exception." msgstr "" -#: ../../c-api/arg.rst:429 +#: ../../c-api/arg.rst:441 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:433 +#: ../../c-api/arg.rst:445 msgid "" "Added support for :ref:`positional-only parameters `." msgstr "" -#: ../../c-api/arg.rst:437 +#: ../../c-api/arg.rst:449 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:446 +#: ../../c-api/arg.rst:458 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:452 +#: ../../c-api/arg.rst:464 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:461 +#: ../../c-api/arg.rst:473 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:465 +#: ../../c-api/arg.rst:477 msgid "Example::" msgstr "" -#: ../../c-api/arg.rst:467 +#: ../../c-api/arg.rst:479 msgid "" "// Function using METH_O calling convention\n" "static PyObject*\n" @@ -836,7 +855,7 @@ msgid "" "}" msgstr "" -#: ../../c-api/arg.rst:481 +#: ../../c-api/arg.rst:493 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 " @@ -854,13 +873,13 @@ msgid "" "if there was a failure." msgstr "" -#: ../../c-api/arg.rst:496 +#: ../../c-api/arg.rst:508 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:499 +#: ../../c-api/arg.rst:511 msgid "" "static PyObject *\n" "weakref_ref(PyObject *self, PyObject *args)\n" @@ -888,17 +907,17 @@ msgstr "" " return result;\n" "}" -#: ../../c-api/arg.rst:512 +#: ../../c-api/arg.rst:524 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:515 +#: ../../c-api/arg.rst:527 msgid "PyArg_ParseTuple(args, \"O|O:ref\", &object, &callback)" msgstr "PyArg_ParseTuple(args, \"O|O:ref\", &object, &callback)" -#: ../../c-api/arg.rst:519 +#: ../../c-api/arg.rst:531 msgid "" "The value to be inserted, if any, before :c:expr:`char * const *` in the " "*keywords* parameter declaration of :c:func:`PyArg_ParseTupleAndKeywords` " @@ -907,11 +926,11 @@ msgid "" "to the desired value before including :file:`Python.h`." msgstr "" -#: ../../c-api/arg.rst:533 +#: ../../c-api/arg.rst:545 msgid "Building values" msgstr "" -#: ../../c-api/arg.rst:537 +#: ../../c-api/arg.rst:549 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 " @@ -919,7 +938,7 @@ msgid "" "``NULL`` is returned." msgstr "" -#: ../../c-api/arg.rst:542 +#: ../../c-api/arg.rst:554 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 " @@ -928,7 +947,7 @@ msgid "" "it to return a tuple of size 0 or one, parenthesize the format string." msgstr "" -#: ../../c-api/arg.rst:548 +#: ../../c-api/arg.rst:560 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. " @@ -939,7 +958,7 @@ msgid "" "`Py_BuildValue` returns." msgstr "" -#: ../../c-api/arg.rst:556 +#: ../../c-api/arg.rst:568 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 " @@ -947,155 +966,155 @@ msgid "" "be passed." msgstr "" -#: ../../c-api/arg.rst:560 +#: ../../c-api/arg.rst:572 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:564 +#: ../../c-api/arg.rst:576 msgid "``s`` (:class:`str` or ``None``) [const char \\*]" msgstr "``s``\\ (:class:`str` 或 ``None``)[const char \\*]" -#: ../../c-api/arg.rst:565 +#: ../../c-api/arg.rst:577 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:568 +#: ../../c-api/arg.rst:580 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:569 +#: ../../c-api/arg.rst:581 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:573 +#: ../../c-api/arg.rst:585 msgid "``y`` (:class:`bytes`) [const char \\*]" msgstr "``y`` (:class:`bytes`) [const char \\*]" -#: ../../c-api/arg.rst:574 +#: ../../c-api/arg.rst:586 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:577 +#: ../../c-api/arg.rst:589 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:578 +#: ../../c-api/arg.rst:590 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:582 ../../c-api/arg.rst:598 +#: ../../c-api/arg.rst:594 ../../c-api/arg.rst:610 msgid "Same as ``s``." msgstr "和 ``s`` 相同。" -#: ../../c-api/arg.rst:584 +#: ../../c-api/arg.rst:596 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:585 ../../c-api/arg.rst:601 +#: ../../c-api/arg.rst:597 ../../c-api/arg.rst:613 msgid "Same as ``s#``." msgstr "和 ``s#`` 相同。" -#: ../../c-api/arg.rst:587 +#: ../../c-api/arg.rst:599 msgid "``u`` (:class:`str`) [const wchar_t \\*]" msgstr "``u`` (:class:`str`) [const wchar_t \\*]" -#: ../../c-api/arg.rst:588 +#: ../../c-api/arg.rst:600 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:592 +#: ../../c-api/arg.rst:604 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:593 +#: ../../c-api/arg.rst:605 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:597 +#: ../../c-api/arg.rst:609 msgid "``U`` (:class:`str` or ``None``) [const char \\*]" msgstr "``U``\\ (:class:`str` 或 ``None``)[const char \\*]" -#: ../../c-api/arg.rst:600 +#: ../../c-api/arg.rst:612 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:604 +#: ../../c-api/arg.rst:616 msgid "Convert a plain C :c:expr:`int` to a Python integer object." msgstr "將一個 C 的 :c:expr:`int` 轉換成 Python 整數物件。" -#: ../../c-api/arg.rst:606 +#: ../../c-api/arg.rst:618 msgid "``b`` (:class:`int`) [char]" msgstr "``b`` (:class:`int`) [char]" -#: ../../c-api/arg.rst:607 +#: ../../c-api/arg.rst:619 msgid "Convert a plain C :c:expr:`char` to a Python integer object." msgstr "將一個 C 的 :c:expr:`char` 轉換成 Python 整數物件。" -#: ../../c-api/arg.rst:610 +#: ../../c-api/arg.rst:622 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:613 +#: ../../c-api/arg.rst:625 msgid "Convert a C :c:expr:`long int` to a Python integer object." msgstr "將一個 C 的 :c:expr:`long int` 轉換成 Python 整數物件。" -#: ../../c-api/arg.rst:616 +#: ../../c-api/arg.rst:628 msgid "Convert a C :c:expr:`unsigned char` to a Python integer object." msgstr "將一個 C 的 :c:expr:`unsigned char` 轉換成 Python 整數物件。" -#: ../../c-api/arg.rst:619 +#: ../../c-api/arg.rst:631 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:622 +#: ../../c-api/arg.rst:634 msgid "Convert a C :c:expr:`unsigned int` to a Python integer object." msgstr "將一個 C 的 :c:expr:`unsigned int` 轉換成 Python 整數物件。" -#: ../../c-api/arg.rst:625 +#: ../../c-api/arg.rst:637 msgid "Convert a C :c:expr:`unsigned long` to a Python integer object." msgstr "將一個 C 的 :c:expr:`unsigned long` 轉換成 Python 整數物件。" -#: ../../c-api/arg.rst:628 +#: ../../c-api/arg.rst:640 msgid "Convert a C :c:expr:`long long` to a Python integer object." msgstr "將一個 C 的 :c:expr:`long long` 轉換成 Python 整數物件。" -#: ../../c-api/arg.rst:631 +#: ../../c-api/arg.rst:645 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:634 +#: ../../c-api/arg.rst:648 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:636 +#: ../../c-api/arg.rst:650 msgid "``c`` (:class:`bytes` of length 1) [char]" msgstr "``c``\\ (長度為 1 的 :class:`bytes`)[char]" -#: ../../c-api/arg.rst:637 +#: ../../c-api/arg.rst:651 msgid "" "Convert a C :c:expr:`int` representing a byte to a Python :class:`bytes` " "object of length 1." @@ -1103,7 +1122,7 @@ msgstr "" "將一個 C 中代表一個位元組的 :c:expr:`int` 轉換成 Python 中長度為一的 :class:" "`bytes`。" -#: ../../c-api/arg.rst:641 +#: ../../c-api/arg.rst:655 msgid "" "Convert a C :c:expr:`int` representing a character to Python :class:`str` " "object of length 1." @@ -1111,23 +1130,23 @@ msgstr "" "將一個 C 中代表一個字元的 :c:expr:`int` 轉換成 Python 中長度為一的 :class:" "`str`。" -#: ../../c-api/arg.rst:645 +#: ../../c-api/arg.rst:659 msgid "Convert a C :c:expr:`double` to a Python floating-point number." msgstr "將一個 C 的 :c:expr:`double` 轉換成 Python 浮點數。" -#: ../../c-api/arg.rst:648 +#: ../../c-api/arg.rst:662 msgid "Convert a C :c:expr:`float` to a Python floating-point number." msgstr "將一個 C 的 :c:expr:`float` 轉換成 Python 浮點數。" -#: ../../c-api/arg.rst:650 +#: ../../c-api/arg.rst:664 msgid "``D`` (:class:`complex`) [Py_complex \\*]" msgstr "``D`` (:class:`complex`) [Py_complex \\*]" -#: ../../c-api/arg.rst:651 +#: ../../c-api/arg.rst:665 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:654 +#: ../../c-api/arg.rst:668 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 " @@ -1137,26 +1156,30 @@ msgid "" "no exception has been raised yet, :exc:`SystemError` is set." msgstr "" -#: ../../c-api/arg.rst:663 +#: ../../c-api/arg.rst:677 msgid "``S`` (object) [PyObject \\*]" msgstr "``S``\\ (物件)[PyObject \\*]" -#: ../../c-api/arg.rst:664 +#: ../../c-api/arg.rst:678 msgid "Same as ``O``." msgstr "和 ``O`` 相同。" -#: ../../c-api/arg.rst:666 +#: ../../c-api/arg.rst:680 msgid "``N`` (object) [PyObject \\*]" msgstr "``N``\\ (物件)[PyObject \\*]" -#: ../../c-api/arg.rst:667 +#: ../../c-api/arg.rst:681 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:672 +#: ../../c-api/arg.rst:685 +msgid "``O&`` (object) [*converter*, *anything*]" +msgstr "``O&``\\ (物件)[*converter*, *anything*]" + +#: ../../c-api/arg.rst:686 msgid "" "Convert *anything* to a Python object through a *converter* function. The " "function is called with *anything* (which should be compatible with :c:expr:" @@ -1164,40 +1187,40 @@ msgid "" "``NULL`` if an error occurred." msgstr "" -#: ../../c-api/arg.rst:678 +#: ../../c-api/arg.rst:692 msgid "" "Convert a sequence of C values to a Python tuple with the same number of " "items." msgstr "" -#: ../../c-api/arg.rst:680 +#: ../../c-api/arg.rst:694 msgid "``[items]`` (:class:`list`) [*matching-items*]" msgstr "``[items]`` (:class:`list`) [*matching-items*]" -#: ../../c-api/arg.rst:681 +#: ../../c-api/arg.rst:695 msgid "" "Convert a sequence of C values to a Python list with the same number of " "items." msgstr "" -#: ../../c-api/arg.rst:683 +#: ../../c-api/arg.rst:697 msgid "``{items}`` (:class:`dict`) [*matching-items*]" msgstr "``{items}`` (:class:`dict`) [*matching-items*]" -#: ../../c-api/arg.rst:684 +#: ../../c-api/arg.rst:698 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:688 +#: ../../c-api/arg.rst:702 msgid "" "If there is an error in the format string, the :exc:`SystemError` exception " "is set and ``NULL`` returned." msgstr "" -#: ../../c-api/arg.rst:693 +#: ../../c-api/arg.rst:707 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/buffer.po b/c-api/buffer.po index fa0c60391b..0b71d7a7c5 100644 --- a/c-api/buffer.po +++ b/c-api/buffer.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-01 22:24+0800\n" +"POT-Creation-Date: 2025-05-04 20:08+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-" @@ -41,24 +41,26 @@ msgstr "" #: ../../c-api/buffer.rst:29 msgid "" -"Python provides such a facility at the C level in the form of the :ref:" -"`buffer protocol `. This protocol has two sides:" +"Python provides such a facility at the C and Python level in the form of " +"the :ref:`buffer protocol `. This protocol has two sides:" msgstr "" #: ../../c-api/buffer.rst:34 msgid "" "on the producer side, a type can export a \"buffer interface\" which allows " "objects of that type to expose information about their underlying buffer. " -"This interface is described in the section :ref:`buffer-structs`;" +"This interface is described in the section :ref:`buffer-structs`; for Python " +"see :ref:`python-buffer-protocol`." msgstr "" -#: ../../c-api/buffer.rst:38 +#: ../../c-api/buffer.rst:39 msgid "" "on the consumer side, several means are available to obtain a pointer to the " -"raw underlying data of an object (for example a method parameter)." +"raw underlying data of an object (for example a method parameter). For " +"Python see :class:`memoryview`." msgstr "" -#: ../../c-api/buffer.rst:41 +#: ../../c-api/buffer.rst:43 msgid "" "Simple objects such as :class:`bytes` and :class:`bytearray` expose their " "underlying buffer in byte-oriented form. Other forms are possible; for " @@ -66,7 +68,7 @@ msgid "" "values." msgstr "" -#: ../../c-api/buffer.rst:45 +#: ../../c-api/buffer.rst:47 msgid "" "An example consumer of the buffer interface is the :meth:`~io.BufferedIOBase." "write` method of file objects: any object that can export a series of bytes " @@ -78,23 +80,23 @@ msgid "" "buffers." msgstr "" -#: ../../c-api/buffer.rst:53 +#: ../../c-api/buffer.rst:55 msgid "" "There are two ways for a consumer of the buffer interface to acquire a " "buffer over a target object:" msgstr "" -#: ../../c-api/buffer.rst:56 +#: ../../c-api/buffer.rst:58 msgid "call :c:func:`PyObject_GetBuffer` with the right parameters;" msgstr "" -#: ../../c-api/buffer.rst:58 +#: ../../c-api/buffer.rst:60 msgid "" "call :c:func:`PyArg_ParseTuple` (or one of its siblings) with one of the " "``y*``, ``w*`` or ``s*`` :ref:`format codes `." msgstr "" -#: ../../c-api/buffer.rst:61 +#: ../../c-api/buffer.rst:63 msgid "" "In both cases, :c:func:`PyBuffer_Release` must be called when the buffer " "isn't needed anymore. Failure to do so could lead to various issues such as " @@ -102,10 +104,16 @@ msgid "" msgstr "" #: ../../c-api/buffer.rst:69 +msgid "" +"The buffer protocol is now accessible in Python, see :ref:`python-buffer-" +"protocol` and :class:`memoryview`." +msgstr "" + +#: ../../c-api/buffer.rst:75 msgid "Buffer structure" msgstr "" -#: ../../c-api/buffer.rst:71 +#: ../../c-api/buffer.rst:77 msgid "" "Buffer structures (or simply \"buffers\") are useful as a way to expose the " "binary data from another object to the Python programmer. They can also be " @@ -117,7 +125,7 @@ msgid "" "in its native, in-memory format." msgstr "" -#: ../../c-api/buffer.rst:80 +#: ../../c-api/buffer.rst:86 msgid "" "Contrary to most data types exposed by the Python interpreter, buffers are " "not :c:type:`PyObject` pointers but rather simple C structures. This allows " @@ -126,14 +134,14 @@ msgid "" "created." msgstr "" -#: ../../c-api/buffer.rst:86 +#: ../../c-api/buffer.rst:92 msgid "" "For short instructions how to write an exporting object, see :ref:`Buffer " "Object Structures `. For obtaining a buffer, see :c:func:" "`PyObject_GetBuffer`." msgstr "" -#: ../../c-api/buffer.rst:94 +#: ../../c-api/buffer.rst:100 msgid "" "A pointer to the start of the logical structure described by the buffer " "fields. This can be any location within the underlying physical memory block " @@ -141,13 +149,13 @@ msgid "" "the value may point to the end of the memory block." msgstr "" -#: ../../c-api/buffer.rst:99 +#: ../../c-api/buffer.rst:105 msgid "" "For :term:`contiguous` arrays, the value points to the beginning of the " "memory block." msgstr "" -#: ../../c-api/buffer.rst:104 +#: ../../c-api/buffer.rst:110 msgid "" "A new reference to the exporting object. The reference is owned by the " "consumer and automatically released (i.e. reference count decremented) and " @@ -155,14 +163,14 @@ msgid "" "of the return value of any standard C-API function." msgstr "" -#: ../../c-api/buffer.rst:111 +#: ../../c-api/buffer.rst:117 msgid "" "As a special case, for *temporary* buffers that are wrapped by :c:func:" "`PyMemoryView_FromBuffer` or :c:func:`PyBuffer_FillInfo` this field is " "``NULL``. In general, exporting objects MUST NOT use this scheme." msgstr "" -#: ../../c-api/buffer.rst:118 +#: ../../c-api/buffer.rst:124 msgid "" "``product(shape) * itemsize``. For contiguous arrays, this is the length of " "the underlying memory block. For non-contiguous arrays, it is the length " @@ -170,7 +178,7 @@ msgid "" "representation." msgstr "" -#: ../../c-api/buffer.rst:123 +#: ../../c-api/buffer.rst:129 msgid "" "Accessing ``((char *)buf)[0] up to ((char *)buf)[len-1]`` is only valid if " "the buffer has been obtained by a request that guarantees contiguity. In " @@ -178,19 +186,19 @@ msgid "" "`PyBUF_WRITABLE`." msgstr "" -#: ../../c-api/buffer.rst:129 +#: ../../c-api/buffer.rst:135 msgid "" "An indicator of whether the buffer is read-only. This field is controlled by " "the :c:macro:`PyBUF_WRITABLE` flag." msgstr "" -#: ../../c-api/buffer.rst:134 +#: ../../c-api/buffer.rst:140 msgid "" "Item size in bytes of a single element. Same as the value of :func:`struct." "calcsize` called on non-``NULL`` :c:member:`~Py_buffer.format` values." msgstr "" -#: ../../c-api/buffer.rst:137 +#: ../../c-api/buffer.rst:143 msgid "" "Important exception: If a consumer requests a buffer without the :c:macro:" "`PyBUF_FORMAT` flag, :c:member:`~Py_buffer.format` will be set to " @@ -198,32 +206,32 @@ msgid "" "original format." msgstr "" -#: ../../c-api/buffer.rst:142 +#: ../../c-api/buffer.rst:148 msgid "" "If :c:member:`~Py_buffer.shape` is present, the equality ``product(shape) * " "itemsize == len`` still holds and the consumer can use :c:member:`~Py_buffer." "itemsize` to navigate the buffer." msgstr "" -#: ../../c-api/buffer.rst:146 +#: ../../c-api/buffer.rst:152 msgid "" "If :c:member:`~Py_buffer.shape` is ``NULL`` as a result of a :c:macro:" "`PyBUF_SIMPLE` or a :c:macro:`PyBUF_WRITABLE` request, the consumer must " "disregard :c:member:`~Py_buffer.itemsize` and assume ``itemsize == 1``." msgstr "" -#: ../../c-api/buffer.rst:152 +#: ../../c-api/buffer.rst:158 msgid "" "A *NULL* terminated string in :mod:`struct` module style syntax describing " "the contents of a single item. If this is ``NULL``, ``\"B\"`` (unsigned " "bytes) is assumed." msgstr "" -#: ../../c-api/buffer.rst:156 +#: ../../c-api/buffer.rst:162 msgid "This field is controlled by the :c:macro:`PyBUF_FORMAT` flag." msgstr "" -#: ../../c-api/buffer.rst:160 +#: ../../c-api/buffer.rst:166 msgid "" "The number of dimensions the memory represents as an n-dimensional array. If " "it is ``0``, :c:member:`~Py_buffer.buf` points to a single item representing " @@ -232,7 +240,7 @@ msgid "" "number of dimensions is given by :c:macro:`PyBUF_MAX_NDIM`." msgstr "" -#: ../../c-api/buffer.rst:168 +#: ../../c-api/buffer.rst:174 msgid "" "An array of :c:type:`Py_ssize_t` of length :c:member:`~Py_buffer.ndim` " "indicating the shape of the memory as an n-dimensional array. Note that " @@ -240,34 +248,34 @@ msgid "" "`~Py_buffer.len`." msgstr "" -#: ../../c-api/buffer.rst:173 +#: ../../c-api/buffer.rst:179 msgid "" "Shape values are restricted to ``shape[n] >= 0``. The case ``shape[n] == 0`` " "requires special attention. See `complex arrays`_ for further information." msgstr "" -#: ../../c-api/buffer.rst:177 +#: ../../c-api/buffer.rst:183 msgid "The shape array is read-only for the consumer." msgstr "" -#: ../../c-api/buffer.rst:181 +#: ../../c-api/buffer.rst:187 msgid "" "An array of :c:type:`Py_ssize_t` of length :c:member:`~Py_buffer.ndim` " "giving the number of bytes to skip to get to a new element in each dimension." msgstr "" -#: ../../c-api/buffer.rst:185 +#: ../../c-api/buffer.rst:191 msgid "" "Stride values can be any integer. For regular arrays, strides are usually " "positive, but a consumer MUST be able to handle the case ``strides[n] <= " "0``. See `complex arrays`_ for further information." msgstr "" -#: ../../c-api/buffer.rst:189 +#: ../../c-api/buffer.rst:195 msgid "The strides array is read-only for the consumer." msgstr "" -#: ../../c-api/buffer.rst:193 +#: ../../c-api/buffer.rst:199 msgid "" "An array of :c:type:`Py_ssize_t` of length :c:member:`~Py_buffer.ndim`. If " "``suboffsets[n] >= 0``, the values stored along the nth dimension are " @@ -276,24 +284,24 @@ msgid "" "that no de-referencing should occur (striding in a contiguous memory block)." msgstr "" -#: ../../c-api/buffer.rst:200 +#: ../../c-api/buffer.rst:206 msgid "" "If all suboffsets are negative (i.e. no de-referencing is needed), then this " "field must be ``NULL`` (the default value)." msgstr "" -#: ../../c-api/buffer.rst:203 +#: ../../c-api/buffer.rst:209 msgid "" "This type of array representation is used by the Python Imaging Library " "(PIL). See `complex arrays`_ for further information how to access elements " "of such an array." msgstr "" -#: ../../c-api/buffer.rst:207 +#: ../../c-api/buffer.rst:213 msgid "The suboffsets array is read-only for the consumer." msgstr "" -#: ../../c-api/buffer.rst:211 +#: ../../c-api/buffer.rst:217 msgid "" "This is for use internally by the exporting object. For example, this might " "be re-cast as an integer by the exporter and used to store flags about " @@ -301,22 +309,22 @@ msgid "" "the buffer is released. The consumer MUST NOT alter this value." msgstr "" -#: ../../c-api/buffer.rst:218 +#: ../../c-api/buffer.rst:224 msgid "Constants:" msgstr "常數:" -#: ../../c-api/buffer.rst:222 +#: ../../c-api/buffer.rst:228 msgid "" "The maximum number of dimensions the memory represents. Exporters MUST " "respect this limit, consumers of multi-dimensional buffers SHOULD be able to " "handle up to :c:macro:`!PyBUF_MAX_NDIM` dimensions. Currently set to 64." msgstr "" -#: ../../c-api/buffer.rst:231 +#: ../../c-api/buffer.rst:237 msgid "Buffer request types" msgstr "" -#: ../../c-api/buffer.rst:233 +#: ../../c-api/buffer.rst:239 msgid "" "Buffers are usually obtained by sending a buffer request to an exporting " "object via :c:func:`PyObject_GetBuffer`. Since the complexity of the logical " @@ -324,16 +332,16 @@ msgid "" "argument to specify the exact buffer type it can handle." msgstr "" -#: ../../c-api/buffer.rst:238 +#: ../../c-api/buffer.rst:244 msgid "" "All :c:type:`Py_buffer` fields are unambiguously defined by the request type." msgstr "" -#: ../../c-api/buffer.rst:242 +#: ../../c-api/buffer.rst:248 msgid "request-independent fields" msgstr "" -#: ../../c-api/buffer.rst:243 +#: ../../c-api/buffer.rst:249 msgid "" "The following fields are not influenced by *flags* and must always be filled " "in with the correct values: :c:member:`~Py_buffer.obj`, :c:member:" @@ -341,25 +349,26 @@ msgid "" "itemsize`, :c:member:`~Py_buffer.ndim`." msgstr "" -#: ../../c-api/buffer.rst:249 +#: ../../c-api/buffer.rst:254 msgid "readonly, format" msgstr "" -#: ../../c-api/buffer.rst:253 +#: ../../c-api/buffer.rst:258 msgid "" "Controls the :c:member:`~Py_buffer.readonly` field. If set, the exporter " "MUST provide a writable buffer or else report failure. Otherwise, the " "exporter MAY provide either a read-only or writable buffer, but the choice " -"MUST be consistent for all consumers." +"MUST be consistent for all consumers. For example, :c:expr:`PyBUF_SIMPLE | " +"PyBUF_WRITABLE` can be used to request a simple writable buffer." msgstr "" -#: ../../c-api/buffer.rst:260 +#: ../../c-api/buffer.rst:266 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:264 +#: ../../c-api/buffer.rst:270 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:" @@ -367,158 +376,159 @@ msgid "" "writable buffer." msgstr "" -#: ../../c-api/buffer.rst:268 +#: ../../c-api/buffer.rst:274 msgid "" -":c:macro:`PyBUF_FORMAT` can be \\|'d to any of the flags except :c:macro:" -"`PyBUF_SIMPLE`. The latter already implies format ``B`` (unsigned bytes)." +":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:273 +#: ../../c-api/buffer.rst:280 msgid "shape, strides, suboffsets" msgstr "" -#: ../../c-api/buffer.rst:275 +#: ../../c-api/buffer.rst:282 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:282 ../../c-api/buffer.rst:306 -#: ../../c-api/buffer.rst:331 +#: ../../c-api/buffer.rst:289 ../../c-api/buffer.rst:313 +#: ../../c-api/buffer.rst:338 msgid "Request" msgstr "" -#: ../../c-api/buffer.rst:282 ../../c-api/buffer.rst:306 -#: ../../c-api/buffer.rst:331 +#: ../../c-api/buffer.rst:289 ../../c-api/buffer.rst:313 +#: ../../c-api/buffer.rst:338 msgid "shape" msgstr "" -#: ../../c-api/buffer.rst:282 ../../c-api/buffer.rst:306 -#: ../../c-api/buffer.rst:331 +#: ../../c-api/buffer.rst:289 ../../c-api/buffer.rst:313 +#: ../../c-api/buffer.rst:338 msgid "strides" msgstr "" -#: ../../c-api/buffer.rst:282 ../../c-api/buffer.rst:306 -#: ../../c-api/buffer.rst:331 +#: ../../c-api/buffer.rst:289 ../../c-api/buffer.rst:313 +#: ../../c-api/buffer.rst:338 msgid "suboffsets" msgstr "" -#: ../../c-api/buffer.rst:284 ../../c-api/buffer.rst:286 -#: ../../c-api/buffer.rst:288 ../../c-api/buffer.rst:308 -#: ../../c-api/buffer.rst:310 ../../c-api/buffer.rst:312 -#: ../../c-api/buffer.rst:314 ../../c-api/buffer.rst:333 -#: ../../c-api/buffer.rst:335 ../../c-api/buffer.rst:337 -#: ../../c-api/buffer.rst:339 ../../c-api/buffer.rst:341 -#: ../../c-api/buffer.rst:343 ../../c-api/buffer.rst:345 -#: ../../c-api/buffer.rst:347 +#: ../../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:346 ../../c-api/buffer.rst:348 +#: ../../c-api/buffer.rst:350 ../../c-api/buffer.rst:352 +#: ../../c-api/buffer.rst:354 msgid "yes" msgstr "" -#: ../../c-api/buffer.rst:284 ../../c-api/buffer.rst:333 -#: ../../c-api/buffer.rst:335 +#: ../../c-api/buffer.rst:291 ../../c-api/buffer.rst:340 +#: ../../c-api/buffer.rst:342 msgid "if needed" msgstr "" -#: ../../c-api/buffer.rst:286 ../../c-api/buffer.rst:288 -#: ../../c-api/buffer.rst:290 ../../c-api/buffer.rst:308 -#: ../../c-api/buffer.rst:310 ../../c-api/buffer.rst:312 -#: ../../c-api/buffer.rst:314 ../../c-api/buffer.rst:337 -#: ../../c-api/buffer.rst:339 ../../c-api/buffer.rst:341 -#: ../../c-api/buffer.rst:343 ../../c-api/buffer.rst:345 -#: ../../c-api/buffer.rst:347 +#: ../../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:350 ../../c-api/buffer.rst:352 +#: ../../c-api/buffer.rst:354 msgid "NULL" msgstr "NULL" -#: ../../c-api/buffer.rst:297 +#: ../../c-api/buffer.rst:304 msgid "contiguity requests" msgstr "" -#: ../../c-api/buffer.rst:299 +#: ../../c-api/buffer.rst:306 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:306 ../../c-api/buffer.rst:331 +#: ../../c-api/buffer.rst:313 ../../c-api/buffer.rst:338 msgid "contig" msgstr "" -#: ../../c-api/buffer.rst:308 ../../c-api/buffer.rst:314 -#: ../../c-api/buffer.rst:345 ../../c-api/buffer.rst:347 +#: ../../c-api/buffer.rst:315 ../../c-api/buffer.rst:321 +#: ../../c-api/buffer.rst:352 ../../c-api/buffer.rst:354 msgid "C" msgstr "C" -#: ../../c-api/buffer.rst:310 +#: ../../c-api/buffer.rst:317 msgid "F" msgstr "F" -#: ../../c-api/buffer.rst:312 +#: ../../c-api/buffer.rst:319 msgid "C or F" msgstr "C 或 F" -#: ../../c-api/buffer.rst:314 +#: ../../c-api/buffer.rst:321 msgid ":c:macro:`PyBUF_ND`" msgstr ":c:macro:`PyBUF_ND`" -#: ../../c-api/buffer.rst:319 +#: ../../c-api/buffer.rst:326 msgid "compound requests" msgstr "" -#: ../../c-api/buffer.rst:321 +#: ../../c-api/buffer.rst:328 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:325 +#: ../../c-api/buffer.rst:332 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:331 +#: ../../c-api/buffer.rst:338 msgid "readonly" msgstr "" -#: ../../c-api/buffer.rst:331 +#: ../../c-api/buffer.rst:338 msgid "format" msgstr "" -#: ../../c-api/buffer.rst:333 ../../c-api/buffer.rst:335 -#: ../../c-api/buffer.rst:337 ../../c-api/buffer.rst:339 -#: ../../c-api/buffer.rst:341 ../../c-api/buffer.rst:343 +#: ../../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 msgid "U" msgstr "U" -#: ../../c-api/buffer.rst:333 ../../c-api/buffer.rst:337 -#: ../../c-api/buffer.rst:341 ../../c-api/buffer.rst:345 +#: ../../c-api/buffer.rst:340 ../../c-api/buffer.rst:344 +#: ../../c-api/buffer.rst:348 ../../c-api/buffer.rst:352 msgid "0" msgstr "0" -#: ../../c-api/buffer.rst:335 ../../c-api/buffer.rst:339 -#: ../../c-api/buffer.rst:343 ../../c-api/buffer.rst:347 +#: ../../c-api/buffer.rst:342 ../../c-api/buffer.rst:346 +#: ../../c-api/buffer.rst:350 ../../c-api/buffer.rst:354 msgid "1 or 0" msgstr "1 或 0" -#: ../../c-api/buffer.rst:352 +#: ../../c-api/buffer.rst:359 msgid "Complex arrays" msgstr "" -#: ../../c-api/buffer.rst:355 +#: ../../c-api/buffer.rst:362 msgid "NumPy-style: shape and strides" msgstr "" -#: ../../c-api/buffer.rst:357 +#: ../../c-api/buffer.rst:364 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:360 +#: ../../c-api/buffer.rst:367 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 " @@ -526,14 +536,14 @@ msgid "" "strides` are ``NULL``." msgstr "" -#: ../../c-api/buffer.rst:364 +#: ../../c-api/buffer.rst:371 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:368 +#: ../../c-api/buffer.rst:375 msgid "" "ptr = (char *)buf + indices[0] * strides[0] + ... + indices[n-1] * " "strides[n-1];\n" @@ -543,14 +553,14 @@ msgstr "" "strides[n-1];\n" "item = *((typeof(item) *)ptr);" -#: ../../c-api/buffer.rst:374 +#: ../../c-api/buffer.rst:381 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:378 +#: ../../c-api/buffer.rst:385 msgid "" "def verify_structure(memlen, itemsize, ndim, shape, strides, offset):\n" " \"\"\"Verify that the parameters represent a valid array within\n" @@ -579,11 +589,11 @@ msgid "" " return 0 <= offset+imin and offset+imax+itemsize <= memlen" msgstr "" -#: ../../c-api/buffer.rst:408 +#: ../../c-api/buffer.rst:415 msgid "PIL-style: shape, strides and suboffsets" msgstr "" -#: ../../c-api/buffer.rst:410 +#: ../../c-api/buffer.rst:417 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 " @@ -594,14 +604,14 @@ msgid "" "x[2][3]`` arrays that can be located anywhere in memory." msgstr "" -#: ../../c-api/buffer.rst:419 +#: ../../c-api/buffer.rst:426 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:423 +#: ../../c-api/buffer.rst:430 msgid "" "void *get_item_pointer(int ndim, void *buf, Py_ssize_t *strides,\n" " Py_ssize_t *suboffsets, Py_ssize_t *indices) {\n" @@ -629,25 +639,25 @@ msgstr "" " return (void*)pointer;\n" "}" -#: ../../c-api/buffer.rst:438 +#: ../../c-api/buffer.rst:445 msgid "Buffer-related functions" msgstr "" -#: ../../c-api/buffer.rst:442 +#: ../../c-api/buffer.rst:449 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:449 +#: ../../c-api/buffer.rst:456 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:454 +#: ../../c-api/buffer.rst:461 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 " @@ -655,7 +665,7 @@ msgid "" "instead of *exporter* (See :ref:`Buffer Object Structures `)." msgstr "" -#: ../../c-api/buffer.rst:459 +#: ../../c-api/buffer.rst:466 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:" @@ -663,7 +673,7 @@ msgid "" "`PyBuffer_Release` must be called exactly once." msgstr "" -#: ../../c-api/buffer.rst:467 +#: ../../c-api/buffer.rst:474 msgid "" "Release the buffer *view* and release the :term:`strong reference` (i.e. " "decrement the reference count) to the view's supporting object, ``view-" @@ -671,19 +681,19 @@ msgid "" "used, otherwise reference leaks may occur." msgstr "" -#: ../../c-api/buffer.rst:472 +#: ../../c-api/buffer.rst:479 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:478 +#: ../../c-api/buffer.rst:485 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:486 +#: ../../c-api/buffer.rst:493 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 " @@ -691,69 +701,69 @@ msgid "" "succeeds." msgstr "" -#: ../../c-api/buffer.rst:493 +#: ../../c-api/buffer.rst:500 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:499 +#: ../../c-api/buffer.rst:506 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:506 +#: ../../c-api/buffer.rst:513 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:510 +#: ../../c-api/buffer.rst:517 msgid "This function fails if *len* != *src->len*." msgstr "" -#: ../../c-api/buffer.rst:515 +#: ../../c-api/buffer.rst:522 msgid "" "Copy data from *src* to *dest* buffer. Can convert between C-style and or " "Fortran-style buffers." msgstr "" -#: ../../c-api/buffer.rst:518 +#: ../../c-api/buffer.rst:525 msgid "``0`` is returned on success, ``-1`` on error." msgstr "" -#: ../../c-api/buffer.rst:522 +#: ../../c-api/buffer.rst:529 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:529 +#: ../../c-api/buffer.rst:536 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:533 +#: ../../c-api/buffer.rst:540 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:537 +#: ../../c-api/buffer.rst:544 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:541 +#: ../../c-api/buffer.rst:548 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 " @@ -780,14 +790,14 @@ msgstr "buffer object(緩衝物件)" msgid "PyBufferProcs (C type)" msgstr "PyBufferProcs(C 型別)" -#: ../../c-api/buffer.rst:294 +#: ../../c-api/buffer.rst:301 msgid "contiguous" msgstr "contiguous(連續的)" -#: ../../c-api/buffer.rst:294 +#: ../../c-api/buffer.rst:301 msgid "C-contiguous" msgstr "C-contiguous(C 連續的)" -#: ../../c-api/buffer.rst:294 +#: ../../c-api/buffer.rst:301 msgid "Fortran contiguous" msgstr "Fortran contiguous(Fortran 連續的)" diff --git a/c-api/code.po b/c-api/code.po index c653263f0a..b4636b8c8c 100644 --- a/c-api/code.po +++ b/c-api/code.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2024-10-13 17:13+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-" @@ -48,124 +48,127 @@ msgid "" msgstr "" #: ../../c-api/code.rst:35 -msgid "Return the number of free variables in a code object." +msgid "" +"Return the number of :term:`free (closure) variables ` in " +"a code object." msgstr "" -#: ../../c-api/code.rst:39 -msgid "Return the position of the first free variable in a code object." +#: ../../c-api/code.rst:40 +msgid "" +"Return the position of the first :term:`free (closure) variable ` in a code object." msgstr "" -#: ../../c-api/code.rst:43 +#: ../../c-api/code.rst:45 msgid "" "Renamed from ``PyCode_GetFirstFree`` as part of :ref:`unstable-c-api`. The " "old name is deprecated, but will remain available until the signature " "changes again." msgstr "" -#: ../../c-api/code.rst:49 +#: ../../c-api/code.rst:51 msgid "" "Return a new code object. If you need a dummy code object to create a " "frame, use :c:func:`PyCode_NewEmpty` instead." msgstr "" -#: ../../c-api/code.rst:52 +#: ../../c-api/code.rst:54 msgid "" "Since the definition of the bytecode changes often, calling :c:func:" "`PyUnstable_Code_New` directly can bind you to a precise Python version." msgstr "" -#: ../../c-api/code.rst:55 +#: ../../c-api/code.rst:57 msgid "" "The many arguments of this function are inter-dependent in complex ways, " "meaning that subtle changes to values are likely to result in incorrect " "execution or VM crashes. Use this function only with extreme care." msgstr "" -#: ../../c-api/code.rst:59 +#: ../../c-api/code.rst:61 msgid "Added ``qualname`` and ``exceptiontable`` parameters." msgstr "新增 ``qualname`` 和 ``exceptiontable`` 參數。" -#: ../../c-api/code.rst:66 +#: ../../c-api/code.rst:68 msgid "" "Renamed from ``PyCode_New`` as part of :ref:`unstable-c-api`. The old name " "is deprecated, but will remain available until the signature changes again." msgstr "" -#: ../../c-api/code.rst:72 +#: ../../c-api/code.rst:74 msgid "" "Similar to :c:func:`PyUnstable_Code_New`, but with an extra " "\"posonlyargcount\" for positional-only arguments. The same caveats that " "apply to ``PyUnstable_Code_New`` also apply to this function." msgstr "" -#: ../../c-api/code.rst:77 +#: ../../c-api/code.rst:79 msgid "as ``PyCode_NewWithPosOnlyArgs``" msgstr "" -#: ../../c-api/code.rst:79 +#: ../../c-api/code.rst:81 msgid "Added ``qualname`` and ``exceptiontable`` parameters." msgstr "新增 ``qualname`` 和 ``exceptiontable`` 參數。" -#: ../../c-api/code.rst:84 +#: ../../c-api/code.rst:86 msgid "" "Renamed to ``PyUnstable_Code_NewWithPosOnlyArgs``. The old name is " "deprecated, but will remain available until the signature changes again." msgstr "" -#: ../../c-api/code.rst:90 +#: ../../c-api/code.rst:92 msgid "" "Return a new empty code object with the specified filename, function name, " "and first line number. The resulting code object will raise an ``Exception`` " "if executed." msgstr "" -#: ../../c-api/code.rst:96 +#: ../../c-api/code.rst:98 msgid "" "Return the line number of the instruction that occurs on or before " "``byte_offset`` and ends after it. If you just need the line number of a " "frame, use :c:func:`PyFrame_GetLineNumber` instead." msgstr "" -#: ../../c-api/code.rst:99 +#: ../../c-api/code.rst:101 msgid "" -"For efficiently iterating over the line numbers in a code object, use `the " -"API described in PEP 626 `_." +"For efficiently iterating over the line numbers in a code object, use :pep:" +"`the API described in PEP 626 <0626#out-of-process-debuggers-and-profilers>`." msgstr "" -#: ../../c-api/code.rst:104 +#: ../../c-api/code.rst:106 msgid "" "Sets the passed ``int`` pointers to the source code line and column numbers " "for the instruction at ``byte_offset``. Sets the value to ``0`` when " "information is not available for any particular element." msgstr "" -#: ../../c-api/code.rst:108 +#: ../../c-api/code.rst:110 msgid "Returns ``1`` if the function succeeds and 0 otherwise." msgstr "" -#: ../../c-api/code.rst:114 +#: ../../c-api/code.rst:116 msgid "" "Equivalent to the Python code ``getattr(co, 'co_code')``. Returns a strong " "reference to a :c:type:`PyBytesObject` representing the bytecode in a code " "object. On error, ``NULL`` is returned and an exception is raised." msgstr "" -#: ../../c-api/code.rst:119 +#: ../../c-api/code.rst:121 msgid "" "This ``PyBytesObject`` may be created on-demand by the interpreter and does " "not necessarily represent the bytecode actually executed by CPython. The " "primary use case for this function is debuggers and profilers." msgstr "" -#: ../../c-api/code.rst:127 +#: ../../c-api/code.rst:129 msgid "" "Equivalent to the Python code ``getattr(co, 'co_varnames')``. Returns a new " "reference to a :c:type:`PyTupleObject` containing the names of the local " "variables. On error, ``NULL`` is returned and an exception is raised." msgstr "" -#: ../../c-api/code.rst:136 +#: ../../c-api/code.rst:138 msgid "" "Equivalent to the Python code ``getattr(co, 'co_cellvars')``. Returns a new " "reference to a :c:type:`PyTupleObject` containing the names of the local " @@ -173,14 +176,15 @@ msgid "" "returned and an exception is raised." msgstr "" -#: ../../c-api/code.rst:145 +#: ../../c-api/code.rst:147 msgid "" "Equivalent to the Python code ``getattr(co, 'co_freevars')``. Returns a new " -"reference to a :c:type:`PyTupleObject` containing the names of the free " -"variables. On error, ``NULL`` is returned and an exception is raised." +"reference to a :c:type:`PyTupleObject` containing the names of the :term:" +"`free (closure) variables `. On error, ``NULL`` is " +"returned and an exception is raised." msgstr "" -#: ../../c-api/code.rst:153 +#: ../../c-api/code.rst:156 msgid "" "Register *callback* as a code object watcher for the current interpreter. " "Return an ID which may be passed to :c:func:`PyCode_ClearWatcher`. In case " @@ -188,7 +192,7 @@ msgid "" "exception." msgstr "" -#: ../../c-api/code.rst:162 +#: ../../c-api/code.rst:165 msgid "" "Clear watcher identified by *watcher_id* previously returned from :c:func:" "`PyCode_AddWatcher` for the current interpreter. Return ``0`` on success, or " @@ -196,17 +200,17 @@ msgid "" "never registered.)" msgstr "" -#: ../../c-api/code.rst:171 +#: ../../c-api/code.rst:174 msgid "" "Enumeration of possible code object watcher events: - " "``PY_CODE_EVENT_CREATE`` - ``PY_CODE_EVENT_DESTROY``" msgstr "" -#: ../../c-api/code.rst:179 +#: ../../c-api/code.rst:182 msgid "Type of a code object watcher callback function." msgstr "" -#: ../../c-api/code.rst:181 +#: ../../c-api/code.rst:184 msgid "" "If *event* is ``PY_CODE_EVENT_CREATE``, then the callback is invoked after " "`co` has been fully initialized. Otherwise, the callback is invoked before " @@ -214,7 +218,7 @@ msgid "" "inspected." msgstr "" -#: ../../c-api/code.rst:186 +#: ../../c-api/code.rst:189 msgid "" "If *event* is ``PY_CODE_EVENT_DESTROY``, taking a reference in the callback " "to the about-to-be-destroyed code object will resurrect it and prevent it " @@ -222,7 +226,7 @@ msgid "" "later, any watcher callbacks active at that time will be called again." msgstr "" -#: ../../c-api/code.rst:191 +#: ../../c-api/code.rst:194 msgid "" "Users of this API should not rely on internal runtime implementation " "details. Such details may include, but are not limited to, the exact order " @@ -232,14 +236,14 @@ msgid "" "the Python code being executed." msgstr "" -#: ../../c-api/code.rst:198 +#: ../../c-api/code.rst:201 msgid "" "If the callback sets an exception, it must return ``-1``; this exception " "will be printed as an unraisable exception using :c:func:" "`PyErr_WriteUnraisable`. Otherwise it should return ``0``." msgstr "" -#: ../../c-api/code.rst:202 +#: ../../c-api/code.rst:205 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 " @@ -248,85 +252,85 @@ msgid "" "it before returning." msgstr "" -#: ../../c-api/code.rst:212 +#: ../../c-api/code.rst:215 msgid "Extra information" msgstr "" -#: ../../c-api/code.rst:214 +#: ../../c-api/code.rst:217 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:218 +#: ../../c-api/code.rst:221 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:224 +#: ../../c-api/code.rst:227 msgid "Return a new an opaque index value used to adding data to code objects." msgstr "" -#: ../../c-api/code.rst:226 +#: ../../c-api/code.rst:229 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:230 +#: ../../c-api/code.rst:233 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:236 +#: ../../c-api/code.rst:239 msgid "as ``_PyEval_RequestCodeExtraIndex``" msgstr "" -#: ../../c-api/code.rst:240 +#: ../../c-api/code.rst:243 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:246 +#: ../../c-api/code.rst:249 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:249 +#: ../../c-api/code.rst:252 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:254 +#: ../../c-api/code.rst:257 msgid "as ``_PyCode_GetExtra``" msgstr "" -#: ../../c-api/code.rst:258 +#: ../../c-api/code.rst:261 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:264 +#: ../../c-api/code.rst:267 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:269 +#: ../../c-api/code.rst:272 msgid "as ``_PyCode_SetExtra``" msgstr "" -#: ../../c-api/code.rst:273 +#: ../../c-api/code.rst:276 msgid "" "Renamed to ``PyUnstable_Code_SetExtra``. The old private name is deprecated, " "but will be available until the API changes." @@ -344,22 +348,22 @@ msgstr "code(程式碼)" msgid "code object" msgstr "code object(程式碼物件)" -#: ../../c-api/code.rst:62 +#: ../../c-api/code.rst:64 msgid "PyCode_New (C function)" msgstr "PyCode_New(C 函式)" -#: ../../c-api/code.rst:75 +#: ../../c-api/code.rst:77 msgid "PyCode_NewWithPosOnlyArgs (C function)" msgstr "PyCode_NewWithPosOnlyArgs(C 函式)" -#: ../../c-api/code.rst:234 +#: ../../c-api/code.rst:237 msgid "_PyEval_RequestCodeExtraIndex (C function)" msgstr "_PyEval_RequestCodeExtraIndex(C 函式)" -#: ../../c-api/code.rst:252 +#: ../../c-api/code.rst:255 msgid "_PyCode_GetExtra (C function)" msgstr "_PyCode_GetExtra(C 函式)" -#: ../../c-api/code.rst:267 +#: ../../c-api/code.rst:270 msgid "_PyCode_SetExtra (C function)" msgstr "_PyCode_SetExtra(C 函式)" diff --git a/c-api/dict.po b/c-api/dict.po index 5a9c30db1f..77e792841e 100644 --- a/c-api/dict.po +++ b/c-api/dict.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-03-03 18:39+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-" @@ -184,9 +184,8 @@ msgstr "" #: ../../c-api/dict.rst:159 msgid "" -"Similar than :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 @@ -239,8 +238,8 @@ msgstr "" #: ../../c-api/dict.rst:209 msgid "" -"This is 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 missing." msgstr "" #: ../../c-api/dict.rst:217 diff --git a/c-api/exceptions.po b/c-api/exceptions.po index 7709f0093c..af94883d50 100644 --- a/c-api/exceptions.po +++ b/c-api/exceptions.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2024-10-13 17:13+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-" @@ -267,8 +267,8 @@ msgstr "" #: ../../c-api/exceptions.rst:234 ../../c-api/exceptions.rst:242 #: ../../c-api/exceptions.rst:253 ../../c-api/exceptions.rst:263 #: ../../c-api/exceptions.rst:271 ../../c-api/exceptions.rst:281 -msgid ":ref:`Availability `: Windows." -msgstr ":ref:`適用 `:Windows。" +msgid "Availability" +msgstr "" #: ../../c-api/exceptions.rst:239 msgid "" @@ -784,9 +784,9 @@ msgstr "" #: ../../c-api/exceptions.rst:736 msgid "" -"The :attr:`!__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 to " -"the last part (after the last dot). The *base* argument can be used to " +"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 " +"to the last part (after the last dot). The *base* argument can be used to " "specify alternate base classes; it can either be only one class or a tuple " "of classes. The *dict* argument can be used to specify a dictionary of class " "variables and methods." @@ -1038,451 +1038,461 @@ msgid "" "all the variables:" msgstr "" -#: ../../c-api/exceptions.rst:1027 ../../c-api/exceptions.rst:1160 -#: ../../c-api/exceptions.rst:1205 +#: ../../c-api/exceptions.rst:1028 ../../c-api/exceptions.rst:1163 +#: ../../c-api/exceptions.rst:1208 msgid "C Name" msgstr "C 名稱" -#: ../../c-api/exceptions.rst:1027 ../../c-api/exceptions.rst:1205 +#: ../../c-api/exceptions.rst:1028 ../../c-api/exceptions.rst:1208 msgid "Python Name" msgstr "Python 名稱" -#: ../../c-api/exceptions.rst:1027 ../../c-api/exceptions.rst:1160 -#: ../../c-api/exceptions.rst:1205 +#: ../../c-api/exceptions.rst:1028 ../../c-api/exceptions.rst:1163 +#: ../../c-api/exceptions.rst:1208 msgid "Notes" msgstr "註解" -#: ../../c-api/exceptions.rst:1029 +#: ../../c-api/exceptions.rst:1030 msgid ":c:data:`PyExc_BaseException`" msgstr ":c:data:`PyExc_BaseException`" -#: ../../c-api/exceptions.rst:1029 +#: ../../c-api/exceptions.rst:1030 msgid ":exc:`BaseException`" msgstr ":exc:`BaseException`" -#: ../../c-api/exceptions.rst:1029 ../../c-api/exceptions.rst:1031 -#: ../../c-api/exceptions.rst:1033 ../../c-api/exceptions.rst:1079 -#: ../../c-api/exceptions.rst:1091 +#: ../../c-api/exceptions.rst:1030 ../../c-api/exceptions.rst:1032 +#: ../../c-api/exceptions.rst:1034 ../../c-api/exceptions.rst:1080 +#: ../../c-api/exceptions.rst:1092 msgid "[1]_" msgstr "[1]_" -#: ../../c-api/exceptions.rst:1031 +#: ../../c-api/exceptions.rst:1032 msgid ":c:data:`PyExc_Exception`" msgstr ":c:data:`PyExc_Exception`" -#: ../../c-api/exceptions.rst:1031 +#: ../../c-api/exceptions.rst:1032 msgid ":exc:`Exception`" msgstr ":exc:`Exception`" -#: ../../c-api/exceptions.rst:1033 +#: ../../c-api/exceptions.rst:1034 msgid ":c:data:`PyExc_ArithmeticError`" msgstr ":c:data:`PyExc_ArithmeticError`" -#: ../../c-api/exceptions.rst:1033 +#: ../../c-api/exceptions.rst:1034 msgid ":exc:`ArithmeticError`" msgstr ":exc:`ArithmeticError`" -#: ../../c-api/exceptions.rst:1035 +#: ../../c-api/exceptions.rst:1036 msgid ":c:data:`PyExc_AssertionError`" msgstr ":c:data:`PyExc_AssertionError`" -#: ../../c-api/exceptions.rst:1035 +#: ../../c-api/exceptions.rst:1036 msgid ":exc:`AssertionError`" msgstr ":exc:`AssertionError`" -#: ../../c-api/exceptions.rst:1037 +#: ../../c-api/exceptions.rst:1038 msgid ":c:data:`PyExc_AttributeError`" msgstr ":c:data:`PyExc_AttributeError`" -#: ../../c-api/exceptions.rst:1037 +#: ../../c-api/exceptions.rst:1038 msgid ":exc:`AttributeError`" msgstr ":exc:`AttributeError`" -#: ../../c-api/exceptions.rst:1039 +#: ../../c-api/exceptions.rst:1040 msgid ":c:data:`PyExc_BlockingIOError`" msgstr ":c:data:`PyExc_BlockingIOError`" -#: ../../c-api/exceptions.rst:1039 +#: ../../c-api/exceptions.rst:1040 msgid ":exc:`BlockingIOError`" msgstr ":exc:`BlockingIOError`" -#: ../../c-api/exceptions.rst:1041 +#: ../../c-api/exceptions.rst:1042 msgid ":c:data:`PyExc_BrokenPipeError`" msgstr ":c:data:`PyExc_BrokenPipeError`" -#: ../../c-api/exceptions.rst:1041 +#: ../../c-api/exceptions.rst:1042 msgid ":exc:`BrokenPipeError`" msgstr ":exc:`BrokenPipeError`" -#: ../../c-api/exceptions.rst:1043 +#: ../../c-api/exceptions.rst:1044 msgid ":c:data:`PyExc_BufferError`" msgstr ":c:data:`PyExc_BufferError`" -#: ../../c-api/exceptions.rst:1043 +#: ../../c-api/exceptions.rst:1044 msgid ":exc:`BufferError`" msgstr ":exc:`BufferError`" -#: ../../c-api/exceptions.rst:1045 +#: ../../c-api/exceptions.rst:1046 msgid ":c:data:`PyExc_ChildProcessError`" msgstr ":c:data:`PyExc_ChildProcessError`" -#: ../../c-api/exceptions.rst:1045 +#: ../../c-api/exceptions.rst:1046 msgid ":exc:`ChildProcessError`" msgstr ":exc:`ChildProcessError`" -#: ../../c-api/exceptions.rst:1047 +#: ../../c-api/exceptions.rst:1048 msgid ":c:data:`PyExc_ConnectionAbortedError`" msgstr ":c:data:`PyExc_ConnectionAbortedError`" -#: ../../c-api/exceptions.rst:1047 +#: ../../c-api/exceptions.rst:1048 msgid ":exc:`ConnectionAbortedError`" msgstr ":exc:`ConnectionAbortedError`" -#: ../../c-api/exceptions.rst:1049 +#: ../../c-api/exceptions.rst:1050 msgid ":c:data:`PyExc_ConnectionError`" msgstr ":c:data:`PyExc_ConnectionError`" -#: ../../c-api/exceptions.rst:1049 +#: ../../c-api/exceptions.rst:1050 msgid ":exc:`ConnectionError`" msgstr ":exc:`ConnectionError`" -#: ../../c-api/exceptions.rst:1051 +#: ../../c-api/exceptions.rst:1052 msgid ":c:data:`PyExc_ConnectionRefusedError`" msgstr ":c:data:`PyExc_ConnectionRefusedError`" -#: ../../c-api/exceptions.rst:1051 +#: ../../c-api/exceptions.rst:1052 msgid ":exc:`ConnectionRefusedError`" msgstr ":exc:`ConnectionRefusedError`" -#: ../../c-api/exceptions.rst:1053 +#: ../../c-api/exceptions.rst:1054 msgid ":c:data:`PyExc_ConnectionResetError`" msgstr ":c:data:`PyExc_ConnectionResetError`" -#: ../../c-api/exceptions.rst:1053 +#: ../../c-api/exceptions.rst:1054 msgid ":exc:`ConnectionResetError`" msgstr ":exc:`ConnectionResetError`" -#: ../../c-api/exceptions.rst:1055 +#: ../../c-api/exceptions.rst:1056 msgid ":c:data:`PyExc_EOFError`" msgstr ":c:data:`PyExc_EOFError`" -#: ../../c-api/exceptions.rst:1055 +#: ../../c-api/exceptions.rst:1056 msgid ":exc:`EOFError`" msgstr ":exc:`EOFError`" -#: ../../c-api/exceptions.rst:1057 +#: ../../c-api/exceptions.rst:1058 msgid ":c:data:`PyExc_FileExistsError`" msgstr ":c:data:`PyExc_FileExistsError`" -#: ../../c-api/exceptions.rst:1057 +#: ../../c-api/exceptions.rst:1058 msgid ":exc:`FileExistsError`" msgstr ":exc:`FileExistsError`" -#: ../../c-api/exceptions.rst:1059 +#: ../../c-api/exceptions.rst:1060 msgid ":c:data:`PyExc_FileNotFoundError`" msgstr ":c:data:`PyExc_FileNotFoundError`" -#: ../../c-api/exceptions.rst:1059 +#: ../../c-api/exceptions.rst:1060 msgid ":exc:`FileNotFoundError`" msgstr ":exc:`FileNotFoundError`" -#: ../../c-api/exceptions.rst:1061 +#: ../../c-api/exceptions.rst:1062 msgid ":c:data:`PyExc_FloatingPointError`" msgstr ":c:data:`PyExc_FloatingPointError`" -#: ../../c-api/exceptions.rst:1061 +#: ../../c-api/exceptions.rst:1062 msgid ":exc:`FloatingPointError`" msgstr ":exc:`FloatingPointError`" -#: ../../c-api/exceptions.rst:1063 +#: ../../c-api/exceptions.rst:1064 msgid ":c:data:`PyExc_GeneratorExit`" msgstr ":c:data:`PyExc_GeneratorExit`" -#: ../../c-api/exceptions.rst:1063 +#: ../../c-api/exceptions.rst:1064 msgid ":exc:`GeneratorExit`" msgstr ":exc:`GeneratorExit`" -#: ../../c-api/exceptions.rst:1065 +#: ../../c-api/exceptions.rst:1066 msgid ":c:data:`PyExc_ImportError`" msgstr ":c:data:`PyExc_ImportError`" -#: ../../c-api/exceptions.rst:1065 +#: ../../c-api/exceptions.rst:1066 msgid ":exc:`ImportError`" msgstr ":exc:`ImportError`" -#: ../../c-api/exceptions.rst:1067 +#: ../../c-api/exceptions.rst:1068 msgid ":c:data:`PyExc_IndentationError`" msgstr ":c:data:`PyExc_IndentationError`" -#: ../../c-api/exceptions.rst:1067 +#: ../../c-api/exceptions.rst:1068 msgid ":exc:`IndentationError`" msgstr ":exc:`IndentationError`" -#: ../../c-api/exceptions.rst:1069 +#: ../../c-api/exceptions.rst:1070 msgid ":c:data:`PyExc_IndexError`" msgstr ":c:data:`PyExc_IndexError`" -#: ../../c-api/exceptions.rst:1069 +#: ../../c-api/exceptions.rst:1070 msgid ":exc:`IndexError`" msgstr ":exc:`IndexError`" -#: ../../c-api/exceptions.rst:1071 +#: ../../c-api/exceptions.rst:1072 msgid ":c:data:`PyExc_InterruptedError`" msgstr ":c:data:`PyExc_InterruptedError`" -#: ../../c-api/exceptions.rst:1071 +#: ../../c-api/exceptions.rst:1072 msgid ":exc:`InterruptedError`" msgstr ":exc:`InterruptedError`" -#: ../../c-api/exceptions.rst:1073 +#: ../../c-api/exceptions.rst:1074 msgid ":c:data:`PyExc_IsADirectoryError`" msgstr ":c:data:`PyExc_IsADirectoryError`" -#: ../../c-api/exceptions.rst:1073 +#: ../../c-api/exceptions.rst:1074 msgid ":exc:`IsADirectoryError`" msgstr ":exc:`IsADirectoryError`" -#: ../../c-api/exceptions.rst:1075 +#: ../../c-api/exceptions.rst:1076 msgid ":c:data:`PyExc_KeyError`" msgstr ":c:data:`PyExc_KeyError`" -#: ../../c-api/exceptions.rst:1075 +#: ../../c-api/exceptions.rst:1076 msgid ":exc:`KeyError`" msgstr ":exc:`KeyError`" -#: ../../c-api/exceptions.rst:1077 +#: ../../c-api/exceptions.rst:1078 msgid ":c:data:`PyExc_KeyboardInterrupt`" msgstr ":c:data:`PyExc_KeyboardInterrupt`" -#: ../../c-api/exceptions.rst:1077 +#: ../../c-api/exceptions.rst:1078 msgid ":exc:`KeyboardInterrupt`" msgstr ":exc:`KeyboardInterrupt`" -#: ../../c-api/exceptions.rst:1079 +#: ../../c-api/exceptions.rst:1080 msgid ":c:data:`PyExc_LookupError`" msgstr ":c:data:`PyExc_LookupError`" -#: ../../c-api/exceptions.rst:1079 +#: ../../c-api/exceptions.rst:1080 msgid ":exc:`LookupError`" msgstr ":exc:`LookupError`" -#: ../../c-api/exceptions.rst:1081 +#: ../../c-api/exceptions.rst:1082 msgid ":c:data:`PyExc_MemoryError`" msgstr ":c:data:`PyExc_MemoryError`" -#: ../../c-api/exceptions.rst:1081 +#: ../../c-api/exceptions.rst:1082 msgid ":exc:`MemoryError`" msgstr ":exc:`MemoryError`" -#: ../../c-api/exceptions.rst:1083 +#: ../../c-api/exceptions.rst:1084 msgid ":c:data:`PyExc_ModuleNotFoundError`" msgstr ":c:data:`PyExc_ModuleNotFoundError`" -#: ../../c-api/exceptions.rst:1083 +#: ../../c-api/exceptions.rst:1084 msgid ":exc:`ModuleNotFoundError`" msgstr ":exc:`ModuleNotFoundError`" -#: ../../c-api/exceptions.rst:1085 +#: ../../c-api/exceptions.rst:1086 msgid ":c:data:`PyExc_NameError`" msgstr ":c:data:`PyExc_NameError`" -#: ../../c-api/exceptions.rst:1085 +#: ../../c-api/exceptions.rst:1086 msgid ":exc:`NameError`" msgstr ":exc:`NameError`" -#: ../../c-api/exceptions.rst:1087 +#: ../../c-api/exceptions.rst:1088 msgid ":c:data:`PyExc_NotADirectoryError`" msgstr ":c:data:`PyExc_NotADirectoryError`" -#: ../../c-api/exceptions.rst:1087 +#: ../../c-api/exceptions.rst:1088 msgid ":exc:`NotADirectoryError`" msgstr ":exc:`NotADirectoryError`" -#: ../../c-api/exceptions.rst:1089 +#: ../../c-api/exceptions.rst:1090 msgid ":c:data:`PyExc_NotImplementedError`" msgstr ":c:data:`PyExc_NotImplementedError`" -#: ../../c-api/exceptions.rst:1089 +#: ../../c-api/exceptions.rst:1090 msgid ":exc:`NotImplementedError`" msgstr ":exc:`NotImplementedError`" -#: ../../c-api/exceptions.rst:1091 +#: ../../c-api/exceptions.rst:1092 msgid ":c:data:`PyExc_OSError`" msgstr ":c:data:`PyExc_OSError`" -#: ../../c-api/exceptions.rst:1091 +#: ../../c-api/exceptions.rst:1092 msgid ":exc:`OSError`" msgstr ":exc:`OSError`" -#: ../../c-api/exceptions.rst:1093 +#: ../../c-api/exceptions.rst:1094 msgid ":c:data:`PyExc_OverflowError`" msgstr ":c:data:`PyExc_OverflowError`" -#: ../../c-api/exceptions.rst:1093 +#: ../../c-api/exceptions.rst:1094 msgid ":exc:`OverflowError`" msgstr ":exc:`OverflowError`" -#: ../../c-api/exceptions.rst:1095 +#: ../../c-api/exceptions.rst:1096 msgid ":c:data:`PyExc_PermissionError`" msgstr ":c:data:`PyExc_PermissionError`" -#: ../../c-api/exceptions.rst:1095 +#: ../../c-api/exceptions.rst:1096 msgid ":exc:`PermissionError`" msgstr ":exc:`PermissionError`" -#: ../../c-api/exceptions.rst:1097 +#: ../../c-api/exceptions.rst:1098 msgid ":c:data:`PyExc_ProcessLookupError`" msgstr ":c:data:`PyExc_ProcessLookupError`" -#: ../../c-api/exceptions.rst:1097 +#: ../../c-api/exceptions.rst:1098 msgid ":exc:`ProcessLookupError`" msgstr ":exc:`ProcessLookupError`" -#: ../../c-api/exceptions.rst:1099 +#: ../../c-api/exceptions.rst:1100 +#, fuzzy +msgid ":c:data:`PyExc_PythonFinalizationError`" +msgstr ":c:data:`PyExc_ConnectionError`" + +#: ../../c-api/exceptions.rst:1100 +#, fuzzy +msgid ":exc:`PythonFinalizationError`" +msgstr ":exc:`ConnectionError`" + +#: ../../c-api/exceptions.rst:1102 msgid ":c:data:`PyExc_RecursionError`" msgstr ":c:data:`PyExc_RecursionError`" -#: ../../c-api/exceptions.rst:1099 +#: ../../c-api/exceptions.rst:1102 msgid ":exc:`RecursionError`" msgstr ":exc:`RecursionError`" -#: ../../c-api/exceptions.rst:1101 +#: ../../c-api/exceptions.rst:1104 msgid ":c:data:`PyExc_ReferenceError`" msgstr ":c:data:`PyExc_ReferenceError`" -#: ../../c-api/exceptions.rst:1101 +#: ../../c-api/exceptions.rst:1104 msgid ":exc:`ReferenceError`" msgstr ":exc:`ReferenceError`" -#: ../../c-api/exceptions.rst:1103 +#: ../../c-api/exceptions.rst:1106 msgid ":c:data:`PyExc_RuntimeError`" msgstr ":c:data:`PyExc_RuntimeError`" -#: ../../c-api/exceptions.rst:1103 +#: ../../c-api/exceptions.rst:1106 msgid ":exc:`RuntimeError`" msgstr ":exc:`RuntimeError`" -#: ../../c-api/exceptions.rst:1105 +#: ../../c-api/exceptions.rst:1108 msgid ":c:data:`PyExc_StopAsyncIteration`" msgstr ":c:data:`PyExc_StopAsyncIteration`" -#: ../../c-api/exceptions.rst:1105 +#: ../../c-api/exceptions.rst:1108 msgid ":exc:`StopAsyncIteration`" msgstr ":exc:`StopAsyncIteration`" -#: ../../c-api/exceptions.rst:1107 +#: ../../c-api/exceptions.rst:1110 msgid ":c:data:`PyExc_StopIteration`" msgstr ":c:data:`PyExc_StopIteration`" -#: ../../c-api/exceptions.rst:1107 +#: ../../c-api/exceptions.rst:1110 msgid ":exc:`StopIteration`" msgstr ":exc:`StopIteration`" -#: ../../c-api/exceptions.rst:1109 +#: ../../c-api/exceptions.rst:1112 msgid ":c:data:`PyExc_SyntaxError`" msgstr ":c:data:`PyExc_SyntaxError`" -#: ../../c-api/exceptions.rst:1109 +#: ../../c-api/exceptions.rst:1112 msgid ":exc:`SyntaxError`" msgstr ":exc:`SyntaxError`" -#: ../../c-api/exceptions.rst:1111 +#: ../../c-api/exceptions.rst:1114 msgid ":c:data:`PyExc_SystemError`" msgstr ":c:data:`PyExc_SystemError`" -#: ../../c-api/exceptions.rst:1111 +#: ../../c-api/exceptions.rst:1114 msgid ":exc:`SystemError`" msgstr ":exc:`SystemError`" -#: ../../c-api/exceptions.rst:1113 +#: ../../c-api/exceptions.rst:1116 msgid ":c:data:`PyExc_SystemExit`" msgstr ":c:data:`PyExc_SystemExit`" -#: ../../c-api/exceptions.rst:1113 +#: ../../c-api/exceptions.rst:1116 msgid ":exc:`SystemExit`" msgstr ":exc:`SystemExit`" -#: ../../c-api/exceptions.rst:1115 +#: ../../c-api/exceptions.rst:1118 msgid ":c:data:`PyExc_TabError`" msgstr ":c:data:`PyExc_TabError`" -#: ../../c-api/exceptions.rst:1115 +#: ../../c-api/exceptions.rst:1118 msgid ":exc:`TabError`" msgstr ":exc:`TabError`" -#: ../../c-api/exceptions.rst:1117 +#: ../../c-api/exceptions.rst:1120 msgid ":c:data:`PyExc_TimeoutError`" msgstr ":c:data:`PyExc_TimeoutError`" -#: ../../c-api/exceptions.rst:1117 +#: ../../c-api/exceptions.rst:1120 msgid ":exc:`TimeoutError`" msgstr ":exc:`TimeoutError`" -#: ../../c-api/exceptions.rst:1119 +#: ../../c-api/exceptions.rst:1122 msgid ":c:data:`PyExc_TypeError`" msgstr ":c:data:`PyExc_TypeError`" -#: ../../c-api/exceptions.rst:1119 +#: ../../c-api/exceptions.rst:1122 msgid ":exc:`TypeError`" msgstr ":exc:`TypeError`" -#: ../../c-api/exceptions.rst:1121 +#: ../../c-api/exceptions.rst:1124 msgid ":c:data:`PyExc_UnboundLocalError`" msgstr ":c:data:`PyExc_UnboundLocalError`" -#: ../../c-api/exceptions.rst:1121 +#: ../../c-api/exceptions.rst:1124 msgid ":exc:`UnboundLocalError`" msgstr ":exc:`UnboundLocalError`" -#: ../../c-api/exceptions.rst:1123 +#: ../../c-api/exceptions.rst:1126 msgid ":c:data:`PyExc_UnicodeDecodeError`" msgstr ":c:data:`PyExc_UnicodeDecodeError`" -#: ../../c-api/exceptions.rst:1123 +#: ../../c-api/exceptions.rst:1126 msgid ":exc:`UnicodeDecodeError`" msgstr ":exc:`UnicodeDecodeError`" -#: ../../c-api/exceptions.rst:1125 +#: ../../c-api/exceptions.rst:1128 msgid ":c:data:`PyExc_UnicodeEncodeError`" msgstr ":c:data:`PyExc_UnicodeEncodeError`" -#: ../../c-api/exceptions.rst:1125 +#: ../../c-api/exceptions.rst:1128 msgid ":exc:`UnicodeEncodeError`" msgstr ":exc:`UnicodeEncodeError`" -#: ../../c-api/exceptions.rst:1127 +#: ../../c-api/exceptions.rst:1130 msgid ":c:data:`PyExc_UnicodeError`" msgstr ":c:data:`PyExc_UnicodeError`" -#: ../../c-api/exceptions.rst:1127 +#: ../../c-api/exceptions.rst:1130 msgid ":exc:`UnicodeError`" msgstr ":exc:`UnicodeError`" -#: ../../c-api/exceptions.rst:1129 +#: ../../c-api/exceptions.rst:1132 msgid ":c:data:`PyExc_UnicodeTranslateError`" msgstr ":c:data:`PyExc_UnicodeTranslateError`" -#: ../../c-api/exceptions.rst:1129 +#: ../../c-api/exceptions.rst:1132 msgid ":exc:`UnicodeTranslateError`" msgstr ":exc:`UnicodeTranslateError`" -#: ../../c-api/exceptions.rst:1131 +#: ../../c-api/exceptions.rst:1134 msgid ":c:data:`PyExc_ValueError`" msgstr ":c:data:`PyExc_ValueError`" -#: ../../c-api/exceptions.rst:1131 +#: ../../c-api/exceptions.rst:1134 msgid ":exc:`ValueError`" msgstr ":exc:`ValueError`" -#: ../../c-api/exceptions.rst:1133 +#: ../../c-api/exceptions.rst:1136 msgid ":c:data:`PyExc_ZeroDivisionError`" msgstr ":c:data:`PyExc_ZeroDivisionError`" -#: ../../c-api/exceptions.rst:1133 +#: ../../c-api/exceptions.rst:1136 msgid ":exc:`ZeroDivisionError`" msgstr ":exc:`ZeroDivisionError`" -#: ../../c-api/exceptions.rst:1136 +#: ../../c-api/exceptions.rst:1139 msgid "" ":c:data:`PyExc_BlockingIOError`, :c:data:`PyExc_BrokenPipeError`, :c:data:" "`PyExc_ChildProcessError`, :c:data:`PyExc_ConnectionError`, :c:data:" @@ -1502,57 +1512,57 @@ msgstr "" "`PyExc_PermissionError`, :c:data:`PyExc_ProcessLookupError` 和 :c:data:" "`PyExc_TimeoutError` 是在 :pep:`3151` 被引入。" -#: ../../c-api/exceptions.rst:1146 +#: ../../c-api/exceptions.rst:1149 msgid ":c:data:`PyExc_StopAsyncIteration` and :c:data:`PyExc_RecursionError`." msgstr ":c:data:`PyExc_StopAsyncIteration` 和 :c:data:`PyExc_RecursionError`。" -#: ../../c-api/exceptions.rst:1149 +#: ../../c-api/exceptions.rst:1152 msgid ":c:data:`PyExc_ModuleNotFoundError`." msgstr ":c:data:`PyExc_ModuleNotFoundError`。" -#: ../../c-api/exceptions.rst:1152 +#: ../../c-api/exceptions.rst:1155 msgid "These are compatibility aliases to :c:data:`PyExc_OSError`:" msgstr "" -#: ../../c-api/exceptions.rst:1162 +#: ../../c-api/exceptions.rst:1165 msgid ":c:data:`!PyExc_EnvironmentError`" msgstr ":c:data:`!PyExc_EnvironmentError`" -#: ../../c-api/exceptions.rst:1164 +#: ../../c-api/exceptions.rst:1167 msgid ":c:data:`!PyExc_IOError`" msgstr ":c:data:`!PyExc_IOError`" -#: ../../c-api/exceptions.rst:1166 +#: ../../c-api/exceptions.rst:1169 msgid ":c:data:`!PyExc_WindowsError`" msgstr ":c:data:`!PyExc_WindowsError`" -#: ../../c-api/exceptions.rst:1166 +#: ../../c-api/exceptions.rst:1169 msgid "[2]_" msgstr "[2]_" -#: ../../c-api/exceptions.rst:1169 +#: ../../c-api/exceptions.rst:1172 msgid "These aliases used to be separate exception types." msgstr "" -#: ../../c-api/exceptions.rst:1172 ../../c-api/exceptions.rst:1233 +#: ../../c-api/exceptions.rst:1175 ../../c-api/exceptions.rst:1236 msgid "Notes:" msgstr "註解:" -#: ../../c-api/exceptions.rst:1175 +#: ../../c-api/exceptions.rst:1178 msgid "This is a base class for other standard exceptions." msgstr "" -#: ../../c-api/exceptions.rst:1178 +#: ../../c-api/exceptions.rst:1181 msgid "" "Only defined on Windows; protect code that uses this by testing that the " "preprocessor macro ``MS_WINDOWS`` is defined." msgstr "" -#: ../../c-api/exceptions.rst:1184 +#: ../../c-api/exceptions.rst:1187 msgid "Standard Warning Categories" msgstr "" -#: ../../c-api/exceptions.rst:1186 +#: ../../c-api/exceptions.rst:1189 msgid "" "All standard Python warning categories are available as global variables " "whose names are ``PyExc_`` followed by the Python exception name. These have " @@ -1560,103 +1570,103 @@ msgid "" "here are all the variables:" msgstr "" -#: ../../c-api/exceptions.rst:1207 +#: ../../c-api/exceptions.rst:1210 msgid ":c:data:`PyExc_Warning`" msgstr ":c:data:`PyExc_Warning`" -#: ../../c-api/exceptions.rst:1207 +#: ../../c-api/exceptions.rst:1210 msgid ":exc:`Warning`" msgstr ":exc:`Warning`" -#: ../../c-api/exceptions.rst:1207 +#: ../../c-api/exceptions.rst:1210 msgid "[3]_" msgstr "[3]_" -#: ../../c-api/exceptions.rst:1209 +#: ../../c-api/exceptions.rst:1212 msgid ":c:data:`PyExc_BytesWarning`" msgstr ":c:data:`PyExc_BytesWarning`" -#: ../../c-api/exceptions.rst:1209 +#: ../../c-api/exceptions.rst:1212 msgid ":exc:`BytesWarning`" msgstr ":exc:`BytesWarning`" -#: ../../c-api/exceptions.rst:1211 +#: ../../c-api/exceptions.rst:1214 msgid ":c:data:`PyExc_DeprecationWarning`" msgstr ":c:data:`PyExc_DeprecationWarning`" -#: ../../c-api/exceptions.rst:1211 +#: ../../c-api/exceptions.rst:1214 msgid ":exc:`DeprecationWarning`" msgstr ":exc:`DeprecationWarning`" -#: ../../c-api/exceptions.rst:1213 +#: ../../c-api/exceptions.rst:1216 msgid ":c:data:`PyExc_FutureWarning`" msgstr ":c:data:`PyExc_FutureWarning`" -#: ../../c-api/exceptions.rst:1213 +#: ../../c-api/exceptions.rst:1216 msgid ":exc:`FutureWarning`" msgstr ":exc:`FutureWarning`" -#: ../../c-api/exceptions.rst:1215 +#: ../../c-api/exceptions.rst:1218 msgid ":c:data:`PyExc_ImportWarning`" msgstr ":c:data:`PyExc_ImportWarning`" -#: ../../c-api/exceptions.rst:1215 +#: ../../c-api/exceptions.rst:1218 msgid ":exc:`ImportWarning`" msgstr ":exc:`ImportWarning`" -#: ../../c-api/exceptions.rst:1217 +#: ../../c-api/exceptions.rst:1220 msgid ":c:data:`PyExc_PendingDeprecationWarning`" msgstr ":c:data:`PyExc_PendingDeprecationWarning`" -#: ../../c-api/exceptions.rst:1217 +#: ../../c-api/exceptions.rst:1220 msgid ":exc:`PendingDeprecationWarning`" msgstr ":exc:`PendingDeprecationWarning`" -#: ../../c-api/exceptions.rst:1219 +#: ../../c-api/exceptions.rst:1222 msgid ":c:data:`PyExc_ResourceWarning`" msgstr ":c:data:`PyExc_ResourceWarning`" -#: ../../c-api/exceptions.rst:1219 +#: ../../c-api/exceptions.rst:1222 msgid ":exc:`ResourceWarning`" msgstr ":exc:`ResourceWarning`" -#: ../../c-api/exceptions.rst:1221 +#: ../../c-api/exceptions.rst:1224 msgid ":c:data:`PyExc_RuntimeWarning`" msgstr ":c:data:`PyExc_RuntimeWarning`" -#: ../../c-api/exceptions.rst:1221 +#: ../../c-api/exceptions.rst:1224 msgid ":exc:`RuntimeWarning`" msgstr ":exc:`RuntimeWarning`" -#: ../../c-api/exceptions.rst:1223 +#: ../../c-api/exceptions.rst:1226 msgid ":c:data:`PyExc_SyntaxWarning`" msgstr ":c:data:`PyExc_SyntaxWarning`" -#: ../../c-api/exceptions.rst:1223 +#: ../../c-api/exceptions.rst:1226 msgid ":exc:`SyntaxWarning`" msgstr ":exc:`SyntaxWarning`" -#: ../../c-api/exceptions.rst:1225 +#: ../../c-api/exceptions.rst:1228 msgid ":c:data:`PyExc_UnicodeWarning`" msgstr ":c:data:`PyExc_UnicodeWarning`" -#: ../../c-api/exceptions.rst:1225 +#: ../../c-api/exceptions.rst:1228 msgid ":exc:`UnicodeWarning`" msgstr ":exc:`UnicodeWarning`" -#: ../../c-api/exceptions.rst:1227 +#: ../../c-api/exceptions.rst:1230 msgid ":c:data:`PyExc_UserWarning`" msgstr ":c:data:`PyExc_UserWarning`" -#: ../../c-api/exceptions.rst:1227 +#: ../../c-api/exceptions.rst:1230 msgid ":exc:`UserWarning`" msgstr ":exc:`UserWarning`" -#: ../../c-api/exceptions.rst:1230 +#: ../../c-api/exceptions.rst:1233 msgid ":c:data:`PyExc_ResourceWarning`." msgstr ":c:data:`PyExc_ResourceWarning`." -#: ../../c-api/exceptions.rst:1236 +#: ../../c-api/exceptions.rst:1239 msgid "This is a base class for other standard warning categories." msgstr "" @@ -1823,6 +1833,11 @@ msgstr "PyExc_PermissionError(C 變數)" msgid "PyExc_ProcessLookupError (C var)" msgstr "PyExc_ProcessLookupError(C 變數)" +#: ../../c-api/exceptions.rst:971 +#, fuzzy +msgid "PyExc_PythonFinalizationError (C var)" +msgstr "PyExc_ConnectionError(C 變數)" + #: ../../c-api/exceptions.rst:971 msgid "PyExc_RecursionError (C var)" msgstr "PyExc_RecursionError(C 變數)" @@ -1895,58 +1910,61 @@ msgstr "PyExc_ValueError(C 變數)" msgid "PyExc_ZeroDivisionError (C var)" msgstr "PyExc_ZeroDivisionError(C 變數)" -#: ../../c-api/exceptions.rst:1154 +#: ../../c-api/exceptions.rst:1157 msgid "PyExc_EnvironmentError (C var)" msgstr "PyExc_EnvironmentError(C 變數)" -#: ../../c-api/exceptions.rst:1154 +#: ../../c-api/exceptions.rst:1157 msgid "PyExc_IOError (C var)" msgstr "PyExc_IOError(C 變數)" -#: ../../c-api/exceptions.rst:1154 +#: ../../c-api/exceptions.rst:1157 msgid "PyExc_WindowsError (C var)" msgstr "PyExc_WindowsError(C 變數)" -#: ../../c-api/exceptions.rst:1191 +#: ../../c-api/exceptions.rst:1194 msgid "PyExc_Warning (C var)" msgstr "PyExc_Warning(C 變數)" -#: ../../c-api/exceptions.rst:1191 +#: ../../c-api/exceptions.rst:1194 msgid "PyExc_BytesWarning (C var)" msgstr "PyExc_BytesWarning(C 變數)" -#: ../../c-api/exceptions.rst:1191 +#: ../../c-api/exceptions.rst:1194 msgid "PyExc_DeprecationWarning (C var)" msgstr "PyExc_DeprecationWarning(C 變數)" -#: ../../c-api/exceptions.rst:1191 +#: ../../c-api/exceptions.rst:1194 msgid "PyExc_FutureWarning (C var)" msgstr "PyExc_FutureWarning(C 變數)" -#: ../../c-api/exceptions.rst:1191 +#: ../../c-api/exceptions.rst:1194 msgid "PyExc_ImportWarning (C var)" msgstr "PyExc_ImportWarning(C 變數)" -#: ../../c-api/exceptions.rst:1191 +#: ../../c-api/exceptions.rst:1194 msgid "PyExc_PendingDeprecationWarning (C var)" msgstr "PyExc_PendingDeprecationWarning(C 變數)" -#: ../../c-api/exceptions.rst:1191 +#: ../../c-api/exceptions.rst:1194 msgid "PyExc_ResourceWarning (C var)" msgstr "PyExc_ResourceWarning(C 變數)" -#: ../../c-api/exceptions.rst:1191 +#: ../../c-api/exceptions.rst:1194 msgid "PyExc_RuntimeWarning (C var)" msgstr "PyExc_RuntimeWarning(C 變數)" -#: ../../c-api/exceptions.rst:1191 +#: ../../c-api/exceptions.rst:1194 msgid "PyExc_SyntaxWarning (C var)" msgstr "PyExc_SyntaxWarning(C 變數)" -#: ../../c-api/exceptions.rst:1191 +#: ../../c-api/exceptions.rst:1194 msgid "PyExc_UnicodeWarning (C var)" msgstr "PyExc_UnicodeWarning(C 變數)" -#: ../../c-api/exceptions.rst:1191 +#: ../../c-api/exceptions.rst:1194 msgid "PyExc_UserWarning (C var)" msgstr "PyExc_UserWarning(C 變數)" + +#~ msgid ":ref:`Availability `: Windows." +#~ msgstr ":ref:`適用 `:Windows。" diff --git a/c-api/frame.po b/c-api/frame.po index 1e518a36e3..31dd038db1 100644 --- a/c-api/frame.po +++ b/c-api/frame.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2024-12-15 18:10+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -155,34 +155,61 @@ msgid "" msgstr "" #: ../../c-api/frame.rst:134 -msgid "As part of :pep:`667`, return a proxy object for optimized scopes." +msgid "" +"As part of :pep:`667`, return an instance of :c:var:" +"`PyFrameLocalsProxy_Type`." msgstr "" #: ../../c-api/frame.rst:140 msgid "Return the line number that *frame* is currently executing." msgstr "" -#: ../../c-api/frame.rst:145 +#: ../../c-api/frame.rst:144 +msgid "Frame Locals Proxies" +msgstr "" + +#: ../../c-api/frame.rst:148 +msgid "" +"The :attr:`~frame.f_locals` attribute on a :ref:`frame object ` is an instance of a \"frame-locals proxy\". The proxy object " +"exposes a write-through view of the underlying locals dictionary for the " +"frame. This ensures that the variables exposed by ``f_locals`` are always up " +"to date with the live local variables in the frame itself." +msgstr "" + +#: ../../c-api/frame.rst:154 +msgid "See :pep:`667` for more information." +msgstr "" + +#: ../../c-api/frame.rst:158 +msgid "The type of frame :func:`locals` proxy objects." +msgstr "" + +#: ../../c-api/frame.rst:162 +msgid "Return non-zero if *obj* is a frame :func:`locals` proxy." +msgstr "" + +#: ../../c-api/frame.rst:165 msgid "Internal Frames" msgstr "" -#: ../../c-api/frame.rst:147 +#: ../../c-api/frame.rst:167 msgid "Unless using :pep:`523`, you will not need this." msgstr "" -#: ../../c-api/frame.rst:151 +#: ../../c-api/frame.rst:171 msgid "The interpreter's internal frame representation." msgstr "" -#: ../../c-api/frame.rst:157 +#: ../../c-api/frame.rst:177 msgid "Return a :term:`strong reference` to the code object for the frame." msgstr "" -#: ../../c-api/frame.rst:164 +#: ../../c-api/frame.rst:184 msgid "Return the byte offset into the last executed instruction." msgstr "" -#: ../../c-api/frame.rst:171 +#: ../../c-api/frame.rst:191 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 c9e9a6c79f..b197aa7c8a 100644 --- a/c-api/function.po +++ b/c-api/function.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-12-13 00:03+0000\n" +"POT-Creation-Date: 2025-03-03 18:39+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-" @@ -187,18 +187,34 @@ msgid "" msgstr "" #: ../../c-api/function.rst:148 -msgid "" -"Enumeration of possible function watcher events: - " -"``PyFunction_EVENT_CREATE`` - ``PyFunction_EVENT_DESTROY`` - " -"``PyFunction_EVENT_MODIFY_CODE`` - ``PyFunction_EVENT_MODIFY_DEFAULTS`` - " -"``PyFunction_EVENT_MODIFY_KWDEFAULTS``" +msgid "Enumeration of possible function watcher events:" +msgstr "" + +#: ../../c-api/function.rst:150 +msgid "``PyFunction_EVENT_CREATE``" +msgstr "" + +#: ../../c-api/function.rst:151 +msgid "``PyFunction_EVENT_DESTROY``" +msgstr "" + +#: ../../c-api/function.rst:152 +msgid "``PyFunction_EVENT_MODIFY_CODE``" +msgstr "" + +#: ../../c-api/function.rst:153 +msgid "``PyFunction_EVENT_MODIFY_DEFAULTS``" +msgstr "" + +#: ../../c-api/function.rst:154 +msgid "``PyFunction_EVENT_MODIFY_KWDEFAULTS``" msgstr "" -#: ../../c-api/function.rst:160 +#: ../../c-api/function.rst:161 msgid "Type of a function watcher callback function." msgstr "" -#: ../../c-api/function.rst:162 +#: ../../c-api/function.rst:163 msgid "" "If *event* is ``PyFunction_EVENT_CREATE`` or ``PyFunction_EVENT_DESTROY`` " "then *new_value* will be ``NULL``. Otherwise, *new_value* will hold a :term:" @@ -206,13 +222,13 @@ msgid "" "for the attribute that is being modified." msgstr "" -#: ../../c-api/function.rst:167 +#: ../../c-api/function.rst:168 msgid "" "The callback may inspect but must not modify *func*; doing so could have " "unpredictable effects, including infinite recursion." msgstr "" -#: ../../c-api/function.rst:170 +#: ../../c-api/function.rst:171 msgid "" "If *event* is ``PyFunction_EVENT_CREATE``, then the callback is invoked " "after `func` has been fully initialized. Otherwise, the callback is invoked " @@ -224,7 +240,7 @@ msgid "" "semantics of the Python code being executed." msgstr "" -#: ../../c-api/function.rst:179 +#: ../../c-api/function.rst:180 msgid "" "If *event* is ``PyFunction_EVENT_DESTROY``, Taking a reference in the " "callback to the about-to-be-destroyed function will resurrect it, preventing " @@ -232,14 +248,14 @@ msgid "" "later, any watcher callbacks active at that time will be called again." msgstr "" -#: ../../c-api/function.rst:184 +#: ../../c-api/function.rst:185 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:188 +#: ../../c-api/function.rst:189 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 51c11e9884..e57228828e 100644 --- a/c-api/gcsupport.po +++ b/c-api/gcsupport.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-01 22:24+0800\n" +"POT-Creation-Date: 2025-04-24 05:56+0000\n" "PO-Revision-Date: 2018-05-23 14:31+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -369,7 +369,7 @@ msgstr "" 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 ``0`` to continue iteration, return " -"``1`` to stop iteration. Other return values are reserved for now so " +"``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/import.po b/c-api/import.po index 96b3529885..fd97d9146d 100644 --- a/c-api/import.po +++ b/c-api/import.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2024-10-13 17:13+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-" @@ -159,17 +159,17 @@ msgstr "" #: ../../c-api/import.rst:139 msgid "" -"The module's :attr:`__spec__` and :attr:`__loader__` will be set, if not set " -"already, with the appropriate values. The spec's loader will be set to the " -"module's ``__loader__`` (if set) and to an instance of :class:`~importlib." -"machinery.SourceFileLoader` otherwise." +"The module's :attr:`~module.__spec__` and :attr:`~module.__loader__` will be " +"set, if not set already, with the appropriate values. The spec's loader " +"will be set to the module's :attr:`!__loader__` (if set) and to an instance " +"of :class:`~importlib.machinery.SourceFileLoader` otherwise." msgstr "" #: ../../c-api/import.rst:144 msgid "" -"The module's :attr:`__file__` attribute will be set to the code object's :" -"attr:`~codeobject.co_filename`. If applicable, :attr:`__cached__` will also " -"be set." +"The module's :attr:`~module.__file__` attribute will be set to the code " +"object's :attr:`~codeobject.co_filename`. If applicable, :attr:`~module." +"__cached__` will also be set." msgstr "" #: ../../c-api/import.rst:148 @@ -192,14 +192,14 @@ msgstr "" #: ../../c-api/import.rst:157 msgid "" -"The setting of :attr:`__cached__` and :attr:`__loader__` is deprecated. See :" -"class:`~importlib.machinery.ModuleSpec` for alternatives." +"The setting of :attr:`~module.__cached__` and :attr:`~module.__loader__` is " +"deprecated. See :class:`~importlib.machinery.ModuleSpec` for alternatives." msgstr "" #: ../../c-api/import.rst:165 msgid "" -"Like :c:func:`PyImport_ExecCodeModule`, but the :attr:`__file__` attribute " -"of the module object is set to *pathname* if it is non-``NULL``." +"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-api/import.rst:168 @@ -208,15 +208,15 @@ msgstr "也請見 :c:func:`PyImport_ExecCodeModuleWithPathnames`。" #: ../../c-api/import.rst:173 msgid "" -"Like :c:func:`PyImport_ExecCodeModuleEx`, but the :attr:`__cached__` " +"Like :c:func:`PyImport_ExecCodeModuleEx`, but the :attr:`~module.__cached__` " "attribute of the module object is set to *cpathname* if it is non-``NULL``. " "Of the three functions, this is the preferred one to use." msgstr "" #: ../../c-api/import.rst:179 msgid "" -"Setting :attr:`__cached__` is deprecated. See :class:`~importlib.machinery." -"ModuleSpec` for alternatives." +"Setting :attr:`~module.__cached__` is deprecated. See :class:`~importlib." +"machinery.ModuleSpec` for alternatives." msgstr "" #: ../../c-api/import.rst:186 diff --git a/c-api/init.po b/c-api/init.po index 9ca9aecb98..320de68f9a 100644 --- a/c-api/init.po +++ b/c-api/init.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-02-16 08:33+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-" @@ -25,14 +25,17 @@ msgid "Initialization, Finalization, and Threads" msgstr "" #: ../../c-api/init.rst:10 -msgid "See also :ref:`Python Initialization Configuration `." +#, fuzzy +msgid "" +"See :ref:`Python Initialization Configuration ` for details on " +"how to configure the interpreter prior to initialization." msgstr "也請參見 :ref:`Python 初始化設定 `。" -#: ../../c-api/init.rst:15 +#: ../../c-api/init.rst:16 msgid "Before Python Initialization" msgstr "Python 初始化之前" -#: ../../c-api/init.rst:17 +#: ../../c-api/init.rst:18 msgid "" "In an application embedding Python, the :c:func:`Py_Initialize` function " "must be called before using any other Python/C API functions; with the " @@ -40,148 +43,191 @@ msgid "" "`." msgstr "" -#: ../../c-api/init.rst:22 +#: ../../c-api/init.rst:23 msgid "" "The following functions can be safely called before Python is initialized:" msgstr "" -#: ../../c-api/init.rst:24 +#: ../../c-api/init.rst:25 +msgid "Functions that initialize the interpreter:" +msgstr "" + +#: ../../c-api/init.rst:27 +#, fuzzy +msgid ":c:func:`Py_Initialize`" +msgstr ":c:func:`Py_IsInitialized`" + +#: ../../c-api/init.rst:28 +#, fuzzy +msgid ":c:func:`Py_InitializeEx`" +msgstr ":c:func:`Py_IsInitialized`" + +#: ../../c-api/init.rst:29 +#, fuzzy +msgid ":c:func:`Py_InitializeFromConfig`" +msgstr ":c:func:`Py_IsInitialized`" + +#: ../../c-api/init.rst:30 +#, fuzzy +msgid ":c:func:`Py_BytesMain`" +msgstr ":c:func:`Py_GetVersion`" + +#: ../../c-api/init.rst:31 +#, fuzzy +msgid ":c:func:`Py_Main`" +msgstr ":c:func:`Py_SetPath`" + +#: ../../c-api/init.rst:32 +msgid "the runtime pre-initialization functions covered in :ref:`init-config`" +msgstr "" + +#: ../../c-api/init.rst:34 msgid "Configuration functions:" msgstr "" -#: ../../c-api/init.rst:26 +#: ../../c-api/init.rst:36 msgid ":c:func:`PyImport_AppendInittab`" msgstr ":c:func:`PyImport_AppendInittab`" -#: ../../c-api/init.rst:27 +#: ../../c-api/init.rst:37 msgid ":c:func:`PyImport_ExtendInittab`" msgstr ":c:func:`PyImport_ExtendInittab`" -#: ../../c-api/init.rst:28 +#: ../../c-api/init.rst:38 msgid ":c:func:`!PyInitFrozenExtensions`" msgstr ":c:func:`!PyInitFrozenExtensions`" -#: ../../c-api/init.rst:29 +#: ../../c-api/init.rst:39 msgid ":c:func:`PyMem_SetAllocator`" msgstr ":c:func:`PyMem_SetAllocator`" -#: ../../c-api/init.rst:30 +#: ../../c-api/init.rst:40 msgid ":c:func:`PyMem_SetupDebugHooks`" msgstr ":c:func:`PyMem_SetupDebugHooks`" -#: ../../c-api/init.rst:31 +#: ../../c-api/init.rst:41 msgid ":c:func:`PyObject_SetArenaAllocator`" msgstr ":c:func:`PyObject_SetArenaAllocator`" -#: ../../c-api/init.rst:32 +#: ../../c-api/init.rst:42 msgid ":c:func:`Py_SetProgramName`" msgstr ":c:func:`Py_SetProgramName`" -#: ../../c-api/init.rst:33 +#: ../../c-api/init.rst:43 msgid ":c:func:`Py_SetPythonHome`" msgstr ":c:func:`Py_SetPythonHome`" -#: ../../c-api/init.rst:34 +#: ../../c-api/init.rst:44 msgid ":c:func:`PySys_ResetWarnOptions`" msgstr ":c:func:`PySys_ResetWarnOptions`" -#: ../../c-api/init.rst:36 +#: ../../c-api/init.rst:45 +msgid "the configuration functions covered in :ref:`init-config`" +msgstr "" + +#: ../../c-api/init.rst:47 msgid "Informative functions:" msgstr "" -#: ../../c-api/init.rst:38 +#: ../../c-api/init.rst:49 ../../c-api/init.rst:57 msgid ":c:func:`Py_IsInitialized`" msgstr ":c:func:`Py_IsInitialized`" -#: ../../c-api/init.rst:39 +#: ../../c-api/init.rst:50 msgid ":c:func:`PyMem_GetAllocator`" msgstr ":c:func:`PyMem_GetAllocator`" -#: ../../c-api/init.rst:40 +#: ../../c-api/init.rst:51 msgid ":c:func:`PyObject_GetArenaAllocator`" msgstr ":c:func:`PyObject_GetArenaAllocator`" -#: ../../c-api/init.rst:41 +#: ../../c-api/init.rst:52 msgid ":c:func:`Py_GetBuildInfo`" msgstr ":c:func:`Py_GetBuildInfo`" -#: ../../c-api/init.rst:42 +#: ../../c-api/init.rst:53 msgid ":c:func:`Py_GetCompiler`" msgstr ":c:func:`Py_GetCompiler`" -#: ../../c-api/init.rst:43 +#: ../../c-api/init.rst:54 msgid ":c:func:`Py_GetCopyright`" msgstr ":c:func:`Py_GetCopyright`" -#: ../../c-api/init.rst:44 +#: ../../c-api/init.rst:55 msgid ":c:func:`Py_GetPlatform`" msgstr ":c:func:`Py_GetPlatform`" -#: ../../c-api/init.rst:45 +#: ../../c-api/init.rst:56 msgid ":c:func:`Py_GetVersion`" msgstr ":c:func:`Py_GetVersion`" -#: ../../c-api/init.rst:47 +#: ../../c-api/init.rst:59 msgid "Utilities:" msgstr "" -#: ../../c-api/init.rst:49 +#: ../../c-api/init.rst:61 msgid ":c:func:`Py_DecodeLocale`" msgstr ":c:func:`Py_DecodeLocale`" -#: ../../c-api/init.rst:51 +#: ../../c-api/init.rst:62 +msgid "" +"the status reporting and utility functions covered in :ref:`init-config`" +msgstr "" + +#: ../../c-api/init.rst:64 msgid "Memory allocators:" msgstr "" -#: ../../c-api/init.rst:53 +#: ../../c-api/init.rst:66 msgid ":c:func:`PyMem_RawMalloc`" msgstr ":c:func:`PyMem_RawMalloc`" -#: ../../c-api/init.rst:54 +#: ../../c-api/init.rst:67 msgid ":c:func:`PyMem_RawRealloc`" msgstr ":c:func:`PyMem_RawRealloc`" -#: ../../c-api/init.rst:55 +#: ../../c-api/init.rst:68 msgid ":c:func:`PyMem_RawCalloc`" msgstr ":c:func:`PyMem_RawCalloc`" -#: ../../c-api/init.rst:56 +#: ../../c-api/init.rst:69 msgid ":c:func:`PyMem_RawFree`" msgstr ":c:func:`PyMem_RawFree`" -#: ../../c-api/init.rst:58 +#: ../../c-api/init.rst:71 msgid "Synchronization:" msgstr "" -#: ../../c-api/init.rst:60 +#: ../../c-api/init.rst:73 msgid ":c:func:`PyMutex_Lock`" msgstr ":c:func:`PyMutex_Lock`" -#: ../../c-api/init.rst:61 +#: ../../c-api/init.rst:74 msgid ":c:func:`PyMutex_Unlock`" msgstr ":c:func:`PyMutex_Unlock`" -#: ../../c-api/init.rst:65 +#: ../../c-api/init.rst:78 msgid "" -"The following functions **should not be called** before :c:func:" -"`Py_Initialize`: :c:func:`Py_EncodeLocale`, :c:func:`Py_GetPath`, :c:func:" +"Despite their apparent similarity to some of the functions listed above, the " +"following functions **should not be called** before the interpreter has been " +"initialized: :c:func:`Py_EncodeLocale`, :c:func:`Py_GetPath`, :c:func:" "`Py_GetPrefix`, :c:func:`Py_GetExecPrefix`, :c:func:" "`Py_GetProgramFullPath`, :c:func:`Py_GetPythonHome`, :c:func:" -"`Py_GetProgramName` and :c:func:`PyEval_InitThreads`." +"`Py_GetProgramName`, :c:func:`PyEval_InitThreads`, and :c:func:`Py_RunMain`." msgstr "" -#: ../../c-api/init.rst:75 +#: ../../c-api/init.rst:90 msgid "Global configuration variables" msgstr "" -#: ../../c-api/init.rst:77 +#: ../../c-api/init.rst:92 msgid "" "Python has variables for the global configuration to control different " "features and options. By default, these flags are controlled by :ref:" "`command line options `." msgstr "" -#: ../../c-api/init.rst:81 +#: ../../c-api/init.rst:96 msgid "" "When a flag is set by an option, the value of the flag is the number of " "times that the option was set. For example, ``-b`` sets :c:data:" @@ -189,108 +235,108 @@ msgid "" "2." msgstr "" -#: ../../c-api/init.rst:87 +#: ../../c-api/init.rst:102 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "bytes_warning` should be used instead, see :ref:`Python Initialization " "Configuration `." msgstr "" -#: ../../c-api/init.rst:91 +#: ../../c-api/init.rst:106 msgid "" "Issue a warning when comparing :class:`bytes` or :class:`bytearray` with :" "class:`str` or :class:`bytes` with :class:`int`. Issue an error if greater " "or equal to ``2``." msgstr "" -#: ../../c-api/init.rst:95 +#: ../../c-api/init.rst:110 msgid "Set by the :option:`-b` option." msgstr "由 :option:`-b` 選項設定。" -#: ../../c-api/init.rst:101 +#: ../../c-api/init.rst:116 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "parser_debug` should be used instead, see :ref:`Python Initialization " "Configuration `." msgstr "" -#: ../../c-api/init.rst:105 +#: ../../c-api/init.rst:120 msgid "" "Turn on parser debugging output (for expert only, depending on compilation " "options)." msgstr "" -#: ../../c-api/init.rst:108 +#: ../../c-api/init.rst:123 msgid "" "Set by the :option:`-d` option and the :envvar:`PYTHONDEBUG` environment " "variable." msgstr "由 :option:`-d` 選項與 :envvar:`PYTHONDEBUG` 環境變數設定。" -#: ../../c-api/init.rst:115 +#: ../../c-api/init.rst:130 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "write_bytecode` should be used instead, see :ref:`Python Initialization " "Configuration `." msgstr "" -#: ../../c-api/init.rst:119 +#: ../../c-api/init.rst:134 msgid "" "If set to non-zero, Python won't try to write ``.pyc`` files on the import " "of source modules." msgstr "" -#: ../../c-api/init.rst:122 +#: ../../c-api/init.rst:137 msgid "" "Set by the :option:`-B` option and the :envvar:`PYTHONDONTWRITEBYTECODE` " "environment variable." msgstr "" "由 :option:`-B` 選項與 :envvar:`PYTHONDONTWRITEBYTECODE` 環境變數設定。" -#: ../../c-api/init.rst:129 +#: ../../c-api/init.rst:144 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "pathconfig_warnings` should be used instead, see :ref:`Python Initialization " "Configuration `." msgstr "" -#: ../../c-api/init.rst:133 +#: ../../c-api/init.rst:148 msgid "" "Suppress error messages when calculating the module search path in :c:func:" "`Py_GetPath`." msgstr "" -#: ../../c-api/init.rst:136 +#: ../../c-api/init.rst:151 msgid "Private flag used by ``_freeze_module`` and ``frozenmain`` programs." msgstr "" -#: ../../c-api/init.rst:142 +#: ../../c-api/init.rst:157 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "hash_seed` and :c:member:`PyConfig.use_hash_seed` should be used instead, " "see :ref:`Python Initialization Configuration `." msgstr "" -#: ../../c-api/init.rst:147 +#: ../../c-api/init.rst:162 msgid "" "Set to ``1`` if the :envvar:`PYTHONHASHSEED` environment variable is set to " "a non-empty string." msgstr "" "如果環境變數 :envvar:`PYTHONHASHSEED` 被設定為一個非空字串則設為 ``1``。" -#: ../../c-api/init.rst:150 +#: ../../c-api/init.rst:165 msgid "" "If the flag is non-zero, read the :envvar:`PYTHONHASHSEED` environment " "variable to initialize the secret hash seed." msgstr "" -#: ../../c-api/init.rst:157 +#: ../../c-api/init.rst:172 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "use_environment` should be used instead, see :ref:`Python Initialization " "Configuration `." msgstr "" -#: ../../c-api/init.rst:161 +#: ../../c-api/init.rst:176 msgid "" "Ignore all :envvar:`!PYTHON*` environment variables, e.g. :envvar:" "`PYTHONPATH` and :envvar:`PYTHONHOME`, that might be set." @@ -298,73 +344,73 @@ msgstr "" "忽略所有可能被設定的 :envvar:`!PYTHON*` 環境變數,例如 :envvar:`PYTHONPATH` " "與 :envvar:`PYTHONHOME`。" -#: ../../c-api/init.rst:164 +#: ../../c-api/init.rst:179 msgid "Set by the :option:`-E` and :option:`-I` options." msgstr "由 :option:`-E` 與 :option:`-I` 選項設定。" -#: ../../c-api/init.rst:170 +#: ../../c-api/init.rst:185 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "inspect` should be used instead, see :ref:`Python Initialization " "Configuration `." msgstr "" -#: ../../c-api/init.rst:174 +#: ../../c-api/init.rst:189 msgid "" "When a script is passed as first argument or the :option:`-c` option is " "used, enter interactive mode after executing the script or the command, even " "when :data:`sys.stdin` does not appear to be a terminal." msgstr "" -#: ../../c-api/init.rst:178 +#: ../../c-api/init.rst:193 msgid "" "Set by the :option:`-i` option and the :envvar:`PYTHONINSPECT` environment " "variable." msgstr "由 :option:`-i` 選項與 :envvar:`PYTHONINSPECT` 環境變數設定。" -#: ../../c-api/init.rst:185 +#: ../../c-api/init.rst:200 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "interactive` should be used instead, see :ref:`Python Initialization " "Configuration `." msgstr "" -#: ../../c-api/init.rst:189 +#: ../../c-api/init.rst:204 msgid "Set by the :option:`-i` option." msgstr "由 :option:`-i` 選項設定。" -#: ../../c-api/init.rst:195 +#: ../../c-api/init.rst:210 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "isolated` should be used instead, see :ref:`Python Initialization " "Configuration `." msgstr "" -#: ../../c-api/init.rst:199 +#: ../../c-api/init.rst:214 msgid "" "Run Python in isolated mode. In isolated mode :data:`sys.path` contains " "neither the script's directory nor the user's site-packages directory." msgstr "" -#: ../../c-api/init.rst:202 +#: ../../c-api/init.rst:217 msgid "Set by the :option:`-I` option." msgstr "由 :option:`-i` 選項設定。" -#: ../../c-api/init.rst:210 +#: ../../c-api/init.rst:225 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyPreConfig." "legacy_windows_fs_encoding` should be used instead, see :ref:`Python " "Initialization Configuration `." msgstr "" -#: ../../c-api/init.rst:214 +#: ../../c-api/init.rst:229 msgid "" "If the flag is non-zero, use the ``mbcs`` encoding with ``replace`` error " "handler, instead of the UTF-8 encoding with ``surrogatepass`` error handler, " "for the :term:`filesystem encoding and error handler`." msgstr "" -#: ../../c-api/init.rst:218 +#: ../../c-api/init.rst:233 msgid "" "Set to ``1`` if the :envvar:`PYTHONLEGACYWINDOWSFSENCODING` environment " "variable is set to a non-empty string." @@ -372,45 +418,45 @@ msgstr "" "如果環境變數 :envvar:`PYTHONLEGACYWINDOWSFSENCODING` 被設定為一個非空字串則設" "為 ``1``。" -#: ../../c-api/init.rst:221 +#: ../../c-api/init.rst:236 msgid "See :pep:`529` for more details." msgstr "更多詳情請見 :pep:`529`。" -#: ../../c-api/init.rst:223 ../../c-api/init.rst:241 -msgid ":ref:`Availability `: Windows." -msgstr ":ref:`適用 `:Windows。" +#: ../../c-api/init.rst:238 ../../c-api/init.rst:256 +msgid "Availability" +msgstr "" -#: ../../c-api/init.rst:229 +#: ../../c-api/init.rst:244 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "legacy_windows_stdio` should be used instead, see :ref:`Python " "Initialization Configuration `." msgstr "" -#: ../../c-api/init.rst:233 +#: ../../c-api/init.rst:248 msgid "" "If the flag is non-zero, use :class:`io.FileIO` instead of :class:`!io." "_WindowsConsoleIO` for :mod:`sys` standard streams." msgstr "" -#: ../../c-api/init.rst:236 +#: ../../c-api/init.rst:251 msgid "" "Set to ``1`` if the :envvar:`PYTHONLEGACYWINDOWSSTDIO` environment variable " "is set to a non-empty string." msgstr "" -#: ../../c-api/init.rst:239 +#: ../../c-api/init.rst:254 msgid "See :pep:`528` for more details." msgstr "更多詳情請見 :pep:`528`。" -#: ../../c-api/init.rst:247 +#: ../../c-api/init.rst:262 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "site_import` should be used instead, see :ref:`Python Initialization " "Configuration `." msgstr "" -#: ../../c-api/init.rst:251 +#: ../../c-api/init.rst:266 msgid "" "Disable the import of the module :mod:`site` and the site-dependent " "manipulations of :data:`sys.path` that it entails. Also disable these " @@ -418,24 +464,24 @@ msgid "" "main` if you want them to be triggered)." msgstr "" -#: ../../c-api/init.rst:256 +#: ../../c-api/init.rst:271 msgid "Set by the :option:`-S` option." msgstr "由 :option:`-S` 選項設定。" -#: ../../c-api/init.rst:262 +#: ../../c-api/init.rst:277 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "user_site_directory` should be used instead, see :ref:`Python Initialization " "Configuration `." msgstr "" -#: ../../c-api/init.rst:266 +#: ../../c-api/init.rst:281 msgid "" "Don't add the :data:`user site-packages directory ` to :data:" "`sys.path`." msgstr "" -#: ../../c-api/init.rst:269 +#: ../../c-api/init.rst:284 msgid "" "Set by the :option:`-s` and :option:`-I` options, and the :envvar:" "`PYTHONNOUSERSITE` environment variable." @@ -443,60 +489,60 @@ msgstr "" "由 :option:`-s` 選項、:option:`-I` 選項與 :envvar:`PYTHONNOUSERSITE` 環境變數" "設定。" -#: ../../c-api/init.rst:276 +#: ../../c-api/init.rst:291 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "optimization_level` should be used instead, see :ref:`Python Initialization " "Configuration `." msgstr "" -#: ../../c-api/init.rst:280 +#: ../../c-api/init.rst:295 msgid "" "Set by the :option:`-O` option and the :envvar:`PYTHONOPTIMIZE` environment " "variable." msgstr "由 :option:`-O` 選項與 :envvar:`PYTHONOPTIMIZE` 環境變數設定。" -#: ../../c-api/init.rst:287 +#: ../../c-api/init.rst:302 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "quiet` should be used instead, see :ref:`Python Initialization Configuration " "`." msgstr "" -#: ../../c-api/init.rst:291 +#: ../../c-api/init.rst:306 msgid "" "Don't display the copyright and version messages even in interactive mode." msgstr "" -#: ../../c-api/init.rst:293 +#: ../../c-api/init.rst:308 msgid "Set by the :option:`-q` option." msgstr "由 :option:`-q` 選項設定。" -#: ../../c-api/init.rst:301 +#: ../../c-api/init.rst:316 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "buffered_stdio` should be used instead, see :ref:`Python Initialization " "Configuration `." msgstr "" -#: ../../c-api/init.rst:305 +#: ../../c-api/init.rst:320 msgid "Force the stdout and stderr streams to be unbuffered." msgstr "" -#: ../../c-api/init.rst:307 +#: ../../c-api/init.rst:322 msgid "" "Set by the :option:`-u` option and the :envvar:`PYTHONUNBUFFERED` " "environment variable." msgstr "由 :option:`-u` 選項與 :envvar:`PYTHONUNBUFFERED` 環境變數設定。" -#: ../../c-api/init.rst:314 +#: ../../c-api/init.rst:329 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "verbose` should be used instead, see :ref:`Python Initialization " "Configuration `." msgstr "" -#: ../../c-api/init.rst:318 +#: ../../c-api/init.rst:333 msgid "" "Print a message each time a module is initialized, showing the place " "(filename or built-in module) from which it is loaded. If greater or equal " @@ -504,67 +550,82 @@ msgid "" "for a module. Also provides information on module cleanup at exit." msgstr "" -#: ../../c-api/init.rst:323 +#: ../../c-api/init.rst:338 msgid "" "Set by the :option:`-v` option and the :envvar:`PYTHONVERBOSE` environment " "variable." msgstr "由 :option:`-v` 選項與 :envvar:`PYTHONVERBOSE` 環境變數設定。" -#: ../../c-api/init.rst:330 +#: ../../c-api/init.rst:345 msgid "Initializing and finalizing the interpreter" msgstr "" -#: ../../c-api/init.rst:345 +#: ../../c-api/init.rst:360 msgid "" "Initialize the Python interpreter. In an application embedding Python, " "this should be called before using any other Python/C API functions; see :" "ref:`Before Python Initialization ` for the few exceptions." msgstr "" -#: ../../c-api/init.rst:349 +#: ../../c-api/init.rst:364 msgid "" "This initializes the table of loaded modules (``sys.modules``), and creates " -"the fundamental modules :mod:`builtins`, :mod:`__main__` and :mod:`sys`. It " +"the fundamental modules :mod:`builtins`, :mod:`__main__` and :mod:`sys`. It " "also initializes the module search path (``sys.path``). It does not set " -"``sys.argv``; use the new :c:type:`PyConfig` API of the :ref:`Python " -"Initialization Configuration ` for that. This is a no-op when " -"called for a second time (without calling :c:func:`Py_FinalizeEx` first). " -"There is no return value; it is a fatal error if the initialization fails." +"``sys.argv``; use the :ref:`Python Initialization Configuration ` API for that. This is a no-op when called for a second time " +"(without calling :c:func:`Py_FinalizeEx` first). There is no return value; " +"it is a fatal error if the initialization fails." msgstr "" -#: ../../c-api/init.rst:359 ../../c-api/init.rst:373 +#: ../../c-api/init.rst:372 ../../c-api/init.rst:386 +#, fuzzy msgid "" -"Use the :c:func:`Py_InitializeFromConfig` function to customize the :ref:" -"`Python Initialization Configuration `." -msgstr "" +"Use :c:func:`Py_InitializeFromConfig` to customize the :ref:`Python " +"Initialization Configuration `." +msgstr "也請參見 :ref:`Python 初始化設定 `。" -#: ../../c-api/init.rst:363 +#: ../../c-api/init.rst:376 msgid "" "On Windows, changes the console mode from ``O_TEXT`` to ``O_BINARY``, which " "will also affect non-Python uses of the console using the C Runtime." msgstr "" -#: ../../c-api/init.rst:369 +#: ../../c-api/init.rst:382 msgid "" "This function works like :c:func:`Py_Initialize` if *initsigs* is ``1``. If " "*initsigs* is ``0``, it skips initialization registration of signal " -"handlers, which might be useful when Python is embedded." +"handlers, which may be useful when CPython is embedded as part of a larger " +"application." +msgstr "" + +#: ../../c-api/init.rst:392 +msgid "" +"Initialize Python from *config* configuration, as described in :ref:`init-" +"from-config`." msgstr "" -#: ../../c-api/init.rst:379 +#: ../../c-api/init.rst:395 +msgid "" +"See the :ref:`init-config` section for details on pre-initializing the " +"interpreter, populating the runtime configuration structure, and querying " +"the returned status structure." +msgstr "" + +#: ../../c-api/init.rst:402 msgid "" "Return true (nonzero) when the Python interpreter has been initialized, " "false (zero) if not. After :c:func:`Py_FinalizeEx` is called, this returns " "false until :c:func:`Py_Initialize` is called again." msgstr "" -#: ../../c-api/init.rst:386 +#: ../../c-api/init.rst:409 msgid "" "Return true (non-zero) if the main Python interpreter is :term:`shutting " "down `. Return false (zero) otherwise." msgstr "" -#: ../../c-api/init.rst:394 +#: ../../c-api/init.rst:417 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:" @@ -574,7 +635,7 @@ msgid "" "second time (without calling :c:func:`Py_Initialize` again first)." msgstr "" -#: ../../c-api/init.rst:401 +#: ../../c-api/init.rst:424 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 " @@ -582,13 +643,13 @@ msgid "" "`Py_RunMain` is running." msgstr "" -#: ../../c-api/init.rst:406 +#: ../../c-api/init.rst:429 msgid "" "Normally the return value is ``0``. If there were errors during finalization " "(flushing buffered data), ``-1`` is returned." msgstr "" -#: ../../c-api/init.rst:410 +#: ../../c-api/init.rst:433 msgid "" "This function is provided for a number of reasons. An embedding application " "might want to restart Python without having to restart the application " @@ -599,7 +660,7 @@ msgid "" "Python before exiting from the application." msgstr "" -#: ../../c-api/init.rst:418 +#: ../../c-api/init.rst:441 msgid "" "**Bugs and caveats:** The destruction of modules and objects in modules is " "done in random order; this may cause destructors (:meth:`~object.__del__` " @@ -614,7 +675,7 @@ msgid "" "more than once." msgstr "" -#: ../../c-api/init.rst:429 +#: ../../c-api/init.rst:452 msgid "" "Raises an :ref:`auditing event ` ``cpython." "_PySys_ClearAuditHooks`` with no arguments." @@ -622,24 +683,165 @@ msgstr "" "引發一個不附帶引數的\\ :ref:`稽核事件 ` ``cpython." "_PySys_ClearAuditHooks``。" -#: ../../c-api/init.rst:435 +#: ../../c-api/init.rst:459 msgid "" "This is a backwards-compatible version of :c:func:`Py_FinalizeEx` that " "disregards the return value." msgstr "" -#: ../../c-api/init.rst:440 +#: ../../c-api/init.rst:465 +msgid "" +"Similar to :c:func:`Py_Main` but *argv* is an array of bytes strings, " +"allowing the calling application to delegate the text decoding step to the " +"CPython runtime." +msgstr "" + +#: ../../c-api/init.rst:474 +msgid "" +"The main program for the standard interpreter, encapsulating a full " +"initialization/finalization cycle, as well as additional behaviour to " +"implement reading configurations settings from the environment and command " +"line, and then executing ``__main__`` in accordance with :ref:`using-on-" +"cmdline`." +msgstr "" + +#: ../../c-api/init.rst:480 +msgid "" +"This is made available for programs which wish to support the full CPython " +"command line interface, rather than just embedding a Python runtime in a " +"larger application." +msgstr "" + +#: ../../c-api/init.rst:484 +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 " +"first converted to ``wchar_t`` using :c:func:`Py_DecodeLocale`. It is also " +"important to note that the argument list entries may be modified to point to " +"strings other than those passed in (however, the contents of the strings " +"pointed to by the argument list are not modified)." +msgstr "" + +#: ../../c-api/init.rst:491 +msgid "" +"The return value will be ``0`` if the interpreter exits normally (i.e., " +"without an exception), ``1`` if the interpreter exits due to an exception, " +"or ``2`` if the argument list does not represent a valid Python command line." +msgstr "" + +#: ../../c-api/init.rst:496 +msgid "" +"Note that if an otherwise unhandled :exc:`SystemExit` is raised, this " +"function will not return ``1``, but exit the process, as long as " +"``Py_InspectFlag`` is not set. If ``Py_InspectFlag`` is set, execution will " +"drop into the interactive Python prompt, at which point a second otherwise " +"unhandled :exc:`SystemExit` will still exit the process, while any other " +"means of exiting will set the return value as described above." +msgstr "" + +#: ../../c-api/init.rst:503 +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:507 +msgid "" +"PyConfig config;\n" +"PyConfig_InitPythonConfig(&config);\n" +"PyConfig_SetArgv(&config, argc, argv);\n" +"Py_InitializeFromConfig(&config);\n" +"PyConfig_Clear(&config);\n" +"\n" +"Py_RunMain();" +msgstr "" + +#: ../../c-api/init.rst:515 +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:" +"`Py_InitializeFromConfig` directly, and all settings will be applied as " +"described elsewhere in this documentation. If this function is instead " +"called *after* a preceding runtime initialization API call, then exactly " +"which environmental and command line configuration settings will be updated " +"is version dependent (as it depends on which settings correctly support " +"being modified after they have already been set once when the runtime was " +"first initialized)." +msgstr "" + +#: ../../c-api/init.rst:528 +msgid "Executes the main module in a fully configured CPython runtime." +msgstr "" + +#: ../../c-api/init.rst:530 +msgid "" +"Executes the command (:c:member:`PyConfig.run_command`), the script (:c:" +"member:`PyConfig.run_filename`) or the module (:c:member:`PyConfig." +"run_module`) specified on the command line or in the configuration. If none " +"of these values are set, runs the interactive Python prompt (REPL) using the " +"``__main__`` module's global namespace." +msgstr "" + +#: ../../c-api/init.rst:536 +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 " +"exception), or ``1`` if the interpreter exits due to an exception. If an " +"otherwise unhandled :exc:`SystemExit` is raised, the function will " +"immediately exit the process instead of returning ``1``." +msgstr "" + +#: ../../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 " +"instead resume in an interactive Python prompt (REPL) using the ``__main__`` " +"module's global namespace. If the interpreter exited with an exception, it " +"is immediately raised in the REPL session. The function return value is then " +"determined by the way the *REPL session* terminates: returning ``0`` if the " +"session terminates without raising an unhandled exception, exiting " +"immediately for an unhandled :exc:`SystemExit`, and returning ``1`` for any " +"other unhandled exception." +msgstr "" + +#: ../../c-api/init.rst:552 +msgid "" +"This function always finalizes the Python interpreter regardless of whether " +"it returns a value or immediately exits the process due to an unhandled :exc:" +"`SystemExit` exception." +msgstr "" + +#: ../../c-api/init.rst:556 +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:562 +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:566 +msgid "The :term:`GIL` must be held for *interp*." +msgstr "" + +#: ../../c-api/init.rst:571 msgid "Process-wide parameters" msgstr "" -#: ../../c-api/init.rst:450 +#: ../../c-api/init.rst:581 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:454 +#: ../../c-api/init.rst:585 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 " @@ -653,37 +855,37 @@ msgid "" "this storage." msgstr "" -#: ../../c-api/init.rst:465 ../../c-api/init.rst:704 ../../c-api/init.rst:740 -#: ../../c-api/init.rst:766 +#: ../../c-api/init.rst:596 ../../c-api/init.rst:838 ../../c-api/init.rst:874 +#: ../../c-api/init.rst:900 msgid "" "Use :c:func:`Py_DecodeLocale` to decode a bytes string to get a :c:expr:" -"`wchar_*` string." +"`wchar_t*` string." msgstr "" -#: ../../c-api/init.rst:473 +#: ../../c-api/init.rst:604 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:477 ../../c-api/init.rst:499 ../../c-api/init.rst:543 -#: ../../c-api/init.rst:564 ../../c-api/init.rst:590 ../../c-api/init.rst:778 +#: ../../c-api/init.rst:608 ../../c-api/init.rst:630 ../../c-api/init.rst:676 +#: ../../c-api/init.rst:698 ../../c-api/init.rst:724 ../../c-api/init.rst:912 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:480 ../../c-api/init.rst:502 ../../c-api/init.rst:546 -#: ../../c-api/init.rst:567 ../../c-api/init.rst:595 ../../c-api/init.rst:781 +#: ../../c-api/init.rst:611 ../../c-api/init.rst:633 ../../c-api/init.rst:679 +#: ../../c-api/init.rst:701 ../../c-api/init.rst:729 ../../c-api/init.rst:915 msgid "It now returns ``NULL`` if called before :c:func:`Py_Initialize`." msgstr "如果在 :c:func:`Py_Initialize` 之前呼叫,現在會回傳 ``NULL``。" -#: ../../c-api/init.rst:483 ../../c-api/init.rst:570 +#: ../../c-api/init.rst:614 ../../c-api/init.rst:704 msgid "Get :data:`sys.executable` instead." msgstr "" -#: ../../c-api/init.rst:489 +#: ../../c-api/init.rst:620 msgid "" "Return the *prefix* for installed platform-independent files. This is " "derived through a number of complicated rules from the program name set " @@ -693,15 +895,17 @@ msgid "" "should not modify its value. This corresponds to the :makevar:`prefix` " "variable in the top-level :file:`Makefile` and the :option:`--prefix` " "argument to the :program:`configure` script at build time. The value is " -"available to Python code as ``sys.prefix``. It is only useful on Unix. See " -"also the next function." +"available to Python code as ``sys.base_prefix``. It is only useful on Unix. " +"See also the next function." msgstr "" -#: ../../c-api/init.rst:505 -msgid "Get :data:`sys.prefix` instead." +#: ../../c-api/init.rst:636 +msgid "" +"Get :data:`sys.base_prefix` instead, or :data:`sys.prefix` if :ref:`virtual " +"environments ` need to be handled." msgstr "" -#: ../../c-api/init.rst:511 +#: ../../c-api/init.rst:643 msgid "" "Return the *exec-prefix* for installed platform-*dependent* files. This is " "derived through a number of complicated rules from the program name set " @@ -711,11 +915,11 @@ msgid "" "caller should not modify its value. This corresponds to the :makevar:" "`exec_prefix` variable in the top-level :file:`Makefile` and the ``--exec-" "prefix`` argument to the :program:`configure` script at build time. The " -"value is available to Python code as ``sys.exec_prefix``. It is only useful " -"on Unix." +"value is available to Python code as ``sys.base_exec_prefix``. It is only " +"useful on Unix." msgstr "" -#: ../../c-api/init.rst:521 +#: ../../c-api/init.rst:654 msgid "" "Background: The exec-prefix differs from the prefix when platform dependent " "files (such as executables and shared libraries) are installed in a " @@ -724,7 +928,7 @@ msgid "" "independent may be installed in :file:`/usr/local`." msgstr "" -#: ../../c-api/init.rst:527 +#: ../../c-api/init.rst:660 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 " @@ -738,7 +942,7 @@ msgid "" "independent from the Python version by which they were compiled!)." msgstr "" -#: ../../c-api/init.rst:538 +#: ../../c-api/init.rst:671 msgid "" "System administrators will know how to configure the :program:`mount` or :" "program:`automount` programs to share :file:`/usr/local` between platforms " @@ -746,11 +950,13 @@ msgid "" "platform." msgstr "" -#: ../../c-api/init.rst:549 -msgid "Get :data:`sys.exec_prefix` instead." +#: ../../c-api/init.rst:682 +msgid "" +"Get :data:`sys.base_exec_prefix` instead, or :data:`sys.exec_prefix` if :ref:" +"`virtual environments ` need to be handled." msgstr "" -#: ../../c-api/init.rst:558 +#: ../../c-api/init.rst:692 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 " @@ -759,7 +965,7 @@ msgid "" "available to Python code as ``sys.executable``." msgstr "" -#: ../../c-api/init.rst:580 +#: ../../c-api/init.rst:714 msgid "" "Return the default module search path; this is computed from the program " "name (set by :c:member:`PyConfig.program_name`) and some environment " @@ -772,21 +978,21 @@ msgid "" "for loading modules." msgstr "" -#: ../../c-api/init.rst:598 +#: ../../c-api/init.rst:732 msgid "Get :data:`sys.path` instead." msgstr "" -#: ../../c-api/init.rst:604 +#: ../../c-api/init.rst:738 msgid "" "Return the version of this Python interpreter. This is a string that looks " "something like ::" msgstr "" -#: ../../c-api/init.rst:607 +#: ../../c-api/init.rst:741 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:611 +#: ../../c-api/init.rst:745 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 " @@ -795,11 +1001,11 @@ msgid "" "version`." msgstr "" -#: ../../c-api/init.rst:616 +#: ../../c-api/init.rst:750 msgid "See also the :c:var:`Py_Version` constant." msgstr "" -#: ../../c-api/init.rst:623 +#: ../../c-api/init.rst:757 msgid "" "Return the platform identifier for the current platform. On Unix, this is " "formed from the \"official\" name of the operating system, converted to " @@ -810,50 +1016,50 @@ msgid "" "available to Python code as ``sys.platform``." msgstr "" -#: ../../c-api/init.rst:634 +#: ../../c-api/init.rst:768 msgid "" "Return the official copyright string for the current Python version, for " "example" msgstr "" -#: ../../c-api/init.rst:636 +#: ../../c-api/init.rst:770 msgid "``'Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam'``" msgstr "``'Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam'``" -#: ../../c-api/init.rst:640 +#: ../../c-api/init.rst:774 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:646 +#: ../../c-api/init.rst:780 msgid "" "Return an indication of the compiler used to build the current Python " "version, in square brackets, for example::" msgstr "" -#: ../../c-api/init.rst:649 +#: ../../c-api/init.rst:783 msgid "\"[GCC 2.7.2.2]\"" msgstr "\"[GCC 2.7.2.2]\"" -#: ../../c-api/init.rst:653 ../../c-api/init.rst:667 +#: ../../c-api/init.rst:787 ../../c-api/init.rst:801 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:660 +#: ../../c-api/init.rst:794 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:663 +#: ../../c-api/init.rst:797 msgid "\"#67, Aug 1 1997, 22:34:28\"" msgstr "\"#67, Aug 1 1997, 22:34:28\"" -#: ../../c-api/init.rst:679 +#: ../../c-api/init.rst:813 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "argv`, :c:member:`PyConfig.parse_argv` and :c:member:`PyConfig.safe_path` " @@ -861,7 +1067,7 @@ msgid "" "config>`." msgstr "" -#: ../../c-api/init.rst:684 +#: ../../c-api/init.rst:818 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 " @@ -872,84 +1078,84 @@ msgid "" "fatal condition is signalled using :c:func:`Py_FatalError`." msgstr "" -#: ../../c-api/init.rst:692 +#: ../../c-api/init.rst:826 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:696 +#: ../../c-api/init.rst:830 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:699 +#: ../../c-api/init.rst:833 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:707 ../../c-api/init.rst:743 +#: ../../c-api/init.rst:841 ../../c-api/init.rst:877 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:711 +#: ../../c-api/init.rst:845 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:716 +#: ../../c-api/init.rst:850 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:720 +#: ../../c-api/init.rst:854 msgid "PyRun_SimpleString(\"import sys; sys.path.pop(0)\\n\");" msgstr "PyRun_SimpleString(\"import sys; sys.path.pop(0)\\n\");" -#: ../../c-api/init.rst:732 +#: ../../c-api/init.rst:866 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:736 +#: ../../c-api/init.rst:870 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:746 +#: ../../c-api/init.rst:880 msgid "The *updatepath* value depends on :option:`-I`." msgstr "" -#: ../../c-api/init.rst:753 +#: ../../c-api/init.rst:887 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:757 +#: ../../c-api/init.rst:891 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:761 +#: ../../c-api/init.rst:895 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 " @@ -957,24 +1163,24 @@ msgid "" "this storage." msgstr "" -#: ../../c-api/init.rst:774 +#: ../../c-api/init.rst:908 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:784 +#: ../../c-api/init.rst:918 msgid "" "Get :c:member:`PyConfig.home` or :envvar:`PYTHONHOME` environment variable " "instead." msgstr "改為取得 :c:member:`PyConfig.home` 或 :envvar:`PYTHONHOME` 環境變數。" -#: ../../c-api/init.rst:792 +#: ../../c-api/init.rst:926 msgid "Thread State and the Global Interpreter Lock" msgstr "" -#: ../../c-api/init.rst:799 +#: ../../c-api/init.rst:933 msgid "" "The Python interpreter is not fully thread-safe. In order to support multi-" "threaded Python programs, there's a global lock, called the :term:`global " @@ -986,7 +1192,7 @@ msgid "" "once instead of twice." msgstr "" -#: ../../c-api/init.rst:809 +#: ../../c-api/init.rst:943 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 " @@ -996,7 +1202,7 @@ msgid "" "a file, so that other Python threads can run in the meantime." msgstr "" -#: ../../c-api/init.rst:819 +#: ../../c-api/init.rst:953 msgid "" "The Python interpreter keeps some thread-specific bookkeeping information " "inside a data structure called :c:type:`PyThreadState`. There's also one " @@ -1004,17 +1210,17 @@ msgid "" "retrieved using :c:func:`PyThreadState_Get`." msgstr "" -#: ../../c-api/init.rst:825 +#: ../../c-api/init.rst:959 msgid "Releasing the GIL from extension code" msgstr "" -#: ../../c-api/init.rst:827 +#: ../../c-api/init.rst:961 msgid "" "Most extension code manipulating the :term:`GIL` has the following simple " "structure::" msgstr "" -#: ../../c-api/init.rst:830 +#: ../../c-api/init.rst:964 msgid "" "Save the thread state in a local variable.\n" "Release the global interpreter lock.\n" @@ -1023,29 +1229,29 @@ msgid "" "Restore the thread state from the local variable." msgstr "" -#: ../../c-api/init.rst:836 +#: ../../c-api/init.rst:970 msgid "This is so common that a pair of macros exists to simplify it::" msgstr "" -#: ../../c-api/init.rst:838 +#: ../../c-api/init.rst:972 msgid "" "Py_BEGIN_ALLOW_THREADS\n" "... Do some blocking I/O operation ...\n" "Py_END_ALLOW_THREADS" msgstr "" -#: ../../c-api/init.rst:846 +#: ../../c-api/init.rst:980 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:850 +#: ../../c-api/init.rst:984 msgid "The block above expands to the following code::" msgstr "" -#: ../../c-api/init.rst:852 +#: ../../c-api/init.rst:986 msgid "" "PyThreadState *_save;\n" "\n" @@ -1054,7 +1260,7 @@ msgid "" "PyEval_RestoreThread(_save);" msgstr "" -#: ../../c-api/init.rst:862 +#: ../../c-api/init.rst:996 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 " @@ -1065,7 +1271,7 @@ msgid "" "state, the lock must be acquired before storing the thread state pointer." msgstr "" -#: ../../c-api/init.rst:871 +#: ../../c-api/init.rst:1005 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 " @@ -1075,11 +1281,11 @@ msgid "" "compressing or hashing data." msgstr "" -#: ../../c-api/init.rst:882 +#: ../../c-api/init.rst:1016 msgid "Non-Python created threads" msgstr "" -#: ../../c-api/init.rst:884 +#: ../../c-api/init.rst:1018 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 " @@ -1089,7 +1295,7 @@ msgid "" "for them." msgstr "" -#: ../../c-api/init.rst:891 +#: ../../c-api/init.rst:1025 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 " @@ -1100,14 +1306,14 @@ msgid "" "finally free the thread state data structure." msgstr "" -#: ../../c-api/init.rst:899 +#: ../../c-api/init.rst:1033 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:903 +#: ../../c-api/init.rst:1037 msgid "" "PyGILState_STATE gstate;\n" "gstate = PyGILState_Ensure();\n" @@ -1120,7 +1326,7 @@ msgid "" "PyGILState_Release(gstate);" msgstr "" -#: ../../c-api/init.rst:913 +#: ../../c-api/init.rst:1047 msgid "" "Note that the ``PyGILState_*`` functions assume there is only one global " "interpreter (created automatically by :c:func:`Py_Initialize`). Python " @@ -1129,11 +1335,11 @@ msgid "" "``PyGILState_*`` API is unsupported." msgstr "" -#: ../../c-api/init.rst:923 +#: ../../c-api/init.rst:1057 msgid "Cautions about fork()" msgstr "" -#: ../../c-api/init.rst:925 +#: ../../c-api/init.rst:1059 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 " @@ -1142,7 +1348,7 @@ msgid "" "CPython's runtime." msgstr "" -#: ../../c-api/init.rst:931 +#: ../../c-api/init.rst:1065 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` " @@ -1159,7 +1365,7 @@ msgid "" "locks, but is not always able to." msgstr "" -#: ../../c-api/init.rst:946 +#: ../../c-api/init.rst:1080 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 " @@ -1172,17 +1378,17 @@ msgid "" "called immediately after." msgstr "" -#: ../../c-api/init.rst:959 +#: ../../c-api/init.rst:1093 msgid "High-level API" msgstr "高階 API" -#: ../../c-api/init.rst:961 +#: ../../c-api/init.rst:1095 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:966 +#: ../../c-api/init.rst:1100 msgid "" "This data structure represents the state shared by a number of cooperating " "threads. Threads belonging to the same interpreter share their module " @@ -1190,7 +1396,7 @@ msgid "" "in this structure." msgstr "" -#: ../../c-api/init.rst:971 +#: ../../c-api/init.rst:1105 msgid "" "Threads belonging to different interpreters initially share nothing, except " "process state like available memory, open file descriptors and such. The " @@ -1198,41 +1404,41 @@ msgid "" "which interpreter they belong." msgstr "" -#: ../../c-api/init.rst:979 +#: ../../c-api/init.rst:1113 msgid "" "This data structure represents the state of a single thread. The only " "public data member is:" msgstr "" -#: ../../c-api/init.rst:984 +#: ../../c-api/init.rst:1118 msgid "This thread's interpreter state." msgstr "" -#: ../../c-api/init.rst:995 +#: ../../c-api/init.rst:1129 msgid "Deprecated function which does nothing." msgstr "" -#: ../../c-api/init.rst:997 +#: ../../c-api/init.rst:1131 msgid "" "In Python 3.6 and older, this function created the GIL if it didn't exist." msgstr "" -#: ../../c-api/init.rst:999 +#: ../../c-api/init.rst:1133 msgid "The function now does nothing." msgstr "此函式現在不會做任何事情。" -#: ../../c-api/init.rst:1002 +#: ../../c-api/init.rst:1136 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:1006 +#: ../../c-api/init.rst:1140 msgid "" "This function cannot be called before :c:func:`Py_Initialize()` anymore." msgstr "" -#: ../../c-api/init.rst:1016 +#: ../../c-api/init.rst:1150 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 " @@ -1240,7 +1446,7 @@ msgid "" "acquired it." msgstr "" -#: ../../c-api/init.rst:1024 +#: ../../c-api/init.rst:1158 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 " @@ -1248,8 +1454,8 @@ msgid "" "ensues." msgstr "" -#: ../../c-api/init.rst:1030 ../../c-api/init.rst:1089 -#: ../../c-api/init.rst:1371 +#: ../../c-api/init.rst:1164 ../../c-api/init.rst:1223 +#: ../../c-api/init.rst:1519 msgid "" "Calling this function from a thread when the runtime is finalizing will " "terminate the thread, even if the thread was not created by Python. You can " @@ -1258,44 +1464,44 @@ msgid "" "avoid unwanted termination." msgstr "" -#: ../../c-api/init.rst:1038 +#: ../../c-api/init.rst:1172 msgid "" "Return the current thread state. The global interpreter lock must be held. " "When the current thread state is ``NULL``, this issues a fatal error (so " "that the caller needn't check for ``NULL``)." msgstr "" -#: ../../c-api/init.rst:1042 +#: ../../c-api/init.rst:1176 msgid "See also :c:func:`PyThreadState_GetUnchecked`." msgstr "也請見 :c:func:`PyThreadState_GetUnchecked`。" -#: ../../c-api/init.rst:1047 +#: ../../c-api/init.rst:1181 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:1051 +#: ../../c-api/init.rst:1185 msgid "" "In Python 3.5 to 3.12, the function was private and known as " "``_PyThreadState_UncheckedGet()``." msgstr "" -#: ../../c-api/init.rst:1058 +#: ../../c-api/init.rst:1192 msgid "" "Swap the current thread state with the thread state given by the argument " "*tstate*, which may be ``NULL``. The global interpreter lock must be held " "and is not released." msgstr "" -#: ../../c-api/init.rst:1063 +#: ../../c-api/init.rst:1197 msgid "" "The following functions use thread-local storage, and are not compatible " "with sub-interpreters:" msgstr "" -#: ../../c-api/init.rst:1068 +#: ../../c-api/init.rst:1202 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 " @@ -1308,7 +1514,7 @@ msgid "" "is acceptable." msgstr "" -#: ../../c-api/init.rst:1078 +#: ../../c-api/init.rst:1212 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:" @@ -1318,13 +1524,13 @@ msgid "" "func:`PyGILState_Release`." msgstr "" -#: ../../c-api/init.rst:1085 +#: ../../c-api/init.rst:1219 msgid "" "When the function returns, the current thread will hold the GIL and be able " "to call arbitrary Python code. Failure is a fatal error." msgstr "" -#: ../../c-api/init.rst:1097 +#: ../../c-api/init.rst:1231 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:" @@ -1332,13 +1538,13 @@ msgid "" "caller, hence the use of the GILState API)." msgstr "" -#: ../../c-api/init.rst:1102 +#: ../../c-api/init.rst:1236 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:1108 +#: ../../c-api/init.rst:1242 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 " @@ -1346,7 +1552,7 @@ msgid "" "made on the main thread. This is mainly a helper/diagnostic function." msgstr "" -#: ../../c-api/init.rst:1116 +#: ../../c-api/init.rst:1250 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 " @@ -1357,13 +1563,13 @@ msgid "" "otherwise behave differently." msgstr "" -#: ../../c-api/init.rst:1128 +#: ../../c-api/init.rst:1262 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:1134 +#: ../../c-api/init.rst:1268 msgid "" "This macro expands to ``{ PyThreadState *_save; _save = PyEval_SaveThread();" "``. Note that it contains an opening brace; it must be matched with a " @@ -1371,7 +1577,7 @@ msgid "" "discussion of this macro." msgstr "" -#: ../../c-api/init.rst:1142 +#: ../../c-api/init.rst:1276 msgid "" "This macro expands to ``PyEval_RestoreThread(_save); }``. Note that it " "contains a closing brace; it must be matched with an earlier :c:macro:" @@ -1379,40 +1585,40 @@ msgid "" "macro." msgstr "" -#: ../../c-api/init.rst:1150 +#: ../../c-api/init.rst:1284 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:1156 +#: ../../c-api/init.rst:1290 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:1162 +#: ../../c-api/init.rst:1296 msgid "Low-level API" msgstr "低階 API" -#: ../../c-api/init.rst:1164 +#: ../../c-api/init.rst:1298 msgid "" "All of the following functions must be called after :c:func:`Py_Initialize`." msgstr "" -#: ../../c-api/init.rst:1166 +#: ../../c-api/init.rst:1300 msgid ":c:func:`Py_Initialize()` now initializes the :term:`GIL`." msgstr "" -#: ../../c-api/init.rst:1172 +#: ../../c-api/init.rst:1306 msgid "" "Create a new interpreter state object. The global interpreter lock need not " "be held, but may be held if it is necessary to serialize calls to this " "function." msgstr "" -#: ../../c-api/init.rst:1176 +#: ../../c-api/init.rst:1310 msgid "" "Raises an :ref:`auditing event ` ``cpython." "PyInterpreterState_New`` with no arguments." @@ -1420,13 +1626,13 @@ msgstr "" "引發一個不附帶引數的\\ :ref:`稽核事件 ` ``cpython." "PyInterpreterState_New``。" -#: ../../c-api/init.rst:1181 +#: ../../c-api/init.rst:1315 msgid "" "Reset all information in an interpreter state object. The global " "interpreter lock must be held." msgstr "" -#: ../../c-api/init.rst:1184 +#: ../../c-api/init.rst:1318 msgid "" "Raises an :ref:`auditing event ` ``cpython." "PyInterpreterState_Clear`` with no arguments." @@ -1434,160 +1640,171 @@ msgstr "" "引發一個不附帶引數的\\ :ref:`稽核事件 ` ``cpython." "PyInterpreterState_Clear``。" -#: ../../c-api/init.rst:1189 +#: ../../c-api/init.rst:1323 msgid "" "Destroy an interpreter state object. The global interpreter lock need not " "be held. The interpreter state must have been reset with a previous call " "to :c:func:`PyInterpreterState_Clear`." msgstr "" -#: ../../c-api/init.rst:1196 +#: ../../c-api/init.rst:1330 msgid "" "Create a new thread state object belonging to the given interpreter object. " "The global interpreter lock need not be held, but may be held if it is " "necessary to serialize calls to this function." msgstr "" -#: ../../c-api/init.rst:1203 +#: ../../c-api/init.rst:1337 msgid "" "Reset all information in a thread state object. The global interpreter lock " "must be held." msgstr "" -#: ../../c-api/init.rst:1206 +#: ../../c-api/init.rst:1340 msgid "" "This function now calls the :c:member:`PyThreadState.on_delete` callback. " "Previously, that happened in :c:func:`PyThreadState_Delete`." msgstr "" -#: ../../c-api/init.rst:1213 +#: ../../c-api/init.rst:1344 +msgid "The :c:member:`PyThreadState.on_delete` callback was removed." +msgstr "" + +#: ../../c-api/init.rst:1350 msgid "" "Destroy a thread state object. The global interpreter lock need not be " "held. The thread state must have been reset with a previous call to :c:func:" "`PyThreadState_Clear`." msgstr "" -#: ../../c-api/init.rst:1220 +#: ../../c-api/init.rst:1357 msgid "" "Destroy the current thread state and release the global interpreter lock. " -"Like :c:func:`PyThreadState_Delete`, the global interpreter lock need not be " +"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`." msgstr "" -#: ../../c-api/init.rst:1228 +#: ../../c-api/init.rst:1365 msgid "Get the current frame of the Python thread state *tstate*." msgstr "" -#: ../../c-api/init.rst:1230 +#: ../../c-api/init.rst:1367 msgid "" "Return a :term:`strong reference`. Return ``NULL`` if no frame is currently " "executing." msgstr "" -#: ../../c-api/init.rst:1233 +#: ../../c-api/init.rst:1370 msgid "See also :c:func:`PyEval_GetFrame`." msgstr "也請見 :c:func:`PyEval_GetFrame`。" -#: ../../c-api/init.rst:1235 ../../c-api/init.rst:1244 -#: ../../c-api/init.rst:1253 +#: ../../c-api/init.rst:1372 ../../c-api/init.rst:1381 +#: ../../c-api/init.rst:1390 msgid "*tstate* must not be ``NULL``." msgstr "*tstate* 不可為 ``NULL``。" -#: ../../c-api/init.rst:1242 +#: ../../c-api/init.rst:1379 msgid "" "Get the unique thread state identifier of the Python thread state *tstate*." msgstr "" -#: ../../c-api/init.rst:1251 +#: ../../c-api/init.rst:1388 msgid "Get the interpreter of the Python thread state *tstate*." msgstr "" -#: ../../c-api/init.rst:1260 +#: ../../c-api/init.rst:1397 msgid "Suspend tracing and profiling in the Python thread state *tstate*." msgstr "" -#: ../../c-api/init.rst:1262 +#: ../../c-api/init.rst:1399 msgid "Resume them using the :c:func:`PyThreadState_LeaveTracing` function." msgstr "" -#: ../../c-api/init.rst:1269 +#: ../../c-api/init.rst:1406 msgid "" "Resume tracing and profiling in the Python thread state *tstate* suspended " "by the :c:func:`PyThreadState_EnterTracing` function." msgstr "" -#: ../../c-api/init.rst:1272 +#: ../../c-api/init.rst:1409 msgid "" "See also :c:func:`PyEval_SetTrace` and :c:func:`PyEval_SetProfile` functions." msgstr "" -#: ../../c-api/init.rst:1280 +#: ../../c-api/init.rst:1417 msgid "Get the current interpreter." msgstr "" -#: ../../c-api/init.rst:1282 +#: ../../c-api/init.rst:1419 msgid "" "Issue a fatal error if there no current Python thread state or no current " "interpreter. It cannot return NULL." msgstr "" -#: ../../c-api/init.rst:1285 ../../c-api/init.rst:1295 +#: ../../c-api/init.rst:1422 ../../c-api/init.rst:1432 +#: ../../c-api/init.rst:1454 msgid "The caller must hold the GIL." msgstr "" -#: ../../c-api/init.rst:1292 +#: ../../c-api/init.rst:1429 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:1302 +#: ../../c-api/init.rst:1439 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:1306 +#: ../../c-api/init.rst:1443 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:1313 +#: ../../c-api/init.rst:1451 +msgid "" +"Return a :term:`strong reference` to the ``__main__`` :ref:`module object " +"` for the given interpreter." +msgstr "" + +#: ../../c-api/init.rst:1461 msgid "Type of a frame evaluation function." msgstr "" -#: ../../c-api/init.rst:1315 +#: ../../c-api/init.rst:1463 msgid "" "The *throwflag* parameter is used by the ``throw()`` method of generators: " "if non-zero, handle the current exception." msgstr "" -#: ../../c-api/init.rst:1318 +#: ../../c-api/init.rst:1466 msgid "The function now takes a *tstate* parameter." msgstr "" -#: ../../c-api/init.rst:1321 +#: ../../c-api/init.rst:1469 msgid "" "The *frame* parameter changed from ``PyFrameObject*`` to " "``_PyInterpreterFrame*``." msgstr "" -#: ../../c-api/init.rst:1326 +#: ../../c-api/init.rst:1474 msgid "Get the frame evaluation function." msgstr "" -#: ../../c-api/init.rst:1328 ../../c-api/init.rst:1336 +#: ../../c-api/init.rst:1476 ../../c-api/init.rst:1484 msgid "See the :pep:`523` \"Adding a frame evaluation API to CPython\"." msgstr "" -#: ../../c-api/init.rst:1334 +#: ../../c-api/init.rst:1482 msgid "Set the frame evaluation function." msgstr "" -#: ../../c-api/init.rst:1343 +#: ../../c-api/init.rst:1491 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 " @@ -1596,7 +1813,7 @@ msgid "" "raised and the caller should assume no current thread state is available." msgstr "" -#: ../../c-api/init.rst:1352 +#: ../../c-api/init.rst:1500 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. " @@ -1608,33 +1825,33 @@ msgid "" "raises no exceptions." msgstr "" -#: ../../c-api/init.rst:1360 +#: ../../c-api/init.rst:1508 msgid "" "The type of the *id* parameter changed from :c:expr:`long` to :c:expr:" "`unsigned long`." msgstr "" -#: ../../c-api/init.rst:1366 +#: ../../c-api/init.rst:1514 msgid "" "Acquire the global interpreter lock and set the current thread state to " "*tstate*, which must not be ``NULL``. The lock must have been created " "earlier. If this thread already has the lock, deadlock ensues." msgstr "" -#: ../../c-api/init.rst:1377 +#: ../../c-api/init.rst:1525 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:1382 +#: ../../c-api/init.rst:1530 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:1388 +#: ../../c-api/init.rst:1536 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 " @@ -1643,17 +1860,17 @@ msgid "" "isn't, a fatal error is reported." msgstr "" -#: ../../c-api/init.rst:1394 +#: ../../c-api/init.rst:1542 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:1401 +#: ../../c-api/init.rst:1549 msgid "Sub-interpreter support" msgstr "" -#: ../../c-api/init.rst:1403 +#: ../../c-api/init.rst:1551 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 " @@ -1661,7 +1878,7 @@ msgid "" "to do that." msgstr "" -#: ../../c-api/init.rst:1408 +#: ../../c-api/init.rst:1556 msgid "" "The \"main\" interpreter is the first one created when the runtime " "initializes. It is usually the only Python interpreter in a process. Unlike " @@ -1672,31 +1889,31 @@ msgid "" "returns a pointer to its state." msgstr "" -#: ../../c-api/init.rst:1415 +#: ../../c-api/init.rst:1563 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:1421 +#: ../../c-api/init.rst:1569 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:1427 +#: ../../c-api/init.rst:1575 msgid "Structure fields:" msgstr "" -#: ../../c-api/init.rst:1431 +#: ../../c-api/init.rst:1579 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:1435 +#: ../../c-api/init.rst:1583 msgid "" "If this is ``0`` then :c:member:`~PyInterpreterConfig." "check_multi_interp_extensions` must be ``1`` (non-zero). If this is ``1`` " @@ -1704,44 +1921,44 @@ msgid "" "`PyInterpreterConfig_OWN_GIL`." msgstr "" -#: ../../c-api/init.rst:1443 +#: ../../c-api/init.rst:1591 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:1447 +#: ../../c-api/init.rst:1595 msgid "" "Note that the :mod:`subprocess` module still works when fork is disallowed." msgstr "" -#: ../../c-api/init.rst:1452 +#: ../../c-api/init.rst:1600 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:1457 +#: ../../c-api/init.rst:1605 msgid "" "Note that the :mod:`subprocess` module still works when exec is disallowed." msgstr "" -#: ../../c-api/init.rst:1462 +#: ../../c-api/init.rst:1610 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:1468 +#: ../../c-api/init.rst:1616 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:1475 +#: ../../c-api/init.rst:1623 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 " @@ -1750,37 +1967,37 @@ msgid "" "`Py_mod_multiple_interpreters`.)" msgstr "" -#: ../../c-api/init.rst:1482 +#: ../../c-api/init.rst:1630 msgid "" "This must be ``1`` (non-zero) if :c:member:`~PyInterpreterConfig." "use_main_obmalloc` is ``0``." msgstr "" -#: ../../c-api/init.rst:1487 +#: ../../c-api/init.rst:1635 msgid "" "This determines the operation of the GIL for the sub-interpreter. It may be " "one of the following:" msgstr "" -#: ../../c-api/init.rst:1494 +#: ../../c-api/init.rst:1642 msgid "Use the default selection (:c:macro:`PyInterpreterConfig_SHARED_GIL`)." msgstr "" -#: ../../c-api/init.rst:1498 +#: ../../c-api/init.rst:1646 msgid "Use (share) the main interpreter's GIL." msgstr "" -#: ../../c-api/init.rst:1502 +#: ../../c-api/init.rst:1650 msgid "Use the sub-interpreter's own GIL." msgstr "" -#: ../../c-api/init.rst:1504 +#: ../../c-api/init.rst:1652 msgid "" "If this is :c:macro:`PyInterpreterConfig_OWN_GIL` then :c:member:" "`PyInterpreterConfig.use_main_obmalloc` must be ``0``." msgstr "" -#: ../../c-api/init.rst:1518 +#: ../../c-api/init.rst:1666 msgid "" "Create a new sub-interpreter. This is an (almost) totally separate " "environment for the execution of Python code. In particular, the new " @@ -1793,13 +2010,13 @@ msgid "" "underlying file descriptors)." msgstr "" -#: ../../c-api/init.rst:1528 +#: ../../c-api/init.rst:1676 msgid "" "The given *config* controls the options with which the interpreter is " "initialized." msgstr "" -#: ../../c-api/init.rst:1531 +#: ../../c-api/init.rst:1679 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 " @@ -1810,7 +2027,7 @@ msgid "" "state." msgstr "" -#: ../../c-api/init.rst:1540 +#: ../../c-api/init.rst:1688 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. " @@ -1822,13 +2039,14 @@ msgid "" "released here." msgstr "" -#: ../../c-api/init.rst:1551 +#: ../../c-api/init.rst:1699 msgid "" "Sub-interpreters are most effective when isolated from each other, with " "certain functionality restricted::" msgstr "" -#: ../../c-api/init.rst:1554 +#: ../../c-api/init.rst:1702 +#, fuzzy msgid "" "PyInterpreterConfig config = {\n" " .use_main_obmalloc = 0,\n" @@ -1839,7 +2057,11 @@ msgid "" " .check_multi_interp_extensions = 1,\n" " .gil = PyInterpreterConfig_OWN_GIL,\n" "};\n" -"PyThreadState *tstate = Py_NewInterpreterFromConfig(&config);" +"PyThreadState *tstate = NULL;\n" +"PyStatus status = Py_NewInterpreterFromConfig(&tstate, &config);\n" +"if (PyStatus_Exception(status)) {\n" +" Py_ExitStatusException(status);\n" +"}" msgstr "" "PyInterpreterConfig config = {\n" " .use_main_obmalloc = 0,\n" @@ -1852,7 +2074,7 @@ msgstr "" "};\n" "PyThreadState *tstate = Py_NewInterpreterFromConfig(&config);" -#: ../../c-api/init.rst:1565 +#: ../../c-api/init.rst:1717 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:" @@ -1860,11 +2082,11 @@ msgid "" "internally on the :c:type:`PyInterpreterState`." msgstr "" -#: ../../c-api/init.rst:1574 +#: ../../c-api/init.rst:1726 msgid "Extension modules are shared between (sub-)interpreters as follows:" msgstr "" -#: ../../c-api/init.rst:1576 +#: ../../c-api/init.rst:1728 msgid "" "For modules using multi-phase initialization, e.g. :c:func:" "`PyModule_FromDefAndSpec`, a separate module object is created and " @@ -1872,7 +2094,7 @@ msgid "" "are shared between these module objects." msgstr "" -#: ../../c-api/init.rst:1582 +#: ../../c-api/init.rst:1734 msgid "" "For modules using single-phase initialization, e.g. :c:func:" "`PyModule_Create`, the first time a particular extension is imported, it is " @@ -1884,7 +2106,7 @@ msgid "" "might cause unwanted behavior (see `Bugs and caveats`_ below)." msgstr "" -#: ../../c-api/init.rst:1593 +#: ../../c-api/init.rst:1745 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:" @@ -1894,7 +2116,7 @@ msgid "" "shared between these modules." msgstr "" -#: ../../c-api/init.rst:1613 +#: ../../c-api/init.rst:1765 msgid "" "Create a new sub-interpreter. This is essentially just a wrapper around :c:" "func:`Py_NewInterpreterFromConfig` with a config that preserves the existing " @@ -1903,7 +2125,7 @@ msgid "" "single-phase init modules." msgstr "" -#: ../../c-api/init.rst:1625 +#: ../../c-api/init.rst:1777 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 " @@ -1913,17 +2135,17 @@ msgid "" "be held before calling this function. No GIL is held when it returns." msgstr "" -#: ../../c-api/init.rst:1633 +#: ../../c-api/init.rst:1785 msgid "" ":c:func:`Py_FinalizeEx` will destroy all sub-interpreters that haven't been " "explicitly destroyed at that point." msgstr "" -#: ../../c-api/init.rst:1638 +#: ../../c-api/init.rst:1790 msgid "A Per-Interpreter GIL" msgstr "" -#: ../../c-api/init.rst:1640 +#: ../../c-api/init.rst:1792 msgid "" "Using :c:func:`Py_NewInterpreterFromConfig` you can create a sub-interpreter " "that is completely isolated from other interpreters, including having its " @@ -1935,7 +2157,7 @@ msgid "" "just using threads. (See :pep:`554`.)" msgstr "" -#: ../../c-api/init.rst:1650 +#: ../../c-api/init.rst:1802 msgid "" "Using an isolated interpreter requires vigilance in preserving that " "isolation. That especially means not sharing any objects or mutable state " @@ -1949,7 +2171,7 @@ msgid "" "builtin objects." msgstr "" -#: ../../c-api/init.rst:1661 +#: ../../c-api/init.rst:1813 msgid "" "If you preserve isolation then you will have access to proper multi-core " "computing without the complications that come with free-threading. Failure " @@ -1957,7 +2179,7 @@ msgid "" "threading, including races and hard-to-debug crashes." msgstr "" -#: ../../c-api/init.rst:1666 +#: ../../c-api/init.rst:1818 msgid "" "Aside from that, one of the main challenges of using multiple isolated " "interpreters is how to communicate between them safely (not break isolation) " @@ -1967,11 +2189,11 @@ msgid "" "sharing) data between interpreters." msgstr "" -#: ../../c-api/init.rst:1677 +#: ../../c-api/init.rst:1829 msgid "Bugs and caveats" msgstr "" -#: ../../c-api/init.rst:1679 +#: ../../c-api/init.rst:1831 msgid "" "Because sub-interpreters (and the main interpreter) are part of the same " "process, the insulation between them isn't perfect --- for example, using " @@ -1984,7 +2206,7 @@ msgid "" "should be avoided if possible." msgstr "" -#: ../../c-api/init.rst:1689 +#: ../../c-api/init.rst:1841 msgid "" "Special care should be taken to avoid sharing user-defined functions, " "methods, instances or classes between sub-interpreters, since import " @@ -1993,7 +2215,7 @@ msgid "" "objects from which the above are reachable." msgstr "" -#: ../../c-api/init.rst:1695 +#: ../../c-api/init.rst:1847 msgid "" "Also note that combining this functionality with ``PyGILState_*`` APIs is " "delicate, because these APIs assume a bijection between Python thread states " @@ -2005,25 +2227,25 @@ msgid "" "created threads will probably be broken when using sub-interpreters." msgstr "" -#: ../../c-api/init.rst:1706 +#: ../../c-api/init.rst:1858 msgid "Asynchronous Notifications" msgstr "" -#: ../../c-api/init.rst:1708 +#: ../../c-api/init.rst:1860 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:1715 +#: ../../c-api/init.rst:1867 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:1719 +#: ../../c-api/init.rst:1871 msgid "" "When successfully queued, *func* will be *eventually* called from the main " "interpreter thread with the argument *arg*. It will be called " @@ -2031,17 +2253,17 @@ msgid "" "these conditions met:" msgstr "" -#: ../../c-api/init.rst:1724 +#: ../../c-api/init.rst:1876 msgid "on a :term:`bytecode` boundary;" msgstr "" -#: ../../c-api/init.rst:1725 +#: ../../c-api/init.rst:1877 msgid "" "with the main thread holding the :term:`global interpreter lock` (*func* can " "therefore use the full C API)." msgstr "" -#: ../../c-api/init.rst:1728 +#: ../../c-api/init.rst:1880 msgid "" "*func* must return ``0`` on success, or ``-1`` on failure with an exception " "set. *func* won't be interrupted to perform another asynchronous " @@ -2049,20 +2271,20 @@ msgid "" "if the global interpreter lock is released." msgstr "" -#: ../../c-api/init.rst:1733 +#: ../../c-api/init.rst:1885 msgid "" "This function doesn't need a current thread state to run, and it doesn't " "need the global interpreter lock." msgstr "" -#: ../../c-api/init.rst:1736 +#: ../../c-api/init.rst:1888 msgid "" "To call this function in a subinterpreter, the caller must hold the GIL. " "Otherwise, the function *func* can be scheduled to be called from the wrong " "interpreter." msgstr "" -#: ../../c-api/init.rst:1741 +#: ../../c-api/init.rst:1893 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 " @@ -2072,7 +2294,7 @@ msgid "" "`PyGILState API`." msgstr "" -#: ../../c-api/init.rst:1750 +#: ../../c-api/init.rst:1902 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 " @@ -2080,18 +2302,18 @@ msgid "" "scheduled calls." msgstr "" -#: ../../c-api/init.rst:1759 +#: ../../c-api/init.rst:1911 msgid "Profiling and Tracing" msgstr "" -#: ../../c-api/init.rst:1764 +#: ../../c-api/init.rst:1916 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:1768 +#: ../../c-api/init.rst:1920 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 " @@ -2101,7 +2323,7 @@ msgid "" "reported to the Python-level trace functions in previous versions." msgstr "" -#: ../../c-api/init.rst:1778 +#: ../../c-api/init.rst:1930 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 " @@ -2113,66 +2335,66 @@ msgid "" "value of *what*:" msgstr "" -#: ../../c-api/init.rst:1787 +#: ../../c-api/init.rst:1939 msgid "Value of *what*" msgstr "" -#: ../../c-api/init.rst:1787 +#: ../../c-api/init.rst:1939 msgid "Meaning of *arg*" msgstr "*arg* 的含義" -#: ../../c-api/init.rst:1789 +#: ../../c-api/init.rst:1941 msgid ":c:data:`PyTrace_CALL`" msgstr ":c:data:`PyTrace_CALL`" -#: ../../c-api/init.rst:1789 ../../c-api/init.rst:1794 -#: ../../c-api/init.rst:1805 +#: ../../c-api/init.rst:1941 ../../c-api/init.rst:1946 +#: ../../c-api/init.rst:1957 msgid "Always :c:data:`Py_None`." msgstr "" -#: ../../c-api/init.rst:1791 +#: ../../c-api/init.rst:1943 msgid ":c:data:`PyTrace_EXCEPTION`" msgstr ":c:data:`PyTrace_EXCEPTION`" -#: ../../c-api/init.rst:1791 +#: ../../c-api/init.rst:1943 msgid "Exception information as returned by :func:`sys.exc_info`." msgstr "" -#: ../../c-api/init.rst:1794 +#: ../../c-api/init.rst:1946 msgid ":c:data:`PyTrace_LINE`" msgstr ":c:data:`PyTrace_LINE`" -#: ../../c-api/init.rst:1796 +#: ../../c-api/init.rst:1948 msgid ":c:data:`PyTrace_RETURN`" msgstr ":c:data:`PyTrace_RETURN`" -#: ../../c-api/init.rst:1796 +#: ../../c-api/init.rst:1948 msgid "" "Value being returned to the caller, or ``NULL`` if caused by an exception." msgstr "" -#: ../../c-api/init.rst:1799 +#: ../../c-api/init.rst:1951 msgid ":c:data:`PyTrace_C_CALL`" msgstr ":c:data:`PyTrace_C_CALL`" -#: ../../c-api/init.rst:1799 ../../c-api/init.rst:1801 -#: ../../c-api/init.rst:1803 +#: ../../c-api/init.rst:1951 ../../c-api/init.rst:1953 +#: ../../c-api/init.rst:1955 msgid "Function object being called." msgstr "被呼叫的函式物件。" -#: ../../c-api/init.rst:1801 +#: ../../c-api/init.rst:1953 msgid ":c:data:`PyTrace_C_EXCEPTION`" msgstr ":c:data:`PyTrace_C_EXCEPTION`" -#: ../../c-api/init.rst:1803 +#: ../../c-api/init.rst:1955 msgid ":c:data:`PyTrace_C_RETURN`" msgstr ":c:data:`PyTrace_C_RETURN`" -#: ../../c-api/init.rst:1805 +#: ../../c-api/init.rst:1957 msgid ":c:data:`PyTrace_OPCODE`" msgstr ":c:data:`PyTrace_OPCODE`" -#: ../../c-api/init.rst:1810 +#: ../../c-api/init.rst:1962 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 " @@ -2181,7 +2403,7 @@ msgid "" "the corresponding frame." msgstr "" -#: ../../c-api/init.rst:1819 +#: ../../c-api/init.rst:1971 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 " @@ -2193,7 +2415,7 @@ msgid "" "profiler." msgstr "" -#: ../../c-api/init.rst:1830 +#: ../../c-api/init.rst:1982 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 " @@ -2201,31 +2423,31 @@ msgid "" "f_trace_lines` to *0* on that frame." msgstr "" -#: ../../c-api/init.rst:1838 +#: ../../c-api/init.rst:1990 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:1844 +#: ../../c-api/init.rst:1996 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:1850 +#: ../../c-api/init.rst:2002 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:1856 +#: ../../c-api/init.rst:2008 msgid "" "The value for the *what* parameter to :c:type:`Py_tracefunc` functions when " "a C function has returned." msgstr "" -#: ../../c-api/init.rst:1862 +#: ../../c-api/init.rst:2014 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 " @@ -2233,7 +2455,7 @@ msgid "" "attr:`~frame.f_trace_opcodes` to *1* on the frame." msgstr "" -#: ../../c-api/init.rst:1870 +#: ../../c-api/init.rst:2022 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``. " @@ -2243,29 +2465,29 @@ msgid "" "`PyTrace_LINE` :c:data:`PyTrace_OPCODE` and :c:data:`PyTrace_EXCEPTION`." msgstr "" -#: ../../c-api/init.rst:1877 +#: ../../c-api/init.rst:2029 msgid "See also the :func:`sys.setprofile` function." msgstr "" -#: ../../c-api/init.rst:1879 ../../c-api/init.rst:1886 -#: ../../c-api/init.rst:1905 ../../c-api/init.rst:1912 +#: ../../c-api/init.rst:2031 ../../c-api/init.rst:2038 +#: ../../c-api/init.rst:2057 ../../c-api/init.rst:2064 msgid "The caller must hold the :term:`GIL`." msgstr "呼叫者必須持有 :term:`GIL`。" -#: ../../c-api/init.rst:1883 +#: ../../c-api/init.rst:2035 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:1888 +#: ../../c-api/init.rst:2040 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:1896 +#: ../../c-api/init.rst:2048 msgid "" "Set the tracing function to *func*. This is similar to :c:func:" "`PyEval_SetProfile`, except the tracing function does receive line-number " @@ -2276,28 +2498,28 @@ msgid "" "*what* parameter." msgstr "" -#: ../../c-api/init.rst:1903 +#: ../../c-api/init.rst:2055 msgid "See also the :func:`sys.settrace` function." msgstr "也請見 :func:`sys.settrace` 函式。" -#: ../../c-api/init.rst:1909 +#: ../../c-api/init.rst:2061 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:1914 +#: ../../c-api/init.rst:2066 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:1920 +#: ../../c-api/init.rst:2072 msgid "Reference tracing" msgstr "" -#: ../../c-api/init.rst:1926 +#: ../../c-api/init.rst:2078 msgid "" "The type of the trace function registered using :c:func:" "`PyRefTracer_SetTracer`. The first parameter is a Python object that has " @@ -2307,19 +2529,19 @@ msgid "" "provided when :c:func:`PyRefTracer_SetTracer` was called." msgstr "" -#: ../../c-api/init.rst:1936 +#: ../../c-api/init.rst:2088 msgid "" "The value for the *event* parameter to :c:type:`PyRefTracer` functions when " "a Python object has been created." msgstr "" -#: ../../c-api/init.rst:1941 +#: ../../c-api/init.rst:2093 msgid "" "The value for the *event* parameter to :c:type:`PyRefTracer` functions when " "a Python object has been destroyed." msgstr "" -#: ../../c-api/init.rst:1946 +#: ../../c-api/init.rst:2098 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 " @@ -2328,7 +2550,7 @@ msgid "" "return ``-1`` on error." msgstr "" -#: ../../c-api/init.rst:1952 +#: ../../c-api/init.rst:2104 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 " @@ -2336,11 +2558,11 @@ msgid "" "the tracer function is called." msgstr "" -#: ../../c-api/init.rst:1957 ../../c-api/init.rst:1968 +#: ../../c-api/init.rst:2109 ../../c-api/init.rst:2120 msgid "The GIL must be held when calling this function." msgstr "" -#: ../../c-api/init.rst:1963 +#: ../../c-api/init.rst:2115 msgid "" "Get the registered reference tracer function and the value of the opaque " "data pointer that was registered when :c:func:`PyRefTracer_SetTracer` was " @@ -2348,48 +2570,48 @@ msgid "" "set the **data** pointer to NULL." msgstr "" -#: ../../c-api/init.rst:1975 +#: ../../c-api/init.rst:2127 msgid "Advanced Debugger Support" msgstr "" -#: ../../c-api/init.rst:1980 +#: ../../c-api/init.rst:2132 msgid "" "These functions are only intended to be used by advanced debugging tools." msgstr "" -#: ../../c-api/init.rst:1985 +#: ../../c-api/init.rst:2137 msgid "" "Return the interpreter state object at the head of the list of all such " "objects." msgstr "" -#: ../../c-api/init.rst:1990 +#: ../../c-api/init.rst:2142 msgid "Return the main interpreter state object." msgstr "" -#: ../../c-api/init.rst:1995 +#: ../../c-api/init.rst:2147 msgid "" "Return the next interpreter state object after *interp* from the list of all " "such objects." msgstr "" -#: ../../c-api/init.rst:2001 +#: ../../c-api/init.rst:2153 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:2007 +#: ../../c-api/init.rst:2159 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:2014 +#: ../../c-api/init.rst:2166 msgid "Thread Local Storage Support" msgstr "" -#: ../../c-api/init.rst:2018 +#: ../../c-api/init.rst:2170 msgid "" "The Python interpreter provides low-level support for thread-local storage " "(TLS) which wraps the underlying native TLS implementation to support the " @@ -2399,19 +2621,19 @@ msgid "" "thread." msgstr "" -#: ../../c-api/init.rst:2025 +#: ../../c-api/init.rst:2177 msgid "" "The GIL does *not* need to be held when calling these functions; they supply " "their own locking." msgstr "" -#: ../../c-api/init.rst:2028 +#: ../../c-api/init.rst:2180 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:2032 +#: ../../c-api/init.rst:2184 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 " @@ -2419,22 +2641,22 @@ msgid "" "don't do refcount operations on them either." msgstr "" -#: ../../c-api/init.rst:2040 +#: ../../c-api/init.rst:2192 msgid "Thread Specific Storage (TSS) API" msgstr "" -#: ../../c-api/init.rst:2042 +#: ../../c-api/init.rst:2194 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:2048 +#: ../../c-api/init.rst:2200 msgid "\"A New C-API for Thread-Local Storage in CPython\" (:pep:`539`)" msgstr "" -#: ../../c-api/init.rst:2053 +#: ../../c-api/init.rst:2205 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 " @@ -2442,52 +2664,52 @@ msgid "" "public members in this structure." msgstr "" -#: ../../c-api/init.rst:2058 +#: ../../c-api/init.rst:2210 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:2064 +#: ../../c-api/init.rst:2216 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:2069 +#: ../../c-api/init.rst:2221 msgid "Dynamic Allocation" msgstr "" -#: ../../c-api/init.rst:2071 +#: ../../c-api/init.rst:2223 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:2078 +#: ../../c-api/init.rst:2230 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:2085 +#: ../../c-api/init.rst:2237 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:2091 +#: ../../c-api/init.rst:2243 msgid "" "A freed key becomes a dangling pointer. You should reset the key to ``NULL``." msgstr "" -#: ../../c-api/init.rst:2096 +#: ../../c-api/init.rst:2248 msgid "Methods" msgstr "方法" -#: ../../c-api/init.rst:2098 +#: ../../c-api/init.rst:2250 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 " @@ -2495,13 +2717,13 @@ msgid "" "func:`PyThread_tss_create`." msgstr "" -#: ../../c-api/init.rst:2106 +#: ../../c-api/init.rst:2258 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:2112 +#: ../../c-api/init.rst:2264 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 " @@ -2510,7 +2732,7 @@ msgid "" "no-op and immediately returns success." msgstr "" -#: ../../c-api/init.rst:2121 +#: ../../c-api/init.rst:2273 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 " @@ -2519,31 +2741,31 @@ msgid "" "key -- calling it on an already destroyed key is a no-op." msgstr "" -#: ../../c-api/init.rst:2130 +#: ../../c-api/init.rst:2282 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:2137 +#: ../../c-api/init.rst:2289 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:2145 +#: ../../c-api/init.rst:2297 msgid "Thread Local Storage (TLS) API" msgstr "執行緒局部儲存 (Thread Local Storage, TLS) API:" -#: ../../c-api/init.rst:2147 +#: ../../c-api/init.rst:2299 msgid "" "This API is superseded by :ref:`Thread Specific Storage (TSS) API `." msgstr "" -#: ../../c-api/init.rst:2152 +#: ../../c-api/init.rst:2304 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 " @@ -2552,62 +2774,62 @@ msgid "" "platforms." msgstr "" -#: ../../c-api/init.rst:2157 +#: ../../c-api/init.rst:2309 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:2168 +#: ../../c-api/init.rst:2320 msgid "Synchronization Primitives" msgstr "" -#: ../../c-api/init.rst:2170 +#: ../../c-api/init.rst:2322 msgid "The C-API provides a basic mutual exclusion lock." msgstr "" -#: ../../c-api/init.rst:2174 +#: ../../c-api/init.rst:2326 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:2177 +#: ../../c-api/init.rst:2329 msgid "PyMutex mutex = {0};" msgstr "" -#: ../../c-api/init.rst:2179 +#: ../../c-api/init.rst:2331 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:2185 +#: ../../c-api/init.rst:2337 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:2193 +#: ../../c-api/init.rst:2345 msgid "" "Lock mutex *m*. If another thread has already locked it, the calling thread " "will block until the mutex is unlocked. While blocked, the thread will " "temporarily release the :term:`GIL` if it is held." msgstr "" -#: ../../c-api/init.rst:2201 +#: ../../c-api/init.rst:2353 msgid "" "Unlock mutex *m*. The mutex must be locked --- otherwise, the function will " "issue a fatal error." msgstr "" -#: ../../c-api/init.rst:2209 +#: ../../c-api/init.rst:2361 msgid "Python Critical Section API" msgstr "" -#: ../../c-api/init.rst:2211 +#: ../../c-api/init.rst:2363 msgid "" "The critical section API provides a deadlock avoidance layer on top of per-" "object locks for :term:`free-threaded ` CPython. They are " @@ -2615,7 +2837,7 @@ msgid "" "no-ops in versions of Python with the global interpreter lock." msgstr "" -#: ../../c-api/init.rst:2216 +#: ../../c-api/init.rst:2368 msgid "" "Critical sections avoid deadlocks by implicitly suspending active critical " "sections and releasing the locks during calls to :c:func:" @@ -2625,7 +2847,7 @@ msgid "" "-- they are useful because their behavior is similar to the :term:`GIL`." msgstr "" -#: ../../c-api/init.rst:2223 +#: ../../c-api/init.rst:2375 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 " @@ -2633,7 +2855,7 @@ msgid "" "future Python versions." msgstr "" -#: ../../c-api/init.rst:2230 +#: ../../c-api/init.rst:2382 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 " @@ -2642,11 +2864,11 @@ msgid "" "lock more than two objects at once." msgstr "" -#: ../../c-api/init.rst:2236 +#: ../../c-api/init.rst:2388 msgid "Example usage::" msgstr "" -#: ../../c-api/init.rst:2238 +#: ../../c-api/init.rst:2390 msgid "" "static PyObject *\n" "set_field(MyObject *self, PyObject *value)\n" @@ -2658,231 +2880,231 @@ msgid "" "}" msgstr "" -#: ../../c-api/init.rst:2247 +#: ../../c-api/init.rst:2399 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 " -"critical section API avoids potentital deadlocks due to reentrancy and lock " +"critical section API avoids potential deadlocks due to reentrancy and lock " "ordering by allowing the runtime to temporarily suspend the critical section " "if the code triggered by the finalizer blocks and calls :c:func:" "`PyEval_SaveThread`." msgstr "" -#: ../../c-api/init.rst:2255 +#: ../../c-api/init.rst:2407 msgid "" "Acquires the per-object lock for the object *op* and begins a critical " "section." msgstr "" -#: ../../c-api/init.rst:2258 ../../c-api/init.rst:2272 -#: ../../c-api/init.rst:2287 ../../c-api/init.rst:2301 +#: ../../c-api/init.rst:2410 ../../c-api/init.rst:2424 +#: ../../c-api/init.rst:2439 ../../c-api/init.rst:2453 msgid "In the free-threaded build, this macro expands to::" msgstr "" -#: ../../c-api/init.rst:2260 +#: ../../c-api/init.rst:2412 msgid "" "{\n" " PyCriticalSection _py_cs;\n" " PyCriticalSection_Begin(&_py_cs, (PyObject*)(op))" msgstr "" -#: ../../c-api/init.rst:2264 ../../c-api/init.rst:2293 +#: ../../c-api/init.rst:2416 ../../c-api/init.rst:2445 msgid "In the default build, this macro expands to ``{``." msgstr "" -#: ../../c-api/init.rst:2270 +#: ../../c-api/init.rst:2422 msgid "Ends the critical section and releases the per-object lock." msgstr "" -#: ../../c-api/init.rst:2274 +#: ../../c-api/init.rst:2426 msgid "" " PyCriticalSection_End(&_py_cs);\n" "}" msgstr "" -#: ../../c-api/init.rst:2277 ../../c-api/init.rst:2306 +#: ../../c-api/init.rst:2429 ../../c-api/init.rst:2458 msgid "In the default build, this macro expands to ``}``." msgstr "" -#: ../../c-api/init.rst:2283 +#: ../../c-api/init.rst:2435 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:2289 +#: ../../c-api/init.rst:2441 msgid "" "{\n" " PyCriticalSection2 _py_cs2;\n" -" PyCriticalSection_Begin2(&_py_cs2, (PyObject*)(a), (PyObject*)(b))" +" PyCriticalSection2_Begin(&_py_cs2, (PyObject*)(a), (PyObject*)(b))" msgstr "" -#: ../../c-api/init.rst:2299 +#: ../../c-api/init.rst:2451 msgid "Ends the critical section and releases the per-object locks." msgstr "" -#: ../../c-api/init.rst:2303 +#: ../../c-api/init.rst:2455 msgid "" -" PyCriticalSection_End2(&_py_cs2);\n" +" PyCriticalSection2_End(&_py_cs2);\n" "}" msgstr "" -#: ../../c-api/init.rst:335 +#: ../../c-api/init.rst:350 msgid "PyEval_InitThreads()" msgstr "PyEval_InitThreads()" -#: ../../c-api/init.rst:335 +#: ../../c-api/init.rst:350 msgid "modules (in module sys)" msgstr "modules(sys 模組中)" -#: ../../c-api/init.rst:335 ../../c-api/init.rst:576 +#: ../../c-api/init.rst:350 ../../c-api/init.rst:710 msgid "path (in module sys)" msgstr "path(sys 模組中)" -#: ../../c-api/init.rst:335 ../../c-api/init.rst:576 ../../c-api/init.rst:1011 -#: ../../c-api/init.rst:1510 ../../c-api/init.rst:1605 +#: ../../c-api/init.rst:350 ../../c-api/init.rst:710 ../../c-api/init.rst:1145 +#: ../../c-api/init.rst:1658 ../../c-api/init.rst:1757 msgid "module" msgstr "模組" -#: ../../c-api/init.rst:335 ../../c-api/init.rst:1510 ../../c-api/init.rst:1605 +#: ../../c-api/init.rst:350 ../../c-api/init.rst:1658 ../../c-api/init.rst:1757 msgid "builtins" msgstr "builtins(內建)" -#: ../../c-api/init.rst:335 ../../c-api/init.rst:1510 ../../c-api/init.rst:1605 +#: ../../c-api/init.rst:350 ../../c-api/init.rst:1658 ../../c-api/init.rst:1757 msgid "__main__" msgstr "__main__" -#: ../../c-api/init.rst:335 ../../c-api/init.rst:1510 ../../c-api/init.rst:1605 +#: ../../c-api/init.rst:350 ../../c-api/init.rst:1658 ../../c-api/init.rst:1757 msgid "sys" msgstr "sys" -#: ../../c-api/init.rst:335 ../../c-api/init.rst:576 +#: ../../c-api/init.rst:350 ../../c-api/init.rst:710 msgid "search" msgstr "search(搜尋)" -#: ../../c-api/init.rst:335 ../../c-api/init.rst:576 +#: ../../c-api/init.rst:350 ../../c-api/init.rst:710 msgid "path" msgstr "path(路徑)" -#: ../../c-api/init.rst:335 ../../c-api/init.rst:1570 ../../c-api/init.rst:1623 +#: ../../c-api/init.rst:350 ../../c-api/init.rst:1722 ../../c-api/init.rst:1775 msgid "Py_FinalizeEx (C function)" msgstr "Py_FinalizeEx(C 函式)" -#: ../../c-api/init.rst:445 +#: ../../c-api/init.rst:576 msgid "Py_Initialize()" msgstr "Py_Initialize()" -#: ../../c-api/init.rst:445 ../../c-api/init.rst:674 +#: ../../c-api/init.rst:576 ../../c-api/init.rst:808 msgid "main()" msgstr "main()" -#: ../../c-api/init.rst:445 +#: ../../c-api/init.rst:576 msgid "Py_GetPath()" msgstr "Py_GetPath()" -#: ../../c-api/init.rst:555 +#: ../../c-api/init.rst:689 msgid "executable (in module sys)" msgstr "executable(sys 模組中)" -#: ../../c-api/init.rst:609 ../../c-api/init.rst:651 ../../c-api/init.rst:665 +#: ../../c-api/init.rst:743 ../../c-api/init.rst:785 ../../c-api/init.rst:799 msgid "version (in module sys)" msgstr "version(sys 模組中)" -#: ../../c-api/init.rst:621 +#: ../../c-api/init.rst:755 msgid "platform (in module sys)" msgstr "platform(sys 模組中)" -#: ../../c-api/init.rst:638 +#: ../../c-api/init.rst:772 msgid "copyright (in module sys)" msgstr "copyright(sys 模組中)" -#: ../../c-api/init.rst:674 +#: ../../c-api/init.rst:808 msgid "Py_FatalError()" msgstr "Py_FatalError()" -#: ../../c-api/init.rst:674 +#: ../../c-api/init.rst:808 msgid "argv (in module sys)" msgstr "argv(sys 模組中)" -#: ../../c-api/init.rst:794 +#: ../../c-api/init.rst:928 msgid "global interpreter lock" msgstr "global interpreter lock(全域直譯器鎖)" -#: ../../c-api/init.rst:794 +#: ../../c-api/init.rst:928 msgid "interpreter lock" msgstr "interpreter lock(直譯器鎖)" -#: ../../c-api/init.rst:794 +#: ../../c-api/init.rst:928 msgid "lock, interpreter" msgstr "lock, interpreter(鎖、直譯器)" -#: ../../c-api/init.rst:807 +#: ../../c-api/init.rst:941 msgid "setswitchinterval (in module sys)" msgstr "setswitchinterval (sys 模組中)" -#: ../../c-api/init.rst:816 +#: ../../c-api/init.rst:950 msgid "PyThreadState (C type)" msgstr "PyThreadState(C 型別)" -#: ../../c-api/init.rst:842 +#: ../../c-api/init.rst:976 msgid "Py_BEGIN_ALLOW_THREADS (C macro)" msgstr "Py_BEGIN_ALLOW_THREADS(C 巨集)" -#: ../../c-api/init.rst:842 +#: ../../c-api/init.rst:976 msgid "Py_END_ALLOW_THREADS (C macro)" msgstr "Py_END_ALLOW_THREADS(C 巨集)" -#: ../../c-api/init.rst:858 +#: ../../c-api/init.rst:992 msgid "PyEval_RestoreThread (C function)" msgstr "PyEval_RestoreThread(C 函式)" -#: ../../c-api/init.rst:858 +#: ../../c-api/init.rst:992 msgid "PyEval_SaveThread (C function)" msgstr "PyEval_SaveThread(C 函式)" -#: ../../c-api/init.rst:989 +#: ../../c-api/init.rst:1123 msgid "PyEval_AcquireThread()" msgstr "PyEval_AcquireThread()" -#: ../../c-api/init.rst:989 +#: ../../c-api/init.rst:1123 msgid "PyEval_ReleaseThread()" msgstr "PyEval_ReleaseThread()" -#: ../../c-api/init.rst:989 +#: ../../c-api/init.rst:1123 msgid "PyEval_SaveThread()" msgstr "PyEval_SaveThread()" -#: ../../c-api/init.rst:989 +#: ../../c-api/init.rst:1123 msgid "PyEval_RestoreThread()" msgstr "PyEval_RestoreThread()" -#: ../../c-api/init.rst:1011 +#: ../../c-api/init.rst:1145 msgid "_thread" msgstr "_thread" -#: ../../c-api/init.rst:1510 ../../c-api/init.rst:1605 +#: ../../c-api/init.rst:1658 ../../c-api/init.rst:1757 msgid "stdout (in module sys)" msgstr "stdout(sys 模組中)" -#: ../../c-api/init.rst:1510 ../../c-api/init.rst:1605 +#: ../../c-api/init.rst:1658 ../../c-api/init.rst:1757 msgid "stderr (in module sys)" msgstr "stderr(sys 模組中)" -#: ../../c-api/init.rst:1510 ../../c-api/init.rst:1605 +#: ../../c-api/init.rst:1658 ../../c-api/init.rst:1757 msgid "stdin (in module sys)" msgstr "stdin(sys 模組中)" -#: ../../c-api/init.rst:1570 +#: ../../c-api/init.rst:1722 msgid "Py_Initialize (C function)" msgstr "Py_Initialize(C 函式)" -#: ../../c-api/init.rst:1600 +#: ../../c-api/init.rst:1752 msgid "close (in module os)" msgstr "close(os 模組中)" -#~ msgid ":c:func:`Py_SetPath`" -#~ msgstr ":c:func:`Py_SetPath`" +#~ msgid ":ref:`Availability `: Windows." +#~ msgstr ":ref:`適用 `:Windows。" #~ msgid ":c:func:`Py_SetStandardStreamEncoding`" #~ msgstr ":c:func:`Py_SetStandardStreamEncoding`" diff --git a/c-api/init_config.po b/c-api/init_config.po index a51f220060..828fea6d8e 100644 --- a/c-api/init_config.po +++ b/c-api/init_config.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-04-24 05:56+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-" @@ -573,7 +573,7 @@ msgid "" "`~PyPreConfig.parse_argv` of *preconfig* is non-zero." msgstr "" -#: ../../c-api/init_config.rst:401 ../../c-api/init_config.rst:1360 +#: ../../c-api/init_config.rst:401 ../../c-api/init_config.rst:1359 msgid "" "The caller is responsible to handle exceptions (error or exit) using :c:func:" "`PyStatus_Exception` and :c:func:`Py_ExitStatusException`." @@ -1839,19 +1839,17 @@ msgstr "" msgid "The ``show_alloc_count`` field has been removed." msgstr "" -#: ../../c-api/init_config.rst:1352 -msgid "Initialization with PyConfig" -msgstr "" - #: ../../c-api/init_config.rst:1354 -msgid "Function to initialize Python:" +msgid "Initialization with PyConfig" msgstr "" -#: ../../c-api/init_config.rst:1358 -msgid "Initialize Python from *config* configuration." +#: ../../c-api/init_config.rst:1356 +msgid "" +"Initializing the interpreter from a populated configuration struct is " +"handled by calling :c:func:`Py_InitializeFromConfig`." msgstr "" -#: ../../c-api/init_config.rst:1363 +#: ../../c-api/init_config.rst:1362 msgid "" "If :c:func:`PyImport_FrozenModules`, :c:func:`PyImport_AppendInittab` or :c:" "func:`PyImport_ExtendInittab` are used, they must be set or called after " @@ -1860,17 +1858,17 @@ msgid "" "`PyImport_ExtendInittab` must be called before each Python initialization." msgstr "" -#: ../../c-api/init_config.rst:1370 +#: ../../c-api/init_config.rst:1369 msgid "" "The current configuration (``PyConfig`` type) is stored in " "``PyInterpreterState.config``." msgstr "" -#: ../../c-api/init_config.rst:1373 +#: ../../c-api/init_config.rst:1372 msgid "Example setting the program name::" msgstr "" -#: ../../c-api/init_config.rst:1375 +#: ../../c-api/init_config.rst:1374 msgid "" "void init_python(void)\n" "{\n" @@ -1924,7 +1922,7 @@ msgstr "" " Py_ExitStatusException(status);\n" "}" -#: ../../c-api/init_config.rst:1401 +#: ../../c-api/init_config.rst:1400 msgid "" "More complete example modifying the default configuration, read the " "configuration, and then override some parameters. Note that since 3.11, many " @@ -1933,7 +1931,7 @@ msgid "" "called will be left unchanged by initialization::" msgstr "" -#: ../../c-api/init_config.rst:1408 +#: ../../c-api/init_config.rst:1407 msgid "" "PyStatus init_python(const char *program_name)\n" "{\n" @@ -1988,18 +1986,18 @@ msgid "" "}" msgstr "" -#: ../../c-api/init_config.rst:1464 +#: ../../c-api/init_config.rst:1463 msgid "Isolated Configuration" msgstr "" -#: ../../c-api/init_config.rst:1466 +#: ../../c-api/init_config.rst:1465 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:1471 +#: ../../c-api/init_config.rst:1470 msgid "" "This configuration ignores global configuration variables, environment " "variables, command line arguments (:c:member:`PyConfig.argv` is not parsed) " @@ -2007,115 +2005,115 @@ msgid "" "LC_CTYPE locale are left unchanged. Signal handlers are not installed." msgstr "" -#: ../../c-api/init_config.rst:1476 +#: ../../c-api/init_config.rst:1475 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:1484 +#: ../../c-api/init_config.rst:1483 msgid "Python Configuration" msgstr "" -#: ../../c-api/init_config.rst:1486 +#: ../../c-api/init_config.rst:1485 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:1490 +#: ../../c-api/init_config.rst:1489 msgid "" "Environments variables and command line arguments are used to configure " "Python, whereas global configuration variables are ignored." msgstr "" -#: ../../c-api/init_config.rst:1493 +#: ../../c-api/init_config.rst:1492 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:1502 +#: ../../c-api/init_config.rst:1501 msgid "Python Path Configuration" msgstr "" -#: ../../c-api/init_config.rst:1504 +#: ../../c-api/init_config.rst:1503 msgid ":c:type:`PyConfig` contains multiple fields for the path configuration:" msgstr "" -#: ../../c-api/init_config.rst:1506 +#: ../../c-api/init_config.rst:1505 msgid "Path configuration inputs:" msgstr "" -#: ../../c-api/init_config.rst:1508 +#: ../../c-api/init_config.rst:1507 msgid ":c:member:`PyConfig.home`" msgstr ":c:member:`PyConfig.home`" -#: ../../c-api/init_config.rst:1509 +#: ../../c-api/init_config.rst:1508 msgid ":c:member:`PyConfig.platlibdir`" msgstr ":c:member:`PyConfig.platlibdir`" -#: ../../c-api/init_config.rst:1510 +#: ../../c-api/init_config.rst:1509 msgid ":c:member:`PyConfig.pathconfig_warnings`" msgstr ":c:member:`PyConfig.pathconfig_warnings`" -#: ../../c-api/init_config.rst:1511 +#: ../../c-api/init_config.rst:1510 msgid ":c:member:`PyConfig.program_name`" msgstr ":c:member:`PyConfig.program_name`" -#: ../../c-api/init_config.rst:1512 +#: ../../c-api/init_config.rst:1511 msgid ":c:member:`PyConfig.pythonpath_env`" msgstr ":c:member:`PyConfig.pythonpath_env`" -#: ../../c-api/init_config.rst:1513 +#: ../../c-api/init_config.rst:1512 msgid "current working directory: to get absolute paths" msgstr "" -#: ../../c-api/init_config.rst:1514 +#: ../../c-api/init_config.rst:1513 msgid "" "``PATH`` environment variable to get the program full path (from :c:member:" "`PyConfig.program_name`)" msgstr "" -#: ../../c-api/init_config.rst:1516 +#: ../../c-api/init_config.rst:1515 msgid "``__PYVENV_LAUNCHER__`` environment variable" msgstr "``__PYVENV_LAUNCHER__`` 環境變數" -#: ../../c-api/init_config.rst:1517 +#: ../../c-api/init_config.rst:1516 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:1521 +#: ../../c-api/init_config.rst:1520 msgid "Path configuration output fields:" msgstr "" -#: ../../c-api/init_config.rst:1523 +#: ../../c-api/init_config.rst:1522 msgid ":c:member:`PyConfig.base_exec_prefix`" msgstr ":c:member:`PyConfig.base_exec_prefix`" -#: ../../c-api/init_config.rst:1524 +#: ../../c-api/init_config.rst:1523 msgid ":c:member:`PyConfig.base_executable`" msgstr ":c:member:`PyConfig.base_executable`" -#: ../../c-api/init_config.rst:1525 +#: ../../c-api/init_config.rst:1524 msgid ":c:member:`PyConfig.base_prefix`" msgstr ":c:member:`PyConfig.base_prefix`" -#: ../../c-api/init_config.rst:1526 +#: ../../c-api/init_config.rst:1525 msgid ":c:member:`PyConfig.exec_prefix`" msgstr ":c:member:`PyConfig.exec_prefix`" -#: ../../c-api/init_config.rst:1527 +#: ../../c-api/init_config.rst:1526 msgid ":c:member:`PyConfig.executable`" msgstr ":c:member:`PyConfig.executable`" -#: ../../c-api/init_config.rst:1528 +#: ../../c-api/init_config.rst:1527 msgid "" ":c:member:`PyConfig.module_search_paths_set`, :c:member:`PyConfig." "module_search_paths`" @@ -2123,11 +2121,11 @@ msgstr "" ":c:member:`PyConfig.module_search_paths_set`, :c:member:`PyConfig." "module_search_paths`" -#: ../../c-api/init_config.rst:1530 +#: ../../c-api/init_config.rst:1529 msgid ":c:member:`PyConfig.prefix`" msgstr ":c:member:`PyConfig.prefix`" -#: ../../c-api/init_config.rst:1532 +#: ../../c-api/init_config.rst:1531 msgid "" "If at least one \"output field\" is not set, Python calculates the path " "configuration to fill unset fields. If :c:member:`~PyConfig." @@ -2136,7 +2134,7 @@ msgid "" "module_search_paths_set` is set to ``1``." msgstr "" -#: ../../c-api/init_config.rst:1538 +#: ../../c-api/init_config.rst:1537 msgid "" "It is possible to completely ignore the function calculating the default " "path configuration by setting explicitly all path configuration output " @@ -2146,52 +2144,52 @@ msgid "" "modification." msgstr "" -#: ../../c-api/init_config.rst:1545 +#: ../../c-api/init_config.rst:1544 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:1548 +#: ../../c-api/init_config.rst:1547 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:1552 +#: ../../c-api/init_config.rst:1551 msgid ":c:func:`Py_RunMain` and :c:func:`Py_Main` modify :data:`sys.path`:" msgstr "" -#: ../../c-api/init_config.rst:1554 +#: ../../c-api/init_config.rst:1553 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:1557 +#: ../../c-api/init_config.rst:1556 msgid "If :c:member:`~PyConfig.isolated` is zero:" msgstr "" -#: ../../c-api/init_config.rst:1559 +#: ../../c-api/init_config.rst:1558 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:1561 +#: ../../c-api/init_config.rst:1560 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:1563 +#: ../../c-api/init_config.rst:1562 msgid "Otherwise, prepend an empty string to :data:`sys.path`." msgstr "" -#: ../../c-api/init_config.rst:1565 +#: ../../c-api/init_config.rst:1564 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." @@ -2200,170 +2198,143 @@ msgid "" "data:`sys.path`." msgstr "" -#: ../../c-api/init_config.rst:1571 +#: ../../c-api/init_config.rst:1570 msgid "The following configuration files are used by the path configuration:" msgstr "" -#: ../../c-api/init_config.rst:1573 +#: ../../c-api/init_config.rst:1572 msgid "``pyvenv.cfg``" msgstr "``pyvenv.cfg``" -#: ../../c-api/init_config.rst:1574 +#: ../../c-api/init_config.rst:1573 msgid "``._pth`` file (ex: ``python._pth``)" msgstr "" -#: ../../c-api/init_config.rst:1575 +#: ../../c-api/init_config.rst:1574 msgid "``pybuilddir.txt`` (Unix only)" msgstr "" -#: ../../c-api/init_config.rst:1577 +#: ../../c-api/init_config.rst:1576 msgid "If a ``._pth`` file is present:" msgstr "" -#: ../../c-api/init_config.rst:1579 +#: ../../c-api/init_config.rst:1578 msgid "Set :c:member:`~PyConfig.isolated` to ``1``." msgstr "將 :c:member:`~PyConfig.isolated` 設定為 ``1``。" -#: ../../c-api/init_config.rst:1580 +#: ../../c-api/init_config.rst:1579 msgid "Set :c:member:`~PyConfig.use_environment` to ``0``." msgstr "將 :c:member:`~PyConfig.use_environment` 設定為 ``0``。" -#: ../../c-api/init_config.rst:1581 +#: ../../c-api/init_config.rst:1580 msgid "Set :c:member:`~PyConfig.site_import` to ``0``." msgstr "將 :c:member:`~PyConfig.site_import` 設定為 ``0``。" -#: ../../c-api/init_config.rst:1582 +#: ../../c-api/init_config.rst:1581 msgid "Set :c:member:`~PyConfig.safe_path` to ``1``." msgstr "將 :c:member:`~PyConfig.safe_path` 設定為 ``1``。" -#: ../../c-api/init_config.rst:1584 +#: ../../c-api/init_config.rst:1583 msgid "" "The ``__PYVENV_LAUNCHER__`` environment variable is used to set :c:member:" "`PyConfig.base_executable`." msgstr "" -#: ../../c-api/init_config.rst:1589 -msgid "Py_RunMain()" -msgstr "Py_RunMain()" - -#: ../../c-api/init_config.rst:1593 -msgid "" -"Execute the command (:c:member:`PyConfig.run_command`), the script (:c:" -"member:`PyConfig.run_filename`) or the module (:c:member:`PyConfig." -"run_module`) specified on the command line or in the configuration." -msgstr "" - -#: ../../c-api/init_config.rst:1598 -msgid "By default and when if :option:`-i` option is used, run the REPL." -msgstr "" - -#: ../../c-api/init_config.rst:1600 -msgid "" -"Finally, finalizes Python and returns an exit status that can be passed to " -"the ``exit()`` function." -msgstr "" - -#: ../../c-api/init_config.rst:1603 -msgid "" -"See :ref:`Python Configuration ` for an example of " -"customized Python always running in isolated mode using :c:func:`Py_RunMain`." -msgstr "" - -#: ../../c-api/init_config.rst:1609 +#: ../../c-api/init_config.rst:1588 msgid "Py_GetArgcArgv()" msgstr "Py_GetArgcArgv()" -#: ../../c-api/init_config.rst:1613 +#: ../../c-api/init_config.rst:1592 msgid "Get the original command line arguments, before Python modified them." msgstr "" -#: ../../c-api/init_config.rst:1615 +#: ../../c-api/init_config.rst:1594 msgid "See also :c:member:`PyConfig.orig_argv` member." msgstr "" -#: ../../c-api/init_config.rst:1619 +#: ../../c-api/init_config.rst:1598 msgid "Multi-Phase Initialization Private Provisional API" msgstr "" -#: ../../c-api/init_config.rst:1621 +#: ../../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:1624 +#: ../../c-api/init_config.rst:1603 msgid "\"Core\" initialization phase, \"bare minimum Python\":" msgstr "" -#: ../../c-api/init_config.rst:1626 +#: ../../c-api/init_config.rst:1605 msgid "Builtin types;" msgstr "內建型別;" -#: ../../c-api/init_config.rst:1627 +#: ../../c-api/init_config.rst:1606 msgid "Builtin exceptions;" msgstr "內建例外;" -#: ../../c-api/init_config.rst:1628 +#: ../../c-api/init_config.rst:1607 msgid "Builtin and frozen modules;" msgstr "" -#: ../../c-api/init_config.rst:1629 +#: ../../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:1632 +#: ../../c-api/init_config.rst:1611 msgid "\"Main\" initialization phase, Python is fully initialized:" msgstr "" -#: ../../c-api/init_config.rst:1634 +#: ../../c-api/init_config.rst:1613 msgid "Install and configure :mod:`importlib`;" msgstr "" -#: ../../c-api/init_config.rst:1635 +#: ../../c-api/init_config.rst:1614 msgid "Apply the :ref:`Path Configuration `;" msgstr "" -#: ../../c-api/init_config.rst:1636 +#: ../../c-api/init_config.rst:1615 msgid "Install signal handlers;" msgstr "" -#: ../../c-api/init_config.rst:1637 +#: ../../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:1639 +#: ../../c-api/init_config.rst:1618 msgid "" "Enable optional features like :mod:`faulthandler` and :mod:`tracemalloc`;" msgstr "" -#: ../../c-api/init_config.rst:1640 +#: ../../c-api/init_config.rst:1619 msgid "Import the :mod:`site` module;" msgstr "引入 :mod:`site` 模組;" -#: ../../c-api/init_config.rst:1641 +#: ../../c-api/init_config.rst:1620 msgid "etc." msgstr "" -#: ../../c-api/init_config.rst:1643 +#: ../../c-api/init_config.rst:1622 msgid "Private provisional API:" msgstr "" -#: ../../c-api/init_config.rst:1645 +#: ../../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:1650 +#: ../../c-api/init_config.rst:1629 msgid "" "Move to the \"Main\" initialization phase, finish the Python initialization." msgstr "" -#: ../../c-api/init_config.rst:1652 +#: ../../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 " @@ -2372,14 +2343,14 @@ msgid "" "maybe install a custom :data:`sys.meta_path` importer or an import hook, etc." msgstr "" -#: ../../c-api/init_config.rst:1658 +#: ../../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." msgstr "" -#: ../../c-api/init_config.rst:1662 +#: ../../c-api/init_config.rst:1641 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 " @@ -2387,13 +2358,13 @@ msgid "" "until a proper public API is designed." msgstr "" -#: ../../c-api/init_config.rst:1667 +#: ../../c-api/init_config.rst:1646 msgid "" "Example running Python code between \"Core\" and \"Main\" initialization " "phases::" msgstr "" -#: ../../c-api/init_config.rst:1670 +#: ../../c-api/init_config.rst:1649 msgid "" "void init_python(void)\n" "{\n" @@ -2438,5 +2409,8 @@ msgstr "" msgid "argv (in module sys)" msgstr "" +#~ msgid "Py_RunMain()" +#~ msgstr "Py_RunMain()" + #~ msgid "Command line arguments: :data:`sys.argv`." #~ msgstr "命令列引數::data:`sys.argv`。" diff --git a/c-api/intro.po b/c-api/intro.po index 9854c7f4d0..458588d6ba 100644 --- a/c-api/intro.po +++ b/c-api/intro.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-05-04 20:08+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-" @@ -253,9 +253,10 @@ msgid "Return the absolute value of ``x``." msgstr "回傳 ``x`` 的絕對值。" #: ../../c-api/intro.rst:140 +#, fuzzy msgid "" "Ask the compiler to always inline a static inline function. The compiler can " -"ignore it and decides to not inline the function." +"ignore it and decide to not inline the function." msgstr "" "要求編譯器總是嵌入靜態行內函式 (static inline function),編譯器可以忽略它並決" "定不嵌入該函式。" diff --git a/c-api/long.po b/c-api/long.po index 7abcaaf2c1..5aac705341 100644 --- a/c-api/long.po +++ b/c-api/long.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2024-10-28 06:59+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-" @@ -166,41 +166,52 @@ msgid "" "most-significant bit is not a sign bit. Flags other than endian are ignored." msgstr "" -#: ../../c-api/long.rst:149 ../../c-api/long.rst:175 +#: ../../c-api/long.rst:148 ../../c-api/long.rst:184 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:153 +#: ../../c-api/long.rst:152 msgid "" "Raise :exc:`OverflowError` if the value of *obj* is out of range for a :c:" "expr:`long`." msgstr "" -#: ../../c-api/long.rst:156 ../../c-api/long.rst:184 ../../c-api/long.rst:205 -#: ../../c-api/long.rst:225 ../../c-api/long.rst:248 +#: ../../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 msgid "Returns ``-1`` on error. Use :c:func:`PyErr_Occurred` to disambiguate." msgstr "" -#: ../../c-api/long.rst:158 ../../c-api/long.rst:186 ../../c-api/long.rst:207 -#: ../../c-api/long.rst:229 ../../c-api/long.rst:313 ../../c-api/long.rst:333 +#: ../../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 msgid "Use :meth:`~object.__index__` if available." msgstr "" -#: ../../c-api/long.rst:161 ../../c-api/long.rst:189 ../../c-api/long.rst:210 -#: ../../c-api/long.rst:232 ../../c-api/long.rst:316 ../../c-api/long.rst:336 +#: ../../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 msgid "This function will no longer use :meth:`~object.__int__`." msgstr "" #: ../../c-api/long.rst:167 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 +msgid "The function is soft deprecated." +msgstr "" + +#: ../../c-api/long.rst:176 +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:179 +#: ../../c-api/long.rst:188 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 " @@ -208,20 +219,20 @@ msgid "" "exception occurs set *\\*overflow* to ``0`` and return ``-1`` as usual." msgstr "" -#: ../../c-api/long.rst:198 ../../c-api/long.rst:216 +#: ../../c-api/long.rst:207 ../../c-api/long.rst:225 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:202 +#: ../../c-api/long.rst:211 msgid "" "Raise :exc:`OverflowError` if the value of *obj* is out of range for a :c:" "expr:`long long`." msgstr "" -#: ../../c-api/long.rst:220 +#: ../../c-api/long.rst:229 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 " @@ -229,133 +240,133 @@ msgid "" "exception occurs set *\\*overflow* to ``0`` and return ``-1`` as usual." msgstr "" -#: ../../c-api/long.rst:242 +#: ../../c-api/long.rst:251 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:245 +#: ../../c-api/long.rst:254 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:257 +#: ../../c-api/long.rst:266 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:260 +#: ../../c-api/long.rst:269 msgid "" "Raise :exc:`OverflowError` if the value of *pylong* is out of range for a :c:" "expr:`unsigned long`." msgstr "" -#: ../../c-api/long.rst:263 +#: ../../c-api/long.rst:272 msgid "" "Returns ``(unsigned long)-1`` on error. Use :c:func:`PyErr_Occurred` to " "disambiguate." msgstr "" -#: ../../c-api/long.rst:273 +#: ../../c-api/long.rst:282 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:276 +#: ../../c-api/long.rst:285 msgid "" "Raise :exc:`OverflowError` if the value of *pylong* is out of range for a :c:" "type:`size_t`." msgstr "" -#: ../../c-api/long.rst:279 +#: ../../c-api/long.rst:288 msgid "" "Returns ``(size_t)-1`` on error. Use :c:func:`PyErr_Occurred` to " "disambiguate." msgstr "" -#: ../../c-api/long.rst:288 +#: ../../c-api/long.rst:297 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:291 +#: ../../c-api/long.rst:300 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:294 +#: ../../c-api/long.rst:303 msgid "" "Returns ``(unsigned long long)-1`` on error. Use :c:func:`PyErr_Occurred` to " "disambiguate." msgstr "" -#: ../../c-api/long.rst:297 +#: ../../c-api/long.rst:306 msgid "" "A negative *pylong* now raises :exc:`OverflowError`, not :exc:`TypeError`." msgstr "" -#: ../../c-api/long.rst:303 +#: ../../c-api/long.rst:312 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:307 +#: ../../c-api/long.rst:316 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:310 +#: ../../c-api/long.rst:319 msgid "" "Returns ``(unsigned long)-1`` on error. Use :c:func:`PyErr_Occurred` to " "disambiguate." msgstr "" -#: ../../c-api/long.rst:322 +#: ../../c-api/long.rst:331 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:327 +#: ../../c-api/long.rst:336 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:330 +#: ../../c-api/long.rst:339 msgid "" "Returns ``(unsigned long long)-1`` on error. Use :c:func:`PyErr_Occurred` " "to disambiguate." msgstr "" -#: ../../c-api/long.rst:342 +#: ../../c-api/long.rst:351 msgid "" "Return a C :c:expr:`double` representation of *pylong*. *pylong* must be an " "instance of :c:type:`PyLongObject`." msgstr "" -#: ../../c-api/long.rst:345 +#: ../../c-api/long.rst:354 msgid "" "Raise :exc:`OverflowError` if the value of *pylong* is out of range for a :c:" "expr:`double`." msgstr "" -#: ../../c-api/long.rst:348 +#: ../../c-api/long.rst:357 msgid "" "Returns ``-1.0`` on error. Use :c:func:`PyErr_Occurred` to disambiguate." msgstr "" -#: ../../c-api/long.rst:353 +#: ../../c-api/long.rst:362 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 " @@ -363,33 +374,33 @@ msgid "" "c:func:`PyLong_FromVoidPtr`." msgstr "" -#: ../../c-api/long.rst:358 +#: ../../c-api/long.rst:367 msgid "" "Returns ``NULL`` on error. Use :c:func:`PyErr_Occurred` to disambiguate." msgstr "" -#: ../../c-api/long.rst:363 +#: ../../c-api/long.rst:372 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:367 +#: ../../c-api/long.rst:376 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:371 +#: ../../c-api/long.rst:380 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:376 +#: ../../c-api/long.rst:385 msgid "" "If the returned value is greater than than *n_bytes*, the value was " "truncated: as many of the lowest bits of the value as could fit are written, " @@ -397,25 +408,25 @@ msgid "" "style downcast." msgstr "" -#: ../../c-api/long.rst:383 +#: ../../c-api/long.rst:392 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:386 +#: ../../c-api/long.rst:395 msgid "``0`` will never be returned." msgstr "" -#: ../../c-api/long.rst:388 +#: ../../c-api/long.rst:397 msgid "Values are always copied as two's-complement." msgstr "" -#: ../../c-api/long.rst:390 +#: ../../c-api/long.rst:399 msgid "Usage example::" msgstr "" -#: ../../c-api/long.rst:392 +#: ../../c-api/long.rst:401 msgid "" "int32_t value;\n" "Py_ssize_t bytes = PyLong_AsNativeBytes(pylong, &value, sizeof(value), -1);\n" @@ -432,26 +443,26 @@ msgid "" "}" msgstr "" -#: ../../c-api/long.rst:406 +#: ../../c-api/long.rst:415 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:413 +#: ../../c-api/long.rst:422 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:416 +#: ../../c-api/long.rst:425 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:419 +#: ../../c-api/long.rst:428 msgid "" "// Ask how much space we need.\n" "Py_ssize_t expected = PyLong_AsNativeBytes(pylong, NULL, 0, -1);\n" @@ -482,69 +493,69 @@ msgid "" "free(bignum);" msgstr "" -#: ../../c-api/long.rst:447 +#: ../../c-api/long.rst:456 msgid "" "*flags* is either ``-1`` (``Py_ASNATIVEBYTES_DEFAULTS``) to select defaults " -"that behave most like a C cast, or a combintation of the other flags in the " +"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:452 +#: ../../c-api/long.rst:461 msgid "" "Currently, ``-1`` corresponds to ``Py_ASNATIVEBYTES_NATIVE_ENDIAN | " "Py_ASNATIVEBYTES_UNSIGNED_BUFFER``." msgstr "" -#: ../../c-api/long.rst:456 +#: ../../c-api/long.rst:467 msgid "Flag" msgstr "" -#: ../../c-api/long.rst:456 +#: ../../c-api/long.rst:467 msgid "Value" msgstr "" -#: ../../c-api/long.rst:458 +#: ../../c-api/long.rst:469 msgid "``-1``" msgstr "" -#: ../../c-api/long.rst:459 +#: ../../c-api/long.rst:470 msgid "``0``" msgstr "" -#: ../../c-api/long.rst:460 +#: ../../c-api/long.rst:471 msgid "``1``" msgstr "" -#: ../../c-api/long.rst:461 +#: ../../c-api/long.rst:472 msgid "``3``" msgstr "" -#: ../../c-api/long.rst:462 +#: ../../c-api/long.rst:473 msgid "``4``" msgstr "" -#: ../../c-api/long.rst:463 +#: ../../c-api/long.rst:474 msgid "``8``" msgstr "" -#: ../../c-api/long.rst:464 +#: ../../c-api/long.rst:475 msgid "``16``" msgstr "" -#: ../../c-api/long.rst:467 +#: ../../c-api/long.rst:478 msgid "" "Specifying ``Py_ASNATIVEBYTES_NATIVE_ENDIAN`` will override any other endian " "flags. Passing ``2`` is reserved." msgstr "" -#: ../../c-api/long.rst:470 +#: ../../c-api/long.rst:481 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:474 +#: ../../c-api/long.rst:485 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 " @@ -554,7 +565,7 @@ msgid "" "requested." msgstr "" -#: ../../c-api/long.rst:481 +#: ../../c-api/long.rst:492 msgid "" "Specifying ``Py_ASNATIVEBYTES_REJECT_NEGATIVE`` causes an exception to be " "set if *pylong* is negative. Without this flag, negative values will be " @@ -562,7 +573,7 @@ msgid "" "of whether ``Py_ASNATIVEBYTES_UNSIGNED_BUFFER`` was specified." msgstr "" -#: ../../c-api/long.rst:486 +#: ../../c-api/long.rst:497 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 " @@ -572,7 +583,7 @@ msgid "" "`TypeError`." msgstr "" -#: ../../c-api/long.rst:495 +#: ../../c-api/long.rst:506 msgid "" "With the default *flags* (``-1``, or *UNSIGNED_BUFFER* without " "*REJECT_NEGATIVE*), multiple Python integers can map to a single value " @@ -580,22 +591,22 @@ msgid "" "buffer and set all its bits. This matches typical C cast behavior." msgstr "" -#: ../../c-api/long.rst:506 +#: ../../c-api/long.rst:517 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:510 +#: ../../c-api/long.rst:521 msgid "On failure, return ``NULL`` with an exception set." msgstr "在失敗時,會回傳 ``NULL`` 並設定例外。" -#: ../../c-api/long.rst:517 +#: ../../c-api/long.rst:528 msgid "Return 1 if *op* is compact, 0 otherwise." msgstr "" -#: ../../c-api/long.rst:519 +#: ../../c-api/long.rst:530 msgid "" "This function makes it possible for performance-critical code to implement a " "“fast path” for small integers. For compact values use :c:func:" @@ -603,23 +614,23 @@ msgid "" "`PyLong_As* ` function or :c:func:`PyLong_AsNativeBytes`." msgstr "" -#: ../../c-api/long.rst:525 +#: ../../c-api/long.rst:536 msgid "The speedup is expected to be negligible for most users." msgstr "" -#: ../../c-api/long.rst:527 +#: ../../c-api/long.rst:538 msgid "" "Exactly what values are considered compact is an implementation detail and " "is subject to change." msgstr "" -#: ../../c-api/long.rst:532 +#: ../../c-api/long.rst:546 msgid "" "If *op* is compact, as determined by :c:func:`PyUnstable_Long_IsCompact`, " "return its value." msgstr "" -#: ../../c-api/long.rst:535 +#: ../../c-api/long.rst:549 msgid "Otherwise, the return value is undefined." msgstr "" @@ -635,23 +646,23 @@ msgstr "long integer(長整数)" msgid "integer" msgstr "integer(整数)" -#: ../../c-api/long.rst:145 +#: ../../c-api/long.rst:144 msgid "LONG_MAX (C macro)" msgstr "LONG_MAX(C 巨集)" -#: ../../c-api/long.rst:145 ../../c-api/long.rst:195 ../../c-api/long.rst:238 -#: ../../c-api/long.rst:253 ../../c-api/long.rst:269 ../../c-api/long.rst:285 +#: ../../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 msgid "OverflowError (built-in exception)" msgstr "OverflowError(内建例外)" -#: ../../c-api/long.rst:238 +#: ../../c-api/long.rst:247 msgid "PY_SSIZE_T_MAX (C macro)" msgstr "PY_SSIZE_T_MAX(C 巨集)" -#: ../../c-api/long.rst:253 +#: ../../c-api/long.rst:262 msgid "ULONG_MAX (C macro)" msgstr "ULONG_MAX(C 巨集)" -#: ../../c-api/long.rst:269 +#: ../../c-api/long.rst:278 msgid "SIZE_MAX (C macro)" msgstr "SIZE_MAX(C 巨集)" diff --git a/c-api/memory.po b/c-api/memory.po index 489366188e..e3b9669a9d 100644 --- a/c-api/memory.po +++ b/c-api/memory.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2024-09-24 07:20+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-" @@ -135,59 +135,70 @@ msgid "" "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 `. There is no hard requirement to use the memory returned by the " -"allocation functions belonging to a given domain for only the purposes " -"hinted by that domain (although this is the recommended practice). For " -"example, one could use the memory returned by :c:func:`PyMem_RawMalloc` for " -"allocating Python objects or the memory returned by :c:func:" -"`PyObject_Malloc` for allocating memory for buffers." +"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 "" -#: ../../c-api/memory.rst:112 +#: ../../c-api/memory.rst:109 msgid "The three allocation domains are:" msgstr "" -#: ../../c-api/memory.rst:114 +#: ../../c-api/memory.rst:111 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 to the system." +"directly from the system. See :ref:`Raw Memory Interface `." msgstr "" -#: ../../c-api/memory.rst:119 +#: ../../c-api/memory.rst:116 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." +"the :term:`GIL` held. The memory is taken from the Python private heap. See :" +"ref:`Memory Interface `." msgstr "" -#: ../../c-api/memory.rst:123 +#: ../../c-api/memory.rst:121 msgid "" -"Object domain: intended for allocating memory belonging to Python objects. " -"The memory is taken from the Python private heap." +"Object domain: intended for allocating memory for Python objects. The memory " +"is taken from the Python private heap. See :ref:`Object allocators " +"`." msgstr "" #: ../../c-api/memory.rst:126 msgid "" -"When freeing memory previously allocated by the allocating functions " -"belonging to a given domain,the matching specific deallocating functions " -"must be used. For example, :c:func:`PyMem_Free` must be used to free memory " -"allocated using :c:func:`PyMem_Malloc`." +"The :term:`free-threaded ` build requires that only Python " +"objects 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 "" -#: ../../c-api/memory.rst:131 -msgid "Raw Memory Interface" +#: ../../c-api/memory.rst:130 +msgid "" +"For example, buffers (non-Python objects) should be allocated using :c:func:" +"`PyMem_Malloc`, :c:func:`PyMem_RawMalloc`, or :c:func:`malloc`, but not :c:" +"func:`PyObject_Malloc`." msgstr "" #: ../../c-api/memory.rst:133 +msgid "See :ref:`Memory Allocation APIs `." +msgstr "" + +#: ../../c-api/memory.rst:139 +msgid "Raw Memory Interface" +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." msgstr "" -#: ../../c-api/memory.rst:137 +#: ../../c-api/memory.rst:145 msgid "" "The :ref:`default raw memory allocator ` uses the " "following functions: :c:func:`malloc`, :c:func:`calloc`, :c:func:`realloc` " @@ -195,63 +206,63 @@ msgid "" "requesting zero bytes." msgstr "" -#: ../../c-api/memory.rst:146 ../../c-api/memory.rst:217 -#: ../../c-api/memory.rst:325 +#: ../../c-api/memory.rst:154 ../../c-api/memory.rst:225 +#: ../../c-api/memory.rst:335 msgid "" "Allocates *n* bytes and returns a pointer of type :c:expr:`void*` to the " "allocated memory, or ``NULL`` if the request fails." msgstr "" -#: ../../c-api/memory.rst:149 +#: ../../c-api/memory.rst:157 msgid "" "Requesting zero bytes returns a distinct non-``NULL`` pointer if possible, " "as if ``PyMem_RawMalloc(1)`` had been called instead. The memory will not " "have been initialized in any way." msgstr "" -#: ../../c-api/memory.rst:156 ../../c-api/memory.rst:227 -#: ../../c-api/memory.rst:335 +#: ../../c-api/memory.rst:164 ../../c-api/memory.rst:235 +#: ../../c-api/memory.rst:345 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 " "the request fails. The memory is initialized to zeros." msgstr "" -#: ../../c-api/memory.rst:160 +#: ../../c-api/memory.rst:168 msgid "" "Requesting zero elements or elements of size zero bytes returns a distinct " "non-``NULL`` pointer if possible, as if ``PyMem_RawCalloc(1, 1)`` had been " "called instead." msgstr "" -#: ../../c-api/memory.rst:169 ../../c-api/memory.rst:240 -#: ../../c-api/memory.rst:348 +#: ../../c-api/memory.rst:177 ../../c-api/memory.rst:248 +#: ../../c-api/memory.rst:358 msgid "" "Resizes the memory block pointed to by *p* to *n* bytes. The contents will " "be unchanged to the minimum of the old and the new sizes." msgstr "" -#: ../../c-api/memory.rst:172 +#: ../../c-api/memory.rst:180 msgid "" "If *p* is ``NULL``, the call is equivalent to ``PyMem_RawMalloc(n)``; else " "if *n* is equal to zero, the memory block is resized but is not freed, and " "the returned pointer is non-``NULL``." msgstr "" -#: ../../c-api/memory.rst:176 +#: ../../c-api/memory.rst:184 msgid "" "Unless *p* is ``NULL``, it must have been returned by a previous call to :c:" "func:`PyMem_RawMalloc`, :c:func:`PyMem_RawRealloc` or :c:func:" "`PyMem_RawCalloc`." msgstr "" -#: ../../c-api/memory.rst:180 +#: ../../c-api/memory.rst:188 msgid "" "If the request fails, :c:func:`PyMem_RawRealloc` returns ``NULL`` and *p* " "remains a valid pointer to the previous memory area." msgstr "" -#: ../../c-api/memory.rst:186 +#: ../../c-api/memory.rst:194 msgid "" "Frees the memory block pointed to by *p*, which must have been returned by a " "previous call to :c:func:`PyMem_RawMalloc`, :c:func:`PyMem_RawRealloc` or :c:" @@ -259,73 +270,73 @@ msgid "" "called before, undefined behavior occurs." msgstr "" -#: ../../c-api/memory.rst:191 ../../c-api/memory.rst:261 -#: ../../c-api/memory.rst:369 +#: ../../c-api/memory.rst:199 ../../c-api/memory.rst:269 +#: ../../c-api/memory.rst:379 msgid "If *p* is ``NULL``, no operation is performed." msgstr "" -#: ../../c-api/memory.rst:197 +#: ../../c-api/memory.rst:205 msgid "Memory Interface" msgstr "記憶體介面" -#: ../../c-api/memory.rst:199 ../../c-api/memory.rst:305 +#: ../../c-api/memory.rst:207 ../../c-api/memory.rst:315 msgid "" "The following function sets, modeled after the ANSI C standard, but " "specifying behavior when requesting zero bytes, are available for allocating " "and releasing memory from the Python heap." msgstr "" -#: ../../c-api/memory.rst:203 +#: ../../c-api/memory.rst:211 msgid "" "The :ref:`default memory allocator ` uses the :" "ref:`pymalloc memory allocator `." msgstr "" -#: ../../c-api/memory.rst:208 ../../c-api/memory.rst:320 +#: ../../c-api/memory.rst:216 ../../c-api/memory.rst:330 msgid "" "The :term:`GIL ` must be held when using these " "functions." msgstr "" -#: ../../c-api/memory.rst:213 +#: ../../c-api/memory.rst:221 msgid "" "The default allocator is now pymalloc instead of system :c:func:`malloc`." msgstr "" -#: ../../c-api/memory.rst:220 +#: ../../c-api/memory.rst:228 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:231 +#: ../../c-api/memory.rst:239 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:243 +#: ../../c-api/memory.rst:251 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:247 +#: ../../c-api/memory.rst:255 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:250 +#: ../../c-api/memory.rst:258 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:256 +#: ../../c-api/memory.rst:264 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:" @@ -333,20 +344,20 @@ msgid "" "undefined behavior occurs." msgstr "" -#: ../../c-api/memory.rst:263 +#: ../../c-api/memory.rst:271 msgid "" "The following type-oriented macros are provided for convenience. Note that " "*TYPE* refers to any C type." msgstr "" -#: ../../c-api/memory.rst:269 +#: ../../c-api/memory.rst:277 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:276 +#: ../../c-api/memory.rst:284 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* " @@ -354,17 +365,17 @@ msgid "" "failure." msgstr "" -#: ../../c-api/memory.rst:281 +#: ../../c-api/memory.rst:289 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:287 +#: ../../c-api/memory.rst:295 msgid "Same as :c:func:`PyMem_Free`." msgstr "和 :c:func:`PyMem_Free` 相同。" -#: ../../c-api/memory.rst:289 +#: ../../c-api/memory.rst:297 msgid "" "In addition, the following macro sets are provided for calling the Python " "memory allocator directly, without involving the C API functions listed " @@ -372,35 +383,35 @@ msgid "" "across Python versions and is therefore deprecated in extension modules." msgstr "" -#: ../../c-api/memory.rst:294 +#: ../../c-api/memory.rst:302 msgid "``PyMem_MALLOC(size)``" msgstr "``PyMem_MALLOC(size)``" -#: ../../c-api/memory.rst:295 +#: ../../c-api/memory.rst:303 msgid "``PyMem_NEW(type, size)``" msgstr "``PyMem_NEW(type, size)``" -#: ../../c-api/memory.rst:296 +#: ../../c-api/memory.rst:304 msgid "``PyMem_REALLOC(ptr, size)``" msgstr "``PyMem_REALLOC(ptr, size)``" -#: ../../c-api/memory.rst:297 +#: ../../c-api/memory.rst:305 msgid "``PyMem_RESIZE(ptr, type, size)``" msgstr "``PyMem_RESIZE(ptr, type, size)``" -#: ../../c-api/memory.rst:298 +#: ../../c-api/memory.rst:306 msgid "``PyMem_FREE(ptr)``" msgstr "``PyMem_FREE(ptr)``" -#: ../../c-api/memory.rst:299 +#: ../../c-api/memory.rst:307 msgid "``PyMem_DEL(ptr)``" msgstr "``PyMem_DEL(ptr)``" -#: ../../c-api/memory.rst:303 +#: ../../c-api/memory.rst:313 msgid "Object allocators" msgstr "" -#: ../../c-api/memory.rst:310 +#: ../../c-api/memory.rst:320 msgid "" "There is no guarantee that the memory returned by these allocators can be " "successfully cast to a Python object when intercepting the allocating " @@ -408,47 +419,47 @@ msgid "" "Memory Allocators ` section." msgstr "" -#: ../../c-api/memory.rst:315 +#: ../../c-api/memory.rst:325 msgid "" "The :ref:`default object allocator ` uses the :" "ref:`pymalloc memory allocator `." msgstr "" -#: ../../c-api/memory.rst:328 +#: ../../c-api/memory.rst:338 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:339 +#: ../../c-api/memory.rst:349 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:351 +#: ../../c-api/memory.rst:361 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:355 +#: ../../c-api/memory.rst:365 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:358 +#: ../../c-api/memory.rst:368 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:364 +#: ../../c-api/memory.rst:374 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:" @@ -456,283 +467,283 @@ msgid "" "called before, undefined behavior occurs." msgstr "" -#: ../../c-api/memory.rst:375 +#: ../../c-api/memory.rst:385 msgid "Default Memory Allocators" msgstr "" -#: ../../c-api/memory.rst:377 +#: ../../c-api/memory.rst:387 msgid "Default memory allocators:" msgstr "" -#: ../../c-api/memory.rst:380 +#: ../../c-api/memory.rst:390 msgid "Configuration" msgstr "配置" -#: ../../c-api/memory.rst:380 +#: ../../c-api/memory.rst:390 msgid "Name" msgstr "名稱" -#: ../../c-api/memory.rst:380 +#: ../../c-api/memory.rst:390 msgid "PyMem_RawMalloc" msgstr "PyMem_RawMalloc" -#: ../../c-api/memory.rst:380 +#: ../../c-api/memory.rst:390 msgid "PyMem_Malloc" msgstr "PyMem_Malloc" -#: ../../c-api/memory.rst:380 +#: ../../c-api/memory.rst:390 msgid "PyObject_Malloc" msgstr "PyObject_Malloc" -#: ../../c-api/memory.rst:382 +#: ../../c-api/memory.rst:392 msgid "Release build" msgstr "" -#: ../../c-api/memory.rst:382 +#: ../../c-api/memory.rst:392 msgid "``\"pymalloc\"``" msgstr "``\"pymalloc\"``" -#: ../../c-api/memory.rst:382 ../../c-api/memory.rst:384 +#: ../../c-api/memory.rst:392 ../../c-api/memory.rst:394 msgid "``malloc``" msgstr "``malloc``" -#: ../../c-api/memory.rst:382 +#: ../../c-api/memory.rst:392 msgid "``pymalloc``" msgstr "``pymalloc``" -#: ../../c-api/memory.rst:383 +#: ../../c-api/memory.rst:393 msgid "Debug build" msgstr "" -#: ../../c-api/memory.rst:383 +#: ../../c-api/memory.rst:393 msgid "``\"pymalloc_debug\"``" msgstr "``\"pymalloc_debug\"``" -#: ../../c-api/memory.rst:383 ../../c-api/memory.rst:385 +#: ../../c-api/memory.rst:393 ../../c-api/memory.rst:395 msgid "``malloc`` + debug" msgstr "" -#: ../../c-api/memory.rst:383 +#: ../../c-api/memory.rst:393 msgid "``pymalloc`` + debug" msgstr "" -#: ../../c-api/memory.rst:384 +#: ../../c-api/memory.rst:394 msgid "Release build, without pymalloc" msgstr "" -#: ../../c-api/memory.rst:384 +#: ../../c-api/memory.rst:394 msgid "``\"malloc\"``" msgstr "``\"malloc\"``" -#: ../../c-api/memory.rst:385 +#: ../../c-api/memory.rst:395 msgid "Debug build, without pymalloc" msgstr "" -#: ../../c-api/memory.rst:385 +#: ../../c-api/memory.rst:395 msgid "``\"malloc_debug\"``" msgstr "``\"malloc_debug\"``" -#: ../../c-api/memory.rst:388 +#: ../../c-api/memory.rst:398 msgid "Legend:" msgstr "" -#: ../../c-api/memory.rst:390 +#: ../../c-api/memory.rst:400 msgid "Name: value for :envvar:`PYTHONMALLOC` environment variable." msgstr "" -#: ../../c-api/memory.rst:391 +#: ../../c-api/memory.rst:401 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:393 +#: ../../c-api/memory.rst:403 msgid "``pymalloc``: :ref:`pymalloc memory allocator `." msgstr "" -#: ../../c-api/memory.rst:394 +#: ../../c-api/memory.rst:404 msgid "" "``mimalloc``: :ref:`mimalloc memory allocator `. The pymalloc " "allocator will be used if mimalloc support isn't available." msgstr "" -#: ../../c-api/memory.rst:396 +#: ../../c-api/memory.rst:406 msgid "" "\"+ debug\": with :ref:`debug hooks on the Python memory allocators `." msgstr "" -#: ../../c-api/memory.rst:398 +#: ../../c-api/memory.rst:408 msgid "\"Debug build\": :ref:`Python build in debug mode `." msgstr "" -#: ../../c-api/memory.rst:403 +#: ../../c-api/memory.rst:413 msgid "Customize Memory Allocators" msgstr "" -#: ../../c-api/memory.rst:409 +#: ../../c-api/memory.rst:419 msgid "" "Structure used to describe a memory block allocator. The structure has the " "following fields:" msgstr "" -#: ../../c-api/memory.rst:413 ../../c-api/memory.rst:660 +#: ../../c-api/memory.rst:423 ../../c-api/memory.rst:670 msgid "Field" msgstr "欄位" -#: ../../c-api/memory.rst:413 ../../c-api/memory.rst:660 +#: ../../c-api/memory.rst:423 ../../c-api/memory.rst:670 msgid "Meaning" msgstr "意義" -#: ../../c-api/memory.rst:415 ../../c-api/memory.rst:662 +#: ../../c-api/memory.rst:425 ../../c-api/memory.rst:672 msgid "``void *ctx``" msgstr "``void *ctx``" -#: ../../c-api/memory.rst:415 ../../c-api/memory.rst:662 +#: ../../c-api/memory.rst:425 ../../c-api/memory.rst:672 msgid "user context passed as first argument" msgstr "" -#: ../../c-api/memory.rst:417 +#: ../../c-api/memory.rst:427 msgid "``void* malloc(void *ctx, size_t size)``" msgstr "``void* malloc(void *ctx, size_t size)``" -#: ../../c-api/memory.rst:417 +#: ../../c-api/memory.rst:427 msgid "allocate a memory block" msgstr "" -#: ../../c-api/memory.rst:419 +#: ../../c-api/memory.rst:429 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:419 +#: ../../c-api/memory.rst:429 msgid "allocate a memory block initialized with zeros" msgstr "" -#: ../../c-api/memory.rst:422 +#: ../../c-api/memory.rst:432 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:422 +#: ../../c-api/memory.rst:432 msgid "allocate or resize a memory block" msgstr "" -#: ../../c-api/memory.rst:424 +#: ../../c-api/memory.rst:434 msgid "``void free(void *ctx, void *ptr)``" msgstr "``void free(void *ctx, void *ptr)``" -#: ../../c-api/memory.rst:424 +#: ../../c-api/memory.rst:434 msgid "free a memory block" msgstr "" -#: ../../c-api/memory.rst:427 +#: ../../c-api/memory.rst:437 msgid "" "The :c:type:`!PyMemAllocator` structure was renamed to :c:type:" "`PyMemAllocatorEx` and a new ``calloc`` field was added." msgstr "" -#: ../../c-api/memory.rst:434 +#: ../../c-api/memory.rst:444 msgid "Enum used to identify an allocator domain. Domains:" msgstr "" -#: ../../c-api/memory.rst:440 ../../c-api/memory.rst:449 -#: ../../c-api/memory.rst:458 +#: ../../c-api/memory.rst:450 ../../c-api/memory.rst:459 +#: ../../c-api/memory.rst:468 msgid "Functions:" msgstr "函式:" -#: ../../c-api/memory.rst:442 +#: ../../c-api/memory.rst:452 msgid ":c:func:`PyMem_RawMalloc`" msgstr ":c:func:`PyMem_RawMalloc`" -#: ../../c-api/memory.rst:443 +#: ../../c-api/memory.rst:453 msgid ":c:func:`PyMem_RawRealloc`" msgstr ":c:func:`PyMem_RawRealloc`" -#: ../../c-api/memory.rst:444 +#: ../../c-api/memory.rst:454 msgid ":c:func:`PyMem_RawCalloc`" msgstr ":c:func:`PyMem_RawCalloc`" -#: ../../c-api/memory.rst:445 +#: ../../c-api/memory.rst:455 msgid ":c:func:`PyMem_RawFree`" msgstr ":c:func:`PyMem_RawFree`" -#: ../../c-api/memory.rst:451 +#: ../../c-api/memory.rst:461 msgid ":c:func:`PyMem_Malloc`," msgstr ":c:func:`PyMem_Malloc`," -#: ../../c-api/memory.rst:452 +#: ../../c-api/memory.rst:462 msgid ":c:func:`PyMem_Realloc`" msgstr ":c:func:`PyMem_Realloc`" -#: ../../c-api/memory.rst:453 +#: ../../c-api/memory.rst:463 msgid ":c:func:`PyMem_Calloc`" msgstr ":c:func:`PyMem_Calloc`" -#: ../../c-api/memory.rst:454 +#: ../../c-api/memory.rst:464 msgid ":c:func:`PyMem_Free`" msgstr ":c:func:`PyMem_Free`" -#: ../../c-api/memory.rst:460 +#: ../../c-api/memory.rst:470 msgid ":c:func:`PyObject_Malloc`" msgstr ":c:func:`PyObject_Malloc`" -#: ../../c-api/memory.rst:461 +#: ../../c-api/memory.rst:471 msgid ":c:func:`PyObject_Realloc`" msgstr ":c:func:`PyObject_Realloc`" -#: ../../c-api/memory.rst:462 +#: ../../c-api/memory.rst:472 msgid ":c:func:`PyObject_Calloc`" msgstr ":c:func:`PyObject_Calloc`" -#: ../../c-api/memory.rst:463 +#: ../../c-api/memory.rst:473 msgid ":c:func:`PyObject_Free`" msgstr ":c:func:`PyObject_Free`" -#: ../../c-api/memory.rst:467 +#: ../../c-api/memory.rst:477 msgid "Get the memory block allocator of the specified domain." msgstr "" -#: ../../c-api/memory.rst:472 +#: ../../c-api/memory.rst:482 msgid "Set the memory block allocator of the specified domain." msgstr "" -#: ../../c-api/memory.rst:474 +#: ../../c-api/memory.rst:484 msgid "" "The new allocator must return a distinct non-``NULL`` pointer when " "requesting zero bytes." msgstr "" -#: ../../c-api/memory.rst:477 +#: ../../c-api/memory.rst:487 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." msgstr "" -#: ../../c-api/memory.rst:481 +#: ../../c-api/memory.rst:491 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``." msgstr "" -#: ../../c-api/memory.rst:485 +#: ../../c-api/memory.rst:495 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:489 +#: ../../c-api/memory.rst:499 msgid "" "See also :c:member:`PyPreConfig.allocator` and :ref:`Preinitialize Python " "with PyPreConfig `." msgstr "" -#: ../../c-api/memory.rst:494 +#: ../../c-api/memory.rst:504 msgid ":c:func:`PyMem_SetAllocator` does have the following contract:" msgstr "" -#: ../../c-api/memory.rst:496 +#: ../../c-api/memory.rst:506 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 " @@ -742,7 +753,7 @@ msgid "" "domains>` for more information." msgstr "" -#: ../../c-api/memory.rst:504 +#: ../../c-api/memory.rst:514 msgid "" "If called after Python has finish initializing (after :c:func:" "`Py_InitializeFromConfig` has been called) the allocator **must** wrap the " @@ -750,21 +761,21 @@ msgid "" "arbitrary one is **not supported**." msgstr "" -#: ../../c-api/memory.rst:509 +#: ../../c-api/memory.rst:519 msgid "All allocators must be thread-safe." msgstr "" -#: ../../c-api/memory.rst:515 +#: ../../c-api/memory.rst:525 msgid "" "Setup :ref:`debug hooks in the Python memory allocators ` " "to detect memory errors." msgstr "" -#: ../../c-api/memory.rst:522 +#: ../../c-api/memory.rst:532 msgid "Debug hooks on the Python memory allocators" msgstr "" -#: ../../c-api/memory.rst:524 +#: ../../c-api/memory.rst:534 msgid "" "When :ref:`Python is built in debug mode `, the :c:func:" "`PyMem_SetupDebugHooks` function is called at the :ref:`Python " @@ -772,19 +783,19 @@ msgid "" "allocators to detect memory errors." msgstr "" -#: ../../c-api/memory.rst:529 +#: ../../c-api/memory.rst:539 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:532 +#: ../../c-api/memory.rst:542 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:535 +#: ../../c-api/memory.rst:545 msgid "" "These debug hooks fill dynamically allocated memory blocks with special, " "recognizable bit patterns. Newly allocated memory is filled with the byte " @@ -794,25 +805,25 @@ msgid "" "these bytes are unlikely to be valid addresses, floats, or ASCII strings." msgstr "" -#: ../../c-api/memory.rst:542 +#: ../../c-api/memory.rst:552 msgid "Runtime checks:" msgstr "Runtime 檢查:" -#: ../../c-api/memory.rst:544 +#: ../../c-api/memory.rst:554 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:546 +#: ../../c-api/memory.rst:556 msgid "Detect write before the start of the buffer (buffer underflow)." msgstr "" -#: ../../c-api/memory.rst:547 +#: ../../c-api/memory.rst:557 msgid "Detect write after the end of the buffer (buffer overflow)." msgstr "" -#: ../../c-api/memory.rst:548 +#: ../../c-api/memory.rst:558 msgid "" "Check that the :term:`GIL ` is held when allocator " "functions of :c:macro:`PYMEM_DOMAIN_OBJ` (ex: :c:func:`PyObject_Malloc`) " @@ -820,7 +831,7 @@ msgid "" "called." msgstr "" -#: ../../c-api/memory.rst:553 +#: ../../c-api/memory.rst:563 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 " @@ -828,7 +839,7 @@ msgid "" "memory block was traced." msgstr "" -#: ../../c-api/memory.rst:558 +#: ../../c-api/memory.rst:568 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 " @@ -838,49 +849,49 @@ msgid "" "from a Python slice):" msgstr "" -#: ../../c-api/memory.rst:564 +#: ../../c-api/memory.rst:574 msgid "``p[-2*S:-S]``" msgstr "``p[-2*S:-S]``" -#: ../../c-api/memory.rst:565 +#: ../../c-api/memory.rst:575 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:567 +#: ../../c-api/memory.rst:577 msgid "``p[-S]``" msgstr "``p[-S]``" -#: ../../c-api/memory.rst:568 +#: ../../c-api/memory.rst:578 msgid "API identifier (ASCII character):" msgstr "" -#: ../../c-api/memory.rst:570 +#: ../../c-api/memory.rst:580 msgid "``'r'`` for :c:macro:`PYMEM_DOMAIN_RAW`." msgstr "" -#: ../../c-api/memory.rst:571 +#: ../../c-api/memory.rst:581 msgid "``'m'`` for :c:macro:`PYMEM_DOMAIN_MEM`." msgstr "" -#: ../../c-api/memory.rst:572 +#: ../../c-api/memory.rst:582 msgid "``'o'`` for :c:macro:`PYMEM_DOMAIN_OBJ`." msgstr "" -#: ../../c-api/memory.rst:574 +#: ../../c-api/memory.rst:584 msgid "``p[-S+1:0]``" msgstr "``p[-S+1:0]``" -#: ../../c-api/memory.rst:575 +#: ../../c-api/memory.rst:585 msgid "Copies of PYMEM_FORBIDDENBYTE. Used to catch under- writes and reads." msgstr "" -#: ../../c-api/memory.rst:577 +#: ../../c-api/memory.rst:587 msgid "``p[0:N]``" msgstr "``p[0:N]``" -#: ../../c-api/memory.rst:578 +#: ../../c-api/memory.rst:588 msgid "" "The requested memory, filled with copies of PYMEM_CLEANBYTE, used to catch " "reference to uninitialized memory. When a realloc-like function is called " @@ -891,25 +902,25 @@ msgid "" "bytes are also filled with PYMEM_DEADBYTE." msgstr "" -#: ../../c-api/memory.rst:586 +#: ../../c-api/memory.rst:596 msgid "``p[N:N+S]``" msgstr "``p[N:N+S]``" -#: ../../c-api/memory.rst:587 +#: ../../c-api/memory.rst:597 msgid "Copies of PYMEM_FORBIDDENBYTE. Used to catch over- writes and reads." msgstr "" -#: ../../c-api/memory.rst:589 +#: ../../c-api/memory.rst:599 msgid "``p[N+S:N+2*S]``" msgstr "``p[N+S:N+2*S]``" -#: ../../c-api/memory.rst:590 +#: ../../c-api/memory.rst:600 msgid "" "Only used if the ``PYMEM_DEBUG_SERIALNO`` macro is defined (not defined by " "default)." msgstr "" -#: ../../c-api/memory.rst:593 +#: ../../c-api/memory.rst:603 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 " @@ -919,7 +930,7 @@ msgid "" "number is incremented, and exists so you can set such a breakpoint easily." msgstr "" -#: ../../c-api/memory.rst:600 +#: ../../c-api/memory.rst:610 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, " @@ -932,7 +943,7 @@ msgid "" "getting used)." msgstr "" -#: ../../c-api/memory.rst:609 +#: ../../c-api/memory.rst:619 msgid "" "The :c:func:`PyMem_SetupDebugHooks` function now also works on Python " "compiled in release mode. On error, the debug hooks now use :mod:" @@ -941,7 +952,7 @@ msgid "" "`PYMEM_DOMAIN_OBJ` and :c:macro:`PYMEM_DOMAIN_MEM` domains are called." msgstr "" -#: ../../c-api/memory.rst:617 +#: ../../c-api/memory.rst:627 msgid "" "Byte patterns ``0xCB`` (``PYMEM_CLEANBYTE``), ``0xDB`` (``PYMEM_DEADBYTE``) " "and ``0xFB`` (``PYMEM_FORBIDDENBYTE``) have been replaced with ``0xCD``, " @@ -949,11 +960,11 @@ msgid "" "``malloc()`` and ``free()``." msgstr "" -#: ../../c-api/memory.rst:627 +#: ../../c-api/memory.rst:637 msgid "The pymalloc allocator" msgstr "" -#: ../../c-api/memory.rst:629 +#: ../../c-api/memory.rst:639 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 " @@ -962,75 +973,75 @@ msgid "" "`PyMem_RawRealloc` for allocations larger than 512 bytes." msgstr "" -#: ../../c-api/memory.rst:635 +#: ../../c-api/memory.rst:645 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:639 +#: ../../c-api/memory.rst:649 msgid "The arena allocator uses the following functions:" msgstr "" -#: ../../c-api/memory.rst:641 +#: ../../c-api/memory.rst:651 msgid ":c:func:`!VirtualAlloc` and :c:func:`!VirtualFree` on Windows," msgstr "" -#: ../../c-api/memory.rst:642 +#: ../../c-api/memory.rst:652 msgid ":c:func:`!mmap` and :c:func:`!munmap` if available," msgstr "" -#: ../../c-api/memory.rst:643 +#: ../../c-api/memory.rst:653 msgid ":c:func:`malloc` and :c:func:`free` otherwise." msgstr "" -#: ../../c-api/memory.rst:645 +#: ../../c-api/memory.rst:655 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:650 +#: ../../c-api/memory.rst:660 msgid "Customize pymalloc Arena Allocator" msgstr "" -#: ../../c-api/memory.rst:656 +#: ../../c-api/memory.rst:666 msgid "" "Structure used to describe an arena allocator. The structure has three " "fields:" msgstr "" -#: ../../c-api/memory.rst:664 +#: ../../c-api/memory.rst:674 msgid "``void* alloc(void *ctx, size_t size)``" msgstr "``void* alloc(void *ctx, size_t size)``" -#: ../../c-api/memory.rst:664 +#: ../../c-api/memory.rst:674 msgid "allocate an arena of size bytes" msgstr "" -#: ../../c-api/memory.rst:666 +#: ../../c-api/memory.rst:676 msgid "``void free(void *ctx, void *ptr, size_t size)``" msgstr "``void free(void *ctx, void *ptr, size_t size)``" -#: ../../c-api/memory.rst:666 +#: ../../c-api/memory.rst:676 msgid "free an arena" msgstr "" -#: ../../c-api/memory.rst:671 +#: ../../c-api/memory.rst:681 msgid "Get the arena allocator." msgstr "" -#: ../../c-api/memory.rst:675 +#: ../../c-api/memory.rst:685 msgid "Set the arena allocator." msgstr "" -#: ../../c-api/memory.rst:680 +#: ../../c-api/memory.rst:690 msgid "The mimalloc allocator" msgstr "" -#: ../../c-api/memory.rst:684 +#: ../../c-api/memory.rst:694 msgid "" "Python supports the mimalloc allocator when the underlying platform support " "is available. mimalloc \"is a general purpose allocator with excellent " @@ -1038,46 +1049,46 @@ msgid "" "runtime systems of the Koka and Lean languages.\"" msgstr "" -#: ../../c-api/memory.rst:689 +#: ../../c-api/memory.rst:699 msgid "tracemalloc C API" msgstr "" -#: ../../c-api/memory.rst:695 +#: ../../c-api/memory.rst:705 msgid "Track an allocated memory block in the :mod:`tracemalloc` module." msgstr "" -#: ../../c-api/memory.rst:697 +#: ../../c-api/memory.rst:707 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:700 +#: ../../c-api/memory.rst:710 msgid "If memory block is already tracked, update the existing trace." msgstr "" -#: ../../c-api/memory.rst:704 +#: ../../c-api/memory.rst:714 msgid "" "Untrack an allocated memory block in the :mod:`tracemalloc` module. Do " "nothing if the block was not tracked." msgstr "" -#: ../../c-api/memory.rst:707 +#: ../../c-api/memory.rst:717 msgid "Return ``-2`` if tracemalloc is disabled, otherwise return ``0``." msgstr "" -#: ../../c-api/memory.rst:713 +#: ../../c-api/memory.rst:723 msgid "Examples" msgstr "範例" -#: ../../c-api/memory.rst:715 +#: ../../c-api/memory.rst:725 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:718 +#: ../../c-api/memory.rst:728 msgid "" "PyObject *res;\n" "char *buf = (char *) PyMem_Malloc(BUFSIZ); /* for I/O */\n" @@ -1090,11 +1101,11 @@ msgid "" "return res;" msgstr "" -#: ../../c-api/memory.rst:728 +#: ../../c-api/memory.rst:738 msgid "The same code using the type-oriented function set::" msgstr "" -#: ../../c-api/memory.rst:730 +#: ../../c-api/memory.rst:740 msgid "" "PyObject *res;\n" "char *buf = PyMem_New(char, BUFSIZ); /* for I/O */\n" @@ -1107,7 +1118,7 @@ msgid "" "return res;" msgstr "" -#: ../../c-api/memory.rst:740 +#: ../../c-api/memory.rst:750 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 " @@ -1117,7 +1128,7 @@ msgid "" "different allocators operating on different heaps. ::" msgstr "" -#: ../../c-api/memory.rst:747 +#: ../../c-api/memory.rst:757 msgid "" "char *buf1 = PyMem_New(char, BUFSIZ);\n" "char *buf2 = (char *) malloc(BUFSIZ);\n" @@ -1128,14 +1139,14 @@ msgid "" "free(buf1); /* Fatal -- should be PyMem_Del() */" msgstr "" -#: ../../c-api/memory.rst:755 +#: ../../c-api/memory.rst:765 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`." msgstr "" -#: ../../c-api/memory.rst:759 +#: ../../c-api/memory.rst:769 msgid "" "These will be explained in the next chapter on defining and implementing new " "object types in C." diff --git a/c-api/module.po b/c-api/module.po index cd977561d1..92ccf53755 100644 --- a/c-api/module.po +++ b/c-api/module.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-03-03 18:39+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-" @@ -42,29 +42,32 @@ msgstr "" #: ../../c-api/module.rst:40 msgid "" -"Return a new module object with the :attr:`__name__` attribute set to " -"*name*. The module's :attr:`__name__`, :attr:`__doc__`, :attr:`__package__`, " -"and :attr:`__loader__` attributes are filled in (all but :attr:`__name__` " -"are set to ``None``); the caller is responsible for providing a :attr:" -"`__file__` attribute." +"Return a new module object with :attr:`module.__name__` set to *name*. The " +"module's :attr:`!__name__`, :attr:`~module.__doc__`, :attr:`~module." +"__package__` and :attr:`~module.__loader__` attributes are filled in (all " +"but :attr:`!__name__` are set to ``None``). The caller is responsible for " +"setting a :attr:`~module.__file__` attribute." msgstr "" -#: ../../c-api/module.rst:46 ../../c-api/module.rst:270 -#: ../../c-api/module.rst:470 +#: ../../c-api/module.rst:46 ../../c-api/module.rst:272 +#: ../../c-api/module.rst:474 msgid "Return ``NULL`` with an exception set on error." msgstr "在失敗時回傳 ``NULL`` 並設定例外。" #: ../../c-api/module.rst:50 -msgid ":attr:`__package__` and :attr:`__loader__` are set to ``None``." +#, fuzzy +msgid "" +":attr:`~module.__package__` and :attr:`~module.__loader__` are now set to " +"``None``." msgstr ":attr:`__package__` 和 :attr:`__loader__` 被設為 ``None``。" -#: ../../c-api/module.rst:56 +#: ../../c-api/module.rst:57 msgid "" "Similar to :c:func:`PyModule_NewObject`, but the name is a UTF-8 encoded " "string instead of a Unicode object." msgstr "" -#: ../../c-api/module.rst:64 +#: ../../c-api/module.rst:65 msgid "" "Return the dictionary object that implements *module*'s namespace; this " "object is the same as the :attr:`~object.__dict__` attribute of the module " @@ -72,64 +75,64 @@ msgid "" "object), :exc:`SystemError` is raised and ``NULL`` is returned." msgstr "" -#: ../../c-api/module.rst:69 +#: ../../c-api/module.rst:70 msgid "" "It is recommended extensions use other ``PyModule_*`` and ``PyObject_*`` " "functions rather than directly manipulate a module's :attr:`~object." "__dict__`." msgstr "" -#: ../../c-api/module.rst:80 +#: ../../c-api/module.rst:81 msgid "" -"Return *module*'s :attr:`__name__` value. If the module does not provide " -"one, or if it is not a string, :exc:`SystemError` is raised and ``NULL`` is " -"returned." +"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:88 +#: ../../c-api/module.rst:90 msgid "" "Similar to :c:func:`PyModule_GetNameObject` but return the name encoded to " "``'utf-8'``." msgstr "" -#: ../../c-api/module.rst:93 +#: ../../c-api/module.rst:95 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:100 +#: ../../c-api/module.rst:102 msgid "" "Return a pointer to the :c:type:`PyModuleDef` struct from which the module " "was created, or ``NULL`` if the module wasn't created from a definition." msgstr "" -#: ../../c-api/module.rst:110 +#: ../../c-api/module.rst:112 msgid "" "Return the name of the file from which *module* was loaded using *module*'s :" -"attr:`__file__` attribute. If this is not defined, or if it is not a " -"unicode string, raise :exc:`SystemError` and return ``NULL``; otherwise " -"return a reference to a Unicode object." +"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:120 +#: ../../c-api/module.rst:122 msgid "" "Similar to :c:func:`PyModule_GetFilenameObject` but return the filename " "encoded to 'utf-8'." msgstr "" -#: ../../c-api/module.rst:123 +#: ../../c-api/module.rst:125 msgid "" ":c:func:`PyModule_GetFilename` raises :exc:`UnicodeEncodeError` on " "unencodable filenames, use :c:func:`PyModule_GetFilenameObject` instead." msgstr "" -#: ../../c-api/module.rst:131 +#: ../../c-api/module.rst:133 msgid "Initializing C modules" msgstr "初始化 C 模組" -#: ../../c-api/module.rst:133 +#: ../../c-api/module.rst:135 msgid "" "Modules objects are usually created from extension modules (shared libraries " "which export an initialization function), or compiled-in modules (where the " @@ -137,55 +140,55 @@ msgid "" "See :ref:`building` or :ref:`extending-with-embedding` for details." msgstr "" -#: ../../c-api/module.rst:138 +#: ../../c-api/module.rst:140 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." msgstr "" -#: ../../c-api/module.rst:144 +#: ../../c-api/module.rst:146 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." msgstr "" -#: ../../c-api/module.rst:150 +#: ../../c-api/module.rst:152 msgid "Always initialize this member to :c:macro:`PyModuleDef_HEAD_INIT`." msgstr "" -#: ../../c-api/module.rst:154 +#: ../../c-api/module.rst:156 msgid "Name for the new module." msgstr "" -#: ../../c-api/module.rst:158 +#: ../../c-api/module.rst:160 msgid "" "Docstring for the module; usually a docstring variable created with :c:macro:" "`PyDoc_STRVAR` is used." msgstr "" -#: ../../c-api/module.rst:163 +#: ../../c-api/module.rst:165 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:167 +#: ../../c-api/module.rst:169 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:171 +#: ../../c-api/module.rst:173 msgid "" "Setting ``m_size`` to ``-1`` means that the module does not support sub-" "interpreters, because it has global state." msgstr "" -#: ../../c-api/module.rst:174 +#: ../../c-api/module.rst:176 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 " @@ -193,37 +196,37 @@ msgid "" "initialization." msgstr "" -#: ../../c-api/module.rst:179 +#: ../../c-api/module.rst:181 msgid "See :PEP:`3121` for more details." msgstr "更多詳情請見 :pep:`3121`。" -#: ../../c-api/module.rst:183 +#: ../../c-api/module.rst:185 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:188 +#: ../../c-api/module.rst:190 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``." msgstr "" -#: ../../c-api/module.rst:194 +#: ../../c-api/module.rst:196 msgid "" "Prior to version 3.5, this member was always set to ``NULL``, and was " "defined as:" msgstr "" -#: ../../c-api/module.rst:201 +#: ../../c-api/module.rst:203 msgid "" "A traversal function to call during GC traversal of the module object, or " "``NULL`` if not needed." msgstr "" -#: ../../c-api/module.rst:204 ../../c-api/module.rst:219 -#: ../../c-api/module.rst:240 +#: ../../c-api/module.rst:206 ../../c-api/module.rst:221 +#: ../../c-api/module.rst:242 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 " @@ -233,18 +236,18 @@ msgid "" "`PyModule_GetState`) is ``NULL``." msgstr "" -#: ../../c-api/module.rst:211 ../../c-api/module.rst:232 -#: ../../c-api/module.rst:247 +#: ../../c-api/module.rst:213 ../../c-api/module.rst:234 +#: ../../c-api/module.rst:249 msgid "No longer called before the module state is allocated." msgstr "" -#: ../../c-api/module.rst:216 +#: ../../c-api/module.rst:218 msgid "" "A clear function to call during GC clearing of the module object, or " "``NULL`` if not needed." msgstr "" -#: ../../c-api/module.rst:226 +#: ../../c-api/module.rst:228 msgid "" "Like :c:member:`PyTypeObject.tp_clear`, this function is not *always* called " "before a module is deallocated. For example, when reference counting is " @@ -253,55 +256,55 @@ msgid "" "directly." msgstr "" -#: ../../c-api/module.rst:237 +#: ../../c-api/module.rst:239 msgid "" "A function to call during deallocation of the module object, or ``NULL`` if " "not needed." msgstr "" -#: ../../c-api/module.rst:251 +#: ../../c-api/module.rst:253 msgid "Single-phase initialization" msgstr "" -#: ../../c-api/module.rst:253 +#: ../../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:259 +#: ../../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:266 +#: ../../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:274 +#: ../../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:277 +#: ../../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:283 +#: ../../c-api/module.rst:285 msgid "Multi-phase initialization" msgstr "" -#: ../../c-api/module.rst:285 +#: ../../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 " @@ -311,7 +314,7 @@ msgid "" "__init__` methods of classes." msgstr "" -#: ../../c-api/module.rst:292 +#: ../../c-api/module.rst:294 msgid "" "Unlike modules created using single-phase initialization, these modules are " "not singletons: if the *sys.modules* entry is removed and the module is re-" @@ -324,14 +327,14 @@ msgid "" "__dict__` or individual classes created with :c:func:`PyType_FromSpec`)." msgstr "" -#: ../../c-api/module.rst:302 +#: ../../c-api/module.rst:304 msgid "" "All modules created using multi-phase initialization are expected to " "support :ref:`sub-interpreters `. Making sure " "multiple modules are independent is typically enough to achieve this." msgstr "" -#: ../../c-api/module.rst:306 +#: ../../c-api/module.rst:308 msgid "" "To request multi-phase initialization, the initialization function " "(PyInit_modulename) returns a :c:type:`PyModuleDef` instance with non-empty :" @@ -339,65 +342,65 @@ msgid "" "instance must be initialized with the following function:" msgstr "" -#: ../../c-api/module.rst:313 +#: ../../c-api/module.rst:315 msgid "" "Ensures a module definition is a properly initialized Python object that " "correctly reports its type and reference count." msgstr "" -#: ../../c-api/module.rst:316 +#: ../../c-api/module.rst:318 msgid "Returns *def* cast to ``PyObject*``, or ``NULL`` if an error occurred." msgstr "" -#: ../../c-api/module.rst:320 +#: ../../c-api/module.rst:322 msgid "" "The *m_slots* member of the module definition must point to an array of " "``PyModuleDef_Slot`` structures:" msgstr "" -#: ../../c-api/module.rst:327 +#: ../../c-api/module.rst:329 msgid "A slot ID, chosen from the available values explained below." msgstr "" -#: ../../c-api/module.rst:331 +#: ../../c-api/module.rst:333 msgid "Value of the slot, whose meaning depends on the slot ID." msgstr "" -#: ../../c-api/module.rst:335 +#: ../../c-api/module.rst:337 msgid "The *m_slots* array must be terminated by a slot with id 0." msgstr "" -#: ../../c-api/module.rst:337 +#: ../../c-api/module.rst:339 msgid "The available slot types are:" msgstr "" -#: ../../c-api/module.rst:341 +#: ../../c-api/module.rst:343 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:348 +#: ../../c-api/module.rst:350 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:353 +#: ../../c-api/module.rst:355 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:357 +#: ../../c-api/module.rst:359 msgid "" "Multiple ``Py_mod_create`` slots may not be specified in one module " "definition." msgstr "" -#: ../../c-api/module.rst:360 +#: ../../c-api/module.rst:362 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 " @@ -406,7 +409,7 @@ msgid "" "through symlinks, all while sharing a single module definition." msgstr "" -#: ../../c-api/module.rst:366 +#: ../../c-api/module.rst:368 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 " @@ -416,7 +419,7 @@ msgid "" "``Py_mod_create``." msgstr "" -#: ../../c-api/module.rst:375 +#: ../../c-api/module.rst:377 msgid "" "Specifies a function that is called to *execute* the module. This is " "equivalent to executing the code of a Python module: typically, this " @@ -424,61 +427,61 @@ msgid "" "function is:" msgstr "" -#: ../../c-api/module.rst:384 +#: ../../c-api/module.rst:386 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:389 ../../c-api/module.rst:422 +#: ../../c-api/module.rst:391 ../../c-api/module.rst:424 msgid "Specifies one of the following values:" msgstr "" -#: ../../c-api/module.rst:395 +#: ../../c-api/module.rst:397 msgid "The module does not support being imported in subinterpreters." msgstr "" -#: ../../c-api/module.rst:399 +#: ../../c-api/module.rst:401 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:405 +#: ../../c-api/module.rst:407 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:409 +#: ../../c-api/module.rst:411 msgid "" "This slot determines whether or not importing this module in a " "subinterpreter will fail." msgstr "" -#: ../../c-api/module.rst:412 +#: ../../c-api/module.rst:414 msgid "" "Multiple ``Py_mod_multiple_interpreters`` slots may not be specified in one " "module definition." msgstr "" -#: ../../c-api/module.rst:415 +#: ../../c-api/module.rst:417 msgid "" "If ``Py_mod_multiple_interpreters`` is not specified, the import machinery " -"defaults to ``Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED``." +"defaults to ``Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED``." msgstr "" -#: ../../c-api/module.rst:426 +#: ../../c-api/module.rst:430 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:431 +#: ../../c-api/module.rst:435 msgid "The module is safe to run without an active GIL." msgstr "" -#: ../../c-api/module.rst:433 +#: ../../c-api/module.rst:437 msgid "" "This slot is ignored by Python builds not configured with :option:`--disable-" "gil`. Otherwise, it determines whether or not importing this module will " @@ -486,26 +489,26 @@ msgid "" "threaded-cpython` for more detail." msgstr "" -#: ../../c-api/module.rst:438 +#: ../../c-api/module.rst:442 msgid "" "Multiple ``Py_mod_gil`` slots may not be specified in one module definition." msgstr "" -#: ../../c-api/module.rst:440 +#: ../../c-api/module.rst:444 msgid "" "If ``Py_mod_gil`` is not specified, the import machinery defaults to " "``Py_MOD_GIL_USED``." msgstr "" -#: ../../c-api/module.rst:445 +#: ../../c-api/module.rst:449 msgid "See :PEP:`489` for more details on multi-phase initialization." msgstr "" -#: ../../c-api/module.rst:448 +#: ../../c-api/module.rst:452 msgid "Low-level module creation functions" msgstr "" -#: ../../c-api/module.rst:450 +#: ../../c-api/module.rst:454 msgid "" "The following functions are called under the hood when using multi-phase " "initialization. They can be used directly, for example when creating module " @@ -513,14 +516,14 @@ msgid "" "``PyModule_ExecDef`` must be called to fully initialize a module." msgstr "" -#: ../../c-api/module.rst:457 +#: ../../c-api/module.rst:461 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`." msgstr "" -#: ../../c-api/module.rst:465 +#: ../../c-api/module.rst:469 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 " @@ -528,24 +531,24 @@ msgid "" "emitted." msgstr "" -#: ../../c-api/module.rst:474 +#: ../../c-api/module.rst:478 msgid "" "Most uses of this function should be using :c:func:`PyModule_FromDefAndSpec` " "instead; only use this if you are sure you need it." msgstr "" -#: ../../c-api/module.rst:481 +#: ../../c-api/module.rst:485 msgid "Process any execution slots (:c:data:`Py_mod_exec`) given in *def*." msgstr "" -#: ../../c-api/module.rst:487 +#: ../../c-api/module.rst:491 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``." msgstr "" -#: ../../c-api/module.rst:496 +#: ../../c-api/module.rst:500 msgid "" "Add the functions from the ``NULL`` terminated *functions* array to " "*module*. Refer to the :c:type:`PyMethodDef` documentation for details on " @@ -557,11 +560,11 @@ msgid "" "``PyModule_FromDefAndSpec``." msgstr "" -#: ../../c-api/module.rst:508 +#: ../../c-api/module.rst:512 msgid "Support functions" msgstr "支援的函式" -#: ../../c-api/module.rst:510 +#: ../../c-api/module.rst:514 msgid "" "The module initialization function (if using single phase initialization) or " "a function called from a module execution slot (if using multi-phase " @@ -569,29 +572,23 @@ msgid "" "module state:" msgstr "" -#: ../../c-api/module.rst:517 +#: ../../c-api/module.rst:521 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:520 +#: ../../c-api/module.rst:524 msgid "" "On success, return ``0``. On error, raise an exception and return ``-1``." msgstr "" -#: ../../c-api/module.rst:522 -msgid "" -"Return ``-1`` if *value* is ``NULL``. It must be called with an exception " -"raised in this case." -msgstr "" - -#: ../../c-api/module.rst:525 ../../c-api/module.rst:572 -#: ../../c-api/module.rst:599 +#: ../../c-api/module.rst:526 ../../c-api/module.rst:577 +#: ../../c-api/module.rst:604 msgid "Example usage::" msgstr "用法範例: ::" -#: ../../c-api/module.rst:527 +#: ../../c-api/module.rst:528 msgid "" "static int\n" "add_spam(PyObject *module, int value)\n" @@ -617,13 +614,20 @@ msgstr "" " return res;\n" " }" -#: ../../c-api/module.rst:539 +#: ../../c-api/module.rst:540 +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:544 msgid "" "The example can also be written without checking explicitly if *obj* is " "``NULL``::" msgstr "" -#: ../../c-api/module.rst:542 +#: ../../c-api/module.rst:547 msgid "" "static int\n" "add_spam(PyObject *module, int value)\n" @@ -643,13 +647,13 @@ msgstr "" " return res;\n" " }" -#: ../../c-api/module.rst:551 +#: ../../c-api/module.rst:556 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:554 +#: ../../c-api/module.rst:559 msgid "" "The number of different *name* strings passed to this function should be " "kept small, usually by only using statically allocated strings as *name*. " @@ -659,7 +663,7 @@ msgid "" "internally to create a key object." msgstr "" -#: ../../c-api/module.rst:567 +#: ../../c-api/module.rst:572 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 " @@ -667,39 +671,39 @@ msgid "" "variable." msgstr "" -#: ../../c-api/module.rst:574 +#: ../../c-api/module.rst:579 msgid "" "if (PyModule_Add(module, \"spam\", PyBytes_FromString(value)) < 0) {\n" " goto error;\n" "}" msgstr "" -#: ../../c-api/module.rst:583 +#: ../../c-api/module.rst:588 msgid "" "Similar to :c:func:`PyModule_AddObjectRef`, but steals a reference to " "*value* on success (if it returns ``0``)." msgstr "" -#: ../../c-api/module.rst:586 +#: ../../c-api/module.rst:591 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:593 +#: ../../c-api/module.rst:598 msgid "" "Unlike other functions that steal references, ``PyModule_AddObject()`` only " "releases the reference to *value* **on success**." msgstr "" -#: ../../c-api/module.rst:596 +#: ../../c-api/module.rst:601 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:601 +#: ../../c-api/module.rst:606 msgid "" "PyObject *obj = PyBytes_FromString(value);\n" "if (PyModule_AddObject(module, \"spam\", obj) < 0) {\n" @@ -713,24 +717,24 @@ msgid "" "// Py_XDECREF(obj) is not needed here." msgstr "" -#: ../../c-api/module.rst:614 +#: ../../c-api/module.rst:619 msgid ":c:func:`PyModule_AddObject` is :term:`soft deprecated`." msgstr "" -#: ../../c-api/module.rst:619 +#: ../../c-api/module.rst:624 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:623 +#: ../../c-api/module.rst:628 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:629 +#: ../../c-api/module.rst:634 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 " @@ -738,14 +742,14 @@ msgid "" "on success." msgstr "" -#: ../../c-api/module.rst:634 +#: ../../c-api/module.rst:639 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:641 +#: ../../c-api/module.rst:646 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 " @@ -753,11 +757,11 @@ msgid "" "with an exception set on error, ``0`` on success." msgstr "" -#: ../../c-api/module.rst:649 +#: ../../c-api/module.rst:654 msgid "Add a string constant to *module*." msgstr "" -#: ../../c-api/module.rst:653 +#: ../../c-api/module.rst:658 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 " @@ -765,7 +769,7 @@ msgid "" "``-1`` with an exception set on error, ``0`` on success." msgstr "" -#: ../../c-api/module.rst:663 +#: ../../c-api/module.rst:668 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`. " @@ -776,25 +780,25 @@ msgid "" "Return ``-1`` with an exception set on error, ``0`` on success." msgstr "" -#: ../../c-api/module.rst:676 +#: ../../c-api/module.rst:681 msgid "Module lookup" msgstr "模組查找" -#: ../../c-api/module.rst:678 +#: ../../c-api/module.rst:683 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." msgstr "" -#: ../../c-api/module.rst:682 +#: ../../c-api/module.rst:687 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:687 +#: ../../c-api/module.rst:692 msgid "" "Returns the module object that was created from *def* for the current " "interpreter. This method requires that the module object has been attached " @@ -803,18 +807,18 @@ msgid "" "to the interpreter state yet, it returns ``NULL``." msgstr "" -#: ../../c-api/module.rst:694 +#: ../../c-api/module.rst:699 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:697 +#: ../../c-api/module.rst:702 msgid "Only effective on modules created using single-phase initialization." msgstr "" -#: ../../c-api/module.rst:699 +#: ../../c-api/module.rst:704 msgid "" "Python calls ``PyState_AddModule`` automatically after importing a module, " "so it is unnecessary (but harmless) to call it from module initialization " @@ -825,15 +829,15 @@ msgid "" "state updates)." msgstr "" -#: ../../c-api/module.rst:707 ../../c-api/module.rst:718 +#: ../../c-api/module.rst:712 ../../c-api/module.rst:723 msgid "The caller must hold the GIL." msgstr "" -#: ../../c-api/module.rst:709 +#: ../../c-api/module.rst:714 msgid "Return ``-1`` with an exception set on error, ``0`` on success." msgstr "成功時回傳 ``0``,在失敗時回傳 ``-1`` 並設定例外。" -#: ../../c-api/module.rst:715 +#: ../../c-api/module.rst:720 msgid "" "Removes the module object created from *def* from the interpreter state. " "Return ``-1`` with an exception set on error, ``0`` on success." @@ -851,7 +855,7 @@ msgstr "module(模組)" msgid "ModuleType (in module types)" msgstr "MethodType(types 模組中)" -#: ../../c-api/module.rst:33 ../../c-api/module.rst:76 +#: ../../c-api/module.rst:33 ../../c-api/module.rst:77 msgid "__name__ (module attribute)" msgstr "__name__(模組屬性)" @@ -859,7 +863,7 @@ msgstr "__name__(模組屬性)" msgid "__doc__ (module attribute)" msgstr "__doc__(模組屬性)" -#: ../../c-api/module.rst:33 ../../c-api/module.rst:106 +#: ../../c-api/module.rst:33 ../../c-api/module.rst:108 msgid "__file__ (module attribute)" msgstr "__file__(模組屬性)" @@ -871,10 +875,10 @@ msgstr "__package__(模組屬性)" msgid "__loader__ (module attribute)" msgstr "__loader__(模組屬性)" -#: ../../c-api/module.rst:62 +#: ../../c-api/module.rst:63 msgid "__dict__ (module attribute)" msgstr "__dict__(模組屬性)" -#: ../../c-api/module.rst:76 ../../c-api/module.rst:106 +#: ../../c-api/module.rst:77 ../../c-api/module.rst:108 msgid "SystemError (built-in exception)" msgstr "SystemError(內建例外)" diff --git a/c-api/monitoring.po b/c-api/monitoring.po index cd950f57fa..5ca0544fdf 100644 --- a/c-api/monitoring.po +++ b/c-api/monitoring.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-04-24 05:56+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -166,3 +166,130 @@ msgid "" "Monitoring states can be managed with the help of monitoring scopes. A scope " "would typically correspond to a python function." msgstr "" + +#: ../../c-api/monitoring.rst:138 +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 " +"``PY_START`` event is the value ``PY_MONITORING_EVENT_PY_START``, which is " +"numerically equal to the base-2 logarithm of ``sys.monitoring.events." +"PY_START``. ``state_array`` is an array with a monitoring state entry for " +"each event in ``event_types``, it is allocated by the user but populated by :" +"c:func:`!PyMonitoring_EnterScope` with information about the activation " +"state of the event. The size of ``event_types`` (and hence also of " +"``state_array``) is given in ``length``." +msgstr "" + +#: ../../c-api/monitoring.rst:148 +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 " +"only by :c:func:`!PyMonitoring_EnterScope` itself. It allows this function " +"to determine whether event states have changed since the previous call, and " +"to return quickly if they have not." +msgstr "" + +#: ../../c-api/monitoring.rst:154 +msgid "" +"The scopes referred to here are lexical scopes: a function, class or " +"method. :c:func:`!PyMonitoring_EnterScope` should be called whenever the " +"lexical scope is entered. Scopes can be reentered, reusing the same " +"*state_array* and *version*, in situations like when emulating a recursive " +"Python function. When a code-like's execution is paused, such as when " +"emulating a generator, the scope needs to be exited and re-entered." +msgstr "" + +#: ../../c-api/monitoring.rst:161 +msgid "The macros for *event_types* are:" +msgstr "" + +#: ../../c-api/monitoring.rst:169 +msgid "Macro" +msgstr "" + +#: ../../c-api/monitoring.rst:169 +msgid "Event" +msgstr "" + +#: ../../c-api/monitoring.rst:171 +msgid ":monitoring-event:`BRANCH`" +msgstr "" + +#: ../../c-api/monitoring.rst:172 +msgid ":monitoring-event:`CALL`" +msgstr "" + +#: ../../c-api/monitoring.rst:173 +msgid ":monitoring-event:`C_RAISE`" +msgstr "" + +#: ../../c-api/monitoring.rst:174 +msgid ":monitoring-event:`C_RETURN`" +msgstr "" + +#: ../../c-api/monitoring.rst:175 +msgid ":monitoring-event:`EXCEPTION_HANDLED`" +msgstr "" + +#: ../../c-api/monitoring.rst:176 +msgid ":monitoring-event:`INSTRUCTION`" +msgstr "" + +#: ../../c-api/monitoring.rst:177 +msgid ":monitoring-event:`JUMP`" +msgstr "" + +#: ../../c-api/monitoring.rst:178 +msgid ":monitoring-event:`LINE`" +msgstr "" + +#: ../../c-api/monitoring.rst:179 +msgid ":monitoring-event:`PY_RESUME`" +msgstr "" + +#: ../../c-api/monitoring.rst:180 +msgid ":monitoring-event:`PY_RETURN`" +msgstr "" + +#: ../../c-api/monitoring.rst:181 +msgid ":monitoring-event:`PY_START`" +msgstr "" + +#: ../../c-api/monitoring.rst:182 +msgid ":monitoring-event:`PY_THROW`" +msgstr "" + +#: ../../c-api/monitoring.rst:183 +msgid ":monitoring-event:`PY_UNWIND`" +msgstr "" + +#: ../../c-api/monitoring.rst:184 +msgid ":monitoring-event:`PY_YIELD`" +msgstr "" + +#: ../../c-api/monitoring.rst:185 +msgid ":monitoring-event:`RAISE`" +msgstr "" + +#: ../../c-api/monitoring.rst:186 +msgid ":monitoring-event:`RERAISE`" +msgstr "" + +#: ../../c-api/monitoring.rst:187 +msgid ":monitoring-event:`STOP_ITERATION`" +msgstr "" + +#: ../../c-api/monitoring.rst:192 +msgid "" +"Exit the last scope that was entered with :c:func:`!PyMonitoring_EnterScope`." +msgstr "" + +#: ../../c-api/monitoring.rst:197 +msgid "" +"Return true if the event corresponding to the event ID *ev* is a :ref:`local " +"event `." +msgstr "" + +#: ../../c-api/monitoring.rst:204 +msgid "This function is :term:`soft deprecated`." +msgstr "" diff --git a/c-api/object.po b/c-api/object.po index a672a4c44f..19197cf526 100644 --- a/c-api/object.po +++ b/c-api/object.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-02-07 08:41+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-" @@ -196,19 +196,20 @@ msgstr "" #: ../../c-api/object.rst:113 msgid "" "Exceptions that occur when this calls :meth:`~object.__getattr__` and :meth:" -"`~object.__getattribute__` methods are silently ignored. For proper error " -"handling, use :c:func:`PyObject_HasAttrWithError`, :c:func:" -"`PyObject_GetOptionalAttr` or :c:func:`PyObject_GetAttr` instead." +"`~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:121 +#: ../../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*`." msgstr "" -#: ../../c-api/object.rst:127 +#: ../../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:" @@ -217,39 +218,39 @@ msgid "" "or :c:func:`PyObject_GetAttrString` instead." msgstr "" -#: ../../c-api/object.rst:137 +#: ../../c-api/object.rst:138 msgid "" "Retrieve an attribute named *attr_name* from object *o*. Returns the " "attribute value on success, or ``NULL`` on failure. This is the equivalent " "of the Python expression ``o.attr_name``." msgstr "" -#: ../../c-api/object.rst:141 +#: ../../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." msgstr "" -#: ../../c-api/object.rst:147 +#: ../../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*`." msgstr "" -#: ../../c-api/object.rst:151 +#: ../../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." msgstr "" -#: ../../c-api/object.rst:157 +#: ../../c-api/object.rst:158 msgid "" "Variant of :c:func:`PyObject_GetAttr` which doesn't raise :exc:" "`AttributeError` if the attribute is not found." msgstr "" -#: ../../c-api/object.rst:160 +#: ../../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 " @@ -258,14 +259,14 @@ msgid "" "``-1`` and set *\\*result* to ``NULL``." msgstr "" -#: ../../c-api/object.rst:172 +#: ../../c-api/object.rst:173 msgid "" "This is the same as :c:func:`PyObject_GetOptionalAttr`, but *attr_name* is " "specified as a :c:expr:`const char*` UTF-8 encoded bytes string, rather than " "a :c:expr:`PyObject*`." msgstr "" -#: ../../c-api/object.rst:180 +#: ../../c-api/object.rst:181 msgid "" "Generic attribute getter function that is meant to be put into a type " "object's ``tp_getattro`` slot. It looks for a descriptor in the dictionary " @@ -275,34 +276,34 @@ msgid "" "descriptors don't. Otherwise, an :exc:`AttributeError` is raised." msgstr "" -#: ../../c-api/object.rst:190 +#: ../../c-api/object.rst:191 msgid "" "Set the value of the attribute named *attr_name*, for object *o*, to the " "value *v*. Raise an exception and return ``-1`` on failure; return ``0`` on " "success. This is the equivalent of the Python statement ``o.attr_name = v``." msgstr "" -#: ../../c-api/object.rst:195 +#: ../../c-api/object.rst:196 msgid "" "If *v* is ``NULL``, the attribute is deleted. This behaviour is deprecated " "in favour of using :c:func:`PyObject_DelAttr`, but there are currently no " "plans to remove it." msgstr "" -#: ../../c-api/object.rst:202 +#: ../../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*`." msgstr "" -#: ../../c-api/object.rst:206 +#: ../../c-api/object.rst:207 msgid "" "If *v* is ``NULL``, the attribute is deleted, but this feature is deprecated " "in favour of using :c:func:`PyObject_DelAttrString`." msgstr "" -#: ../../c-api/object.rst:209 +#: ../../c-api/object.rst:210 msgid "" "The number of different attribute names passed to this function should be " "kept small, usually by using a statically allocated string as *attr_name*. " @@ -312,7 +313,7 @@ msgid "" "internally to create a key object." msgstr "" -#: ../../c-api/object.rst:219 +#: ../../c-api/object.rst:220 msgid "" "Generic attribute setter and deleter function that is meant to be put into a " "type object's :c:member:`~PyTypeObject.tp_setattro` slot. It looks for a " @@ -324,20 +325,20 @@ msgid "" "returned." msgstr "" -#: ../../c-api/object.rst:231 +#: ../../c-api/object.rst:232 msgid "" "Delete attribute named *attr_name*, for object *o*. Returns ``-1`` on " "failure. This is the equivalent of the Python statement ``del o.attr_name``." msgstr "" -#: ../../c-api/object.rst:237 +#: ../../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*`." msgstr "" -#: ../../c-api/object.rst:241 +#: ../../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*. " @@ -347,13 +348,13 @@ msgid "" "internally to create a key object for lookup." msgstr "" -#: ../../c-api/object.rst:252 +#: ../../c-api/object.rst:253 msgid "" "A generic implementation for the getter of a ``__dict__`` descriptor. It " "creates the dictionary if necessary." msgstr "" -#: ../../c-api/object.rst:255 +#: ../../c-api/object.rst:256 msgid "" "This function may also be called to get the :py:attr:`~object.__dict__` of " "the object *o*. Pass ``NULL`` for *context* when calling it. Since this " @@ -362,30 +363,30 @@ msgid "" "the object." msgstr "" -#: ../../c-api/object.rst:261 +#: ../../c-api/object.rst:262 msgid "On failure, returns ``NULL`` with an exception set." msgstr "在失敗時,會回傳 ``NULL`` 並設定例外。" -#: ../../c-api/object.rst:268 +#: ../../c-api/object.rst:269 msgid "" "A generic implementation for the setter of a ``__dict__`` descriptor. This " "implementation does not allow the dictionary to be deleted." msgstr "" -#: ../../c-api/object.rst:276 +#: ../../c-api/object.rst:277 msgid "" "Return a pointer to :py:attr:`~object.__dict__` of the object *obj*. If " "there is no ``__dict__``, return ``NULL`` without setting an exception." msgstr "" -#: ../../c-api/object.rst:279 +#: ../../c-api/object.rst:280 msgid "" "This function may need to allocate memory for the dictionary, so it may be " "more efficient to call :c:func:`PyObject_GetAttr` when accessing an " "attribute on the object." msgstr "" -#: ../../c-api/object.rst:286 +#: ../../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`, :" @@ -396,33 +397,33 @@ msgid "" "success, or ``NULL`` on failure." msgstr "" -#: ../../c-api/object.rst:296 +#: ../../c-api/object.rst:297 msgid "" "Compare the values of *o1* and *o2* using the operation specified by *opid*, " "like :c:func:`PyObject_RichCompare`, but returns ``-1`` on error, ``0`` if " "the result is false, ``1`` otherwise." msgstr "" -#: ../../c-api/object.rst:301 +#: ../../c-api/object.rst:302 msgid "" "If *o1* and *o2* are the same object, :c:func:`PyObject_RichCompareBool` " "will always return ``1`` for :c:macro:`Py_EQ` and ``0`` for :c:macro:`Py_NE`." msgstr "" -#: ../../c-api/object.rst:306 +#: ../../c-api/object.rst:307 msgid "" "Format *obj* using *format_spec*. This is equivalent to the Python " "expression ``format(obj, format_spec)``." msgstr "" -#: ../../c-api/object.rst:309 +#: ../../c-api/object.rst:310 msgid "" "*format_spec* may be ``NULL``. In this case the call is equivalent to " "``format(obj)``. Returns the formatted string on success, ``NULL`` on " "failure." msgstr "" -#: ../../c-api/object.rst:317 +#: ../../c-api/object.rst:318 msgid "" "Compute a string representation of object *o*. Returns the string " "representation on success, ``NULL`` on failure. This is the equivalent of " @@ -430,13 +431,13 @@ msgid "" "function." msgstr "" -#: ../../c-api/object.rst:321 ../../c-api/object.rst:345 +#: ../../c-api/object.rst:322 ../../c-api/object.rst:346 msgid "" "This function now includes a debug assertion to help ensure that it does not " "silently discard an active exception." msgstr "" -#: ../../c-api/object.rst:329 +#: ../../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:" @@ -445,7 +446,7 @@ msgid "" "Called by the :func:`ascii` built-in function." msgstr "" -#: ../../c-api/object.rst:340 +#: ../../c-api/object.rst:341 msgid "" "Compute a string representation of object *o*. Returns the string " "representation on success, ``NULL`` on failure. This is the equivalent of " @@ -453,7 +454,7 @@ msgid "" "function and, therefore, by the :func:`print` function." msgstr "" -#: ../../c-api/object.rst:354 +#: ../../c-api/object.rst:355 msgid "" "Compute a bytes representation of object *o*. ``NULL`` is returned on " "failure and a bytes object on success. This is equivalent to the Python " @@ -462,73 +463,73 @@ msgid "" "bytes object." msgstr "" -#: ../../c-api/object.rst:363 +#: ../../c-api/object.rst:364 msgid "" "Return ``1`` if the class *derived* is identical to or derived from the " "class *cls*, otherwise return ``0``. In case of an error, return ``-1``." msgstr "" -#: ../../c-api/object.rst:366 ../../c-api/object.rst:385 +#: ../../c-api/object.rst:367 ../../c-api/object.rst:386 msgid "" "If *cls* is a tuple, the check will be done against every entry in *cls*. " "The result will be ``1`` when at least one of the checks returns ``1``, " "otherwise it will be ``0``." msgstr "" -#: ../../c-api/object.rst:370 +#: ../../c-api/object.rst:371 msgid "" -"If *cls* has a :meth:`~class.__subclasscheck__` method, it will be called to " +"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 ``cls.__mro__``." +"e. contained in :attr:`cls.__mro__ `." msgstr "" -#: ../../c-api/object.rst:375 +#: ../../c-api/object.rst:376 msgid "" "Normally only class objects, i.e. instances of :class:`type` or a derived " "class, are considered classes. However, objects can override this by having " -"a :attr:`~class.__bases__` attribute (which must be a tuple of base classes)." +"a :attr:`~type.__bases__` attribute (which must be a tuple of base classes)." msgstr "" -#: ../../c-api/object.rst:382 +#: ../../c-api/object.rst:383 msgid "" "Return ``1`` if *inst* is an instance of the class *cls* or a subclass of " "*cls*, or ``0`` if not. On error, returns ``-1`` and sets an exception." msgstr "" -#: ../../c-api/object.rst:389 +#: ../../c-api/object.rst:390 msgid "" -"If *cls* has a :meth:`~class.__instancecheck__` method, it will be called to " +"If *cls* has a :meth:`~type.__instancecheck__` method, it will be called to " "determine the subclass status as described in :pep:`3119`. Otherwise, " "*inst* is an instance of *cls* if its class is a subclass of *cls*." msgstr "" -#: ../../c-api/object.rst:393 +#: ../../c-api/object.rst:394 msgid "" "An instance *inst* can override what is considered its class by having a :" -"attr:`~instance.__class__` attribute." +"attr:`~object.__class__` attribute." msgstr "" -#: ../../c-api/object.rst:396 +#: ../../c-api/object.rst:397 msgid "" "An object *cls* can override if it is considered a class, and what its base " -"classes are, by having a :attr:`~class.__bases__` attribute (which must be a " +"classes are, by having a :attr:`~type.__bases__` attribute (which must be a " "tuple of base classes)." msgstr "" -#: ../../c-api/object.rst:405 +#: ../../c-api/object.rst:406 msgid "" "Compute and return the hash value of an object *o*. On failure, return " "``-1``. This is the equivalent of the Python expression ``hash(o)``." msgstr "" -#: ../../c-api/object.rst:408 +#: ../../c-api/object.rst:409 msgid "" "The return type is now Py_hash_t. This is a signed integer the same size " "as :c:type:`Py_ssize_t`." msgstr "" -#: ../../c-api/object.rst:415 +#: ../../c-api/object.rst:416 msgid "" "Set a :exc:`TypeError` indicating that ``type(o)`` is not :term:`hashable` " "and return ``-1``. This function receives special treatment when stored in a " @@ -536,21 +537,21 @@ msgid "" "that it is not hashable." msgstr "" -#: ../../c-api/object.rst:423 +#: ../../c-api/object.rst:424 msgid "" "Returns ``1`` if the object *o* is considered to be true, and ``0`` " "otherwise. This is equivalent to the Python expression ``not not o``. On " "failure, return ``-1``." msgstr "" -#: ../../c-api/object.rst:430 +#: ../../c-api/object.rst:431 msgid "" "Returns ``0`` if the object *o* is considered to be true, and ``1`` " "otherwise. This is equivalent to the Python expression ``not o``. On " "failure, return ``-1``." msgstr "" -#: ../../c-api/object.rst:439 +#: ../../c-api/object.rst:440 msgid "" "When *o* is non-``NULL``, returns a type object corresponding to the object " "type of object *o*. On failure, raises :exc:`SystemError` and returns " @@ -561,13 +562,13 @@ msgid "" "when a new :term:`strong reference` is needed." msgstr "" -#: ../../c-api/object.rst:451 +#: ../../c-api/object.rst:452 msgid "" "Return non-zero if the object *o* is of type *type* or a subtype of *type*, " "and ``0`` otherwise. Both parameters must be non-``NULL``." msgstr "" -#: ../../c-api/object.rst:460 +#: ../../c-api/object.rst:461 msgid "" "Return the length of object *o*. If the object *o* provides either the " "sequence and mapping protocols, the sequence length is returned. On error, " @@ -575,7 +576,7 @@ msgid "" "``len(o)``." msgstr "" -#: ../../c-api/object.rst:467 +#: ../../c-api/object.rst:468 msgid "" "Return an estimated length for the object *o*. First try to return its " "actual length, then an estimate using :meth:`~object.__length_hint__`, and " @@ -584,26 +585,33 @@ msgid "" "defaultvalue)``." msgstr "" -#: ../../c-api/object.rst:477 +#: ../../c-api/object.rst:478 msgid "" "Return element of *o* corresponding to the object *key* or ``NULL`` on " "failure. This is the equivalent of the Python expression ``o[key]``." msgstr "" -#: ../../c-api/object.rst:483 +#: ../../c-api/object.rst:484 msgid "" "Map the object *key* to the value *v*. Raise an exception and return ``-1`` " "on failure; return ``0`` on success. This is the equivalent of the Python " "statement ``o[key] = v``. This function *does not* steal a reference to *v*." msgstr "" -#: ../../c-api/object.rst:491 +#: ../../c-api/object.rst:492 msgid "" "Remove the mapping for the object *key* from the object *o*. Return ``-1`` " "on failure. This is equivalent to the Python statement ``del o[key]``." msgstr "" -#: ../../c-api/object.rst:497 +#: ../../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*`." +msgstr "" + +#: ../../c-api/object.rst:505 msgid "" "This is equivalent to the Python expression ``dir(o)``, returning a " "(possibly empty) list of strings appropriate for the object argument, or " @@ -613,7 +621,7 @@ msgid "" "`PyErr_Occurred` will return false." msgstr "" -#: ../../c-api/object.rst:506 +#: ../../c-api/object.rst:514 msgid "" "This is equivalent to the Python expression ``iter(o)``. It returns a new " "iterator for the object argument, or the object itself if the object is " @@ -621,7 +629,14 @@ msgid "" "object cannot be iterated." msgstr "" -#: ../../c-api/object.rst:514 +#: ../../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." +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. " @@ -630,104 +645,104 @@ msgid "" "``NULL`` if the object cannot be iterated." msgstr "" -#: ../../c-api/object.rst:524 +#: ../../c-api/object.rst:538 msgid "Get a pointer to subclass-specific data reserved for *cls*." msgstr "" -#: ../../c-api/object.rst:526 +#: ../../c-api/object.rst:540 msgid "" "The object *o* must be an instance of *cls*, and *cls* must have been " "created using negative :c:member:`PyType_Spec.basicsize`. Python does not " "check this." msgstr "" -#: ../../c-api/object.rst:530 +#: ../../c-api/object.rst:544 msgid "On error, set an exception and return ``NULL``." msgstr "" -#: ../../c-api/object.rst:536 +#: ../../c-api/object.rst:550 msgid "" "Return the size of the instance memory space reserved for *cls*, i.e. the " "size of the memory :c:func:`PyObject_GetTypeData` returns." msgstr "" -#: ../../c-api/object.rst:539 +#: ../../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`)." msgstr "" -#: ../../c-api/object.rst:542 +#: ../../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." msgstr "" -#: ../../c-api/object.rst:546 +#: ../../c-api/object.rst:560 msgid "On error, set an exception and return a negative value." msgstr "" -#: ../../c-api/object.rst:552 +#: ../../c-api/object.rst:566 msgid "" "Get a pointer to per-item data for a class with :c:macro:" "`Py_TPFLAGS_ITEMS_AT_END`." msgstr "" -#: ../../c-api/object.rst:555 +#: ../../c-api/object.rst:569 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 "" -#: ../../c-api/object.rst:563 +#: ../../c-api/object.rst:577 msgid "Visit the managed dictionary of *obj*." msgstr "" -#: ../../c-api/object.rst:565 ../../c-api/object.rst:574 +#: ../../c-api/object.rst:579 ../../c-api/object.rst:588 msgid "" "This function must only be called in a traverse function of the type which " "has the :c:macro:`Py_TPFLAGS_MANAGED_DICT` flag set." msgstr "" -#: ../../c-api/object.rst:572 +#: ../../c-api/object.rst:586 msgid "Clear the managed dictionary of *obj*." msgstr "" -#: ../../c-api/object.rst:315 ../../c-api/object.rst:327 -#: ../../c-api/object.rst:352 ../../c-api/object.rst:403 -#: ../../c-api/object.rst:437 ../../c-api/object.rst:458 +#: ../../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 msgid "built-in function" msgstr "bulit-in function(內建函式)" -#: ../../c-api/object.rst:315 +#: ../../c-api/object.rst:316 msgid "repr" msgstr "repr" -#: ../../c-api/object.rst:327 +#: ../../c-api/object.rst:328 msgid "ascii" msgstr "ascii" -#: ../../c-api/object.rst:335 +#: ../../c-api/object.rst:336 msgid "string" msgstr "string(字串)" -#: ../../c-api/object.rst:335 +#: ../../c-api/object.rst:336 msgid "PyObject_Str (C function)" msgstr "PyObject_Str(C 函式)" -#: ../../c-api/object.rst:352 +#: ../../c-api/object.rst:353 msgid "bytes" msgstr "bytes(位元組)" -#: ../../c-api/object.rst:403 +#: ../../c-api/object.rst:404 msgid "hash" msgstr "hash(雜湊)" -#: ../../c-api/object.rst:437 +#: ../../c-api/object.rst:438 msgid "type" msgstr "type(型別)" -#: ../../c-api/object.rst:458 +#: ../../c-api/object.rst:459 msgid "len" msgstr "len" diff --git a/c-api/refcounting.po b/c-api/refcounting.po index 4f44c6bec2..0343683dfa 100644 --- a/c-api/refcounting.po +++ b/c-api/refcounting.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2024-09-24 07:20+0000\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-" @@ -114,15 +114,14 @@ msgstr "" "該物件不能為 ``NULL``;如果你不確定它不是 ``NULL``,請使用 :c:func:" "`Py_XINCREF`。" -#: ../../c-api/refcounting.rst:64 ../../c-api/refcounting.rst:132 +#: ../../c-api/refcounting.rst:64 #, fuzzy msgid "" -"Do not expect this function to actually modify *o* in any way. For at least " -"`some objects `_, 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>`\\ " -"來說,此函式沒有任何效果。" +"不要期望此函式會以任何方式實際修改 *o*,至少對於\\ :pep:`某些物件 <683>`\\ 來" +"說,此函式沒有任何效果。" #: ../../c-api/refcounting.rst:74 msgid "" @@ -225,6 +224,14 @@ msgstr "" "該物件不能為 ``NULL``;如果你不確定它不是 ``NULL``,請改用 :c:func:" "`Py_XDECREF`。" +#: ../../c-api/refcounting.rst:132 +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." +msgstr "" +"不要期望此函式會以任何方式實際修改 *o*,至少對於\\ :pep:`某些物件 <683>`\\ 來" +"說,此函式沒有任何效果。" + #: ../../c-api/refcounting.rst:138 msgid "" "The deallocation function can cause arbitrary Python code to be invoked (e." @@ -352,9 +359,11 @@ msgstr "" ":c:macro:`Py_SETREF` 巨集的變體,請改用 :c:func:`Py_XDECREF` 而非 :c:func:" "`Py_DECREF`。" +#, fuzzy #~ 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." +#~ "least `some objects `_, this function " +#~ "has no effect." #~ msgstr "" #~ "不要期望此函式會以任何方式實際修改 *o*,至少對於\\ :pep:`某些物件 " -#~ "<683>`\\ 來說,此函式沒有任何效果。" +#~ "<0683>`\\ 來說,此函式沒有任何效果。" diff --git a/c-api/slice.po b/c-api/slice.po index a2b3dbc7a7..67f1bcdff8 100644 --- a/c-api/slice.po +++ b/c-api/slice.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-03-03 18:39+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-" @@ -160,10 +160,16 @@ msgstr "" #: ../../c-api/slice.rst:123 msgid "" +"The type of Python :const:`Ellipsis` object. Same as :class:`types." +"EllipsisType` in the Python layer." +msgstr "" + +#: ../../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 "" -#: ../../c-api/slice.rst:126 +#: ../../c-api/slice.rst:132 msgid ":c:data:`Py_Ellipsis` is immortal." msgstr ":c:data:`Py_Ellipsis` 為不滅的 (immortal)。" diff --git a/c-api/stable.po b/c-api/stable.po index 919634426e..58c72d5c6b 100644 --- a/c-api/stable.po +++ b/c-api/stable.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-01-19 00:03+0000\n" +"POT-Creation-Date: 2024-12-15 18:10+0000\n" "PO-Revision-Date: 2023-01-24 21:07+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -132,10 +132,11 @@ msgid "Limited C API" msgstr "受限 C API" #: ../../c-api/stable.rst:67 +#, fuzzy 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 work with " -"multiple versions of Python. Contents of the Limited API are :ref:`listed " +"Extensions that only use the Limited API can be compiled once and be loaded " +"on multiple versions of Python. Contents of the Limited API are :ref:`listed " "below `." msgstr "" "Python 3.2 引入了\\ *受限 API (Limited API)*,它是 Python C API 的一個子集。" @@ -150,12 +151,12 @@ msgstr "" "在包含 ``Python.h`` 之前定義此巨集以選擇只使用受限 API,並挑選受限 API 版本。" #: ../../c-api/stable.rst:77 +#, fuzzy msgid "" "Define ``Py_LIMITED_API`` to the value of :c:macro:`PY_VERSION_HEX` " "corresponding to the lowest Python version your extension supports. The " -"extension will work without recompilation with all Python 3 releases from " -"the specified one onward, and can use Limited API introduced up to that " -"version." +"extension will be ABI-compatible with all Python 3 releases from the " +"specified one onward, and can use Limited API introduced up to that version." msgstr "" "將 ``Py_LIMITED_API`` 定義為對應於你的擴充有支援的最低 Python 版本的 :c:" "macro:`PY_VERSION_HEX` 值。該擴充無需重新編譯即可與從指定版本開始的所有 " @@ -184,14 +185,24 @@ msgid "Stable ABI" msgstr "穩定 ABI" #: ../../c-api/stable.rst:96 +#, fuzzy msgid "" "To enable this, Python provides a *Stable ABI*: a set of symbols that will " -"remain compatible across Python 3.x versions." +"remain ABI-compatible across Python 3.x versions." msgstr "" "為了實現它,Python 提供了一個\\ *穩定 ABI (Stable ABI)*:一組將在各個 Python " "3.x 版本之間保持相容的符號。" -#: ../../c-api/stable.rst:99 +#: ../../c-api/stable.rst:101 +msgid "" +"The Stable ABI prevents ABI issues, like linker errors due to missing " +"symbols or data corruption due to changes in structure layouts or function " +"signatures. However, other changes in Python can change the *behavior* of " +"extensions. See Python's Backwards Compatibility Policy (:pep:`387`) for " +"details." +msgstr "" + +#: ../../c-api/stable.rst:107 msgid "" "The Stable ABI contains symbols exposed in the :ref:`Limited API `, but also other ones – for example, functions necessary to support " @@ -200,7 +211,7 @@ msgstr "" "穩定 ABI 被包含在\\ :ref:`受限 API ` 中開放的符號,但也包含其" "他符號 - 例如,支援舊版受限 API 所必需的函式。" -#: ../../c-api/stable.rst:103 +#: ../../c-api/stable.rst:111 msgid "" "On Windows, extensions that use the Stable ABI should be linked against " "``python3.dll`` rather than a version-specific library such as ``python39." @@ -209,7 +220,7 @@ msgstr "" "在 Windows 上,使用穩定 ABI 的擴充應該連接到 ``python3.dll`` 而不是特定版本的" "函式庫,例如 ``python39.dll``。" -#: ../../c-api/stable.rst:107 +#: ../../c-api/stable.rst:115 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 " @@ -222,7 +233,7 @@ msgstr "" "用者(或者打包工具)身上,例如使用 3.10+ 受限 API 建置的擴充不會為較低版本的 " "Python 所安裝。" -#: ../../c-api/stable.rst:114 +#: ../../c-api/stable.rst:122 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 " @@ -231,18 +242,18 @@ msgstr "" "穩定 ABI 中的所有函式都作為函式存在於 Python 的共享函式庫中,而不僅是作為巨" "集。這使得它們可被用於不使用 C 預處理器 (preprocessor) 的語言。" -#: ../../c-api/stable.rst:120 +#: ../../c-api/stable.rst:128 msgid "Limited API Scope and Performance" msgstr "受限 API 範圍和性能" -#: ../../c-api/stable.rst:122 +#: ../../c-api/stable.rst:130 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:125 +#: ../../c-api/stable.rst:133 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 " @@ -252,7 +263,7 @@ msgstr "" "`PyList_GET_ITEM` 為不可用。巨集運行可以更快,因為它可以依賴 list 物件的特定" "版本實作細節。" -#: ../../c-api/stable.rst:130 +#: ../../c-api/stable.rst:138 msgid "" "Without ``Py_LIMITED_API`` defined, some C API functions are inlined or " "replaced by macros. Defining ``Py_LIMITED_API`` disables this inlining, " @@ -263,7 +274,7 @@ msgstr "" "``Py_LIMITED_API`` 會禁用嵌入,從而隨著 Python 資料結構的改進而提高穩定性,但" "可能會降低性能。" -#: ../../c-api/stable.rst:135 +#: ../../c-api/stable.rst:143 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 " @@ -277,11 +288,11 @@ msgstr "" "將產生一個擴充,可以在特定版本的擴充不可用的地方發布 — 例如,用於即將發布的 " "Python 版本的預發布版本 (prerelease)。" -#: ../../c-api/stable.rst:144 +#: ../../c-api/stable.rst:152 msgid "Limited API Caveats" msgstr "受限 API 注意事項" -#: ../../c-api/stable.rst:146 +#: ../../c-api/stable.rst:154 msgid "" "Note that compiling with ``Py_LIMITED_API`` is *not* a complete guarantee " "that code conforms to the :ref:`Limited API ` or the :ref:" @@ -293,7 +304,7 @@ msgstr "" "``Py_LIMITED_API`` 僅涵蓋定義,但 API 還包括其他議題,例如預期的語義 " "(semantic)。" -#: ../../c-api/stable.rst:151 +#: ../../c-api/stable.rst:159 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 " @@ -307,7 +318,7 @@ msgstr "" "現在代表選擇預設行為,但在 Python 3.8 中,引數將被直接使用,導致 ``NULL`` 取" "消參照 (dereference) 且崩潰 (crash)。類似的引數適用於結構 (struct) 的欄位。" -#: ../../c-api/stable.rst:158 +#: ../../c-api/stable.rst:166 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." @@ -315,7 +326,7 @@ msgstr "" "另一個問題是,當有定義 ``Py_LIMITED_API`` 時,一些結構欄位目前不會被隱藏,即" "使它們是受限 API 的一部分。" -#: ../../c-api/stable.rst:161 +#: ../../c-api/stable.rst:169 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." @@ -323,7 +334,7 @@ msgstr "" "出於這些原因,我們建議要以它支援的\\ *所有*\\ 次要 Python 版本來測試擴充,並" "且最好使用\\ *最低*\\ 版本進行建置。" -#: ../../c-api/stable.rst:164 +#: ../../c-api/stable.rst:172 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 " @@ -334,7 +345,7 @@ msgstr "" "義 ``Py_LIMITED_API``,一些私有聲明也會因為技術原因(或者甚至是無意地,例如臭" "蟲)而被公開出來。" -#: ../../c-api/stable.rst:169 +#: ../../c-api/stable.rst:177 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 " @@ -346,11 +357,11 @@ msgstr "" "行編譯意味著擴充將能以 Python 3.12 運行,但不一定能以 Python 3.12 *編譯*。特" "別是如果穩定 ABI 保持穩定,部分受限 API 可能會被棄用和刪除。" -#: ../../c-api/stable.rst:179 +#: ../../c-api/stable.rst:187 msgid "Platform Considerations" msgstr "平台注意事項" -#: ../../c-api/stable.rst:181 +#: ../../c-api/stable.rst:189 msgid "" "ABI stability depends not only on Python, but also on the compiler used, " "lower-level libraries and compiler options. For the purposes of the :ref:" @@ -361,7 +372,7 @@ msgstr "" "於\\ :ref:`穩定 ABI ` 的目的,這些細節定義了一個「平台」。它們通" "常取決於作業系統種類和處理器架構" -#: ../../c-api/stable.rst:186 +#: ../../c-api/stable.rst:194 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 " @@ -372,11 +383,11 @@ msgstr "" "定 ABI 的方式建置。``python.org`` 和許多第三方發布者發布的 Windows 和 macOS " "版本就是這種情況。" -#: ../../c-api/stable.rst:196 +#: ../../c-api/stable.rst:204 msgid "Contents of Limited API" msgstr "受限 API 的內容" -#: ../../c-api/stable.rst:199 +#: ../../c-api/stable.rst:207 msgid "" "Currently, the :ref:`Limited API ` includes the following " "items:" diff --git a/c-api/structures.po b/c-api/structures.po index 76d856ee90..77a94f4310 100644 --- a/c-api/structures.po +++ b/c-api/structures.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-04-24 05:56+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-" @@ -95,80 +95,85 @@ msgstr "請見上面 :c:type:`PyVarObject` 的文件。" #: ../../c-api/structures.rst:68 msgid "" +"The base class of all other objects, the same as :class:`object` in Python." +msgstr "" + +#: ../../c-api/structures.rst:73 +msgid "" "Test if the *x* object is the *y* object, the same as ``x is y`` in Python." msgstr "" -#: ../../c-api/structures.rst:75 +#: ../../c-api/structures.rst:80 msgid "" "Test if an object is the ``None`` singleton, the same as ``x is None`` in " "Python." msgstr "" -#: ../../c-api/structures.rst:83 +#: ../../c-api/structures.rst:88 msgid "" "Test if an object is the ``True`` singleton, the same as ``x is True`` in " "Python." msgstr "" -#: ../../c-api/structures.rst:91 +#: ../../c-api/structures.rst:96 msgid "" "Test if an object is the ``False`` singleton, the same as ``x is False`` in " "Python." msgstr "" -#: ../../c-api/structures.rst:99 +#: ../../c-api/structures.rst:104 msgid "Get the type of the Python object *o*." msgstr "" -#: ../../c-api/structures.rst:101 +#: ../../c-api/structures.rst:106 msgid "Return a :term:`borrowed reference`." msgstr "" -#: ../../c-api/structures.rst:103 +#: ../../c-api/structures.rst:108 msgid "Use the :c:func:`Py_SET_TYPE` function to set an object type." msgstr "" -#: ../../c-api/structures.rst:105 +#: ../../c-api/structures.rst:110 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:112 +#: ../../c-api/structures.rst:117 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:120 +#: ../../c-api/structures.rst:125 msgid "Set the object *o* type to *type*." msgstr "將物件 *o* 的型別設為 *type*。" -#: ../../c-api/structures.rst:127 +#: ../../c-api/structures.rst:132 msgid "Get the size of the Python object *o*." msgstr "取得 Python 物件 *o* 的大小。" -#: ../../c-api/structures.rst:129 +#: ../../c-api/structures.rst:134 msgid "Use the :c:func:`Py_SET_SIZE` function to set an object size." msgstr "" -#: ../../c-api/structures.rst:131 +#: ../../c-api/structures.rst:136 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:138 +#: ../../c-api/structures.rst:143 msgid "Set the object *o* size to *size*." msgstr "將物件 *o* 的大小設為 *size*。" -#: ../../c-api/structures.rst:145 +#: ../../c-api/structures.rst:150 msgid "" "This is a macro which expands to initialization values for a new :c:type:" "`PyObject` type. This macro expands to::" msgstr "" -#: ../../c-api/structures.rst:148 +#: ../../c-api/structures.rst:153 msgid "" "_PyObject_EXTRA_INIT\n" "1, type," @@ -176,14 +181,14 @@ msgstr "" "_PyObject_EXTRA_INIT\n" "1, type," -#: ../../c-api/structures.rst:154 +#: ../../c-api/structures.rst:159 msgid "" "This is a macro which expands to initialization values for a new :c:type:" "`PyVarObject` type, including the :c:member:`~PyVarObject.ob_size` field. " "This macro expands to::" msgstr "" -#: ../../c-api/structures.rst:158 +#: ../../c-api/structures.rst:163 msgid "" "_PyObject_EXTRA_INIT\n" "1, type, size," @@ -191,11 +196,11 @@ msgstr "" "_PyObject_EXTRA_INIT\n" "1, type, size," -#: ../../c-api/structures.rst:163 +#: ../../c-api/structures.rst:168 msgid "Implementing functions and methods" msgstr "實作函式與方法" -#: ../../c-api/structures.rst:167 +#: ../../c-api/structures.rst:172 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 " @@ -205,11 +210,11 @@ msgid "" "reference." msgstr "" -#: ../../c-api/structures.rst:174 +#: ../../c-api/structures.rst:179 msgid "The function signature is::" msgstr "" -#: ../../c-api/structures.rst:176 +#: ../../c-api/structures.rst:181 msgid "" "PyObject *PyCFunction(PyObject *self,\n" " PyObject *args);" @@ -217,14 +222,14 @@ msgstr "" "PyObject *PyCFunction(PyObject *self,\n" " PyObject *args);" -#: ../../c-api/structures.rst:181 +#: ../../c-api/structures.rst:186 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:185 +#: ../../c-api/structures.rst:190 msgid "" "PyObject *PyCFunctionWithKeywords(PyObject *self,\n" " PyObject *args,\n" @@ -234,13 +239,13 @@ msgstr "" " PyObject *args,\n" " PyObject *kwargs);" -#: ../../c-api/structures.rst:192 +#: ../../c-api/structures.rst:197 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:196 +#: ../../c-api/structures.rst:201 #, fuzzy msgid "" "PyObject *PyCFunctionFast(PyObject *self,\n" @@ -251,14 +256,14 @@ msgstr "" " PyObject *const *args,\n" " Py_ssize_t nargs);" -#: ../../c-api/structures.rst:202 +#: ../../c-api/structures.rst:207 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:206 +#: ../../c-api/structures.rst:211 #, fuzzy msgid "" "PyObject *PyCFunctionFastWithKeywords(PyObject *self,\n" @@ -271,14 +276,14 @@ msgstr "" " Py_ssize_t nargs,\n" " PyObject *kwnames);" -#: ../../c-api/structures.rst:213 +#: ../../c-api/structures.rst:218 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:217 +#: ../../c-api/structures.rst:222 msgid "" "PyObject *PyCMethod(PyObject *self,\n" " PyTypeObject *defining_class,\n" @@ -292,29 +297,29 @@ msgstr "" " Py_ssize_t nargs,\n" " PyObject *kwnames)" -#: ../../c-api/structures.rst:228 +#: ../../c-api/structures.rst:233 msgid "" "Structure used to describe a method of an extension type. This structure " "has four fields:" msgstr "" -#: ../../c-api/structures.rst:233 +#: ../../c-api/structures.rst:238 msgid "Name of the method." msgstr "" -#: ../../c-api/structures.rst:237 +#: ../../c-api/structures.rst:242 msgid "Pointer to the C implementation." msgstr "" -#: ../../c-api/structures.rst:241 +#: ../../c-api/structures.rst:246 msgid "Flags bits indicating how the call should be constructed." msgstr "" -#: ../../c-api/structures.rst:245 +#: ../../c-api/structures.rst:250 msgid "Points to the contents of the docstring." msgstr "" -#: ../../c-api/structures.rst:247 +#: ../../c-api/structures.rst:252 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 " @@ -324,18 +329,18 @@ msgid "" "implementation uses the specific C type of the *self* object." msgstr "" -#: ../../c-api/structures.rst:255 +#: ../../c-api/structures.rst:260 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:260 +#: ../../c-api/structures.rst:265 msgid "There are these calling conventions:" msgstr "" -#: ../../c-api/structures.rst:264 +#: ../../c-api/structures.rst:269 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 " @@ -345,7 +350,7 @@ msgid "" "func:`PyArg_ParseTuple` or :c:func:`PyArg_UnpackTuple`." msgstr "" -#: ../../c-api/structures.rst:274 +#: ../../c-api/structures.rst:279 msgid "" "Can only be used in certain combinations with other flags: :ref:" "`METH_VARARGS | METH_KEYWORDS `, :ref:" @@ -354,11 +359,11 @@ msgid "" "METH_KEYWORDS>`." msgstr "" -#: ../../c-api/structures.rst:282 +#: ../../c-api/structures.rst:287 msgid ":c:expr:`METH_VARARGS | METH_KEYWORDS`" msgstr ":c:expr:`METH_VARARGS | METH_KEYWORDS`" -#: ../../c-api/structures.rst:283 +#: ../../c-api/structures.rst:288 msgid "" "Methods with these flags must be of type :c:type:`PyCFunctionWithKeywords`. " "The function expects three parameters: *self*, *args*, *kwargs* where " @@ -367,7 +372,7 @@ msgid "" "using :c:func:`PyArg_ParseTupleAndKeywords`." msgstr "" -#: ../../c-api/structures.rst:292 +#: ../../c-api/structures.rst:297 msgid "" "Fast calling convention supporting only positional arguments. The methods " "have the type :c:type:`PyCFunctionFast`. The first parameter is *self*, the " @@ -376,15 +381,15 @@ msgid "" "the array)." msgstr "" -#: ../../c-api/structures.rst:302 +#: ../../c-api/structures.rst:307 msgid "``METH_FASTCALL`` is now part of the :ref:`stable ABI `." msgstr "" -#: ../../c-api/structures.rst:307 +#: ../../c-api/structures.rst:312 msgid ":c:expr:`METH_FASTCALL | METH_KEYWORDS`" msgstr ":c:expr:`METH_FASTCALL | METH_KEYWORDS`" -#: ../../c-api/structures.rst:308 +#: ../../c-api/structures.rst:313 msgid "" "Extension of :c:macro:`METH_FASTCALL` supporting also keyword arguments, " "with methods of type :c:type:`PyCFunctionFastWithKeywords`. Keyword " @@ -396,17 +401,17 @@ msgid "" "the positional arguments." msgstr "" -#: ../../c-api/structures.rst:323 +#: ../../c-api/structures.rst:328 msgid "" "Can only be used in the combination with other flags: :ref:`METH_METHOD | " "METH_FASTCALL | METH_KEYWORDS `." msgstr "" -#: ../../c-api/structures.rst:329 +#: ../../c-api/structures.rst:334 msgid ":c:expr:`METH_METHOD | METH_FASTCALL | METH_KEYWORDS`" msgstr ":c:expr:`METH_METHOD | METH_FASTCALL | METH_KEYWORDS`" -#: ../../c-api/structures.rst:330 +#: ../../c-api/structures.rst:335 msgid "" "Extension of :ref:`METH_FASTCALL | METH_KEYWORDS ` supporting the *defining class*, that is, the class that " @@ -414,14 +419,14 @@ msgid "" "``Py_TYPE(self)``." msgstr "" -#: ../../c-api/structures.rst:335 +#: ../../c-api/structures.rst:340 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:344 +#: ../../c-api/structures.rst:349 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 " @@ -430,13 +435,13 @@ msgid "" "the second parameter will be ``NULL``." msgstr "" -#: ../../c-api/structures.rst:350 +#: ../../c-api/structures.rst:355 msgid "" "The function must have 2 parameters. Since the second parameter is unused, :" "c:macro:`Py_UNUSED` can be used to prevent a compiler warning." msgstr "" -#: ../../c-api/structures.rst:356 +#: ../../c-api/structures.rst:361 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 " @@ -445,7 +450,7 @@ msgid "" "single argument." msgstr "" -#: ../../c-api/structures.rst:362 +#: ../../c-api/structures.rst:367 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 " @@ -453,27 +458,27 @@ msgid "" "any given method." msgstr "" -#: ../../c-api/structures.rst:372 +#: ../../c-api/structures.rst:377 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:382 +#: ../../c-api/structures.rst:387 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:386 +#: ../../c-api/structures.rst:391 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:392 +#: ../../c-api/structures.rst:397 msgid "" "The method will be loaded in place of existing definitions. Without " "*METH_COEXIST*, the default is to skip repeated definitions. Since slot " @@ -486,20 +491,20 @@ msgid "" "wrapper object calls." msgstr "" -#: ../../c-api/structures.rst:404 +#: ../../c-api/structures.rst:409 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:408 +#: ../../c-api/structures.rst:413 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:412 +#: ../../c-api/structures.rst:417 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 " @@ -507,71 +512,71 @@ msgid "" "can be set to :const:`None` or ``NULL``." msgstr "" -#: ../../c-api/structures.rst:418 +#: ../../c-api/structures.rst:423 msgid ":attr:`function.__module__`" msgstr ":attr:`function.__module__`" -#: ../../c-api/structures.rst:420 +#: ../../c-api/structures.rst:425 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:429 +#: ../../c-api/structures.rst:434 msgid "Equivalent to ``PyCMethod_New(ml, self, module, NULL)``." msgstr "等價於 ``PyCMethod_New(ml, self, module, NULL)``。" -#: ../../c-api/structures.rst:434 +#: ../../c-api/structures.rst:439 msgid "Equivalent to ``PyCMethod_New(ml, self, NULL, NULL)``." msgstr "等價於 ``PyCMethod_New(ml, self, NULL, NULL)``。" -#: ../../c-api/structures.rst:438 +#: ../../c-api/structures.rst:443 msgid "Accessing attributes of extension types" msgstr "" -#: ../../c-api/structures.rst:442 +#: ../../c-api/structures.rst:447 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:447 +#: ../../c-api/structures.rst:452 msgid "Its fields are, in order:" msgstr "" -#: ../../c-api/structures.rst:451 +#: ../../c-api/structures.rst:456 msgid "" "Name of the member. A NULL value marks the end of a ``PyMemberDef[]`` array." msgstr "" -#: ../../c-api/structures.rst:454 +#: ../../c-api/structures.rst:459 msgid "The string should be static, no copy is made of it." msgstr "" -#: ../../c-api/structures.rst:458 +#: ../../c-api/structures.rst:463 msgid "" "The type of the member in the C struct. See :ref:`PyMemberDef-types` for the " "possible values." msgstr "" -#: ../../c-api/structures.rst:463 +#: ../../c-api/structures.rst:468 msgid "" "The offset in bytes that the member is located on the type’s object struct." msgstr "" -#: ../../c-api/structures.rst:467 +#: ../../c-api/structures.rst:472 msgid "" "Zero or more of the :ref:`PyMemberDef-flags`, combined using bitwise OR." msgstr "" -#: ../../c-api/structures.rst:471 +#: ../../c-api/structures.rst:476 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:475 +#: ../../c-api/structures.rst:480 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-" @@ -580,7 +585,7 @@ msgid "" "`T_OBJECT`) members can be deleted." msgstr "" -#: ../../c-api/structures.rst:484 +#: ../../c-api/structures.rst:489 msgid "" "For heap-allocated types (created using :c:func:`PyType_FromSpec` or " "similar), ``PyMemberDef`` may contain a definition for the special member " @@ -589,7 +594,7 @@ msgid "" "``Py_T_PYSSIZET`` and ``Py_READONLY``, for example::" msgstr "" -#: ../../c-api/structures.rst:490 +#: ../../c-api/structures.rst:495 msgid "" "static PyMemberDef spam_type_members[] = {\n" " {\"__vectorcalloffset__\", Py_T_PYSSIZET,\n" @@ -603,11 +608,11 @@ msgstr "" " {NULL} /* Sentinel */\n" "};" -#: ../../c-api/structures.rst:496 +#: ../../c-api/structures.rst:501 msgid "(You may need to ``#include `` for :c:func:`!offsetof`.)" msgstr "" -#: ../../c-api/structures.rst:498 +#: ../../c-api/structures.rst:503 msgid "" "The legacy offsets :c:member:`~PyTypeObject.tp_dictoffset` and :c:member:" "`~PyTypeObject.tp_weaklistoffset` can be defined similarly using " @@ -616,77 +621,77 @@ msgid "" "and :c:macro:`Py_TPFLAGS_MANAGED_WEAKREF` instead." msgstr "" -#: ../../c-api/structures.rst:506 +#: ../../c-api/structures.rst:511 msgid "" "``PyMemberDef`` is always available. Previously, it required including " "``\"structmember.h\"``." msgstr "" -#: ../../c-api/structures.rst:511 +#: ../../c-api/structures.rst:516 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:517 +#: ../../c-api/structures.rst:522 msgid "" "``PyMember_GetOne`` is always available. Previously, it required including " "``\"structmember.h\"``." msgstr "" -#: ../../c-api/structures.rst:522 +#: ../../c-api/structures.rst:527 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:528 +#: ../../c-api/structures.rst:533 msgid "" "``PyMember_SetOne`` is always available. Previously, it required including " "``\"structmember.h\"``." msgstr "" -#: ../../c-api/structures.rst:534 +#: ../../c-api/structures.rst:539 msgid "Member flags" msgstr "" -#: ../../c-api/structures.rst:536 +#: ../../c-api/structures.rst:541 msgid "The following flags can be used with :c:member:`PyMemberDef.flags`:" msgstr "" -#: ../../c-api/structures.rst:540 +#: ../../c-api/structures.rst:545 msgid "Not writable." msgstr "不可寫入。" -#: ../../c-api/structures.rst:544 +#: ../../c-api/structures.rst:549 msgid "" "Emit an ``object.__getattr__`` :ref:`audit event ` before " "reading." msgstr "" -#: ../../c-api/structures.rst:549 +#: ../../c-api/structures.rst:554 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:553 +#: ../../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:558 +#: ../../c-api/structures.rst:563 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." msgstr "" -#: ../../c-api/structures.rst:570 +#: ../../c-api/structures.rst:575 msgid "" "The :c:macro:`!RESTRICTED`, :c:macro:`!READ_RESTRICTED` and :c:macro:`!" "WRITE_RESTRICTED` macros available with ``#include \"structmember.h\"`` are " @@ -695,7 +700,7 @@ msgid "" "nothing." msgstr "" -#: ../../c-api/structures.rst:581 +#: ../../c-api/structures.rst:586 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 " @@ -704,11 +709,11 @@ msgid "" "names." msgstr "" -#: ../../c-api/structures.rst:590 +#: ../../c-api/structures.rst:595 msgid "Member types" msgstr "" -#: ../../c-api/structures.rst:592 +#: ../../c-api/structures.rst:597 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 " @@ -717,147 +722,147 @@ msgid "" "exception such as :exc:`TypeError` or :exc:`ValueError` is raised." msgstr "" -#: ../../c-api/structures.rst:600 +#: ../../c-api/structures.rst:605 msgid "" "Unless marked (D), attributes defined this way cannot be deleted using e.g. :" "keyword:`del` or :py:func:`delattr`." msgstr "" -#: ../../c-api/structures.rst:604 +#: ../../c-api/structures.rst:609 msgid "Macro name" msgstr "巨集名稱" -#: ../../c-api/structures.rst:604 +#: ../../c-api/structures.rst:609 msgid "C type" msgstr "" -#: ../../c-api/structures.rst:604 +#: ../../c-api/structures.rst:609 msgid "Python type" msgstr "" -#: ../../c-api/structures.rst:606 +#: ../../c-api/structures.rst:611 msgid ":c:expr:`char`" msgstr ":c:expr:`char`" -#: ../../c-api/structures.rst:606 ../../c-api/structures.rst:607 -#: ../../c-api/structures.rst:608 ../../c-api/structures.rst:609 -#: ../../c-api/structures.rst:610 ../../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: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 msgid ":py:class:`int`" msgstr ":py:class:`int`" -#: ../../c-api/structures.rst:607 +#: ../../c-api/structures.rst:612 msgid ":c:expr:`short`" msgstr ":c:expr:`short`" -#: ../../c-api/structures.rst:608 +#: ../../c-api/structures.rst:613 msgid ":c:expr:`int`" msgstr ":c:expr:`int`" -#: ../../c-api/structures.rst:609 +#: ../../c-api/structures.rst:614 msgid ":c:expr:`long`" msgstr ":c:expr:`long`" -#: ../../c-api/structures.rst:610 +#: ../../c-api/structures.rst:615 msgid ":c:expr:`long long`" msgstr ":c:expr:`long long`" -#: ../../c-api/structures.rst:611 +#: ../../c-api/structures.rst:616 msgid ":c:expr:`unsigned char`" msgstr ":c:expr:`unsigned char`" -#: ../../c-api/structures.rst:612 +#: ../../c-api/structures.rst:617 msgid ":c:expr:`unsigned int`" msgstr ":c:expr:`unsigned int`" -#: ../../c-api/structures.rst:613 +#: ../../c-api/structures.rst:618 msgid ":c:expr:`unsigned short`" msgstr ":c:expr:`unsigned short`" -#: ../../c-api/structures.rst:614 +#: ../../c-api/structures.rst:619 msgid ":c:expr:`unsigned long`" msgstr ":c:expr:`unsigned long`" -#: ../../c-api/structures.rst:615 +#: ../../c-api/structures.rst:620 msgid ":c:expr:`unsigned long long`" msgstr ":c:expr:`unsigned long long`" -#: ../../c-api/structures.rst:616 +#: ../../c-api/structures.rst:621 msgid ":c:expr:`Py_ssize_t`" msgstr ":c:expr:`Py_ssize_t`" -#: ../../c-api/structures.rst:617 +#: ../../c-api/structures.rst:622 msgid ":c:expr:`float`" msgstr ":c:expr:`float`" -#: ../../c-api/structures.rst:617 ../../c-api/structures.rst:618 +#: ../../c-api/structures.rst:622 ../../c-api/structures.rst:623 msgid ":py:class:`float`" msgstr ":py:class:`float`" -#: ../../c-api/structures.rst:618 +#: ../../c-api/structures.rst:623 msgid ":c:expr:`double`" msgstr ":c:expr:`double`" -#: ../../c-api/structures.rst:619 +#: ../../c-api/structures.rst:624 msgid ":c:expr:`char` (written as 0 or 1)" msgstr ":c:expr:`char` (寫成 0 或 1)" -#: ../../c-api/structures.rst:619 +#: ../../c-api/structures.rst:624 msgid ":py:class:`bool`" msgstr ":py:class:`bool`" -#: ../../c-api/structures.rst:621 +#: ../../c-api/structures.rst:626 msgid ":c:expr:`const char *` (*)" msgstr ":c:expr:`const char *` (*)" -#: ../../c-api/structures.rst:621 ../../c-api/structures.rst:622 +#: ../../c-api/structures.rst:626 ../../c-api/structures.rst:627 msgid ":py:class:`str` (RO)" msgstr ":py:class:`str` (RO)" -#: ../../c-api/structures.rst:622 +#: ../../c-api/structures.rst:627 msgid ":c:expr:`const char[]` (*)" msgstr ":c:expr:`const char[]` (*)" -#: ../../c-api/structures.rst:623 +#: ../../c-api/structures.rst:628 msgid ":c:expr:`char` (0-127)" msgstr ":c:expr:`char` (0-127)" -#: ../../c-api/structures.rst:623 +#: ../../c-api/structures.rst:628 msgid ":py:class:`str` (**)" msgstr ":py:class:`str` (**)" -#: ../../c-api/structures.rst:624 +#: ../../c-api/structures.rst:629 msgid ":c:expr:`PyObject *`" msgstr ":c:expr:`PyObject *`" -#: ../../c-api/structures.rst:624 +#: ../../c-api/structures.rst:629 msgid ":py:class:`object` (D)" msgstr ":py:class:`object` (D)" -#: ../../c-api/structures.rst:627 +#: ../../c-api/structures.rst:632 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:632 +#: ../../c-api/structures.rst:637 msgid "(**): String of length 1. Only ASCII is accepted." msgstr "" -#: ../../c-api/structures.rst:634 +#: ../../c-api/structures.rst:639 msgid "(RO): Implies :c:macro:`Py_READONLY`." msgstr "" -#: ../../c-api/structures.rst:636 +#: ../../c-api/structures.rst:641 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:662 +#: ../../c-api/structures.rst:667 msgid "" "In previous versions, the macros were only available with ``#include " "\"structmember.h\"`` and were named without the ``Py_`` prefix (e.g. as " @@ -865,174 +870,174 @@ msgid "" "with the following deprecated types:" msgstr "" -#: ../../c-api/structures.rst:670 +#: ../../c-api/structures.rst:675 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:676 +#: ../../c-api/structures.rst:681 msgid "Always ``None``. Must be used with :c:macro:`Py_READONLY`." msgstr "" -#: ../../c-api/structures.rst:679 +#: ../../c-api/structures.rst:684 msgid "Defining Getters and Setters" msgstr "" -#: ../../c-api/structures.rst:683 +#: ../../c-api/structures.rst:688 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:688 +#: ../../c-api/structures.rst:693 msgid "attribute name" msgstr "屬性名稱" -#: ../../c-api/structures.rst:692 +#: ../../c-api/structures.rst:697 msgid "C function to get the attribute." msgstr "" -#: ../../c-api/structures.rst:696 +#: ../../c-api/structures.rst:701 msgid "" "Optional C function to set or delete the attribute. If ``NULL``, the " "attribute is read-only." msgstr "" -#: ../../c-api/structures.rst:701 +#: ../../c-api/structures.rst:706 msgid "optional docstring" msgstr "可選的文件字串" -#: ../../c-api/structures.rst:705 +#: ../../c-api/structures.rst:710 msgid "" "Optional user data pointer, providing additional data for getter and setter." msgstr "" -#: ../../c-api/structures.rst:709 +#: ../../c-api/structures.rst:714 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:712 +#: ../../c-api/structures.rst:717 msgid "" "It should return a new reference on success or ``NULL`` with a set exception " "on failure." msgstr "" -#: ../../c-api/structures.rst:717 +#: ../../c-api/structures.rst:722 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:720 +#: ../../c-api/structures.rst:725 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:370 ../../c-api/structures.rst:380 +#: ../../c-api/structures.rst:375 ../../c-api/structures.rst:385 msgid "built-in function" msgstr "built-in function(內建函式)" -#: ../../c-api/structures.rst:370 +#: ../../c-api/structures.rst:375 msgid "classmethod" msgstr "classmethod" -#: ../../c-api/structures.rst:380 +#: ../../c-api/structures.rst:385 msgid "staticmethod" msgstr "staticmethod" -#: ../../c-api/structures.rst:563 +#: ../../c-api/structures.rst:568 msgid "READ_RESTRICTED (C macro)" msgstr "READ_RESTRICTED(C 巨集)" -#: ../../c-api/structures.rst:563 +#: ../../c-api/structures.rst:568 msgid "WRITE_RESTRICTED (C macro)" msgstr "WRITE_RESTRICTED(C 巨集)" -#: ../../c-api/structures.rst:563 +#: ../../c-api/structures.rst:568 msgid "RESTRICTED (C macro)" msgstr "RESTRICTED(C 巨集)" -#: ../../c-api/structures.rst:576 +#: ../../c-api/structures.rst:581 msgid "READONLY (C macro)" msgstr "READONLY(C 巨集)" -#: ../../c-api/structures.rst:639 +#: ../../c-api/structures.rst:644 msgid "T_BYTE (C macro)" msgstr "T_BYTE(C 巨集)" -#: ../../c-api/structures.rst:639 +#: ../../c-api/structures.rst:644 msgid "T_SHORT (C macro)" msgstr "T_SHORT(C 巨集)" -#: ../../c-api/structures.rst:639 +#: ../../c-api/structures.rst:644 msgid "T_INT (C macro)" msgstr "T_INT(C 巨集)" -#: ../../c-api/structures.rst:639 +#: ../../c-api/structures.rst:644 msgid "T_LONG (C macro)" msgstr "T_LONG(C 巨集)" -#: ../../c-api/structures.rst:639 +#: ../../c-api/structures.rst:644 msgid "T_LONGLONG (C macro)" msgstr "T_LONGLONG(C 巨集)" -#: ../../c-api/structures.rst:639 +#: ../../c-api/structures.rst:644 msgid "T_UBYTE (C macro)" msgstr "T_UBYTE(C 巨集)" -#: ../../c-api/structures.rst:639 +#: ../../c-api/structures.rst:644 msgid "T_USHORT (C macro)" msgstr "T_USHORT(C 巨集)" -#: ../../c-api/structures.rst:639 +#: ../../c-api/structures.rst:644 msgid "T_UINT (C macro)" msgstr "T_UINT(C 巨集)" -#: ../../c-api/structures.rst:639 +#: ../../c-api/structures.rst:644 msgid "T_ULONG (C macro)" msgstr "T_ULONG(C 巨集)" -#: ../../c-api/structures.rst:639 +#: ../../c-api/structures.rst:644 msgid "T_ULONGULONG (C macro)" msgstr "T_ULONGULONG(C 巨集)" -#: ../../c-api/structures.rst:639 +#: ../../c-api/structures.rst:644 msgid "T_PYSSIZET (C macro)" msgstr "T_PYSSIZET(C 巨集)" -#: ../../c-api/structures.rst:639 +#: ../../c-api/structures.rst:644 msgid "T_FLOAT (C macro)" msgstr "T_FLOAT(C 巨集)" -#: ../../c-api/structures.rst:639 +#: ../../c-api/structures.rst:644 msgid "T_DOUBLE (C macro)" msgstr "T_DOUBLE(C 巨集)" -#: ../../c-api/structures.rst:639 +#: ../../c-api/structures.rst:644 msgid "T_BOOL (C macro)" msgstr "T_BOOL(C 巨集)" -#: ../../c-api/structures.rst:639 +#: ../../c-api/structures.rst:644 msgid "T_CHAR (C macro)" msgstr "T_CHAR(C 巨集)" -#: ../../c-api/structures.rst:639 +#: ../../c-api/structures.rst:644 msgid "T_STRING (C macro)" msgstr "T_STRING(C 巨集)" -#: ../../c-api/structures.rst:639 +#: ../../c-api/structures.rst:644 msgid "T_STRING_INPLACE (C macro)" msgstr "T_STRING_INPLACE(C 巨集)" -#: ../../c-api/structures.rst:639 +#: ../../c-api/structures.rst:644 msgid "T_OBJECT_EX (C macro)" msgstr "T_OBJECT_EX(C 巨集)" -#: ../../c-api/structures.rst:639 +#: ../../c-api/structures.rst:644 msgid "structmember.h" msgstr "structmember.h" diff --git a/c-api/sys.po b/c-api/sys.po index 5fa011518f..39d60789fe 100644 --- a/c-api/sys.po +++ b/c-api/sys.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2024-12-15 18:10+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-" @@ -486,6 +486,10 @@ msgid "" "should be called by *func*." msgstr "" +#: ../../c-api/sys.rst:432 +msgid ":c:func:`PyUnstable_AtExit` for passing a ``void *data`` argument." +msgstr "" + #: ../../c-api/sys.rst:101 msgid "USE_STACKCHECK (C macro)" msgstr "USE_STACKCHECK(C 巨集)" diff --git a/c-api/time.po b/c-api/time.po index d41ea7d002..7636335954 100644 --- a/c-api/time.po +++ b/c-api/time.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2024-09-24 07:20+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,70 +17,70 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: ../../c-api/time.rst:4 +#: ../../c-api/time.rst:6 msgid "PyTime C API" msgstr "" -#: ../../c-api/time.rst:8 +#: ../../c-api/time.rst:10 msgid "" "The clock C API provides access to system clocks. It is similar to the " "Python :mod:`time` module." msgstr "" -#: ../../c-api/time.rst:11 +#: ../../c-api/time.rst:13 msgid "" "For C API related to the :mod:`datetime` module, see :ref:`datetimeobjects`." msgstr "" -#: ../../c-api/time.rst:15 +#: ../../c-api/time.rst:17 msgid "Types" msgstr "" -#: ../../c-api/time.rst:19 +#: ../../c-api/time.rst:21 msgid "" "A timestamp or duration in nanoseconds, represented as a signed 64-bit " "integer." msgstr "" -#: ../../c-api/time.rst:22 +#: ../../c-api/time.rst:24 msgid "" "The reference point for timestamps depends on the clock used. For example, :" "c:func:`PyTime_Time` returns timestamps relative to the UNIX epoch." msgstr "" -#: ../../c-api/time.rst:25 +#: ../../c-api/time.rst:27 msgid "" "The supported range is around [-292.3 years; +292.3 years]. Using the Unix " "epoch (January 1st, 1970) as reference, the supported date range is around " "[1677-09-21; 2262-04-11]. The exact limits are exposed as constants:" msgstr "" -#: ../../c-api/time.rst:32 +#: ../../c-api/time.rst:34 msgid "Minimum value of :c:type:`PyTime_t`." msgstr "" -#: ../../c-api/time.rst:36 +#: ../../c-api/time.rst:38 msgid "Maximum value of :c:type:`PyTime_t`." msgstr "" -#: ../../c-api/time.rst:40 +#: ../../c-api/time.rst:42 msgid "Clock Functions" msgstr "" -#: ../../c-api/time.rst:42 +#: ../../c-api/time.rst:44 msgid "" "The following functions take a pointer to a :c:expr:`PyTime_t` that they set " "to the value of a particular clock. Details of each clock are given in the " "documentation of the corresponding Python function." msgstr "" -#: ../../c-api/time.rst:47 +#: ../../c-api/time.rst:49 msgid "" "The functions return ``0`` on success, or ``-1`` (with an exception set) on " "failure." msgstr "" -#: ../../c-api/time.rst:50 +#: ../../c-api/time.rst:52 msgid "" "On integer overflow, they set the :c:data:`PyExc_OverflowError` exception " "and set ``*result`` to the value clamped to the ``[PyTime_MIN; PyTime_MAX]`` " @@ -88,45 +88,45 @@ msgid "" "misconfigured system time.)" msgstr "" -#: ../../c-api/time.rst:56 +#: ../../c-api/time.rst:58 msgid "" "As any other C API (unless otherwise specified), the functions must be " "called with the :term:`GIL` held." msgstr "" -#: ../../c-api/time.rst:61 +#: ../../c-api/time.rst:63 msgid "" "Read the monotonic clock. See :func:`time.monotonic` for important details " "on this clock." msgstr "" -#: ../../c-api/time.rst:66 +#: ../../c-api/time.rst:68 msgid "" "Read the performance counter. See :func:`time.perf_counter` for important " "details on this clock." msgstr "" -#: ../../c-api/time.rst:71 +#: ../../c-api/time.rst:73 msgid "" "Read the “wall clock” time. See :func:`time.time` for details important on " "this clock." msgstr "" -#: ../../c-api/time.rst:76 +#: ../../c-api/time.rst:78 msgid "Raw Clock Functions" msgstr "" -#: ../../c-api/time.rst:78 +#: ../../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 "" -#: ../../c-api/time.rst:81 +#: ../../c-api/time.rst:83 msgid "On success, the functions return ``0``." msgstr "" -#: ../../c-api/time.rst:83 +#: ../../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 " @@ -134,33 +134,33 @@ msgid "" "succeed after the ``Raw`` one failed." msgstr "" -#: ../../c-api/time.rst:90 +#: ../../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." msgstr "" -#: ../../c-api/time.rst:95 +#: ../../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." msgstr "" -#: ../../c-api/time.rst:100 +#: ../../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." msgstr "" -#: ../../c-api/time.rst:105 +#: ../../c-api/time.rst:107 msgid "Conversion functions" msgstr "" -#: ../../c-api/time.rst:109 +#: ../../c-api/time.rst:111 msgid "Convert a timestamp to a number of seconds as a C :c:expr:`double`." msgstr "" -#: ../../c-api/time.rst:111 +#: ../../c-api/time.rst:113 msgid "" "The function cannot fail, but note that :c:expr:`double` has limited " "accuracy for large values." diff --git a/c-api/tuple.po b/c-api/tuple.po index 3e5dbda024..30724c0d7e 100644 --- a/c-api/tuple.po +++ b/c-api/tuple.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2024-10-13 17:13+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-" @@ -119,8 +119,8 @@ msgid "" "*only* be used to fill in brand new tuples." msgstr "" -#: ../../c-api/tuple.rst:102 ../../c-api/tuple.rst:217 -#: ../../c-api/tuple.rst:235 +#: ../../c-api/tuple.rst:102 ../../c-api/tuple.rst:218 +#: ../../c-api/tuple.rst:236 msgid "" "Bounds checking is performed as an assertion if Python is built in :ref:" "`debug mode ` or :option:`with assertions <--with-assertions>`." @@ -167,7 +167,7 @@ msgid "" "`PyStructSequence_New`." msgstr "" -#: ../../c-api/tuple.rst:142 ../../c-api/tuple.rst:210 +#: ../../c-api/tuple.rst:142 ../../c-api/tuple.rst:211 msgid "Return ``NULL`` with an exception set on failure." msgstr "" @@ -186,22 +186,24 @@ msgid "Contains the meta information of a struct sequence type to create." msgstr "" #: ../../c-api/tuple.rst:164 -msgid "Name of the struct sequence type." +msgid "" +"Fully qualified name of the type; null-terminated UTF-8 encoded. The name " +"must contain the module name." msgstr "" -#: ../../c-api/tuple.rst:168 +#: ../../c-api/tuple.rst:169 msgid "Pointer to docstring for the type or ``NULL`` to omit." msgstr "" -#: ../../c-api/tuple.rst:172 +#: ../../c-api/tuple.rst:173 msgid "Pointer to ``NULL``-terminated array with field names of the new type." msgstr "" -#: ../../c-api/tuple.rst:176 +#: ../../c-api/tuple.rst:177 msgid "Number of fields visible to the Python side (if used as tuple)." msgstr "" -#: ../../c-api/tuple.rst:181 +#: ../../c-api/tuple.rst:182 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:" @@ -210,59 +212,59 @@ msgid "" "described." msgstr "" -#: ../../c-api/tuple.rst:189 +#: ../../c-api/tuple.rst:190 msgid "" "Name for the field or ``NULL`` to end the list of named fields, set to :c:" "data:`PyStructSequence_UnnamedField` to leave unnamed." msgstr "" -#: ../../c-api/tuple.rst:194 +#: ../../c-api/tuple.rst:195 msgid "Field docstring or ``NULL`` to omit." msgstr "" -#: ../../c-api/tuple.rst:199 +#: ../../c-api/tuple.rst:200 msgid "Special value for a field name to leave it unnamed." msgstr "" -#: ../../c-api/tuple.rst:201 +#: ../../c-api/tuple.rst:202 msgid "The type was changed from ``char *``." msgstr "" -#: ../../c-api/tuple.rst:207 +#: ../../c-api/tuple.rst:208 msgid "" "Creates an instance of *type*, which must have been created with :c:func:" "`PyStructSequence_NewType`." msgstr "" -#: ../../c-api/tuple.rst:215 +#: ../../c-api/tuple.rst:216 msgid "" "Return the object at position *pos* in the struct sequence pointed to by *p*." msgstr "" -#: ../../c-api/tuple.rst:223 +#: ../../c-api/tuple.rst:224 msgid "Alias to :c:func:`PyStructSequence_GetItem`." msgstr "" -#: ../../c-api/tuple.rst:225 +#: ../../c-api/tuple.rst:226 msgid "Now implemented as an alias to :c:func:`PyStructSequence_GetItem`." msgstr "" -#: ../../c-api/tuple.rst:231 +#: ../../c-api/tuple.rst:232 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 "" -#: ../../c-api/tuple.rst:240 +#: ../../c-api/tuple.rst:241 msgid "This function \"steals\" a reference to *o*." msgstr "" -#: ../../c-api/tuple.rst:245 +#: ../../c-api/tuple.rst:246 msgid "Alias to :c:func:`PyStructSequence_SetItem`." msgstr "" -#: ../../c-api/tuple.rst:247 +#: ../../c-api/tuple.rst:248 msgid "Now implemented as an alias to :c:func:`PyStructSequence_SetItem`." msgstr "" diff --git a/c-api/type.po b/c-api/type.po index 0cba8494b9..5f0ed1e68f 100644 --- a/c-api/type.po +++ b/c-api/type.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-04-24 05:56+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-" @@ -65,32 +65,32 @@ msgstr "" #: ../../c-api/type.rst:55 msgid "" "Return the type object's internal namespace, which is otherwise only exposed " -"via a read-only proxy (``cls.__dict__``). This is a replacement for " -"accessing :c:member:`~PyTypeObject.tp_dict` directly. The returned " -"dictionary must be treated as read-only." +"via a read-only proxy (:attr:`cls.__dict__ `). This is a " +"replacement for accessing :c:member:`~PyTypeObject.tp_dict` directly. The " +"returned dictionary must be treated as read-only." msgstr "" -#: ../../c-api/type.rst:60 +#: ../../c-api/type.rst:61 msgid "" "This function is meant for specific embedding and language-binding cases, " "where direct access to the dict is necessary and indirect access (e.g. via " "the proxy or :c:func:`PyObject_GetAttr`) isn't adequate." msgstr "" -#: ../../c-api/type.rst:64 +#: ../../c-api/type.rst:65 msgid "" "Extension modules should continue to use ``tp_dict``, directly or " "indirectly, when setting up their own types." msgstr "" -#: ../../c-api/type.rst:72 +#: ../../c-api/type.rst:73 msgid "" "Invalidate the internal lookup cache for the type and all of its subtypes. " "This function must be called after any manual modification of the attributes " "or base classes of the type." msgstr "" -#: ../../c-api/type.rst:79 +#: ../../c-api/type.rst:80 msgid "" "Register *callback* as a type watcher. Return a non-negative integer ID " "which must be passed to future calls to :c:func:`PyType_Watch`. In case of " @@ -98,21 +98,27 @@ msgid "" "exception." msgstr "" -#: ../../c-api/type.rst:89 +#: ../../c-api/type.rst:85 +msgid "" +"In free-threaded builds, :c:func:`PyType_AddWatcher` is not thread-safe, so " +"it must be called at start up (before spawning the first thread)." +msgstr "" + +#: ../../c-api/type.rst:93 msgid "" "Clear watcher identified by *watcher_id* (previously returned from :c:func:" "`PyType_AddWatcher`). Return ``0`` on success, ``-1`` on error (e.g. if " "*watcher_id* was never registered.)" msgstr "" -#: ../../c-api/type.rst:93 +#: ../../c-api/type.rst:97 msgid "" "An extension should never call ``PyType_ClearWatcher`` with a *watcher_id* " "that was not returned to it by a previous call to :c:func:" "`PyType_AddWatcher`." msgstr "" -#: ../../c-api/type.rst:102 +#: ../../c-api/type.rst:106 msgid "" "Mark *type* as watched. The callback granted *watcher_id* by :c:func:" "`PyType_AddWatcher` will be called whenever :c:func:`PyType_Modified` " @@ -122,61 +128,61 @@ msgid "" "detail and subject to change.)" msgstr "" -#: ../../c-api/type.rst:109 +#: ../../c-api/type.rst:113 msgid "" "An extension should never call ``PyType_Watch`` with a *watcher_id* that was " "not returned to it by a previous call to :c:func:`PyType_AddWatcher`." msgstr "" -#: ../../c-api/type.rst:117 +#: ../../c-api/type.rst:121 msgid "Type of a type-watcher callback function." msgstr "" -#: ../../c-api/type.rst:119 +#: ../../c-api/type.rst:123 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:128 +#: ../../c-api/type.rst:132 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:134 +#: ../../c-api/type.rst:138 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:140 +#: ../../c-api/type.rst:144 msgid "Return true if *a* is a subtype of *b*." msgstr "" -#: ../../c-api/type.rst:142 +#: ../../c-api/type.rst:146 msgid "" -"This function only checks for actual subtypes, which means that :meth:" -"`~class.__subclasscheck__` is not called on *b*. Call :c:func:" -"`PyObject_IsSubclass` to do the same check that :func:`issubclass` would do." +"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:150 +#: ../../c-api/type.rst:154 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``." msgstr "" -#: ../../c-api/type.rst:156 +#: ../../c-api/type.rst:160 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." msgstr "" -#: ../../c-api/type.rst:161 +#: ../../c-api/type.rst:165 msgid "" "Finalize a type object. This should be called on all type objects to finish " "their initialization. This function is responsible for adding inherited " @@ -184,7 +190,7 @@ msgid "" "and sets an exception on error." msgstr "" -#: ../../c-api/type.rst:167 +#: ../../c-api/type.rst:171 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 " @@ -195,32 +201,32 @@ msgid "" "handle." msgstr "" -#: ../../c-api/type.rst:177 +#: ../../c-api/type.rst:181 msgid "" -"Return the type's name. Equivalent to getting the type's ``__name__`` " -"attribute." +"Return the type's name. Equivalent to getting the type's :attr:`~type." +"__name__` attribute." msgstr "" -#: ../../c-api/type.rst:183 +#: ../../c-api/type.rst:188 msgid "" -"Return the type's qualified name. Equivalent to getting the type's " -"``__qualname__`` attribute." +"Return the type's qualified name. Equivalent to getting the type's :attr:" +"`~type.__qualname__` attribute." msgstr "" -#: ../../c-api/type.rst:190 +#: ../../c-api/type.rst:195 msgid "" "Return the type's fully qualified name. Equivalent to ``f\"{type.__module__}." -"{type.__qualname__}\"``, or ``type.__qualname__`` if ``type.__module__`` is " -"not a string or is equal to ``\"builtins\"``." +"{type.__qualname__}\"``, or :attr:`type.__qualname__` if :attr:`type." +"__module__` is not a string or is equal to ``\"builtins\"``." msgstr "" -#: ../../c-api/type.rst:198 +#: ../../c-api/type.rst:203 msgid "" -"Return the type's module name. Equivalent to getting the ``type.__module__`` " -"attribute." +"Return the type's module name. Equivalent to getting the :attr:`type." +"__module__` attribute." msgstr "" -#: ../../c-api/type.rst:205 +#: ../../c-api/type.rst:210 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 " @@ -228,30 +234,30 @@ msgid "" "result pointer into the appropriate function type." msgstr "" -#: ../../c-api/type.rst:211 +#: ../../c-api/type.rst:216 msgid "" "See :c:member:`PyType_Slot.slot` for possible values of the *slot* argument." msgstr "" -#: ../../c-api/type.rst:215 +#: ../../c-api/type.rst:220 msgid "" ":c:func:`PyType_GetSlot` can now accept all types. Previously, it was " "limited to :ref:`heap types `." msgstr "" -#: ../../c-api/type.rst:221 +#: ../../c-api/type.rst:226 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:224 ../../c-api/type.rst:244 +#: ../../c-api/type.rst:229 ../../c-api/type.rst:249 msgid "" "If no module is associated with the given type, sets :py:class:`TypeError` " "and returns ``NULL``." msgstr "" -#: ../../c-api/type.rst:227 +#: ../../c-api/type.rst:232 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 " @@ -262,31 +268,31 @@ msgid "" "type:`!PyCMethod` cannot be used." msgstr "" -#: ../../c-api/type.rst:240 +#: ../../c-api/type.rst:245 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:247 +#: ../../c-api/type.rst:252 msgid "" "If the *type* has an associated module but its state is ``NULL``, returns " "``NULL`` without setting an exception." msgstr "" -#: ../../c-api/type.rst:254 +#: ../../c-api/type.rst:259 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:257 +#: ../../c-api/type.rst:262 msgid "" "If no module is found, raises a :py:class:`TypeError` and returns ``NULL``." msgstr "" -#: ../../c-api/type.rst:259 +#: ../../c-api/type.rst:264 msgid "" "This function is intended to be used together with :c:func:" "`PyModule_GetState()` to get module state from slot methods (such as :c:" @@ -295,40 +301,40 @@ msgid "" "type:`PyCMethod` calling convention." msgstr "" -#: ../../c-api/type.rst:269 +#: ../../c-api/type.rst:274 msgid "Attempt to assign a version tag to the given type." msgstr "" -#: ../../c-api/type.rst:271 +#: ../../c-api/type.rst:276 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:278 +#: ../../c-api/type.rst:283 msgid "Creating Heap-Allocated Types" msgstr "" -#: ../../c-api/type.rst:280 +#: ../../c-api/type.rst:285 msgid "" "The following functions and structs are used to create :ref:`heap types " "`." msgstr "" -#: ../../c-api/type.rst:285 +#: ../../c-api/type.rst:290 msgid "" "Create and return a :ref:`heap type ` from the *spec* (see :c:" "macro:`Py_TPFLAGS_HEAPTYPE`)." msgstr "" -#: ../../c-api/type.rst:288 +#: ../../c-api/type.rst:293 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:292 +#: ../../c-api/type.rst:297 msgid "" "Metaclasses that override :c:member:`~PyTypeObject.tp_new` are not " "supported, except if ``tp_new`` is ``NULL``. (For backwards compatibility, " @@ -337,7 +343,7 @@ msgid "" "deprecated and in Python 3.14+ such metaclasses will not be supported.)" msgstr "" -#: ../../c-api/type.rst:299 +#: ../../c-api/type.rst:304 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 " @@ -346,7 +352,7 @@ msgid "" "derives from :class:`object`." msgstr "" -#: ../../c-api/type.rst:305 +#: ../../c-api/type.rst:310 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``, " @@ -355,11 +361,11 @@ msgid "" "subclasses; it must be specified for each class individually." msgstr "" -#: ../../c-api/type.rst:312 +#: ../../c-api/type.rst:317 msgid "This function calls :c:func:`PyType_Ready` on the new type." msgstr "" -#: ../../c-api/type.rst:314 +#: ../../c-api/type.rst:319 msgid "" "Note that this function does *not* fully match the behavior of calling :py:" "class:`type() ` or using the :keyword:`class` statement. With user-" @@ -368,41 +374,41 @@ msgid "" "Specifically:" msgstr "" -#: ../../c-api/type.rst:321 +#: ../../c-api/type.rst:326 msgid "" ":py:meth:`~object.__new__` is not called on the new class (and it must be " "set to ``type.__new__``)." msgstr "" -#: ../../c-api/type.rst:323 +#: ../../c-api/type.rst:328 msgid ":py:meth:`~object.__init__` is not called on the new class." msgstr "" -#: ../../c-api/type.rst:324 +#: ../../c-api/type.rst:329 msgid ":py:meth:`~object.__init_subclass__` is not called on any bases." msgstr "" -#: ../../c-api/type.rst:325 +#: ../../c-api/type.rst:330 msgid ":py:meth:`~object.__set_name__` is not called on new descriptors." msgstr "" -#: ../../c-api/type.rst:331 +#: ../../c-api/type.rst:336 msgid "Equivalent to ``PyType_FromMetaclass(NULL, module, spec, bases)``." msgstr "等價於 ``PyType_FromMetaclass(NULL, module, spec, bases)``。" -#: ../../c-api/type.rst:337 +#: ../../c-api/type.rst:342 msgid "" "The function now accepts a single class as the *bases* argument and ``NULL`` " "as the ``tp_doc`` slot." msgstr "" -#: ../../c-api/type.rst:342 ../../c-api/type.rst:359 +#: ../../c-api/type.rst:347 ../../c-api/type.rst:364 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:345 ../../c-api/type.rst:362 ../../c-api/type.rst:378 +#: ../../c-api/type.rst:350 ../../c-api/type.rst:367 ../../c-api/type.rst:383 msgid "" "The :c:member:`~PyTypeObject.tp_new` of the metaclass is *ignored*. which " "may result in incomplete initialization. Creating classes whose metaclass " @@ -410,60 +416,62 @@ msgid "" "it will be no longer allowed." msgstr "" -#: ../../c-api/type.rst:353 +#: ../../c-api/type.rst:358 msgid "Equivalent to ``PyType_FromMetaclass(NULL, NULL, spec, bases)``." msgstr "等價於 ``PyType_FromMetaclass(NULL, NULL, spec, bases)``。" -#: ../../c-api/type.rst:370 +#: ../../c-api/type.rst:375 msgid "Equivalent to ``PyType_FromMetaclass(NULL, NULL, spec, NULL)``." msgstr "等價於 ``PyType_FromMetaclass(NULL, NULL, spec, NULL)``。" -#: ../../c-api/type.rst:374 +#: ../../c-api/type.rst:379 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:395 +#: ../../c-api/type.rst:400 msgid "Structure defining a type's behavior." msgstr "" -#: ../../c-api/type.rst:399 +#: ../../c-api/type.rst:404 msgid "Name of the type, used to set :c:member:`PyTypeObject.tp_name`." msgstr "" -#: ../../c-api/type.rst:403 +#: ../../c-api/type.rst:408 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:406 +#: ../../c-api/type.rst:411 msgid "" "If zero, specifies that :c:member:`~PyTypeObject.tp_basicsize` should be " "inherited." msgstr "" -#: ../../c-api/type.rst:409 +#: ../../c-api/type.rst:414 msgid "" "If negative, the absolute value specifies how much space instances of the " "class need *in addition* to the superclass. Use :c:func:" "`PyObject_GetTypeData` to get a pointer to subclass-specific memory reserved " -"this way." +"this way. For negative :c:member:`!basicsize`, Python will insert padding " +"when needed to meet :c:member:`~PyTypeObject.tp_basicsize`'s alignment " +"requirements." msgstr "" -#: ../../c-api/type.rst:416 +#: ../../c-api/type.rst:424 msgid "Previously, this field could not be negative." msgstr "" -#: ../../c-api/type.rst:420 +#: ../../c-api/type.rst:428 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:424 +#: ../../c-api/type.rst:432 msgid "" "If zero, :c:member:`~PyTypeObject.tp_itemsize` is inherited. Extending " "arbitrary variable-sized classes is dangerous, since some types use a fixed " @@ -472,58 +480,58 @@ msgid "" "only possible in the following situations:" msgstr "" -#: ../../c-api/type.rst:431 +#: ../../c-api/type.rst:439 msgid "" "The base is not variable-sized (its :c:member:`~PyTypeObject.tp_itemsize`)." msgstr "" -#: ../../c-api/type.rst:433 +#: ../../c-api/type.rst:441 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:435 +#: ../../c-api/type.rst:443 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:438 +#: ../../c-api/type.rst:446 msgid "With the :c:macro:`Py_TPFLAGS_ITEMS_AT_END` flag." msgstr "" -#: ../../c-api/type.rst:442 +#: ../../c-api/type.rst:450 msgid "Type flags, used to set :c:member:`PyTypeObject.tp_flags`." msgstr "" -#: ../../c-api/type.rst:444 +#: ../../c-api/type.rst:452 msgid "" "If the ``Py_TPFLAGS_HEAPTYPE`` flag is not set, :c:func:" "`PyType_FromSpecWithBases` sets it automatically." msgstr "" -#: ../../c-api/type.rst:449 +#: ../../c-api/type.rst:457 msgid "" "Array of :c:type:`PyType_Slot` structures. Terminated by the special slot " "value ``{0, NULL}``." msgstr "" -#: ../../c-api/type.rst:452 +#: ../../c-api/type.rst:460 msgid "Each slot ID should be specified at most once." msgstr "" -#: ../../c-api/type.rst:462 +#: ../../c-api/type.rst:470 msgid "" "Structure defining optional functionality of a type, containing a slot ID " "and a value pointer." msgstr "" -#: ../../c-api/type.rst:467 +#: ../../c-api/type.rst:475 msgid "A slot ID." msgstr "" -#: ../../c-api/type.rst:469 +#: ../../c-api/type.rst:477 msgid "" "Slot IDs are named like the field names of the structures :c:type:" "`PyTypeObject`, :c:type:`PyNumberMethods`, :c:type:`PySequenceMethods`, :c:" @@ -531,30 +539,30 @@ msgid "" "prefix. For example, use:" msgstr "" -#: ../../c-api/type.rst:475 +#: ../../c-api/type.rst:483 msgid "``Py_tp_dealloc`` to set :c:member:`PyTypeObject.tp_dealloc`" msgstr "" -#: ../../c-api/type.rst:476 +#: ../../c-api/type.rst:484 msgid "``Py_nb_add`` to set :c:member:`PyNumberMethods.nb_add`" msgstr "" -#: ../../c-api/type.rst:477 +#: ../../c-api/type.rst:485 msgid "``Py_sq_length`` to set :c:member:`PySequenceMethods.sq_length`" msgstr "" -#: ../../c-api/type.rst:479 +#: ../../c-api/type.rst:487 msgid "" "The following “offset” fields cannot be set using :c:type:`PyType_Slot`:" msgstr "" -#: ../../c-api/type.rst:481 +#: ../../c-api/type.rst:489 msgid "" ":c:member:`~PyTypeObject.tp_weaklistoffset` (use :c:macro:" "`Py_TPFLAGS_MANAGED_WEAKREF` instead if possible)" msgstr "" -#: ../../c-api/type.rst:483 +#: ../../c-api/type.rst:491 msgid "" ":c:member:`~PyTypeObject.tp_dictoffset` (use :c:macro:" "`Py_TPFLAGS_MANAGED_DICT` instead if possible)" @@ -562,7 +570,7 @@ msgstr "" ":c:member:`~PyTypeObject.tp_dictoffset`\\ (如果可能,請改用 :c:macro:" "`Py_TPFLAGS_MANAGED_DICT`)" -#: ../../c-api/type.rst:485 +#: ../../c-api/type.rst:493 msgid "" ":c:member:`~PyTypeObject.tp_vectorcall_offset` (use " "``\"__vectorcalloffset__\"`` in :ref:`PyMemberDef `)" @@ -570,7 +578,7 @@ msgstr "" ":c:member:`~PyTypeObject.tp_vectorcall_offset`\\ (請用 :ref:`PyMemberDef " "` 中的 ``\"__vectorcalloffset__\"``)" -#: ../../c-api/type.rst:489 +#: ../../c-api/type.rst:497 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:" @@ -578,48 +586,48 @@ msgid "" "documentation ` for details." msgstr "" -#: ../../c-api/type.rst:495 +#: ../../c-api/type.rst:503 msgid "The following fields cannot be set at all when creating a heap type:" msgstr "" -#: ../../c-api/type.rst:497 +#: ../../c-api/type.rst:505 msgid "" ":c:member:`~PyTypeObject.tp_vectorcall` (use :c:member:`~PyTypeObject." "tp_new` and/or :c:member:`~PyTypeObject.tp_init`)" msgstr "" -#: ../../c-api/type.rst:501 +#: ../../c-api/type.rst:509 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`." msgstr "" -#: ../../c-api/type.rst:508 +#: ../../c-api/type.rst:516 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:515 +#: ../../c-api/type.rst:521 msgid "Slots in :c:type:`PyBufferProcs` may be set in the unlimited API." msgstr "" -#: ../../c-api/type.rst:517 +#: ../../c-api/type.rst:524 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:524 +#: ../../c-api/type.rst:531 msgid "" "The desired value of the slot. In most cases, this is a pointer to a " "function." msgstr "" -#: ../../c-api/type.rst:527 +#: ../../c-api/type.rst:534 msgid "Slots other than ``Py_tp_doc`` may not be ``NULL``." msgstr "" diff --git a/c-api/typeobj.po b/c-api/typeobj.po index a19d40c885..2f906148a2 100644 --- a/c-api/typeobj.po +++ b/c-api/typeobj.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-04-24 05:56+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-" @@ -19,7 +19,8 @@ msgstr "" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/typeobj.rst:6 -msgid "Type Objects" +#, fuzzy +msgid "Type Object Structures" msgstr "型別物件" #: ../../c-api/typeobj.rst:8 @@ -1173,7 +1174,7 @@ msgstr "" #: ../../c-api/typeobj.rst:475 msgid "" "The structure definition for :c:type:`PyTypeObject` can be found in :file:" -"`Include/object.h`. For convenience of reference, this repeats the " +"`Include/cpython/object.h`. For convenience of reference, this repeats the " "definition found there:" msgstr "" @@ -1292,42 +1293,42 @@ msgid "" msgstr "" #: ../../c-api/typeobj.rst:503 ../../c-api/typeobj.rst:526 -#: ../../c-api/typeobj.rst:540 ../../c-api/typeobj.rst:584 -#: ../../c-api/typeobj.rst:627 ../../c-api/typeobj.rst:686 -#: ../../c-api/typeobj.rst:727 ../../c-api/typeobj.rst:744 -#: ../../c-api/typeobj.rst:761 ../../c-api/typeobj.rst:779 -#: ../../c-api/typeobj.rst:803 ../../c-api/typeobj.rst:820 -#: ../../c-api/typeobj.rst:832 ../../c-api/typeobj.rst:844 -#: ../../c-api/typeobj.rst:877 ../../c-api/typeobj.rst:899 -#: ../../c-api/typeobj.rst:919 ../../c-api/typeobj.rst:940 -#: ../../c-api/typeobj.rst:966 ../../c-api/typeobj.rst:985 -#: ../../c-api/typeobj.rst:1001 ../../c-api/typeobj.rst:1040 -#: ../../c-api/typeobj.rst:1051 ../../c-api/typeobj.rst:1061 -#: ../../c-api/typeobj.rst:1071 ../../c-api/typeobj.rst:1085 -#: ../../c-api/typeobj.rst:1103 ../../c-api/typeobj.rst:1126 -#: ../../c-api/typeobj.rst:1144 ../../c-api/typeobj.rst:1157 -#: ../../c-api/typeobj.rst:1179 ../../c-api/typeobj.rst:1223 -#: ../../c-api/typeobj.rst:1244 ../../c-api/typeobj.rst:1263 -#: ../../c-api/typeobj.rst:1293 ../../c-api/typeobj.rst:1315 -#: ../../c-api/typeobj.rst:1341 ../../c-api/typeobj.rst:1426 -#: ../../c-api/typeobj.rst:1500 ../../c-api/typeobj.rst:1561 -#: ../../c-api/typeobj.rst:1597 ../../c-api/typeobj.rst:1622 -#: ../../c-api/typeobj.rst:1645 ../../c-api/typeobj.rst:1658 -#: ../../c-api/typeobj.rst:1673 ../../c-api/typeobj.rst:1687 -#: ../../c-api/typeobj.rst:1717 ../../c-api/typeobj.rst:1749 -#: ../../c-api/typeobj.rst:1775 ../../c-api/typeobj.rst:1793 -#: ../../c-api/typeobj.rst:1822 ../../c-api/typeobj.rst:1866 -#: ../../c-api/typeobj.rst:1883 ../../c-api/typeobj.rst:1924 -#: ../../c-api/typeobj.rst:1946 ../../c-api/typeobj.rst:1978 -#: ../../c-api/typeobj.rst:2006 ../../c-api/typeobj.rst:2019 -#: ../../c-api/typeobj.rst:2029 ../../c-api/typeobj.rst:2046 -#: ../../c-api/typeobj.rst:2063 ../../c-api/typeobj.rst:2077 -#: ../../c-api/typeobj.rst:2123 ../../c-api/typeobj.rst:2146 +#: ../../c-api/typeobj.rst:543 ../../c-api/typeobj.rst:587 +#: ../../c-api/typeobj.rst:665 ../../c-api/typeobj.rst:741 +#: ../../c-api/typeobj.rst:782 ../../c-api/typeobj.rst:799 +#: ../../c-api/typeobj.rst:816 ../../c-api/typeobj.rst:834 +#: ../../c-api/typeobj.rst:858 ../../c-api/typeobj.rst:875 +#: ../../c-api/typeobj.rst:887 ../../c-api/typeobj.rst:899 +#: ../../c-api/typeobj.rst:932 ../../c-api/typeobj.rst:954 +#: ../../c-api/typeobj.rst:974 ../../c-api/typeobj.rst:995 +#: ../../c-api/typeobj.rst:1021 ../../c-api/typeobj.rst:1040 +#: ../../c-api/typeobj.rst:1056 ../../c-api/typeobj.rst:1095 +#: ../../c-api/typeobj.rst:1106 ../../c-api/typeobj.rst:1116 +#: ../../c-api/typeobj.rst:1126 ../../c-api/typeobj.rst:1140 +#: ../../c-api/typeobj.rst:1158 ../../c-api/typeobj.rst:1181 +#: ../../c-api/typeobj.rst:1199 ../../c-api/typeobj.rst:1212 +#: ../../c-api/typeobj.rst:1234 ../../c-api/typeobj.rst:1278 +#: ../../c-api/typeobj.rst:1299 ../../c-api/typeobj.rst:1318 +#: ../../c-api/typeobj.rst:1348 ../../c-api/typeobj.rst:1370 +#: ../../c-api/typeobj.rst:1396 ../../c-api/typeobj.rst:1481 +#: ../../c-api/typeobj.rst:1555 ../../c-api/typeobj.rst:1616 +#: ../../c-api/typeobj.rst:1652 ../../c-api/typeobj.rst:1677 +#: ../../c-api/typeobj.rst:1700 ../../c-api/typeobj.rst:1713 +#: ../../c-api/typeobj.rst:1728 ../../c-api/typeobj.rst:1742 +#: ../../c-api/typeobj.rst:1772 ../../c-api/typeobj.rst:1804 +#: ../../c-api/typeobj.rst:1830 ../../c-api/typeobj.rst:1848 +#: ../../c-api/typeobj.rst:1877 ../../c-api/typeobj.rst:1921 +#: ../../c-api/typeobj.rst:1938 ../../c-api/typeobj.rst:1979 +#: ../../c-api/typeobj.rst:2001 ../../c-api/typeobj.rst:2033 +#: ../../c-api/typeobj.rst:2061 ../../c-api/typeobj.rst:2074 +#: ../../c-api/typeobj.rst:2084 ../../c-api/typeobj.rst:2101 +#: ../../c-api/typeobj.rst:2118 ../../c-api/typeobj.rst:2132 +#: ../../c-api/typeobj.rst:2165 ../../c-api/typeobj.rst:2188 msgid "**Inheritance:**" msgstr "" -#: ../../c-api/typeobj.rst:505 ../../c-api/typeobj.rst:542 -#: ../../c-api/typeobj.rst:586 +#: ../../c-api/typeobj.rst:505 ../../c-api/typeobj.rst:545 +#: ../../c-api/typeobj.rst:589 msgid "This field is not inherited by subtypes." msgstr "" @@ -1355,12 +1356,12 @@ msgid "" "class. :c:func:`PyType_Ready` will not change this field if it is non-zero." msgstr "" -#: ../../c-api/typeobj.rst:528 ../../c-api/typeobj.rst:688 -#: ../../c-api/typeobj.rst:805 ../../c-api/typeobj.rst:901 -#: ../../c-api/typeobj.rst:921 ../../c-api/typeobj.rst:1624 -#: ../../c-api/typeobj.rst:1647 ../../c-api/typeobj.rst:1777 -#: ../../c-api/typeobj.rst:1795 ../../c-api/typeobj.rst:1868 -#: ../../c-api/typeobj.rst:1980 ../../c-api/typeobj.rst:2125 +#: ../../c-api/typeobj.rst:528 ../../c-api/typeobj.rst:743 +#: ../../c-api/typeobj.rst:860 ../../c-api/typeobj.rst:956 +#: ../../c-api/typeobj.rst:976 ../../c-api/typeobj.rst:1679 +#: ../../c-api/typeobj.rst:1702 ../../c-api/typeobj.rst:1832 +#: ../../c-api/typeobj.rst:1850 ../../c-api/typeobj.rst:1923 +#: ../../c-api/typeobj.rst:2035 ../../c-api/typeobj.rst:2167 msgid "This field is inherited by subtypes." msgstr "" @@ -1375,11 +1376,17 @@ msgid "" "types>`, this field has a special internal meaning." msgstr "" -#: ../../c-api/typeobj.rst:546 +#: ../../c-api/typeobj.rst:540 +msgid "" +"This field should be accessed using the :c:func:`Py_SIZE()` and :c:func:" +"`Py_SET_SIZE()` macros." +msgstr "" + +#: ../../c-api/typeobj.rst:549 msgid "PyTypeObject Slots" msgstr "" -#: ../../c-api/typeobj.rst:548 +#: ../../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 " @@ -1387,7 +1394,7 @@ msgid "" "`PyBaseObject_Type` and :c:data:`PyType_Type` effectively act as defaults.)" msgstr "" -#: ../../c-api/typeobj.rst:555 +#: ../../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 " @@ -1399,105 +1406,161 @@ msgid "" "tp_name` initializer ``\"P.Q.M.T\"``." msgstr "" -#: ../../c-api/typeobj.rst:563 +#: ../../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:568 +#: ../../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 " -"accessible as the :attr:`__module__` attribute, and everything after the " -"last dot is made accessible as the :attr:`~definition.__name__` attribute." +"accessible as the :attr:`~type.__module__` attribute, and everything after " +"the last dot is made accessible as the :attr:`~type.__name__` attribute." msgstr "" -#: ../../c-api/typeobj.rst:574 +#: ../../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:`~definition.__name__` attribute, and the :attr:" -"`__module__` attribute is undefined (unless explicitly set in the " +"made accessible as the :attr:`~type.__name__` attribute, and the :attr:" +"`~type.__module__` attribute is undefined (unless explicitly set in the " "dictionary, as explained above). This means your type will be impossible to " "pickle. Additionally, it will not be listed in module documentations " "created with pydoc." msgstr "" -#: ../../c-api/typeobj.rst:580 +#: ../../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:592 +#: ../../c-api/typeobj.rst:595 msgid "" "These fields allow calculating the size in bytes of instances of the type." msgstr "" -#: ../../c-api/typeobj.rst:594 +#: ../../c-api/typeobj.rst:597 msgid "" "There are two kinds of types: types with fixed-length instances have a zero :" -"c:member:`~PyTypeObject.tp_itemsize` field, types with variable-length " -"instances have a non-zero :c:member:`~PyTypeObject.tp_itemsize` field. For " -"a type with fixed-length instances, all instances have the same size, given " -"in :c:member:`~PyTypeObject.tp_basicsize`." +"c:member:`!tp_itemsize` field, types with variable-length instances have a " +"non-zero :c:member:`!tp_itemsize` field. For a type with fixed-length " +"instances, all instances have the same size, given in :c:member:`!" +"tp_basicsize`. (Exceptions to this rule can be made using :c:func:" +"`PyUnstable_Object_GC_NewWithExtraData`.)" msgstr "" -#: ../../c-api/typeobj.rst:599 +#: ../../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:" -"`~PyTypeObject.tp_basicsize` plus N times :c:member:`~PyTypeObject." -"tp_itemsize`, where N is the \"length\" of the object. The value of N is " -"typically stored in the instance's :c:member:`~PyVarObject.ob_size` field. " -"There are exceptions: for example, ints use a negative :c:member:" -"`~PyVarObject.ob_size` to indicate a negative number, and N is " -"``abs(ob_size)`` there. 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 (for example, the structure for the list type " -"has fixed-length instances, yet those instances have a meaningful :c:member:" -"`~PyVarObject.ob_size` field)." +"member:`~PyVarObject.ob_size` field, and the instance size is :c:member:`!" +"tp_basicsize` plus N times :c:member:`!tp_itemsize`, where N is the " +"\"length\" of the object." msgstr "" -#: ../../c-api/typeobj.rst:610 +#: ../../c-api/typeobj.rst:609 msgid "" -"The basic size includes the fields in the instance declared by the macro :c:" -"macro:`PyObject_HEAD` or :c:macro:`PyObject_VAR_HEAD` (whichever is used to " -"declare the instance struct) and this in turn includes the :c:member:" -"`~PyObject._ob_prev` and :c:member:`~PyObject._ob_next` fields if they are " -"present. This means that the only correct way to get an initializer for " -"the :c:member:`~PyTypeObject.tp_basicsize` is to use the ``sizeof`` operator " -"on the struct used to declare the instance layout. The basic size does not " -"include the GC header size." +"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` " +"field. Note that the :c:member:`~PyVarObject.ob_size` field may later be " +"used for other purposes. For example, :py:type:`int` instances use the bits " +"of :c:member:`~PyVarObject.ob_size` in an implementation-defined way; the " +"underlying storage and its size should be accessed using :c:func:" +"`PyLong_Export`." msgstr "" -#: ../../c-api/typeobj.rst:618 +#: ../../c-api/typeobj.rst:619 msgid "" -"A note about alignment: if the variable items require a particular " -"alignment, this should be taken care of by the value of :c:member:" -"`~PyTypeObject.tp_basicsize`. Example: suppose a type implements an array " -"of ``double``. :c:member:`~PyTypeObject.tp_itemsize` is ``sizeof(double)``. " -"It is the programmer's responsibility that :c:member:`~PyTypeObject." -"tp_basicsize` is a multiple of ``sizeof(double)`` (assuming this is the " -"alignment requirement for ``double``)." +"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:625 +#: ../../c-api/typeobj.rst:622 msgid "" -"For any type with variable-length instances, this field must not be ``NULL``." +"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. " +"For example, the :py:type:`list` type has fixed-length instances, yet those " +"instances have a :c:member:`~PyVarObject.ob_size` field. (As with :py:type:" +"`int`, avoid reading lists' :c:member:`!ob_size` directly. Call :c:func:" +"`PyList_Size` instead.)" msgstr "" #: ../../c-api/typeobj.rst:629 msgid "" -"These fields are inherited separately by subtypes. 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 different non-zero value in a " -"subtype (though this depends on the implementation of the base type)." +"The :c:member:`!tp_basicsize` includes size needed for data of the type's :c:" +"member:`~PyTypeObject.tp_base`, plus any extra data needed by each instance." +msgstr "" + +#: ../../c-api/typeobj.rst:633 +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 " +"include the struct used to declare the base type. In other words, :c:member:" +"`!tp_basicsize` must be greater than or equal to the base's :c:member:`!" +"tp_basicsize`." +msgstr "" + +#: ../../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:" +"member:`~PyVarObject.ob_size` should be included). These are usually defined " +"by the macro :c:macro:`PyObject_HEAD` or :c:macro:`PyObject_VAR_HEAD`, " +"respectively." msgstr "" -#: ../../c-api/typeobj.rst:637 +#: ../../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: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:651 +msgid "Notes about alignment:" +msgstr "" + +#: ../../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 " +"recommended, the compiler ensures this. When not using a C ``struct``, or " +"when using compiler extensions like ``__attribute__((packed))``, it is up to " +"you." +msgstr "" + +#: ../../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 " +"alignment. For example, if a type's variable part stores a ``double``, it is " +"your responsibility that both fields are a multiple of ``_Alignof(double)``." +msgstr "" + +#: ../../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: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 " +"different non-zero value in a subtype (though this depends on the " +"implementation of the base type)." +msgstr "" + +#: ../../c-api/typeobj.rst:679 msgid "" "A pointer to the instance destructor function. This function must be " "defined unless the type guarantees that its instances will never be " @@ -1505,11 +1568,11 @@ msgid "" "The function signature is::" msgstr "" -#: ../../c-api/typeobj.rst:641 +#: ../../c-api/typeobj.rst:683 msgid "void tp_dealloc(PyObject *self);" msgstr "void tp_dealloc(PyObject *self);" -#: ../../c-api/typeobj.rst:643 +#: ../../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, " @@ -1527,14 +1590,14 @@ msgid "" "allocated using :c:macro:`PyObject_GC_New` or :c:macro:`PyObject_GC_NewVar`." msgstr "" -#: ../../c-api/typeobj.rst:658 +#: ../../c-api/typeobj.rst:700 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." msgstr "" -#: ../../c-api/typeobj.rst:662 +#: ../../c-api/typeobj.rst:704 msgid "" "static void foo_dealloc(foo_object *self) {\n" " PyObject_GC_UnTrack(self);\n" @@ -1548,7 +1611,7 @@ msgstr "" " Py_TYPE(self)->tp_free((PyObject *)self);\n" "}" -#: ../../c-api/typeobj.rst:670 +#: ../../c-api/typeobj.rst:712 msgid "" "Finally, if the type is heap allocated (:c:macro:`Py_TPFLAGS_HEAPTYPE`), the " "deallocator should release the owned reference to its type object (via :c:" @@ -1556,7 +1619,7 @@ msgid "" "dangling pointers, the recommended way to achieve this is:" msgstr "" -#: ../../c-api/typeobj.rst:676 +#: ../../c-api/typeobj.rst:718 msgid "" "static void foo_dealloc(foo_object *self) {\n" " PyTypeObject *tp = Py_TYPE(self);\n" @@ -1566,28 +1629,41 @@ msgid "" "}" msgstr "" -#: ../../c-api/typeobj.rst:693 +#: ../../c-api/typeobj.rst:729 +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." +msgstr "" + +#: ../../c-api/typeobj.rst:748 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:698 +#: ../../c-api/typeobj.rst:753 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:702 +#: ../../c-api/typeobj.rst:757 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:706 +#: ../../c-api/typeobj.rst:761 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 " @@ -1595,13 +1671,13 @@ msgid "" "`PyVectorcall_Call`." msgstr "" -#: ../../c-api/typeobj.rst:713 +#: ../../c-api/typeobj.rst:768 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:719 +#: ../../c-api/typeobj.rst:774 msgid "" "Before version 3.12, it was not recommended for :ref:`mutable heap types " "` to implement the vectorcall protocol. When a user sets :attr:" @@ -1611,7 +1687,7 @@ msgid "" "`Py_TPFLAGS_HAVE_VECTORCALL` flag." msgstr "" -#: ../../c-api/typeobj.rst:729 +#: ../../c-api/typeobj.rst:784 msgid "" "This field is always inherited. However, the :c:macro:" "`Py_TPFLAGS_HAVE_VECTORCALL` flag is not always inherited. If it's not set, " @@ -1619,11 +1695,11 @@ msgid "" "func:`PyVectorcall_Call` is explicitly called." msgstr "" -#: ../../c-api/typeobj.rst:738 +#: ../../c-api/typeobj.rst:793 msgid "An optional pointer to the get-attribute-string function." msgstr "" -#: ../../c-api/typeobj.rst:740 +#: ../../c-api/typeobj.rst:795 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, " @@ -1631,7 +1707,7 @@ msgid "" "attribute name." msgstr "" -#: ../../c-api/typeobj.rst:746 ../../c-api/typeobj.rst:942 +#: ../../c-api/typeobj.rst:801 ../../c-api/typeobj.rst:997 msgid "" "Group: :c:member:`~PyTypeObject.tp_getattr`, :c:member:`~PyTypeObject." "tp_getattro`" @@ -1639,7 +1715,7 @@ msgstr "" "群組::c:member:`~PyTypeObject.tp_getattr`、:c:member:`~PyTypeObject." "tp_getattro`" -#: ../../c-api/typeobj.rst:748 +#: ../../c-api/typeobj.rst:803 msgid "" "This field is inherited by subtypes together with :c:member:`~PyTypeObject." "tp_getattro`: a subtype inherits both :c:member:`~PyTypeObject.tp_getattr` " @@ -1648,12 +1724,12 @@ msgid "" "tp_getattro` are both ``NULL``." msgstr "" -#: ../../c-api/typeobj.rst:755 ../../c-api/typeobj.rst:955 +#: ../../c-api/typeobj.rst:810 ../../c-api/typeobj.rst:1010 msgid "" "An optional pointer to the function for setting and deleting attributes." msgstr "" -#: ../../c-api/typeobj.rst:757 +#: ../../c-api/typeobj.rst:812 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, " @@ -1661,7 +1737,7 @@ msgid "" "attribute name." msgstr "" -#: ../../c-api/typeobj.rst:763 ../../c-api/typeobj.rst:968 +#: ../../c-api/typeobj.rst:818 ../../c-api/typeobj.rst:1023 msgid "" "Group: :c:member:`~PyTypeObject.tp_setattr`, :c:member:`~PyTypeObject." "tp_setattro`" @@ -1669,7 +1745,7 @@ msgstr "" "群組::c:member:`~PyTypeObject.tp_setattr`、:c:member:`~PyTypeObject." "tp_setattro`" -#: ../../c-api/typeobj.rst:765 +#: ../../c-api/typeobj.rst:820 msgid "" "This field is inherited by subtypes together with :c:member:`~PyTypeObject." "tp_setattro`: a subtype inherits both :c:member:`~PyTypeObject.tp_setattr` " @@ -1678,38 +1754,38 @@ msgid "" "tp_setattro` are both ``NULL``." msgstr "" -#: ../../c-api/typeobj.rst:772 +#: ../../c-api/typeobj.rst:827 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:776 +#: ../../c-api/typeobj.rst:831 msgid "Formerly known as ``tp_compare`` and ``tp_reserved``." msgstr "" -#: ../../c-api/typeobj.rst:781 +#: ../../c-api/typeobj.rst:836 msgid "" "The :c:member:`~PyTypeObject.tp_as_async` field is not inherited, but the " "contained fields are inherited individually." msgstr "" -#: ../../c-api/typeobj.rst:789 +#: ../../c-api/typeobj.rst:844 msgid "" "An optional pointer to a function that implements the built-in function :" "func:`repr`." msgstr "" -#: ../../c-api/typeobj.rst:792 +#: ../../c-api/typeobj.rst:847 msgid "The signature is the same as for :c:func:`PyObject_Repr`::" msgstr "" -#: ../../c-api/typeobj.rst:794 +#: ../../c-api/typeobj.rst:849 msgid "PyObject *tp_repr(PyObject *self);" msgstr "PyObject *tp_repr(PyObject *self);" -#: ../../c-api/typeobj.rst:796 +#: ../../c-api/typeobj.rst:851 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 " @@ -1718,85 +1794,85 @@ msgid "" "``'>'`` from which both the type and the value of the object can be deduced." msgstr "" -#: ../../c-api/typeobj.rst:807 ../../c-api/typeobj.rst:886 -#: ../../c-api/typeobj.rst:923 ../../c-api/typeobj.rst:948 -#: ../../c-api/typeobj.rst:974 ../../c-api/typeobj.rst:1015 -#: ../../c-api/typeobj.rst:1570 ../../c-api/typeobj.rst:1604 -#: ../../c-api/typeobj.rst:1721 ../../c-api/typeobj.rst:1754 -#: ../../c-api/typeobj.rst:1829 ../../c-api/typeobj.rst:1870 -#: ../../c-api/typeobj.rst:1888 ../../c-api/typeobj.rst:1930 -#: ../../c-api/typeobj.rst:1951 ../../c-api/typeobj.rst:1982 +#: ../../c-api/typeobj.rst:862 ../../c-api/typeobj.rst:941 +#: ../../c-api/typeobj.rst:978 ../../c-api/typeobj.rst:1003 +#: ../../c-api/typeobj.rst:1029 ../../c-api/typeobj.rst:1070 +#: ../../c-api/typeobj.rst:1625 ../../c-api/typeobj.rst:1659 +#: ../../c-api/typeobj.rst:1776 ../../c-api/typeobj.rst:1809 +#: ../../c-api/typeobj.rst:1884 ../../c-api/typeobj.rst:1925 +#: ../../c-api/typeobj.rst:1943 ../../c-api/typeobj.rst:1985 +#: ../../c-api/typeobj.rst:2006 ../../c-api/typeobj.rst:2037 msgid "**Default:**" msgstr "**預設:**" -#: ../../c-api/typeobj.rst:809 +#: ../../c-api/typeobj.rst:864 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:816 +#: ../../c-api/typeobj.rst:871 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:822 +#: ../../c-api/typeobj.rst:877 msgid "" "The :c:member:`~PyTypeObject.tp_as_number` field is not inherited, but the " "contained fields are inherited individually." msgstr "" -#: ../../c-api/typeobj.rst:828 +#: ../../c-api/typeobj.rst:883 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:834 +#: ../../c-api/typeobj.rst:889 msgid "" "The :c:member:`~PyTypeObject.tp_as_sequence` field is not inherited, but the " "contained fields are inherited individually." msgstr "" -#: ../../c-api/typeobj.rst:840 +#: ../../c-api/typeobj.rst:895 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:846 +#: ../../c-api/typeobj.rst:901 msgid "" "The :c:member:`~PyTypeObject.tp_as_mapping` field is not inherited, but the " "contained fields are inherited individually." msgstr "" -#: ../../c-api/typeobj.rst:854 +#: ../../c-api/typeobj.rst:909 msgid "" "An optional pointer to a function that implements the built-in function :" "func:`hash`." msgstr "" -#: ../../c-api/typeobj.rst:857 +#: ../../c-api/typeobj.rst:912 msgid "The signature is the same as for :c:func:`PyObject_Hash`::" msgstr "" -#: ../../c-api/typeobj.rst:859 +#: ../../c-api/typeobj.rst:914 msgid "Py_hash_t tp_hash(PyObject *);" msgstr "Py_hash_t tp_hash(PyObject *);" -#: ../../c-api/typeobj.rst:861 +#: ../../c-api/typeobj.rst:916 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:865 +#: ../../c-api/typeobj.rst:920 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:" @@ -1804,7 +1880,7 @@ msgid "" "`PyObject_HashNotImplemented`." msgstr "" -#: ../../c-api/typeobj.rst:869 +#: ../../c-api/typeobj.rst:924 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 " @@ -1815,7 +1891,7 @@ msgid "" "`PyObject_HashNotImplemented`." msgstr "" -#: ../../c-api/typeobj.rst:879 ../../c-api/typeobj.rst:1563 +#: ../../c-api/typeobj.rst:934 ../../c-api/typeobj.rst:1618 msgid "" "Group: :c:member:`~PyTypeObject.tp_hash`, :c:member:`~PyTypeObject." "tp_richcompare`" @@ -1823,7 +1899,7 @@ msgstr "" "群組::c:member:`~PyTypeObject.tp_hash`、:c:member:`~PyTypeObject." "tp_richcompare`" -#: ../../c-api/typeobj.rst:881 +#: ../../c-api/typeobj.rst:936 msgid "" "This field is inherited by subtypes together with :c:member:`~PyTypeObject." "tp_richcompare`: a subtype inherits both of :c:member:`~PyTypeObject." @@ -1832,22 +1908,22 @@ msgid "" "are both ``NULL``." msgstr "" -#: ../../c-api/typeobj.rst:888 +#: ../../c-api/typeobj.rst:943 msgid ":c:data:`PyBaseObject_Type` uses :c:func:`PyObject_GenericHash`." msgstr "" -#: ../../c-api/typeobj.rst:893 +#: ../../c-api/typeobj.rst:948 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:897 +#: ../../c-api/typeobj.rst:952 msgid "PyObject *tp_call(PyObject *self, PyObject *args, PyObject *kwargs);" msgstr "PyObject *tp_call(PyObject *self, PyObject *args, PyObject *kwargs);" -#: ../../c-api/typeobj.rst:906 +#: ../../c-api/typeobj.rst:961 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 " @@ -1856,15 +1932,15 @@ msgid "" "this handler.)" msgstr "" -#: ../../c-api/typeobj.rst:911 +#: ../../c-api/typeobj.rst:966 msgid "The signature is the same as for :c:func:`PyObject_Str`::" msgstr "" -#: ../../c-api/typeobj.rst:913 +#: ../../c-api/typeobj.rst:968 msgid "PyObject *tp_str(PyObject *self);" msgstr "PyObject *tp_str(PyObject *self);" -#: ../../c-api/typeobj.rst:915 +#: ../../c-api/typeobj.rst:970 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 " @@ -1872,32 +1948,32 @@ msgid "" "function." msgstr "" -#: ../../c-api/typeobj.rst:925 +#: ../../c-api/typeobj.rst:980 msgid "" "When this field is not set, :c:func:`PyObject_Repr` is called to return a " "string representation." msgstr "" -#: ../../c-api/typeobj.rst:931 +#: ../../c-api/typeobj.rst:986 msgid "An optional pointer to the get-attribute function." msgstr "" -#: ../../c-api/typeobj.rst:933 +#: ../../c-api/typeobj.rst:988 msgid "The signature is the same as for :c:func:`PyObject_GetAttr`::" msgstr "" -#: ../../c-api/typeobj.rst:935 +#: ../../c-api/typeobj.rst:990 msgid "PyObject *tp_getattro(PyObject *self, PyObject *attr);" msgstr "PyObject *tp_getattro(PyObject *self, PyObject *attr);" -#: ../../c-api/typeobj.rst:937 +#: ../../c-api/typeobj.rst:992 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:944 +#: ../../c-api/typeobj.rst:999 msgid "" "This field is inherited by subtypes together with :c:member:`~PyTypeObject." "tp_getattr`: a subtype inherits both :c:member:`~PyTypeObject.tp_getattr` " @@ -1906,19 +1982,19 @@ msgid "" "tp_getattro` are both ``NULL``." msgstr "" -#: ../../c-api/typeobj.rst:950 +#: ../../c-api/typeobj.rst:1005 msgid ":c:data:`PyBaseObject_Type` uses :c:func:`PyObject_GenericGetAttr`." msgstr "" -#: ../../c-api/typeobj.rst:957 +#: ../../c-api/typeobj.rst:1012 msgid "The signature is the same as for :c:func:`PyObject_SetAttr`::" msgstr "" -#: ../../c-api/typeobj.rst:959 +#: ../../c-api/typeobj.rst:1014 msgid "int tp_setattro(PyObject *self, PyObject *attr, PyObject *value);" msgstr "int tp_setattro(PyObject *self, PyObject *attr, PyObject *value);" -#: ../../c-api/typeobj.rst:961 +#: ../../c-api/typeobj.rst:1016 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:" @@ -1926,7 +2002,7 @@ msgid "" "attributes." msgstr "" -#: ../../c-api/typeobj.rst:970 +#: ../../c-api/typeobj.rst:1025 msgid "" "This field is inherited by subtypes together with :c:member:`~PyTypeObject." "tp_setattr`: a subtype inherits both :c:member:`~PyTypeObject.tp_setattr` " @@ -1935,24 +2011,24 @@ msgid "" "tp_setattro` are both ``NULL``." msgstr "" -#: ../../c-api/typeobj.rst:976 +#: ../../c-api/typeobj.rst:1031 msgid ":c:data:`PyBaseObject_Type` uses :c:func:`PyObject_GenericSetAttr`." msgstr "" -#: ../../c-api/typeobj.rst:981 +#: ../../c-api/typeobj.rst:1036 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:987 +#: ../../c-api/typeobj.rst:1042 msgid "" "The :c:member:`~PyTypeObject.tp_as_buffer` field is not inherited, but the " "contained fields are inherited individually." msgstr "" -#: ../../c-api/typeobj.rst:993 +#: ../../c-api/typeobj.rst:1048 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 " @@ -1964,7 +2040,7 @@ msgid "" "accessed and must be considered to have a zero or ``NULL`` value instead." msgstr "" -#: ../../c-api/typeobj.rst:1003 +#: ../../c-api/typeobj.rst:1058 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 " @@ -1980,7 +2056,7 @@ msgid "" "*really* inherited individually?" msgstr "" -#: ../../c-api/typeobj.rst:1017 +#: ../../c-api/typeobj.rst:1072 msgid "" ":c:data:`PyBaseObject_Type` uses ``Py_TPFLAGS_DEFAULT | " "Py_TPFLAGS_BASETYPE``." @@ -1988,11 +2064,11 @@ msgstr "" ":c:data:`PyBaseObject_Type` 使用 ``Py_TPFLAGS_DEFAULT | " "Py_TPFLAGS_BASETYPE``。" -#: ../../c-api/typeobj.rst:1020 +#: ../../c-api/typeobj.rst:1075 msgid "**Bit Masks:**" msgstr "" -#: ../../c-api/typeobj.rst:1024 +#: ../../c-api/typeobj.rst:1079 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." @@ -2001,7 +2077,7 @@ msgid "" "zero." msgstr "" -#: ../../c-api/typeobj.rst:1031 +#: ../../c-api/typeobj.rst:1086 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 " @@ -2014,32 +2090,32 @@ msgid "" "reference cycle with their own module object." msgstr "" -#: ../../c-api/typeobj.rst:1042 ../../c-api/typeobj.rst:1053 -#: ../../c-api/typeobj.rst:1063 ../../c-api/typeobj.rst:1073 -#: ../../c-api/typeobj.rst:1105 +#: ../../c-api/typeobj.rst:1097 ../../c-api/typeobj.rst:1108 +#: ../../c-api/typeobj.rst:1118 ../../c-api/typeobj.rst:1128 +#: ../../c-api/typeobj.rst:1160 msgid "???" msgstr "???" -#: ../../c-api/typeobj.rst:1047 +#: ../../c-api/typeobj.rst:1102 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:1058 +#: ../../c-api/typeobj.rst:1113 msgid "" "This bit is set when the type object has been fully initialized by :c:func:" "`PyType_Ready`." msgstr "" -#: ../../c-api/typeobj.rst:1068 +#: ../../c-api/typeobj.rst:1123 msgid "" "This bit is set while :c:func:`PyType_Ready` is in the process of " "initializing the type object." msgstr "" -#: ../../c-api/typeobj.rst:1078 +#: ../../c-api/typeobj.rst:1133 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 " @@ -2049,14 +2125,14 @@ msgid "" "tp_clear` are present in the type object." msgstr "" -#: ../../c-api/typeobj.rst:1087 ../../c-api/typeobj.rst:1428 -#: ../../c-api/typeobj.rst:1502 +#: ../../c-api/typeobj.rst:1142 ../../c-api/typeobj.rst:1483 +#: ../../c-api/typeobj.rst:1557 msgid "" "Group: :c:macro:`Py_TPFLAGS_HAVE_GC`, :c:member:`~PyTypeObject." "tp_traverse`, :c:member:`~PyTypeObject.tp_clear`" msgstr "" -#: ../../c-api/typeobj.rst:1089 +#: ../../c-api/typeobj.rst:1144 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` " @@ -2066,105 +2142,105 @@ msgid "" "values." msgstr "" -#: ../../c-api/typeobj.rst:1099 +#: ../../c-api/typeobj.rst:1154 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:1110 +#: ../../c-api/typeobj.rst:1165 msgid "This bit indicates that objects behave like unbound methods." msgstr "" -#: ../../c-api/typeobj.rst:1112 +#: ../../c-api/typeobj.rst:1167 msgid "If this flag is set for ``type(meth)``, then:" msgstr "" -#: ../../c-api/typeobj.rst:1114 +#: ../../c-api/typeobj.rst:1169 msgid "" "``meth.__get__(obj, cls)(*args, **kwds)`` (with ``obj`` not None) must be " "equivalent to ``meth(obj, *args, **kwds)``." msgstr "" -#: ../../c-api/typeobj.rst:1117 +#: ../../c-api/typeobj.rst:1172 msgid "" "``meth.__get__(None, cls)(*args, **kwds)`` must be equivalent to " "``meth(*args, **kwds)``." msgstr "" -#: ../../c-api/typeobj.rst:1120 +#: ../../c-api/typeobj.rst:1175 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:1128 +#: ../../c-api/typeobj.rst:1183 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:1134 +#: ../../c-api/typeobj.rst:1189 msgid "" -"This bit indicates that instances of the class have a ``__dict__`` " +"This bit indicates that instances of the class have a `~object.__dict__` " "attribute, and that the space for the dictionary is managed by the VM." msgstr "" -#: ../../c-api/typeobj.rst:1137 +#: ../../c-api/typeobj.rst:1192 msgid "If this flag is set, :c:macro:`Py_TPFLAGS_HAVE_GC` should also be set." msgstr "" -#: ../../c-api/typeobj.rst:1139 +#: ../../c-api/typeobj.rst:1194 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:1146 +#: ../../c-api/typeobj.rst:1201 msgid "" "This flag is inherited unless the :c:member:`~PyTypeObject.tp_dictoffset` " "field is set in a superclass." msgstr "" -#: ../../c-api/typeobj.rst:1152 +#: ../../c-api/typeobj.rst:1207 msgid "" "This bit indicates that instances of the class should be weakly " "referenceable." msgstr "" -#: ../../c-api/typeobj.rst:1159 +#: ../../c-api/typeobj.rst:1214 msgid "" "This flag is inherited unless the :c:member:`~PyTypeObject." "tp_weaklistoffset` field is set in a superclass." msgstr "" -#: ../../c-api/typeobj.rst:1165 +#: ../../c-api/typeobj.rst:1220 msgid "" "Only usable with variable-size types, i.e. ones with non-zero :c:member:" "`~PyTypeObject.tp_itemsize`." msgstr "" -#: ../../c-api/typeobj.rst:1168 +#: ../../c-api/typeobj.rst:1223 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:1173 +#: ../../c-api/typeobj.rst:1228 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:1181 +#: ../../c-api/typeobj.rst:1236 msgid "This flag is inherited." msgstr "" -#: ../../c-api/typeobj.rst:1195 +#: ../../c-api/typeobj.rst:1250 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 " @@ -2174,90 +2250,90 @@ msgid "" "behave differently depending on what kind of check is used." msgstr "" -#: ../../c-api/typeobj.rst:1206 +#: ../../c-api/typeobj.rst:1261 msgid "" "This bit is set when the :c:member:`~PyTypeObject.tp_finalize` slot is " "present in the type structure." msgstr "" -#: ../../c-api/typeobj.rst:1211 +#: ../../c-api/typeobj.rst:1266 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:1219 +#: ../../c-api/typeobj.rst:1274 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:1225 +#: ../../c-api/typeobj.rst:1280 msgid "" "This bit is inherited if :c:member:`~PyTypeObject.tp_call` is also inherited." msgstr "" -#: ../../c-api/typeobj.rst:1232 +#: ../../c-api/typeobj.rst:1287 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:1235 +#: ../../c-api/typeobj.rst:1290 msgid "This flag can now be inherited by mutable classes." msgstr "" -#: ../../c-api/typeobj.rst:1239 +#: ../../c-api/typeobj.rst:1294 msgid "" "This bit is set for type objects that are immutable: type attributes cannot " "be set nor deleted." msgstr "" -#: ../../c-api/typeobj.rst:1241 +#: ../../c-api/typeobj.rst:1296 msgid "" ":c:func:`PyType_Ready` automatically applies this flag to :ref:`static types " "`." msgstr "" -#: ../../c-api/typeobj.rst:1246 +#: ../../c-api/typeobj.rst:1301 msgid "This flag is not inherited." msgstr "" -#: ../../c-api/typeobj.rst:1252 +#: ../../c-api/typeobj.rst:1307 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:1256 +#: ../../c-api/typeobj.rst:1311 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:1259 +#: ../../c-api/typeobj.rst:1314 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:1265 +#: ../../c-api/typeobj.rst:1320 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:1272 +#: ../../c-api/typeobj.rst:1327 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:1283 +#: ../../c-api/typeobj.rst:1338 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 " @@ -2265,23 +2341,23 @@ msgid "" "unset when registering :class:`collections.abc.Sequence`." msgstr "" -#: ../../c-api/typeobj.rst:1290 ../../c-api/typeobj.rst:1312 +#: ../../c-api/typeobj.rst:1345 ../../c-api/typeobj.rst:1367 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:1295 +#: ../../c-api/typeobj.rst:1350 msgid "" "This flag is inherited by types that do not already set :c:macro:" "`Py_TPFLAGS_SEQUENCE`." msgstr "" -#: ../../c-api/typeobj.rst:1298 ../../c-api/typeobj.rst:1320 +#: ../../c-api/typeobj.rst:1353 ../../c-api/typeobj.rst:1375 msgid ":pep:`634` -- Structural Pattern Matching: Specification" msgstr "" -#: ../../c-api/typeobj.rst:1305 +#: ../../c-api/typeobj.rst:1360 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 " @@ -2289,53 +2365,53 @@ msgid "" "unset when registering :class:`collections.abc.Mapping`." msgstr "" -#: ../../c-api/typeobj.rst:1317 +#: ../../c-api/typeobj.rst:1372 msgid "" "This flag is inherited by types that do not already set :c:macro:" "`Py_TPFLAGS_MAPPING`." msgstr "" -#: ../../c-api/typeobj.rst:1327 +#: ../../c-api/typeobj.rst:1382 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:1331 +#: ../../c-api/typeobj.rst:1386 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:1337 +#: ../../c-api/typeobj.rst:1392 msgid "" "An optional pointer to a NUL-terminated C string giving the docstring for " -"this type object. This is exposed as the :attr:`__doc__` attribute on the " -"type and instances of the type." +"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:1343 +#: ../../c-api/typeobj.rst:1398 msgid "This field is *not* inherited by subtypes." msgstr "" -#: ../../c-api/typeobj.rst:1348 +#: ../../c-api/typeobj.rst:1403 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:1351 +#: ../../c-api/typeobj.rst:1406 msgid "int tp_traverse(PyObject *self, visitproc visit, void *arg);" msgstr "int tp_traverse(PyObject *self, visitproc visit, void *arg);" -#: ../../c-api/typeobj.rst:1353 ../../c-api/typeobj.rst:1497 +#: ../../c-api/typeobj.rst:1408 ../../c-api/typeobj.rst:1552 msgid "" "More information about Python's garbage collection scheme can be found in " "section :ref:`supporting-cycle-detection`." msgstr "" -#: ../../c-api/typeobj.rst:1356 +#: ../../c-api/typeobj.rst:1411 msgid "" "The :c:member:`~PyTypeObject.tp_traverse` pointer is used by the garbage " "collector to detect reference cycles. A typical implementation of a :c:" @@ -2345,7 +2421,7 @@ msgid "" "`!_thread` extension module::" msgstr "" -#: ../../c-api/typeobj.rst:1362 +#: ../../c-api/typeobj.rst:1417 msgid "" "static int\n" "local_traverse(localobject *self, visitproc visit, void *arg)\n" @@ -2365,7 +2441,7 @@ msgstr "" " return 0;\n" "}" -#: ../../c-api/typeobj.rst:1371 +#: ../../c-api/typeobj.rst:1426 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`` " @@ -2373,48 +2449,48 @@ msgid "" "part of a reference cycle." msgstr "" -#: ../../c-api/typeobj.rst:1375 +#: ../../c-api/typeobj.rst:1430 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:1379 +#: ../../c-api/typeobj.rst:1434 msgid "" "Heap types (:c:macro:`Py_TPFLAGS_HEAPTYPE`) must visit their type with::" msgstr "" -#: ../../c-api/typeobj.rst:1381 +#: ../../c-api/typeobj.rst:1436 msgid "Py_VISIT(Py_TYPE(self));" msgstr "" -#: ../../c-api/typeobj.rst:1383 +#: ../../c-api/typeobj.rst:1438 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:1386 +#: ../../c-api/typeobj.rst:1441 msgid "" "#if PY_VERSION_HEX >= 0x03090000\n" " Py_VISIT(Py_TYPE(self));\n" "#endif" msgstr "" -#: ../../c-api/typeobj.rst:1390 +#: ../../c-api/typeobj.rst:1445 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:1394 +#: ../../c-api/typeobj.rst:1449 #, fuzzy msgid "PyObject_VisitManagedDict((PyObject*)self, visit, arg);" msgstr "PyObject *tp_iternext(PyObject *self);" -#: ../../c-api/typeobj.rst:1397 +#: ../../c-api/typeobj.rst:1452 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:" @@ -2443,14 +2519,14 @@ msgid "" "superclass). If they do not, the type object may not be garbage-collected." msgstr "" -#: ../../c-api/typeobj.rst:1421 +#: ../../c-api/typeobj.rst:1476 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:1430 +#: ../../c-api/typeobj.rst:1485 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:" @@ -2458,18 +2534,18 @@ msgid "" "are all inherited from the base type if they are all zero in the subtype." msgstr "" -#: ../../c-api/typeobj.rst:1438 +#: ../../c-api/typeobj.rst:1493 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::" msgstr "" -#: ../../c-api/typeobj.rst:1441 +#: ../../c-api/typeobj.rst:1496 msgid "int tp_clear(PyObject *);" msgstr "int tp_clear(PyObject *);" -#: ../../c-api/typeobj.rst:1443 +#: ../../c-api/typeobj.rst:1498 msgid "" "The :c:member:`~PyTypeObject.tp_clear` member function is used to break " "reference cycles in cyclic garbage detected by the garbage collector. Taken " @@ -2484,7 +2560,7 @@ msgid "" "good reason to avoid implementing :c:member:`~PyTypeObject.tp_clear`." msgstr "" -#: ../../c-api/typeobj.rst:1453 +#: ../../c-api/typeobj.rst:1508 msgid "" "Implementations of :c:member:`~PyTypeObject.tp_clear` should drop the " "instance's references to those of its members that may be Python objects, " @@ -2492,7 +2568,7 @@ msgid "" "example::" msgstr "" -#: ../../c-api/typeobj.rst:1457 +#: ../../c-api/typeobj.rst:1512 msgid "" "static int\n" "local_clear(localobject *self)\n" @@ -2514,7 +2590,7 @@ msgstr "" " return 0;\n" "}" -#: ../../c-api/typeobj.rst:1467 +#: ../../c-api/typeobj.rst:1522 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 :" @@ -2529,19 +2605,19 @@ msgid "" "performs the operations in a safe order." msgstr "" -#: ../../c-api/typeobj.rst:1479 +#: ../../c-api/typeobj.rst:1534 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_ClearManagedDict` like this::" msgstr "" -#: ../../c-api/typeobj.rst:1483 +#: ../../c-api/typeobj.rst:1538 #, fuzzy msgid "PyObject_ClearManagedDict((PyObject*)self);" msgstr "PyObject *am_anext(PyObject *self);" -#: ../../c-api/typeobj.rst:1485 +#: ../../c-api/typeobj.rst:1540 msgid "" "Note that :c:member:`~PyTypeObject.tp_clear` is not *always* called before " "an instance is deallocated. For example, when reference counting is enough " @@ -2549,7 +2625,7 @@ msgid "" "is not involved and :c:member:`~PyTypeObject.tp_dealloc` is called directly." msgstr "" -#: ../../c-api/typeobj.rst:1491 +#: ../../c-api/typeobj.rst:1546 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 " @@ -2559,7 +2635,7 @@ msgid "" "invoke :c:member:`~PyTypeObject.tp_clear`." msgstr "" -#: ../../c-api/typeobj.rst:1504 +#: ../../c-api/typeobj.rst:1559 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, :" @@ -2567,22 +2643,22 @@ msgid "" "are all inherited from the base type if they are all zero in the subtype." msgstr "" -#: ../../c-api/typeobj.rst:1512 +#: ../../c-api/typeobj.rst:1567 msgid "" "An optional pointer to the rich comparison function, whose signature is::" msgstr "" -#: ../../c-api/typeobj.rst:1514 +#: ../../c-api/typeobj.rst:1569 msgid "PyObject *tp_richcompare(PyObject *self, PyObject *other, int op);" msgstr "PyObject *tp_richcompare(PyObject *self, PyObject *other, int op);" -#: ../../c-api/typeobj.rst:1516 +#: ../../c-api/typeobj.rst:1571 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:1519 +#: ../../c-api/typeobj.rst:1574 msgid "" "The function should return the result of the comparison (usually ``Py_True`` " "or ``Py_False``). If the comparison is undefined, it must return " @@ -2590,50 +2666,50 @@ msgid "" "set an exception condition." msgstr "" -#: ../../c-api/typeobj.rst:1524 +#: ../../c-api/typeobj.rst:1579 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:1530 +#: ../../c-api/typeobj.rst:1585 msgid "Constant" msgstr "常數" -#: ../../c-api/typeobj.rst:1530 +#: ../../c-api/typeobj.rst:1585 msgid "Comparison" msgstr "" -#: ../../c-api/typeobj.rst:1532 +#: ../../c-api/typeobj.rst:1587 msgid "``<``" msgstr "``<``" -#: ../../c-api/typeobj.rst:1534 +#: ../../c-api/typeobj.rst:1589 msgid "``<=``" msgstr "``<=``" -#: ../../c-api/typeobj.rst:1536 +#: ../../c-api/typeobj.rst:1591 msgid "``==``" msgstr "``==``" -#: ../../c-api/typeobj.rst:1538 +#: ../../c-api/typeobj.rst:1593 msgid "``!=``" msgstr "``!=``" -#: ../../c-api/typeobj.rst:1540 +#: ../../c-api/typeobj.rst:1595 msgid "``>``" msgstr "``>``" -#: ../../c-api/typeobj.rst:1542 +#: ../../c-api/typeobj.rst:1597 msgid "``>=``" msgstr "``>=``" -#: ../../c-api/typeobj.rst:1545 +#: ../../c-api/typeobj.rst:1600 msgid "" "The following macro is defined to ease writing rich comparison functions:" msgstr "" -#: ../../c-api/typeobj.rst:1549 +#: ../../c-api/typeobj.rst:1604 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 " @@ -2641,15 +2717,15 @@ msgid "" "specifies the requested operation, as for :c:func:`PyObject_RichCompare`." msgstr "" -#: ../../c-api/typeobj.rst:1555 +#: ../../c-api/typeobj.rst:1610 msgid "The returned value is a new :term:`strong reference`." msgstr "" -#: ../../c-api/typeobj.rst:1557 +#: ../../c-api/typeobj.rst:1612 msgid "On error, sets an exception and returns ``NULL`` from the function." msgstr "" -#: ../../c-api/typeobj.rst:1565 +#: ../../c-api/typeobj.rst:1620 msgid "" "This field is inherited by subtypes together with :c:member:`~PyTypeObject." "tp_hash`: a subtype inherits :c:member:`~PyTypeObject.tp_richcompare` and :c:" @@ -2657,7 +2733,7 @@ msgid "" "tp_richcompare` and :c:member:`~PyTypeObject.tp_hash` are both ``NULL``." msgstr "" -#: ../../c-api/typeobj.rst:1572 +#: ../../c-api/typeobj.rst:1627 msgid "" ":c:data:`PyBaseObject_Type` provides a :c:member:`~PyTypeObject." "tp_richcompare` implementation, which may be inherited. However, if only :c:" @@ -2666,13 +2742,13 @@ msgid "" "comparisons." msgstr "" -#: ../../c-api/typeobj.rst:1581 +#: ../../c-api/typeobj.rst:1636 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:1584 +#: ../../c-api/typeobj.rst:1639 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 " @@ -2682,19 +2758,19 @@ msgid "" "`PyObject*` which is initialized to ``NULL``." msgstr "" -#: ../../c-api/typeobj.rst:1591 +#: ../../c-api/typeobj.rst:1646 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:1594 +#: ../../c-api/typeobj.rst:1649 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:1599 +#: ../../c-api/typeobj.rst:1654 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 " @@ -2703,7 +2779,7 @@ msgid "" "not be a problem." msgstr "" -#: ../../c-api/typeobj.rst:1606 +#: ../../c-api/typeobj.rst:1661 msgid "" "If the :c:macro:`Py_TPFLAGS_MANAGED_WEAKREF` bit is set in the :c:member:" "`~PyTypeObject.tp_flags` field, then :c:member:`~PyTypeObject." @@ -2711,32 +2787,32 @@ msgid "" "unsafe to use this field." msgstr "" -#: ../../c-api/typeobj.rst:1614 +#: ../../c-api/typeobj.rst:1669 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:1618 +#: ../../c-api/typeobj.rst:1673 msgid "This function has the same signature as :c:func:`PyObject_GetIter`::" msgstr "" -#: ../../c-api/typeobj.rst:1620 +#: ../../c-api/typeobj.rst:1675 msgid "PyObject *tp_iter(PyObject *self);" msgstr "PyObject *tp_iter(PyObject *self);" -#: ../../c-api/typeobj.rst:1629 +#: ../../c-api/typeobj.rst:1684 msgid "" "An optional pointer to a function that returns the next item in an :term:" "`iterator`. The signature is::" msgstr "" -#: ../../c-api/typeobj.rst:1632 +#: ../../c-api/typeobj.rst:1687 msgid "PyObject *tp_iternext(PyObject *self);" msgstr "PyObject *tp_iternext(PyObject *self);" -#: ../../c-api/typeobj.rst:1634 +#: ../../c-api/typeobj.rst:1689 msgid "" "When the iterator is exhausted, it must return ``NULL``; a :exc:" "`StopIteration` exception may or may not be set. When another error occurs, " @@ -2744,74 +2820,74 @@ msgid "" "this type are iterators." msgstr "" -#: ../../c-api/typeobj.rst:1639 +#: ../../c-api/typeobj.rst:1694 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:1643 +#: ../../c-api/typeobj.rst:1698 msgid "This function has the same signature as :c:func:`PyIter_Next`." msgstr "" -#: ../../c-api/typeobj.rst:1652 +#: ../../c-api/typeobj.rst:1707 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:1655 +#: ../../c-api/typeobj.rst:1710 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:1660 +#: ../../c-api/typeobj.rst:1715 msgid "" "This field is not inherited by subtypes (methods are inherited through a " "different mechanism)." msgstr "" -#: ../../c-api/typeobj.rst:1666 +#: ../../c-api/typeobj.rst:1721 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:1670 +#: ../../c-api/typeobj.rst:1725 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:1675 +#: ../../c-api/typeobj.rst:1730 msgid "" "This field is not inherited by subtypes (members are inherited through a " "different mechanism)." msgstr "" -#: ../../c-api/typeobj.rst:1681 +#: ../../c-api/typeobj.rst:1736 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:1684 +#: ../../c-api/typeobj.rst:1739 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:1689 +#: ../../c-api/typeobj.rst:1744 msgid "" "This field is not inherited by subtypes (computed attributes are inherited " "through a different mechanism)." msgstr "" -#: ../../c-api/typeobj.rst:1695 +#: ../../c-api/typeobj.rst:1750 msgid "" "An optional pointer to a base type from which type properties are " "inherited. At this level, only single inheritance is supported; multiple " @@ -2819,7 +2895,7 @@ msgid "" "metatype." msgstr "" -#: ../../c-api/typeobj.rst:1703 +#: ../../c-api/typeobj.rst:1758 msgid "" "Slot initialization is subject to the rules of initializing globals. C99 " "requires the initializers to be \"address constants\". Function designators " @@ -2827,7 +2903,7 @@ msgid "" "valid C99 address constants." msgstr "" -#: ../../c-api/typeobj.rst:1708 +#: ../../c-api/typeobj.rst:1763 msgid "" "However, the unary '&' operator applied to a non-static variable like :c:" "data:`PyBaseObject_Type` is not required to produce an address constant. " @@ -2835,27 +2911,27 @@ msgid "" "strictly standard conforming in this particular behavior." msgstr "" -#: ../../c-api/typeobj.rst:1714 +#: ../../c-api/typeobj.rst:1769 msgid "" "Consequently, :c:member:`~PyTypeObject.tp_base` should be set in the " "extension module's init function." msgstr "" -#: ../../c-api/typeobj.rst:1719 +#: ../../c-api/typeobj.rst:1774 msgid "This field is not inherited by subtypes (obviously)." msgstr "" -#: ../../c-api/typeobj.rst:1723 +#: ../../c-api/typeobj.rst:1778 msgid "" "This field defaults to ``&PyBaseObject_Type`` (which to Python programmers " "is known as the type :class:`object`)." msgstr "" -#: ../../c-api/typeobj.rst:1729 +#: ../../c-api/typeobj.rst:1784 msgid "The type's dictionary is stored here by :c:func:`PyType_Ready`." msgstr "" -#: ../../c-api/typeobj.rst:1731 +#: ../../c-api/typeobj.rst:1786 msgid "" "This field should normally be initialized to ``NULL`` before PyType_Ready is " "called; it may also be initialized to a dictionary containing initial " @@ -2866,73 +2942,73 @@ msgid "" "be treated as read-only." msgstr "" -#: ../../c-api/typeobj.rst:1739 +#: ../../c-api/typeobj.rst:1794 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:1745 +#: ../../c-api/typeobj.rst:1800 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:1751 +#: ../../c-api/typeobj.rst:1806 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:1756 +#: ../../c-api/typeobj.rst:1811 msgid "" "If this field is ``NULL``, :c:func:`PyType_Ready` will assign a new " "dictionary to it." msgstr "" -#: ../../c-api/typeobj.rst:1761 +#: ../../c-api/typeobj.rst:1816 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:1767 +#: ../../c-api/typeobj.rst:1822 msgid "An optional pointer to a \"descriptor get\" function." msgstr "" -#: ../../c-api/typeobj.rst:1769 ../../c-api/typeobj.rst:1785 -#: ../../c-api/typeobj.rst:1849 ../../c-api/typeobj.rst:1879 -#: ../../c-api/typeobj.rst:1903 +#: ../../c-api/typeobj.rst:1824 ../../c-api/typeobj.rst:1840 +#: ../../c-api/typeobj.rst:1904 ../../c-api/typeobj.rst:1934 +#: ../../c-api/typeobj.rst:1958 msgid "The function signature is::" msgstr "" -#: ../../c-api/typeobj.rst:1771 +#: ../../c-api/typeobj.rst:1826 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:1782 +#: ../../c-api/typeobj.rst:1837 msgid "" "An optional pointer to a function for setting and deleting a descriptor's " "value." msgstr "" -#: ../../c-api/typeobj.rst:1787 +#: ../../c-api/typeobj.rst:1842 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:1789 +#: ../../c-api/typeobj.rst:1844 msgid "The *value* argument is set to ``NULL`` to delete the value." msgstr "" -#: ../../c-api/typeobj.rst:1800 +#: ../../c-api/typeobj.rst:1855 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:1803 +#: ../../c-api/typeobj.rst:1858 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 " @@ -2940,19 +3016,19 @@ msgid "" "func:`PyObject_GenericGetAttr`." msgstr "" -#: ../../c-api/typeobj.rst:1808 +#: ../../c-api/typeobj.rst:1863 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:1811 +#: ../../c-api/typeobj.rst:1866 msgid "" "The value specifies the offset of the dictionary from the start of the " "instance structure." msgstr "" -#: ../../c-api/typeobj.rst:1813 +#: ../../c-api/typeobj.rst:1868 msgid "" "The :c:member:`~PyTypeObject.tp_dictoffset` should be regarded as write-" "only. To get the pointer to the dictionary call :c:func:" @@ -2961,13 +3037,13 @@ msgid "" "to call :c:func:`PyObject_GetAttr` when accessing an attribute on the object." msgstr "" -#: ../../c-api/typeobj.rst:1819 +#: ../../c-api/typeobj.rst:1874 msgid "" -"It is an error to set both the :c:macro:`Py_TPFLAGS_MANAGED_WEAKREF` bit " -"and :c:member:`~PyTypeObject.tp_dictoffset`." +"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:1824 +#: ../../c-api/typeobj.rst:1879 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 " @@ -2975,25 +3051,25 @@ msgid "" "`Py_TPFLAGS_MANAGED_DICT`." msgstr "" -#: ../../c-api/typeobj.rst:1831 +#: ../../c-api/typeobj.rst:1886 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:1834 +#: ../../c-api/typeobj.rst:1889 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:1842 +#: ../../c-api/typeobj.rst:1897 msgid "An optional pointer to an instance initialization function." msgstr "" -#: ../../c-api/typeobj.rst:1844 +#: ../../c-api/typeobj.rst:1899 msgid "" "This function corresponds to the :meth:`~object.__init__` method of " "classes. Like :meth:`!__init__`, it is possible to create an instance " @@ -3001,18 +3077,18 @@ msgid "" "instance by calling its :meth:`!__init__` method again." msgstr "" -#: ../../c-api/typeobj.rst:1851 +#: ../../c-api/typeobj.rst:1906 msgid "int tp_init(PyObject *self, PyObject *args, PyObject *kwds);" msgstr "int tp_init(PyObject *self, PyObject *args, PyObject *kwds);" -#: ../../c-api/typeobj.rst:1853 +#: ../../c-api/typeobj.rst:1908 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:1857 +#: ../../c-api/typeobj.rst:1912 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 :" @@ -3024,53 +3100,53 @@ msgid "" "subtype's :c:member:`~PyTypeObject.tp_init` is called." msgstr "" -#: ../../c-api/typeobj.rst:1864 +#: ../../c-api/typeobj.rst:1919 msgid "Returns ``0`` on success, ``-1`` and sets an exception on error." msgstr "" -#: ../../c-api/typeobj.rst:1872 +#: ../../c-api/typeobj.rst:1927 msgid "" "For :ref:`static types ` this field does not have a default." msgstr "" -#: ../../c-api/typeobj.rst:1877 +#: ../../c-api/typeobj.rst:1932 msgid "An optional pointer to an instance allocation function." msgstr "" -#: ../../c-api/typeobj.rst:1881 +#: ../../c-api/typeobj.rst:1936 msgid "PyObject *tp_alloc(PyTypeObject *self, Py_ssize_t nitems);" msgstr "PyObject *tp_alloc(PyTypeObject *self, Py_ssize_t nitems);" -#: ../../c-api/typeobj.rst:1885 +#: ../../c-api/typeobj.rst:1940 msgid "" "This field is inherited by static subtypes, but not by dynamic subtypes " "(subtypes created by a class statement)." msgstr "" -#: ../../c-api/typeobj.rst:1890 +#: ../../c-api/typeobj.rst:1945 msgid "" "For dynamic subtypes, this field is always set to :c:func:" "`PyType_GenericAlloc`, to force a standard heap allocation strategy." msgstr "" -#: ../../c-api/typeobj.rst:1894 +#: ../../c-api/typeobj.rst:1949 msgid "" "For static subtypes, :c:data:`PyBaseObject_Type` uses :c:func:" "`PyType_GenericAlloc`. That is the recommended value for all statically " "defined types." msgstr "" -#: ../../c-api/typeobj.rst:1901 +#: ../../c-api/typeobj.rst:1956 msgid "An optional pointer to an instance creation function." msgstr "" -#: ../../c-api/typeobj.rst:1905 +#: ../../c-api/typeobj.rst:1960 msgid "" "PyObject *tp_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds);" msgstr "" "PyObject *tp_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds);" -#: ../../c-api/typeobj.rst:1907 +#: ../../c-api/typeobj.rst:1962 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 " @@ -3079,7 +3155,7 @@ msgid "" "that type (but not an unrelated type)." msgstr "" -#: ../../c-api/typeobj.rst:1913 +#: ../../c-api/typeobj.rst:1968 msgid "" "The :c:member:`~PyTypeObject.tp_new` function should call ``subtype-" ">tp_alloc(subtype, nitems)`` to allocate space for the object, and then do " @@ -3091,20 +3167,20 @@ msgid "" "be deferred to :c:member:`~PyTypeObject.tp_init`." msgstr "" -#: ../../c-api/typeobj.rst:1921 +#: ../../c-api/typeobj.rst:1976 msgid "" "Set the :c:macro:`Py_TPFLAGS_DISALLOW_INSTANTIATION` flag to disallow " "creating instances of the type in Python." msgstr "" -#: ../../c-api/typeobj.rst:1926 +#: ../../c-api/typeobj.rst:1981 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:1932 +#: ../../c-api/typeobj.rst:1987 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 " @@ -3112,44 +3188,44 @@ msgid "" "factory function." msgstr "" -#: ../../c-api/typeobj.rst:1940 +#: ../../c-api/typeobj.rst:1995 msgid "" "An optional pointer to an instance deallocation function. Its signature is::" msgstr "" -#: ../../c-api/typeobj.rst:1942 +#: ../../c-api/typeobj.rst:1997 msgid "void tp_free(void *self);" msgstr "void tp_free(void *self);" -#: ../../c-api/typeobj.rst:1944 +#: ../../c-api/typeobj.rst:1999 msgid "" "An initializer that is compatible with this signature is :c:func:" "`PyObject_Free`." msgstr "" -#: ../../c-api/typeobj.rst:1948 +#: ../../c-api/typeobj.rst:2003 msgid "" "This field is inherited by static subtypes, but not by dynamic subtypes " "(subtypes created by a class statement)" msgstr "" -#: ../../c-api/typeobj.rst:1953 +#: ../../c-api/typeobj.rst:2008 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." msgstr "" -#: ../../c-api/typeobj.rst:1957 +#: ../../c-api/typeobj.rst:2012 msgid "" "For static subtypes, :c:data:`PyBaseObject_Type` uses :c:func:`PyObject_Del`." msgstr "" -#: ../../c-api/typeobj.rst:1962 +#: ../../c-api/typeobj.rst:2017 msgid "An optional pointer to a function called by the garbage collector." msgstr "" -#: ../../c-api/typeobj.rst:1964 +#: ../../c-api/typeobj.rst:2019 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 " @@ -3161,93 +3237,93 @@ msgid "" "instance. The signature is::" msgstr "" -#: ../../c-api/typeobj.rst:1972 +#: ../../c-api/typeobj.rst:2027 msgid "int tp_is_gc(PyObject *self);" msgstr "int tp_is_gc(PyObject *self);" -#: ../../c-api/typeobj.rst:1974 +#: ../../c-api/typeobj.rst:2029 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:1984 +#: ../../c-api/typeobj.rst:2039 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:1990 +#: ../../c-api/typeobj.rst:2045 msgid "Tuple of base types." msgstr "" -#: ../../c-api/typeobj.rst:1992 ../../c-api/typeobj.rst:2016 +#: ../../c-api/typeobj.rst:2047 ../../c-api/typeobj.rst:2071 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:1995 +#: ../../c-api/typeobj.rst:2050 msgid "" "For dynamically created classes, the ``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:2002 +#: ../../c-api/typeobj.rst:2057 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:2008 ../../c-api/typeobj.rst:2031 -#: ../../c-api/typeobj.rst:2048 ../../c-api/typeobj.rst:2065 -#: ../../c-api/typeobj.rst:2079 +#: ../../c-api/typeobj.rst:2063 ../../c-api/typeobj.rst:2086 +#: ../../c-api/typeobj.rst:2103 ../../c-api/typeobj.rst:2120 +#: ../../c-api/typeobj.rst:2134 msgid "This field is not inherited." msgstr "" -#: ../../c-api/typeobj.rst:2013 +#: ../../c-api/typeobj.rst:2068 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:2021 +#: ../../c-api/typeobj.rst:2076 msgid "" "This field is not inherited; it is calculated fresh by :c:func:" "`PyType_Ready`." msgstr "" -#: ../../c-api/typeobj.rst:2027 +#: ../../c-api/typeobj.rst:2082 msgid "Unused. Internal use only." msgstr "" -#: ../../c-api/typeobj.rst:2036 +#: ../../c-api/typeobj.rst:2091 msgid "" "A collection of subclasses. Internal use only. May be an invalid pointer." msgstr "" -#: ../../c-api/typeobj.rst:2038 +#: ../../c-api/typeobj.rst:2093 msgid "" -"To get a list of subclasses, call the Python method :py:meth:`~class." +"To get a list of subclasses, call the Python method :py:meth:`~type." "__subclasses__`." msgstr "" -#: ../../c-api/typeobj.rst:2043 +#: ../../c-api/typeobj.rst:2098 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:2053 +#: ../../c-api/typeobj.rst:2108 msgid "" "Weak reference list head, for weak references to this type object. Not " "inherited. Internal use only." msgstr "" -#: ../../c-api/typeobj.rst:2058 +#: ../../c-api/typeobj.rst:2113 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 " @@ -3255,25 +3331,25 @@ msgid "" "``_PyObject_GET_WEAKREFS_LISTPTR()`` macro to avoid the distinction." msgstr "" -#: ../../c-api/typeobj.rst:2070 +#: ../../c-api/typeobj.rst:2125 msgid "" "This field is deprecated. Use :c:member:`~PyTypeObject.tp_finalize` instead." msgstr "" -#: ../../c-api/typeobj.rst:2075 +#: ../../c-api/typeobj.rst:2130 msgid "Used to index into the method cache. Internal use only." msgstr "" -#: ../../c-api/typeobj.rst:2084 +#: ../../c-api/typeobj.rst:2139 msgid "" "An optional pointer to an instance finalization function. Its signature is::" msgstr "" -#: ../../c-api/typeobj.rst:2086 +#: ../../c-api/typeobj.rst:2141 msgid "void tp_finalize(PyObject *self);" msgstr "void tp_finalize(PyObject *self);" -#: ../../c-api/typeobj.rst:2088 +#: ../../c-api/typeobj.rst:2143 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 " @@ -3283,55 +3359,40 @@ msgid "" "object in a sane state." msgstr "" -#: ../../c-api/typeobj.rst:2095 +#: ../../c-api/typeobj.rst:2150 msgid "" ":c:member:`~PyTypeObject.tp_finalize` should not mutate the current " "exception status; therefore, a recommended way to write a non-trivial " "finalizer is::" msgstr "" -#: ../../c-api/typeobj.rst:2098 +#: ../../c-api/typeobj.rst:2153 msgid "" "static void\n" "local_finalize(PyObject *self)\n" "{\n" -" PyObject *error_type, *error_value, *error_traceback;\n" -"\n" " /* Save the current exception, if any. */\n" -" PyErr_Fetch(&error_type, &error_value, &error_traceback);\n" +" PyObject *exc = PyErr_GetRaisedException();\n" "\n" " /* ... */\n" "\n" " /* Restore the saved exception. */\n" -" PyErr_Restore(error_type, error_value, error_traceback);\n" +" PyErr_SetRaisedException(exc);\n" "}" msgstr "" -#: ../../c-api/typeobj.rst:2112 -msgid "" -"Also, note that, in a garbage collected Python, :c:member:`~PyTypeObject." -"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 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 tp_dealloc will not violate any assumptions of the library." -msgstr "" - -#: ../../c-api/typeobj.rst:2131 +#: ../../c-api/typeobj.rst:2173 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:2135 +#: ../../c-api/typeobj.rst:2177 msgid "\"Safe object finalization\" (:pep:`442`)" msgstr "" -#: ../../c-api/typeobj.rst:2140 +#: ../../c-api/typeobj.rst:2182 msgid "" "Vectorcall function to use for calls of this type object. In other words, it " "is used to implement :ref:`vectorcall ` for ``type.__call__``. " @@ -3339,65 +3400,65 @@ msgid "" "meth:`~object.__new__` and :meth:`~object.__init__` is used." msgstr "" -#: ../../c-api/typeobj.rst:2148 +#: ../../c-api/typeobj.rst:2190 msgid "This field is never inherited." msgstr "" -#: ../../c-api/typeobj.rst:2150 +#: ../../c-api/typeobj.rst:2192 msgid "(the field exists since 3.8 but it's only used since 3.9)" msgstr "" -#: ../../c-api/typeobj.rst:2155 +#: ../../c-api/typeobj.rst:2197 msgid "Internal. Do not use." msgstr "" -#: ../../c-api/typeobj.rst:2163 +#: ../../c-api/typeobj.rst:2205 msgid "Static Types" msgstr "" -#: ../../c-api/typeobj.rst:2165 +#: ../../c-api/typeobj.rst:2207 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:2169 +#: ../../c-api/typeobj.rst:2211 msgid "" "This results in types that are limited relative to types defined in Python:" msgstr "" -#: ../../c-api/typeobj.rst:2171 +#: ../../c-api/typeobj.rst:2213 msgid "" "Static types are limited to one base, i.e. they cannot use multiple " "inheritance." msgstr "" -#: ../../c-api/typeobj.rst:2173 +#: ../../c-api/typeobj.rst:2215 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:2175 +#: ../../c-api/typeobj.rst:2217 msgid "" "Static type objects are shared across :ref:`sub-interpreters `, so they should not include any subinterpreter-" "specific state." msgstr "" -#: ../../c-api/typeobj.rst:2179 +#: ../../c-api/typeobj.rst:2221 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:2187 +#: ../../c-api/typeobj.rst:2229 msgid "Heap Types" msgstr "" -#: ../../c-api/typeobj.rst:2189 +#: ../../c-api/typeobj.rst:2231 msgid "" "An alternative to :ref:`static types ` is *heap-allocated " "types*, or *heap types* for short, which correspond closely to classes " @@ -3405,29 +3466,29 @@ msgid "" "`Py_TPFLAGS_HEAPTYPE` flag set." msgstr "" -#: ../../c-api/typeobj.rst:2194 +#: ../../c-api/typeobj.rst:2236 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:2202 +#: ../../c-api/typeobj.rst:2244 msgid "Number Object Structures" msgstr "" -#: ../../c-api/typeobj.rst:2209 +#: ../../c-api/typeobj.rst:2251 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:2215 ../../c-api/typeobj.rst:2539 +#: ../../c-api/typeobj.rst:2257 ../../c-api/typeobj.rst:2581 msgid "Here is the structure definition::" msgstr "" -#: ../../c-api/typeobj.rst:2217 +#: ../../c-api/typeobj.rst:2259 msgid "" "typedef struct {\n" " binaryfunc nb_add;\n" @@ -3515,7 +3576,7 @@ msgstr "" " binaryfunc nb_inplace_matrix_multiply;\n" "} PyNumberMethods;" -#: ../../c-api/typeobj.rst:2262 +#: ../../c-api/typeobj.rst:2304 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 " @@ -3525,31 +3586,31 @@ msgid "" "and set an exception." msgstr "" -#: ../../c-api/typeobj.rst:2271 +#: ../../c-api/typeobj.rst:2313 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:2316 +#: ../../c-api/typeobj.rst:2358 msgid "Mapping Object Structures" msgstr "" -#: ../../c-api/typeobj.rst:2323 +#: ../../c-api/typeobj.rst:2365 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:2328 +#: ../../c-api/typeobj.rst:2370 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:2334 +#: ../../c-api/typeobj.rst:2376 msgid "" "This function is used by :c:func:`PyObject_GetItem` and :c:func:" "`PySequence_GetSlice`, and has the same signature as :c:func:`!" @@ -3557,7 +3618,7 @@ msgid "" "`PyMapping_Check` function to return ``1``, it can be ``NULL`` otherwise." msgstr "" -#: ../../c-api/typeobj.rst:2342 +#: ../../c-api/typeobj.rst:2384 msgid "" "This function is used by :c:func:`PyObject_SetItem`, :c:func:" "`PyObject_DelItem`, :c:func:`PySequence_SetSlice` and :c:func:" @@ -3567,17 +3628,17 @@ msgid "" "deletion." msgstr "" -#: ../../c-api/typeobj.rst:2353 +#: ../../c-api/typeobj.rst:2395 msgid "Sequence Object Structures" msgstr "" -#: ../../c-api/typeobj.rst:2360 +#: ../../c-api/typeobj.rst:2402 msgid "" "This structure holds pointers to the functions which an object uses to " "implement the sequence protocol." msgstr "" -#: ../../c-api/typeobj.rst:2365 +#: ../../c-api/typeobj.rst:2407 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 " @@ -3585,21 +3646,21 @@ msgid "" "member:`~PySequenceMethods.sq_ass_item` slots." msgstr "" -#: ../../c-api/typeobj.rst:2372 +#: ../../c-api/typeobj.rst:2414 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:2378 +#: ../../c-api/typeobj.rst:2420 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:2384 +#: ../../c-api/typeobj.rst:2426 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 " @@ -3608,7 +3669,7 @@ msgid "" "``1``, it can be ``NULL`` otherwise." msgstr "" -#: ../../c-api/typeobj.rst:2390 +#: ../../c-api/typeobj.rst:2432 msgid "" "Negative indexes are handled as follows: if the :c:member:" "`~PySequenceMethods.sq_length` slot is filled, it is called and the sequence " @@ -3617,7 +3678,7 @@ msgid "" "index is passed as is to the function." msgstr "" -#: ../../c-api/typeobj.rst:2397 +#: ../../c-api/typeobj.rst:2439 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:" @@ -3626,14 +3687,14 @@ msgid "" "``NULL`` if the object does not support item assignment and deletion." msgstr "" -#: ../../c-api/typeobj.rst:2406 +#: ../../c-api/typeobj.rst:2448 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:2413 +#: ../../c-api/typeobj.rst:2455 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 " @@ -3643,7 +3704,7 @@ msgid "" "c:member:`~PyNumberMethods.nb_inplace_add` slot." msgstr "" -#: ../../c-api/typeobj.rst:2422 +#: ../../c-api/typeobj.rst:2464 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 " @@ -3653,76 +3714,76 @@ msgid "" "via the :c:member:`~PyNumberMethods.nb_inplace_multiply` slot." msgstr "" -#: ../../c-api/typeobj.rst:2433 +#: ../../c-api/typeobj.rst:2475 msgid "Buffer Object Structures" msgstr "" -#: ../../c-api/typeobj.rst:2441 +#: ../../c-api/typeobj.rst:2483 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:2447 ../../c-api/typeobj.rst:2496 -#: ../../c-api/typeobj.rst:2550 ../../c-api/typeobj.rst:2561 -#: ../../c-api/typeobj.rst:2573 ../../c-api/typeobj.rst:2583 +#: ../../c-api/typeobj.rst:2489 ../../c-api/typeobj.rst:2538 +#: ../../c-api/typeobj.rst:2592 ../../c-api/typeobj.rst:2603 +#: ../../c-api/typeobj.rst:2615 ../../c-api/typeobj.rst:2625 msgid "The signature of this function is::" msgstr "" -#: ../../c-api/typeobj.rst:2449 +#: ../../c-api/typeobj.rst:2491 msgid "int (PyObject *exporter, Py_buffer *view, int flags);" msgstr "int (PyObject *exporter, Py_buffer *view, int flags);" -#: ../../c-api/typeobj.rst:2451 +#: ../../c-api/typeobj.rst:2493 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:2455 +#: ../../c-api/typeobj.rst:2497 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:2458 +#: ../../c-api/typeobj.rst:2500 msgid "Fill in the requested fields." msgstr "" -#: ../../c-api/typeobj.rst:2460 +#: ../../c-api/typeobj.rst:2502 msgid "Increment an internal counter for the number of exports." msgstr "" -#: ../../c-api/typeobj.rst:2462 +#: ../../c-api/typeobj.rst:2504 msgid "" "Set :c:expr:`view->obj` to *exporter* and increment :c:expr:`view->obj`." msgstr "" -#: ../../c-api/typeobj.rst:2464 +#: ../../c-api/typeobj.rst:2506 msgid "Return ``0``." msgstr "回傳 ``0``。" -#: ../../c-api/typeobj.rst:2466 +#: ../../c-api/typeobj.rst:2508 msgid "" "If *exporter* is part of a chain or tree of buffer providers, two main " "schemes can be used:" msgstr "" -#: ../../c-api/typeobj.rst:2469 +#: ../../c-api/typeobj.rst:2511 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:2472 +#: ../../c-api/typeobj.rst:2514 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:2476 +#: ../../c-api/typeobj.rst:2518 msgid "" "The individual fields of *view* are described in section :ref:`Buffer " "structure `, the rules how an exporter must react to " @@ -3730,7 +3791,7 @@ msgid "" "types>`." msgstr "" -#: ../../c-api/typeobj.rst:2481 +#: ../../c-api/typeobj.rst:2523 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:" @@ -3739,23 +3800,23 @@ msgid "" "internal` are read-only for the consumer." msgstr "" -#: ../../c-api/typeobj.rst:2488 +#: ../../c-api/typeobj.rst:2530 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:2491 +#: ../../c-api/typeobj.rst:2533 msgid "" ":c:func:`PyObject_GetBuffer` is the interface for the consumer that wraps " "this function." msgstr "" -#: ../../c-api/typeobj.rst:2498 +#: ../../c-api/typeobj.rst:2540 msgid "void (PyObject *exporter, Py_buffer *view);" msgstr "void (PyObject *exporter, Py_buffer *view);" -#: ../../c-api/typeobj.rst:2500 +#: ../../c-api/typeobj.rst:2542 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 " @@ -3763,15 +3824,15 @@ msgid "" "these optional steps:" msgstr "" -#: ../../c-api/typeobj.rst:2505 +#: ../../c-api/typeobj.rst:2547 msgid "Decrement an internal counter for the number of exports." msgstr "" -#: ../../c-api/typeobj.rst:2507 +#: ../../c-api/typeobj.rst:2549 msgid "If the counter is ``0``, free all memory associated with *view*." msgstr "" -#: ../../c-api/typeobj.rst:2509 +#: ../../c-api/typeobj.rst:2551 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 " @@ -3779,30 +3840,30 @@ msgid "" "*view* argument." msgstr "" -#: ../../c-api/typeobj.rst:2515 +#: ../../c-api/typeobj.rst:2557 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:2520 +#: ../../c-api/typeobj.rst:2562 msgid "" ":c:func:`PyBuffer_Release` is the interface for the consumer that wraps this " "function." msgstr "" -#: ../../c-api/typeobj.rst:2528 +#: ../../c-api/typeobj.rst:2570 msgid "Async Object Structures" msgstr "" -#: ../../c-api/typeobj.rst:2536 +#: ../../c-api/typeobj.rst:2578 msgid "" "This structure holds pointers to the functions required to implement :term:" "`awaitable` and :term:`asynchronous iterator` objects." msgstr "" -#: ../../c-api/typeobj.rst:2541 +#: ../../c-api/typeobj.rst:2583 msgid "" "typedef struct {\n" " unaryfunc am_await;\n" @@ -3818,62 +3879,62 @@ msgstr "" " sendfunc am_send;\n" "} PyAsyncMethods;" -#: ../../c-api/typeobj.rst:2552 +#: ../../c-api/typeobj.rst:2594 msgid "PyObject *am_await(PyObject *self);" msgstr "" -#: ../../c-api/typeobj.rst:2554 +#: ../../c-api/typeobj.rst:2596 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:2557 +#: ../../c-api/typeobj.rst:2599 msgid "" "This slot may be set to ``NULL`` if an object is not an :term:`awaitable`." msgstr "" -#: ../../c-api/typeobj.rst:2563 +#: ../../c-api/typeobj.rst:2605 msgid "PyObject *am_aiter(PyObject *self);" msgstr "PyObject *am_aiter(PyObject *self);" -#: ../../c-api/typeobj.rst:2565 +#: ../../c-api/typeobj.rst:2607 msgid "" "Must return an :term:`asynchronous iterator` object. See :meth:`~object." "__anext__` for details." msgstr "" -#: ../../c-api/typeobj.rst:2568 +#: ../../c-api/typeobj.rst:2610 msgid "" "This slot may be set to ``NULL`` if an object does not implement " "asynchronous iteration protocol." msgstr "" -#: ../../c-api/typeobj.rst:2575 +#: ../../c-api/typeobj.rst:2617 msgid "PyObject *am_anext(PyObject *self);" msgstr "PyObject *am_anext(PyObject *self);" -#: ../../c-api/typeobj.rst:2577 +#: ../../c-api/typeobj.rst:2619 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:2585 +#: ../../c-api/typeobj.rst:2627 msgid "PySendResult am_send(PyObject *self, PyObject *arg, PyObject **result);" msgstr "" "PySendResult am_send(PyObject *self, PyObject *arg, PyObject **result);" -#: ../../c-api/typeobj.rst:2587 +#: ../../c-api/typeobj.rst:2629 msgid "" "See :c:func:`PyIter_Send` for details. This slot may be set to ``NULL``." msgstr "" -#: ../../c-api/typeobj.rst:2596 +#: ../../c-api/typeobj.rst:2638 msgid "Slot Type typedefs" msgstr "" -#: ../../c-api/typeobj.rst:2600 +#: ../../c-api/typeobj.rst:2642 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 " @@ -3887,80 +3948,80 @@ msgid "" "length of the block should be :c:member:`~PyTypeObject.tp_basicsize`." msgstr "" -#: ../../c-api/typeobj.rst:2610 +#: ../../c-api/typeobj.rst:2652 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:2617 +#: ../../c-api/typeobj.rst:2659 msgid "See :c:member:`~PyTypeObject.tp_free`." msgstr "請見 :c:member:`~PyTypeObject.tp_free`。" -#: ../../c-api/typeobj.rst:2621 +#: ../../c-api/typeobj.rst:2663 msgid "See :c:member:`~PyTypeObject.tp_new`." msgstr "請見 :c:member:`~PyTypeObject.tp_new`。" -#: ../../c-api/typeobj.rst:2625 +#: ../../c-api/typeobj.rst:2667 msgid "See :c:member:`~PyTypeObject.tp_init`." msgstr "請見 :c:member:`~PyTypeObject.tp_init`。" -#: ../../c-api/typeobj.rst:2629 +#: ../../c-api/typeobj.rst:2671 msgid "See :c:member:`~PyTypeObject.tp_repr`." msgstr "請見 :c:member:`~PyTypeObject.tp_repr`。" -#: ../../c-api/typeobj.rst:2633 ../../c-api/typeobj.rst:2642 +#: ../../c-api/typeobj.rst:2675 ../../c-api/typeobj.rst:2684 msgid "Return the value of the named attribute for the object." msgstr "" -#: ../../c-api/typeobj.rst:2637 ../../c-api/typeobj.rst:2648 +#: ../../c-api/typeobj.rst:2679 ../../c-api/typeobj.rst:2690 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:2644 +#: ../../c-api/typeobj.rst:2686 msgid "See :c:member:`~PyTypeObject.tp_getattro`." msgstr "請見 :c:member:`~PyTypeObject.tp_getattro`。" -#: ../../c-api/typeobj.rst:2651 +#: ../../c-api/typeobj.rst:2693 msgid "See :c:member:`~PyTypeObject.tp_setattro`." msgstr "請見 :c:member:`~PyTypeObject.tp_setattro`。" -#: ../../c-api/typeobj.rst:2655 +#: ../../c-api/typeobj.rst:2697 msgid "See :c:member:`~PyTypeObject.tp_descr_get`." msgstr "請見 :c:member:`~PyTypeObject.tp_descr_get`。" -#: ../../c-api/typeobj.rst:2659 +#: ../../c-api/typeobj.rst:2701 msgid "See :c:member:`~PyTypeObject.tp_descr_set`." msgstr "請見 :c:member:`~PyTypeObject.tp_descr_set`。" -#: ../../c-api/typeobj.rst:2663 +#: ../../c-api/typeobj.rst:2705 msgid "See :c:member:`~PyTypeObject.tp_hash`." msgstr "請見 :c:member:`~PyTypeObject.tp_hash`。" -#: ../../c-api/typeobj.rst:2667 +#: ../../c-api/typeobj.rst:2709 msgid "See :c:member:`~PyTypeObject.tp_richcompare`." msgstr "請見 :c:member:`~PyTypeObject.tp_richcompare`。" -#: ../../c-api/typeobj.rst:2671 +#: ../../c-api/typeobj.rst:2713 msgid "See :c:member:`~PyTypeObject.tp_iter`." msgstr "請見 :c:member:`~PyTypeObject.tp_iter`。" -#: ../../c-api/typeobj.rst:2675 +#: ../../c-api/typeobj.rst:2717 msgid "See :c:member:`~PyTypeObject.tp_iternext`." msgstr "請見 :c:member:`~PyTypeObject.tp_iternext`。" -#: ../../c-api/typeobj.rst:2689 +#: ../../c-api/typeobj.rst:2731 msgid "See :c:member:`~PyAsyncMethods.am_send`." msgstr "請見 :c:member:`~PyAsyncMethods.am_send`。" -#: ../../c-api/typeobj.rst:2705 +#: ../../c-api/typeobj.rst:2747 msgid "Examples" msgstr "範例" -#: ../../c-api/typeobj.rst:2707 +#: ../../c-api/typeobj.rst:2749 msgid "" "The following are simple examples of Python type definitions. They include " "common usage you may encounter. Some demonstrate tricky corner cases. For " @@ -3968,11 +4029,11 @@ msgid "" "and :ref:`new-types-topics`." msgstr "" -#: ../../c-api/typeobj.rst:2712 +#: ../../c-api/typeobj.rst:2754 msgid "A basic :ref:`static type `::" msgstr "" -#: ../../c-api/typeobj.rst:2714 +#: ../../c-api/typeobj.rst:2756 msgid "" "typedef struct {\n" " PyObject_HEAD\n" @@ -3990,13 +4051,13 @@ msgid "" "};" msgstr "" -#: ../../c-api/typeobj.rst:2729 +#: ../../c-api/typeobj.rst:2771 msgid "" "You may also find older code (especially in the CPython code base) with a " "more verbose initializer::" msgstr "" -#: ../../c-api/typeobj.rst:2732 +#: ../../c-api/typeobj.rst:2774 msgid "" "static PyTypeObject MyObject_Type = {\n" " PyVarObject_HEAD_INIT(NULL, 0)\n" @@ -4080,11 +4141,11 @@ msgstr "" " myobj_new, /* tp_new */\n" "};" -#: ../../c-api/typeobj.rst:2773 +#: ../../c-api/typeobj.rst:2815 msgid "A type that supports weakrefs, instance dicts, and hashing::" msgstr "" -#: ../../c-api/typeobj.rst:2775 +#: ../../c-api/typeobj.rst:2817 msgid "" "typedef struct {\n" " PyObject_HEAD\n" @@ -4110,14 +4171,14 @@ msgid "" "};" msgstr "" -#: ../../c-api/typeobj.rst:2798 +#: ../../c-api/typeobj.rst:2840 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:2802 +#: ../../c-api/typeobj.rst:2844 msgid "" "typedef struct {\n" " PyUnicodeObject raw;\n" @@ -4135,12 +4196,12 @@ msgid "" "};" msgstr "" -#: ../../c-api/typeobj.rst:2817 +#: ../../c-api/typeobj.rst:2859 msgid "" "The simplest :ref:`static type ` with fixed-length instances::" msgstr "" -#: ../../c-api/typeobj.rst:2819 +#: ../../c-api/typeobj.rst:2861 msgid "" "typedef struct {\n" " PyObject_HEAD\n" @@ -4160,13 +4221,13 @@ msgstr "" " .tp_name = \"mymod.MyObject\",\n" "};" -#: ../../c-api/typeobj.rst:2828 +#: ../../c-api/typeobj.rst:2870 msgid "" "The simplest :ref:`static type ` with variable-length " "instances::" msgstr "" -#: ../../c-api/typeobj.rst:2830 +#: ../../c-api/typeobj.rst:2872 msgid "" "typedef struct {\n" " PyObject_VAR_HEAD\n" @@ -4192,14 +4253,14 @@ msgstr "" " .tp_itemsize = sizeof(char *),\n" "};" -#: ../../c-api/typeobj.rst:787 ../../c-api/typeobj.rst:852 +#: ../../c-api/typeobj.rst:842 ../../c-api/typeobj.rst:907 msgid "built-in function" msgstr "built-in function(內建函式)" -#: ../../c-api/typeobj.rst:787 +#: ../../c-api/typeobj.rst:842 msgid "repr" msgstr "repr" -#: ../../c-api/typeobj.rst:852 +#: ../../c-api/typeobj.rst:907 msgid "hash" msgstr "hash(雜湊)" diff --git a/c-api/unicode.po b/c-api/unicode.po index 44e3e7af19..eff2f6c5f4 100644 --- a/c-api/unicode.po +++ b/c-api/unicode.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-05-04 20:08+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-" @@ -88,43 +88,49 @@ msgstr "" #: ../../c-api/unicode.rst:71 msgid "" -"This instance of :c:type:`PyTypeObject` represents the Python Unicode type. " +"This instance of :c:type:`PyTypeObject` represents the Python Unicode type. " "It is exposed to Python code as ``str``." msgstr "" -#: ../../c-api/unicode.rst:75 +#: ../../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 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:80 +#: ../../c-api/unicode.rst:86 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:86 +#: ../../c-api/unicode.rst:92 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:92 +#: ../../c-api/unicode.rst:98 msgid "Returns ``0``. This API is kept only for backward compatibility." msgstr "" -#: ../../c-api/unicode.rst:96 +#: ../../c-api/unicode.rst:102 msgid "This API does nothing since Python 3.12." msgstr "" -#: ../../c-api/unicode.rst:102 +#: ../../c-api/unicode.rst:108 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:112 +#: ../../c-api/unicode.rst:118 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 " @@ -132,15 +138,15 @@ msgid "" "`PyUnicode_KIND` to select the right function." msgstr "" -#: ../../c-api/unicode.rst:124 +#: ../../c-api/unicode.rst:130 msgid "Return values of the :c:func:`PyUnicode_KIND` macro." msgstr "" -#: ../../c-api/unicode.rst:128 +#: ../../c-api/unicode.rst:134 msgid "``PyUnicode_WCHAR_KIND`` has been removed." msgstr "``PyUnicode_WCHAR_KIND`` 已被移除。" -#: ../../c-api/unicode.rst:134 +#: ../../c-api/unicode.rst:140 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. " @@ -148,13 +154,13 @@ msgid "" "(not checked)." msgstr "" -#: ../../c-api/unicode.rst:143 +#: ../../c-api/unicode.rst:149 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:152 +#: ../../c-api/unicode.rst:158 msgid "" "Write into a canonical representation *data* (as obtained with :c:func:" "`PyUnicode_DATA`). This function performs no sanity checks, and is intended " @@ -164,189 +170,188 @@ msgid "" "written to that location." msgstr "" -#: ../../c-api/unicode.rst:165 +#: ../../c-api/unicode.rst:171 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:173 +#: ../../c-api/unicode.rst:179 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:182 +#: ../../c-api/unicode.rst:188 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:191 +#: ../../c-api/unicode.rst:197 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:194 +#: ../../c-api/unicode.rst:200 msgid "" "The function does not call :c:func:`Py_FatalError` anymore if the string is " "not ready." msgstr "" -#: ../../c-api/unicode.rst:200 +#: ../../c-api/unicode.rst:206 msgid "Unicode Character Properties" msgstr "" -#: ../../c-api/unicode.rst:202 +#: ../../c-api/unicode.rst:208 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:209 +#: ../../c-api/unicode.rst:215 msgid "" "Return ``1`` or ``0`` depending on whether *ch* is a whitespace character." msgstr "" -#: ../../c-api/unicode.rst:214 +#: ../../c-api/unicode.rst:220 msgid "" "Return ``1`` or ``0`` depending on whether *ch* is a lowercase character." msgstr "" -#: ../../c-api/unicode.rst:219 +#: ../../c-api/unicode.rst:225 msgid "" "Return ``1`` or ``0`` depending on whether *ch* is an uppercase character." msgstr "" -#: ../../c-api/unicode.rst:224 +#: ../../c-api/unicode.rst:230 msgid "" "Return ``1`` or ``0`` depending on whether *ch* is a titlecase character." msgstr "" -#: ../../c-api/unicode.rst:229 +#: ../../c-api/unicode.rst:235 msgid "" "Return ``1`` or ``0`` depending on whether *ch* is a linebreak character." msgstr "" -#: ../../c-api/unicode.rst:234 +#: ../../c-api/unicode.rst:240 msgid "Return ``1`` or ``0`` depending on whether *ch* is a decimal character." msgstr "" -#: ../../c-api/unicode.rst:239 +#: ../../c-api/unicode.rst:245 msgid "Return ``1`` or ``0`` depending on whether *ch* is a digit character." msgstr "" -#: ../../c-api/unicode.rst:244 +#: ../../c-api/unicode.rst:250 msgid "Return ``1`` or ``0`` depending on whether *ch* is a numeric character." msgstr "" -#: ../../c-api/unicode.rst:249 +#: ../../c-api/unicode.rst:255 msgid "" "Return ``1`` or ``0`` depending on whether *ch* is an alphabetic character." msgstr "" -#: ../../c-api/unicode.rst:254 +#: ../../c-api/unicode.rst:260 msgid "" "Return ``1`` or ``0`` depending on whether *ch* is an alphanumeric character." msgstr "" -#: ../../c-api/unicode.rst:259 +#: ../../c-api/unicode.rst:265 msgid "" -"Return ``1`` or ``0`` depending on whether *ch* is a printable character. " -"Nonprintable characters are those characters defined in the Unicode " -"character database as \"Other\" or \"Separator\", excepting the ASCII space " -"(0x20) which is considered printable. (Note that printable characters in " -"this context are those which should not be escaped when :func:`repr` is " -"invoked on a string. It has no bearing on the handling of strings written " -"to :data:`sys.stdout` or :data:`sys.stderr`.)" +"Return ``1`` or ``0`` depending on whether *ch* is a printable character, in " +"the sense of :meth:`str.isprintable`." msgstr "" -#: ../../c-api/unicode.rst:268 +#: ../../c-api/unicode.rst:269 msgid "These APIs can be used for fast direct character conversions:" msgstr "" -#: ../../c-api/unicode.rst:273 +#: ../../c-api/unicode.rst:274 msgid "Return the character *ch* converted to lower case." msgstr "" -#: ../../c-api/unicode.rst:278 +#: ../../c-api/unicode.rst:279 msgid "Return the character *ch* converted to upper case." msgstr "" -#: ../../c-api/unicode.rst:283 +#: ../../c-api/unicode.rst:284 msgid "Return the character *ch* converted to title case." msgstr "" -#: ../../c-api/unicode.rst:288 +#: ../../c-api/unicode.rst:289 msgid "" "Return the character *ch* converted to a decimal positive integer. Return " "``-1`` if this is not possible. This function does not raise exceptions." msgstr "" -#: ../../c-api/unicode.rst:294 +#: ../../c-api/unicode.rst:295 msgid "" "Return the character *ch* converted to a single digit integer. Return ``-1`` " "if this is not possible. This function does not raise exceptions." msgstr "" -#: ../../c-api/unicode.rst:300 +#: ../../c-api/unicode.rst:301 msgid "" "Return the character *ch* converted to a double. Return ``-1.0`` if this is " "not possible. This function does not raise exceptions." msgstr "" -#: ../../c-api/unicode.rst:304 +#: ../../c-api/unicode.rst:305 msgid "These APIs can be used to work with surrogates:" msgstr "" -#: ../../c-api/unicode.rst:308 +#: ../../c-api/unicode.rst:309 msgid "Check if *ch* is a surrogate (``0xD800 <= ch <= 0xDFFF``)." msgstr "" -#: ../../c-api/unicode.rst:312 +#: ../../c-api/unicode.rst:313 msgid "Check if *ch* is a high surrogate (``0xD800 <= ch <= 0xDBFF``)." msgstr "" -#: ../../c-api/unicode.rst:316 +#: ../../c-api/unicode.rst:317 msgid "Check if *ch* is a low surrogate (``0xDC00 <= ch <= 0xDFFF``)." msgstr "" -#: ../../c-api/unicode.rst:320 +#: ../../c-api/unicode.rst:321 msgid "" -"Join two surrogate characters and return a single :c:type:`Py_UCS4` value. " +"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]." msgstr "" -#: ../../c-api/unicode.rst:327 +#: ../../c-api/unicode.rst:328 msgid "Creating and accessing Unicode strings" msgstr "" -#: ../../c-api/unicode.rst:329 +#: ../../c-api/unicode.rst:330 msgid "" "To create Unicode objects and access their basic sequence properties, use " "these APIs:" msgstr "" -#: ../../c-api/unicode.rst:334 +#: ../../c-api/unicode.rst:335 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:338 +#: ../../c-api/unicode.rst:339 msgid "" "This is the recommended way to allocate a new Unicode object. Objects " "created using this function are not resizable." msgstr "" -#: ../../c-api/unicode.rst:347 +#: ../../c-api/unicode.rst:342 +msgid "On error, set an exception and return ``NULL``." +msgstr "" + +#: ../../c-api/unicode.rst:350 msgid "" "Create a new Unicode object with the given *kind* (possible values are :c:" "macro:`PyUnicode_1BYTE_KIND` etc., as returned by :c:func:" @@ -354,7 +359,7 @@ msgid "" "1, 2 or 4 bytes per character, as given by the kind." msgstr "" -#: ../../c-api/unicode.rst:352 +#: ../../c-api/unicode.rst:355 msgid "" "If necessary, the input *buffer* is copied and transformed into the " "canonical representation. For example, if the *buffer* is a UCS4 string (:c:" @@ -362,7 +367,7 @@ msgid "" "range, it will be transformed into UCS1 (:c:macro:`PyUnicode_1BYTE_KIND`)." msgstr "" -#: ../../c-api/unicode.rst:363 +#: ../../c-api/unicode.rst:366 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 " @@ -370,29 +375,29 @@ msgid "" "data is not allowed." msgstr "" -#: ../../c-api/unicode.rst:369 +#: ../../c-api/unicode.rst:372 msgid "This function raises :exc:`SystemError` when:" msgstr "" -#: ../../c-api/unicode.rst:371 +#: ../../c-api/unicode.rst:374 msgid "*size* < 0," msgstr "" -#: ../../c-api/unicode.rst:372 +#: ../../c-api/unicode.rst:375 msgid "*str* is ``NULL`` and *size* > 0" msgstr "" -#: ../../c-api/unicode.rst:374 +#: ../../c-api/unicode.rst:377 msgid "*str* == ``NULL`` with *size* > 0 is not allowed anymore." msgstr "" -#: ../../c-api/unicode.rst:380 +#: ../../c-api/unicode.rst:383 msgid "" "Create a Unicode object from a UTF-8 encoded null-terminated char buffer " "*str*." msgstr "" -#: ../../c-api/unicode.rst:386 +#: ../../c-api/unicode.rst:389 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 " @@ -401,23 +406,23 @@ msgid "" "*format* ASCII-encoded string." msgstr "" -#: ../../c-api/unicode.rst:392 +#: ../../c-api/unicode.rst:395 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:395 +#: ../../c-api/unicode.rst:398 msgid "The ``'%'`` character, which marks the start of the specifier." msgstr "" -#: ../../c-api/unicode.rst:397 +#: ../../c-api/unicode.rst:400 msgid "" "Conversion flags (optional), which affect the result of some conversion " "types." msgstr "" -#: ../../c-api/unicode.rst:400 +#: ../../c-api/unicode.rst:403 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:" @@ -425,7 +430,7 @@ msgid "" "optional precision." msgstr "" -#: ../../c-api/unicode.rst:405 +#: ../../c-api/unicode.rst:408 msgid "" "Precision (optional), given as a ``'.'`` (dot) followed by the precision. If " "specified as ``'*'`` (an asterisk), the actual precision is given in the " @@ -433,317 +438,317 @@ msgid "" "comes after the precision." msgstr "" -#: ../../c-api/unicode.rst:410 +#: ../../c-api/unicode.rst:413 msgid "Length modifier (optional)." msgstr "" -#: ../../c-api/unicode.rst:412 +#: ../../c-api/unicode.rst:415 msgid "Conversion type." msgstr "" -#: ../../c-api/unicode.rst:414 +#: ../../c-api/unicode.rst:417 msgid "The conversion flag characters are:" msgstr "" -#: ../../c-api/unicode.rst:419 +#: ../../c-api/unicode.rst:422 msgid "Flag" msgstr "旗標" -#: ../../c-api/unicode.rst:419 +#: ../../c-api/unicode.rst:422 msgid "Meaning" msgstr "含義" -#: ../../c-api/unicode.rst:421 +#: ../../c-api/unicode.rst:424 msgid "``0``" msgstr "``0``" -#: ../../c-api/unicode.rst:421 +#: ../../c-api/unicode.rst:424 msgid "The conversion will be zero padded for numeric values." msgstr "" -#: ../../c-api/unicode.rst:423 +#: ../../c-api/unicode.rst:426 msgid "``-``" msgstr "``-``" -#: ../../c-api/unicode.rst:423 +#: ../../c-api/unicode.rst:426 msgid "" "The converted value is left adjusted (overrides the ``0`` flag if both are " "given)." msgstr "" -#: ../../c-api/unicode.rst:427 +#: ../../c-api/unicode.rst:430 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:434 +#: ../../c-api/unicode.rst:437 msgid "Modifier" msgstr "" -#: ../../c-api/unicode.rst:434 +#: ../../c-api/unicode.rst:437 msgid "Types" msgstr "" -#: ../../c-api/unicode.rst:436 +#: ../../c-api/unicode.rst:439 msgid "``l``" msgstr "``l``" -#: ../../c-api/unicode.rst:436 +#: ../../c-api/unicode.rst:439 msgid ":c:expr:`long` or :c:expr:`unsigned long`" msgstr ":c:expr:`long` 或 :c:expr:`unsigned long`" -#: ../../c-api/unicode.rst:438 +#: ../../c-api/unicode.rst:441 msgid "``ll``" msgstr "``ll``" -#: ../../c-api/unicode.rst:438 +#: ../../c-api/unicode.rst:441 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:440 +#: ../../c-api/unicode.rst:443 msgid "``j``" msgstr "``j``" -#: ../../c-api/unicode.rst:440 +#: ../../c-api/unicode.rst:443 msgid ":c:type:`intmax_t` or :c:type:`uintmax_t`" msgstr ":c:type:`intmax_t` 或 :c:type:`uintmax_t`" -#: ../../c-api/unicode.rst:442 +#: ../../c-api/unicode.rst:445 msgid "``z``" msgstr "``z``" -#: ../../c-api/unicode.rst:442 +#: ../../c-api/unicode.rst:445 msgid ":c:type:`size_t` or :c:type:`ssize_t`" msgstr ":c:type:`size_t` 或 :c:type:`ssize_t`" -#: ../../c-api/unicode.rst:444 +#: ../../c-api/unicode.rst:447 msgid "``t``" msgstr "``t``" -#: ../../c-api/unicode.rst:444 +#: ../../c-api/unicode.rst:447 msgid ":c:type:`ptrdiff_t`" msgstr ":c:type:`ptrdiff_t`" -#: ../../c-api/unicode.rst:447 +#: ../../c-api/unicode.rst:450 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:450 +#: ../../c-api/unicode.rst:453 msgid "The conversion specifiers are:" msgstr "" -#: ../../c-api/unicode.rst:456 +#: ../../c-api/unicode.rst:459 msgid "Conversion Specifier" msgstr "" -#: ../../c-api/unicode.rst:457 +#: ../../c-api/unicode.rst:460 msgid "Type" msgstr "" -#: ../../c-api/unicode.rst:458 +#: ../../c-api/unicode.rst:461 msgid "Comment" msgstr "" -#: ../../c-api/unicode.rst:460 +#: ../../c-api/unicode.rst:463 msgid "``%``" msgstr "``%``" -#: ../../c-api/unicode.rst:461 +#: ../../c-api/unicode.rst:464 msgid "*n/a*" msgstr "*n/a*" -#: ../../c-api/unicode.rst:462 +#: ../../c-api/unicode.rst:465 msgid "The literal ``%`` character." msgstr "" -#: ../../c-api/unicode.rst:464 +#: ../../c-api/unicode.rst:467 msgid "``d``, ``i``" msgstr "``d``, ``i``" -#: ../../c-api/unicode.rst:465 ../../c-api/unicode.rst:469 -#: ../../c-api/unicode.rst:473 ../../c-api/unicode.rst:477 -#: ../../c-api/unicode.rst:481 +#: ../../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 msgid "Specified by the length modifier" msgstr "" -#: ../../c-api/unicode.rst:466 +#: ../../c-api/unicode.rst:469 msgid "The decimal representation of a signed C integer." msgstr "" -#: ../../c-api/unicode.rst:468 +#: ../../c-api/unicode.rst:471 msgid "``u``" msgstr "``u``" -#: ../../c-api/unicode.rst:470 +#: ../../c-api/unicode.rst:473 msgid "The decimal representation of an unsigned C integer." msgstr "" -#: ../../c-api/unicode.rst:472 +#: ../../c-api/unicode.rst:475 msgid "``o``" msgstr "``o``" -#: ../../c-api/unicode.rst:474 +#: ../../c-api/unicode.rst:477 msgid "The octal representation of an unsigned C integer." msgstr "" -#: ../../c-api/unicode.rst:476 +#: ../../c-api/unicode.rst:479 msgid "``x``" msgstr "``x``" -#: ../../c-api/unicode.rst:478 +#: ../../c-api/unicode.rst:481 msgid "The hexadecimal representation of an unsigned C integer (lowercase)." msgstr "" -#: ../../c-api/unicode.rst:480 +#: ../../c-api/unicode.rst:483 msgid "``X``" msgstr "``X``" -#: ../../c-api/unicode.rst:482 +#: ../../c-api/unicode.rst:485 msgid "The hexadecimal representation of an unsigned C integer (uppercase)." msgstr "" -#: ../../c-api/unicode.rst:484 +#: ../../c-api/unicode.rst:487 msgid "``c``" msgstr "``c``" -#: ../../c-api/unicode.rst:485 +#: ../../c-api/unicode.rst:488 msgid ":c:expr:`int`" msgstr ":c:expr:`int`" -#: ../../c-api/unicode.rst:486 +#: ../../c-api/unicode.rst:489 msgid "A single character." msgstr "" -#: ../../c-api/unicode.rst:488 +#: ../../c-api/unicode.rst:491 msgid "``s``" msgstr "``s``" -#: ../../c-api/unicode.rst:489 +#: ../../c-api/unicode.rst:492 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:490 +#: ../../c-api/unicode.rst:493 msgid "A null-terminated C character array." msgstr "" -#: ../../c-api/unicode.rst:492 +#: ../../c-api/unicode.rst:495 msgid "``p``" msgstr "``p``" -#: ../../c-api/unicode.rst:493 +#: ../../c-api/unicode.rst:496 msgid ":c:expr:`const void*`" msgstr ":c:expr:`const void*`" -#: ../../c-api/unicode.rst:494 +#: ../../c-api/unicode.rst:497 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:499 +#: ../../c-api/unicode.rst:502 msgid "``A``" msgstr "``A``" -#: ../../c-api/unicode.rst:500 ../../c-api/unicode.rst:504 -#: ../../c-api/unicode.rst:514 ../../c-api/unicode.rst:518 -#: ../../c-api/unicode.rst:522 ../../c-api/unicode.rst:527 +#: ../../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 msgid ":c:expr:`PyObject*`" msgstr ":c:expr:`PyObject*`" -#: ../../c-api/unicode.rst:501 +#: ../../c-api/unicode.rst:504 msgid "The result of calling :func:`ascii`." msgstr "" -#: ../../c-api/unicode.rst:503 +#: ../../c-api/unicode.rst:506 msgid "``U``" msgstr "``U``" -#: ../../c-api/unicode.rst:505 +#: ../../c-api/unicode.rst:508 msgid "A Unicode object." msgstr "一 Unicode 物件。" -#: ../../c-api/unicode.rst:507 +#: ../../c-api/unicode.rst:510 msgid "``V``" msgstr "``V``" -#: ../../c-api/unicode.rst:508 +#: ../../c-api/unicode.rst:511 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:509 +#: ../../c-api/unicode.rst:512 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:513 +#: ../../c-api/unicode.rst:516 msgid "``S``" msgstr "``S``" -#: ../../c-api/unicode.rst:515 +#: ../../c-api/unicode.rst:518 msgid "The result of calling :c:func:`PyObject_Str`." msgstr "" -#: ../../c-api/unicode.rst:517 +#: ../../c-api/unicode.rst:520 msgid "``R``" msgstr "``R``" -#: ../../c-api/unicode.rst:519 +#: ../../c-api/unicode.rst:522 msgid "The result of calling :c:func:`PyObject_Repr`." msgstr "" -#: ../../c-api/unicode.rst:521 +#: ../../c-api/unicode.rst:524 msgid "``T``" msgstr "" -#: ../../c-api/unicode.rst:523 +#: ../../c-api/unicode.rst:526 msgid "" "Get the fully qualified name of an object type; call :c:func:" "`PyType_GetFullyQualifiedName`." msgstr "" -#: ../../c-api/unicode.rst:526 +#: ../../c-api/unicode.rst:529 msgid "``#T``" msgstr "" -#: ../../c-api/unicode.rst:528 +#: ../../c-api/unicode.rst:531 msgid "" "Similar to ``T`` format, but use a colon (``:``) as separator between the " "module name and the qualified name." msgstr "" -#: ../../c-api/unicode.rst:531 +#: ../../c-api/unicode.rst:534 msgid "``N``" msgstr "" -#: ../../c-api/unicode.rst:532 ../../c-api/unicode.rst:537 +#: ../../c-api/unicode.rst:535 ../../c-api/unicode.rst:540 #, fuzzy msgid ":c:expr:`PyTypeObject*`" msgstr ":c:expr:`PyObject*`" -#: ../../c-api/unicode.rst:533 +#: ../../c-api/unicode.rst:536 msgid "" "Get the fully qualified name of a type; call :c:func:" "`PyType_GetFullyQualifiedName`." msgstr "" -#: ../../c-api/unicode.rst:536 +#: ../../c-api/unicode.rst:539 msgid "``#N``" msgstr "" -#: ../../c-api/unicode.rst:538 +#: ../../c-api/unicode.rst:541 msgid "" "Similar to ``N`` format, but use a colon (``:``) as separator between the " "module name and the qualified name." msgstr "" -#: ../../c-api/unicode.rst:542 +#: ../../c-api/unicode.rst:545 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 " @@ -753,28 +758,28 @@ msgid "" "``PyObject*`` argument is not ``NULL``)." msgstr "" -#: ../../c-api/unicode.rst:550 +#: ../../c-api/unicode.rst:553 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:554 +#: ../../c-api/unicode.rst:557 msgid "Support for ``\"%lld\"`` and ``\"%llu\"`` added." msgstr "" -#: ../../c-api/unicode.rst:557 +#: ../../c-api/unicode.rst:560 msgid "Support for ``\"%li\"``, ``\"%lli\"`` and ``\"%zi\"`` added." msgstr "" -#: ../../c-api/unicode.rst:560 +#: ../../c-api/unicode.rst:563 msgid "" "Support width and precision formatter for ``\"%s\"``, ``\"%A\"``, " "``\"%U\"``, ``\"%V\"``, ``\"%S\"``, ``\"%R\"`` added." msgstr "" -#: ../../c-api/unicode.rst:564 +#: ../../c-api/unicode.rst:567 msgid "" "Support for conversion specifiers ``o`` and ``X``. Support for length " "modifiers ``j`` and ``t``. Length modifiers are now applied to all integer " @@ -783,40 +788,50 @@ msgid "" "flag ``-``." msgstr "" -#: ../../c-api/unicode.rst:572 +#: ../../c-api/unicode.rst:575 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:576 +#: ../../c-api/unicode.rst:579 msgid "Support for ``%T``, ``%#T``, ``%N`` and ``%#N`` formats added." msgstr "" -#: ../../c-api/unicode.rst:582 +#: ../../c-api/unicode.rst:585 msgid "" "Identical to :c:func:`PyUnicode_FromFormat` except that it takes exactly two " "arguments." msgstr "" -#: ../../c-api/unicode.rst:588 +#: ../../c-api/unicode.rst:591 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:592 +#: ../../c-api/unicode.rst:595 msgid "" "Objects other than Unicode or its subtypes will cause a :exc:`TypeError`." msgstr "" -#: ../../c-api/unicode.rst:598 +#: ../../c-api/unicode.rst:600 +msgid "Create a Unicode Object from the given Unicode code point *ordinal*." +msgstr "" + +#: ../../c-api/unicode.rst:602 +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 msgid "Decode an encoded object *obj* to a Unicode object." msgstr "" -#: ../../c-api/unicode.rst:600 +#: ../../c-api/unicode.rst:611 msgid "" ":class:`bytes`, :class:`bytearray` and other :term:`bytes-like objects " "` are decoded according to the given *encoding* and using " @@ -824,23 +839,39 @@ msgid "" "interface use the default values (see :ref:`builtincodecs` for details)." msgstr "" -#: ../../c-api/unicode.rst:606 +#: ../../c-api/unicode.rst:617 msgid "" "All other objects, including Unicode objects, cause a :exc:`TypeError` to be " "set." msgstr "" -#: ../../c-api/unicode.rst:609 +#: ../../c-api/unicode.rst:620 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:615 +#: ../../c-api/unicode.rst:626 +msgid "" +"Return the name of the default string encoding, ``\"utf-8\"``. See :func:" +"`sys.getdefaultencoding`." +msgstr "" + +#: ../../c-api/unicode.rst:629 +msgid "" +"The returned string does not need to be freed, and is valid until " +"interpreter shutdown." +msgstr "" + +#: ../../c-api/unicode.rst:635 msgid "Return the length of the Unicode object, in code points." msgstr "" -#: ../../c-api/unicode.rst:626 +#: ../../c-api/unicode.rst:637 +msgid "On error, set an exception and return ``-1``." +msgstr "" + +#: ../../c-api/unicode.rst:648 msgid "" "Copy characters from one Unicode object into another. This function " "performs character conversion when necessary and falls back to :c:func:`!" @@ -848,52 +879,61 @@ msgid "" "otherwise returns the number of copied characters." msgstr "" -#: ../../c-api/unicode.rst:637 +#: ../../c-api/unicode.rst:659 msgid "" "Fill a string with a character: write *fill_char* into ``unicode[start:" "start+length]``." msgstr "" -#: ../../c-api/unicode.rst:640 +#: ../../c-api/unicode.rst:662 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:643 +#: ../../c-api/unicode.rst:665 msgid "" "Return the number of written character, or return ``-1`` and raise an " "exception on error." msgstr "" -#: ../../c-api/unicode.rst:652 +#: ../../c-api/unicode.rst:674 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." msgstr "" -#: ../../c-api/unicode.rst:656 +#: ../../c-api/unicode.rst:678 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)." msgstr "" -#: ../../c-api/unicode.rst:665 +#: ../../c-api/unicode.rst:682 +msgid "Return ``0`` on success, ``-1`` on error with an exception set." +msgstr "" + +#: ../../c-api/unicode.rst:689 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:675 +#: ../../c-api/unicode.rst:693 +msgid "Return character on success, ``-1`` on error with an exception set." +msgstr "" + +#: ../../c-api/unicode.rst:701 msgid "" "Return a substring of *unicode*, from character index *start* (included) to " -"character index *end* (excluded). Negative indices are not supported." +"character index *end* (excluded). Negative indices are not supported. On " +"error, set an exception and return ``NULL``." msgstr "" -#: ../../c-api/unicode.rst:684 +#: ../../c-api/unicode.rst:711 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 " @@ -901,7 +941,7 @@ msgid "" "*unicode*). *buffer* is returned on success." msgstr "" -#: ../../c-api/unicode.rst:694 +#: ../../c-api/unicode.rst:721 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:" @@ -909,17 +949,17 @@ msgid "" "appended." msgstr "" -#: ../../c-api/unicode.rst:703 +#: ../../c-api/unicode.rst:730 msgid "Locale Encoding" msgstr "" -#: ../../c-api/unicode.rst:705 +#: ../../c-api/unicode.rst:732 msgid "" "The current locale encoding can be used to decode text from the operating " "system." msgstr "" -#: ../../c-api/unicode.rst:712 +#: ../../c-api/unicode.rst:739 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 " @@ -928,21 +968,21 @@ msgid "" "null character but cannot contain embedded null characters." msgstr "" -#: ../../c-api/unicode.rst:719 +#: ../../c-api/unicode.rst:746 msgid "" "Use :c:func:`PyUnicode_DecodeFSDefaultAndSize` to decode a string from the :" "term:`filesystem encoding and error handler`." msgstr "" -#: ../../c-api/unicode.rst:722 ../../c-api/unicode.rst:757 +#: ../../c-api/unicode.rst:749 ../../c-api/unicode.rst:784 msgid "This function ignores the :ref:`Python UTF-8 Mode `." msgstr "" -#: ../../c-api/unicode.rst:726 ../../c-api/unicode.rst:823 +#: ../../c-api/unicode.rst:753 ../../c-api/unicode.rst:869 msgid "The :c:func:`Py_DecodeLocale` function." msgstr ":c:func:`Py_DecodeLocale` 函式。" -#: ../../c-api/unicode.rst:730 +#: ../../c-api/unicode.rst:757 msgid "" "The function now also uses the current locale encoding for the " "``surrogateescape`` error handler, except on Android. Previously, :c:func:" @@ -950,13 +990,13 @@ msgid "" "locale encoding was used for ``strict``." msgstr "" -#: ../../c-api/unicode.rst:739 +#: ../../c-api/unicode.rst:766 msgid "" "Similar to :c:func:`PyUnicode_DecodeLocaleAndSize`, but compute the string " "length using :c:func:`!strlen`." msgstr "" -#: ../../c-api/unicode.rst:747 +#: ../../c-api/unicode.rst:774 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 " @@ -965,17 +1005,17 @@ msgid "" "`bytes` object. *unicode* cannot contain embedded null characters." msgstr "" -#: ../../c-api/unicode.rst:754 +#: ../../c-api/unicode.rst:781 msgid "" "Use :c:func:`PyUnicode_EncodeFSDefault` to encode a string to the :term:" "`filesystem encoding and error handler`." msgstr "" -#: ../../c-api/unicode.rst:761 ../../c-api/unicode.rst:854 +#: ../../c-api/unicode.rst:788 ../../c-api/unicode.rst:900 msgid "The :c:func:`Py_EncodeLocale` function." msgstr ":c:func:`Py_EncodeLocale` 函式。" -#: ../../c-api/unicode.rst:765 +#: ../../c-api/unicode.rst:792 msgid "" "The function now also uses the current locale encoding for the " "``surrogateescape`` error handler, except on Android. Previously, :c:func:" @@ -983,103 +1023,124 @@ msgid "" "locale encoding was used for ``strict``." msgstr "" -#: ../../c-api/unicode.rst:774 +#: ../../c-api/unicode.rst:801 msgid "File System Encoding" msgstr "" -#: ../../c-api/unicode.rst:776 +#: ../../c-api/unicode.rst:803 msgid "" "Functions encoding to and decoding from the :term:`filesystem encoding and " "error handler` (:pep:`383` and :pep:`529`)." msgstr "" -#: ../../c-api/unicode.rst:779 +#: ../../c-api/unicode.rst:806 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:" +"``\"O&\"`` converter should be used, passing :c:func:`!" +"PyUnicode_FSConverter` as the conversion function:" msgstr "" -#: ../../c-api/unicode.rst:785 +#: ../../c-api/unicode.rst:812 msgid "" -"ParseTuple converter: encode :class:`str` objects -- obtained directly or " -"through the :class:`os.PathLike` interface -- to :class:`bytes` using :c:" -"func:`PyUnicode_EncodeFSDefault`; :class:`bytes` objects are output as-is. " -"*result* must be a :c:expr:`PyBytesObject*` which must be released when it " -"is no longer used." +":ref:`PyArg_Parse\\* converter `: encode :class:`str` objects " +"-- obtained directly or through the :class:`os.PathLike` interface -- to :" +"class:`bytes` using :c:func:`PyUnicode_EncodeFSDefault`; :class:`bytes` " +"objects are output as-is. *result* must be an address of a C variable of " +"type :c:expr:`PyObject*` (or :c:expr:`PyBytesObject*`). On success, set the " +"variable to a new :term:`strong reference` to a :ref:`bytes object " +"` which must be released when it is no longer used and return " +"a non-zero value (:c:macro:`Py_CLEANUP_SUPPORTED`). Embedded null bytes are " +"not allowed in the result. On failure, return ``0`` with an exception set." msgstr "" -#: ../../c-api/unicode.rst:793 ../../c-api/unicode.rst:810 +#: ../../c-api/unicode.rst:824 +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:829 ../../c-api/unicode.rst:856 msgid "Accepts a :term:`path-like object`." msgstr "" -#: ../../c-api/unicode.rst:796 +#: ../../c-api/unicode.rst:832 msgid "" "To decode file names to :class:`str` during argument parsing, the ``\"O&\"`` " -"converter should be used, passing :c:func:`PyUnicode_FSDecoder` as the " +"converter should be used, passing :c:func:`!PyUnicode_FSDecoder` as the " "conversion function:" msgstr "" -#: ../../c-api/unicode.rst:802 +#: ../../c-api/unicode.rst:838 +msgid "" +":ref:`PyArg_Parse\\* converter `: decode :class:`bytes` objects " +"-- obtained either directly or indirectly through the :class:`os.PathLike` " +"interface -- to :class:`str` using :c:func:" +"`PyUnicode_DecodeFSDefaultAndSize`; :class:`str` objects are output as-is. " +"*result* must be an address of a C variable of type :c:expr:`PyObject*` (or :" +"c:expr:`PyUnicodeObject*`). On success, set the variable to a new :term:" +"`strong reference` to a :ref:`Unicode object ` which must be " +"released when it is no longer used and return a non-zero value (:c:macro:" +"`Py_CLEANUP_SUPPORTED`). Embedded null characters are not allowed in the " +"result. On failure, return ``0`` with an exception set." +msgstr "" + +#: ../../c-api/unicode.rst:851 msgid "" -"ParseTuple converter: decode :class:`bytes` objects -- obtained either " -"directly or indirectly through the :class:`os.PathLike` interface -- to :" -"class:`str` using :c:func:`PyUnicode_DecodeFSDefaultAndSize`; :class:`str` " -"objects are output as-is. *result* must be a :c:expr:`PyUnicodeObject*` " -"which must be released when it is no longer used." +"If *obj* is ``NULL``, release the strong reference to the object referred to " +"by *result* and return ``1``." msgstr "" -#: ../../c-api/unicode.rst:816 +#: ../../c-api/unicode.rst:862 msgid "Decode a string from the :term:`filesystem encoding and error handler`." msgstr "" -#: ../../c-api/unicode.rst:818 +#: ../../c-api/unicode.rst:864 msgid "" "If you need to decode a string from the current locale encoding, use :c:func:" "`PyUnicode_DecodeLocaleAndSize`." msgstr "" -#: ../../c-api/unicode.rst:825 ../../c-api/unicode.rst:838 -#: ../../c-api/unicode.rst:858 +#: ../../c-api/unicode.rst:871 ../../c-api/unicode.rst:884 +#: ../../c-api/unicode.rst:904 msgid "" "The :term:`filesystem error handler ` " "is now used." msgstr "" -#: ../../c-api/unicode.rst:832 +#: ../../c-api/unicode.rst:878 msgid "" "Decode a null-terminated string from the :term:`filesystem encoding and " "error handler`." msgstr "" -#: ../../c-api/unicode.rst:835 +#: ../../c-api/unicode.rst:881 msgid "" "If the string length is known, use :c:func:" "`PyUnicode_DecodeFSDefaultAndSize`." msgstr "" -#: ../../c-api/unicode.rst:845 +#: ../../c-api/unicode.rst:891 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:849 +#: ../../c-api/unicode.rst:895 msgid "" "If you need to encode a string to the current locale encoding, use :c:func:" "`PyUnicode_EncodeLocale`." msgstr "" -#: ../../c-api/unicode.rst:863 +#: ../../c-api/unicode.rst:909 msgid "wchar_t Support" msgstr "wchar_t 支援" -#: ../../c-api/unicode.rst:865 +#: ../../c-api/unicode.rst:911 msgid ":c:type:`wchar_t` support for platforms which support it:" msgstr "" -#: ../../c-api/unicode.rst:869 +#: ../../c-api/unicode.rst:915 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 " @@ -1087,7 +1148,7 @@ msgid "" "failure." msgstr "" -#: ../../c-api/unicode.rst:877 +#: ../../c-api/unicode.rst:923 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 " @@ -1095,13 +1156,13 @@ msgid "" "`wchar_t` characters copied or ``-1`` in case of an error." msgstr "" -#: ../../c-api/unicode.rst:882 +#: ../../c-api/unicode.rst:928 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:885 +#: ../../c-api/unicode.rst:931 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:" @@ -1111,7 +1172,7 @@ msgid "" "most C functions." msgstr "" -#: ../../c-api/unicode.rst:895 +#: ../../c-api/unicode.rst:941 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 " @@ -1122,37 +1183,37 @@ msgid "" "`wchar_t*` string contains null characters a :exc:`ValueError` is raised." msgstr "" -#: ../../c-api/unicode.rst:903 +#: ../../c-api/unicode.rst:949 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:910 +#: ../../c-api/unicode.rst:956 msgid "" "Raises a :exc:`ValueError` if *size* is ``NULL`` and the :c:expr:`wchar_t*` " "string contains null characters." msgstr "" -#: ../../c-api/unicode.rst:918 +#: ../../c-api/unicode.rst:964 msgid "Built-in Codecs" msgstr "" -#: ../../c-api/unicode.rst:920 +#: ../../c-api/unicode.rst:966 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:923 +#: ../../c-api/unicode.rst:969 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:927 +#: ../../c-api/unicode.rst:973 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 " @@ -1160,28 +1221,28 @@ msgid "" "handler` internally." msgstr "" -#: ../../c-api/unicode.rst:932 +#: ../../c-api/unicode.rst:978 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:936 +#: ../../c-api/unicode.rst:982 msgid "" "The codecs all use a similar interface. Only deviations from the following " "generic ones are documented for simplicity." msgstr "" -#: ../../c-api/unicode.rst:941 +#: ../../c-api/unicode.rst:987 msgid "Generic Codecs" msgstr "" -#: ../../c-api/unicode.rst:943 +#: ../../c-api/unicode.rst:989 msgid "These are the generic codec APIs:" msgstr "" -#: ../../c-api/unicode.rst:949 +#: ../../c-api/unicode.rst:995 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 " @@ -1190,7 +1251,7 @@ msgid "" "was raised by the codec." msgstr "" -#: ../../c-api/unicode.rst:959 +#: ../../c-api/unicode.rst:1005 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 " @@ -1199,21 +1260,21 @@ msgid "" "was raised by the codec." msgstr "" -#: ../../c-api/unicode.rst:967 +#: ../../c-api/unicode.rst:1013 msgid "UTF-8 Codecs" msgstr "UTF-8 編解碼器" -#: ../../c-api/unicode.rst:969 +#: ../../c-api/unicode.rst:1015 msgid "These are the UTF-8 codec APIs:" msgstr "" -#: ../../c-api/unicode.rst:974 +#: ../../c-api/unicode.rst:1020 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:981 +#: ../../c-api/unicode.rst:1027 msgid "" "If *consumed* is ``NULL``, behave like :c:func:`PyUnicode_DecodeUTF8`. If " "*consumed* is not ``NULL``, trailing incomplete UTF-8 byte sequences will " @@ -1221,14 +1282,20 @@ msgid "" "of bytes that have been decoded will be stored in *consumed*." msgstr "" -#: ../../c-api/unicode.rst:989 +#: ../../c-api/unicode.rst:1035 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:996 +#: ../../c-api/unicode.rst:1039 ../../c-api/unicode.rst:1054 +msgid "" +"The function fails if the string contains surrogate code points (``U+D800`` " +"- ``U+DFFF``)." +msgstr "" + +#: ../../c-api/unicode.rst:1045 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* " @@ -1237,13 +1304,13 @@ msgid "" "regardless of whether there are any other null code points." msgstr "" -#: ../../c-api/unicode.rst:1002 +#: ../../c-api/unicode.rst:1051 msgid "" "On error, set an exception, set *size* to ``-1`` (if it's not NULL) and " "return ``NULL``." msgstr "" -#: ../../c-api/unicode.rst:1005 +#: ../../c-api/unicode.rst:1057 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 " @@ -1252,47 +1319,57 @@ msgid "" "collected." msgstr "" -#: ../../c-api/unicode.rst:1012 ../../c-api/unicode.rst:1025 +#: ../../c-api/unicode.rst:1064 ../../c-api/unicode.rst:1086 msgid "The return type is now ``const char *`` rather of ``char *``." msgstr "" -#: ../../c-api/unicode.rst:1015 +#: ../../c-api/unicode.rst:1067 msgid "This function is a part of the :ref:`limited API `." msgstr "" -#: ../../c-api/unicode.rst:1021 +#: ../../c-api/unicode.rst:1073 msgid "As :c:func:`PyUnicode_AsUTF8AndSize`, but does not store the size." msgstr "" -#: ../../c-api/unicode.rst:1030 +#: ../../c-api/unicode.rst:1077 +msgid "" +"This function does not have any special behavior for `null characters " +"`_ embedded within *unicode*. " +"As a result, strings containing null characters will remain in the returned " +"string, which some C functions might interpret as the end of the string, " +"leading to truncation. If truncation is an issue, it is recommended to use :" +"c:func:`PyUnicode_AsUTF8AndSize` instead." +msgstr "" + +#: ../../c-api/unicode.rst:1091 msgid "UTF-32 Codecs" msgstr "UTF-32 編解碼器" -#: ../../c-api/unicode.rst:1032 +#: ../../c-api/unicode.rst:1093 msgid "These are the UTF-32 codec APIs:" msgstr "" -#: ../../c-api/unicode.rst:1038 +#: ../../c-api/unicode.rst:1099 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:1042 ../../c-api/unicode.rst:1092 +#: ../../c-api/unicode.rst:1103 ../../c-api/unicode.rst:1153 msgid "" "If *byteorder* is non-``NULL``, the decoder starts decoding using the given " "byte order::" msgstr "" -#: ../../c-api/unicode.rst:1045 ../../c-api/unicode.rst:1095 +#: ../../c-api/unicode.rst:1106 ../../c-api/unicode.rst:1156 msgid "" "*byteorder == -1: little endian\n" "*byteorder == 0: native order\n" "*byteorder == 1: big endian" msgstr "" -#: ../../c-api/unicode.rst:1049 +#: ../../c-api/unicode.rst:1110 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 " @@ -1300,21 +1377,21 @@ msgid "" "``-1`` or ``1``, any byte order mark is copied to the output." msgstr "" -#: ../../c-api/unicode.rst:1054 +#: ../../c-api/unicode.rst:1115 msgid "" "After completion, *\\*byteorder* is set to the current byte order at the end " "of input data." msgstr "" -#: ../../c-api/unicode.rst:1057 ../../c-api/unicode.rst:1108 +#: ../../c-api/unicode.rst:1118 ../../c-api/unicode.rst:1169 msgid "If *byteorder* is ``NULL``, the codec starts in native order mode." msgstr "" -#: ../../c-api/unicode.rst:1059 ../../c-api/unicode.rst:1110 +#: ../../c-api/unicode.rst:1120 ../../c-api/unicode.rst:1171 msgid "Return ``NULL`` if an exception was raised by the codec." msgstr "" -#: ../../c-api/unicode.rst:1065 +#: ../../c-api/unicode.rst:1126 msgid "" "If *consumed* is ``NULL``, behave like :c:func:`PyUnicode_DecodeUTF32`. If " "*consumed* is not ``NULL``, :c:func:`PyUnicode_DecodeUTF32Stateful` will not " @@ -1323,29 +1400,29 @@ msgid "" "number of bytes that have been decoded will be stored in *consumed*." msgstr "" -#: ../../c-api/unicode.rst:1074 +#: ../../c-api/unicode.rst:1135 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:1080 +#: ../../c-api/unicode.rst:1141 msgid "UTF-16 Codecs" msgstr "UTF-16 編解碼器" -#: ../../c-api/unicode.rst:1082 +#: ../../c-api/unicode.rst:1143 msgid "These are the UTF-16 codec APIs:" msgstr "" -#: ../../c-api/unicode.rst:1088 +#: ../../c-api/unicode.rst:1149 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:1099 +#: ../../c-api/unicode.rst:1160 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 " @@ -1354,13 +1431,13 @@ msgid "" "result in either a ``\\ufeff`` or a ``\\ufffe`` character)." msgstr "" -#: ../../c-api/unicode.rst:1105 +#: ../../c-api/unicode.rst:1166 msgid "" "After completion, ``*byteorder`` is set to the current byte order at the end " "of input data." msgstr "" -#: ../../c-api/unicode.rst:1116 +#: ../../c-api/unicode.rst:1177 msgid "" "If *consumed* is ``NULL``, behave like :c:func:`PyUnicode_DecodeUTF16`. If " "*consumed* is not ``NULL``, :c:func:`PyUnicode_DecodeUTF16Stateful` will not " @@ -1370,28 +1447,28 @@ msgid "" "*consumed*." msgstr "" -#: ../../c-api/unicode.rst:1125 +#: ../../c-api/unicode.rst:1186 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:1131 +#: ../../c-api/unicode.rst:1192 msgid "UTF-7 Codecs" msgstr "UTF-7 編解碼器" -#: ../../c-api/unicode.rst:1133 +#: ../../c-api/unicode.rst:1194 msgid "These are the UTF-7 codec APIs:" msgstr "" -#: ../../c-api/unicode.rst:1138 +#: ../../c-api/unicode.rst:1199 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:1145 +#: ../../c-api/unicode.rst:1206 msgid "" "If *consumed* is ``NULL``, behave like :c:func:`PyUnicode_DecodeUTF7`. If " "*consumed* is not ``NULL``, trailing incomplete UTF-7 base-64 sections will " @@ -1399,101 +1476,101 @@ msgid "" "of bytes that have been decoded will be stored in *consumed*." msgstr "" -#: ../../c-api/unicode.rst:1152 +#: ../../c-api/unicode.rst:1213 msgid "Unicode-Escape Codecs" msgstr "" -#: ../../c-api/unicode.rst:1154 +#: ../../c-api/unicode.rst:1215 msgid "These are the \"Unicode Escape\" codec APIs:" msgstr "" -#: ../../c-api/unicode.rst:1160 +#: ../../c-api/unicode.rst:1221 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:1166 +#: ../../c-api/unicode.rst:1227 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:1172 +#: ../../c-api/unicode.rst:1233 msgid "Raw-Unicode-Escape Codecs" msgstr "" -#: ../../c-api/unicode.rst:1174 +#: ../../c-api/unicode.rst:1235 msgid "These are the \"Raw Unicode Escape\" codec APIs:" msgstr "" -#: ../../c-api/unicode.rst:1180 +#: ../../c-api/unicode.rst:1241 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:1186 +#: ../../c-api/unicode.rst:1247 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:1192 +#: ../../c-api/unicode.rst:1253 msgid "Latin-1 Codecs" msgstr "Latin-1 編解碼器" -#: ../../c-api/unicode.rst:1194 +#: ../../c-api/unicode.rst:1255 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:1200 +#: ../../c-api/unicode.rst:1261 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:1206 +#: ../../c-api/unicode.rst:1267 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:1212 +#: ../../c-api/unicode.rst:1273 msgid "ASCII Codecs" msgstr "ASCII 編解碼器" -#: ../../c-api/unicode.rst:1214 +#: ../../c-api/unicode.rst:1275 msgid "" "These are the ASCII codec APIs. Only 7-bit ASCII data is accepted. All " "other codes generate errors." msgstr "" -#: ../../c-api/unicode.rst:1220 +#: ../../c-api/unicode.rst:1281 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:1226 +#: ../../c-api/unicode.rst:1287 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:1232 +#: ../../c-api/unicode.rst:1293 msgid "Character Map Codecs" msgstr "" -#: ../../c-api/unicode.rst:1234 +#: ../../c-api/unicode.rst:1295 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 " @@ -1503,18 +1580,18 @@ msgid "" "sequences work well." msgstr "" -#: ../../c-api/unicode.rst:1240 +#: ../../c-api/unicode.rst:1301 msgid "These are the mapping codec APIs:" msgstr "" -#: ../../c-api/unicode.rst:1245 +#: ../../c-api/unicode.rst:1306 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:1249 +#: ../../c-api/unicode.rst:1310 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 " @@ -1524,14 +1601,14 @@ msgid "" "treated as undefined mappings and cause an error." msgstr "" -#: ../../c-api/unicode.rst:1260 +#: ../../c-api/unicode.rst:1321 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:1264 +#: ../../c-api/unicode.rst:1325 msgid "" "The *mapping* object must map Unicode ordinal integers to bytes objects, " "integers in the range from 0 to 255 or ``None``. Unmapped character " @@ -1539,41 +1616,41 @@ msgid "" "``None`` are treated as \"undefined mapping\" and cause an error." msgstr "" -#: ../../c-api/unicode.rst:1270 +#: ../../c-api/unicode.rst:1331 msgid "The following codec API is special in that maps Unicode to Unicode." msgstr "" -#: ../../c-api/unicode.rst:1274 +#: ../../c-api/unicode.rst:1335 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:1278 +#: ../../c-api/unicode.rst:1339 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:1281 +#: ../../c-api/unicode.rst:1342 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:1285 +#: ../../c-api/unicode.rst:1346 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:1290 +#: ../../c-api/unicode.rst:1351 msgid "MBCS codecs for Windows" msgstr "" -#: ../../c-api/unicode.rst:1292 +#: ../../c-api/unicode.rst:1353 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 " @@ -1581,13 +1658,13 @@ msgid "" "is defined by the user settings on the machine running the codec." msgstr "" -#: ../../c-api/unicode.rst:1299 +#: ../../c-api/unicode.rst:1360 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:1306 +#: ../../c-api/unicode.rst:1367 msgid "" "If *consumed* is ``NULL``, behave like :c:func:`PyUnicode_DecodeMBCS`. If " "*consumed* is not ``NULL``, :c:func:`PyUnicode_DecodeMBCSStateful` will not " @@ -1595,44 +1672,50 @@ msgid "" "will be stored in *consumed*." msgstr "" -#: ../../c-api/unicode.rst:1314 +#: ../../c-api/unicode.rst:1376 +msgid "" +"Similar to :c:func:`PyUnicode_DecodeMBCSStateful`, except uses the code page " +"specified by *code_page*." +msgstr "" + +#: ../../c-api/unicode.rst:1382 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:1321 +#: ../../c-api/unicode.rst:1389 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:1329 +#: ../../c-api/unicode.rst:1397 msgid "Methods & Slots" msgstr "" -#: ../../c-api/unicode.rst:1335 +#: ../../c-api/unicode.rst:1403 msgid "Methods and Slot Functions" msgstr "" -#: ../../c-api/unicode.rst:1337 +#: ../../c-api/unicode.rst:1405 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:1341 +#: ../../c-api/unicode.rst:1409 msgid "They all return ``NULL`` or ``-1`` if an exception occurs." msgstr "" -#: ../../c-api/unicode.rst:1346 +#: ../../c-api/unicode.rst:1414 msgid "Concat two strings giving a new Unicode string." msgstr "" -#: ../../c-api/unicode.rst:1351 +#: ../../c-api/unicode.rst:1419 msgid "" "Split a string giving a list of Unicode strings. If *sep* is ``NULL``, " "splitting will be done at all whitespace substrings. Otherwise, splits " @@ -1641,27 +1724,73 @@ msgid "" "list." msgstr "" -#: ../../c-api/unicode.rst:1359 +#: ../../c-api/unicode.rst:1424 ../../c-api/unicode.rst:1434 +#: ../../c-api/unicode.rst:1455 ../../c-api/unicode.rst:1468 +msgid "On error, return ``NULL`` with an exception set." +msgstr "" + +#: ../../c-api/unicode.rst:1426 +msgid "Equivalent to :py:meth:`str.split`." +msgstr "" + +#: ../../c-api/unicode.rst:1431 +msgid "" +"Similar to :c:func:`PyUnicode_Split`, but splitting will be done beginning " +"at the end of the string." +msgstr "" + +#: ../../c-api/unicode.rst:1436 +msgid "Equivalent to :py:meth:`str.rsplit`." +msgstr "" + +#: ../../c-api/unicode.rst:1441 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:1366 +#: ../../c-api/unicode.rst:1448 +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 " +"the part after the separator. If the separator is not found, return a 3-" +"tuple containing the string itself, followed by two empty strings." +msgstr "" + +#: ../../c-api/unicode.rst:1453 ../../c-api/unicode.rst:1466 +msgid "*sep* must not be empty." +msgstr "" + +#: ../../c-api/unicode.rst:1457 +msgid "Equivalent to :py:meth:`str.partition`." +msgstr "" + +#: ../../c-api/unicode.rst:1462 +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:1470 +msgid "Equivalent to :py:meth:`str.rpartition`." +msgstr "" + +#: ../../c-api/unicode.rst:1475 msgid "" "Join a sequence of strings using the given *separator* and return the " "resulting Unicode string." msgstr "" -#: ../../c-api/unicode.rst:1373 +#: ../../c-api/unicode.rst:1482 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:1381 +#: ../../c-api/unicode.rst:1490 msgid "" "Return the first position of *substr* in ``unicode[start:end]`` using the " "given *direction* (*direction* == ``1`` means to do a forward search, " @@ -1670,7 +1799,7 @@ msgid "" "``-2`` indicates that an error occurred and an exception has been set." msgstr "" -#: ../../c-api/unicode.rst:1391 +#: ../../c-api/unicode.rst:1500 msgid "" "Return the first position of the character *ch* in ``unicode[start:end]`` " "using the given *direction* (*direction* == ``1`` means to do a forward " @@ -1680,56 +1809,57 @@ msgid "" "set." msgstr "" -#: ../../c-api/unicode.rst:1399 +#: ../../c-api/unicode.rst:1508 msgid "" "*start* and *end* are now adjusted to behave like ``unicode[start:end]``." msgstr "" -#: ../../c-api/unicode.rst:1406 +#: ../../c-api/unicode.rst:1515 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:1413 +#: ../../c-api/unicode.rst:1522 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:1420 +#: ../../c-api/unicode.rst:1529 msgid "" "Compare two strings and return ``-1``, ``0``, ``1`` for less than, equal, " "and greater than, respectively." msgstr "" -#: ../../c-api/unicode.rst:1423 +#: ../../c-api/unicode.rst:1532 msgid "" "This function returns ``-1`` upon failure, so one should call :c:func:" "`PyErr_Occurred` to check for errors." msgstr "" -#: ../../c-api/unicode.rst:1429 +#: ../../c-api/unicode.rst:1538 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 " -"(``0``) otherwise. If the Unicode object contains surrogate characters or " -"the C string is not valid UTF-8, false (``0``) is returned." +"(``0``) otherwise. If the Unicode object contains surrogate code points " +"(``U+D800`` - ``U+DFFF``) or the C string is not valid UTF-8, false (``0``) " +"is returned." msgstr "" -#: ../../c-api/unicode.rst:1435 ../../c-api/unicode.rst:1456 +#: ../../c-api/unicode.rst:1545 ../../c-api/unicode.rst:1566 msgid "This function does not raise exceptions." msgstr "" -#: ../../c-api/unicode.rst:1442 +#: ../../c-api/unicode.rst:1552 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:1451 +#: ../../c-api/unicode.rst:1561 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 " @@ -1737,47 +1867,47 @@ msgid "" "string as ISO-8859-1 if it contains non-ASCII characters." msgstr "" -#: ../../c-api/unicode.rst:1461 +#: ../../c-api/unicode.rst:1571 msgid "Rich compare two Unicode strings and return one of the following:" msgstr "" -#: ../../c-api/unicode.rst:1463 +#: ../../c-api/unicode.rst:1573 msgid "``NULL`` in case an exception was raised" msgstr "" -#: ../../c-api/unicode.rst:1464 +#: ../../c-api/unicode.rst:1574 msgid ":c:data:`Py_True` or :c:data:`Py_False` for successful comparisons" msgstr "" -#: ../../c-api/unicode.rst:1465 +#: ../../c-api/unicode.rst:1575 msgid ":c:data:`Py_NotImplemented` in case the type combination is unknown" msgstr "" -#: ../../c-api/unicode.rst:1467 +#: ../../c-api/unicode.rst:1577 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:1473 +#: ../../c-api/unicode.rst:1583 msgid "" "Return a new string object from *format* and *args*; this is analogous to " "``format % args``." msgstr "" -#: ../../c-api/unicode.rst:1479 +#: ../../c-api/unicode.rst:1589 msgid "" "Check whether *substr* is contained in *unicode* and return true or false " "accordingly." msgstr "" -#: ../../c-api/unicode.rst:1482 +#: ../../c-api/unicode.rst:1592 msgid "" "*substr* has to coerce to a one element Unicode string. ``-1`` is returned " "if there was an error." msgstr "" -#: ../../c-api/unicode.rst:1488 +#: ../../c-api/unicode.rst:1598 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. " @@ -1788,7 +1918,7 @@ msgid "" "interns it." msgstr "" -#: ../../c-api/unicode.rst:1495 +#: ../../c-api/unicode.rst:1605 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; " @@ -1796,39 +1926,39 @@ msgid "" "the result.)" msgstr "" -#: ../../c-api/unicode.rst:1500 +#: ../../c-api/unicode.rst:1610 msgid "" "This function never raises an exception. On error, it leaves its argument " "unchanged without interning it." msgstr "" -#: ../../c-api/unicode.rst:1503 +#: ../../c-api/unicode.rst:1613 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:1507 +#: ../../c-api/unicode.rst:1617 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:1513 +#: ../../c-api/unicode.rst:1623 msgid "" "A combination of :c:func:`PyUnicode_FromString` and :c:func:" "`PyUnicode_InternInPlace`, meant for statically allocated strings." msgstr "" -#: ../../c-api/unicode.rst:1516 +#: ../../c-api/unicode.rst:1626 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:1520 +#: ../../c-api/unicode.rst:1630 msgid "" "Python may keep a reference to the result, or make it :term:`immortal`, " "preventing it from being garbage-collected promptly. For interning an " @@ -1837,6 +1967,6 @@ msgid "" "`PyUnicode_InternInPlace` directly." msgstr "" -#: ../../c-api/unicode.rst:1528 +#: ../../c-api/unicode.rst:1638 msgid "Strings interned this way are made :term:`immortal`." msgstr "" diff --git a/c-api/veryhigh.po b/c-api/veryhigh.po index 7f42392eaf..c2902a2f86 100644 --- a/c-api/veryhigh.po +++ b/c-api/veryhigh.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-02-12 00:03+0000\n" +"POT-Creation-Date: 2025-02-07 08:41+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-" @@ -51,47 +51,23 @@ msgstr "" #: ../../c-api/veryhigh.rst:30 msgid "" -"The main program for the standard interpreter. This is made available for " -"programs which embed Python. The *argc* and *argv* parameters should be " -"prepared exactly as those which are passed to a C program's :c:func:`main` " -"function (converted to wchar_t according to the user's locale). It is " -"important to note that the argument list may be modified (but the contents " -"of the strings pointed to by the argument list are not). The return value " -"will be ``0`` if the interpreter exits normally (i.e., without an " -"exception), ``1`` if the interpreter exits due to an exception, or ``2`` if " -"the parameter list does not represent a valid Python command line." -msgstr "" - -#: ../../c-api/veryhigh.rst:40 -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:47 -msgid "Similar to :c:func:`Py_Main` but *argv* is an array of bytes strings." -msgstr "" - -#: ../../c-api/veryhigh.rst:54 -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:60 +#: ../../c-api/veryhigh.rst:36 msgid "" "This is a simplified interface to :c:func:`PyRun_AnyFileExFlags` below, " "leaving the *closeit* argument set to ``0``." msgstr "" -#: ../../c-api/veryhigh.rst:66 +#: ../../c-api/veryhigh.rst:42 msgid "" "This is a simplified interface to :c:func:`PyRun_AnyFileExFlags` below, " "leaving the *flags* argument set to ``NULL``." msgstr "" -#: ../../c-api/veryhigh.rst:72 +#: ../../c-api/veryhigh.rst:48 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:" @@ -102,13 +78,13 @@ msgid "" "before ``PyRun_SimpleFileExFlags()`` returns." msgstr "" -#: ../../c-api/veryhigh.rst:84 +#: ../../c-api/veryhigh.rst:60 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:90 +#: ../../c-api/veryhigh.rst:66 msgid "" "Executes the Python source code from *command* in the :mod:`__main__` module " "according to the *flags* argument. If :mod:`__main__` does not already " @@ -117,26 +93,26 @@ msgid "" "information. For the meaning of *flags*, see below." msgstr "" -#: ../../c-api/veryhigh.rst:96 +#: ../../c-api/veryhigh.rst:72 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:103 +#: ../../c-api/veryhigh.rst:79 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:109 +#: ../../c-api/veryhigh.rst:85 msgid "" "This is a simplified interface to :c:func:`PyRun_SimpleFileExFlags` below, " "leaving *flags* set to ``NULL``." msgstr "" -#: ../../c-api/veryhigh.rst:115 +#: ../../c-api/veryhigh.rst:91 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 " @@ -145,20 +121,20 @@ msgid "" "``PyRun_SimpleFileExFlags()`` returns." msgstr "" -#: ../../c-api/veryhigh.rst:122 +#: ../../c-api/veryhigh.rst:98 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:128 +#: ../../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:134 +#: ../../c-api/veryhigh.rst:110 msgid "" "Read and execute a single statement from a file associated with an " "interactive device according to the *flags* argument. The user will be " @@ -166,7 +142,7 @@ msgid "" "term:`filesystem encoding and error handler`." msgstr "" -#: ../../c-api/veryhigh.rst:139 +#: ../../c-api/veryhigh.rst:115 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 " @@ -175,13 +151,13 @@ msgid "" "specifically if needed.)" msgstr "" -#: ../../c-api/veryhigh.rst:148 +#: ../../c-api/veryhigh.rst:124 msgid "" "This is a simplified interface to :c:func:`PyRun_InteractiveLoopFlags` " "below, leaving *flags* set to ``NULL``." msgstr "" -#: ../../c-api/veryhigh.rst:154 +#: ../../c-api/veryhigh.rst:130 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`` " @@ -189,7 +165,7 @@ msgid "" "and error handler`. Returns ``0`` at EOF or a negative number upon failure." msgstr "" -#: ../../c-api/veryhigh.rst:162 +#: ../../c-api/veryhigh.rst:138 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 " @@ -199,13 +175,13 @@ msgid "" "the Python source code." msgstr "" -#: ../../c-api/veryhigh.rst:170 ../../c-api/veryhigh.rst:194 +#: ../../c-api/veryhigh.rst:146 ../../c-api/veryhigh.rst:170 msgid "" "This function is only called from the :ref:`main interpreter `." msgstr "" -#: ../../c-api/veryhigh.rst:177 +#: ../../c-api/veryhigh.rst:153 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 " @@ -216,26 +192,26 @@ msgid "" "line-editing and tab-completion features." msgstr "" -#: ../../c-api/veryhigh.rst:186 +#: ../../c-api/veryhigh.rst:162 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:189 +#: ../../c-api/veryhigh.rst:165 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:200 +#: ../../c-api/veryhigh.rst:176 msgid "" "This is a simplified interface to :c:func:`PyRun_StringFlags` below, leaving " "*flags* set to ``NULL``." msgstr "" -#: ../../c-api/veryhigh.rst:206 +#: ../../c-api/veryhigh.rst:182 msgid "" "Execute Python source code from *str* in the context specified by the " "objects *globals* and *locals* with the compiler flags specified by " @@ -244,31 +220,31 @@ msgid "" "token that should be used to parse the source code." msgstr "" -#: ../../c-api/veryhigh.rst:212 +#: ../../c-api/veryhigh.rst:188 msgid "" "Returns the result of executing the code as a Python object, or ``NULL`` if " "an exception was raised." msgstr "" -#: ../../c-api/veryhigh.rst:218 +#: ../../c-api/veryhigh.rst:194 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:224 +#: ../../c-api/veryhigh.rst:200 msgid "" "This is a simplified interface to :c:func:`PyRun_FileExFlags` below, leaving " "*flags* set to ``NULL``." msgstr "" -#: ../../c-api/veryhigh.rst:230 +#: ../../c-api/veryhigh.rst:206 msgid "" "This is a simplified interface to :c:func:`PyRun_FileExFlags` below, leaving " "*closeit* set to ``0``." msgstr "" -#: ../../c-api/veryhigh.rst:236 +#: ../../c-api/veryhigh.rst:212 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 " @@ -277,19 +253,19 @@ msgid "" "`PyRun_FileExFlags` returns." msgstr "" -#: ../../c-api/veryhigh.rst:245 +#: ../../c-api/veryhigh.rst:221 msgid "" "This is a simplified interface to :c:func:`Py_CompileStringFlags` below, " "leaving *flags* set to ``NULL``." msgstr "" -#: ../../c-api/veryhigh.rst:251 +#: ../../c-api/veryhigh.rst:227 msgid "" "This is a simplified interface to :c:func:`Py_CompileStringExFlags` below, " "with *optimize* set to ``-1``." msgstr "" -#: ../../c-api/veryhigh.rst:257 +#: ../../c-api/veryhigh.rst:233 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 " @@ -300,7 +276,7 @@ msgid "" "returns ``NULL`` if the code cannot be parsed or compiled." msgstr "" -#: ../../c-api/veryhigh.rst:265 +#: ../../c-api/veryhigh.rst:241 msgid "" "The integer *optimize* specifies the optimization level of the compiler; a " "value of ``-1`` selects the optimization level of the interpreter as given " @@ -309,20 +285,20 @@ msgid "" "or ``2`` (docstrings are removed too)." msgstr "" -#: ../../c-api/veryhigh.rst:276 +#: ../../c-api/veryhigh.rst:252 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:283 +#: ../../c-api/veryhigh.rst:259 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:290 +#: ../../c-api/veryhigh.rst:266 msgid "" "Evaluate a precompiled code object, given a particular environment for its " "evaluation. This environment consists of a dictionary of global variables, " @@ -331,13 +307,13 @@ msgid "" "only_parameter>` arguments and a closure tuple of cells." msgstr "" -#: ../../c-api/veryhigh.rst:299 +#: ../../c-api/veryhigh.rst:275 msgid "" "Evaluate an execution frame. This is a simplified interface to :c:func:" "`PyEval_EvalFrameEx`, for backward compatibility." msgstr "" -#: ../../c-api/veryhigh.rst:305 +#: ../../c-api/veryhigh.rst:281 msgid "" "This is the main, unvarnished function of Python interpretation. The code " "object associated with the execution frame *f* is executed, interpreting " @@ -347,39 +323,39 @@ msgid "" "of generator objects." msgstr "" -#: ../../c-api/veryhigh.rst:312 +#: ../../c-api/veryhigh.rst:288 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:319 +#: ../../c-api/veryhigh.rst:295 msgid "" "This function changes the flags of the current evaluation frame, and returns " "true on success, false on failure." msgstr "" -#: ../../c-api/veryhigh.rst:327 +#: ../../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:335 +#: ../../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:344 +#: ../../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:351 +#: ../../c-api/veryhigh.rst:327 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 " @@ -387,40 +363,50 @@ msgid "" "case, ``from __future__ import`` can modify *flags*." msgstr "" -#: ../../c-api/veryhigh.rst:356 +#: ../../c-api/veryhigh.rst:332 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:362 +#: ../../c-api/veryhigh.rst:338 msgid "Compiler flags." msgstr "" -#: ../../c-api/veryhigh.rst:366 +#: ../../c-api/veryhigh.rst:342 msgid "" "*cf_feature_version* is the minor Python version. It should be initialized " "to ``PY_MINOR_VERSION``." msgstr "" -#: ../../c-api/veryhigh.rst:369 +#: ../../c-api/veryhigh.rst:345 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:372 +#: ../../c-api/veryhigh.rst:348 msgid "Added *cf_feature_version* field." msgstr "新增 *cf_feature_version* 欄位。" -#: ../../c-api/veryhigh.rst:378 +#: ../../c-api/veryhigh.rst:351 +msgid "The available compiler flags are accessible as macros:" +msgstr "" + +#: ../../c-api/veryhigh.rst:360 +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:366 msgid "" "This bit can be set in *flags* to cause division operator ``/`` to be " "interpreted as \"true division\" according to :pep:`238`." msgstr "" -#: ../../c-api/veryhigh.rst:325 ../../c-api/veryhigh.rst:333 -#: ../../c-api/veryhigh.rst:342 +#: ../../c-api/veryhigh.rst:301 ../../c-api/veryhigh.rst:309 +#: ../../c-api/veryhigh.rst:318 msgid "Py_CompileString (C function)" msgstr "Py_CompileString(C 函式)" diff --git a/deprecations/c-api-pending-removal-in-3.14.po b/deprecations/c-api-pending-removal-in-3.14.po index acd9ed6272..25b98dc4ae 100644 --- a/deprecations/c-api-pending-removal-in-3.14.po +++ b/deprecations/c-api-pending-removal-in-3.14.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-08-17 00:03+0000\n" +"POT-Creation-Date: 2024-09-24 07:20+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -41,164 +41,191 @@ msgid "" msgstr "設定 Python 初始化的函式,Python 3.11 中已被棄用:" #: ../../deprecations/c-api-pending-removal-in-3.14.rst:12 -msgid "``PySys_SetArgvEx()``: set :c:member:`PyConfig.argv` instead." +#, fuzzy +msgid ":c:func:`!PySys_SetArgvEx()`: Set :c:member:`PyConfig.argv` instead." msgstr "``PySys_SetArgvEx()``:請改以 :c:member:`PyConfig.argv` 設定。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:13 -msgid "``PySys_SetArgv()``: set :c:member:`PyConfig.argv` instead." +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:14 +#, fuzzy +msgid ":c:func:`!PySys_SetArgv()`: Set :c:member:`PyConfig.argv` instead." msgstr "``PySys_SetArgv()``:請改以 :c:member:`PyConfig.argv` 設定。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:14 -msgid "``Py_SetProgramName()``: set :c:member:`PyConfig.program_name` instead." +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:16 +#, fuzzy +msgid "" +":c:func:`!Py_SetProgramName()`: Set :c:member:`PyConfig.program_name` " +"instead." msgstr "" "``Py_SetProgramName()``:請改以 :c:member:`PyConfig.program_name` 設定。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:15 -msgid "``Py_SetPythonHome()``: set :c:member:`PyConfig.home` instead." +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:18 +#, fuzzy +msgid ":c:func:`!Py_SetPythonHome()`: Set :c:member:`PyConfig.home` instead." msgstr "``Py_SetPythonHome()``:請改以 :c:member:`PyConfig.home` 設定。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:17 -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:45 +#: ../../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:20 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:24 msgid "Global configuration variables:" msgstr "全域設定變數:" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:22 -msgid ":c:var:`Py_DebugFlag`: use :c:member:`PyConfig.parser_debug` instead." +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:26 +#, fuzzy +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:23 -msgid ":c:var:`Py_VerboseFlag`: use :c:member:`PyConfig.verbose` instead." +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:28 +#, fuzzy +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:24 -msgid ":c:var:`Py_QuietFlag`: use :c:member:`PyConfig.quiet` instead." +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:30 +#, fuzzy +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:25 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:32 +#, fuzzy msgid "" -":c:var:`Py_InteractiveFlag`: use :c:member:`PyConfig.interactive` instead." +":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:26 -msgid ":c:var:`Py_InspectFlag`: use :c:member:`PyConfig.inspect` instead." +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:34 +#, fuzzy +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:27 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:36 +#, fuzzy msgid "" -":c:var:`Py_OptimizeFlag`: use :c:member:`PyConfig.optimization_level` " +":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:28 -msgid ":c:var:`Py_NoSiteFlag`: use :c:member:`PyConfig.site_import` instead." +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:38 +#, fuzzy +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:29 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:40 +#, fuzzy msgid "" -":c:var:`Py_BytesWarningFlag`: use :c:member:`PyConfig.bytes_warning` instead." +":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:30 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:42 +#, fuzzy msgid "" -":c:var:`Py_FrozenFlag`: use :c:member:`PyConfig.pathconfig_warnings` instead." +":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:31 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:44 +#, fuzzy msgid "" -":c:var:`Py_IgnoreEnvironmentFlag`: use :c:member:`PyConfig.use_environment` " +":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:32 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:46 +#, fuzzy msgid "" -":c:var:`Py_DontWriteBytecodeFlag`: use :c:member:`PyConfig.write_bytecode` " +":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:33 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:48 +#, fuzzy msgid "" -":c:var:`Py_NoUserSiteDirectory`: use :c:member:`PyConfig." +":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:34 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:50 +#, fuzzy msgid "" -":c:var:`Py_UnbufferedStdioFlag`: use :c:member:`PyConfig.buffered_stdio` " +":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:35 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:52 +#, fuzzy msgid "" -":c:var:`Py_HashRandomizationFlag`: use :c:member:`PyConfig.use_hash_seed` " +":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:37 -msgid ":c:var:`Py_IsolatedFlag`: use :c:member:`PyConfig.isolated` instead." +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:55 +#, fuzzy +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:38 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:57 +#, fuzzy msgid "" -":c:var:`Py_LegacyWindowsFSEncodingFlag`: use :c:member:`PyPreConfig." +":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:39 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:59 +#, fuzzy msgid "" -":c:var:`Py_LegacyWindowsStdioFlag`: use :c:member:`PyConfig." +":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:40 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:61 +#, fuzzy msgid "" -":c:var:`!Py_FileSystemDefaultEncoding`: use :c:member:`PyConfig." +":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:41 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:63 +#, fuzzy msgid "" -":c:var:`!Py_HasFileSystemDefaultEncoding`: use :c:member:`PyConfig." +":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:42 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:65 +#, fuzzy msgid "" -":c:var:`!Py_FileSystemDefaultEncodeErrors`: use :c:member:`PyConfig." +":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:43 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:67 +#, fuzzy msgid "" -":c:var:`!Py_UTF8Mode`: use :c:member:`PyPreConfig.utf8_mode` instead. (see :" +":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:" diff --git a/deprecations/c-api-pending-removal-in-3.15.po b/deprecations/c-api-pending-removal-in-3.15.po index 20ea03215f..c4eb16475f 100644 --- a/deprecations/c-api-pending-removal-in-3.15.po +++ b/deprecations/c-api-pending-removal-in-3.15.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2024-10-28 06:59+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -25,65 +25,82 @@ msgid "The bundled copy of ``libmpdecimal``." msgstr "``libmpdecimal`` 的打包副本 (bundled copy)。" #: ../../deprecations/c-api-pending-removal-in-3.15.rst:5 +#, fuzzy msgid "" -":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`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:6 -msgid ":c:func:`PyWeakref_GET_OBJECT`: use :c:func:`PyWeakref_GetRef` instead." -msgstr ":c:func:`PyWeakref_GET_OBJECT`:請改用 :c:func:`PyWeakref_GetRef`。" - #: ../../deprecations/c-api-pending-removal-in-3.15.rst:7 -msgid ":c:func:`PyWeakref_GetObject`: use :c:func:`PyWeakref_GetRef` instead." -msgstr ":c:func:`PyWeakref_GetObject`:請改用 :c:func:`PyWeakref_GetRef`。" - -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:8 -msgid ":c:type:`!Py_UNICODE_WIDE` type: use :c:type:`wchar_t` instead." -msgstr ":c:type:`!Py_UNICODE_WIDE` type:請改用 :c:type:`wchar_t`。" +#, fuzzy +msgid "" +":c:func:`PyWeakref_GetObject` and :c:func:`PyWeakref_GET_OBJECT`: Use :c:" +"func:`PyWeakref_GetRef` instead." +msgstr ":c:func:`PyWeakref_GET_OBJECT`:請改用 :c:func:`PyWeakref_GetRef`。" #: ../../deprecations/c-api-pending-removal-in-3.15.rst:9 -msgid ":c:type:`Py_UNICODE` type: use :c:type:`wchar_t` instead." +#, fuzzy +msgid "" +":c:type:`Py_UNICODE` type and the :c:macro:`!Py_UNICODE_WIDE` macro: Use :c:" +"type:`wchar_t` instead." msgstr ":c:type:`Py_UNICODE` type:請改用 :c:type:`wchar_t`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:10 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:11 msgid "Python initialization functions:" msgstr "Python 初始化函式:" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:12 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:13 +#, fuzzy msgid "" -":c:func:`PySys_ResetWarnOptions`: clear :data:`sys.warnoptions` and :data:`!" +":c:func:`PySys_ResetWarnOptions`: Clear :data:`sys.warnoptions` and :data:`!" "warnings.filters` instead." msgstr "" ":c:func:`PySys_ResetWarnOptions`:請改為清除 :data:`sys.warnoptions` 和 :" "data:`!warnings.filters`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:14 -msgid ":c:func:`Py_GetExecPrefix`: get :data:`sys.exec_prefix` instead." +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:15 +#, fuzzy +msgid "" +":c:func:`Py_GetExecPrefix`: Get :data:`sys.base_exec_prefix` and :data:`sys." +"exec_prefix` instead." msgstr ":c:func:`Py_GetExecPrefix`:請改用 :data:`sys.exec_prefix`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:15 -msgid ":c:func:`Py_GetPath`: get :data:`sys.path` instead." +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:17 +#, fuzzy +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:16 -msgid ":c:func:`Py_GetPrefix`: get :data:`sys.prefix` instead." +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:19 +#, fuzzy +msgid "" +":c:func:`Py_GetPrefix`: Get :data:`sys.base_prefix` and :data:`sys.prefix` " +"instead." msgstr ":c:func:`Py_GetPrefix`:請改用 :data:`sys.prefix`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:17 -msgid ":c:func:`Py_GetProgramFullPath`: get :data:`sys.executable` instead." +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:21 +#, fuzzy +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:18 -msgid ":c:func:`Py_GetProgramName`: get :data:`sys.executable` instead." +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:23 +#, fuzzy +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:19 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:25 +#, fuzzy msgid "" -":c:func:`Py_GetPythonHome`: get :c:member:`PyConfig.home` or the :envvar:" +":c:func:`Py_GetPythonHome`: Get :c:member:`PyConfig.home` or the :envvar:" "`PYTHONHOME` environment variable instead." msgstr "" ":c:func:`Py_GetPythonHome`:請改用 :c:member:`PyConfig.home` 或 :envvar:" "`PYTHONHOME` 環境變數。" + +#~ msgid "" +#~ ":c:func:`PyWeakref_GetObject`: use :c:func:`PyWeakref_GetRef` instead." +#~ msgstr ":c:func:`PyWeakref_GetObject`:請改用 :c:func:`PyWeakref_GetRef`。" + +#~ msgid ":c:type:`!Py_UNICODE_WIDE` type: use :c:type:`wchar_t` instead." +#~ msgstr ":c:type:`!Py_UNICODE_WIDE` type:請改用 :c:type:`wchar_t`。" diff --git a/deprecations/c-api-pending-removal-in-future.po b/deprecations/c-api-pending-removal-in-future.po index 28b6ce87dc..90982fcb83 100644 --- a/deprecations/c-api-pending-removal-in-future.po +++ b/deprecations/c-api-pending-removal-in-future.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-08-17 00:03+0000\n" +"POT-Creation-Date: 2024-09-24 07:20+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -27,84 +27,99 @@ msgid "" msgstr "下列 API 已被棄用並將會被移除,不過目前尚未訂定移除日期。" #: ../../deprecations/c-api-pending-removal-in-future.rst:7 -msgid ":c:macro:`Py_TPFLAGS_HAVE_FINALIZE`: unneeded since Python 3.8." +#, fuzzy +msgid ":c:macro:`Py_TPFLAGS_HAVE_FINALIZE`: Unneeded since Python 3.8." msgstr ":c:macro:`Py_TPFLAGS_HAVE_FINALIZE`:自 Python 3.8 起不再需要" -#: ../../deprecations/c-api-pending-removal-in-future.rst:8 -msgid ":c:func:`PyErr_Fetch`: use :c:func:`PyErr_GetRaisedException` instead." +#: ../../deprecations/c-api-pending-removal-in-future.rst:9 +#, fuzzy +msgid ":c:func:`PyErr_Fetch`: Use :c:func:`PyErr_GetRaisedException` instead." msgstr ":c:func:`PyErr_Fetch`:請改用 :c:func:`PyErr_GetRaisedException`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:9 +#: ../../deprecations/c-api-pending-removal-in-future.rst:11 +#, fuzzy msgid "" -":c:func:`PyErr_NormalizeException`: use :c:func:`PyErr_GetRaisedException` " +":c:func:`PyErr_NormalizeException`: Use :c:func:`PyErr_GetRaisedException` " "instead." msgstr "" ":c:func:`PyErr_NormalizeException`:請改用 :c:func:" "`PyErr_GetRaisedException`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:10 +#: ../../deprecations/c-api-pending-removal-in-future.rst:13 +#, fuzzy msgid "" -":c:func:`PyErr_Restore`: use :c:func:`PyErr_SetRaisedException` instead." +":c:func:`PyErr_Restore`: Use :c:func:`PyErr_SetRaisedException` instead." msgstr ":c:func:`PyErr_Restore`:請改用 :c:func:`PyErr_SetRaisedException`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:11 +#: ../../deprecations/c-api-pending-removal-in-future.rst:15 +#, fuzzy msgid "" -":c:func:`PyModule_GetFilename`: use :c:func:`PyModule_GetFilenameObject` " +":c:func:`PyModule_GetFilename`: Use :c:func:`PyModule_GetFilenameObject` " "instead." msgstr "" ":c:func:`PyModule_GetFilename`:請改用 :c:func:`PyModule_GetFilenameObject`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:12 -msgid ":c:func:`PyOS_AfterFork`: use :c:func:`PyOS_AfterFork_Child` instead." +#: ../../deprecations/c-api-pending-removal-in-future.rst:17 +#, fuzzy +msgid ":c:func:`PyOS_AfterFork`: Use :c:func:`PyOS_AfterFork_Child` instead." msgstr ":c:func:`PyOS_AfterFork`:請改用 :c:func:`PyOS_AfterFork_Child`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:13 +#: ../../deprecations/c-api-pending-removal-in-future.rst:19 +#, fuzzy msgid "" -":c:func:`PySlice_GetIndicesEx`: use :c:func:`PySlice_Unpack` and :c:func:" +":c:func:`PySlice_GetIndicesEx`: Use :c:func:`PySlice_Unpack` and :c:func:" "`PySlice_AdjustIndices` instead." msgstr "" ":c:func:`PySlice_GetIndicesEx`:請改用 :c:func:`PySlice_Unpack` 和 :c:func:" "`PySlice_AdjustIndices`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:14 +#: ../../deprecations/c-api-pending-removal-in-future.rst:21 +#, fuzzy msgid "" -":c:func:`!PyUnicode_AsDecodedObject`: use :c:func:`PyCodec_Decode` instead." +":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:15 +#: ../../deprecations/c-api-pending-removal-in-future.rst:23 +#, fuzzy msgid "" -":c:func:`!PyUnicode_AsDecodedUnicode`: use :c:func:`PyCodec_Decode` instead." +":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:16 +#: ../../deprecations/c-api-pending-removal-in-future.rst:25 +#, fuzzy msgid "" -":c:func:`!PyUnicode_AsEncodedObject`: use :c:func:`PyCodec_Encode` instead." +":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:17 +#: ../../deprecations/c-api-pending-removal-in-future.rst:27 +#, fuzzy msgid "" -":c:func:`!PyUnicode_AsEncodedUnicode`: use :c:func:`PyCodec_Encode` instead." +":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:18 -msgid ":c:func:`PyUnicode_READY`: unneeded since Python 3.12" +#: ../../deprecations/c-api-pending-removal-in-future.rst:29 +#, fuzzy +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:19 -msgid ":c:func:`!PyErr_Display`: use :c:func:`PyErr_DisplayException` instead." +#: ../../deprecations/c-api-pending-removal-in-future.rst:31 +#, fuzzy +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:20 +#: ../../deprecations/c-api-pending-removal-in-future.rst:33 +#, fuzzy msgid "" -":c:func:`!_PyErr_ChainExceptions`: use ``_PyErr_ChainExceptions1`` instead." +":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:21 +#: ../../deprecations/c-api-pending-removal-in-future.rst:35 msgid "" ":c:member:`!PyBytesObject.ob_shash` member: call :c:func:`PyObject_Hash` " "instead." @@ -112,40 +127,46 @@ msgstr "" ":c:member:`!PyBytesObject.ob_shash` 成員:請改為呼叫 :c:func:" "`PyObject_Hash`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:23 +#: ../../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:24 +#: ../../deprecations/c-api-pending-removal-in-future.rst:38 msgid "Thread Local Storage (TLS) API:" msgstr "執行緒局部儲存 (Thread Local Storage, TLS) API:" -#: ../../deprecations/c-api-pending-removal-in-future.rst:26 +#: ../../deprecations/c-api-pending-removal-in-future.rst:40 +#, fuzzy msgid "" -":c:func:`PyThread_create_key`: use :c:func:`PyThread_tss_alloc` instead." +":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:27 -msgid ":c:func:`PyThread_delete_key`: use :c:func:`PyThread_tss_free` instead." +#: ../../deprecations/c-api-pending-removal-in-future.rst:42 +#, fuzzy +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:28 +#: ../../deprecations/c-api-pending-removal-in-future.rst:44 +#, fuzzy msgid "" -":c:func:`PyThread_set_key_value`: use :c:func:`PyThread_tss_set` instead." +":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:29 +#: ../../deprecations/c-api-pending-removal-in-future.rst:46 +#, fuzzy msgid "" -":c:func:`PyThread_get_key_value`: use :c:func:`PyThread_tss_get` instead." +":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:30 +#: ../../deprecations/c-api-pending-removal-in-future.rst:48 +#, fuzzy msgid "" -":c:func:`PyThread_delete_key_value`: use :c:func:`PyThread_tss_delete` " +":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:31 -msgid ":c:func:`PyThread_ReInitTLS`: unneeded since Python 3.7." +#: ../../deprecations/c-api-pending-removal-in-future.rst:50 +#, fuzzy +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 88748aa9dd..f63318d3de 100644 --- a/deprecations/index.po +++ b/deprecations/index.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-05-11 14:27+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -72,6 +72,7 @@ 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`:" @@ -131,46 +132,38 @@ msgstr "" "Alan Williams 於 :gh:`72346` 貢獻。)" #: ../../deprecations/pending-removal-in-3.14.rst:50 -msgid "" -":mod:`importlib`: ``__package__`` and ``__cached__`` will cease to be set or " -"taken into consideration by the import system (:gh:`97879`)." -msgstr "" -":mod:`importlib`:``__package__`` 和 ``__cached__`` 將不再被設定或被 import " -"系統考慮。 (:gh:`97879`)" - -#: ../../deprecations/pending-removal-in-3.14.rst:53 msgid ":mod:`importlib.abc` deprecated classes:" msgstr ":mod:`importlib.abc` 的已棄用類別:" -#: ../../deprecations/pending-removal-in-3.14.rst:55 +#: ../../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:56 +#: ../../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:57 +#: ../../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:59 +#: ../../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:61 +#: ../../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:62 +#: ../../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:64 +#: ../../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:66 +#: ../../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 " @@ -181,7 +174,7 @@ msgstr "" "deepcopy 和 pickle 操作支援。將在 3.14 中移除以大幅減少程式碼量和維護負擔。 " "(由 Raymond Hettinger 於 :gh:`101588` 貢獻。)" -#: ../../deprecations/pending-removal-in-3.14.rst:72 +#: ../../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 " @@ -198,7 +191,7 @@ msgstr "" "API 來明確指定你的程式碼何時\\ *需要* ``'fork'``。請參閱 :ref:" "`multiprocessing-start-methods`。" -#: ../../deprecations/pending-removal-in-3.14.rst:80 +#: ../../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." @@ -206,7 +199,7 @@ msgstr "" ":mod:`pathlib`:已棄用 :meth:`~pathlib.PurePath.is_relative_to` 和 :meth:" "`~pathlib.PurePath.relative_to`:額外引數的傳遞已被棄用。" -#: ../../deprecations/pending-removal-in-3.14.rst:84 +#: ../../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` " @@ -216,27 +209,27 @@ msgstr "" "現在會引發 :exc:`DeprecationWarning`;請改用 :func:`importlib.util." "find_spec`。 (由 Nikita Sobolev 於 :gh:`97850` 貢獻。)" -#: ../../deprecations/pending-removal-in-3.14.rst:89 +#: ../../deprecations/pending-removal-in-3.14.rst:86 msgid ":mod:`pty`:" msgstr ":mod:`pty`:" -#: ../../deprecations/pending-removal-in-3.14.rst:91 +#: ../../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:92 +#: ../../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:94 +#: ../../deprecations/pending-removal-in-3.14.rst:91 msgid ":mod:`sqlite3`:" msgstr ":mod:`sqlite3`:" -#: ../../deprecations/pending-removal-in-3.14.rst:96 +#: ../../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:98 +#: ../../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 " @@ -246,27 +239,7 @@ msgstr "" "使用 :ref:`named placeholders ` 且 *parameters* 是序列" "而不是 :class:`dict`。" -#: ../../deprecations/pending-removal-in-3.14.rst:102 -msgid "" -"date and datetime adapter, date and timestamp converter: see the :mod:" -"`sqlite3` documentation for suggested replacement recipes." -msgstr "" -"date 和 datetime 的適配器 (adapter)、date 和 timestamp 轉換器 (converter):請" -"參閱 :mod:`sqlite3` 文件以獲得建議的替代方案。" - -#: ../../deprecations/pending-removal-in-3.14.rst:105 -msgid "" -":class:`types.CodeType`: Accessing :attr:`~codeobject.co_lnotab` was " -"deprecated in :pep:`626` since 3.10 and was planned to be removed in 3.12, " -"but it only got a proper :exc:`DeprecationWarning` in 3.12. May be removed " -"in 3.14. (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.14 中移除。(由 Nikita Sobolev 於 :gh:" -"`101866` 貢獻。)" - -#: ../../deprecations/pending-removal-in-3.14.rst:112 +#: ../../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." @@ -274,7 +247,7 @@ msgstr "" ":mod:`typing`:自 Python 3.9 起已被棄用的 :class:`~typing.ByteString` 現在在" "使用時會發出 :exc:`DeprecationWarning`。" -#: ../../deprecations/pending-removal-in-3.14.rst:115 +#: ../../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:" @@ -289,100 +262,180 @@ msgid "Pending Removal in Python 3.15" msgstr "Python 3.15 中待移除的項目" #: ../../deprecations/pending-removal-in-3.15.rst:4 +#: ../../deprecations/pending-removal-in-3.16.rst:4 +msgid "The import system:" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.15.rst:6 +msgid "" +"Setting :attr:`~module.__cached__` on a module while failing to set :attr:" +"`__spec__.cached ` is deprecated. In " +"Python 3.15, :attr:`!__cached__` will cease to be set or take into " +"consideration by the import system or standard library. (:gh:`97879`)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.15.rst:11 +msgid "" +"Setting :attr:`~module.__package__` on a module while failing to set :attr:" +"`__spec__.parent ` is deprecated. In " +"Python 3.15, :attr:`!__package__` will cease to be set or take into " +"consideration by the import system or standard library. (:gh:`97879`)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.15.rst:16 +#, fuzzy +msgid ":mod:`ctypes`:" +msgstr ":mod:`pty`:" + +#: ../../deprecations/pending-removal-in-3.15.rst:18 +msgid "" +"The undocumented :func:`!ctypes.SetPointerType` function has been deprecated " +"since Python 3.13." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.15.rst:21 +#, fuzzy +msgid ":mod:`http.server`:" +msgstr ":mod:`datetime`:" + +#: ../../deprecations/pending-removal-in-3.15.rst:23 +#, fuzzy msgid "" -":class:`http.server.CGIHTTPRequestHandler` will be removed along with its " -"related ``--cgi`` flag to ``python -m http.server``. It was obsolete and " -"rarely used. No direct replacement exists. *Anything* is better than CGI " -"to interface a web server with a request handler." +"The obsolete and rarely used :class:`~http.server.CGIHTTPRequestHandler` has " +"been deprecated since Python 3.13. No direct replacement exists. *Anything* " +"is better than CGI to interface a web server with a request handler." msgstr "" ":class:`http.server.CGIHTTPRequestHandler` 將會被移除,連同其相關的 ``--" "cgi`` 旗標到 ``python -m http.server``。它已經過時且很少被使用。沒有直接的替" "代方案。*任何東西*\\ 都比 CGI 更好的來介接一個帶有請求處理器的網頁伺服器。" -#: ../../deprecations/pending-removal-in-3.15.rst:9 +#: ../../deprecations/pending-removal-in-3.15.rst:29 +msgid "" +"The :option:`!--cgi` flag to the :program:`python -m http.server` command-" +"line interface has been deprecated since Python 3.13." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.15.rst:32 +#: ../../deprecations/pending-removal-in-future.rst:56 +msgid ":mod:`importlib`:" +msgstr ":mod:`importlib`:" + +#: ../../deprecations/pending-removal-in-3.15.rst:34 +msgid "``load_module()`` method: use ``exec_module()`` instead." +msgstr "``load_module()`` method:請改用 ``exec_module()``。" + +#: ../../deprecations/pending-removal-in-3.15.rst:36 +#, fuzzy +msgid ":class:`locale`:" +msgstr ":class:`!ast.Bytes`" + +#: ../../deprecations/pending-removal-in-3.15.rst:38 +#, fuzzy msgid "" -":class:`locale`: :func:`locale.getdefaultlocale` was deprecated in Python " -"3.11 and originally planned for removal in Python 3.13 (:gh:`90817`), but " -"removal has been postponed to Python 3.15. Use :func:`locale.setlocale`, :" -"func:`locale.getencoding` and :func:`locale.getlocale` instead. (Contributed " -"by Hugo van Kemenade in :gh:`111187`.)" +"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`.)" msgstr "" ":class:`locale`::func:`locale.getdefaultlocale` 已在 Python 3.11 中被棄用," "原本計劃在 Python 3.13 中移除 (:gh:`90817`),但被延後至 Python 3.15。請改用 :" "func:`locale.setlocale`、:func:`locale.getencoding` 和 :func:`locale." "getlocale`。 (由 Hugo van Kemenade 於 :gh:`111187` 貢獻。)" -#: ../../deprecations/pending-removal-in-3.15.rst:16 +#: ../../deprecations/pending-removal-in-3.15.rst:46 +#, fuzzy +msgid ":mod:`pathlib`:" +msgstr ":mod:`importlib`:" + +#: ../../deprecations/pending-removal-in-3.15.rst:48 +#, fuzzy msgid "" -":mod:`pathlib`: :meth:`pathlib.PurePath.is_reserved` is deprecated and " -"scheduled for removal in Python 3.15. 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 "" ":mod:`pathlib`::meth:`pathlib.PurePath.is_reserved` 已被棄用並計劃在 Python " "3.15 中移除。請用 :func:`os.path.isreserved` 來偵測 Windows 上的保留路徑。" -#: ../../deprecations/pending-removal-in-3.15.rst:21 +#: ../../deprecations/pending-removal-in-3.15.rst:52 +#, fuzzy +msgid ":mod:`platform`:" +msgstr ":mod:`pty`:" + +#: ../../deprecations/pending-removal-in-3.15.rst:54 msgid "" -":mod:`platform`: :func:`~platform.java_ver` is deprecated and will be " -"removed in 3.15. It was largely untested, had a confusing API, and was only " -"useful for Jython support. (Contributed by Nikita Sobolev in :gh:`116349`.)" +":func:`~platform.java_ver` has been deprecated since Python 3.13. This " +"function is only useful for Jython support, has a confusing API, and is " +"largely untested." msgstr "" -":mod:`platform`::func:`~platform.java_ver` 已被棄用並將在 3.15 中移除。它幾" -"乎沒有被測試過,API 令人困惑並且只對 Jython 支援有用。 (由 Nikita Sobolev " -"於 :gh:`116349` 貢獻。)" -#: ../../deprecations/pending-removal-in-3.15.rst:27 +#: ../../deprecations/pending-removal-in-3.15.rst:58 +#, fuzzy +msgid ":mod:`sysconfig`:" +msgstr ":mod:`pty`:" + +#: ../../deprecations/pending-removal-in-3.15.rst:60 msgid "" -":mod:`threading`: Passing any arguments to :func:`threading.RLock` is now " -"deprecated. C version allows any numbers of args and kwargs, but they are " -"just ignored. Python version does not allow any arguments. All arguments " -"will be removed from :func:`threading.RLock` in Python 3.15. (Contributed by " -"Nikita Sobolev in :gh:`102029`.)" +"The *check_home* argument of :func:`sysconfig.is_python_build` has been " +"deprecated since Python 3.12." msgstr "" -":mod:`threading`:對 :func:`threading.RLock` 傳遞任何引數現在已被棄用。C 版本" -"允許任意數量的引數和關鍵字引數,但它們會被忽略。Python 版本不允許任何引數。所" -"有引數將在 Python 3.15 中從 :func:`threading.RLock` 中移除。 (由 Nikita " -"Sobolev 於 :gh:`102029` 貢獻。)" -#: ../../deprecations/pending-removal-in-3.15.rst:34 -msgid ":class:`typing.NamedTuple`:" -msgstr ":class:`typing.NamedTuple`:" +#: ../../deprecations/pending-removal-in-3.15.rst:63 +#, fuzzy +msgid ":mod:`threading`:" +msgstr ":mod:`threading` 方法:" -#: ../../deprecations/pending-removal-in-3.15.rst:36 +#: ../../deprecations/pending-removal-in-3.15.rst:65 msgid "" -"The undocumented keyword argument syntax for creating :class:`!NamedTuple` " -"classes (``NT = NamedTuple(\"NT\", x=int)``) is deprecated, and will be " -"disallowed in 3.15. Use the class-based syntax or the functional syntax " -"instead." +":func:`~threading.RLock` will take no arguments in Python 3.15. Passing any " +"arguments has been deprecated since Python 3.14, as the Python version does " +"not permit any arguments, but the C version allows any number of positional " +"or keyword arguments, ignoring every argument." msgstr "" -"用於建立 :class:`!NamedTuple` 類別的未以文件記錄之關鍵字引數語法 (``NT = " -"NamedTuple(\"NT\", x=int)``) 已棄用,並將在 3.15 中被禁止。請改用基於類別的語" -"法或函式語法 (functional syntax)。" -#: ../../deprecations/pending-removal-in-3.15.rst:40 +#: ../../deprecations/pending-removal-in-3.15.rst:71 +#, fuzzy +msgid ":mod:`types`:" +msgstr ":mod:`pty`:" + +#: ../../deprecations/pending-removal-in-3.15.rst:73 +#, fuzzy +msgid "" +":class:`types.CodeType`: Accessing :attr:`~codeobject.co_lnotab` was " +"deprecated in :pep:`626` since 3.10 and was planned to be removed in 3.12, " +"but it only got a proper :exc:`DeprecationWarning` in 3.12. May be removed " +"in 3.15. (Contributed by Nikita Sobolev in :gh:`101866`.)" +msgstr "" +":class:`types.CodeType`:自 3.10 起,存取 :attr:`~codeobject.co_lnotab` 已" +"在 :pep:`626` 中被棄用,並計劃在 3.12 中移除,但只在 3.12 中於適當時發出 :" +"exc:`DeprecationWarning`。可能在 3.14 中移除。(由 Nikita Sobolev 於 :gh:" +"`101866` 貢獻。)" + +#: ../../deprecations/pending-removal-in-3.15.rst:80 +#, fuzzy +msgid ":mod:`typing`:" +msgstr ":mod:`pty`:" + +#: ../../deprecations/pending-removal-in-3.15.rst:82 +#, fuzzy msgid "" -"When using the functional syntax to create a :class:`!NamedTuple` class, " -"failing to pass a value to the *fields* parameter (``NT = " -"NamedTuple(\"NT\")``) is deprecated. Passing ``None`` to the *fields* " -"parameter (``NT = NamedTuple(\"NT\", None)``) is also deprecated. Both will " -"be disallowed in Python 3.15. To create a :class:`!NamedTuple` class with 0 " -"fields, use ``class NT(NamedTuple): pass`` or ``NT = NamedTuple(\"NT\", " -"[])``." +"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." msgstr "" -"當使用函式語法來建立 :class:`!NamedTuple` 類別時,沒將值傳遞給 *fields* 參數" -"的方式 (``NT = NamedTuple(\"NT\")``) 已被棄用,將 ``None`` 傳遞給 *fields* 參" -"數(``NT = NamedTuple(\"NT\", None)``)也已被棄用。這兩者將在 Python 3.15 中" -"會被禁止。要建立一個沒有欄位的 :class:`!NamedTuple` 類別,請使用 ``class " -"NT(NamedTuple): pass`` 或 ``NT = NamedTuple(\"NT\", [])``。" +"用於建立 :class:`!NamedTuple` 類別的未以文件記錄之關鍵字引數語法 (``NT = " +"NamedTuple(\"NT\", x=int)``) 已棄用,並將在 3.15 中被禁止。請改用基於類別的語" +"法或函式語法 (functional syntax)。" -#: ../../deprecations/pending-removal-in-3.15.rst:47 +#: ../../deprecations/pending-removal-in-3.15.rst:88 +#, fuzzy msgid "" -":class:`typing.TypedDict`: When using the functional syntax to create a :" -"class:`!TypedDict` class, failing to pass a value to the *fields* parameter " -"(``TD = TypedDict(\"TD\")``) is deprecated. Passing ``None`` to the *fields* " -"parameter (``TD = TypedDict(\"TD\", None)``) is also deprecated. Both will " -"be disallowed in Python 3.15. To create a :class:`!TypedDict` class with 0 " -"fields, use ``class TD(TypedDict): pass`` or ``TD = TypedDict(\"TD\", {})``." +"When using the functional syntax of :class:`~typing.TypedDict`\\s, failing " +"to pass a value to the *fields* parameter (``TD = TypedDict(\"TD\")``) or " +"passing ``None`` (``TD = TypedDict(\"TD\", None)``) has been deprecated " +"since Python 3.13. Use ``class TD(TypedDict): pass`` or ``TD = " +"TypedDict(\"TD\", {})`` to create a TypedDict with zero field." msgstr "" ":class:`typing.TypedDict`:當使用函式語法來建立 :class:`!TypedDict` 類別時," "沒將值傳遞給 *fields* 參數的方式(``TD = TypedDict(\"TD\")``)已被棄用,將 " @@ -391,40 +444,120 @@ msgstr "" "類別,請使用 ``class TD(TypedDict): pass`` 或 ``TD = TypedDict(\"TD\", " "{})``。" -#: ../../deprecations/pending-removal-in-3.15.rst:54 +#: ../../deprecations/pending-removal-in-3.15.rst:95 +msgid "" +"The :func:`typing.no_type_check_decorator` decorator function has been " +"deprecated since Python 3.13. After eight years in the :mod:`typing` module, " +"it has yet to be supported by any major type checker." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.15.rst:100 +#, fuzzy +msgid ":mod:`wave`:" +msgstr ":mod:`datetime`:" + +#: ../../deprecations/pending-removal-in-3.15.rst:102 +#, fuzzy msgid "" -":mod:`wave`: Deprecate the ``getmark()``, ``setmark()`` and ``getmarkers()`` " -"methods of the :class:`wave.Wave_read` and :class:`wave.Wave_write` classes. " -"They will be removed in Python 3.15. (Contributed by Victor Stinner in :gh:" -"`105096`.)" +"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 "" ":mod:`wave`:已棄用 :class:`wave.Wave_read` 和 :class:`wave.Wave_write` 類別" "的 ``getmark()``、``setmark()`` 和 ``getmarkers()`` 方法。它們將在 Python " "3.15 中被移除。 (由 Victor Stinner 於 :gh:`105096` 貢獻。)" #: ../../deprecations/pending-removal-in-3.16.rst:2 -msgid "Pending Removal in Python 3.16" +#, fuzzy +msgid "Pending removal in Python 3.16" msgstr "Python 3.16 中待移除的項目" -#: ../../deprecations/pending-removal-in-3.16.rst:4 +#: ../../deprecations/pending-removal-in-3.16.rst:6 msgid "" -":mod:`array`: :class:`array.array` ``'u'`` type (:c:type:`wchar_t`): use the " -"``'w'`` type instead (``Py_UCS4``)." +"Setting :attr:`~module.__loader__` on a module while failing to set :attr:" +"`__spec__.loader ` is deprecated. In " +"Python 3.16, :attr:`!__loader__` will cease to be set or taken into " +"consideration by the import system or the standard library." msgstr "" -":mod:`array`::class:`array.array` ``'u'`` 型別 (:c:type:`wchar_t`):請改用 " -"``'w'`` 型別 (``Py_UCS4``)。" - -#: ../../deprecations/pending-removal-in-3.16.rst:8 -msgid ":mod:`builtins`: ``~bool``, bitwise inversion on bool." -msgstr ":mod:`builtins`:``~bool``,對 bool 進行位元反轉。" #: ../../deprecations/pending-removal-in-3.16.rst:11 +#, fuzzy +msgid ":mod:`array`:" +msgstr ":mod:`pty`:" + +#: ../../deprecations/pending-removal-in-3.16.rst:13 +msgid "" +"The ``'u'`` format code (:c:type:`wchar_t`) has been deprecated in " +"documentation since Python 3.3 and at runtime since Python 3.13. Use the " +"``'w'`` format code (:c:type:`Py_UCS4`) for Unicode characters instead." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.16.rst:21 +msgid "" +":func:`!asyncio.iscoroutinefunction` is deprecated and will be removed in " +"Python 3.16, use :func:`inspect.iscoroutinefunction` instead. (Contributed " +"by Jiahao Li and Kumar Aditya in :gh:`122875`.)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.16.rst:26 +#: ../../deprecations/pending-removal-in-future.rst:10 +msgid ":mod:`builtins`:" +msgstr ":mod:`builtins`:" + +#: ../../deprecations/pending-removal-in-3.16.rst:28 +msgid "" +"Bitwise inversion on boolean types, ``~True`` or ``~False`` has been " +"deprecated since Python 3.12, as it produces surprising and unintuitive " +"results (``-2`` and ``-1``). Use ``not x`` instead for the logical negation " +"of a Boolean. In the rare case that you need the bitwise inversion of the " +"underlying integer, convert to ``int`` explicitly (``~int(x)``)." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.16.rst:35 +#, fuzzy +msgid ":mod:`shutil`:" +msgstr ":mod:`msilib`" + +#: ../../deprecations/pending-removal-in-3.16.rst:37 +msgid "" +"The :class:`!ExecError` exception has been deprecated since Python 3.14. It " +"has not been used by any function in :mod:`!shutil` since Python 3.4, and is " +"now an alias of :exc:`RuntimeError`." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.16.rst:42 +#, fuzzy +msgid ":mod:`symtable`:" +msgstr ":mod:`sqlite3`:" + +#: ../../deprecations/pending-removal-in-3.16.rst:44 +msgid "" +"The :meth:`Class.get_methods ` method has been " +"deprecated since Python 3.14." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.16.rst:47 +#, fuzzy +msgid ":mod:`sys`:" +msgstr ":mod:`pty`:" + +#: ../../deprecations/pending-removal-in-3.16.rst:49 +msgid "" +"The :func:`~sys._enablelegacywindowsfsencoding` function has been deprecated " +"since Python 3.13. Use the :envvar:`PYTHONLEGACYWINDOWSFSENCODING` " +"environment variable instead." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.16.rst:53 +#, fuzzy +msgid ":mod:`tarfile`:" +msgstr ":mod:`datetime`:" + +#: ../../deprecations/pending-removal-in-3.16.rst:55 msgid "" -":mod:`symtable`: Deprecate :meth:`symtable.Class.get_methods` due to the " -"lack of interest. (Contributed by Bénédikt Tran in :gh:`119698`.)" +"The undocumented and unused :attr:`!TarFile.tarfile` attribute has been " +"deprecated since Python 3.13." msgstr "" -":mod:`symtable`:由於並沒有太多關注,已棄用 :meth:`symtable.Class." -"get_methods`。 (由 Bénédikt Tran 於 :gh:`119698` 貢獻。)" #: ../../deprecations/c-api-pending-removal-in-future.rst:2 #: ../../deprecations/pending-removal-in-future.rst:2 @@ -443,19 +576,11 @@ msgid "" "groups are deprecated." msgstr ":mod:`argparse`:已棄用巢狀引數群組和巢狀互斥群組。" -#: ../../deprecations/pending-removal-in-future.rst:10 -msgid ":mod:`array`'s ``'u'`` format code (:gh:`57281`)" -msgstr ":mod:`array` 的 ``'u'`` 格式碼 (:gh:`57281`)" - #: ../../deprecations/pending-removal-in-future.rst:12 -msgid ":mod:`builtins`:" -msgstr ":mod:`builtins`:" - -#: ../../deprecations/pending-removal-in-future.rst:14 msgid "``bool(NotImplemented)``." msgstr "``bool(NotImplemented)``。" -#: ../../deprecations/pending-removal-in-future.rst:15 +#: ../../deprecations/pending-removal-in-future.rst:13 msgid "" "Generators: ``throw(type, exc, tb)`` and ``athrow(type, exc, tb)`` signature " "is deprecated: use ``throw(exc)`` and ``athrow(exc)`` instead, the single " @@ -464,7 +589,7 @@ msgstr "" "產生器:``throw(type, exc, tb)`` 和 ``athrow(type, exc, tb)`` 簽名已被棄用:" "請改用 ``throw(exc)`` 和 ``athrow(exc)``,為單引數簽名。" -#: ../../deprecations/pending-removal-in-future.rst:18 +#: ../../deprecations/pending-removal-in-future.rst:16 msgid "" "Currently Python accepts numeric literals immediately followed by keywords, " "for example ``0in x``, ``1or x``, ``0if 1else 2``. It allows confusing and " @@ -482,7 +607,7 @@ msgstr "" "`in`、:keyword:`is` 和 :keyword:`or` 之一的關鍵字,則會引發語法警告。在未來版" "本中,它將被更改為語法錯誤。(:gh:`87999`)" -#: ../../deprecations/pending-removal-in-future.rst:26 +#: ../../deprecations/pending-removal-in-future.rst:24 msgid "" "Support for ``__index__()`` and ``__int__()`` method returning non-int type: " "these methods will be required to return an instance of a strict subclass " @@ -491,7 +616,7 @@ msgstr "" "``__index__()`` 和 ``__int__()`` 方法回傳非 int 型別的支援:這些方法將需要回" "傳 :class:`int` 的嚴格子類別實例。" -#: ../../deprecations/pending-removal-in-future.rst:29 +#: ../../deprecations/pending-removal-in-future.rst:27 msgid "" "Support for ``__float__()`` method returning a strict subclass of :class:" "`float`: these methods will be required to return an instance of :class:" @@ -500,7 +625,7 @@ msgstr "" "回傳 :class:`float` 嚴格子類別 ``__float__()`` 方法的支援:這些方法將需要回" "傳 :class:`float` 的實例。" -#: ../../deprecations/pending-removal-in-future.rst:32 +#: ../../deprecations/pending-removal-in-future.rst:30 msgid "" "Support for ``__complex__()`` method returning a strict subclass of :class:" "`complex`: these methods will be required to return an instance of :class:" @@ -509,11 +634,11 @@ msgstr "" "回傳 :class:`complex` 嚴格子類別 ``__complex__()`` 方法的支援:這些方法將需要" "回傳 :class:`complex` 的實例。" -#: ../../deprecations/pending-removal-in-future.rst:35 +#: ../../deprecations/pending-removal-in-future.rst:33 msgid "Delegation of ``int()`` to ``__trunc__()`` method." msgstr "將 ``int()`` 委派給 ``__trunc__()`` 方法。" -#: ../../deprecations/pending-removal-in-future.rst:36 +#: ../../deprecations/pending-removal-in-future.rst:34 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 " @@ -523,7 +648,7 @@ msgstr "" "在 :func:`complex` 建構子中將複數作為 *real* 或 *imag* 引數傳遞現在已被棄用;" "它應該只作為單個位置引數傳遞。 (由 Serhiy Storchaka 於 :gh:`109218` 貢獻。)" -#: ../../deprecations/pending-removal-in-future.rst:41 +#: ../../deprecations/pending-removal-in-future.rst:39 msgid "" ":mod:`calendar`: ``calendar.January`` and ``calendar.February`` constants " "are deprecated and replaced by :data:`calendar.JANUARY` and :data:`calendar." @@ -533,18 +658,18 @@ msgstr "" "被 :data:`calendar.JANUARY` 和 :data:`calendar.FEBRUARY` 取代。 (由 Prince " "Roshan 於 :gh:`103636` 貢獻。)" -#: ../../deprecations/pending-removal-in-future.rst:46 +#: ../../deprecations/pending-removal-in-future.rst:44 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:49 +#: ../../deprecations/pending-removal-in-future.rst:47 msgid ":mod:`datetime`:" msgstr ":mod:`datetime`:" -#: ../../deprecations/pending-removal-in-future.rst:51 +#: ../../deprecations/pending-removal-in-future.rst:49 msgid "" ":meth:`~datetime.datetime.utcnow`: use ``datetime.datetime.now(tz=datetime." "UTC)``." @@ -552,7 +677,7 @@ msgstr "" ":meth:`~datetime.datetime.utcnow`:請改用 ``datetime.datetime." "now(tz=datetime.UTC)``。" -#: ../../deprecations/pending-removal-in-future.rst:53 +#: ../../deprecations/pending-removal-in-future.rst:51 msgid "" ":meth:`~datetime.datetime.utcfromtimestamp`: use ``datetime.datetime." "fromtimestamp(timestamp, tz=datetime.UTC)``." @@ -560,19 +685,11 @@ msgstr "" ":meth:`~datetime.datetime.utcfromtimestamp`:請改用 ``datetime.datetime." "fromtimestamp(timestamp, tz=datetime.UTC)``。" -#: ../../deprecations/pending-removal-in-future.rst:56 +#: ../../deprecations/pending-removal-in-future.rst:54 msgid ":mod:`gettext`: Plural value must be an integer." msgstr ":mod:`gettext`:複數值必須是整數。" #: ../../deprecations/pending-removal-in-future.rst:58 -msgid ":mod:`importlib`:" -msgstr ":mod:`importlib`:" - -#: ../../deprecations/pending-removal-in-future.rst:60 -msgid "``load_module()`` method: use ``exec_module()`` instead." -msgstr "``load_module()`` method:請改用 ``exec_module()``。" - -#: ../../deprecations/pending-removal-in-future.rst:61 msgid "" ":func:`~importlib.util.cache_from_source` *debug_override* parameter is " "deprecated: use the *optimization* parameter instead." @@ -580,37 +697,37 @@ msgstr "" ":func:`~importlib.util.cache_from_source` *debug_override* 參數已被棄用:請改" "用 *optimization* 參數。" -#: ../../deprecations/pending-removal-in-future.rst:64 +#: ../../deprecations/pending-removal-in-future.rst:61 msgid ":mod:`importlib.metadata`:" msgstr ":mod:`importlib.metadata`:" -#: ../../deprecations/pending-removal-in-future.rst:66 +#: ../../deprecations/pending-removal-in-future.rst:63 msgid "``EntryPoints`` tuple interface." msgstr "``EntryPoints`` 元組介面。" -#: ../../deprecations/pending-removal-in-future.rst:67 +#: ../../deprecations/pending-removal-in-future.rst:64 msgid "Implicit ``None`` on return values." msgstr "回傳值上的隱式 ``None``。" -#: ../../deprecations/pending-removal-in-future.rst:69 +#: ../../deprecations/pending-removal-in-future.rst:66 msgid "" ":mod:`logging`: the ``warn()`` method has been deprecated since Python 3.3, " "use :meth:`~logging.warning` instead." msgstr "" -#: ../../deprecations/pending-removal-in-future.rst:72 +#: ../../deprecations/pending-removal-in-future.rst:69 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:75 +#: ../../deprecations/pending-removal-in-future.rst:72 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:77 +#: ../../deprecations/pending-removal-in-future.rst:74 msgid "" ":class:`!pydoc.ErrorDuringImport`: A tuple value for *exc_info* parameter is " "deprecated, use an exception instance." @@ -618,7 +735,7 @@ msgstr "" ":class:`!pydoc.ErrorDuringImport`:*exc_info* 參數的元組值已被棄用,請用例外" "實例。" -#: ../../deprecations/pending-removal-in-future.rst:80 +#: ../../deprecations/pending-removal-in-future.rst:77 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 " @@ -630,12 +747,12 @@ msgstr "" "有 ASCII 數碼序列被接受作為數值參照。位元組模式和替換字串中的群組名稱現在只能" "包含 ASCII 字母、數碼和底線。(由 Serhiy Storchaka 於 :gh:`91760` 貢獻。)" -#: ../../deprecations/pending-removal-in-future.rst:87 +#: ../../deprecations/pending-removal-in-future.rst:84 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:89 +#: ../../deprecations/pending-removal-in-future.rst:86 msgid "" ":mod:`shutil`: :func:`~shutil.rmtree`'s *onerror* parameter is deprecated in " "Python 3.12; use the *onexc* parameter instead." @@ -643,15 +760,15 @@ msgstr "" ":mod:`shutil`::func:`~shutil.rmtree` 的 *onerror* 參數在 Python 3.12 中已被" "棄用;請改用 *onexc* 參數。" -#: ../../deprecations/pending-removal-in-future.rst:92 +#: ../../deprecations/pending-removal-in-future.rst:89 msgid ":mod:`ssl` options and protocols:" msgstr ":mod:`ssl` 選項和協定:" -#: ../../deprecations/pending-removal-in-future.rst:94 +#: ../../deprecations/pending-removal-in-future.rst:91 msgid ":class:`ssl.SSLContext` without protocol argument is deprecated." msgstr "不帶協定引數的 :class:`ssl.SSLContext` 已被棄用。" -#: ../../deprecations/pending-removal-in-future.rst:95 +#: ../../deprecations/pending-removal-in-future.rst:92 msgid "" ":class:`ssl.SSLContext`: :meth:`~ssl.SSLContext.set_npn_protocols` and :meth:" "`!selected_npn_protocol` are deprecated: use ALPN instead." @@ -659,58 +776,51 @@ msgstr "" ":class:`ssl.SSLContext`::meth:`~ssl.SSLContext.set_npn_protocols` 和 :meth:" "`!selected_npn_protocol` 已被棄用:請改用 ALPN。" -#: ../../deprecations/pending-removal-in-future.rst:98 +#: ../../deprecations/pending-removal-in-future.rst:95 msgid "``ssl.OP_NO_SSL*`` options" msgstr "``ssl.OP_NO_SSL*`` 選項" -#: ../../deprecations/pending-removal-in-future.rst:99 +#: ../../deprecations/pending-removal-in-future.rst:96 msgid "``ssl.OP_NO_TLS*`` options" msgstr "``ssl.OP_NO_TLS*`` 選項" -#: ../../deprecations/pending-removal-in-future.rst:100 +#: ../../deprecations/pending-removal-in-future.rst:97 msgid "``ssl.PROTOCOL_SSLv3``" msgstr "``ssl.PROTOCOL_SSLv3``" -#: ../../deprecations/pending-removal-in-future.rst:101 +#: ../../deprecations/pending-removal-in-future.rst:98 msgid "``ssl.PROTOCOL_TLS``" msgstr "``ssl.PROTOCOL_TLS``" -#: ../../deprecations/pending-removal-in-future.rst:102 +#: ../../deprecations/pending-removal-in-future.rst:99 msgid "``ssl.PROTOCOL_TLSv1``" msgstr "``ssl.PROTOCOL_TLSv1``" -#: ../../deprecations/pending-removal-in-future.rst:103 +#: ../../deprecations/pending-removal-in-future.rst:100 msgid "``ssl.PROTOCOL_TLSv1_1``" msgstr "``ssl.PROTOCOL_TLSv1_1``" -#: ../../deprecations/pending-removal-in-future.rst:104 +#: ../../deprecations/pending-removal-in-future.rst:101 msgid "``ssl.PROTOCOL_TLSv1_2``" msgstr "``ssl.PROTOCOL_TLSv1_2``" -#: ../../deprecations/pending-removal-in-future.rst:105 +#: ../../deprecations/pending-removal-in-future.rst:102 msgid "``ssl.TLSVersion.SSLv3``" msgstr "``ssl.TLSVersion.SSLv3``" -#: ../../deprecations/pending-removal-in-future.rst:106 +#: ../../deprecations/pending-removal-in-future.rst:103 msgid "``ssl.TLSVersion.TLSv1``" msgstr "``ssl.TLSVersion.TLSv1``" -#: ../../deprecations/pending-removal-in-future.rst:107 +#: ../../deprecations/pending-removal-in-future.rst:104 msgid "``ssl.TLSVersion.TLSv1_1``" msgstr "``ssl.TLSVersion.TLSv1_1``" -#: ../../deprecations/pending-removal-in-future.rst:109 -msgid "" -":func:`sysconfig.is_python_build` *check_home* parameter is deprecated and " -"ignored." -msgstr "" -":func:`sysconfig.is_python_build` 的 *check_home* 參數已被棄用並被忽略。" - -#: ../../deprecations/pending-removal-in-future.rst:112 +#: ../../deprecations/pending-removal-in-future.rst:106 msgid ":mod:`threading` methods:" msgstr ":mod:`threading` 方法:" -#: ../../deprecations/pending-removal-in-future.rst:114 +#: ../../deprecations/pending-removal-in-future.rst:108 msgid "" ":meth:`!threading.Condition.notifyAll`: use :meth:`~threading.Condition." "notify_all`." @@ -718,11 +828,11 @@ msgstr "" ":meth:`!threading.Condition.notifyAll`:請用 :meth:`~threading.Condition." "notify_all`。" -#: ../../deprecations/pending-removal-in-future.rst:115 +#: ../../deprecations/pending-removal-in-future.rst:109 msgid ":meth:`!threading.Event.isSet`: use :meth:`~threading.Event.is_set`." msgstr ":meth:`!threading.Event.isSet`:請用 :meth:`~threading.Event.is_set`。" -#: ../../deprecations/pending-removal-in-future.rst:116 +#: ../../deprecations/pending-removal-in-future.rst:110 msgid "" ":meth:`!threading.Thread.isDaemon`, :meth:`threading.Thread.setDaemon`: use :" "attr:`threading.Thread.daemon` attribute." @@ -730,7 +840,7 @@ msgstr "" ":meth:`!threading.Thread.isDaemon`、:meth:`threading.Thread.setDaemon`:請" "用 :attr:`threading.Thread.daemon` 屬性。" -#: ../../deprecations/pending-removal-in-future.rst:118 +#: ../../deprecations/pending-removal-in-future.rst:112 msgid "" ":meth:`!threading.Thread.getName`, :meth:`threading.Thread.setName`: use :" "attr:`threading.Thread.name` attribute." @@ -738,20 +848,20 @@ msgstr "" ":meth:`!threading.Thread.getName`、:meth:`threading.Thread.setName`:請用 :" "attr:`threading.Thread.name` 屬性。" -#: ../../deprecations/pending-removal-in-future.rst:120 +#: ../../deprecations/pending-removal-in-future.rst:114 msgid ":meth:`!threading.currentThread`: use :meth:`threading.current_thread`." msgstr "" ":meth:`!threading.currentThread`:請用 :meth:`threading.current_thread`。" -#: ../../deprecations/pending-removal-in-future.rst:121 +#: ../../deprecations/pending-removal-in-future.rst:115 msgid ":meth:`!threading.activeCount`: use :meth:`threading.active_count`." msgstr ":meth:`!threading.activeCount`:請用 :meth:`threading.active_count`。" -#: ../../deprecations/pending-removal-in-future.rst:123 +#: ../../deprecations/pending-removal-in-future.rst:117 msgid ":class:`typing.Text` (:gh:`92332`)." msgstr ":class:`typing.Text` (:gh:`92332`)。" -#: ../../deprecations/pending-removal-in-future.rst:125 +#: ../../deprecations/pending-removal-in-future.rst:119 msgid "" ":class:`unittest.IsolatedAsyncioTestCase`: it is deprecated to return a " "value that is not ``None`` from a test case." @@ -759,58 +869,58 @@ msgstr "" ":class:`unittest.IsolatedAsyncioTestCase`:從測試案例中回傳非 ``None`` 的值已" "被棄用。" -#: ../../deprecations/pending-removal-in-future.rst:128 +#: ../../deprecations/pending-removal-in-future.rst:122 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:130 +#: ../../deprecations/pending-removal-in-future.rst:124 msgid "``splitattr()``" msgstr "``splitattr()``" -#: ../../deprecations/pending-removal-in-future.rst:131 +#: ../../deprecations/pending-removal-in-future.rst:125 msgid "``splithost()``" msgstr "``splithost()``" -#: ../../deprecations/pending-removal-in-future.rst:132 +#: ../../deprecations/pending-removal-in-future.rst:126 msgid "``splitnport()``" msgstr "``splitnport()``" -#: ../../deprecations/pending-removal-in-future.rst:133 +#: ../../deprecations/pending-removal-in-future.rst:127 msgid "``splitpasswd()``" msgstr "``splitpasswd()``" -#: ../../deprecations/pending-removal-in-future.rst:134 +#: ../../deprecations/pending-removal-in-future.rst:128 msgid "``splitport()``" msgstr "``splitport()``" -#: ../../deprecations/pending-removal-in-future.rst:135 +#: ../../deprecations/pending-removal-in-future.rst:129 msgid "``splitquery()``" msgstr "``splitquery()``" -#: ../../deprecations/pending-removal-in-future.rst:136 +#: ../../deprecations/pending-removal-in-future.rst:130 msgid "``splittag()``" msgstr "``splittag()``" -#: ../../deprecations/pending-removal-in-future.rst:137 +#: ../../deprecations/pending-removal-in-future.rst:131 msgid "``splittype()``" msgstr "``splittype()``" -#: ../../deprecations/pending-removal-in-future.rst:138 +#: ../../deprecations/pending-removal-in-future.rst:132 msgid "``splituser()``" msgstr "``splituser()``" -#: ../../deprecations/pending-removal-in-future.rst:139 +#: ../../deprecations/pending-removal-in-future.rst:133 msgid "``splitvalue()``" msgstr "``splitvalue()``" -#: ../../deprecations/pending-removal-in-future.rst:140 +#: ../../deprecations/pending-removal-in-future.rst:134 msgid "``to_bytes()``" msgstr "``to_bytes()``" -#: ../../deprecations/pending-removal-in-future.rst:142 +#: ../../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. " @@ -820,13 +930,13 @@ msgstr "" "class:`~urllib.request.FancyURLopener` 風格已被棄用。請改用更新的 :func:" "`~urllib.request.urlopen` 函式和方法。" -#: ../../deprecations/pending-removal-in-future.rst:146 +#: ../../deprecations/pending-removal-in-future.rst:140 msgid "" ":mod:`wsgiref`: ``SimpleHandler.stdout.write()`` should not do partial " "writes." msgstr ":mod:`wsgiref`:``SimpleHandler.stdout.write()`` 不應該進行部分寫入。" -#: ../../deprecations/pending-removal-in-future.rst:149 +#: ../../deprecations/pending-removal-in-future.rst:143 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 " @@ -837,7 +947,7 @@ msgstr "" "Element` 的真值測試。在未來版本中,它將始終回傳 ``True``。請改用明確的 " "``len(elem)`` 或 ``elem is not None`` 測試。" -#: ../../deprecations/pending-removal-in-future.rst:154 +#: ../../deprecations/pending-removal-in-future.rst:148 msgid "" ":meth:`zipimport.zipimporter.load_module` is deprecated: use :meth:" "`~zipimport.zipimporter.exec_module` instead." @@ -871,164 +981,191 @@ msgid "" msgstr "設定 Python 初始化的函式,Python 3.11 中已被棄用:" #: ../../deprecations/c-api-pending-removal-in-3.14.rst:12 -msgid "``PySys_SetArgvEx()``: set :c:member:`PyConfig.argv` instead." +#, fuzzy +msgid ":c:func:`!PySys_SetArgvEx()`: Set :c:member:`PyConfig.argv` instead." msgstr "``PySys_SetArgvEx()``:請改以 :c:member:`PyConfig.argv` 設定。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:13 -msgid "``PySys_SetArgv()``: set :c:member:`PyConfig.argv` instead." +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:14 +#, fuzzy +msgid ":c:func:`!PySys_SetArgv()`: Set :c:member:`PyConfig.argv` instead." msgstr "``PySys_SetArgv()``:請改以 :c:member:`PyConfig.argv` 設定。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:14 -msgid "``Py_SetProgramName()``: set :c:member:`PyConfig.program_name` instead." +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:16 +#, fuzzy +msgid "" +":c:func:`!Py_SetProgramName()`: Set :c:member:`PyConfig.program_name` " +"instead." msgstr "" "``Py_SetProgramName()``:請改以 :c:member:`PyConfig.program_name` 設定。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:15 -msgid "``Py_SetPythonHome()``: set :c:member:`PyConfig.home` instead." +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:18 +#, fuzzy +msgid ":c:func:`!Py_SetPythonHome()`: Set :c:member:`PyConfig.home` instead." msgstr "``Py_SetPythonHome()``:請改以 :c:member:`PyConfig.home` 設定。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:17 -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:45 +#: ../../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:20 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:24 msgid "Global configuration variables:" msgstr "全域設定變數:" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:22 -msgid ":c:var:`Py_DebugFlag`: use :c:member:`PyConfig.parser_debug` instead." +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:26 +#, fuzzy +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:23 -msgid ":c:var:`Py_VerboseFlag`: use :c:member:`PyConfig.verbose` instead." +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:28 +#, fuzzy +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:24 -msgid ":c:var:`Py_QuietFlag`: use :c:member:`PyConfig.quiet` instead." +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:30 +#, fuzzy +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:25 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:32 +#, fuzzy msgid "" -":c:var:`Py_InteractiveFlag`: use :c:member:`PyConfig.interactive` instead." +":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:26 -msgid ":c:var:`Py_InspectFlag`: use :c:member:`PyConfig.inspect` instead." +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:34 +#, fuzzy +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:27 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:36 +#, fuzzy msgid "" -":c:var:`Py_OptimizeFlag`: use :c:member:`PyConfig.optimization_level` " +":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:28 -msgid ":c:var:`Py_NoSiteFlag`: use :c:member:`PyConfig.site_import` instead." +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:38 +#, fuzzy +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:29 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:40 +#, fuzzy msgid "" -":c:var:`Py_BytesWarningFlag`: use :c:member:`PyConfig.bytes_warning` instead." +":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:30 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:42 +#, fuzzy msgid "" -":c:var:`Py_FrozenFlag`: use :c:member:`PyConfig.pathconfig_warnings` instead." +":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:31 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:44 +#, fuzzy msgid "" -":c:var:`Py_IgnoreEnvironmentFlag`: use :c:member:`PyConfig.use_environment` " +":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:32 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:46 +#, fuzzy msgid "" -":c:var:`Py_DontWriteBytecodeFlag`: use :c:member:`PyConfig.write_bytecode` " +":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:33 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:48 +#, fuzzy msgid "" -":c:var:`Py_NoUserSiteDirectory`: use :c:member:`PyConfig." +":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:34 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:50 +#, fuzzy msgid "" -":c:var:`Py_UnbufferedStdioFlag`: use :c:member:`PyConfig.buffered_stdio` " +":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:35 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:52 +#, fuzzy msgid "" -":c:var:`Py_HashRandomizationFlag`: use :c:member:`PyConfig.use_hash_seed` " +":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:37 -msgid ":c:var:`Py_IsolatedFlag`: use :c:member:`PyConfig.isolated` instead." +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:55 +#, fuzzy +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:38 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:57 +#, fuzzy msgid "" -":c:var:`Py_LegacyWindowsFSEncodingFlag`: use :c:member:`PyPreConfig." +":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:39 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:59 +#, fuzzy msgid "" -":c:var:`Py_LegacyWindowsStdioFlag`: use :c:member:`PyConfig." +":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:40 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:61 +#, fuzzy msgid "" -":c:var:`!Py_FileSystemDefaultEncoding`: use :c:member:`PyConfig." +":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:41 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:63 +#, fuzzy msgid "" -":c:var:`!Py_HasFileSystemDefaultEncoding`: use :c:member:`PyConfig." +":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:42 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:65 +#, fuzzy msgid "" -":c:var:`!Py_FileSystemDefaultEncodeErrors`: use :c:member:`PyConfig." +":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:43 +#: ../../deprecations/c-api-pending-removal-in-3.14.rst:67 +#, fuzzy msgid "" -":c:var:`!Py_UTF8Mode`: use :c:member:`PyPreConfig.utf8_mode` instead. (see :" +":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:" @@ -1039,64 +1176,74 @@ msgid "The bundled copy of ``libmpdecimal``." msgstr "``libmpdecimal`` 的打包副本 (bundled copy)。" #: ../../deprecations/c-api-pending-removal-in-3.15.rst:5 +#, fuzzy msgid "" -":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`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:6 -msgid ":c:func:`PyWeakref_GET_OBJECT`: use :c:func:`PyWeakref_GetRef` instead." -msgstr ":c:func:`PyWeakref_GET_OBJECT`:請改用 :c:func:`PyWeakref_GetRef`。" - #: ../../deprecations/c-api-pending-removal-in-3.15.rst:7 -msgid ":c:func:`PyWeakref_GetObject`: use :c:func:`PyWeakref_GetRef` instead." -msgstr ":c:func:`PyWeakref_GetObject`:請改用 :c:func:`PyWeakref_GetRef`。" - -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:8 -msgid ":c:type:`!Py_UNICODE_WIDE` type: use :c:type:`wchar_t` instead." -msgstr ":c:type:`!Py_UNICODE_WIDE` type:請改用 :c:type:`wchar_t`。" +#, fuzzy +msgid "" +":c:func:`PyWeakref_GetObject` and :c:func:`PyWeakref_GET_OBJECT`: Use :c:" +"func:`PyWeakref_GetRef` instead." +msgstr ":c:func:`PyWeakref_GET_OBJECT`:請改用 :c:func:`PyWeakref_GetRef`。" #: ../../deprecations/c-api-pending-removal-in-3.15.rst:9 -msgid ":c:type:`Py_UNICODE` type: use :c:type:`wchar_t` instead." +#, fuzzy +msgid "" +":c:type:`Py_UNICODE` type and the :c:macro:`!Py_UNICODE_WIDE` macro: Use :c:" +"type:`wchar_t` instead." msgstr ":c:type:`Py_UNICODE` type:請改用 :c:type:`wchar_t`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:10 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:11 msgid "Python initialization functions:" msgstr "Python 初始化函式:" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:12 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:13 +#, fuzzy msgid "" -":c:func:`PySys_ResetWarnOptions`: clear :data:`sys.warnoptions` and :data:`!" +":c:func:`PySys_ResetWarnOptions`: Clear :data:`sys.warnoptions` and :data:`!" "warnings.filters` instead." msgstr "" ":c:func:`PySys_ResetWarnOptions`:請改為清除 :data:`sys.warnoptions` 和 :" "data:`!warnings.filters`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:14 -msgid ":c:func:`Py_GetExecPrefix`: get :data:`sys.exec_prefix` instead." +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:15 +#, fuzzy +msgid "" +":c:func:`Py_GetExecPrefix`: Get :data:`sys.base_exec_prefix` and :data:`sys." +"exec_prefix` instead." msgstr ":c:func:`Py_GetExecPrefix`:請改用 :data:`sys.exec_prefix`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:15 -msgid ":c:func:`Py_GetPath`: get :data:`sys.path` instead." +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:17 +#, fuzzy +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:16 -msgid ":c:func:`Py_GetPrefix`: get :data:`sys.prefix` instead." +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:19 +#, fuzzy +msgid "" +":c:func:`Py_GetPrefix`: Get :data:`sys.base_prefix` and :data:`sys.prefix` " +"instead." msgstr ":c:func:`Py_GetPrefix`:請改用 :data:`sys.prefix`。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:17 -msgid ":c:func:`Py_GetProgramFullPath`: get :data:`sys.executable` instead." +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:21 +#, fuzzy +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:18 -msgid ":c:func:`Py_GetProgramName`: get :data:`sys.executable` instead." +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:23 +#, fuzzy +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:19 +#: ../../deprecations/c-api-pending-removal-in-3.15.rst:25 +#, fuzzy msgid "" -":c:func:`Py_GetPythonHome`: get :c:member:`PyConfig.home` or the :envvar:" +":c:func:`Py_GetPythonHome`: Get :c:member:`PyConfig.home` or the :envvar:" "`PYTHONHOME` environment variable instead." msgstr "" ":c:func:`Py_GetPythonHome`:請改用 :c:member:`PyConfig.home` 或 :envvar:" @@ -1109,84 +1256,99 @@ msgid "" msgstr "下列 API 已被棄用並將會被移除,不過目前尚未訂定移除日期。" #: ../../deprecations/c-api-pending-removal-in-future.rst:7 -msgid ":c:macro:`Py_TPFLAGS_HAVE_FINALIZE`: unneeded since Python 3.8." +#, fuzzy +msgid ":c:macro:`Py_TPFLAGS_HAVE_FINALIZE`: Unneeded since Python 3.8." msgstr ":c:macro:`Py_TPFLAGS_HAVE_FINALIZE`:自 Python 3.8 起不再需要" -#: ../../deprecations/c-api-pending-removal-in-future.rst:8 -msgid ":c:func:`PyErr_Fetch`: use :c:func:`PyErr_GetRaisedException` instead." +#: ../../deprecations/c-api-pending-removal-in-future.rst:9 +#, fuzzy +msgid ":c:func:`PyErr_Fetch`: Use :c:func:`PyErr_GetRaisedException` instead." msgstr ":c:func:`PyErr_Fetch`:請改用 :c:func:`PyErr_GetRaisedException`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:9 +#: ../../deprecations/c-api-pending-removal-in-future.rst:11 +#, fuzzy msgid "" -":c:func:`PyErr_NormalizeException`: use :c:func:`PyErr_GetRaisedException` " +":c:func:`PyErr_NormalizeException`: Use :c:func:`PyErr_GetRaisedException` " "instead." msgstr "" ":c:func:`PyErr_NormalizeException`:請改用 :c:func:" "`PyErr_GetRaisedException`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:10 +#: ../../deprecations/c-api-pending-removal-in-future.rst:13 +#, fuzzy msgid "" -":c:func:`PyErr_Restore`: use :c:func:`PyErr_SetRaisedException` instead." +":c:func:`PyErr_Restore`: Use :c:func:`PyErr_SetRaisedException` instead." msgstr ":c:func:`PyErr_Restore`:請改用 :c:func:`PyErr_SetRaisedException`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:11 +#: ../../deprecations/c-api-pending-removal-in-future.rst:15 +#, fuzzy msgid "" -":c:func:`PyModule_GetFilename`: use :c:func:`PyModule_GetFilenameObject` " +":c:func:`PyModule_GetFilename`: Use :c:func:`PyModule_GetFilenameObject` " "instead." msgstr "" ":c:func:`PyModule_GetFilename`:請改用 :c:func:`PyModule_GetFilenameObject`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:12 -msgid ":c:func:`PyOS_AfterFork`: use :c:func:`PyOS_AfterFork_Child` instead." +#: ../../deprecations/c-api-pending-removal-in-future.rst:17 +#, fuzzy +msgid ":c:func:`PyOS_AfterFork`: Use :c:func:`PyOS_AfterFork_Child` instead." msgstr ":c:func:`PyOS_AfterFork`:請改用 :c:func:`PyOS_AfterFork_Child`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:13 +#: ../../deprecations/c-api-pending-removal-in-future.rst:19 +#, fuzzy msgid "" -":c:func:`PySlice_GetIndicesEx`: use :c:func:`PySlice_Unpack` and :c:func:" +":c:func:`PySlice_GetIndicesEx`: Use :c:func:`PySlice_Unpack` and :c:func:" "`PySlice_AdjustIndices` instead." msgstr "" ":c:func:`PySlice_GetIndicesEx`:請改用 :c:func:`PySlice_Unpack` 和 :c:func:" "`PySlice_AdjustIndices`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:14 +#: ../../deprecations/c-api-pending-removal-in-future.rst:21 +#, fuzzy msgid "" -":c:func:`!PyUnicode_AsDecodedObject`: use :c:func:`PyCodec_Decode` instead." +":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:15 +#: ../../deprecations/c-api-pending-removal-in-future.rst:23 +#, fuzzy msgid "" -":c:func:`!PyUnicode_AsDecodedUnicode`: use :c:func:`PyCodec_Decode` instead." +":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:16 +#: ../../deprecations/c-api-pending-removal-in-future.rst:25 +#, fuzzy msgid "" -":c:func:`!PyUnicode_AsEncodedObject`: use :c:func:`PyCodec_Encode` instead." +":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:17 +#: ../../deprecations/c-api-pending-removal-in-future.rst:27 +#, fuzzy msgid "" -":c:func:`!PyUnicode_AsEncodedUnicode`: use :c:func:`PyCodec_Encode` instead." +":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:18 -msgid ":c:func:`PyUnicode_READY`: unneeded since Python 3.12" +#: ../../deprecations/c-api-pending-removal-in-future.rst:29 +#, fuzzy +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:19 -msgid ":c:func:`!PyErr_Display`: use :c:func:`PyErr_DisplayException` instead." +#: ../../deprecations/c-api-pending-removal-in-future.rst:31 +#, fuzzy +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:20 +#: ../../deprecations/c-api-pending-removal-in-future.rst:33 +#, fuzzy msgid "" -":c:func:`!_PyErr_ChainExceptions`: use ``_PyErr_ChainExceptions1`` instead." +":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:21 +#: ../../deprecations/c-api-pending-removal-in-future.rst:35 msgid "" ":c:member:`!PyBytesObject.ob_shash` member: call :c:func:`PyObject_Hash` " "instead." @@ -1194,44 +1356,137 @@ msgstr "" ":c:member:`!PyBytesObject.ob_shash` 成員:請改為呼叫 :c:func:" "`PyObject_Hash`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:23 +#: ../../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:24 +#: ../../deprecations/c-api-pending-removal-in-future.rst:38 msgid "Thread Local Storage (TLS) API:" msgstr "執行緒局部儲存 (Thread Local Storage, TLS) API:" -#: ../../deprecations/c-api-pending-removal-in-future.rst:26 +#: ../../deprecations/c-api-pending-removal-in-future.rst:40 +#, fuzzy msgid "" -":c:func:`PyThread_create_key`: use :c:func:`PyThread_tss_alloc` instead." +":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:27 -msgid ":c:func:`PyThread_delete_key`: use :c:func:`PyThread_tss_free` instead." +#: ../../deprecations/c-api-pending-removal-in-future.rst:42 +#, fuzzy +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:28 +#: ../../deprecations/c-api-pending-removal-in-future.rst:44 +#, fuzzy msgid "" -":c:func:`PyThread_set_key_value`: use :c:func:`PyThread_tss_set` instead." +":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:29 +#: ../../deprecations/c-api-pending-removal-in-future.rst:46 +#, fuzzy msgid "" -":c:func:`PyThread_get_key_value`: use :c:func:`PyThread_tss_get` instead." +":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:30 +#: ../../deprecations/c-api-pending-removal-in-future.rst:48 +#, fuzzy msgid "" -":c:func:`PyThread_delete_key_value`: use :c:func:`PyThread_tss_delete` " +":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:31 -msgid ":c:func:`PyThread_ReInitTLS`: unneeded since Python 3.7." +#: ../../deprecations/c-api-pending-removal-in-future.rst:50 +#, fuzzy +msgid ":c:func:`PyThread_ReInitTLS`: Unneeded since Python 3.7." msgstr ":c:func:`PyThread_ReInitTLS`:自 Python 3.7 起不再需要。" +#~ msgid ":mod:`array`'s ``'u'`` format code (:gh:`57281`)" +#~ msgstr ":mod:`array` 的 ``'u'`` 格式碼 (:gh:`57281`)" + +#~ msgid "" +#~ ":func:`sysconfig.is_python_build` *check_home* parameter is deprecated " +#~ "and ignored." +#~ msgstr "" +#~ ":func:`sysconfig.is_python_build` 的 *check_home* 參數已被棄用並被忽略。" + +#~ msgid "" +#~ "date and datetime adapter, date and timestamp converter: see the :mod:" +#~ "`sqlite3` documentation for suggested replacement recipes." +#~ msgstr "" +#~ "date 和 datetime 的適配器 (adapter)、date 和 timestamp 轉換器 " +#~ "(converter):請參閱 :mod:`sqlite3` 文件以獲得建議的替代方案。" + +#~ msgid "" +#~ ":mod:`importlib`: ``__package__`` and ``__cached__`` will cease to be set " +#~ "or taken into consideration by the import system (:gh:`97879`)." +#~ msgstr "" +#~ ":mod:`importlib`:``__package__`` 和 ``__cached__`` 將不再被設定或被 " +#~ "import 系統考慮。 (:gh:`97879`)" + +#~ msgid "" +#~ ":mod:`platform`: :func:`~platform.java_ver` is deprecated and will be " +#~ "removed in 3.15. It was largely untested, had a confusing API, and was " +#~ "only useful for Jython support. (Contributed by Nikita Sobolev in :gh:" +#~ "`116349`.)" +#~ msgstr "" +#~ ":mod:`platform`::func:`~platform.java_ver` 已被棄用並將在 3.15 中移除。它" +#~ "幾乎沒有被測試過,API 令人困惑並且只對 Jython 支援有用。 (由 Nikita " +#~ "Sobolev 於 :gh:`116349` 貢獻。)" + +#~ msgid "" +#~ ":mod:`threading`: Passing any arguments to :func:`threading.RLock` is now " +#~ "deprecated. C version allows any numbers of args and kwargs, but they are " +#~ "just ignored. Python version does not allow any arguments. All arguments " +#~ "will be removed from :func:`threading.RLock` in Python 3.15. (Contributed " +#~ "by Nikita Sobolev in :gh:`102029`.)" +#~ msgstr "" +#~ ":mod:`threading`:對 :func:`threading.RLock` 傳遞任何引數現在已被棄用。C " +#~ "版本允許任意數量的引數和關鍵字引數,但它們會被忽略。Python 版本不允許任何" +#~ "引數。所有引數將在 Python 3.15 中從 :func:`threading.RLock` 中移除。 (由 " +#~ "Nikita Sobolev 於 :gh:`102029` 貢獻。)" + +#~ msgid ":class:`typing.NamedTuple`:" +#~ msgstr ":class:`typing.NamedTuple`:" + +#~ msgid "" +#~ "When using the functional syntax to create a :class:`!NamedTuple` class, " +#~ "failing to pass a value to the *fields* parameter (``NT = " +#~ "NamedTuple(\"NT\")``) is deprecated. Passing ``None`` to the *fields* " +#~ "parameter (``NT = NamedTuple(\"NT\", None)``) is also deprecated. Both " +#~ "will be disallowed in Python 3.15. To create a :class:`!NamedTuple` class " +#~ "with 0 fields, use ``class NT(NamedTuple): pass`` or ``NT = " +#~ "NamedTuple(\"NT\", [])``." +#~ msgstr "" +#~ "當使用函式語法來建立 :class:`!NamedTuple` 類別時,沒將值傳遞給 *fields* 參" +#~ "數的方式 (``NT = NamedTuple(\"NT\")``) 已被棄用,將 ``None`` 傳遞給 " +#~ "*fields* 參數(``NT = NamedTuple(\"NT\", None)``)也已被棄用。這兩者將在 " +#~ "Python 3.15 中會被禁止。要建立一個沒有欄位的 :class:`!NamedTuple` 類別,請" +#~ "使用 ``class NT(NamedTuple): pass`` 或 ``NT = NamedTuple(\"NT\", [])``。" + +#~ msgid "" +#~ ":mod:`array`: :class:`array.array` ``'u'`` type (:c:type:`wchar_t`): use " +#~ "the ``'w'`` type instead (``Py_UCS4``)." +#~ msgstr "" +#~ ":mod:`array`::class:`array.array` ``'u'`` 型別 (:c:type:`wchar_t`):請改" +#~ "用 ``'w'`` 型別 (``Py_UCS4``)。" + +#~ msgid ":mod:`builtins`: ``~bool``, bitwise inversion on bool." +#~ msgstr ":mod:`builtins`:``~bool``,對 bool 進行位元反轉。" + +#~ msgid "" +#~ ":mod:`symtable`: Deprecate :meth:`symtable.Class.get_methods` due to the " +#~ "lack of interest. (Contributed by Bénédikt Tran in :gh:`119698`.)" +#~ msgstr "" +#~ ":mod:`symtable`:由於並沒有太多關注,已棄用 :meth:`symtable.Class." +#~ "get_methods`。 (由 Bénédikt Tran 於 :gh:`119698` 貢獻。)" + +#~ msgid "" +#~ ":c:func:`PyWeakref_GetObject`: use :c:func:`PyWeakref_GetRef` instead." +#~ msgstr ":c:func:`PyWeakref_GetObject`:請改用 :c:func:`PyWeakref_GetRef`。" + +#~ msgid ":c:type:`!Py_UNICODE_WIDE` type: use :c:type:`wchar_t` instead." +#~ msgstr ":c:type:`!Py_UNICODE_WIDE` type:請改用 :c:type:`wchar_t`。" + #~ msgid "Pending Removal in Python 3.13" #~ msgstr "Python 3.13 中待移除的項目" @@ -1262,9 +1517,6 @@ msgstr ":c:func:`PyThread_ReInitTLS`:自 Python 3.7 起不再需要。" #~ msgid ":mod:`mailcap`" #~ msgstr ":mod:`mailcap`" -#~ msgid ":mod:`msilib`" -#~ msgstr ":mod:`msilib`" - #~ msgid ":mod:`nis`" #~ msgstr ":mod:`nis`" diff --git a/deprecations/pending-removal-in-3.14.po b/deprecations/pending-removal-in-3.14.po index 2b0e1acbc9..e6ff4172f6 100644 --- a/deprecations/pending-removal-in-3.14.po +++ b/deprecations/pending-removal-in-3.14.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-08-17 00:03+0000\n" +"POT-Creation-Date: 2024-11-20 09:21+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -126,46 +126,38 @@ msgstr "" "Alan Williams 於 :gh:`72346` 貢獻。)" #: ../../deprecations/pending-removal-in-3.14.rst:50 -msgid "" -":mod:`importlib`: ``__package__`` and ``__cached__`` will cease to be set or " -"taken into consideration by the import system (:gh:`97879`)." -msgstr "" -":mod:`importlib`:``__package__`` 和 ``__cached__`` 將不再被設定或被 import " -"系統考慮。 (:gh:`97879`)" - -#: ../../deprecations/pending-removal-in-3.14.rst:53 msgid ":mod:`importlib.abc` deprecated classes:" msgstr ":mod:`importlib.abc` 的已棄用類別:" -#: ../../deprecations/pending-removal-in-3.14.rst:55 +#: ../../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:56 +#: ../../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:57 +#: ../../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:59 +#: ../../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:61 +#: ../../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:62 +#: ../../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:64 +#: ../../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:66 +#: ../../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 " @@ -176,7 +168,7 @@ msgstr "" "deepcopy 和 pickle 操作支援。將在 3.14 中移除以大幅減少程式碼量和維護負擔。 " "(由 Raymond Hettinger 於 :gh:`101588` 貢獻。)" -#: ../../deprecations/pending-removal-in-3.14.rst:72 +#: ../../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 " @@ -193,7 +185,7 @@ msgstr "" "API 來明確指定你的程式碼何時\\ *需要* ``'fork'``。請參閱 :ref:" "`multiprocessing-start-methods`。" -#: ../../deprecations/pending-removal-in-3.14.rst:80 +#: ../../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." @@ -201,7 +193,7 @@ msgstr "" ":mod:`pathlib`:已棄用 :meth:`~pathlib.PurePath.is_relative_to` 和 :meth:" "`~pathlib.PurePath.relative_to`:額外引數的傳遞已被棄用。" -#: ../../deprecations/pending-removal-in-3.14.rst:84 +#: ../../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` " @@ -211,27 +203,27 @@ msgstr "" "現在會引發 :exc:`DeprecationWarning`;請改用 :func:`importlib.util." "find_spec`。 (由 Nikita Sobolev 於 :gh:`97850` 貢獻。)" -#: ../../deprecations/pending-removal-in-3.14.rst:89 +#: ../../deprecations/pending-removal-in-3.14.rst:86 msgid ":mod:`pty`:" msgstr ":mod:`pty`:" -#: ../../deprecations/pending-removal-in-3.14.rst:91 +#: ../../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:92 +#: ../../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:94 +#: ../../deprecations/pending-removal-in-3.14.rst:91 msgid ":mod:`sqlite3`:" msgstr ":mod:`sqlite3`:" -#: ../../deprecations/pending-removal-in-3.14.rst:96 +#: ../../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:98 +#: ../../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 " @@ -241,27 +233,7 @@ msgstr "" "使用 :ref:`named placeholders ` 且 *parameters* 是序列" "而不是 :class:`dict`。" -#: ../../deprecations/pending-removal-in-3.14.rst:102 -msgid "" -"date and datetime adapter, date and timestamp converter: see the :mod:" -"`sqlite3` documentation for suggested replacement recipes." -msgstr "" -"date 和 datetime 的適配器 (adapter)、date 和 timestamp 轉換器 (converter):請" -"參閱 :mod:`sqlite3` 文件以獲得建議的替代方案。" - -#: ../../deprecations/pending-removal-in-3.14.rst:105 -msgid "" -":class:`types.CodeType`: Accessing :attr:`~codeobject.co_lnotab` was " -"deprecated in :pep:`626` since 3.10 and was planned to be removed in 3.12, " -"but it only got a proper :exc:`DeprecationWarning` in 3.12. May be removed " -"in 3.14. (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.14 中移除。(由 Nikita Sobolev 於 :gh:" -"`101866` 貢獻。)" - -#: ../../deprecations/pending-removal-in-3.14.rst:112 +#: ../../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." @@ -269,7 +241,7 @@ msgstr "" ":mod:`typing`:自 Python 3.9 起已被棄用的 :class:`~typing.ByteString` 現在在" "使用時會發出 :exc:`DeprecationWarning`。" -#: ../../deprecations/pending-removal-in-3.14.rst:115 +#: ../../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:" @@ -277,3 +249,28 @@ msgid "" msgstr "" ":mod:`urllib`::class:`!urllib.parse.Quoter` 已被棄用:它並非預期的公開 API。" "(由 Gregory P. Smith 於 :gh:`88168` 貢獻。)" + +#~ msgid "" +#~ "date and datetime adapter, date and timestamp converter: see the :mod:" +#~ "`sqlite3` documentation for suggested replacement recipes." +#~ msgstr "" +#~ "date 和 datetime 的適配器 (adapter)、date 和 timestamp 轉換器 " +#~ "(converter):請參閱 :mod:`sqlite3` 文件以獲得建議的替代方案。" + +#~ msgid "" +#~ ":class:`types.CodeType`: Accessing :attr:`~codeobject.co_lnotab` was " +#~ "deprecated in :pep:`626` since 3.10 and was planned to be removed in " +#~ "3.12, but it only got a proper :exc:`DeprecationWarning` in 3.12. May be " +#~ "removed in 3.14. (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.14 中移除。(由 Nikita Sobolev 於 :gh:" +#~ "`101866` 貢獻。)" + +#~ msgid "" +#~ ":mod:`importlib`: ``__package__`` and ``__cached__`` will cease to be set " +#~ "or taken into consideration by the import system (:gh:`97879`)." +#~ msgstr "" +#~ ":mod:`importlib`:``__package__`` 和 ``__cached__`` 將不再被設定或被 " +#~ "import 系統考慮。 (:gh:`97879`)" diff --git a/deprecations/pending-removal-in-3.15.po b/deprecations/pending-removal-in-3.15.po index b2019d1972..af424714af 100644 --- a/deprecations/pending-removal-in-3.15.po +++ b/deprecations/pending-removal-in-3.15.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-05-11 14:27+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -21,100 +21,165 @@ msgid "Pending Removal in Python 3.15" msgstr "Python 3.15 中待移除的項目" #: ../../deprecations/pending-removal-in-3.15.rst:4 +msgid "The import system:" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.15.rst:6 +msgid "" +"Setting :attr:`~module.__cached__` on a module while failing to set :attr:" +"`__spec__.cached ` is deprecated. In " +"Python 3.15, :attr:`!__cached__` will cease to be set or take into " +"consideration by the import system or standard library. (:gh:`97879`)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.15.rst:11 +msgid "" +"Setting :attr:`~module.__package__` on a module while failing to set :attr:" +"`__spec__.parent ` is deprecated. In " +"Python 3.15, :attr:`!__package__` will cease to be set or take into " +"consideration by the import system or standard library. (:gh:`97879`)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.15.rst:16 +msgid ":mod:`ctypes`:" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.15.rst:18 +msgid "" +"The undocumented :func:`!ctypes.SetPointerType` function has been deprecated " +"since Python 3.13." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.15.rst:21 +msgid ":mod:`http.server`:" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.15.rst:23 +#, fuzzy msgid "" -":class:`http.server.CGIHTTPRequestHandler` will be removed along with its " -"related ``--cgi`` flag to ``python -m http.server``. It was obsolete and " -"rarely used. No direct replacement exists. *Anything* is better than CGI " -"to interface a web server with a request handler." +"The obsolete and rarely used :class:`~http.server.CGIHTTPRequestHandler` has " +"been deprecated since Python 3.13. No direct replacement exists. *Anything* " +"is better than CGI to interface a web server with a request handler." msgstr "" ":class:`http.server.CGIHTTPRequestHandler` 將會被移除,連同其相關的 ``--" "cgi`` 旗標到 ``python -m http.server``。它已經過時且很少被使用。沒有直接的替" "代方案。*任何東西*\\ 都比 CGI 更好的來介接一個帶有請求處理器的網頁伺服器。" -#: ../../deprecations/pending-removal-in-3.15.rst:9 +#: ../../deprecations/pending-removal-in-3.15.rst:29 +msgid "" +"The :option:`!--cgi` flag to the :program:`python -m http.server` command-" +"line interface has been deprecated since Python 3.13." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.15.rst:32 +msgid ":mod:`importlib`:" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.15.rst:34 +msgid "``load_module()`` method: use ``exec_module()`` instead." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.15.rst:36 +#, fuzzy +msgid ":class:`locale`:" +msgstr ":class:`typing.NamedTuple`:" + +#: ../../deprecations/pending-removal-in-3.15.rst:38 +#, fuzzy msgid "" -":class:`locale`: :func:`locale.getdefaultlocale` was deprecated in Python " -"3.11 and originally planned for removal in Python 3.13 (:gh:`90817`), but " -"removal has been postponed to Python 3.15. Use :func:`locale.setlocale`, :" -"func:`locale.getencoding` and :func:`locale.getlocale` instead. (Contributed " -"by Hugo van Kemenade in :gh:`111187`.)" +"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`.)" msgstr "" ":class:`locale`::func:`locale.getdefaultlocale` 已在 Python 3.11 中被棄用," "原本計劃在 Python 3.13 中移除 (:gh:`90817`),但被延後至 Python 3.15。請改用 :" "func:`locale.setlocale`、:func:`locale.getencoding` 和 :func:`locale." "getlocale`。 (由 Hugo van Kemenade 於 :gh:`111187` 貢獻。)" -#: ../../deprecations/pending-removal-in-3.15.rst:16 +#: ../../deprecations/pending-removal-in-3.15.rst:46 +msgid ":mod:`pathlib`:" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.15.rst:48 +#, fuzzy msgid "" -":mod:`pathlib`: :meth:`pathlib.PurePath.is_reserved` is deprecated and " -"scheduled for removal in Python 3.15. 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 "" ":mod:`pathlib`::meth:`pathlib.PurePath.is_reserved` 已被棄用並計劃在 Python " "3.15 中移除。請用 :func:`os.path.isreserved` 來偵測 Windows 上的保留路徑。" -#: ../../deprecations/pending-removal-in-3.15.rst:21 +#: ../../deprecations/pending-removal-in-3.15.rst:52 +msgid ":mod:`platform`:" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.15.rst:54 msgid "" -":mod:`platform`: :func:`~platform.java_ver` is deprecated and will be " -"removed in 3.15. It was largely untested, had a confusing API, and was only " -"useful for Jython support. (Contributed by Nikita Sobolev in :gh:`116349`.)" +":func:`~platform.java_ver` has been deprecated since Python 3.13. This " +"function is only useful for Jython support, has a confusing API, and is " +"largely untested." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.15.rst:58 +msgid ":mod:`sysconfig`:" msgstr "" -":mod:`platform`::func:`~platform.java_ver` 已被棄用並將在 3.15 中移除。它幾" -"乎沒有被測試過,API 令人困惑並且只對 Jython 支援有用。 (由 Nikita Sobolev " -"於 :gh:`116349` 貢獻。)" -#: ../../deprecations/pending-removal-in-3.15.rst:27 +#: ../../deprecations/pending-removal-in-3.15.rst:60 msgid "" -":mod:`threading`: Passing any arguments to :func:`threading.RLock` is now " -"deprecated. C version allows any numbers of args and kwargs, but they are " -"just ignored. Python version does not allow any arguments. All arguments " -"will be removed from :func:`threading.RLock` in Python 3.15. (Contributed by " -"Nikita Sobolev in :gh:`102029`.)" +"The *check_home* argument of :func:`sysconfig.is_python_build` has been " +"deprecated since Python 3.12." msgstr "" -":mod:`threading`:對 :func:`threading.RLock` 傳遞任何引數現在已被棄用。C 版本" -"允許任意數量的引數和關鍵字引數,但它們會被忽略。Python 版本不允許任何引數。所" -"有引數將在 Python 3.15 中從 :func:`threading.RLock` 中移除。 (由 Nikita " -"Sobolev 於 :gh:`102029` 貢獻。)" -#: ../../deprecations/pending-removal-in-3.15.rst:34 -msgid ":class:`typing.NamedTuple`:" -msgstr ":class:`typing.NamedTuple`:" +#: ../../deprecations/pending-removal-in-3.15.rst:63 +msgid ":mod:`threading`:" +msgstr "" -#: ../../deprecations/pending-removal-in-3.15.rst:36 +#: ../../deprecations/pending-removal-in-3.15.rst:65 msgid "" -"The undocumented keyword argument syntax for creating :class:`!NamedTuple` " -"classes (``NT = NamedTuple(\"NT\", x=int)``) is deprecated, and will be " -"disallowed in 3.15. Use the class-based syntax or the functional syntax " -"instead." +":func:`~threading.RLock` will take no arguments in Python 3.15. Passing any " +"arguments has been deprecated since Python 3.14, as the Python version does " +"not permit any arguments, but the C version allows any number of positional " +"or keyword arguments, ignoring every argument." msgstr "" -"用於建立 :class:`!NamedTuple` 類別的未以文件記錄之關鍵字引數語法 (``NT = " -"NamedTuple(\"NT\", x=int)``) 已棄用,並將在 3.15 中被禁止。請改用基於類別的語" -"法或函式語法 (functional syntax)。" -#: ../../deprecations/pending-removal-in-3.15.rst:40 +#: ../../deprecations/pending-removal-in-3.15.rst:71 +msgid ":mod:`types`:" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.15.rst:73 msgid "" -"When using the functional syntax to create a :class:`!NamedTuple` class, " -"failing to pass a value to the *fields* parameter (``NT = " -"NamedTuple(\"NT\")``) is deprecated. Passing ``None`` to the *fields* " -"parameter (``NT = NamedTuple(\"NT\", None)``) is also deprecated. Both will " -"be disallowed in Python 3.15. To create a :class:`!NamedTuple` class with 0 " -"fields, use ``class NT(NamedTuple): pass`` or ``NT = NamedTuple(\"NT\", " -"[])``." +":class:`types.CodeType`: Accessing :attr:`~codeobject.co_lnotab` was " +"deprecated in :pep:`626` since 3.10 and was planned to be removed in 3.12, " +"but it only got a proper :exc:`DeprecationWarning` in 3.12. May be removed " +"in 3.15. (Contributed by Nikita Sobolev in :gh:`101866`.)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.15.rst:80 +msgid ":mod:`typing`:" msgstr "" -"當使用函式語法來建立 :class:`!NamedTuple` 類別時,沒將值傳遞給 *fields* 參數" -"的方式 (``NT = NamedTuple(\"NT\")``) 已被棄用,將 ``None`` 傳遞給 *fields* 參" -"數(``NT = NamedTuple(\"NT\", None)``)也已被棄用。這兩者將在 Python 3.15 中" -"會被禁止。要建立一個沒有欄位的 :class:`!NamedTuple` 類別,請使用 ``class " -"NT(NamedTuple): pass`` 或 ``NT = NamedTuple(\"NT\", [])``。" -#: ../../deprecations/pending-removal-in-3.15.rst:47 +#: ../../deprecations/pending-removal-in-3.15.rst:82 +#, fuzzy msgid "" -":class:`typing.TypedDict`: When using the functional syntax to create a :" -"class:`!TypedDict` class, failing to pass a value to the *fields* parameter " -"(``TD = TypedDict(\"TD\")``) is deprecated. Passing ``None`` to the *fields* " -"parameter (``TD = TypedDict(\"TD\", None)``) is also deprecated. Both will " -"be disallowed in Python 3.15. To create a :class:`!TypedDict` class with 0 " -"fields, use ``class TD(TypedDict): pass`` or ``TD = TypedDict(\"TD\", {})``." +"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." +msgstr "" +"用於建立 :class:`!NamedTuple` 類別的未以文件記錄之關鍵字引數語法 (``NT = " +"NamedTuple(\"NT\", x=int)``) 已棄用,並將在 3.15 中被禁止。請改用基於類別的語" +"法或函式語法 (functional syntax)。" + +#: ../../deprecations/pending-removal-in-3.15.rst:88 +#, fuzzy +msgid "" +"When using the functional syntax of :class:`~typing.TypedDict`\\s, failing " +"to pass a value to the *fields* parameter (``TD = TypedDict(\"TD\")``) or " +"passing ``None`` (``TD = TypedDict(\"TD\", None)``) has been deprecated " +"since Python 3.13. Use ``class TD(TypedDict): pass`` or ``TD = " +"TypedDict(\"TD\", {})`` to create a TypedDict with zero field." msgstr "" ":class:`typing.TypedDict`:當使用函式語法來建立 :class:`!TypedDict` 類別時," "沒將值傳遞給 *fields* 參數的方式(``TD = TypedDict(\"TD\")``)已被棄用,將 " @@ -123,13 +188,61 @@ msgstr "" "類別,請使用 ``class TD(TypedDict): pass`` 或 ``TD = TypedDict(\"TD\", " "{})``。" -#: ../../deprecations/pending-removal-in-3.15.rst:54 +#: ../../deprecations/pending-removal-in-3.15.rst:95 msgid "" -":mod:`wave`: Deprecate the ``getmark()``, ``setmark()`` and ``getmarkers()`` " -"methods of the :class:`wave.Wave_read` and :class:`wave.Wave_write` classes. " -"They will be removed in Python 3.15. (Contributed by Victor Stinner in :gh:" -"`105096`.)" +"The :func:`typing.no_type_check_decorator` decorator function has been " +"deprecated since Python 3.13. After eight years in the :mod:`typing` module, " +"it has yet to be supported by any major type checker." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.15.rst:100 +msgid ":mod:`wave`:" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.15.rst:102 +#, fuzzy +msgid "" +"The :meth:`~wave.Wave_read.getmark`, :meth:`!setmark`, and :meth:`~wave." +"Wave_read.getmarkers` methods of the :class:`~wave.Wave_read` and :class:" +"`~wave.Wave_write` classes have been deprecated since Python 3.13." msgstr "" ":mod:`wave`:已棄用 :class:`wave.Wave_read` 和 :class:`wave.Wave_write` 類別" "的 ``getmark()``、``setmark()`` 和 ``getmarkers()`` 方法。它們將在 Python " "3.15 中被移除。 (由 Victor Stinner 於 :gh:`105096` 貢獻。)" + +#~ msgid "" +#~ ":mod:`platform`: :func:`~platform.java_ver` is deprecated and will be " +#~ "removed in 3.15. It was largely untested, had a confusing API, and was " +#~ "only useful for Jython support. (Contributed by Nikita Sobolev in :gh:" +#~ "`116349`.)" +#~ msgstr "" +#~ ":mod:`platform`::func:`~platform.java_ver` 已被棄用並將在 3.15 中移除。它" +#~ "幾乎沒有被測試過,API 令人困惑並且只對 Jython 支援有用。 (由 Nikita " +#~ "Sobolev 於 :gh:`116349` 貢獻。)" + +#~ msgid "" +#~ ":mod:`threading`: Passing any arguments to :func:`threading.RLock` is now " +#~ "deprecated. C version allows any numbers of args and kwargs, but they are " +#~ "just ignored. Python version does not allow any arguments. All arguments " +#~ "will be removed from :func:`threading.RLock` in Python 3.15. (Contributed " +#~ "by Nikita Sobolev in :gh:`102029`.)" +#~ msgstr "" +#~ ":mod:`threading`:對 :func:`threading.RLock` 傳遞任何引數現在已被棄用。C " +#~ "版本允許任意數量的引數和關鍵字引數,但它們會被忽略。Python 版本不允許任何" +#~ "引數。所有引數將在 Python 3.15 中從 :func:`threading.RLock` 中移除。 (由 " +#~ "Nikita Sobolev 於 :gh:`102029` 貢獻。)" + +#~ msgid "" +#~ "When using the functional syntax to create a :class:`!NamedTuple` class, " +#~ "failing to pass a value to the *fields* parameter (``NT = " +#~ "NamedTuple(\"NT\")``) is deprecated. Passing ``None`` to the *fields* " +#~ "parameter (``NT = NamedTuple(\"NT\", None)``) is also deprecated. Both " +#~ "will be disallowed in Python 3.15. To create a :class:`!NamedTuple` class " +#~ "with 0 fields, use ``class NT(NamedTuple): pass`` or ``NT = " +#~ "NamedTuple(\"NT\", [])``." +#~ msgstr "" +#~ "當使用函式語法來建立 :class:`!NamedTuple` 類別時,沒將值傳遞給 *fields* 參" +#~ "數的方式 (``NT = NamedTuple(\"NT\")``) 已被棄用,將 ``None`` 傳遞給 " +#~ "*fields* 參數(``NT = NamedTuple(\"NT\", None)``)也已被棄用。這兩者將在 " +#~ "Python 3.15 中會被禁止。要建立一個沒有欄位的 :class:`!NamedTuple` 類別,請" +#~ "使用 ``class NT(NamedTuple): pass`` 或 ``NT = NamedTuple(\"NT\", [])``。" diff --git a/deprecations/pending-removal-in-3.16.po b/deprecations/pending-removal-in-3.16.po index 184a9c07c8..9219dffea2 100644 --- a/deprecations/pending-removal-in-3.16.po +++ b/deprecations/pending-removal-in-3.16.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-08-26 00:03+0000\n" +"POT-Creation-Date: 2024-11-20 09:21+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -16,25 +16,112 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" #: ../../deprecations/pending-removal-in-3.16.rst:2 -msgid "Pending Removal in Python 3.16" +#, fuzzy +msgid "Pending removal in Python 3.16" msgstr "Python 3.16 中待移除的項目" #: ../../deprecations/pending-removal-in-3.16.rst:4 -msgid "" -":mod:`array`: :class:`array.array` ``'u'`` type (:c:type:`wchar_t`): use the " -"``'w'`` type instead (``Py_UCS4``)." +msgid "The import system:" msgstr "" -":mod:`array`::class:`array.array` ``'u'`` 型別 (:c:type:`wchar_t`):請改用 " -"``'w'`` 型別 (``Py_UCS4``)。" -#: ../../deprecations/pending-removal-in-3.16.rst:8 -msgid ":mod:`builtins`: ``~bool``, bitwise inversion on bool." -msgstr ":mod:`builtins`:``~bool``,對 bool 進行位元反轉。" +#: ../../deprecations/pending-removal-in-3.16.rst:6 +msgid "" +"Setting :attr:`~module.__loader__` on a module while failing to set :attr:" +"`__spec__.loader ` is deprecated. In " +"Python 3.16, :attr:`!__loader__` will cease to be set or taken into " +"consideration by the import system or the standard library." +msgstr "" #: ../../deprecations/pending-removal-in-3.16.rst:11 +msgid ":mod:`array`:" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.16.rst:13 +msgid "" +"The ``'u'`` format code (:c:type:`wchar_t`) has been deprecated in " +"documentation since Python 3.3 and at runtime since Python 3.13. Use the " +"``'w'`` format code (:c:type:`Py_UCS4`) for Unicode characters instead." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.16.rst:19 +msgid ":mod:`asyncio`:" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.16.rst:21 +msgid "" +":func:`!asyncio.iscoroutinefunction` is deprecated and will be removed in " +"Python 3.16, use :func:`inspect.iscoroutinefunction` instead. (Contributed " +"by Jiahao Li and Kumar Aditya in :gh:`122875`.)" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.16.rst:26 +msgid ":mod:`builtins`:" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.16.rst:28 +msgid "" +"Bitwise inversion on boolean types, ``~True`` or ``~False`` has been " +"deprecated since Python 3.12, as it produces surprising and unintuitive " +"results (``-2`` and ``-1``). Use ``not x`` instead for the logical negation " +"of a Boolean. In the rare case that you need the bitwise inversion of the " +"underlying integer, convert to ``int`` explicitly (``~int(x)``)." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.16.rst:35 +msgid ":mod:`shutil`:" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.16.rst:37 +msgid "" +"The :class:`!ExecError` exception has been deprecated since Python 3.14. It " +"has not been used by any function in :mod:`!shutil` since Python 3.4, and is " +"now an alias of :exc:`RuntimeError`." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.16.rst:42 +msgid ":mod:`symtable`:" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.16.rst:44 msgid "" -":mod:`symtable`: Deprecate :meth:`symtable.Class.get_methods` due to the " -"lack of interest. (Contributed by Bénédikt Tran in :gh:`119698`.)" +"The :meth:`Class.get_methods ` method has been " +"deprecated since Python 3.14." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.16.rst:47 +msgid ":mod:`sys`:" msgstr "" -":mod:`symtable`:由於並沒有太多關注,已棄用 :meth:`symtable.Class." -"get_methods`。 (由 Bénédikt Tran 於 :gh:`119698` 貢獻。)" + +#: ../../deprecations/pending-removal-in-3.16.rst:49 +msgid "" +"The :func:`~sys._enablelegacywindowsfsencoding` function has been deprecated " +"since Python 3.13. Use the :envvar:`PYTHONLEGACYWINDOWSFSENCODING` " +"environment variable instead." +msgstr "" + +#: ../../deprecations/pending-removal-in-3.16.rst:53 +msgid ":mod:`tarfile`:" +msgstr "" + +#: ../../deprecations/pending-removal-in-3.16.rst:55 +msgid "" +"The undocumented and unused :attr:`!TarFile.tarfile` attribute has been " +"deprecated since Python 3.13." +msgstr "" + +#~ msgid "" +#~ ":mod:`array`: :class:`array.array` ``'u'`` type (:c:type:`wchar_t`): use " +#~ "the ``'w'`` type instead (``Py_UCS4``)." +#~ msgstr "" +#~ ":mod:`array`::class:`array.array` ``'u'`` 型別 (:c:type:`wchar_t`):請改" +#~ "用 ``'w'`` 型別 (``Py_UCS4``)。" + +#~ msgid ":mod:`builtins`: ``~bool``, bitwise inversion on bool." +#~ msgstr ":mod:`builtins`:``~bool``,對 bool 進行位元反轉。" + +#~ msgid "" +#~ ":mod:`symtable`: Deprecate :meth:`symtable.Class.get_methods` due to the " +#~ "lack of interest. (Contributed by Bénédikt Tran in :gh:`119698`.)" +#~ msgstr "" +#~ ":mod:`symtable`:由於並沒有太多關注,已棄用 :meth:`symtable.Class." +#~ "get_methods`。 (由 Bénédikt Tran 於 :gh:`119698` 貢獻。)" diff --git a/deprecations/pending-removal-in-future.po b/deprecations/pending-removal-in-future.po index c46ed6f7d3..822ed65af5 100644 --- a/deprecations/pending-removal-in-future.po +++ b/deprecations/pending-removal-in-future.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-05-04 20:08+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -32,18 +32,14 @@ msgid "" msgstr ":mod:`argparse`:已棄用巢狀引數群組和巢狀互斥群組。" #: ../../deprecations/pending-removal-in-future.rst:10 -msgid ":mod:`array`'s ``'u'`` format code (:gh:`57281`)" -msgstr ":mod:`array` 的 ``'u'`` 格式碼 (:gh:`57281`)" - -#: ../../deprecations/pending-removal-in-future.rst:12 msgid ":mod:`builtins`:" msgstr ":mod:`builtins`:" -#: ../../deprecations/pending-removal-in-future.rst:14 +#: ../../deprecations/pending-removal-in-future.rst:12 msgid "``bool(NotImplemented)``." msgstr "``bool(NotImplemented)``。" -#: ../../deprecations/pending-removal-in-future.rst:15 +#: ../../deprecations/pending-removal-in-future.rst:13 msgid "" "Generators: ``throw(type, exc, tb)`` and ``athrow(type, exc, tb)`` signature " "is deprecated: use ``throw(exc)`` and ``athrow(exc)`` instead, the single " @@ -52,7 +48,7 @@ msgstr "" "產生器:``throw(type, exc, tb)`` 和 ``athrow(type, exc, tb)`` 簽名已被棄用:" "請改用 ``throw(exc)`` 和 ``athrow(exc)``,為單引數簽名。" -#: ../../deprecations/pending-removal-in-future.rst:18 +#: ../../deprecations/pending-removal-in-future.rst:16 msgid "" "Currently Python accepts numeric literals immediately followed by keywords, " "for example ``0in x``, ``1or x``, ``0if 1else 2``. It allows confusing and " @@ -70,7 +66,7 @@ msgstr "" "`in`、:keyword:`is` 和 :keyword:`or` 之一的關鍵字,則會引發語法警告。在未來版" "本中,它將被更改為語法錯誤。(:gh:`87999`)" -#: ../../deprecations/pending-removal-in-future.rst:26 +#: ../../deprecations/pending-removal-in-future.rst:24 msgid "" "Support for ``__index__()`` and ``__int__()`` method returning non-int type: " "these methods will be required to return an instance of a strict subclass " @@ -79,7 +75,7 @@ msgstr "" "``__index__()`` 和 ``__int__()`` 方法回傳非 int 型別的支援:這些方法將需要回" "傳 :class:`int` 的嚴格子類別實例。" -#: ../../deprecations/pending-removal-in-future.rst:29 +#: ../../deprecations/pending-removal-in-future.rst:27 msgid "" "Support for ``__float__()`` method returning a strict subclass of :class:" "`float`: these methods will be required to return an instance of :class:" @@ -88,7 +84,7 @@ msgstr "" "回傳 :class:`float` 嚴格子類別 ``__float__()`` 方法的支援:這些方法將需要回" "傳 :class:`float` 的實例。" -#: ../../deprecations/pending-removal-in-future.rst:32 +#: ../../deprecations/pending-removal-in-future.rst:30 msgid "" "Support for ``__complex__()`` method returning a strict subclass of :class:" "`complex`: these methods will be required to return an instance of :class:" @@ -97,11 +93,11 @@ msgstr "" "回傳 :class:`complex` 嚴格子類別 ``__complex__()`` 方法的支援:這些方法將需要" "回傳 :class:`complex` 的實例。" -#: ../../deprecations/pending-removal-in-future.rst:35 +#: ../../deprecations/pending-removal-in-future.rst:33 msgid "Delegation of ``int()`` to ``__trunc__()`` method." msgstr "將 ``int()`` 委派給 ``__trunc__()`` 方法。" -#: ../../deprecations/pending-removal-in-future.rst:36 +#: ../../deprecations/pending-removal-in-future.rst:34 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 " @@ -111,7 +107,7 @@ msgstr "" "在 :func:`complex` 建構子中將複數作為 *real* 或 *imag* 引數傳遞現在已被棄用;" "它應該只作為單個位置引數傳遞。 (由 Serhiy Storchaka 於 :gh:`109218` 貢獻。)" -#: ../../deprecations/pending-removal-in-future.rst:41 +#: ../../deprecations/pending-removal-in-future.rst:39 msgid "" ":mod:`calendar`: ``calendar.January`` and ``calendar.February`` constants " "are deprecated and replaced by :data:`calendar.JANUARY` and :data:`calendar." @@ -121,18 +117,18 @@ msgstr "" "被 :data:`calendar.JANUARY` 和 :data:`calendar.FEBRUARY` 取代。 (由 Prince " "Roshan 於 :gh:`103636` 貢獻。)" -#: ../../deprecations/pending-removal-in-future.rst:46 +#: ../../deprecations/pending-removal-in-future.rst:44 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:49 +#: ../../deprecations/pending-removal-in-future.rst:47 msgid ":mod:`datetime`:" msgstr ":mod:`datetime`:" -#: ../../deprecations/pending-removal-in-future.rst:51 +#: ../../deprecations/pending-removal-in-future.rst:49 msgid "" ":meth:`~datetime.datetime.utcnow`: use ``datetime.datetime.now(tz=datetime." "UTC)``." @@ -140,7 +136,7 @@ msgstr "" ":meth:`~datetime.datetime.utcnow`:請改用 ``datetime.datetime." "now(tz=datetime.UTC)``。" -#: ../../deprecations/pending-removal-in-future.rst:53 +#: ../../deprecations/pending-removal-in-future.rst:51 msgid "" ":meth:`~datetime.datetime.utcfromtimestamp`: use ``datetime.datetime." "fromtimestamp(timestamp, tz=datetime.UTC)``." @@ -148,19 +144,15 @@ msgstr "" ":meth:`~datetime.datetime.utcfromtimestamp`:請改用 ``datetime.datetime." "fromtimestamp(timestamp, tz=datetime.UTC)``。" -#: ../../deprecations/pending-removal-in-future.rst:56 +#: ../../deprecations/pending-removal-in-future.rst:54 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:56 msgid ":mod:`importlib`:" msgstr ":mod:`importlib`:" -#: ../../deprecations/pending-removal-in-future.rst:60 -msgid "``load_module()`` method: use ``exec_module()`` instead." -msgstr "``load_module()`` method:請改用 ``exec_module()``。" - -#: ../../deprecations/pending-removal-in-future.rst:61 +#: ../../deprecations/pending-removal-in-future.rst:58 msgid "" ":func:`~importlib.util.cache_from_source` *debug_override* parameter is " "deprecated: use the *optimization* parameter instead." @@ -168,37 +160,37 @@ msgstr "" ":func:`~importlib.util.cache_from_source` *debug_override* 參數已被棄用:請改" "用 *optimization* 參數。" -#: ../../deprecations/pending-removal-in-future.rst:64 +#: ../../deprecations/pending-removal-in-future.rst:61 msgid ":mod:`importlib.metadata`:" msgstr ":mod:`importlib.metadata`:" -#: ../../deprecations/pending-removal-in-future.rst:66 +#: ../../deprecations/pending-removal-in-future.rst:63 msgid "``EntryPoints`` tuple interface." msgstr "``EntryPoints`` 元組介面。" -#: ../../deprecations/pending-removal-in-future.rst:67 +#: ../../deprecations/pending-removal-in-future.rst:64 msgid "Implicit ``None`` on return values." msgstr "回傳值上的隱式 ``None``。" -#: ../../deprecations/pending-removal-in-future.rst:69 +#: ../../deprecations/pending-removal-in-future.rst:66 msgid "" ":mod:`logging`: the ``warn()`` method has been deprecated since Python 3.3, " "use :meth:`~logging.warning` instead." msgstr "" -#: ../../deprecations/pending-removal-in-future.rst:72 +#: ../../deprecations/pending-removal-in-future.rst:69 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:75 +#: ../../deprecations/pending-removal-in-future.rst:72 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:77 +#: ../../deprecations/pending-removal-in-future.rst:74 msgid "" ":class:`!pydoc.ErrorDuringImport`: A tuple value for *exc_info* parameter is " "deprecated, use an exception instance." @@ -206,7 +198,7 @@ msgstr "" ":class:`!pydoc.ErrorDuringImport`:*exc_info* 參數的元組值已被棄用,請用例外" "實例。" -#: ../../deprecations/pending-removal-in-future.rst:80 +#: ../../deprecations/pending-removal-in-future.rst:77 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 " @@ -218,12 +210,12 @@ msgstr "" "有 ASCII 數碼序列被接受作為數值參照。位元組模式和替換字串中的群組名稱現在只能" "包含 ASCII 字母、數碼和底線。(由 Serhiy Storchaka 於 :gh:`91760` 貢獻。)" -#: ../../deprecations/pending-removal-in-future.rst:87 +#: ../../deprecations/pending-removal-in-future.rst:84 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:89 +#: ../../deprecations/pending-removal-in-future.rst:86 msgid "" ":mod:`shutil`: :func:`~shutil.rmtree`'s *onerror* parameter is deprecated in " "Python 3.12; use the *onexc* parameter instead." @@ -231,15 +223,15 @@ msgstr "" ":mod:`shutil`::func:`~shutil.rmtree` 的 *onerror* 參數在 Python 3.12 中已被" "棄用;請改用 *onexc* 參數。" -#: ../../deprecations/pending-removal-in-future.rst:92 +#: ../../deprecations/pending-removal-in-future.rst:89 msgid ":mod:`ssl` options and protocols:" msgstr ":mod:`ssl` 選項和協定:" -#: ../../deprecations/pending-removal-in-future.rst:94 +#: ../../deprecations/pending-removal-in-future.rst:91 msgid ":class:`ssl.SSLContext` without protocol argument is deprecated." msgstr "不帶協定引數的 :class:`ssl.SSLContext` 已被棄用。" -#: ../../deprecations/pending-removal-in-future.rst:95 +#: ../../deprecations/pending-removal-in-future.rst:92 msgid "" ":class:`ssl.SSLContext`: :meth:`~ssl.SSLContext.set_npn_protocols` and :meth:" "`!selected_npn_protocol` are deprecated: use ALPN instead." @@ -247,58 +239,51 @@ msgstr "" ":class:`ssl.SSLContext`::meth:`~ssl.SSLContext.set_npn_protocols` 和 :meth:" "`!selected_npn_protocol` 已被棄用:請改用 ALPN。" -#: ../../deprecations/pending-removal-in-future.rst:98 +#: ../../deprecations/pending-removal-in-future.rst:95 msgid "``ssl.OP_NO_SSL*`` options" msgstr "``ssl.OP_NO_SSL*`` 選項" -#: ../../deprecations/pending-removal-in-future.rst:99 +#: ../../deprecations/pending-removal-in-future.rst:96 msgid "``ssl.OP_NO_TLS*`` options" msgstr "``ssl.OP_NO_TLS*`` 選項" -#: ../../deprecations/pending-removal-in-future.rst:100 +#: ../../deprecations/pending-removal-in-future.rst:97 msgid "``ssl.PROTOCOL_SSLv3``" msgstr "``ssl.PROTOCOL_SSLv3``" -#: ../../deprecations/pending-removal-in-future.rst:101 +#: ../../deprecations/pending-removal-in-future.rst:98 msgid "``ssl.PROTOCOL_TLS``" msgstr "``ssl.PROTOCOL_TLS``" -#: ../../deprecations/pending-removal-in-future.rst:102 +#: ../../deprecations/pending-removal-in-future.rst:99 msgid "``ssl.PROTOCOL_TLSv1``" msgstr "``ssl.PROTOCOL_TLSv1``" -#: ../../deprecations/pending-removal-in-future.rst:103 +#: ../../deprecations/pending-removal-in-future.rst:100 msgid "``ssl.PROTOCOL_TLSv1_1``" msgstr "``ssl.PROTOCOL_TLSv1_1``" -#: ../../deprecations/pending-removal-in-future.rst:104 +#: ../../deprecations/pending-removal-in-future.rst:101 msgid "``ssl.PROTOCOL_TLSv1_2``" msgstr "``ssl.PROTOCOL_TLSv1_2``" -#: ../../deprecations/pending-removal-in-future.rst:105 +#: ../../deprecations/pending-removal-in-future.rst:102 msgid "``ssl.TLSVersion.SSLv3``" msgstr "``ssl.TLSVersion.SSLv3``" -#: ../../deprecations/pending-removal-in-future.rst:106 +#: ../../deprecations/pending-removal-in-future.rst:103 msgid "``ssl.TLSVersion.TLSv1``" msgstr "``ssl.TLSVersion.TLSv1``" -#: ../../deprecations/pending-removal-in-future.rst:107 +#: ../../deprecations/pending-removal-in-future.rst:104 msgid "``ssl.TLSVersion.TLSv1_1``" msgstr "``ssl.TLSVersion.TLSv1_1``" -#: ../../deprecations/pending-removal-in-future.rst:109 -msgid "" -":func:`sysconfig.is_python_build` *check_home* parameter is deprecated and " -"ignored." -msgstr "" -":func:`sysconfig.is_python_build` 的 *check_home* 參數已被棄用並被忽略。" - -#: ../../deprecations/pending-removal-in-future.rst:112 +#: ../../deprecations/pending-removal-in-future.rst:106 msgid ":mod:`threading` methods:" msgstr ":mod:`threading` 方法:" -#: ../../deprecations/pending-removal-in-future.rst:114 +#: ../../deprecations/pending-removal-in-future.rst:108 msgid "" ":meth:`!threading.Condition.notifyAll`: use :meth:`~threading.Condition." "notify_all`." @@ -306,11 +291,11 @@ msgstr "" ":meth:`!threading.Condition.notifyAll`:請用 :meth:`~threading.Condition." "notify_all`。" -#: ../../deprecations/pending-removal-in-future.rst:115 +#: ../../deprecations/pending-removal-in-future.rst:109 msgid ":meth:`!threading.Event.isSet`: use :meth:`~threading.Event.is_set`." msgstr ":meth:`!threading.Event.isSet`:請用 :meth:`~threading.Event.is_set`。" -#: ../../deprecations/pending-removal-in-future.rst:116 +#: ../../deprecations/pending-removal-in-future.rst:110 msgid "" ":meth:`!threading.Thread.isDaemon`, :meth:`threading.Thread.setDaemon`: use :" "attr:`threading.Thread.daemon` attribute." @@ -318,7 +303,7 @@ msgstr "" ":meth:`!threading.Thread.isDaemon`、:meth:`threading.Thread.setDaemon`:請" "用 :attr:`threading.Thread.daemon` 屬性。" -#: ../../deprecations/pending-removal-in-future.rst:118 +#: ../../deprecations/pending-removal-in-future.rst:112 msgid "" ":meth:`!threading.Thread.getName`, :meth:`threading.Thread.setName`: use :" "attr:`threading.Thread.name` attribute." @@ -326,20 +311,20 @@ msgstr "" ":meth:`!threading.Thread.getName`、:meth:`threading.Thread.setName`:請用 :" "attr:`threading.Thread.name` 屬性。" -#: ../../deprecations/pending-removal-in-future.rst:120 +#: ../../deprecations/pending-removal-in-future.rst:114 msgid ":meth:`!threading.currentThread`: use :meth:`threading.current_thread`." msgstr "" ":meth:`!threading.currentThread`:請用 :meth:`threading.current_thread`。" -#: ../../deprecations/pending-removal-in-future.rst:121 +#: ../../deprecations/pending-removal-in-future.rst:115 msgid ":meth:`!threading.activeCount`: use :meth:`threading.active_count`." msgstr ":meth:`!threading.activeCount`:請用 :meth:`threading.active_count`。" -#: ../../deprecations/pending-removal-in-future.rst:123 +#: ../../deprecations/pending-removal-in-future.rst:117 msgid ":class:`typing.Text` (:gh:`92332`)." msgstr ":class:`typing.Text` (:gh:`92332`)。" -#: ../../deprecations/pending-removal-in-future.rst:125 +#: ../../deprecations/pending-removal-in-future.rst:119 msgid "" ":class:`unittest.IsolatedAsyncioTestCase`: it is deprecated to return a " "value that is not ``None`` from a test case." @@ -347,58 +332,58 @@ msgstr "" ":class:`unittest.IsolatedAsyncioTestCase`:從測試案例中回傳非 ``None`` 的值已" "被棄用。" -#: ../../deprecations/pending-removal-in-future.rst:128 +#: ../../deprecations/pending-removal-in-future.rst:122 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:130 +#: ../../deprecations/pending-removal-in-future.rst:124 msgid "``splitattr()``" msgstr "``splitattr()``" -#: ../../deprecations/pending-removal-in-future.rst:131 +#: ../../deprecations/pending-removal-in-future.rst:125 msgid "``splithost()``" msgstr "``splithost()``" -#: ../../deprecations/pending-removal-in-future.rst:132 +#: ../../deprecations/pending-removal-in-future.rst:126 msgid "``splitnport()``" msgstr "``splitnport()``" -#: ../../deprecations/pending-removal-in-future.rst:133 +#: ../../deprecations/pending-removal-in-future.rst:127 msgid "``splitpasswd()``" msgstr "``splitpasswd()``" -#: ../../deprecations/pending-removal-in-future.rst:134 +#: ../../deprecations/pending-removal-in-future.rst:128 msgid "``splitport()``" msgstr "``splitport()``" -#: ../../deprecations/pending-removal-in-future.rst:135 +#: ../../deprecations/pending-removal-in-future.rst:129 msgid "``splitquery()``" msgstr "``splitquery()``" -#: ../../deprecations/pending-removal-in-future.rst:136 +#: ../../deprecations/pending-removal-in-future.rst:130 msgid "``splittag()``" msgstr "``splittag()``" -#: ../../deprecations/pending-removal-in-future.rst:137 +#: ../../deprecations/pending-removal-in-future.rst:131 msgid "``splittype()``" msgstr "``splittype()``" -#: ../../deprecations/pending-removal-in-future.rst:138 +#: ../../deprecations/pending-removal-in-future.rst:132 msgid "``splituser()``" msgstr "``splituser()``" -#: ../../deprecations/pending-removal-in-future.rst:139 +#: ../../deprecations/pending-removal-in-future.rst:133 msgid "``splitvalue()``" msgstr "``splitvalue()``" -#: ../../deprecations/pending-removal-in-future.rst:140 +#: ../../deprecations/pending-removal-in-future.rst:134 msgid "``to_bytes()``" msgstr "``to_bytes()``" -#: ../../deprecations/pending-removal-in-future.rst:142 +#: ../../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. " @@ -408,13 +393,13 @@ msgstr "" "class:`~urllib.request.FancyURLopener` 風格已被棄用。請改用更新的 :func:" "`~urllib.request.urlopen` 函式和方法。" -#: ../../deprecations/pending-removal-in-future.rst:146 +#: ../../deprecations/pending-removal-in-future.rst:140 msgid "" ":mod:`wsgiref`: ``SimpleHandler.stdout.write()`` should not do partial " "writes." msgstr ":mod:`wsgiref`:``SimpleHandler.stdout.write()`` 不應該進行部分寫入。" -#: ../../deprecations/pending-removal-in-future.rst:149 +#: ../../deprecations/pending-removal-in-future.rst:143 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 " @@ -425,10 +410,22 @@ msgstr "" "Element` 的真值測試。在未來版本中,它將始終回傳 ``True``。請改用明確的 " "``len(elem)`` 或 ``elem is not None`` 測試。" -#: ../../deprecations/pending-removal-in-future.rst:154 +#: ../../deprecations/pending-removal-in-future.rst:148 msgid "" ":meth:`zipimport.zipimporter.load_module` is deprecated: use :meth:" "`~zipimport.zipimporter.exec_module` 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`)" + +#~ msgid "" +#~ ":func:`sysconfig.is_python_build` *check_home* parameter is deprecated " +#~ "and ignored." +#~ msgstr "" +#~ ":func:`sysconfig.is_python_build` 的 *check_home* 參數已被棄用並被忽略。" + +#~ msgid "``load_module()`` method: use ``exec_module()`` instead." +#~ msgstr "``load_module()`` method:請改用 ``exec_module()``。" diff --git a/extending/embedding.po b/extending/embedding.po index ac486c5aef..bfac4ddcfb 100644 --- a/extending/embedding.po +++ b/extending/embedding.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-04-24 05:56+0000\n" "PO-Revision-Date: 2018-05-23 14:09+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -356,7 +356,7 @@ msgstr "" msgid "" "After initializing the interpreter, the script is loaded using :c:func:" "`PyImport_Import`. This routine needs a Python string as its argument, " -"which is constructed using the :c:func:`PyUnicode_FromString` data " +"which is constructed using the :c:func:`PyUnicode_DecodeFSDefault` data " "conversion routine. ::" msgstr "" diff --git a/extending/newtypes.po b/extending/newtypes.po index d31c7ef8a7..7cd5d6fe10 100644 --- a/extending/newtypes.po +++ b/extending/newtypes.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2024-10-04 16:20+0000\n" "PO-Revision-Date: 2018-05-23 14:34+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -561,7 +561,7 @@ msgid "" "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:" -"`!__doc__` attribute." +"`~type.__doc__` attribute." msgstr "" #: ../../extending/newtypes.rst:301 diff --git a/extending/newtypes_tutorial.po b/extending/newtypes_tutorial.po index 8b1a2a41b9..b707cab931 100644 --- a/extending/newtypes_tutorial.po +++ b/extending/newtypes_tutorial.po @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2024-10-04 16:20+0000\n" "PO-Revision-Date: 2018-07-15 18:56+0800\n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" @@ -289,8 +289,8 @@ msgid "" "If you want your type to be subclassable from Python, and your type has the " "same :c:member:`~PyTypeObject.tp_basicsize` as its base type, you may have " "problems with multiple inheritance. A Python subclass of your type will " -"have to list your type first in its :attr:`~class.__bases__`, or else it " -"will not be able to call your type's :meth:`~object.__new__` method without " +"have to list your type first in its :attr:`~type.__bases__`, or else it will " +"not be able to call your type's :meth:`~object.__new__` method without " "getting an error. You can avoid this problem by ensuring that your type has " "a larger value for :c:member:`~PyTypeObject.tp_basicsize` than its base type " "does. Most of the time, this will be true anyway, because either your base " diff --git a/faq/design.po b/faq/design.po index 0b92963fe7..26224e56c0 100644 --- a/faq/design.po +++ b/faq/design.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2024-09-24 07:20+0000\n" "PO-Revision-Date: 2023-08-31 11:34+0800\n" "Last-Translator: Steven Hsu \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -650,8 +650,8 @@ msgstr "Python 可以被編譯成機器語言、C 語言或其他種語言嗎? #, fuzzy msgid "" "`Cython `_ compiles a modified version of Python with " -"optional annotations into C extensions. `Nuitka `_ " -"is an up-and-coming compiler of Python into C++ code, aiming to support the " +"optional annotations into C extensions. `Nuitka `_ is " +"an up-and-coming compiler of Python into C++ code, aiming to support the " "full Python language." msgstr "" "`Cython `_ 可以編譯一個調整過有選擇性註解的 Python 版" @@ -682,10 +682,10 @@ msgstr "" #, fuzzy msgid "" "Other implementations (such as `Jython `_ or `PyPy " -"`_), however, can rely on a different mechanism such " -"as a full-blown garbage collector. This difference can cause some subtle " -"porting problems if your Python code depends on the behavior of the " -"reference counting implementation." +"`_), however, can rely on a different mechanism such as a " +"full-blown garbage collector. This difference can cause some subtle porting " +"problems if your Python code depends on the behavior of the reference " +"counting implementation." msgstr "" "然而,在其他實作(像是 `Jython `_ 或 `PyPy `_)中,會使用像是成熟的垃圾收集器等不同機制。如果你的 Python 程式碼" diff --git a/faq/extending.po b/faq/extending.po index f55f34caaf..0d3fb55618 100644 --- a/faq/extending.po +++ b/faq/extending.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2024-09-24 07:20+0000\n" "PO-Revision-Date: 2023-02-18 13:08+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -51,10 +51,10 @@ msgstr "我可以在 C++ 中建立自己的函式嗎?" #: ../../faq/extending.rst:28 #, fuzzy msgid "" -"Yes, using the C compatibility features found in C++. Place ``extern \"C\" " -"{ ... }`` around the Python include files and put ``extern \"C\"`` before " -"each function that is going to be called by the Python interpreter. Global " -"or static C++ objects with constructors are probably not a good idea." +"Yes, using the C compatibility features found in C++. Place ``extern " +"\"C\" { ... }`` around the Python include files and put ``extern \"C\"`` " +"before each function that is going to be called by the Python interpreter. " +"Global or static C++ objects with constructors are probably not a good idea." msgstr "" "是的,使用 C++ 中的 C 相容性功能。將 ``extern \"C\" { ... }`` 放在 Python 包" "含檔案周圍,並將 ``extern \"C\"`` 放在每個將由 Python 直譯器呼叫的函式之前。" @@ -467,26 +467,27 @@ msgstr "" #: ../../faq/extending.rst:249 #, fuzzy msgid "" -"Most packaged versions of Python don't include the :file:`/usr/lib/python2." -"{x}/config/` directory, which contains various files required for compiling " +"Most packaged versions of Python omit some files required for compiling " "Python extensions." msgstr "" "大多數打包版本的 Python 不包含 :file:`/usr/lib/python2.{x}/config/` 目錄,該" "目錄包含編譯 Python 擴充所需的各種檔案。" -#: ../../faq/extending.rst:253 -msgid "For Red Hat, install the python-devel RPM to get the necessary files." +#: ../../faq/extending.rst:252 +#, fuzzy +msgid "For Red Hat, install the python3-devel RPM to get the necessary files." msgstr "在 Red Hat 上,請安裝 python-devel RPM 來取得必要的檔案。" -#: ../../faq/extending.rst:255 -msgid "For Debian, run ``apt-get install python-dev``." +#: ../../faq/extending.rst:254 +#, fuzzy +msgid "For Debian, run ``apt-get install python3-dev``." msgstr "對於 Debian,運行 ``apt-get install python-dev``。" -#: ../../faq/extending.rst:258 +#: ../../faq/extending.rst:257 msgid "How do I tell \"incomplete input\" from \"invalid input\"?" msgstr "如何從「無效輸入」區分出「不完整輸入」?" -#: ../../faq/extending.rst:260 +#: ../../faq/extending.rst:259 #, fuzzy msgid "" "Sometimes you want to emulate the Python interactive interpreter's behavior, " @@ -499,7 +500,7 @@ msgstr "" "(例如,你鍵入了 \"if\" 陳述句的開頭或者你沒有關閉你的括號或三重字串引號)," "但是當輸入無效時,它會立即為你提供語法錯誤消息。" -#: ../../faq/extending.rst:266 +#: ../../faq/extending.rst:265 msgid "" "In Python you can use the :mod:`codeop` module, which approximates the " "parser's behavior sufficiently. IDLE uses this, for example." @@ -507,7 +508,7 @@ msgstr "" "在 Python 中,你可以使用 :mod:`codeop` 模組,它充分模擬了剖析器 (parser) 的行" "為。像是 IDLE 就有使用它。" -#: ../../faq/extending.rst:269 +#: ../../faq/extending.rst:268 #, fuzzy msgid "" "The easiest way to do it in C is to call :c:func:`PyRun_InteractiveLoop` " @@ -521,11 +522,11 @@ msgstr "" "`PyOS_ReadlineFunctionPointer` 設定為指向你的自定義輸入函式。有關更多提示,請" "參閱``Modules/readline.c`` 和``Parser/myreadline.c``。" -#: ../../faq/extending.rst:276 +#: ../../faq/extending.rst:275 msgid "How do I find undefined g++ symbols __builtin_new or __pure_virtual?" msgstr "如何找到未定義的 g++ 符號 __builtin_new 或 __pure_virtual?" -#: ../../faq/extending.rst:278 +#: ../../faq/extending.rst:277 #, fuzzy msgid "" "To dynamically load g++ extension modules, you must recompile Python, relink " @@ -536,7 +537,7 @@ msgstr "" "Python 模組 Makefile 中的 LINKCC),並使用 g++ 鏈接你的擴充模組(例如,``g++ " "-shared -o mymodule.so mymodule.o` `)。" -#: ../../faq/extending.rst:284 +#: ../../faq/extending.rst:283 #, fuzzy msgid "" "Can I create an object class with some methods implemented in C and others " @@ -545,7 +546,7 @@ msgstr "" "我可以用一些用 C 實作的方法和用 Python 實作的其他方法(例如通過繼承)建立一個" "物件類別嗎?" -#: ../../faq/extending.rst:286 +#: ../../faq/extending.rst:285 msgid "" "Yes, you can inherit from built-in classes such as :class:`int`, :class:" "`list`, :class:`dict`, etc." @@ -553,7 +554,7 @@ msgstr "" "是的,你可以繼承內建類別,例如 :class:`int`、:class:`list`、:class:`dict` " "等。" -#: ../../faq/extending.rst:289 +#: ../../faq/extending.rst:288 msgid "" "The Boost Python Library (BPL, https://www.boost.org/libs/python/doc/index." "html) provides a way of doing this from C++ (i.e. you can inherit from an " diff --git a/faq/general.po b/faq/general.po index 95f7688655..2cde377391 100644 --- a/faq/general.po +++ b/faq/general.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-03-03 18:39+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-" @@ -614,10 +614,9 @@ msgstr "" #, fuzzy msgid "" "The latest stable releases can always be found on the `Python download page " -"`_. There are two production-ready " -"versions of Python: 2.x and 3.x. The recommended version is 3.x, which is " -"supported by most widely used libraries. Although 2.x is still widely used, " -"`it is not maintained anymore `_." +"`_. Python 3.x is the recommended version " +"and supported by most widely used libraries. Python 2.x :pep:`is not " +"maintained anymore <373>`." msgstr "" "最新的穩定發布版本隨時都可以在 `Python 下載頁面 `_\\ 上找到。Python 有兩個生產就緒 (production-ready) 的版本:2.x " @@ -809,9 +808,10 @@ msgstr "" "(串列)的 method(方法),他們可以像這樣做: ::" #: ../../faq/general.rst:412 +#, fuzzy msgid "" ">>> L = []\n" -">>> dir(L) \n" +">>> dir(L)\n" "['__add__', '__class__', '__contains__', '__delattr__', '__delitem__',\n" "'__dir__', '__doc__', '__eq__', '__format__', '__ge__',\n" "'__getattribute__', '__getitem__', '__gt__', '__hash__', '__iadd__',\n" diff --git a/faq/programming.po b/faq/programming.po index 4a9bd315fb..9cbbf4e682 100644 --- a/faq/programming.po +++ b/faq/programming.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-04-24 05:56+0000\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-" @@ -1945,8 +1945,8 @@ msgstr "" #: ../../faq/programming.rst:990 #, fuzzy msgid "" -"Is there an equivalent to Perl's chomp() for removing trailing newlines from " -"strings?" +"Is there an equivalent to Perl's ``chomp()`` for removing trailing newlines " +"from strings?" msgstr "是否有與 Perl 的 chomp() 等效的方法用於從字串中刪除尾隨換行符?" #: ../../faq/programming.rst:992 @@ -1983,7 +1983,7 @@ msgstr "" #: ../../faq/programming.rst:1009 #, fuzzy -msgid "Is there a scanf() or sscanf() equivalent?" +msgid "Is there a ``scanf()`` or ``sscanf()`` equivalent?" msgstr "是否有 scanf() 或 sscanf() 等價物?" #: ../../faq/programming.rst:1011 @@ -2015,7 +2015,8 @@ msgstr "" "對於更複雜的輸入解析,正則運算式比 C 的 ``sscanf`` 更強大,更適合這項任務。" #: ../../faq/programming.rst:1024 -msgid "What does 'UnicodeDecodeError' or 'UnicodeEncodeError' error mean?" +#, fuzzy +msgid "What does ``UnicodeDecodeError`` or ``UnicodeEncodeError`` error mean?" msgstr "'UnicodeDecodeError' 或 'UnicodeEncodeErro' 錯誤是什麼意思?" #: ../../faq/programming.rst:1026 @@ -2035,11 +2036,12 @@ msgid "" msgstr "以奇數個反斜杠結尾的原始字串將轉義字串的引號: ::" #: ../../faq/programming.rst:1036 +#, fuzzy msgid "" ">>> r'C:\\this\\will\\not\\work\\'\n" " File \"\", line 1\n" " r'C:\\this\\will\\not\\work\\'\n" -" ^\n" +" ^\n" "SyntaxError: unterminated string literal (detected at line 1)" msgstr "" ">>> r'C:\\this\\will\\not\\work\\'\n" @@ -3224,25 +3226,44 @@ msgstr "" #: ../../faq/programming.rst:1616 #, fuzzy msgid "" -"Most :meth:`!__setattr__` implementations must modify :meth:`self.__dict__ " -"` to store local state for self without causing an infinite " -"recursion." +"Many :meth:`~object.__setattr__` implementations call :meth:`!object." +"__setattr__` to set an attribute on self without causing infinite recursion::" msgstr "" "大多數 :meth:`!__setattr__` 實作必須修改 :meth:`self.__dict__ ` 以存儲 self 的本地狀態,而不會導致無限遞迴。" -#: ../../faq/programming.rst:1622 +#: ../../faq/programming.rst:1619 +#, fuzzy +msgid "" +"class X:\n" +" def __setattr__(self, name, value):\n" +" # Custom logic here...\n" +" object.__setattr__(self, name, value)" +msgstr "" +"class X:\n" +" ...\n" +" def __setattr__(self, name, value):\n" +" self.__dict__[name] = value\n" +" ..." + +#: ../../faq/programming.rst:1624 +msgid "" +"Alternatively, it is possible to set attributes by inserting entries into :" +"attr:`self.__dict__ ` directly." +msgstr "" + +#: ../../faq/programming.rst:1629 #, fuzzy msgid "" "How do I call a method defined in a base class from a derived class that " "extends it?" msgstr "如何從擴充它的衍生類別呼叫基底類別中定義的方法?" -#: ../../faq/programming.rst:1624 +#: ../../faq/programming.rst:1631 msgid "Use the built-in :func:`super` function::" msgstr "使用內建的 :func:`super` 函式: ::" -#: ../../faq/programming.rst:1626 +#: ../../faq/programming.rst:1633 msgid "" "class Derived(Base):\n" " def meth(self):\n" @@ -3252,7 +3273,7 @@ msgstr "" " def meth(self):\n" " super().meth() # calls Base.meth" -#: ../../faq/programming.rst:1630 +#: ../../faq/programming.rst:1637 #, fuzzy msgid "" "In the example, :func:`super` will automatically determine the instance from " @@ -3263,12 +3284,12 @@ msgstr "" "在示例中,:func:`super` 將自動確定呼叫它的實例(``self`` 值),使用 " "``type(self ).__mro__``,並回傳 MRO 中``Derived`` 之後的下一行:``Base``。" -#: ../../faq/programming.rst:1637 +#: ../../faq/programming.rst:1644 #, fuzzy msgid "How can I organize my code to make it easier to change the base class?" msgstr "我如何組織我的程式碼以便更容易地更改基底類別?" -#: ../../faq/programming.rst:1639 +#: ../../faq/programming.rst:1646 #, fuzzy msgid "" "You could assign the base class to an alias and derive from the alias. Then " @@ -3280,7 +3301,7 @@ msgstr "" "說一句,如果你想動態決定(例如,取決於資源的可用性)使用哪個基底類別,這個技" "巧也很方便。例子: ::" -#: ../../faq/programming.rst:1644 +#: ../../faq/programming.rst:1651 msgid "" "class Base:\n" " ...\n" @@ -3298,19 +3319,19 @@ msgstr "" "class Derived(BaseAlias):\n" " ..." -#: ../../faq/programming.rst:1654 +#: ../../faq/programming.rst:1661 #, fuzzy msgid "How do I create static class data and static class methods?" msgstr "如何建立靜態類別資料和靜態類別方法?" -#: ../../faq/programming.rst:1656 +#: ../../faq/programming.rst:1663 #, fuzzy msgid "" "Both static data and static methods (in the sense of C++ or Java) are " "supported in Python." msgstr "Python 支援靜態資料和靜態方法(在 C++ 或 Java 的意義上)。" -#: ../../faq/programming.rst:1659 +#: ../../faq/programming.rst:1666 #, fuzzy msgid "" "For static data, simply define a class attribute. To assign a new value to " @@ -3319,7 +3340,7 @@ msgstr "" "對於靜態資料,只需定義一個類別屬性即可。要為屬性分配新值,你必須在分配中顯式" "使用類別名: ::" -#: ../../faq/programming.rst:1662 +#: ../../faq/programming.rst:1669 msgid "" "class C:\n" " count = 0 # number of times C.__init__ called\n" @@ -3331,7 +3352,7 @@ msgid "" " return C.count # or return self.count" msgstr "" -#: ../../faq/programming.rst:1671 +#: ../../faq/programming.rst:1678 #, fuzzy msgid "" "``c.count`` also refers to ``C.count`` for any ``c`` such that " @@ -3342,7 +3363,7 @@ msgstr "" "除非被 ``c`` 本身或某些人覆蓋從 ``c.__class__`` 回到 ``C`` 的基底類別搜索路徑" "上的類別。" -#: ../../faq/programming.rst:1675 +#: ../../faq/programming.rst:1682 #, fuzzy msgid "" "Caution: within a method of C, an assignment like ``self.count = 42`` " @@ -3354,15 +3375,15 @@ msgstr "" "一個名為 \"count\" 的新的不相關實例。類別靜態資料名稱的重新綁定必須始終指定類" "別是否在方法內: ::" -#: ../../faq/programming.rst:1680 +#: ../../faq/programming.rst:1687 msgid "C.count = 314" msgstr "C.count = 314" -#: ../../faq/programming.rst:1682 +#: ../../faq/programming.rst:1689 msgid "Static methods are possible::" msgstr "靜態方法是可能的: ::" -#: ../../faq/programming.rst:1684 +#: ../../faq/programming.rst:1691 msgid "" "class C:\n" " @staticmethod\n" @@ -3376,7 +3397,7 @@ msgstr "" " # 沒有 'self' 參數!\n" " ..." -#: ../../faq/programming.rst:1690 +#: ../../faq/programming.rst:1697 #, fuzzy msgid "" "However, a far more straightforward way to get the effect of a static method " @@ -3384,7 +3405,7 @@ msgid "" msgstr "" "然而,獲得靜態方法效果的一種更直接的方法是透過一個簡單的模組級函式: ::" -#: ../../faq/programming.rst:1693 +#: ../../faq/programming.rst:1700 msgid "" "def getcount():\n" " return C.count" @@ -3392,7 +3413,7 @@ msgstr "" "def getcount():\n" " return C.count" -#: ../../faq/programming.rst:1696 +#: ../../faq/programming.rst:1703 #, fuzzy msgid "" "If your code is structured so as to define one class (or tightly related " @@ -3401,12 +3422,12 @@ msgstr "" "如果你的程式碼結構化以便為每個模組定義一個類別(或緊密相關的類別層次結構)," "則這提供了所需的封裝。" -#: ../../faq/programming.rst:1701 +#: ../../faq/programming.rst:1708 #, fuzzy msgid "How can I overload constructors (or methods) in Python?" msgstr "如何在 Python 中重載構造函式(或方法)?" -#: ../../faq/programming.rst:1703 +#: ../../faq/programming.rst:1710 #, fuzzy msgid "" "This answer actually applies to all methods, but the question usually comes " @@ -3414,11 +3435,11 @@ msgid "" msgstr "" "這個答案實際上適用於所有方法,但這個問題通常首先出現在構造函式的上下文中。" -#: ../../faq/programming.rst:1706 +#: ../../faq/programming.rst:1713 msgid "In C++ you'd write" msgstr "在 C++ 中你會寫成" -#: ../../faq/programming.rst:1708 +#: ../../faq/programming.rst:1715 msgid "" "class C {\n" " C() { cout << \"No arguments\\n\"; }\n" @@ -3430,7 +3451,7 @@ msgstr "" " C(int i) { cout << \"Argument is \" << i << \"\\n\"; }\n" "}" -#: ../../faq/programming.rst:1715 +#: ../../faq/programming.rst:1722 #, fuzzy msgid "" "In Python you have to write a single constructor that catches all cases " @@ -3438,7 +3459,7 @@ msgid "" msgstr "" "在 Python 中,你必須編寫一個構造函式來捕獲所有使用預設引數的情況。例如: ::" -#: ../../faq/programming.rst:1718 +#: ../../faq/programming.rst:1725 msgid "" "class C:\n" " def __init__(self, i=None):\n" @@ -3454,17 +3475,17 @@ msgstr "" " else:\n" " print(\"Argument is\", i)" -#: ../../faq/programming.rst:1725 +#: ../../faq/programming.rst:1732 #, fuzzy msgid "This is not entirely equivalent, but close enough in practice." msgstr "這並不完全等價,但在實踐中足夠接近。" -#: ../../faq/programming.rst:1727 +#: ../../faq/programming.rst:1734 #, fuzzy msgid "You could also try a variable-length argument list, e.g. ::" msgstr "你也可以嘗試可變長度引數 list,例如: ::" -#: ../../faq/programming.rst:1729 +#: ../../faq/programming.rst:1736 msgid "" "def __init__(self, *args):\n" " ..." @@ -3472,17 +3493,17 @@ msgstr "" "def __init__(self, *args):\n" " ..." -#: ../../faq/programming.rst:1732 +#: ../../faq/programming.rst:1739 #, fuzzy msgid "The same approach works for all method definitions." msgstr "相同的方法適用於所有方法定義。" -#: ../../faq/programming.rst:1736 +#: ../../faq/programming.rst:1743 #, fuzzy msgid "I try to use __spam and I get an error about _SomeClassName__spam." msgstr "我嘗試使用 __spam,但收到有關 _SomeClassName__spam 的錯誤。" -#: ../../faq/programming.rst:1738 +#: ../../faq/programming.rst:1745 #, fuzzy msgid "" "Variable names with double leading underscores are \"mangled\" to provide a " @@ -3497,13 +3518,13 @@ msgstr "" "上替換為 ``_classname__spam``,其中 ``classname`` 是當前類別名,所有前導底線" "被去除。" -#: ../../faq/programming.rst:1744 +#: ../../faq/programming.rst:1751 msgid "" "The identifier can be used unchanged within the class, but to access it " "outside the class, the mangled name must be used:" msgstr "" -#: ../../faq/programming.rst:1747 +#: ../../faq/programming.rst:1754 msgid "" "class A:\n" " def __one(self):\n" @@ -3529,7 +3550,7 @@ msgstr "" "\n" "four = 4 * A()._A__one()" -#: ../../faq/programming.rst:1761 +#: ../../faq/programming.rst:1768 #, fuzzy msgid "" "In particular, this does not guarantee privacy since an outside user can " @@ -3539,23 +3560,23 @@ msgstr "" "這並不能保證隱私:外部使用者仍然可以故意存取 \"_classname__spam\" 屬性,並且" "私有值在物件的 __dict__ 中可見。許多 Python 程式員根本懶得使用私有變數名。" -#: ../../faq/programming.rst:1767 +#: ../../faq/programming.rst:1774 msgid "" "The :ref:`private name mangling specifications ` for " "details and special cases." msgstr "" -#: ../../faq/programming.rst:1771 +#: ../../faq/programming.rst:1778 #, fuzzy msgid "My class defines __del__ but it is not called when I delete the object." msgstr "我的類別定義了 __del__ 但是當我刪除物件時它沒有被呼叫。" -#: ../../faq/programming.rst:1773 +#: ../../faq/programming.rst:1780 #, fuzzy msgid "There are several possible reasons for this." msgstr "這有幾個可能的原因。" -#: ../../faq/programming.rst:1775 +#: ../../faq/programming.rst:1782 #, fuzzy msgid "" "The :keyword:`del` statement does not necessarily call :meth:`~object." @@ -3565,7 +3586,7 @@ msgstr "" ":keyword:`del` 陳述式不一定呼叫 :meth:`~object.__del__` -- 它只是減少物件的引" "用計數,如果達到零,則呼叫 :meth:`!__del__`。" -#: ../../faq/programming.rst:1779 +#: ../../faq/programming.rst:1786 #, fuzzy msgid "" "If your data structures contain circular links (e.g. a tree where each child " @@ -3587,7 +3608,7 @@ msgstr "" "行順序是任意的。你可以運行 :func:`gc.collect` 來強制收集,但*存在*永遠不會收" "集物件的病態情況。" -#: ../../faq/programming.rst:1790 +#: ../../faq/programming.rst:1797 #, fuzzy msgid "" "Despite the cycle collector, it's still a good idea to define an explicit " @@ -3602,7 +3623,7 @@ msgstr "" "性。不要直接呼叫 :meth:`!__del__` -- :meth:`!__del__` 應該呼叫 ``close()`` 並" "且 ``close()`` 應該確保它可以多次呼叫同一個物件。" -#: ../../faq/programming.rst:1797 +#: ../../faq/programming.rst:1804 #, fuzzy msgid "" "Another way to avoid cyclical references is to use the :mod:`weakref` " @@ -3614,7 +3635,7 @@ msgstr "" "的情況下指向物件。例如,樹資料結構應該對其父參照和同級參照使用弱參照(如果需" "要的話!)。" -#: ../../faq/programming.rst:1810 +#: ../../faq/programming.rst:1817 #, fuzzy msgid "" "Finally, if your :meth:`!__del__` method raises an exception, a warning " @@ -3623,12 +3644,12 @@ msgstr "" "最後,如果你的 :meth:`!__del__` 方法引發例外,則會將一條警告消息印出到 :data:" "`sys.stderr`。" -#: ../../faq/programming.rst:1815 +#: ../../faq/programming.rst:1822 #, fuzzy msgid "How do I get a list of all instances of a given class?" msgstr "如何獲取給定類別的所有實例的 list?" -#: ../../faq/programming.rst:1817 +#: ../../faq/programming.rst:1824 #, fuzzy msgid "" "Python does not keep track of all instances of a class (or of a built-in " @@ -3638,12 +3659,12 @@ msgstr "" "Python 不會跟踪類別(或內建型別)的所有實例。你可以對類別的構造函式進行編程," "以透過保留對每個實例的弱參照list來跟踪所有實例。" -#: ../../faq/programming.rst:1823 +#: ../../faq/programming.rst:1830 #, fuzzy msgid "Why does the result of ``id()`` appear to be not unique?" msgstr "為什麼 ``id()`` 的結果看起來不唯一?" -#: ../../faq/programming.rst:1825 +#: ../../faq/programming.rst:1832 #, fuzzy msgid "" "The :func:`id` builtin returns an integer that is guaranteed to be unique " @@ -3656,7 +3677,7 @@ msgstr "" "CPython 中,這是物件的記憶體地址,所以經常發生在從記憶體中刪除一個物件後,下" "一個新建立的物件被分配在記憶體中的相同位置。這個例子說明了這一點:" -#: ../../faq/programming.rst:1836 +#: ../../faq/programming.rst:1843 #, fuzzy msgid "" "The two ids belong to different integer objects that are created before, and " @@ -3667,18 +3688,18 @@ msgstr "" "這兩個 id 屬於之前建立的不同整數物件,並在執行 ``id()`` 呼叫後立即刪除。要確" "保你要檢查其 id 的物件仍然存在,請建立對該物件的另一個參照:" -#: ../../faq/programming.rst:1849 +#: ../../faq/programming.rst:1856 msgid "When can I rely on identity tests with the *is* operator?" msgstr "我什麼時候可以依靠 *is* 運算子進行識別性測試?" -#: ../../faq/programming.rst:1851 +#: ../../faq/programming.rst:1858 msgid "" "The ``is`` operator tests for object identity. The test ``a is b`` is " "equivalent to ``id(a) == id(b)``." msgstr "" "``is`` 運算子測試物件識別性。測試 ``a is b`` 等同於 ``id(a) == id(b)`` 。" -#: ../../faq/programming.rst:1854 +#: ../../faq/programming.rst:1861 msgid "" "The most important property of an identity test is that an object is always " "identical to itself, ``a is a`` always returns ``True``. Identity tests are " @@ -3689,7 +3710,7 @@ msgstr "" "識別性測試通常比相等性測試更快。與相等性測試不同,識別性測試保證回傳布林值 " "``True`` 或 ``False`` 。" -#: ../../faq/programming.rst:1859 +#: ../../faq/programming.rst:1866 msgid "" "However, identity tests can *only* be substituted for equality tests when " "object identity is assured. Generally, there are three circumstances where " @@ -3698,34 +3719,36 @@ msgstr "" "然而,*只有*\\ 當物件識別性得到保證時,識別性測試才能代替相等性測試。一般來" "說,保證識別性的情況有以下三種:" -#: ../../faq/programming.rst:1863 +#: ../../faq/programming.rst:1870 +#, fuzzy msgid "" -"1) Assignments create new names but do not change object identity. After " -"the assignment ``new = old``, it is guaranteed that ``new is old``." +"Assignments create new names but do not change object identity. After the " +"assignment ``new = old``, it is guaranteed that ``new is old``." msgstr "" "1) 賦值建立新名稱但不改變物件識別性。賦值 ``new = old`` 後,保證 ``new is " "old``。" -#: ../../faq/programming.rst:1866 +#: ../../faq/programming.rst:1873 +#, fuzzy msgid "" -"2) Putting an object in a container that stores object references does not " +"Putting an object in a container that stores object references does not " "change object identity. After the list assignment ``s[0] = x``, it is " "guaranteed that ``s[0] is x``." msgstr "" "2) 將物件放入存儲物件參照的容器中不會改變物件識別性。在 list 賦值 ``s[0] = " "x`` 之後,保證 ``s[0] 是 x``。" -#: ../../faq/programming.rst:1870 +#: ../../faq/programming.rst:1877 #, fuzzy msgid "" -"3) If an object is a singleton, it means that only one instance of that " -"object can exist. After the assignments ``a = None`` and ``b = None``, it " -"is guaranteed that ``a is b`` because ``None`` is a singleton." +"If an object is a singleton, it means that only one instance of that object " +"can exist. After the assignments ``a = None`` and ``b = None``, it is " +"guaranteed that ``a is b`` because ``None`` is a singleton." msgstr "" "3)如果一個物件是單例,則意味著該物件只能存在一個實例。在賦值 ``a = None`` " "和 ``b = None`` 之後,可以保證 ``a is b`` 因為 ``None`` 是單例。" -#: ../../faq/programming.rst:1874 +#: ../../faq/programming.rst:1881 msgid "" "In most other circumstances, identity tests are inadvisable and equality " "tests are preferred. In particular, identity tests should not be used to " @@ -3735,7 +3758,7 @@ msgstr "" "在大多數其他情況下,識別性測試是不可取的,相等性測試是首選。特別是,識別性測" "試不應用於檢查常數,例如不能保證是單例的 :class:`int` 和 :class:`str`: ::" -#: ../../faq/programming.rst:1879 +#: ../../faq/programming.rst:1886 msgid "" ">>> a = 1000\n" ">>> b = 500\n" @@ -3761,12 +3784,12 @@ msgstr "" ">>> a is c\n" "False" -#: ../../faq/programming.rst:1891 +#: ../../faq/programming.rst:1898 #, fuzzy msgid "Likewise, new instances of mutable containers are never identical::" msgstr "同樣,可變容器的新實例永遠不會相同: ::" -#: ../../faq/programming.rst:1893 +#: ../../faq/programming.rst:1900 msgid "" ">>> a = []\n" ">>> b = []\n" @@ -3778,35 +3801,35 @@ msgstr "" ">>> a is b\n" "False" -#: ../../faq/programming.rst:1898 +#: ../../faq/programming.rst:1905 msgid "" "In the standard library code, you will see several common patterns for " "correctly using identity tests:" msgstr "在標準函式庫程式碼中,你將看到幾種正確使用識別性測試的常見模式:" -#: ../../faq/programming.rst:1901 +#: ../../faq/programming.rst:1908 +#, fuzzy msgid "" -"1) As recommended by :pep:`8`, an identity test is the preferred way to " -"check for ``None``. This reads like plain English in code and avoids " -"confusion with other objects that may have boolean values that evaluate to " -"false." +"As recommended by :pep:`8`, an identity test is the preferred way to check " +"for ``None``. This reads like plain English in code and avoids confusion " +"with other objects that may have boolean values that evaluate to false." msgstr "" "1) 正如 :pep:`8` 所推薦的,識別性測試是檢查 ``None`` 的首選方法。這在程式碼中" "讀起來像簡單的英語,並避免與其他可能具有評估為 false 的布林值的物件混淆。" -#: ../../faq/programming.rst:1905 +#: ../../faq/programming.rst:1912 #, fuzzy msgid "" -"2) Detecting optional arguments can be tricky when ``None`` is a valid input " +"Detecting optional arguments can be tricky when ``None`` is a valid input " "value. In those situations, you can create a singleton sentinel object " "guaranteed to be distinct from other objects. For example, here is how to " -"implement a method that behaves like :meth:`dict.pop`::" +"implement a method that behaves like :meth:`dict.pop`:" msgstr "" "2)當 ``None`` 是有效輸入值時,檢測可選引數可能會很棘手。在這些情況下,你可以" "建立一個保證與其他物件不同的單例哨兵物件。例如,這裡是如何實作一個行為類似" "於 :meth:`dict.pop` 的方法: ::" -#: ../../faq/programming.rst:1910 +#: ../../faq/programming.rst:1917 msgid "" "_sentinel = object()\n" "\n" @@ -3830,23 +3853,24 @@ msgstr "" " raise KeyError(key)\n" " return default" -#: ../../faq/programming.rst:1921 +#: ../../faq/programming.rst:1930 +#, fuzzy msgid "" -"3) Container implementations sometimes need to augment equality tests with " +"Container implementations sometimes need to augment equality tests with " "identity tests. This prevents the code from being confused by objects such " "as ``float('NaN')`` that are not equal to themselves." msgstr "" "3) 容器實作有時需要透過識別性測試來增強相等性測試。這可以防止程式碼被諸如 " "float('NaN') 之類的不等於自身的物件所混淆。" -#: ../../faq/programming.rst:1925 +#: ../../faq/programming.rst:1934 msgid "" "For example, here is the implementation of :meth:`!collections.abc.Sequence." "__contains__`::" msgstr "" "例如,以下是 :meth:`!collections.abc.Sequence.__contains__` 的實作: ::" -#: ../../faq/programming.rst:1928 +#: ../../faq/programming.rst:1937 msgid "" "def __contains__(self, value):\n" " for v in self:\n" @@ -3860,12 +3884,12 @@ msgstr "" " return True\n" " return False" -#: ../../faq/programming.rst:1936 +#: ../../faq/programming.rst:1945 msgid "" "How can a subclass control what data is stored in an immutable instance?" msgstr "子類別如何控制不可變實例中存儲的資料?" -#: ../../faq/programming.rst:1938 +#: ../../faq/programming.rst:1947 #, fuzzy msgid "" "When subclassing an immutable type, override the :meth:`~object.__new__` " @@ -3877,14 +3901,14 @@ msgstr "" "`~object.__init__` 方法。後者僅在*建立實例後*運行,這為時已晚,無法更改不可變" "實例中的資料。" -#: ../../faq/programming.rst:1943 +#: ../../faq/programming.rst:1952 #, fuzzy msgid "" "All of these immutable classes have a different signature than their parent " "class:" msgstr "所有這些不可變類別都具有與其父類別不同的簽名:" -#: ../../faq/programming.rst:1946 +#: ../../faq/programming.rst:1955 msgid "" "from datetime import date\n" "\n" @@ -3908,11 +3932,11 @@ msgid "" " return super().__new__(cls, s)" msgstr "" -#: ../../faq/programming.rst:1969 +#: ../../faq/programming.rst:1978 msgid "The classes can be used like this:" msgstr "這些類別可以像這樣使用:" -#: ../../faq/programming.rst:1971 +#: ../../faq/programming.rst:1980 msgid "" ">>> FirstOfMonthDate(2012, 2, 14)\n" "FirstOfMonthDate(2012, 2, 1)\n" @@ -3932,11 +3956,11 @@ msgstr "" ">>> TitleStr('Blog: Why Python Rocks')\n" "'blog-why-python-rocks'" -#: ../../faq/programming.rst:1986 +#: ../../faq/programming.rst:1995 msgid "How do I cache method calls?" msgstr "如何快取方法呼叫?" -#: ../../faq/programming.rst:1988 +#: ../../faq/programming.rst:1997 #, fuzzy msgid "" "The two principal tools for caching methods are :func:`functools." @@ -3946,7 +3970,7 @@ msgstr "" "快取方法的兩個主要工具是 func:`functools.cached_property` 和 :func:" "`functools.lru_cache`。前者在實例級別存儲結果,後者在類別級別存儲結果。" -#: ../../faq/programming.rst:1993 +#: ../../faq/programming.rst:2002 #, fuzzy msgid "" "The *cached_property* approach only works with methods that do not take any " @@ -3956,7 +3980,7 @@ msgstr "" "*cached_property* 方法僅適用於不帶任何引數的方法。它不會建立對實例的參照。只" "要實例還活著,快取的方法結果就會被保留。" -#: ../../faq/programming.rst:1997 +#: ../../faq/programming.rst:2006 #, fuzzy msgid "" "The advantage is that when an instance is no longer used, the cached method " @@ -3967,7 +3991,7 @@ msgstr "" "好處是當一個實例不再使用時,快取的方法結果會立即釋放。缺點是如果實例累積,累" "積的方法結果也會累積。他們可以不受限制地成長。" -#: ../../faq/programming.rst:2002 +#: ../../faq/programming.rst:2011 msgid "" "The *lru_cache* approach works with methods that have :term:`hashable` " "arguments. It creates a reference to the instance unless special efforts " @@ -3976,7 +4000,7 @@ msgstr "" "*lru_cache* 方法適用於具有\\ :term:`可雜湊 `\\ 引數的方法。除非特別" "努力傳遞弱參照,否則它會建立對實例的參照。" -#: ../../faq/programming.rst:2006 +#: ../../faq/programming.rst:2015 #, fuzzy msgid "" "The advantage of the least recently used algorithm is that the cache is " @@ -3986,11 +4010,11 @@ msgstr "" "最近最少使用演算法的優點是快取受指定的 *maxsize* 限制。缺點是實例會一直保持活" "動狀態,直到它們從快取中老化或快取被清除。" -#: ../../faq/programming.rst:2011 +#: ../../faq/programming.rst:2020 msgid "This example shows the various techniques::" msgstr "這個例子展示了各種技術: ::" -#: ../../faq/programming.rst:2013 +#: ../../faq/programming.rst:2022 msgid "" "class Weather:\n" " \"Lookup weather information on a government website\"\n" @@ -4015,7 +4039,7 @@ msgid "" " # Depends on the station_id, date, and units." msgstr "" -#: ../../faq/programming.rst:2035 +#: ../../faq/programming.rst:2044 #, fuzzy msgid "" "The above example assumes that the *station_id* never changes. If the " @@ -4025,7 +4049,7 @@ msgstr "" "上面的例子假設 *station_id* 永遠不會改變。如果相關的實例屬性是可變的,則 " "*cached_property* 方法無法工作,因為它無法檢測到屬性的更改。" -#: ../../faq/programming.rst:2040 +#: ../../faq/programming.rst:2049 #, fuzzy msgid "" "To make the *lru_cache* approach work when the *station_id* is mutable, the " @@ -4036,7 +4060,7 @@ msgstr "" "`~object.__eq__` 和 :meth:`~object.__hash__` 方法,以便快取可以檢測相關屬性更" "新: ::" -#: ../../faq/programming.rst:2044 +#: ../../faq/programming.rst:2053 msgid "" "class Weather:\n" " \"Example with a mutable station identifier\"\n" @@ -4059,15 +4083,15 @@ msgid "" " # Depends on the station_id, date, and units." msgstr "" -#: ../../faq/programming.rst:2066 +#: ../../faq/programming.rst:2075 msgid "Modules" msgstr "模組" -#: ../../faq/programming.rst:2069 +#: ../../faq/programming.rst:2078 msgid "How do I create a .pyc file?" msgstr "如何建立 .pyc 檔案?" -#: ../../faq/programming.rst:2071 +#: ../../faq/programming.rst:2080 #, fuzzy msgid "" "When a module is imported for the first time (or when the source file has " @@ -4084,7 +4108,7 @@ msgstr "" "間部分依賴於特定的``python `` 建立它的二進製檔案。(有關詳細資訊,請參閱 :" "pep:`3147`。)" -#: ../../faq/programming.rst:2079 +#: ../../faq/programming.rst:2088 #, fuzzy msgid "" "One reason that a ``.pyc`` file may not be created is a permissions problem " @@ -4097,7 +4121,7 @@ msgstr "" "__pycache__ 子目錄。例如,如果你以一個使用者的身份開發但以另一個使用者的身份" "運行,例如你正在使用 Web 服務器進行測試,就會發生這種情況。" -#: ../../faq/programming.rst:2084 +#: ../../faq/programming.rst:2093 #, fuzzy msgid "" "Unless the :envvar:`PYTHONDONTWRITEBYTECODE` environment variable is set, " @@ -4110,7 +4134,7 @@ msgstr "" "並且 Python 有能力(權限,空閒空間等)建立一個 .pyc 檔案是自動的建立一個" "``__pycache__ `` 子目錄並將編譯後的模組寫入該子目錄。" -#: ../../faq/programming.rst:2089 +#: ../../faq/programming.rst:2098 #, fuzzy msgid "" "Running Python on a top level script is not considered an import and no ``." @@ -4125,7 +4149,7 @@ msgstr "" "入 ``python foo.py`` 作為一個 shell 命令),將為 xyz 建立一個 .pyc 因為引入" "了 xyz,但是不會為 foo 建立 .pyc 檔案,因為 ` `foo.py`` 沒有被引入。" -#: ../../faq/programming.rst:2096 +#: ../../faq/programming.rst:2105 #, fuzzy msgid "" "If you need to create a ``.pyc`` file for ``foo`` -- that is, to create a ``." @@ -4135,7 +4159,7 @@ msgstr "" "如果你需要為 ``foo`` 建立一個 ``.pyc`` 檔案——也就是說,為一個未引入的模組建立" "一個 ``.pyc`` 檔案——你可以使用 :mod :`py_compile` 和 :mod:`compileall` 模組。" -#: ../../faq/programming.rst:2100 +#: ../../faq/programming.rst:2109 #, fuzzy msgid "" "The :mod:`py_compile` module can manually compile any module. One way is to " @@ -4144,15 +4168,16 @@ msgstr "" ":mod:`py_compile` 模組可以手動編譯任何模組。一種方法是在該模組中以交互方式使" "用 ``compile()`` 函式: ::" -#: ../../faq/programming.rst:2103 +#: ../../faq/programming.rst:2112 +#, fuzzy msgid "" ">>> import py_compile\n" -">>> py_compile.compile('foo.py') " +">>> py_compile.compile('foo.py')" msgstr "" ">>> import py_compile\n" ">>> py_compile.compile('foo.py') " -#: ../../faq/programming.rst:2106 +#: ../../faq/programming.rst:2115 #, fuzzy msgid "" "This will write the ``.pyc`` to a ``__pycache__`` subdirectory in the same " @@ -4162,7 +4187,7 @@ msgstr "" "這會將 .pyc 寫入與 foo.py 相同位置的 __pycache__ 子目錄(或者你可以使用可選參" "數 cfile 覆蓋它)。" -#: ../../faq/programming.rst:2110 +#: ../../faq/programming.rst:2119 #, fuzzy msgid "" "You can also automatically compile all files in a directory or directories " @@ -4173,15 +4198,15 @@ msgstr "" "你還可以使用 :mod:`compileall` 模組自動編譯目錄中的所有檔案。你可以在 shell " "提示符下運行 ``compileall.py`` 並提供包含要編譯的 Python 檔案的目錄路徑: ::" -#: ../../faq/programming.rst:2115 +#: ../../faq/programming.rst:2124 msgid "python -m compileall ." msgstr "python -m compileall ." -#: ../../faq/programming.rst:2119 +#: ../../faq/programming.rst:2128 msgid "How do I find the current module name?" msgstr "如何找到當前模組名稱?" -#: ../../faq/programming.rst:2121 +#: ../../faq/programming.rst:2130 #, fuzzy msgid "" "A module can find out its own module name by looking at the predefined " @@ -4194,7 +4219,7 @@ msgstr "" "值為``'__main__'``,則該程式作為腳本運行。許多通常透過引入使用的模組還提供命" "令行界面或自檢,只有在檢查 ``__name__`` 後才執行此程式碼: ::" -#: ../../faq/programming.rst:2127 +#: ../../faq/programming.rst:2136 msgid "" "def main():\n" " print('Running test...')\n" @@ -4204,20 +4229,20 @@ msgid "" " main()" msgstr "" -#: ../../faq/programming.rst:2136 +#: ../../faq/programming.rst:2145 #, fuzzy msgid "How can I have modules that mutually import each other?" msgstr "我怎樣才能擁有相互引入的模組?" -#: ../../faq/programming.rst:2138 +#: ../../faq/programming.rst:2147 msgid "Suppose you have the following modules:" msgstr "假設你有以下模組:" -#: ../../faq/programming.rst:2140 +#: ../../faq/programming.rst:2149 msgid ":file:`foo.py`::" msgstr ":file:`foo.py`: ::" -#: ../../faq/programming.rst:2142 +#: ../../faq/programming.rst:2151 msgid "" "from bar import bar_var\n" "foo_var = 1" @@ -4225,11 +4250,11 @@ msgstr "" "from bar import bar_var\n" "foo_var = 1" -#: ../../faq/programming.rst:2145 +#: ../../faq/programming.rst:2154 msgid ":file:`bar.py`::" msgstr ":file:`bar.py`: ::" -#: ../../faq/programming.rst:2147 +#: ../../faq/programming.rst:2156 msgid "" "from foo import foo_var\n" "bar_var = 2" @@ -4237,39 +4262,39 @@ msgstr "" "from foo import foo_var\n" "bar_var = 2" -#: ../../faq/programming.rst:2150 +#: ../../faq/programming.rst:2159 #, fuzzy msgid "The problem is that the interpreter will perform the following steps:" msgstr "問題是直譯器將執行以下步驟:" -#: ../../faq/programming.rst:2152 +#: ../../faq/programming.rst:2161 #, fuzzy msgid "main imports ``foo``" msgstr "主要引入 ``foo``" -#: ../../faq/programming.rst:2153 +#: ../../faq/programming.rst:2162 #, fuzzy msgid "Empty globals for ``foo`` are created" msgstr "建立了 ``foo`` 的空全域變數" -#: ../../faq/programming.rst:2154 +#: ../../faq/programming.rst:2163 msgid "``foo`` is compiled and starts executing" msgstr "``foo`` 被編譯並開始執行" -#: ../../faq/programming.rst:2155 +#: ../../faq/programming.rst:2164 msgid "``foo`` imports ``bar``" msgstr "``foo`` 引入 ``bar``" -#: ../../faq/programming.rst:2156 +#: ../../faq/programming.rst:2165 #, fuzzy msgid "Empty globals for ``bar`` are created" msgstr "建立了 ``bar`` 的空全域變數" -#: ../../faq/programming.rst:2157 +#: ../../faq/programming.rst:2166 msgid "``bar`` is compiled and starts executing" msgstr "``bar`` 已被編譯並開始執行" -#: ../../faq/programming.rst:2158 +#: ../../faq/programming.rst:2167 #, fuzzy msgid "" "``bar`` imports ``foo`` (which is a no-op since there already is a module " @@ -4277,7 +4302,7 @@ msgid "" msgstr "" "``bar`` 引入 ``foo``(這是一個空操作,因為已經有一個名為 ``foo`` 的模組)" -#: ../../faq/programming.rst:2159 +#: ../../faq/programming.rst:2168 #, fuzzy msgid "" "The import mechanism tries to read ``foo_var`` from ``foo`` globals, to set " @@ -4286,7 +4311,7 @@ msgstr "" "引入機制嘗試從 ``foo`` 全域變數中讀取 ``foo_var`` ,以設定 ``bar.foo_var = " "foo.foo_var`` " -#: ../../faq/programming.rst:2161 +#: ../../faq/programming.rst:2170 #, fuzzy msgid "" "The last step fails, because Python isn't done with interpreting ``foo`` yet " @@ -4295,7 +4320,7 @@ msgstr "" "最後一步失敗了,因為 Python 還沒有完成對 ``foo`` 的直譯,而 ``foo`` 的全域符" "號字典仍然是空的。" -#: ../../faq/programming.rst:2164 +#: ../../faq/programming.rst:2173 #, fuzzy msgid "" "The same thing happens when you use ``import foo``, and then try to access " @@ -4304,11 +4329,11 @@ msgstr "" "當你使用 ``import foo``,然後嘗試在全域程式碼中存取 ``foo.foo_var`` 時,也會" "發生同樣的事情。" -#: ../../faq/programming.rst:2167 +#: ../../faq/programming.rst:2176 msgid "There are (at least) three possible workarounds for this problem." msgstr "此問題有(至少)三種可能的解決方法。" -#: ../../faq/programming.rst:2169 +#: ../../faq/programming.rst:2178 #, fuzzy msgid "" "Guido van Rossum recommends avoiding all uses of ``from import ..." @@ -4321,28 +4346,28 @@ msgstr "" "函式中。全域變數和類別變數的初始化應該只使用常數或內建函式。這意味著來自引入" "模組的所有內容都被參照為 ``.``。" -#: ../../faq/programming.rst:2174 +#: ../../faq/programming.rst:2183 msgid "" "Jim Roskind suggests performing steps in the following order in each module:" msgstr "Jim Roskind 建議在每個模組中按以下順序執行各個步驟:" -#: ../../faq/programming.rst:2176 +#: ../../faq/programming.rst:2185 #, fuzzy msgid "" "exports (globals, functions, and classes that don't need imported base " "classes)" msgstr "導出(不需要引入基底類別的全域變數、函式和類別)" -#: ../../faq/programming.rst:2178 +#: ../../faq/programming.rst:2187 msgid "``import`` statements" msgstr "``import`` 陳述式" -#: ../../faq/programming.rst:2179 +#: ../../faq/programming.rst:2188 msgid "" "active code (including globals that are initialized from imported values)." msgstr "活躍程式碼(包括從引入值初始化的全域變數)。" -#: ../../faq/programming.rst:2181 +#: ../../faq/programming.rst:2190 #, fuzzy msgid "" "Van Rossum doesn't like this approach much because the imports appear in a " @@ -4350,21 +4375,21 @@ msgid "" msgstr "" "Van Rossum 不太喜歡這種方法,因為引入出現在一個奇怪的地方,但它確實有效。" -#: ../../faq/programming.rst:2184 +#: ../../faq/programming.rst:2193 msgid "" "Matthias Urlichs recommends restructuring your code so that the recursive " "import is not necessary in the first place." msgstr "Matthias Urlichs 建議重構你的程式碼,以便打從一開始就不需要遞迴引入。" -#: ../../faq/programming.rst:2187 +#: ../../faq/programming.rst:2196 msgid "These solutions are not mutually exclusive." msgstr "這些方案並不衝突。" -#: ../../faq/programming.rst:2191 +#: ../../faq/programming.rst:2200 msgid "__import__('x.y.z') returns ; how do I get z?" msgstr "__import__('x.y.z') 回傳 ,那我怎麼得到 z?" -#: ../../faq/programming.rst:2193 +#: ../../faq/programming.rst:2202 #, fuzzy msgid "" "Consider using the convenience function :func:`~importlib.import_module` " @@ -4373,17 +4398,17 @@ msgstr "" "考慮使用來自 :mod:`importlib` 的便利函式 :func:`~importlib.import_module` 代" "替: ::" -#: ../../faq/programming.rst:2196 +#: ../../faq/programming.rst:2205 msgid "z = importlib.import_module('x.y.z')" msgstr "z = importlib.import_module('x.y.z')" -#: ../../faq/programming.rst:2200 +#: ../../faq/programming.rst:2209 msgid "" "When I edit an imported module and reimport it, the changes don't show up. " "Why does this happen?" msgstr "當我編輯需要引入的模組並重新引入它時,更動沒有反應出來。為什麼會這樣?" -#: ../../faq/programming.rst:2202 +#: ../../faq/programming.rst:2211 #, fuzzy msgid "" "For reasons of efficiency as well as consistency, Python only reads the " @@ -4396,7 +4421,7 @@ msgstr "" "一個由許多模組組成的程式中,每個模組都引入相同的基本模組,基本模組將被解析和" "重新解析很多次。要強制重新讀取已更改的模組,請執行以下操作: ::" -#: ../../faq/programming.rst:2208 +#: ../../faq/programming.rst:2217 msgid "" "import importlib\n" "import modname\n" @@ -4406,18 +4431,18 @@ msgstr "" "import modname\n" "importlib.reload(modname)" -#: ../../faq/programming.rst:2212 +#: ../../faq/programming.rst:2221 #, fuzzy msgid "" "Warning: this technique is not 100% fool-proof. In particular, modules " "containing statements like ::" msgstr "警告:此技術並非 100% 萬無一失。尤其是,包含像這樣的陳述式的模組: ::" -#: ../../faq/programming.rst:2215 +#: ../../faq/programming.rst:2224 msgid "from modname import some_objects" msgstr "from modname import some_objects" -#: ../../faq/programming.rst:2217 +#: ../../faq/programming.rst:2226 #, fuzzy msgid "" "will continue to work with the old version of the imported objects. If the " @@ -4428,7 +4453,7 @@ msgstr "" "將繼續使用舊版本的引入物件。如果模組包含類別定義,現有的類別實例將*不會*更新" "為使用新的類別定義。這可能會導致以下自相矛盾的行為: ::" -#: ../../faq/programming.rst:2222 +#: ../../faq/programming.rst:2231 msgid "" ">>> import importlib\n" ">>> import cls\n" @@ -4439,13 +4464,13 @@ msgid "" "False" msgstr "" -#: ../../faq/programming.rst:2230 +#: ../../faq/programming.rst:2239 msgid "" "The nature of the problem is made clear if you print out the \"identity\" of " "the class objects::" msgstr "如果印出類別物件的「識別性」,問題的本質就很清楚了: ::" -#: ../../faq/programming.rst:2233 +#: ../../faq/programming.rst:2242 msgid "" ">>> hex(id(c.__class__))\n" "'0x7352a0'\n" diff --git a/glossary.po b/glossary.po index 076f333c7b..8c6ed4d702 100644 --- a/glossary.po +++ b/glossary.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-04-24 05:56+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-" @@ -256,12 +256,13 @@ msgstr "" "運算式。" #: ../../glossary.rst:112 +#, fuzzy msgid "" "Each :keyword:`yield` temporarily suspends processing, remembering the " -"location execution state (including local variables and pending try-" -"statements). When the *asynchronous generator iterator* effectively resumes " -"with another awaitable returned by :meth:`~object.__anext__`, it picks up " -"where it left off. See :pep:`492` and :pep:`525`." +"execution state (including local variables and pending try-statements). " +"When the *asynchronous generator iterator* effectively resumes with another " +"awaitable returned by :meth:`~object.__anext__`, it picks up where it left " +"off. See :pep:`492` and :pep:`525`." msgstr "" "每個 :keyword:`yield` 會暫停處理程序,並記住位置執行狀態(包括區域變數及擱置" "中的 try 陳述式)。當\\ *非同步產生器疊代器*\\ 以另一個被 :meth:`~object." @@ -530,10 +531,51 @@ msgstr "" "修改的變數。" #: ../../glossary.rst:228 +#, fuzzy +msgid "closure variable" +msgstr "class variable(類別變數)" + +#: ../../glossary.rst:230 +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 " +"globals or builtin namespaces. May be explicitly defined with the :keyword:" +"`nonlocal` keyword to allow write access, or implicitly defined if the " +"variable is only being read." +msgstr "" + +#: ../../glossary.rst:235 +msgid "" +"For example, in the ``inner`` function in the following code, both ``x`` and " +"``print`` are :term:`free variables `, but only ``x`` is a " +"*closure variable*::" +msgstr "" + +#: ../../glossary.rst:238 +msgid "" +"def outer():\n" +" x = 0\n" +" def inner():\n" +" nonlocal x\n" +" x += 1\n" +" print(x)\n" +" return inner" +msgstr "" + +#: ../../glossary.rst:246 +msgid "" +"Due to the :attr:`codeobject.co_freevars` attribute (which, despite its " +"name, only includes the names of closure variables rather than listing all " +"referenced free variables), the more general :term:`free variable` term is " +"sometimes used even when the intended meaning is to refer specifically to " +"closure variables." +msgstr "" + +#: ../../glossary.rst:250 msgid "complex number" msgstr "complex number(複數)" -#: ../../glossary.rst:230 +#: ../../glossary.rst:252 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 " @@ -553,44 +595,74 @@ msgstr "" "相當進階的數學功能。如果你沒有察覺到對它們的需求,那麼幾乎能確定你可以安全地" "忽略它們。" -#: ../../glossary.rst:240 +#: ../../glossary.rst:262 +#, fuzzy +msgid "context" +msgstr "context manager(情境管理器)" + +#: ../../glossary.rst:264 +msgid "" +"This term has different meanings depending on where and how it is used. Some " +"common meanings:" +msgstr "" + +#: ../../glossary.rst:267 +msgid "" +"The temporary state or environment established by a :term:`context manager` " +"via a :keyword:`with` statement." +msgstr "" + +#: ../../glossary.rst:269 +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 +msgid "" +"A :class:`contextvars.Context` object. Also see :term:`current context`." +msgstr "" + +#: ../../glossary.rst:275 +#, fuzzy +msgid "context management protocol" +msgstr "context manager(情境管理器)" + +#: ../../glossary.rst:277 +msgid "" +"The :meth:`~object.__enter__` and :meth:`~object.__exit__` methods called by " +"the :keyword:`with` statement. See :pep:`343`." +msgstr "" + +#: ../../glossary.rst:279 msgid "context manager" msgstr "context manager(情境管理器)" -#: ../../glossary.rst:242 +#: ../../glossary.rst:281 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`." +"An object which implements the :term:`context management protocol` and " +"controls the environment seen in a :keyword:`with` statement. See :pep:" +"`343`." msgstr "" -"一個可以控制 :keyword:`with` 陳述式中所見環境的物件,而它是透過定義 :meth:" -"`~object.__enter__` 和 :meth:`~object.__exit__` method 來控制的。請參閱 :pep:" -"`343`。" -#: ../../glossary.rst:245 +#: ../../glossary.rst:284 msgid "context variable" msgstr "context variable(情境變數)" -#: ../../glossary.rst:247 +#: ../../glossary.rst:286 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`." +"A variable whose value depends on which context is the :term:`current " +"context`. Values are accessed via :class:`contextvars.ContextVar` objects. " +"Context variables are primarily used to isolate state between concurrent " +"asynchronous tasks." msgstr "" -"一個變數,其值可以根據上下文的情境而有所不同。這類似執行緒區域儲存區 (Thread-" -"Local Storage),在其中,一個變數在每個執行緒可能具有不同的值。然而,關於情境" -"變數,在一個執行緒中可能會有多個情境,而情境變數的主要用途,是在並行的非同步" -"任務 (concurrent asynchronous task) 中,對於變數狀態的追蹤。請參閱 :mod:" -"`contextvars`。" -#: ../../glossary.rst:254 +#: ../../glossary.rst:290 msgid "contiguous" msgstr "contiguous(連續的)" -#: ../../glossary.rst:258 +#: ../../glossary.rst:294 msgid "" "A buffer is considered contiguous exactly if it is either *C-contiguous* or " "*Fortran contiguous*. Zero-dimensional buffers are C and Fortran " @@ -607,11 +679,11 @@ msgstr "" "的順序訪問各個項目時,最後一個索引的變化最快。然而,在 Fortran contiguous 陣" "列中,第一個索引的變化最快。" -#: ../../glossary.rst:266 +#: ../../glossary.rst:302 msgid "coroutine" msgstr "coroutine(協程)" -#: ../../glossary.rst:268 +#: ../../glossary.rst:304 msgid "" "Coroutines are a more generalized form of subroutines. Subroutines are " "entered at one point and exited at another point. Coroutines can be " @@ -622,11 +694,11 @@ msgstr "" "在另一個時間點被退出。協程可以在許多不同的時間點被進入、退出和回復。它們能夠" "以 :keyword:`async def` 陳述式被實作。另請參閱 :pep:`492`。" -#: ../../glossary.rst:273 +#: ../../glossary.rst:309 msgid "coroutine function" msgstr "coroutine function(協程函式)" -#: ../../glossary.rst:275 +#: ../../glossary.rst:311 msgid "" "A function which returns a :term:`coroutine` object. A coroutine function " "may be defined with the :keyword:`async def` statement, and may contain :" @@ -637,11 +709,11 @@ msgstr "" "`async def` 陳述式被定義,並可能會包含 :keyword:`await`、:keyword:`async " "for` 和 :keyword:`async with` 關鍵字。這些關鍵字由 :pep:`492` 引入。" -#: ../../glossary.rst:280 +#: ../../glossary.rst:316 msgid "CPython" msgstr "CPython" -#: ../../glossary.rst:282 +#: ../../glossary.rst:318 msgid "" "The canonical implementation of the Python programming language, as " "distributed on `python.org `_. The term \"CPython\" " @@ -652,11 +724,25 @@ msgstr "" "`_ 上。「CPython」這個術語在必要時被使用,以區分此實" "作與其它語言的實作,例如 Jython 或 IronPython。" -#: ../../glossary.rst:286 +#: ../../glossary.rst:322 +msgid "current context" +msgstr "" + +#: ../../glossary.rst:324 +msgid "" +"The :term:`context` (:class:`contextvars.Context` object) that is currently " +"used by :class:`~contextvars.ContextVar` objects to access (get or set) the " +"values of :term:`context variables `. Each thread has its " +"own current context. Frameworks for executing asynchronous tasks (see :mod:" +"`asyncio`) associate each task with a context which becomes the current " +"context whenever the task starts or resumes execution." +msgstr "" + +#: ../../glossary.rst:330 msgid "decorator" msgstr "decorator(裝飾器)" -#: ../../glossary.rst:288 +#: ../../glossary.rst:332 msgid "" "A function returning another function, usually applied as a function " "transformation using the ``@wrapper`` syntax. Common examples for " @@ -666,13 +752,13 @@ msgstr "" "式的變換 (function transformation)。裝飾器的常見範例是 :func:`classmethod` " "和 :func:`staticmethod`。" -#: ../../glossary.rst:292 +#: ../../glossary.rst:336 msgid "" "The decorator syntax is merely syntactic sugar, the following two function " "definitions are semantically equivalent::" msgstr "裝飾器語法只是語法糖。以下兩個函式定義在語義上是等效的: ::" -#: ../../glossary.rst:295 +#: ../../glossary.rst:339 msgid "" "def f(arg):\n" " ...\n" @@ -690,7 +776,7 @@ msgstr "" "def f(arg):\n" " ..." -#: ../../glossary.rst:303 +#: ../../glossary.rst:347 msgid "" "The same concept exists for classes, but is less commonly used there. See " "the documentation for :ref:`function definitions ` and :ref:`class " @@ -699,11 +785,11 @@ msgstr "" "Class 也存在相同的概念,但在那裡比較不常用。關於裝飾器的更多內容,請參閱\\ :" "ref:`函式定義 `\\ 和 :ref:`class 定義 `\\ 的說明文件。" -#: ../../glossary.rst:306 +#: ../../glossary.rst:350 msgid "descriptor" msgstr "descriptor(描述器)" -#: ../../glossary.rst:308 +#: ../../glossary.rst:352 msgid "" "Any object which defines the methods :meth:`~object.__get__`, :meth:`~object." "__set__`, or :meth:`~object.__delete__`. When a class attribute is a " @@ -723,7 +809,7 @@ msgstr "" "們是許多功能的基礎,這些功能包括函式、method、屬性 (property)、class method、" "靜態 method,以及對 super class(父類別)的參照。" -#: ../../glossary.rst:319 +#: ../../glossary.rst:363 msgid "" "For more information about descriptors' methods, see :ref:`descriptors` or " "the :ref:`Descriptor How To Guide `." @@ -731,11 +817,11 @@ msgstr "" "關於描述器 method 的更多資訊,請參閱\\ :ref:`descriptors`\\ 或\\ :ref:`描述器" "使用指南 `。" -#: ../../glossary.rst:321 +#: ../../glossary.rst:365 msgid "dictionary" msgstr "dictionary(字典)" -#: ../../glossary.rst:323 +#: ../../glossary.rst:367 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__` " @@ -745,11 +831,11 @@ msgstr "" "有 :meth:`~object.__hash__` 和 :meth:`~object.__eq__` method 的物件。在 Perl " "中被稱為雜湊 (hash)。" -#: ../../glossary.rst:327 +#: ../../glossary.rst:371 msgid "dictionary comprehension" msgstr "dictionary comprehension(字典綜合運算)" -#: ../../glossary.rst:329 +#: ../../glossary.rst:373 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 " @@ -760,11 +846,11 @@ msgstr "" "字典回傳。``results = {n: n ** 2 for n in range(10)}`` 會產生一個字典,它包含" "了鍵 ``n`` 映射到值 ``n ** 2``。請參閱\\ :ref:`comprehensions`。" -#: ../../glossary.rst:333 +#: ../../glossary.rst:377 msgid "dictionary view" msgstr "dictionary view(字典檢視)" -#: ../../glossary.rst:335 +#: ../../glossary.rst:379 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 " @@ -777,28 +863,29 @@ msgstr "" "反映這些變動。若要強制將字典檢視轉為完整的 list(串列),須使用 " "``list(dictview)``。請參閱\\ :ref:`dict-views`。" -#: ../../glossary.rst:341 +#: ../../glossary.rst:385 msgid "docstring" msgstr "docstring(說明字串)" -#: ../../glossary.rst:343 +#: ../../glossary.rst:387 +#, fuzzy 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 " -"the compiler and put into the :attr:`!__doc__` attribute of the enclosing " -"class, function or module. Since it is available via introspection, it is " -"the canonical place for documentation of the object." +"the compiler and put into the :attr:`~definition.__doc__` attribute of the " +"enclosing class, function or module. Since it is available via " +"introspection, it is the canonical place for documentation of the object." msgstr "" "一個在 class、函式或模組中,作為第一個運算式出現的字串文本。雖然它在套件執行" "時會被忽略,但它會被編譯器辨識,並被放入所屬 class、函式或模組的 :attr:`!" "__doc__` 屬性中。由於說明字串可以透過內省 (introspection) 來瀏覽,因此它是物" "件的說明文件存放的標準位置。" -#: ../../glossary.rst:349 +#: ../../glossary.rst:393 msgid "duck-typing" msgstr "duck-typing(鴨子型別)" -#: ../../glossary.rst:351 +#: ../../glossary.rst:395 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 " @@ -819,11 +906,11 @@ msgstr "" "來補充。)然而,它通常會採用 :func:`hasattr` 測試,或是 :term:`EAFP` 程式設計" "風格。" -#: ../../glossary.rst:360 +#: ../../glossary.rst:404 msgid "EAFP" msgstr "EAFP" -#: ../../glossary.rst:362 +#: ../../glossary.rst:406 msgid "" "Easier to ask for forgiveness than permission. This common Python coding " "style assumes the existence of valid keys or attributes and catches " @@ -838,11 +925,11 @@ msgstr "" "keyword:`except` 陳述式。該技術與許多其他語言(例如 C)常見的 :term:`LBYL` 風" "格形成了對比。" -#: ../../glossary.rst:368 +#: ../../glossary.rst:412 msgid "expression" msgstr "expression(運算式)" -#: ../../glossary.rst:370 +#: ../../glossary.rst:414 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, " @@ -858,11 +945,11 @@ msgstr "" "(陳述式)不能被用作運算式,例如 :keyword:`while`。賦值 (assignment) 也是陳述" "式,而不是運算式。" -#: ../../glossary.rst:377 +#: ../../glossary.rst:421 msgid "extension module" msgstr "extension module(擴充模組)" -#: ../../glossary.rst:379 +#: ../../glossary.rst:423 msgid "" "A module written in C or C++, using Python's C API to interact with the core " "and with user code." @@ -870,11 +957,11 @@ msgstr "" "一個以 C 或 C++ 編寫的模組,它使用 Python 的 C API 來與核心及使用者程式碼進行" "互動。" -#: ../../glossary.rst:381 +#: ../../glossary.rst:425 msgid "f-string" msgstr "f-string(f 字串)" -#: ../../glossary.rst:383 +#: ../../glossary.rst:427 msgid "" "String literals prefixed with ``'f'`` or ``'F'`` are commonly called \"f-" "strings\" which is short for :ref:`formatted string literals `. " @@ -883,11 +970,11 @@ msgstr "" "以 ``'f'`` 或 ``'F'`` 為前綴的字串文本通常被稱為「f 字串」,它是\\ :ref:`格式" "化的字串文本 `\\ 的縮寫。另請參閱 :pep:`498`。" -#: ../../glossary.rst:386 +#: ../../glossary.rst:430 msgid "file object" msgstr "file object(檔案物件)" -#: ../../glossary.rst:388 +#: ../../glossary.rst:432 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 " @@ -902,7 +989,7 @@ msgstr "" "衝區、socket(插座)、管線 (pipe) 等)的存取。檔案物件也被稱為\\ :dfn:`類檔案" "物件 (file-like object)` 或\\ :dfn:`串流 (stream)`。" -#: ../../glossary.rst:396 +#: ../../glossary.rst:440 msgid "" "There are actually three categories of file objects: raw :term:`binary files " "`, buffered :term:`binary files ` and :term:`text " @@ -914,19 +1001,19 @@ msgstr "" "term:`二進位檔案 `\\ 和\\ :term:`文字檔案 `。它們的介" "面在 :mod:`io` 模組中被定義。建立檔案物件的標準方法是使用 :func:`open` 函式。" -#: ../../glossary.rst:401 +#: ../../glossary.rst:445 msgid "file-like object" msgstr "file-like object(類檔案物件)" -#: ../../glossary.rst:403 +#: ../../glossary.rst:447 msgid "A synonym for :term:`file object`." msgstr ":term:`file object`\\ (檔案物件)的同義字。" -#: ../../glossary.rst:404 +#: ../../glossary.rst:448 msgid "filesystem encoding and error handler" msgstr "filesystem encoding and error handler(檔案系統編碼和錯誤處理函式)" -#: ../../glossary.rst:406 +#: ../../glossary.rst:450 msgid "" "Encoding and error handler used by Python to decode bytes from the operating " "system and encode Unicode to the operating system." @@ -934,7 +1021,7 @@ msgstr "" "Python 所使用的一種編碼和錯誤處理函式,用來解碼來自作業系統的位元組,以及將 " "Unicode 編碼到作業系統。" -#: ../../glossary.rst:409 +#: ../../glossary.rst:453 msgid "" "The filesystem encoding must guarantee to successfully decode all bytes " "below 128. If the file system encoding fails to provide this guarantee, API " @@ -943,7 +1030,7 @@ msgstr "" "檔案系統編碼必須保證能成功解碼所有小於 128 的位元組。如果檔案系統編碼無法提供" "此保證,則 API 函式會引發 :exc:`UnicodeError`。" -#: ../../glossary.rst:413 +#: ../../glossary.rst:457 msgid "" "The :func:`sys.getfilesystemencoding` and :func:`sys." "getfilesystemencodeerrors` functions can be used to get the filesystem " @@ -952,7 +1039,7 @@ msgstr "" ":func:`sys.getfilesystemencoding` 和 :func:`sys.getfilesystemencodeerrors` 函" "式可用於取得檔案系統編碼和錯誤處理函式。" -#: ../../glossary.rst:417 +#: ../../glossary.rst:461 msgid "" "The :term:`filesystem encoding and error handler` are configured at Python " "startup by the :c:func:`PyConfig_Read` function: see :c:member:`~PyConfig." @@ -964,22 +1051,22 @@ msgstr "" "member:`~PyConfig.filesystem_encoding`,以及 :c:type:`PyConfig` 的成員 :c:" "member:`~PyConfig.filesystem_errors`。" -#: ../../glossary.rst:422 +#: ../../glossary.rst:466 msgid "See also the :term:`locale encoding`." msgstr "另請參閱 :term:`locale encoding`\\ (區域編碼)。" -#: ../../glossary.rst:423 +#: ../../glossary.rst:467 msgid "finder" msgstr "finder(尋檢器)" -#: ../../glossary.rst:425 +#: ../../glossary.rst:469 msgid "" "An object that tries to find the :term:`loader` for a module that is being " "imported." msgstr "" "一個物件,它會嘗試為正在被 import 的模組尋找 :term:`loader`\\ (載入器)。" -#: ../../glossary.rst:428 +#: ../../glossary.rst:472 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:432 -msgid "See :ref:`importsystem` and :mod:`importlib` for much more detail." +#: ../../glossary.rst:476 +#, fuzzy +msgid "" +"See :ref:`finders-and-loaders` and :mod:`importlib` for much more detail." msgstr "請參閱 :ref:`importsystem` 和 :mod:`importlib` 以了解更多細節。" -#: ../../glossary.rst:433 +#: ../../glossary.rst:477 msgid "floor division" msgstr "floor division(向下取整除法)" -#: ../../glossary.rst:435 +#: ../../glossary.rst:479 msgid "" "Mathematical division that rounds down to nearest integer. The floor " "division operator is ``//``. For example, the expression ``11 // 4`` " @@ -1010,11 +1099,11 @@ msgstr "" "``2.75`` 不同。請注意,``(-11) // 4`` 的結果是 ``-3``,因為是 ``-2.75`` 被\\ " "*向下*\\ 無條件捨去。請參閱 :pep:`238`。" -#: ../../glossary.rst:440 +#: ../../glossary.rst:484 msgid "free threading" msgstr "" -#: ../../glossary.rst:442 +#: ../../glossary.rst:486 msgid "" "A threading model where multiple threads can run Python bytecode " "simultaneously within the same interpreter. This is in contrast to the :" @@ -1022,11 +1111,26 @@ msgid "" "Python bytecode at a time. See :pep:`703`." msgstr "" -#: ../../glossary.rst:446 +#: ../../glossary.rst:490 +#, fuzzy +msgid "free variable" +msgstr "context variable(情境變數)" + +#: ../../glossary.rst:492 +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 " +"variable in that namespace. See :term:`closure variable` for an example. " +"Pragmatically, due to the name of the :attr:`codeobject.co_freevars` " +"attribute, the term is also sometimes used as a synonym for :term:`closure " +"variable`." +msgstr "" + +#: ../../glossary.rst:497 msgid "function" msgstr "function(函式)" -#: ../../glossary.rst:448 +#: ../../glossary.rst:499 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 " @@ -1038,15 +1142,15 @@ msgstr "" "`parameter`\\ (參數)、:term:`method`\\ (方法),以及\\ :ref:`function`\\ " "章節。" -#: ../../glossary.rst:452 +#: ../../glossary.rst:503 msgid "function annotation" msgstr "function annotation(函式註釋)" -#: ../../glossary.rst:454 +#: ../../glossary.rst:505 msgid "An :term:`annotation` of a function parameter or return value." msgstr "函式參數或回傳值的一個 :term:`annotation`\\ (註釋)。" -#: ../../glossary.rst:456 +#: ../../glossary.rst:507 msgid "" "Function annotations are usually used for :term:`type hints `: " "for example, this function is expected to take two :class:`int` arguments " @@ -1055,7 +1159,7 @@ msgstr "" "函式註釋通常被使用於\\ :term:`型別提示 `:例如,這個函式預期會得到" "兩個 :class:`int` 引數,並會有一個 :class:`int` 回傳值: ::" -#: ../../glossary.rst:461 +#: ../../glossary.rst:512 msgid "" "def sum_two_numbers(a: int, b: int) -> int:\n" " return a + b" @@ -1063,11 +1167,11 @@ msgstr "" "def sum_two_numbers(a: int, b: int) -> int:\n" " return a + b" -#: ../../glossary.rst:464 +#: ../../glossary.rst:515 msgid "Function annotation syntax is explained in section :ref:`function`." msgstr "函式註釋的語法在\\ :ref:`function`\\ 章節有詳細解釋。" -#: ../../glossary.rst:466 +#: ../../glossary.rst:517 msgid "" "See :term:`variable annotation` and :pep:`484`, which describe this " "functionality. Also see :ref:`annotations-howto` for best practices on " @@ -1076,11 +1180,11 @@ msgstr "" "請參閱 :term:`variable annotation` 和 :pep:`484`,皆有此功能的描述。關於註釋" "的最佳實踐方法,另請參閱 :ref:`annotations-howto`。" -#: ../../glossary.rst:470 +#: ../../glossary.rst:521 msgid "__future__" msgstr "__future__" -#: ../../glossary.rst:472 +#: ../../glossary.rst:523 msgid "" "A :ref:`future statement `, ``from __future__ import ``, " "directs the compiler to compile the current module using syntax or semantics " @@ -1096,7 +1200,7 @@ msgstr "" "import 此模組並對其變數求值,你可以看見一個新的功能是何時首次被新增到此語言" "中,以及它何時將會(或已經)成為預設的功能: ::" -#: ../../glossary.rst:480 +#: ../../glossary.rst:531 msgid "" ">>> import __future__\n" ">>> __future__.division\n" @@ -1106,11 +1210,11 @@ msgstr "" ">>> __future__.division\n" "_Feature((2, 2, 0, 'alpha', 2), (3, 0, 0, 'alpha', 0), 8192)" -#: ../../glossary.rst:483 +#: ../../glossary.rst:534 msgid "garbage collection" msgstr "garbage collection(垃圾回收)" -#: ../../glossary.rst:485 +#: ../../glossary.rst:536 msgid "" "The process of freeing memory when it is not used anymore. Python performs " "garbage collection via reference counting and a cyclic garbage collector " @@ -1122,11 +1226,11 @@ msgstr "" "垃圾回收器 (cyclic garbage collector) 來完成。垃圾回收器可以使用 :mod:`gc` 模" "組對其進行控制。" -#: ../../glossary.rst:490 ../../glossary.rst:491 +#: ../../glossary.rst:541 ../../glossary.rst:542 msgid "generator" msgstr "generator(產生器)" -#: ../../glossary.rst:493 +#: ../../glossary.rst:544 msgid "" "A function which returns a :term:`generator iterator`. It looks like a " "normal function except that it contains :keyword:`yield` expressions for " @@ -1137,7 +1241,7 @@ msgstr "" "個正常的函式,但不同的是它包含了 :keyword:`yield` 運算式,能產生一系列的值," "這些值可用於 for 迴圈,或是以 :func:`next` 函式,每次檢索其中的一個值。" -#: ../../glossary.rst:498 +#: ../../glossary.rst:549 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 " @@ -1146,30 +1250,31 @@ msgstr "" "這個術語通常用來表示一個產生器函式,但在某些情境中,也可能是表示\\ *產生器疊" "代器*。萬一想表達的意思不夠清楚,那就使用完整的術語,以避免歧義。" -#: ../../glossary.rst:501 +#: ../../glossary.rst:552 msgid "generator iterator" msgstr "generator iterator(產生器疊代器)" -#: ../../glossary.rst:503 +#: ../../glossary.rst:554 msgid "An object created by a :term:`generator` function." msgstr "一個由 :term:`generator`\\ (產生器)函式所建立的物件。" -#: ../../glossary.rst:505 +#: ../../glossary.rst:556 +#, fuzzy msgid "" "Each :keyword:`yield` temporarily suspends processing, remembering the " -"location execution state (including local variables and pending try-" -"statements). When the *generator iterator* resumes, it picks up where it " -"left off (in contrast to functions which start fresh on every invocation)." +"execution state (including local variables and pending try-statements). " +"When the *generator iterator* resumes, it picks up where it left off (in " +"contrast to functions which start fresh on every invocation)." msgstr "" "每個 :keyword:`yield` 會暫停處理程序,並記住位置執行狀態(包括區域變數及擱置" "中的 try 陳述式)。當\\ *產生器疊代器*\\ 回復時,它會從停止的地方繼續執行(與" "那些每次調用時都要重新開始的函式有所不同)。" -#: ../../glossary.rst:511 ../../glossary.rst:512 +#: ../../glossary.rst:562 ../../glossary.rst:563 msgid "generator expression" msgstr "generator expression(產生器運算式)" -#: ../../glossary.rst:514 +#: ../../glossary.rst:565 msgid "" "An :term:`expression` that returns an :term:`iterator`. It looks like a " "normal expression followed by a :keyword:`!for` clause defining a loop " @@ -1181,17 +1286,17 @@ msgstr "" "變數、範圍以及一個選擇性的 :keyword:`!if` 子句。該組合運算式會為外層函式產生" "多個值: ::" -#: ../../glossary.rst:519 +#: ../../glossary.rst:570 msgid "" ">>> sum(i*i for i in range(10)) # sum of squares 0, 1, 4, ... 81\n" "285" msgstr "" -#: ../../glossary.rst:521 +#: ../../glossary.rst:572 msgid "generic function" msgstr "generic function(泛型函式)" -#: ../../glossary.rst:523 +#: ../../glossary.rst:574 msgid "" "A function composed of multiple functions implementing the same operation " "for different types. Which implementation should be used during a call is " @@ -1200,7 +1305,7 @@ msgstr "" "一個由多個函式組成的函式,該函式會對不同的型別實作相同的運算。呼叫期間應該使" "用哪種實作,是由調度演算法 (dispatch algorithm) 來決定。" -#: ../../glossary.rst:527 +#: ../../glossary.rst:578 msgid "" "See also the :term:`single dispatch` glossary entry, the :func:`functools." "singledispatch` decorator, and :pep:`443`." @@ -1208,11 +1313,11 @@ msgstr "" "另請參閱 :term:`single dispatch`\\ (單一調度)術語表條目、:func:`functools." "singledispatch` 裝飾器和 :pep:`443`。" -#: ../../glossary.rst:529 +#: ../../glossary.rst:580 msgid "generic type" msgstr "generic type(泛型型別)" -#: ../../glossary.rst:531 +#: ../../glossary.rst:582 msgid "" "A :term:`type` that can be parameterized; typically a :ref:`container " "class` such as :class:`list` or :class:`dict`. Used for :" @@ -1222,7 +1327,7 @@ msgstr "" "`容器型別 `,像是 :class:`list` 和 :class:`dict`。它被用於" "\\ :term:`型別提示 `\\ 和\\ :term:`註釋 `。" -#: ../../glossary.rst:536 +#: ../../glossary.rst:587 msgid "" "For more details, see :ref:`generic alias types`, :pep:" "`483`, :pep:`484`, :pep:`585`, and the :mod:`typing` module." @@ -1230,19 +1335,19 @@ msgstr "" "詳情請參閱\\ :ref:`泛型別名型別 `、:pep:`483`、:pep:" "`484`、:pep:`585` 和 :mod:`typing` 模組。" -#: ../../glossary.rst:538 +#: ../../glossary.rst:589 msgid "GIL" msgstr "GIL" -#: ../../glossary.rst:540 +#: ../../glossary.rst:591 msgid "See :term:`global interpreter lock`." msgstr "請參閱 :term:`global interpreter lock`\\ (全域直譯器鎖)。" -#: ../../glossary.rst:541 +#: ../../glossary.rst:592 msgid "global interpreter lock" msgstr "global interpreter lock(全域直譯器鎖)" -#: ../../glossary.rst:543 +#: ../../glossary.rst:594 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 " @@ -1259,7 +1364,7 @@ msgstr "" "(multi-threaded),但代價是會犧牲掉多處理器的機器能夠提供的一大部分平行性 " "(parallelism)。" -#: ../../glossary.rst:552 +#: ../../glossary.rst:603 msgid "" "However, some extension modules, either standard or third-party, are " "designed so as to release the GIL when doing computationally intensive tasks " @@ -1270,21 +1375,21 @@ msgstr "" "計算密集 (computationally intensive) 的任務時,可以解除 GIL。另外,在執行 I/" "O 時,GIL 總是會被解除。" -#: ../../glossary.rst:557 +#: ../../glossary.rst:608 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 " -"run with :option:`-X gil 0 <-X>` or after setting the :envvar:`PYTHON_GIL=0 " +"run with :option:`-X gil=0 <-X>` or after setting the :envvar:`PYTHON_GIL=0 " "` environment variable. This feature enables improved " "performance for multi-threaded applications and makes it easier to use multi-" "core CPUs efficiently. For more details, see :pep:`703`." msgstr "" -#: ../../glossary.rst:563 +#: ../../glossary.rst:614 msgid "hash-based pyc" msgstr "hash-based pyc(雜湊架構的 pyc)" -#: ../../glossary.rst:565 +#: ../../glossary.rst:616 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-" @@ -1293,11 +1398,11 @@ msgstr "" "一個位元組碼 (bytecode) 暫存檔,它使用雜湊值而不是對應原始檔案的最後修改時" "間,來確定其有效性。請參閱\\ :ref:`pyc-invalidation`。" -#: ../../glossary.rst:568 +#: ../../glossary.rst:619 msgid "hashable" msgstr "hashable(可雜湊的)" -#: ../../glossary.rst:570 +#: ../../glossary.rst:621 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 " @@ -1309,7 +1414,7 @@ msgstr "" "`~object.__eq__` method),那麼它就是一個\\ *可雜湊*\\ 物件。比較結果為相等的" "多個可雜湊物件,它們必須擁有相同的雜湊值。" -#: ../../glossary.rst:576 +#: ../../glossary.rst:627 msgid "" "Hashability makes an object usable as a dictionary key and a set member, " "because these data structures use the hash value internally." @@ -1317,7 +1422,7 @@ msgstr "" "可雜湊性 (hashability) 使一個物件可用作 dictionary(字典)的鍵和 set(集合)" "的成員,因為這些資料結構都在其內部使用了雜湊值。" -#: ../../glossary.rst:579 +#: ../../glossary.rst:630 msgid "" "Most of Python's immutable built-in objects are hashable; mutable containers " "(such as lists or dictionaries) are not; immutable containers (such as " @@ -1332,11 +1437,11 @@ msgstr "" "則這些物件會被預設為可雜湊的。它們在互相比較時都是不相等的(除非它們與自己比" "較),而它們的雜湊值則是衍生自它們的 :func:`id`。" -#: ../../glossary.rst:586 +#: ../../glossary.rst:637 msgid "IDLE" msgstr "IDLE" -#: ../../glossary.rst:588 +#: ../../glossary.rst:639 msgid "" "An Integrated Development and Learning Environment for Python. :ref:`idle` " "is a basic editor and interpreter environment which ships with the standard " @@ -1346,28 +1451,28 @@ msgstr "" "境)。:ref:`idle` 是一個基本的編輯器和直譯器環境,它和 Python 的標準發行版本" "一起被提供。" -#: ../../glossary.rst:591 +#: ../../glossary.rst:642 msgid "immortal" msgstr "" -#: ../../glossary.rst:593 +#: ../../glossary.rst:644 msgid "" "*Immortal objects* are a CPython implementation detail introduced in :pep:" "`683`." msgstr "" -#: ../../glossary.rst:596 +#: ../../glossary.rst:647 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 " "example, :const:`True` and :const:`None` are immortal in CPython." msgstr "" -#: ../../glossary.rst:599 +#: ../../glossary.rst:650 msgid "immutable" msgstr "immutable(不可變物件)" -#: ../../glossary.rst:601 +#: ../../glossary.rst:652 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 " @@ -1379,11 +1484,11 @@ msgstr "" "能被改變的。如果一個不同的值必須被儲存,則必須建立一個新的物件。它們在需要恆" "定雜湊值的地方,扮演重要的角色,例如 dictionary(字典)中的一個鍵。" -#: ../../glossary.rst:606 +#: ../../glossary.rst:657 msgid "import path" msgstr "import path(引入路徑)" -#: ../../glossary.rst:608 +#: ../../glossary.rst:659 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 " @@ -1395,11 +1500,11 @@ msgstr "" "的位置。在 import 期間,此位置列表通常是來自 :data:`sys.path`,但對於子套件 " "(subpackage) 而言,它也可能是來自父套件的 ``__path__`` 屬性。" -#: ../../glossary.rst:613 +#: ../../glossary.rst:664 msgid "importing" msgstr "importing(引入)" -#: ../../glossary.rst:615 +#: ../../glossary.rst:666 msgid "" "The process by which Python code in one module is made available to Python " "code in another module." @@ -1407,11 +1512,11 @@ msgstr "" "一個過程。一個模組中的 Python 程式碼可以透過此過程,被另一個模組中的 Python " "程式碼使用。" -#: ../../glossary.rst:617 +#: ../../glossary.rst:668 msgid "importer" msgstr "importer(引入器)" -#: ../../glossary.rst:619 +#: ../../glossary.rst:670 msgid "" "An object that both finds and loads a module; both a :term:`finder` and :" "term:`loader` object." @@ -1419,11 +1524,11 @@ msgstr "" "一個能夠尋找及載入模組的物件;它既是 :term:`finder`\\ (尋檢器)也是 :term:" "`loader`\\ (載入器)物件。" -#: ../../glossary.rst:621 +#: ../../glossary.rst:672 msgid "interactive" msgstr "interactive(互動的)" -#: ../../glossary.rst:623 +#: ../../glossary.rst:674 msgid "" "Python has an interactive interpreter which means you can enter statements " "and expressions at the interpreter prompt, immediately execute them and see " @@ -1437,11 +1542,11 @@ msgstr "" "從你的電腦的主選單選擇它)。這是測試新想法或檢查模塊和包的非常強大的方法(請" "記住help(x))。更多互動式模式相關資訊請見 :ref:`tut-interac`。" -#: ../../glossary.rst:630 +#: ../../glossary.rst:681 msgid "interpreted" msgstr "interpreted(直譯的)" -#: ../../glossary.rst:632 +#: ../../glossary.rst:683 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. " @@ -1455,11 +1560,11 @@ msgstr "" "一個執行檔,然後再執行它。直譯語言通常比編譯語言有更短的開發/除錯週期,不過" "它們的程式通常也運行得較慢。另請參閱 :term:`interactive`\\ (互動的)。" -#: ../../glossary.rst:639 +#: ../../glossary.rst:690 msgid "interpreter shutdown" msgstr "interpreter shutdown(直譯器關閉)" -#: ../../glossary.rst:641 +#: ../../glossary.rst:692 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 " @@ -1477,25 +1582,26 @@ msgstr "" "段被執行的程式碼會遇到各種例外,因為它所依賴的資源可能不再有作用了(常見的例" "子是函式庫模組或是警告機制)。" -#: ../../glossary.rst:650 +#: ../../glossary.rst:701 msgid "" "The main reason for interpreter shutdown is that the ``__main__`` module or " "the script being run has finished executing." msgstr "" "直譯器關閉的主要原因,是 ``__main__`` 模組或正被運行的腳本已經執行完成。" -#: ../../glossary.rst:652 +#: ../../glossary.rst:703 msgid "iterable" msgstr "iterable(可疊代物件)" -#: ../../glossary.rst:654 +#: ../../glossary.rst:705 +#, fuzzy 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`, " "and :class:`tuple`) and some non-sequence types like :class:`dict`, :term:" "`file objects `, and objects of any classes you define with an :" -"meth:`~iterator.__iter__` method or with a :meth:`~object.__getitem__` " -"method that implements :term:`sequence` semantics." +"meth:`~object.__iter__` method or with a :meth:`~object.__getitem__` method " +"that implements :term:`sequence` semantics." msgstr "" "一種能夠一次回傳一個其中成員的物件。可疊代物件的例子包括所有的序列型別(像" "是 :class:`list`、:class:`str` 和 :class:`tuple`\\ )和某些非序列型別,像是 :" @@ -1504,7 +1610,7 @@ msgstr "" "`sequence`\\ (序列)語意的 :meth:`~object.__getitem__` method,該物件就是可" "疊代物件。" -#: ../../glossary.rst:662 +#: ../../glossary.rst:713 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 " @@ -1524,11 +1630,11 @@ msgstr "" "數,用於在迴圈期間保有該疊代器。另請參閱 :term:`iterator`\\ (疊代器)、:" "term:`sequence`\\ (序列)和 :term:`generator`\\ (產生器)。" -#: ../../glossary.rst:672 +#: ../../glossary.rst:723 msgid "iterator" msgstr "iterator(疊代器)" -#: ../../glossary.rst:674 +#: ../../glossary.rst:725 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 :" @@ -1557,11 +1663,11 @@ msgstr "" "此事(多遍疊代)時,只會回傳在前一遍疊代中被用過的、同一個已被用盡的疊代器物" "件,使其看起來就像一個空的容器。" -#: ../../glossary.rst:689 +#: ../../glossary.rst:740 msgid "More information can be found in :ref:`typeiter`." msgstr "在\\ :ref:`typeiter`\\ 文中可以找到更多資訊。" -#: ../../glossary.rst:693 +#: ../../glossary.rst:744 #, fuzzy msgid "" "CPython does not consistently apply the requirement that an iterator define :" @@ -1571,11 +1677,11 @@ msgstr "" "CPython 並不是始終如一地都會檢查「疊代器有定義 :meth:`~iterator." "__iter__`\\ 」這個規定。" -#: ../../glossary.rst:698 +#: ../../glossary.rst:749 msgid "key function" msgstr "key function(鍵函式)" -#: ../../glossary.rst:700 +#: ../../glossary.rst:751 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 " @@ -1585,7 +1691,7 @@ msgstr "" "一個用於排序 (sorting) 或定序 (ordering) 的值。例如,:func:`locale.strxfrm` " "被用來產生一個了解區域特定排序慣例的排序鍵。" -#: ../../glossary.rst:705 +#: ../../glossary.rst:756 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`, :" @@ -1597,7 +1703,7 @@ msgstr "" "merge`、:func:`heapq.nsmallest`、:func:`heapq.nlargest` 和 :func:`itertools." "groupby`。" -#: ../../glossary.rst:711 +#: ../../glossary.rst:762 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. " @@ -1614,19 +1720,19 @@ msgstr "" "式 (constructor)。關於如何建立和使用鍵函式的範例,請參閱\\ :ref:`如何排序 " "`。" -#: ../../glossary.rst:718 +#: ../../glossary.rst:769 msgid "keyword argument" msgstr "keyword argument(關鍵字引數)" -#: ../../glossary.rst:720 ../../glossary.rst:1019 +#: ../../glossary.rst:771 ../../glossary.rst:1086 msgid "See :term:`argument`." msgstr "請參閱 :term:`argument`\\ (引數)。" -#: ../../glossary.rst:721 +#: ../../glossary.rst:772 msgid "lambda" msgstr "lambda" -#: ../../glossary.rst:723 +#: ../../glossary.rst:774 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 " @@ -1636,11 +1742,11 @@ msgstr "" "function),於該函式被呼叫時求值。建立 lambda 函式的語法是 ``lambda " "[parameters]: expression``" -#: ../../glossary.rst:726 +#: ../../glossary.rst:777 msgid "LBYL" msgstr "LBYL" -#: ../../glossary.rst:728 +#: ../../glossary.rst:779 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` " @@ -1651,7 +1757,7 @@ msgstr "" "地測試先決條件。這種風格與 :term:`EAFP` 方式形成對比,且它的特色是會有許多 :" "keyword:`if` 陳述式的存在。" -#: ../../glossary.rst:733 +#: ../../glossary.rst:784 msgid "" "In a multi-threaded environment, the LBYL approach can risk introducing a " "race condition between \"the looking\" and \"the leaping\". For example, " @@ -1665,11 +1771,19 @@ msgstr "" "了 *key*,則該程式碼就會失效。這個問題可以用鎖 (lock) 或使用 EAFP 編碼方式來" "解決。" -#: ../../glossary.rst:738 +#: ../../glossary.rst:789 +msgid "lexical analyzer" +msgstr "" + +#: ../../glossary.rst:792 +msgid "Formal name for the *tokenizer*; see :term:`token`." +msgstr "" + +#: ../../glossary.rst:793 msgid "list" msgstr "list(串列)" -#: ../../glossary.rst:740 +#: ../../glossary.rst:795 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 " @@ -1679,11 +1793,11 @@ msgstr "" "似其他語言中的一個陣列 (array) 而較不像一個鏈結串列 (linked list),因為存取元" "素的時間複雜度是 *O*\\ (1)。" -#: ../../glossary.rst:743 +#: ../../glossary.rst:798 msgid "list comprehension" msgstr "list comprehension(串列綜合運算)" -#: ../../glossary.rst:745 +#: ../../glossary.rst:800 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 " @@ -1697,27 +1811,41 @@ msgstr "" "keyword:`if` 子句是選擇性的。如果省略它,則 ``range(256)`` 中的所有元素都會被" "處理。" -#: ../../glossary.rst:751 +#: ../../glossary.rst:806 msgid "loader" msgstr "loader(載入器)" -#: ../../glossary.rst:753 +#: ../../glossary.rst:808 +#, fuzzy msgid "" -"An object that loads a module. It must define a method named :meth:" -"`load_module`. A loader is typically returned by a :term:`finder`. See :pep:" -"`302` for details and :class:`importlib.abc.Loader` for an :term:`abstract " -"base class`." +"An object that loads a module. It must define the :meth:`!exec_module` and :" +"meth:`!create_module` methods to implement the :class:`~importlib.abc." +"Loader` interface. A loader is typically returned by a :term:`finder`. See " +"also:" msgstr "" "一個能夠載入模組的物件。它必須定義一個名為 :meth:`load_module` 的 method(方" "法)。載入器通常是被 :term:`finder`\\ (尋檢器)回傳。更多細節請參閱 :pep:" "`302`,關於 :term:`abstract base class`\\ (抽象基底類別),請參閱 :class:" "`importlib.abc.Loader`。" -#: ../../glossary.rst:757 +#: ../../glossary.rst:814 +msgid ":ref:`finders-and-loaders`" +msgstr "" + +#: ../../glossary.rst:815 +msgid ":class:`importlib.abc.Loader`" +msgstr "" + +#: ../../glossary.rst:816 +#, fuzzy +msgid ":pep:`302`" +msgstr "請參閱 :pep:`1`。" + +#: ../../glossary.rst:817 msgid "locale encoding" msgstr "locale encoding(區域編碼)" -#: ../../glossary.rst:759 +#: ../../glossary.rst:819 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) `." @@ -1725,36 +1853,36 @@ msgstr "" "在 Unix 上,它是 LC_CTYPE 區域設定的編碼。它可以用 :func:`locale." "setlocale(locale.LC_CTYPE, new_locale) ` 來設定。" -#: ../../glossary.rst:762 +#: ../../glossary.rst:822 msgid "On Windows, it is the ANSI code page (ex: ``\"cp1252\"``)." msgstr "在 Windows 上,它是 ANSI 代碼頁(code page,例如 ``\"cp1252\"``\\ )。" -#: ../../glossary.rst:764 +#: ../../glossary.rst:824 msgid "" "On Android and VxWorks, Python uses ``\"utf-8\"`` as the locale encoding." msgstr "在 Android 和 VxWorks 上,Python 使用 ``\"utf-8\"`` 作為區域編碼。" -#: ../../glossary.rst:766 +#: ../../glossary.rst:826 msgid ":func:`locale.getencoding` can be used to get the locale encoding." msgstr ":func:`locale.getencoding` 可以用來取得區域編碼。" -#: ../../glossary.rst:768 +#: ../../glossary.rst:828 msgid "See also the :term:`filesystem encoding and error handler`." msgstr "也請參考 :term:`filesystem encoding and error handler`。" -#: ../../glossary.rst:769 +#: ../../glossary.rst:829 msgid "magic method" msgstr "magic method(魔術方法)" -#: ../../glossary.rst:773 +#: ../../glossary.rst:833 msgid "An informal synonym for :term:`special method`." msgstr ":term:`special method`\\ (特殊方法)的一個非正式同義詞。" -#: ../../glossary.rst:774 +#: ../../glossary.rst:834 msgid "mapping" msgstr "mapping(對映)" -#: ../../glossary.rst:776 +#: ../../glossary.rst:836 msgid "" "A container object that supports arbitrary key lookups and implements the " "methods specified in the :class:`collections.abc.Mapping` or :class:" @@ -1769,11 +1897,11 @@ msgstr "" "包括 :class:`dict`、:class:`collections.defaultdict`、:class:`collections." "OrderedDict` 和 :class:`collections.Counter`。" -#: ../../glossary.rst:782 +#: ../../glossary.rst:842 msgid "meta path finder" msgstr "meta path finder(元路徑尋檢器)" -#: ../../glossary.rst:784 +#: ../../glossary.rst:844 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:788 +#: ../../glossary.rst:848 msgid "" "See :class:`importlib.abc.MetaPathFinder` for the methods that meta path " "finders implement." msgstr "" "關於元路徑尋檢器實作的 method,請參閱 :class:`importlib.abc.MetaPathFinder`。" -#: ../../glossary.rst:790 +#: ../../glossary.rst:850 msgid "metaclass" msgstr "metaclass(元類別)" -#: ../../glossary.rst:792 +#: ../../glossary.rst:852 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 " @@ -1814,15 +1942,15 @@ msgstr "" "性存取、增加執行緒安全性、追蹤物件建立、實作單例模式 (singleton),以及許多其" "他的任務。" -#: ../../glossary.rst:802 +#: ../../glossary.rst:862 msgid "More information can be found in :ref:`metaclasses`." msgstr "更多資訊可以在\\ :ref:`metaclasses`\\ 章節中找到。" -#: ../../glossary.rst:771 ../../glossary.rst:803 ../../glossary.rst:1168 +#: ../../glossary.rst:831 ../../glossary.rst:863 ../../glossary.rst:1231 msgid "method" msgstr "method(方法)" -#: ../../glossary.rst:805 +#: ../../glossary.rst:865 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 " @@ -1834,11 +1962,11 @@ msgstr "" "通常被稱為 ``self``)。請參閱 :term:`function`\\ (函式)和 :term:`nested " "scope`\\ (巢狀作用域)。" -#: ../../glossary.rst:809 +#: ../../glossary.rst:869 msgid "method resolution order" msgstr "method resolution order(方法解析順序)" -#: ../../glossary.rst:811 +#: ../../glossary.rst:871 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 " @@ -1847,11 +1975,11 @@ msgstr "" "方法解析順序是在查找某個成員的過程中,base class(基底類別)被搜尋的順序。關" "於 Python 自 2.3 版直譯器所使用的演算法細節,請參閱 :ref:`python_2.3_mro`。" -#: ../../glossary.rst:814 +#: ../../glossary.rst:874 msgid "module" msgstr "module(模組)" -#: ../../glossary.rst:816 +#: ../../glossary.rst:876 msgid "" "An object that serves as an organizational unit of Python code. Modules " "have a namespace containing arbitrary Python objects. Modules are loaded " @@ -1861,15 +1989,15 @@ msgstr "" "空間,它包含任意的 Python 物件。模組是藉由 :term:`importing` 的過程,被載入" "至 Python。" -#: ../../glossary.rst:820 +#: ../../glossary.rst:880 msgid "See also :term:`package`." msgstr "另請參閱 :term:`package`\\ (套件)。" -#: ../../glossary.rst:821 +#: ../../glossary.rst:881 msgid "module spec" msgstr "module spec(模組規格)" -#: ../../glossary.rst:823 +#: ../../glossary.rst:883 msgid "" "A namespace containing the import-related information used to load a module. " "An instance of :class:`importlib.machinery.ModuleSpec`." @@ -1877,19 +2005,24 @@ msgstr "" "一個命名空間,它包含用於載入模組的 import 相關資訊。它是 :class:`importlib." "machinery.ModuleSpec` 的一個實例。" -#: ../../glossary.rst:825 +#: ../../glossary.rst:886 +#, fuzzy +msgid "See also :ref:`module-specs`." +msgstr "另請參閱 :term:`module`\\ (模組)。" + +#: ../../glossary.rst:887 msgid "MRO" msgstr "MRO" -#: ../../glossary.rst:827 +#: ../../glossary.rst:889 msgid "See :term:`method resolution order`." msgstr "請參閱 :term:`method resolution order`\\ (方法解析順序)。" -#: ../../glossary.rst:828 +#: ../../glossary.rst:890 msgid "mutable" msgstr "mutable(可變物件)" -#: ../../glossary.rst:830 +#: ../../glossary.rst:892 msgid "" "Mutable objects can change their value but keep their :func:`id`. See also :" "term:`immutable`." @@ -1897,11 +2030,11 @@ msgstr "" "可變物件可以改變它們的值,但維持它們的 :func:`id`。另請參閱 :term:" "`immutable`\\ (不可變物件)。" -#: ../../glossary.rst:832 +#: ../../glossary.rst:894 msgid "named tuple" msgstr "named tuple(附名元組)" -#: ../../glossary.rst:834 +#: ../../glossary.rst:896 msgid "" "The term \"named tuple\" applies to any type or class that inherits from " "tuple and whose indexable elements are also accessible using named " @@ -1911,7 +2044,7 @@ msgstr "" "索引 (indexable) 元素也可以用附名屬性來存取。這些型別或 class 也可以具有其他" "的特性。" -#: ../../glossary.rst:838 +#: ../../glossary.rst:900 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." @@ -1920,7 +2053,7 @@ msgstr "" "有些內建型別是 named tuple,包括由 :func:`time.localtime` 和 :func:`os.stat` " "回傳的值。另一個例子是 :data:`sys.float_info`: ::" -#: ../../glossary.rst:842 +#: ../../glossary.rst:904 msgid "" ">>> sys.float_info[1] # indexed access\n" "1024\n" @@ -1930,7 +2063,7 @@ msgid "" "True" msgstr "" -#: ../../glossary.rst:849 +#: ../../glossary.rst:911 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 " @@ -1947,11 +2080,11 @@ msgstr "" "namedtuple` 來建立。後者技術也增加了一些額外的 method,這些 method 可能是在手" "寫或內建的 named tuple 中,無法找到的。" -#: ../../glossary.rst:857 +#: ../../glossary.rst:919 msgid "namespace" msgstr "namespace(命名空間)" -#: ../../glossary.rst:859 +#: ../../glossary.rst:921 msgid "" "The place where a variable is stored. Namespaces are implemented as " "dictionaries. There are the local, global and built-in namespaces as well " @@ -1971,30 +2104,42 @@ msgstr "" "func:`itertools.islice` 明確地表示,這些函式分別是由 :mod:`random` 和 :mod:" "`itertools` 模組在實作。" -#: ../../glossary.rst:869 +#: ../../glossary.rst:931 msgid "namespace package" msgstr "namespace package(命名空間套件)" -#: ../../glossary.rst:871 +#: ../../glossary.rst:933 +#, fuzzy msgid "" -"A :pep:`420` :term:`package` which serves only as a container for " -"subpackages. Namespace packages may have no physical representation, and " -"specifically are not like a :term:`regular package` because they have no " -"``__init__.py`` file." +"A :term:`package` which serves only as a container for subpackages. " +"Namespace packages may have no physical representation, and specifically are " +"not like a :term:`regular package` because they have no ``__init__.py`` file." msgstr "" "一個 :pep:`420` :term:`package`\\ (套件),它只能作為子套件 (subpackage) 的" "一個容器。命名空間套件可能沒有實體的表示法,而且具體來說它們不像是一個 :term:" "`regular package`\\ (正規套件),因為它們並沒有 ``__init__.py`` 這個檔案。" -#: ../../glossary.rst:876 +#: ../../glossary.rst:938 +msgid "" +"Namespace packages allow several individually installable packages to have a " +"common parent package. Otherwise, it is recommended to use a :term:`regular " +"package`." +msgstr "" + +#: ../../glossary.rst:941 +msgid "" +"For more information, see :pep:`420` and :ref:`reference-namespace-package`." +msgstr "" + +#: ../../glossary.rst:943 msgid "See also :term:`module`." msgstr "另請參閱 :term:`module`\\ (模組)。" -#: ../../glossary.rst:877 +#: ../../glossary.rst:944 msgid "nested scope" msgstr "nested scope(巢狀作用域)" -#: ../../glossary.rst:879 +#: ../../glossary.rst:946 msgid "" "The ability to refer to a variable in an enclosing definition. For " "instance, a function defined inside another function can refer to variables " @@ -2009,11 +2154,11 @@ msgstr "" "寫入。同樣地,全域變數是在全域命名空間中讀取及寫入。:keyword:`nonlocal` 容許" "對外層作用域進行寫入。" -#: ../../glossary.rst:886 +#: ../../glossary.rst:953 msgid "new-style class" msgstr "new-style class(新式類別)" -#: ../../glossary.rst:888 +#: ../../glossary.rst:955 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, " @@ -2025,11 +2170,11 @@ msgstr "" "__slots__`、描述器 (descriptor)、屬性 (property)、:meth:`~object." "__getattribute__`、class method(類別方法)和 static method(靜態方法)。" -#: ../../glossary.rst:893 +#: ../../glossary.rst:960 msgid "object" msgstr "object(物件)" -#: ../../glossary.rst:895 +#: ../../glossary.rst:962 msgid "" "Any data with state (attributes or value) and defined behavior (methods). " "Also the ultimate base class of any :term:`new-style class`." @@ -2037,11 +2182,11 @@ msgstr "" "具有狀態(屬性或值)及被定義的行為(method)的任何資料。它也是任何 :term:" "`new-style class`\\ (新式類別)的最終 base class(基底類別)。" -#: ../../glossary.rst:898 +#: ../../glossary.rst:965 msgid "optimized scope" msgstr "optimized scope(最佳化作用域)" -#: ../../glossary.rst:900 +#: ../../glossary.rst:967 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 " @@ -2052,11 +2197,11 @@ msgid "" "to optimized scopes." msgstr "" -#: ../../glossary.rst:907 +#: ../../glossary.rst:974 msgid "package" msgstr "package(套件)" -#: ../../glossary.rst:909 +#: ../../glossary.rst:976 msgid "" "A Python :term:`module` which can contain submodules or recursively, " "subpackages. Technically, a package is a Python module with a ``__path__`` " @@ -2066,17 +2211,17 @@ msgstr "" "迴的子套件 (subpackage)。技術上而言,套件就是具有 ``__path__`` 屬性的一個 " "Python 模組。" -#: ../../glossary.rst:913 +#: ../../glossary.rst:980 msgid "See also :term:`regular package` and :term:`namespace package`." msgstr "" "另請參閱 :term:`regular package`\\ (正規套件)和 :term:`namespace " "package`\\ (命名空間套件)。" -#: ../../glossary.rst:914 +#: ../../glossary.rst:981 msgid "parameter" msgstr "parameter(參數)" -#: ../../glossary.rst:916 +#: ../../glossary.rst:983 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 " @@ -2086,7 +2231,7 @@ msgstr "" "它指明該函式能夠接受的一個 :term:`argument`\\ (引數),或在某些情況下指示多" "個引數。共有有五種不同的參數類型:" -#: ../../glossary.rst:920 +#: ../../glossary.rst:987 msgid "" ":dfn:`positional-or-keyword`: specifies an argument that can be passed " "either :term:`positionally ` or as a :term:`keyword argument " @@ -2097,11 +2242,11 @@ msgstr "" "置 `\\ 或是作為\\ :term:`關鍵字引數 `\\ 被傳遞的引數。這" "是參數的預設類型,例如以下的 *foo* 和 *bar*: ::" -#: ../../glossary.rst:925 +#: ../../glossary.rst:992 msgid "def func(foo, bar=None): ..." msgstr "def func(foo, bar=None): ..." -#: ../../glossary.rst:929 +#: ../../glossary.rst:996 msgid "" ":dfn:`positional-only`: specifies an argument that can be supplied only by " "position. Positional-only parameters can be defined by including a ``/`` " @@ -2112,11 +2257,11 @@ msgstr "" "式定義的參數列表中包含一個 ``/`` 字元,就可以在該字元前面定義僅限位置參數,例" "如以下的 *posonly1* 和 *posonly2*: ::" -#: ../../glossary.rst:934 +#: ../../glossary.rst:1001 msgid "def func(posonly1, posonly2, /, positional_or_keyword): ..." msgstr "def func(posonly1, posonly2, /, positional_or_keyword): ..." -#: ../../glossary.rst:938 +#: ../../glossary.rst:1005 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-" @@ -2129,11 +2274,11 @@ msgstr "" "單純的 ``*`` 字元,就可以在其後方定義僅限關鍵字參數,例如以下的 *kw_only1* " "和 *kw_only2*: ::" -#: ../../glossary.rst:944 +#: ../../glossary.rst:1011 msgid "def func(arg, *, kw_only1, kw_only2): ..." msgstr "def func(arg, *, kw_only1, kw_only2): ..." -#: ../../glossary.rst:946 +#: ../../glossary.rst:1013 msgid "" ":dfn:`var-positional`: specifies that an arbitrary sequence of positional " "arguments can be provided (in addition to any positional arguments already " @@ -2145,11 +2290,11 @@ msgstr "" "數(在已被其他參數接受的任何位置引數之外)。這類參數是透過在其參數名稱字首加" "上 ``*`` 來定義的,例如以下的 *args*: ::" -#: ../../glossary.rst:952 +#: ../../glossary.rst:1019 msgid "def func(*args, **kwargs): ..." msgstr "def func(*args, **kwargs): ..." -#: ../../glossary.rst:954 +#: ../../glossary.rst:1021 msgid "" ":dfn:`var-keyword`: specifies that arbitrarily many keyword arguments can be " "provided (in addition to any keyword arguments already accepted by other " @@ -2160,14 +2305,14 @@ msgstr "" "已被其他參數接受的任何關鍵字引數之外)。這類參數是透過在其參數名稱字首加上 " "``**`` 來定義的,例如上面範例中的 *kwargs*。" -#: ../../glossary.rst:960 +#: ../../glossary.rst:1027 msgid "" "Parameters can specify both optional and required arguments, as well as " "default values for some optional arguments." msgstr "" "參數可以指明引數是選擇性的或必需的,也可以為一些選擇性的引數指定預設值。" -#: ../../glossary.rst:963 +#: ../../glossary.rst:1030 msgid "" "See also the :term:`argument` glossary entry, the FAQ question on :ref:`the " "difference between arguments and parameters `, " @@ -2178,11 +2323,11 @@ msgstr "" "參數之間的差異 `、:class:`inspect.Parameter` " "class、:ref:`function`\\ 章節,以及 :pep:`362`。" -#: ../../glossary.rst:967 +#: ../../glossary.rst:1034 msgid "path entry" msgstr "path entry(路徑項目)" -#: ../../glossary.rst:969 +#: ../../glossary.rst:1036 msgid "" "A single location on the :term:`import path` which the :term:`path based " "finder` consults to find modules for importing." @@ -2190,11 +2335,11 @@ msgstr "" "在 :term:`import path`\\ (引入路徑)中的一個位置,而 :term:`path based " "finder` (基於路徑的尋檢器)會參考該位置來尋找要 import 的模組。" -#: ../../glossary.rst:971 +#: ../../glossary.rst:1038 msgid "path entry finder" msgstr "path entry finder(路徑項目尋檢器)" -#: ../../glossary.rst:973 +#: ../../glossary.rst:1040 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:" @@ -2204,7 +2349,7 @@ msgstr "" "`path entry hook`\\ )所回傳的一種 :term:`finder`,它知道如何以一個 :term:" "`path entry`\\ 定位模組。" -#: ../../glossary.rst:977 +#: ../../glossary.rst:1044 msgid "" "See :class:`importlib.abc.PathEntryFinder` for the methods that path entry " "finders implement." @@ -2212,11 +2357,11 @@ msgstr "" "關於路徑項目尋檢器實作的 method,請參閱 :class:`importlib.abc." "PathEntryFinder`。" -#: ../../glossary.rst:979 +#: ../../glossary.rst:1046 msgid "path entry hook" msgstr "path entry hook(路徑項目鉤)" -#: ../../glossary.rst:981 +#: ../../glossary.rst:1048 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 " @@ -2226,11 +2371,11 @@ msgstr "" "個特定的 :term:`path entry` 中尋找模組,則會回傳一個 :term:`path entry " "finder`\\ (路徑項目尋檢器)。" -#: ../../glossary.rst:984 +#: ../../glossary.rst:1051 msgid "path based finder" msgstr "path based finder(基於路徑的尋檢器)" -#: ../../glossary.rst:986 +#: ../../glossary.rst:1053 msgid "" "One of the default :term:`meta path finders ` which " "searches an :term:`import path` for modules." @@ -2238,11 +2383,11 @@ msgstr "" "預設的\\ :term:`元路徑尋檢器 (meta path finder) ` 之一,它" "會在一個 :term:`import path` 中搜尋模組。" -#: ../../glossary.rst:988 +#: ../../glossary.rst:1055 msgid "path-like object" msgstr "path-like object(類路徑物件)" -#: ../../glossary.rst:990 +#: ../../glossary.rst:1057 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 " @@ -2260,11 +2405,11 @@ msgstr "" "`os.fsencode` 則分別可用於確保 :class:`str` 及 :class:`bytes` 的結果。由 :" "pep:`519` 引入。" -#: ../../glossary.rst:998 +#: ../../glossary.rst:1065 msgid "PEP" msgstr "PEP" -#: ../../glossary.rst:1000 +#: ../../glossary.rst:1067 msgid "" "Python Enhancement Proposal. A PEP is a design document providing " "information to the Python community, or describing a new feature for Python " @@ -2275,7 +2420,7 @@ msgstr "" "為 Python 社群提供資訊,或是描述 Python 的一個新功能或該功能的程序和環境。" "PEP 應該要提供簡潔的技術規範以及被提案功能的運作原理。" -#: ../../glossary.rst:1006 +#: ../../glossary.rst:1073 msgid "" "PEPs are intended to be the primary mechanisms for proposing major new " "features, for collecting community input on an issue, and for documenting " @@ -2287,15 +2432,15 @@ msgstr "" "已納入 Python 的設計決策的記錄,這些過程的主要機制。PEP 的作者要負責在社群內" "建立共識並記錄反對意見。" -#: ../../glossary.rst:1012 +#: ../../glossary.rst:1079 msgid "See :pep:`1`." msgstr "請參閱 :pep:`1`。" -#: ../../glossary.rst:1013 +#: ../../glossary.rst:1080 msgid "portion" msgstr "portion(部分)" -#: ../../glossary.rst:1015 +#: ../../glossary.rst:1082 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`." @@ -2303,15 +2448,15 @@ msgstr "" "在單一目錄中的一組檔案(也可能儲存在一個 zip 檔中),這些檔案能對一個命名空間" "套件 (namespace package) 有所貢獻,如同 :pep:`420` 中的定義。" -#: ../../glossary.rst:1017 +#: ../../glossary.rst:1084 msgid "positional argument" msgstr "positional argument(位置引數)" -#: ../../glossary.rst:1020 +#: ../../glossary.rst:1087 msgid "provisional API" msgstr "provisional API(暫行 API)" -#: ../../glossary.rst:1022 +#: ../../glossary.rst:1089 msgid "" "A provisional API is one which has been deliberately excluded from the " "standard library's backwards compatibility guarantees. While major changes " @@ -2327,7 +2472,7 @@ msgstr "" "該介面)。這種變更並不會無端地產生——只有 API 被納入之前未察覺的嚴重基本缺陷被" "揭露時,它們才會發生。" -#: ../../glossary.rst:1031 +#: ../../glossary.rst:1098 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 " @@ -2336,7 +2481,7 @@ msgstr "" "即使對於暫行 API,向後不相容的變更也會被視為「最後的解決方案」——對於任何被發" "現的問題,仍然會盡可能找出一個向後相容的解決方案。" -#: ../../glossary.rst:1035 +#: ../../glossary.rst:1102 msgid "" "This process allows the standard library to continue to evolve over time, " "without locking in problematic design errors for extended periods of time. " @@ -2345,19 +2490,19 @@ msgstr "" "這個過程使得標準函式庫能隨著時間不斷進化,而避免耗費過長的時間去鎖定有問題的" "設計錯誤。請參閱 :pep:`411` 了解更多細節。" -#: ../../glossary.rst:1038 +#: ../../glossary.rst:1105 msgid "provisional package" msgstr "provisional package(暫行套件)" -#: ../../glossary.rst:1040 +#: ../../glossary.rst:1107 msgid "See :term:`provisional API`." msgstr "請參閱 :term:`provisional API`\\ (暫行 API)。" -#: ../../glossary.rst:1041 +#: ../../glossary.rst:1108 msgid "Python 3000" msgstr "Python 3000" -#: ../../glossary.rst:1043 +#: ../../glossary.rst:1110 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 " @@ -2366,11 +2511,11 @@ msgstr "" "Python 3.x 系列版本的暱稱(很久以前創造的,當時第 3 版的發布是在遙遠的未" "來。)也可以縮寫為「Py3k」。" -#: ../../glossary.rst:1046 +#: ../../glossary.rst:1113 msgid "Pythonic" msgstr "Pythonic(Python 風格的)" -#: ../../glossary.rst:1048 +#: ../../glossary.rst:1115 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 " @@ -2384,7 +2529,7 @@ msgstr "" "keyword:`for` 陳述式,對一個可疊代物件的所有元素進行迴圈。許多其他語言並沒有" "這種類型的架構,所以不熟悉 Python 的人有時會使用一個數值計數器來代替: ::" -#: ../../glossary.rst:1055 +#: ../../glossary.rst:1122 msgid "" "for i in range(len(food)):\n" " print(food[i])" @@ -2392,11 +2537,11 @@ msgstr "" "for i in range(len(food)):\n" " print(food[i])" -#: ../../glossary.rst:1058 +#: ../../glossary.rst:1125 msgid "As opposed to the cleaner, Pythonic method::" msgstr "相較之下,以下方法更簡潔、更具有 Python 風格: ::" -#: ../../glossary.rst:1060 +#: ../../glossary.rst:1127 msgid "" "for piece in food:\n" " print(piece)" @@ -2404,11 +2549,11 @@ msgstr "" "for piece in food:\n" " print(piece)" -#: ../../glossary.rst:1062 +#: ../../glossary.rst:1129 msgid "qualified name" msgstr "qualified name(限定名稱)" -#: ../../glossary.rst:1064 +#: ../../glossary.rst:1131 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 " @@ -2419,7 +2564,7 @@ msgstr "" "或 method 的「路徑」,如 :pep:`3155` 中的定義。對於頂層的函式和 class 而言," "限定名稱與其物件名稱相同: ::" -#: ../../glossary.rst:1069 +#: ../../glossary.rst:1136 msgid "" ">>> class C:\n" "... class D:\n" @@ -2445,7 +2590,7 @@ msgstr "" ">>> C.D.meth.__qualname__\n" "'C.D.meth'" -#: ../../glossary.rst:1081 +#: ../../glossary.rst:1148 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." @@ -2454,7 +2599,7 @@ msgstr "" "當用於引用模組時,*完全限定名稱 (fully qualified name)* 是表示該模組的完整點" "分隔路徑,包括任何的父套件,例如 ``email.mime.text``: ::" -#: ../../glossary.rst:1085 +#: ../../glossary.rst:1152 msgid "" ">>> import email.mime.text\n" ">>> email.mime.text.__name__\n" @@ -2464,11 +2609,11 @@ msgstr "" ">>> email.mime.text.__name__\n" "'email.mime.text'" -#: ../../glossary.rst:1088 +#: ../../glossary.rst:1155 msgid "reference count" msgstr "reference count(參照計數)" -#: ../../glossary.rst:1090 +#: ../../glossary.rst:1157 #, fuzzy msgid "" "The number of references to an object. When the reference count of an " @@ -2485,11 +2630,11 @@ msgstr "" "`CPython` 實作的一個關鍵元素。程式設計師可以呼叫 :func:`~sys.getrefcount` 函" "式來回傳一個特定物件的參照計數。" -#: ../../glossary.rst:1098 +#: ../../glossary.rst:1165 msgid "regular package" msgstr "regular package(正規套件)" -#: ../../glossary.rst:1100 +#: ../../glossary.rst:1167 msgid "" "A traditional :term:`package`, such as a directory containing an ``__init__." "py`` file." @@ -2497,25 +2642,25 @@ msgstr "" "一個傳統的 :term:`package`\\ (套件),例如一個包含 ``__init__.py`` 檔案的目" "錄。" -#: ../../glossary.rst:1103 +#: ../../glossary.rst:1170 msgid "See also :term:`namespace package`." msgstr "另請參閱 :term:`namespace package`\\ (命名空間套件)。" -#: ../../glossary.rst:1104 +#: ../../glossary.rst:1171 msgid "REPL" msgstr "" -#: ../../glossary.rst:1106 +#: ../../glossary.rst:1173 msgid "" "An acronym for the \"read–eval–print loop\", another name for the :term:" "`interactive` interpreter shell." msgstr "" -#: ../../glossary.rst:1108 +#: ../../glossary.rst:1175 msgid "__slots__" msgstr "__slots__" -#: ../../glossary.rst:1110 +#: ../../glossary.rst:1177 msgid "" "A declaration inside a class that saves memory by pre-declaring space for " "instance attributes and eliminating instance dictionaries. Though popular, " @@ -2528,11 +2673,12 @@ msgstr "" "最好保留給那種在一個記憶體關鍵 (memory-critical) 的應用程式中存在大量實例的罕" "見情況。" -#: ../../glossary.rst:1115 +#: ../../glossary.rst:1182 msgid "sequence" msgstr "sequence(序列)" -#: ../../glossary.rst:1117 +#: ../../glossary.rst:1184 +#, fuzzy msgid "" "An :term:`iterable` which supports efficient element access using integer " "indices via the :meth:`~object.__getitem__` special method and defines a :" @@ -2540,8 +2686,8 @@ msgid "" "built-in sequence types are :class:`list`, :class:`str`, :class:`tuple`, " "and :class:`bytes`. Note that :class:`dict` also supports :meth:`~object." "__getitem__` and :meth:`!__len__`, but is considered a mapping rather than a " -"sequence because the lookups use arbitrary :term:`immutable` keys rather " -"than integers." +"sequence because the lookups use arbitrary :term:`hashable` keys rather than " +"integers." msgstr "" "一個 :term:`iterable`\\ (可疊代物件),它透過 :meth:`~object.__getitem__` " "special method(特殊方法),使用整數索引來支援高效率的元素存取,並定義了一" @@ -2551,7 +2697,7 @@ msgstr "" "為對映 (mapping) 而不是序列,因為其查找方式是使用任意的 :term:`immutable` " "鍵,而不是整數。" -#: ../../glossary.rst:1126 +#: ../../glossary.rst:1193 msgid "" "The :class:`collections.abc.Sequence` abstract base class defines a much " "richer interface that goes beyond just :meth:`~object.__getitem__` and :meth:" @@ -2568,11 +2714,11 @@ msgstr "" "用 :func:`~abc.ABCMeta.register` 被明確地註冊。更多關於序列方法的文件,請見" "\\ :ref:`常見序列操作 `。" -#: ../../glossary.rst:1135 +#: ../../glossary.rst:1202 msgid "set comprehension" msgstr "set comprehension(集合綜合運算)" -#: ../../glossary.rst:1137 +#: ../../glossary.rst:1204 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 " @@ -2583,11 +2729,11 @@ msgstr "" "set 回傳。``results = {c for c in 'abracadabra' if c not in 'abc'}`` 會產生一" "個字串 set:``{'r', 'd'}``。請參閱\\ :ref:`comprehensions`。" -#: ../../glossary.rst:1141 +#: ../../glossary.rst:1208 msgid "single dispatch" msgstr "single dispatch(單一調度)" -#: ../../glossary.rst:1143 +#: ../../glossary.rst:1210 msgid "" "A form of :term:`generic function` dispatch where the implementation is " "chosen based on the type of a single argument." @@ -2595,11 +2741,11 @@ msgstr "" ":term:`generic function`\\ (泛型函式)調度的一種形式,在此,實作的選擇是基於" "單一引數的型別。" -#: ../../glossary.rst:1145 +#: ../../glossary.rst:1212 msgid "slice" msgstr "slice(切片)" -#: ../../glossary.rst:1147 +#: ../../glossary.rst:1214 msgid "" "An object usually containing a portion of a :term:`sequence`. A slice is " "created using the subscript notation, ``[]`` with colons between numbers " @@ -2611,40 +2757,34 @@ msgstr "" "之間使用冒號,例如 ``variable_name[1:3:5]``。在括號(下標)符號的內部,會使" "用 :class:`slice` 物件。" -#: ../../glossary.rst:1151 +#: ../../glossary.rst:1218 msgid "soft deprecated" msgstr "" -#: ../../glossary.rst:1153 +#: ../../glossary.rst:1220 msgid "" -"A soft deprecation can be used when using an API which should no longer be " -"used to write new code, but it remains safe to continue using it in existing " -"code. The API remains documented and tested, but will not be developed " -"further (no enhancement)." +"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 " +"will not be enhanced further." msgstr "" -#: ../../glossary.rst:1158 +#: ../../glossary.rst:1224 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 "" - -#: ../../glossary.rst:1162 -msgid "Another difference is that a soft deprecation does not issue a warning." +"Soft deprecation, unlike normal deprecation, does not plan on removing the " +"API and will not emit warnings." msgstr "" -#: ../../glossary.rst:1164 +#: ../../glossary.rst:1227 msgid "" "See `PEP 387: Soft Deprecation `_." msgstr "" -#: ../../glossary.rst:1166 +#: ../../glossary.rst:1229 msgid "special method" msgstr "special method(特殊方法)" -#: ../../glossary.rst:1170 +#: ../../glossary.rst:1233 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 " @@ -2655,11 +2795,11 @@ msgstr "" "種 method 的名稱會在開頭和結尾有兩個下底線。Special method 在\\ :ref:" "`specialnames`\\ 中有詳細說明。" -#: ../../glossary.rst:1174 +#: ../../glossary.rst:1237 msgid "statement" msgstr "statement(陳述式)" -#: ../../glossary.rst:1176 +#: ../../glossary.rst:1239 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 :" @@ -2669,11 +2809,11 @@ msgstr "" "term:`expression`\\ (運算式),或是含有關鍵字(例如 :keyword:`if`、:keyword:" "`while` 或 :keyword:`for`\\ )的多種結構之一。" -#: ../../glossary.rst:1179 +#: ../../glossary.rst:1242 msgid "static type checker" msgstr "static type checker(靜態型別檢查器)" -#: ../../glossary.rst:1181 +#: ../../glossary.rst:1244 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 :" @@ -2683,11 +2823,11 @@ msgstr "" "另請參閱\\ :term:`型別提示 (type hints) ` 以及 :mod:`typing` 模" "組。" -#: ../../glossary.rst:1184 +#: ../../glossary.rst:1247 msgid "strong reference" msgstr "strong reference(強參照)" -#: ../../glossary.rst:1186 +#: ../../glossary.rst:1249 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 " @@ -2698,7 +2838,7 @@ msgstr "" "有。建立參照時透過呼叫 :c:func:`Py_INCREF` 來獲得強參照、刪除參照時透過 :c:" "func:`Py_DECREF` 釋放強參照。" -#: ../../glossary.rst:1192 +#: ../../glossary.rst:1255 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 " @@ -2708,15 +2848,15 @@ msgstr "" ":c:func:`Py_NewRef` 函式可用於建立一個對物件的強參照。通常,在退出強參照的作" "用域之前,必須在該強參照上呼叫 :c:func:`Py_DECREF` 函式,以避免洩漏一個參照。" -#: ../../glossary.rst:1197 +#: ../../glossary.rst:1260 msgid "See also :term:`borrowed reference`." msgstr "另請參閱 :term:`borrowed reference`\\ (借用參照)。" -#: ../../glossary.rst:1198 +#: ../../glossary.rst:1261 msgid "text encoding" msgstr "text encoding(文字編碼)" -#: ../../glossary.rst:1200 +#: ../../glossary.rst:1263 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 " @@ -2725,7 +2865,7 @@ msgstr "" "Python 中的字串是一個 Unicode 碼點 (code point) 的序列(範圍在 ``U+0000`` -- " "``U+10FFFF`` 之間)。若要儲存或傳送一個字串,它必須被序列化為一個位元組序列。" -#: ../../glossary.rst:1204 +#: ../../glossary.rst:1267 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\"." @@ -2733,7 +2873,7 @@ msgstr "" "將一個字串序列化為位元組序列,稱為「編碼」,而從位元組序列重新建立該字串則稱" "為「解碼 (decoding)」。" -#: ../../glossary.rst:1207 +#: ../../glossary.rst:1270 msgid "" "There are a variety of different text serialization :ref:`codecs `, which are collectively referred to as \"text encodings\"." @@ -2741,11 +2881,11 @@ msgstr "" "有多種不同的文字序列化編解碼器 (:ref:`codecs `),它們被統" "稱為「文字編碼」。" -#: ../../glossary.rst:1210 +#: ../../glossary.rst:1273 msgid "text file" msgstr "text file(文字檔案)" -#: ../../glossary.rst:1212 +#: ../../glossary.rst:1275 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:" @@ -2759,7 +2899,7 @@ msgstr "" "有:以文字模式(``'r'`` 或 ``'w'``)開啟的檔案、:data:`sys.stdin`、:data:" "`sys.stdout` 以及 :class:`io.StringIO` 的實例。" -#: ../../glossary.rst:1219 +#: ../../glossary.rst:1282 msgid "" "See also :term:`binary file` for a file object able to read and write :term:" "`bytes-like objects `." @@ -2767,11 +2907,28 @@ msgstr "" "另請參閱 :term:`binary file`\\ (二進位檔案),它是一個能夠讀取和寫入\\ :" "term:`類位元組串物件 (bytes-like object) ` 的檔案物件。" -#: ../../glossary.rst:1221 +#: ../../glossary.rst:1284 +msgid "token" +msgstr "" + +#: ../../glossary.rst:1287 +msgid "" +"A small unit of source code, generated by the :ref:`lexical analyzer " +"` (also called the *tokenizer*). Names, numbers, strings, " +"operators, newlines and similar are represented by tokens." +msgstr "" + +#: ../../glossary.rst:1292 +msgid "" +"The :mod:`tokenize` module exposes Python's lexical analyzer. The :mod:" +"`token` module contains information on the various types of tokens." +msgstr "" + +#: ../../glossary.rst:1295 msgid "triple-quoted string" msgstr "triple-quoted string(三引號內字串)" -#: ../../glossary.rst:1223 +#: ../../glossary.rst:1297 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 " @@ -2786,36 +2943,37 @@ msgstr "" "中包含未跳脫 (unescaped) 的單引號和雙引號,而且它們不需使用連續字元 " "(continuation character) 就可以跨越多行,這使得它們在編寫說明字串時特別有用。" -#: ../../glossary.rst:1230 +#: ../../glossary.rst:1304 msgid "type" msgstr "type(型別)" -#: ../../glossary.rst:1232 +#: ../../glossary.rst:1306 +#, fuzzy 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:`~instance." +"object has a type. An object's type is accessible as its :attr:`~object." "__class__` attribute or can be retrieved with ``type(obj)``." msgstr "" "一個 Python 物件的型別決定了它是什麼類型的物件;每個物件都有一個型別。一個物" "件的型別可以用它的 :attr:`~instance.__class__` 屬性來存取,或以 " "``type(obj)`` 來檢索。" -#: ../../glossary.rst:1236 +#: ../../glossary.rst:1310 msgid "type alias" msgstr "type alias(型別別名)" -#: ../../glossary.rst:1238 +#: ../../glossary.rst:1312 msgid "A synonym for a type, created by assigning the type to an identifier." msgstr "一個型別的同義詞,透過將型別指定給一個識別符 (identifier) 來建立。" -#: ../../glossary.rst:1240 +#: ../../glossary.rst:1314 msgid "" "Type aliases are useful for simplifying :term:`type hints `. For " "example::" msgstr "" "型別別名對於簡化\\ :term:`型別提示 (type hint) ` 很有用。例如: ::" -#: ../../glossary.rst:1243 +#: ../../glossary.rst:1317 msgid "" "def remove_gray_shades(\n" " colors: list[tuple[int, int, int]]) -> list[tuple[int, int, int]]:\n" @@ -2825,11 +2983,11 @@ msgstr "" " colors: list[tuple[int, int, int]]) -> list[tuple[int, int, int]]:\n" " pass" -#: ../../glossary.rst:1247 +#: ../../glossary.rst:1321 msgid "could be made more readable like this::" msgstr "可以寫成這樣,更具有可讀性: ::" -#: ../../glossary.rst:1249 +#: ../../glossary.rst:1323 msgid "" "Color = tuple[int, int, int]\n" "\n" @@ -2841,15 +2999,15 @@ msgstr "" "def remove_gray_shades(colors: list[Color]) -> list[Color]:\n" " pass" -#: ../../glossary.rst:1254 ../../glossary.rst:1268 +#: ../../glossary.rst:1328 ../../glossary.rst:1342 msgid "See :mod:`typing` and :pep:`484`, which describe this functionality." msgstr "請參閱 :mod:`typing` 和 :pep:`484`,有此功能的描述。" -#: ../../glossary.rst:1255 +#: ../../glossary.rst:1329 msgid "type hint" msgstr "type hint(型別提示)" -#: ../../glossary.rst:1257 +#: ../../glossary.rst:1331 msgid "" "An :term:`annotation` that specifies the expected type for a variable, a " "class attribute, or a function parameter or return value." @@ -2857,7 +3015,7 @@ msgstr "" "一種 :term:`annotation`\\ (註釋),它指定一個變數、一個 class 屬性或一個函式" "的參數或回傳值的預期型別。" -#: ../../glossary.rst:1260 +#: ../../glossary.rst:1334 msgid "" "Type hints are optional and are not enforced by Python but they are useful " "to :term:`static type checkers `. They can also aid " @@ -2867,7 +3025,7 @@ msgstr "" "(static type checkers) `\\ 很有用,並能協助 IDE 完成程式" "碼的補全 (completion) 和重構 (refactoring)。" -#: ../../glossary.rst:1264 +#: ../../glossary.rst:1338 msgid "" "Type hints of global variables, class attributes, and functions, but not " "local variables, can be accessed using :func:`typing.get_type_hints`." @@ -2875,11 +3033,11 @@ msgstr "" "全域變數、class 屬性和函式(不含區域變數)的型別提示,都可以使用 :func:" "`typing.get_type_hints` 來存取。" -#: ../../glossary.rst:1269 +#: ../../glossary.rst:1343 msgid "universal newlines" msgstr "universal newlines(通用換行字元)" -#: ../../glossary.rst:1271 +#: ../../glossary.rst:1345 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 " @@ -2892,20 +3050,20 @@ msgstr "" "``'\\r'``。請參閱 :pep:`278` 和 :pep:`3116`,以及用於 :func:`bytes." "splitlines` 的附加用途。" -#: ../../glossary.rst:1276 +#: ../../glossary.rst:1350 msgid "variable annotation" msgstr "variable annotation(變數註釋)" -#: ../../glossary.rst:1278 +#: ../../glossary.rst:1352 msgid "An :term:`annotation` of a variable or a class attribute." msgstr "一個變數或 class 屬性的 :term:`annotation`\\ (註釋)。" -#: ../../glossary.rst:1280 +#: ../../glossary.rst:1354 msgid "" "When annotating a variable or a class attribute, assignment is optional::" msgstr "註釋變數或 class 屬性時,賦值是選擇性的: ::" -#: ../../glossary.rst:1282 +#: ../../glossary.rst:1356 msgid "" "class C:\n" " field: 'annotation'" @@ -2913,7 +3071,7 @@ msgstr "" "class C:\n" " field: 'annotation'" -#: ../../glossary.rst:1285 +#: ../../glossary.rst:1359 msgid "" "Variable annotations are usually used for :term:`type hints `: " "for example this variable is expected to take :class:`int` values::" @@ -2921,15 +3079,15 @@ msgstr "" "變數註釋通常用於\\ :term:`型別提示 (type hint) `:例如,這個變數預" "期會取得 :class:`int`\\ (整數)值: ::" -#: ../../glossary.rst:1289 +#: ../../glossary.rst:1363 msgid "count: int = 0" msgstr "count: int = 0" -#: ../../glossary.rst:1291 +#: ../../glossary.rst:1365 msgid "Variable annotation syntax is explained in section :ref:`annassign`." msgstr "變數註釋的語法在\\ :ref:`annassign`\\ 章節有詳細的解釋。" -#: ../../glossary.rst:1293 +#: ../../glossary.rst:1367 msgid "" "See :term:`function annotation`, :pep:`484` and :pep:`526`, which describe " "this functionality. Also see :ref:`annotations-howto` for best practices on " @@ -2938,11 +3096,11 @@ msgstr "" "請參閱 :term:`function annotation`\\ (函式註釋)、:pep:`484` 和 :pep:`526`," "皆有此功能的描述。關於註釋的最佳實踐方法,另請參閱 :ref:`annotations-howto`。" -#: ../../glossary.rst:1297 +#: ../../glossary.rst:1371 msgid "virtual environment" msgstr "virtual environment(虛擬環境)" -#: ../../glossary.rst:1299 +#: ../../glossary.rst:1373 msgid "" "A cooperatively isolated runtime environment that allows Python users and " "applications to install and upgrade Python distribution packages without " @@ -2953,15 +3111,15 @@ msgstr "" "程式得以安裝和升級 Python 發佈套件,而不會對同一個系統上運行的其他 Python 應" "用程式的行為產生干擾。" -#: ../../glossary.rst:1304 +#: ../../glossary.rst:1378 msgid "See also :mod:`venv`." msgstr "另請參閱 :mod:`venv`。" -#: ../../glossary.rst:1305 +#: ../../glossary.rst:1379 msgid "virtual machine" msgstr "virtual machine(虛擬機器)" -#: ../../glossary.rst:1307 +#: ../../glossary.rst:1381 msgid "" "A computer defined entirely in software. Python's virtual machine executes " "the :term:`bytecode` emitted by the bytecode compiler." @@ -2969,11 +3127,11 @@ msgstr "" "一部完全由軟體所定義的電腦 (computer)。Python 的虛擬機器會執行由 :term:" "`bytecode`\\ (位元組碼)編譯器所發出的位元組碼。" -#: ../../glossary.rst:1309 +#: ../../glossary.rst:1383 msgid "Zen of Python" msgstr "Zen of Python(Python 之禪)" -#: ../../glossary.rst:1311 +#: ../../glossary.rst:1385 msgid "" "Listing of Python design principles and philosophies that are helpful in " "understanding and using the language. The listing can be found by typing " @@ -2982,22 +3140,45 @@ msgstr "" "Python 設計原則與哲學的列表,其內容有助於理解和使用此語言。此列表可以透過在互" "動式提式字元後輸入「``import this``」來找到它。" -#: ../../glossary.rst:256 +#: ../../glossary.rst:292 msgid "C-contiguous" msgstr "C-contiguous(C 連續的)" -#: ../../glossary.rst:256 +#: ../../glossary.rst:292 msgid "Fortran contiguous" msgstr "Fortran contiguous(Fortran 連續的)" -#: ../../glossary.rst:771 +#: ../../glossary.rst:831 msgid "magic" msgstr "magic" -#: ../../glossary.rst:1168 +#: ../../glossary.rst:1231 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 "2to3" #~ msgstr "2to3" diff --git a/howto/annotations.po b/howto/annotations.po index c4450542af..3c01650d00 100644 --- a/howto/annotations.po +++ b/howto/annotations.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-01 22:24+0800\n" +"POT-Creation-Date: 2024-10-04 16:20+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-" @@ -188,13 +188,14 @@ msgid "This will print the annotations dict from ``Base``, not ``Derived``." msgstr "這將印出 (print) 來自 ``Base`` 的註釋字典,而不是 ``Derived``。" #: ../../howto/annotations.rst:101 +#, fuzzy 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 " "relies on an implementation detail of Python 3.9 and before: if a class has " -"annotations defined, they are stored in the class's ``__dict__`` " +"annotations defined, they are stored in the class's :attr:`~type.__dict__` " "dictionary. Since the class may or may not have annotations defined, best " -"practice is to call the ``get`` method on the class dict." +"practice is to call the :meth:`~dict.get` method on the class dict." msgstr "" "如果你正在檢查的物件是一個類別 (``isinstance(o, type)``),你的程式碼將必須有" "一個單獨的程式碼路徑。在這種情況下,最佳實踐依賴 Python 3.9 及之前版本的實作" @@ -233,10 +234,11 @@ msgstr "" "用 :func:`isinstance` 仔細檢查 ``ann`` 的型別。" #: ../../howto/annotations.rst:123 +#, fuzzy msgid "" -"Note that some exotic or malformed type objects may not have a ``__dict__`` " -"attribute, so for extra safety you may also wish to use :func:`getattr` to " -"access ``__dict__``." +"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:" +"`getattr` to access :attr:`!__dict__`." msgstr "" "請注意,某些外來 (exotic) 或格式錯誤 (malform) 的型別物件可能沒有 " "``__dict__`` 屬性,因此為了額外的安全,你可能還希望使用 :func:`getattr` 來存" diff --git a/howto/argparse-optparse.po b/howto/argparse-optparse.po new file mode 100644 index 0000000000..a2e3055353 --- /dev/null +++ b/howto/argparse-optparse.po @@ -0,0 +1,135 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2001-2024, Python Software Foundation +# This file is distributed under the same license as the Python package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Python 3.13\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-12-29 16:19+0000\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: zh_TW\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: ../../howto/argparse-optparse.rst:8 +msgid "Migrating ``optparse`` code to ``argparse``" +msgstr "" + +#: ../../howto/argparse-optparse.rst:10 +msgid "" +"The :mod:`argparse` module offers several higher level features not natively " +"provided by the :mod:`optparse` module, including:" +msgstr "" + +#: ../../howto/argparse-optparse.rst:13 +msgid "Handling positional arguments." +msgstr "" + +#: ../../howto/argparse-optparse.rst:14 +msgid "Supporting subcommands." +msgstr "" + +#: ../../howto/argparse-optparse.rst:15 +msgid "Allowing alternative option prefixes like ``+`` and ``/``." +msgstr "" + +#: ../../howto/argparse-optparse.rst:16 +msgid "Handling zero-or-more and one-or-more style arguments." +msgstr "" + +#: ../../howto/argparse-optparse.rst:17 +msgid "Producing more informative usage messages." +msgstr "" + +#: ../../howto/argparse-optparse.rst:18 +msgid "Providing a much simpler interface for custom ``type`` and ``action``." +msgstr "" + +#: ../../howto/argparse-optparse.rst:20 +msgid "" +"Originally, the :mod:`argparse` module attempted to maintain compatibility " +"with :mod:`optparse`. However, the fundamental design differences between " +"supporting declarative command line option processing (while leaving " +"positional argument processing to application code), and supporting both " +"named options and positional arguments in the declarative interface mean " +"that the API has diverged from that of ``optparse`` over time." +msgstr "" + +#: ../../howto/argparse-optparse.rst:27 +msgid "" +"As described in :ref:`choosing-an-argument-parser`, applications that are " +"currently using :mod:`optparse` and are happy with the way it works can just " +"continue to use ``optparse``." +msgstr "" + +#: ../../howto/argparse-optparse.rst:31 +msgid "" +"Application developers that are considering migrating should also review the " +"list of intrinsic behavioural differences described in that section before " +"deciding whether or not migration is desirable." +msgstr "" + +#: ../../howto/argparse-optparse.rst:35 +msgid "" +"For applications that do choose to migrate from :mod:`optparse` to :mod:" +"`argparse`, the following suggestions should be helpful:" +msgstr "" + +#: ../../howto/argparse-optparse.rst:38 +msgid "" +"Replace all :meth:`optparse.OptionParser.add_option` calls with :meth:" +"`ArgumentParser.add_argument` calls." +msgstr "" + +#: ../../howto/argparse-optparse.rst:41 +msgid "" +"Replace ``(options, args) = parser.parse_args()`` with ``args = parser." +"parse_args()`` and add additional :meth:`ArgumentParser.add_argument` calls " +"for the positional arguments. Keep in mind that what was previously called " +"``options``, now in the :mod:`argparse` context is called ``args``." +msgstr "" + +#: ../../howto/argparse-optparse.rst:46 +msgid "" +"Replace :meth:`optparse.OptionParser.disable_interspersed_args` by using :" +"meth:`~ArgumentParser.parse_intermixed_args` instead of :meth:" +"`~ArgumentParser.parse_args`." +msgstr "" + +#: ../../howto/argparse-optparse.rst:50 +msgid "" +"Replace callback actions and the ``callback_*`` keyword arguments with " +"``type`` or ``action`` arguments." +msgstr "" + +#: ../../howto/argparse-optparse.rst:53 +msgid "" +"Replace string names for ``type`` keyword arguments with the corresponding " +"type objects (e.g. int, float, complex, etc)." +msgstr "" + +#: ../../howto/argparse-optparse.rst:56 +msgid "" +"Replace :class:`optparse.Values` with :class:`Namespace` and :exc:`optparse." +"OptionError` and :exc:`optparse.OptionValueError` with :exc:`ArgumentError`." +msgstr "" + +#: ../../howto/argparse-optparse.rst:60 +msgid "" +"Replace strings with implicit arguments such as ``%default`` or ``%prog`` " +"with the standard Python syntax to use dictionaries to format strings, that " +"is, ``%(default)s`` and ``%(prog)s``." +msgstr "" + +#: ../../howto/argparse-optparse.rst:64 +msgid "" +"Replace the OptionParser constructor ``version`` argument with a call to " +"``parser.add_argument('--version', action='version', version='')``." +msgstr "" diff --git a/howto/argparse.po b/howto/argparse.po index c8731127a1..6681c8f583 100644 --- a/howto/argparse.po +++ b/howto/argparse.po @@ -12,7 +12,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2024-12-29 16:19+0000\n" "PO-Revision-Date: 2023-12-11 17:33+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -46,27 +46,30 @@ msgstr "" #: ../../howto/argparse.rst:16 msgid "" -"There are two other modules that fulfill the same task, namely :mod:`getopt` " -"(an equivalent for ``getopt()`` from the C language) and the deprecated :mod:" -"`optparse`. Note also that :mod:`argparse` is based on :mod:`optparse`, and " -"therefore very similar in terms of usage." +"The standard library includes two other libraries directly related to " +"command-line parameter processing: the lower level :mod:`optparse` module " +"(which may require more code to configure for a given application, but also " +"allows an application to request behaviors that ``argparse`` doesn't " +"support), and the very low level :mod:`getopt` (which specifically serves as " +"an equivalent to the :c:func:`!getopt` family of functions available to C " +"programmers). While neither of those modules is covered directly in this " +"guide, many of the core concepts in ``argparse`` first originated in " +"``optparse``, so some aspects of this tutorial will also be relevant to " +"``optparse`` users." msgstr "" -"另外還有兩個模組可以完成相同的任務,即 :mod:`getopt`\\ (相當於 C 語言中的 " -"``getopt()``)和已棄用的 :mod:`optparse`。另請注意,:mod:`argparse` 是基於 :" -"mod:`optparse` 的,因此在用法上非常相似。" -#: ../../howto/argparse.rst:24 +#: ../../howto/argparse.rst:29 msgid "Concepts" msgstr "概念" -#: ../../howto/argparse.rst:26 +#: ../../howto/argparse.rst:31 msgid "" "Let's show the sort of functionality that we are going to explore in this " "introductory tutorial by making use of the :command:`ls` command:" msgstr "" "讓我們透過使用 :command:`ls` 指令來展示我們將在本介紹教學中探索的功能類型:" -#: ../../howto/argparse.rst:29 +#: ../../howto/argparse.rst:34 msgid "" "$ ls\n" "cpython devguide prog.py pypy rm-unused-function.patch\n" @@ -102,11 +105,11 @@ msgstr "" "Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.\n" "..." -#: ../../howto/argparse.rst:48 +#: ../../howto/argparse.rst:53 msgid "A few concepts we can learn from the four commands:" msgstr "我們可以從這四個命令中學到一些概念:" -#: ../../howto/argparse.rst:50 +#: ../../howto/argparse.rst:55 msgid "" "The :command:`ls` command is useful when run without any options at all. It " "defaults to displaying the contents of the current directory." @@ -114,7 +117,7 @@ msgstr "" ":command:`ls` 命令即便在沒有任何選項的情況下執行仍非常有用。它預設顯示目前目" "錄的內容。" -#: ../../howto/argparse.rst:53 +#: ../../howto/argparse.rst:58 msgid "" "If we want beyond what it provides by default, we tell it a bit more. In " "this case, we want it to display a different directory, ``pypy``. What we " @@ -131,7 +134,7 @@ msgstr "" "command:`cp` 這樣的指令更相關,其最基本的用法是 ``cp SRC DEST``。第一個是\\ *" "你想要複製的位置*,第二個是\\ *你想要複製過去的位置*。" -#: ../../howto/argparse.rst:62 +#: ../../howto/argparse.rst:67 msgid "" "Now, say we want to change behaviour of the program. In our example, we " "display more info for each file instead of just showing the file names. The " @@ -140,7 +143,7 @@ msgstr "" "現在假設我們想要改變程式的行為。在我們的範例中,我們顯示每個檔案的更多資訊," "而不僅是顯示檔案名稱。在這種情況下,``-l`` 被稱為可選引數。" -#: ../../howto/argparse.rst:66 +#: ../../howto/argparse.rst:71 msgid "" "That's a snippet of the help text. It's very useful in that you can come " "across a program you have never used before, and can figure out how it works " @@ -149,15 +152,15 @@ msgstr "" "這是幫助文字的片段。它非常有用,因為當你遇到以前從未使用過的程式時,只需閱讀" "其幫助文字即可了解它的工作原理。" -#: ../../howto/argparse.rst:72 +#: ../../howto/argparse.rst:77 msgid "The basics" msgstr "基本用法" -#: ../../howto/argparse.rst:74 +#: ../../howto/argparse.rst:79 msgid "Let us start with a very simple example which does (almost) nothing::" msgstr "讓我們從一個非常簡單的例子開始,它(幾乎)什麼都不做: ::" -#: ../../howto/argparse.rst:76 +#: ../../howto/argparse.rst:81 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -167,12 +170,12 @@ msgstr "" "parser = argparse.ArgumentParser()\n" "parser.parse_args()" -#: ../../howto/argparse.rst:80 ../../howto/argparse.rst:188 -#: ../../howto/argparse.rst:209 +#: ../../howto/argparse.rst:85 ../../howto/argparse.rst:193 +#: ../../howto/argparse.rst:214 msgid "Following is a result of running the code:" msgstr "程式碼執行結果如下:" -#: ../../howto/argparse.rst:82 +#: ../../howto/argparse.rst:87 msgid "" "$ python prog.py\n" "$ python prog.py --help\n" @@ -200,18 +203,18 @@ msgstr "" "usage: prog.py [-h]\n" "prog.py: error: unrecognized arguments: foo" -#: ../../howto/argparse.rst:97 ../../howto/argparse.rst:254 -#: ../../howto/argparse.rst:298 +#: ../../howto/argparse.rst:102 ../../howto/argparse.rst:259 +#: ../../howto/argparse.rst:303 msgid "Here is what is happening:" msgstr "這是發生的事情:" -#: ../../howto/argparse.rst:99 +#: ../../howto/argparse.rst:104 msgid "" "Running the script without any options results in nothing displayed to " "stdout. Not so useful." msgstr "執行不帶任何選項的腳本不會在標準輸出中顯示任何內容。不太有用。" -#: ../../howto/argparse.rst:102 +#: ../../howto/argparse.rst:107 msgid "" "The second one starts to display the usefulness of the :mod:`argparse` " "module. We have done almost nothing, but already we get a nice help message." @@ -219,7 +222,7 @@ msgstr "" "第二個開始能夠顯現 :mod:`argparse` 模組的有用之處。我們幾乎什麼也沒做,但我們" "已經收到了一個很好的幫助訊息。" -#: ../../howto/argparse.rst:105 +#: ../../howto/argparse.rst:110 msgid "" "The ``--help`` option, which can also be shortened to ``-h``, is the only " "option we get for free (i.e. no need to specify it). Specifying anything " @@ -230,15 +233,15 @@ msgstr "" "它)。指定任何其他內容都會導致錯誤。但即便如此,我們也還是輕鬆地獲得了有用的" "使用資訊。" -#: ../../howto/argparse.rst:112 +#: ../../howto/argparse.rst:117 msgid "Introducing Positional arguments" msgstr "位置引數的介紹" -#: ../../howto/argparse.rst:114 +#: ../../howto/argparse.rst:119 msgid "An example::" msgstr "例如: ::" -#: ../../howto/argparse.rst:116 +#: ../../howto/argparse.rst:121 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -252,11 +255,11 @@ msgstr "" "args = parser.parse_args()\n" "print(args.echo)" -#: ../../howto/argparse.rst:122 +#: ../../howto/argparse.rst:127 msgid "And running the code:" msgstr "執行這段程式碼:" -#: ../../howto/argparse.rst:124 +#: ../../howto/argparse.rst:129 msgid "" "$ python prog.py\n" "usage: prog.py [-h] echo\n" @@ -286,11 +289,11 @@ msgstr "" "$ python prog.py foo\n" "foo" -#: ../../howto/argparse.rst:140 +#: ../../howto/argparse.rst:145 msgid "Here is what's happening:" msgstr "這是會發生的事情:" -#: ../../howto/argparse.rst:142 +#: ../../howto/argparse.rst:147 msgid "" "We've added the :meth:`~ArgumentParser.add_argument` method, which is what " "we use to specify which command-line options the program is willing to " @@ -300,11 +303,11 @@ msgstr "" "我們新增了 :meth:`~ArgumentParser.add_argument` 方法,我們用它來指定程式願意" "接受哪些命令列選項。在本例中,我將其命名為 ``echo``,以便與其功能一致。" -#: ../../howto/argparse.rst:146 +#: ../../howto/argparse.rst:151 msgid "Calling our program now requires us to specify an option." msgstr "現在呼叫我們的程式時需要指定一個選項。" -#: ../../howto/argparse.rst:148 +#: ../../howto/argparse.rst:153 msgid "" "The :meth:`~ArgumentParser.parse_args` method actually returns some data " "from the options specified, in this case, ``echo``." @@ -312,7 +315,7 @@ msgstr "" ":meth:`~ArgumentParser.parse_args` 方法實際上從指定的選項中回傳一些資料,在本" "例中為 ``echo``。" -#: ../../howto/argparse.rst:151 +#: ../../howto/argparse.rst:156 msgid "" "The variable is some form of 'magic' that :mod:`argparse` performs for free " "(i.e. no need to specify which variable that value is stored in). You will " @@ -322,7 +325,7 @@ msgstr "" "該變數是某種形式的「魔法」,:mod:`argparse` 可以自由執行(即無需指定該值儲存" "在哪個變數中)。你還會注意到,它的名稱與提供給方法 ``echo`` 的字串引數相符。" -#: ../../howto/argparse.rst:156 +#: ../../howto/argparse.rst:161 msgid "" "Note however that, although the help display looks nice and all, it " "currently is not as helpful as it can be. For example we see that we got " @@ -334,7 +337,7 @@ msgstr "" "看到 ``echo`` 作為位置引數,但除了猜測或閱讀原始程式碼之外,我們不知道它的作" "用。那麼,我們來讓它變得更有用一點: ::" -#: ../../howto/argparse.rst:161 +#: ../../howto/argparse.rst:166 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -348,11 +351,11 @@ msgstr "" "args = parser.parse_args()\n" "print(args.echo)" -#: ../../howto/argparse.rst:167 +#: ../../howto/argparse.rst:172 msgid "And we get:" msgstr "然後我們得到:" -#: ../../howto/argparse.rst:169 +#: ../../howto/argparse.rst:174 msgid "" "$ python prog.py -h\n" "usage: prog.py [-h] echo\n" @@ -372,11 +375,11 @@ msgstr "" "options:\n" " -h, --help show this help message and exit" -#: ../../howto/argparse.rst:180 +#: ../../howto/argparse.rst:185 msgid "Now, how about doing something even more useful::" msgstr "現在來做一些更有用處的事情: ::" -#: ../../howto/argparse.rst:182 +#: ../../howto/argparse.rst:187 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -392,7 +395,7 @@ msgstr "" "args = parser.parse_args()\n" "print(args.square**2)" -#: ../../howto/argparse.rst:190 +#: ../../howto/argparse.rst:195 msgid "" "$ python prog.py 4\n" "Traceback (most recent call last):\n" @@ -406,7 +409,7 @@ msgstr "" " print(args.square**2)\n" "TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'int'" -#: ../../howto/argparse.rst:198 +#: ../../howto/argparse.rst:203 msgid "" "That didn't go so well. That's because :mod:`argparse` treats the options we " "give it as strings, unless we tell it otherwise. So, let's tell :mod:" @@ -415,7 +418,7 @@ msgstr "" "進展不太順利。這是因為,除非我們另有說明,:mod:`argparse` 會將我們給它的選項" "視為字串。因此,讓我們告訴 :mod:`argparse` 將該輸入視為整數: ::" -#: ../../howto/argparse.rst:202 +#: ../../howto/argparse.rst:207 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -433,7 +436,7 @@ msgstr "" "args = parser.parse_args()\n" "print(args.square**2)" -#: ../../howto/argparse.rst:211 +#: ../../howto/argparse.rst:216 msgid "" "$ python prog.py 4\n" "16\n" @@ -447,23 +450,23 @@ msgstr "" "usage: prog.py [-h] square\n" "prog.py: error: argument square: invalid int value: 'four'" -#: ../../howto/argparse.rst:219 +#: ../../howto/argparse.rst:224 msgid "" "That went well. The program now even helpfully quits on bad illegal input " "before proceeding." msgstr "順利進展。現在該程式甚至可以在繼續操作之前因錯誤的非法輸入而退出。" -#: ../../howto/argparse.rst:224 +#: ../../howto/argparse.rst:229 msgid "Introducing Optional arguments" msgstr "可選引數的介紹" -#: ../../howto/argparse.rst:226 +#: ../../howto/argparse.rst:231 msgid "" "So far we have been playing with positional arguments. Let us have a look on " "how to add optional ones::" msgstr "到目前為止,我們一直在討論位置引數。我們來看看如何新增可選引數: ::" -#: ../../howto/argparse.rst:229 +#: ../../howto/argparse.rst:234 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -479,12 +482,12 @@ msgstr "" "if args.verbosity:\n" " print(\"verbosity turned on\")" -#: ../../howto/argparse.rst:236 ../../howto/argparse.rst:282 -#: ../../howto/argparse.rst:398 ../../howto/argparse.rst:432 +#: ../../howto/argparse.rst:241 ../../howto/argparse.rst:287 +#: ../../howto/argparse.rst:403 ../../howto/argparse.rst:437 msgid "And the output:" msgstr "接者是結果:" -#: ../../howto/argparse.rst:238 +#: ../../howto/argparse.rst:243 msgid "" "$ python prog.py --verbosity 1\n" "verbosity turned on\n" @@ -514,7 +517,7 @@ msgstr "" "usage: prog.py [-h] [--verbosity VERBOSITY]\n" "prog.py: error: argument --verbosity: expected one argument" -#: ../../howto/argparse.rst:256 +#: ../../howto/argparse.rst:261 msgid "" "The program is written so as to display something when ``--verbosity`` is " "specified and display nothing when not." @@ -522,7 +525,7 @@ msgstr "" "程式被編寫為在指定 ``--verbosity`` 時顯示一些內容,並在未指定時不顯示任何內" "容。" -#: ../../howto/argparse.rst:259 +#: ../../howto/argparse.rst:264 msgid "" "To show that the option is actually optional, there is no error when running " "the program without it. Note that by default, if an optional argument isn't " @@ -534,17 +537,17 @@ msgstr "" "情況下,如果未使用可選引數,則相關變數(在本例中為 ``args.verbosity``)將被賦" "予 ``None`` 作為值,這就是它未能通過 :keyword:`if` 陳述式真值測試的原因。" -#: ../../howto/argparse.rst:265 +#: ../../howto/argparse.rst:270 msgid "The help message is a bit different." msgstr "幫助訊息有點不同。" -#: ../../howto/argparse.rst:267 +#: ../../howto/argparse.rst:272 msgid "" "When using the ``--verbosity`` option, one must also specify some value, any " "value." msgstr "當使用 ``--verbosity`` 選項時必須要指定一些值,任何值都可以。" -#: ../../howto/argparse.rst:270 +#: ../../howto/argparse.rst:275 msgid "" "The above example accepts arbitrary integer values for ``--verbosity``, but " "for our simple program, only two values are actually useful, ``True`` or " @@ -553,7 +556,7 @@ msgstr "" "在上面的例子中,``--verbosity`` 接受任意的整數,但對我們的程式來說只接受兩個" "輸入值, ``True`` 或 ``False``。所以我們來修改一下程式碼使其符合: ::" -#: ../../howto/argparse.rst:274 +#: ../../howto/argparse.rst:279 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -571,7 +574,7 @@ msgstr "" "if args.verbose:\n" " print(\"verbosity turned on\")" -#: ../../howto/argparse.rst:284 +#: ../../howto/argparse.rst:289 msgid "" "$ python prog.py --verbose\n" "verbosity turned on\n" @@ -597,7 +600,7 @@ msgstr "" " -h, --help show this help message and exit\n" " --verbose increase output verbosity" -#: ../../howto/argparse.rst:300 +#: ../../howto/argparse.rst:305 msgid "" "The option is now more of a flag than something that requires a value. We " "even changed the name of the option to match that idea. Note that we now " @@ -610,21 +613,21 @@ msgstr "" "``\"store_true\"``。這意味著,如果指定了該選項,則將值 ``True`` 指派給 " "``args.verbose``。不指定它代表為 ``False``。" -#: ../../howto/argparse.rst:307 +#: ../../howto/argparse.rst:312 msgid "" "It complains when you specify a value, in true spirit of what flags actually " "are." msgstr "當你指定一個值時,它會本著旗標的實際精神來抱怨。" -#: ../../howto/argparse.rst:310 +#: ../../howto/argparse.rst:315 msgid "Notice the different help text." msgstr "請注意不同的幫助文字。" -#: ../../howto/argparse.rst:314 +#: ../../howto/argparse.rst:319 msgid "Short options" msgstr "短選項" -#: ../../howto/argparse.rst:316 +#: ../../howto/argparse.rst:321 msgid "" "If you are familiar with command line usage, you will notice that I haven't " "yet touched on the topic of short versions of the options. It's quite " @@ -632,7 +635,7 @@ msgid "" msgstr "" "如果你熟悉命令列用法,你會注意到我尚未提及選項的簡短版本。這很簡單: ::" -#: ../../howto/argparse.rst:320 +#: ../../howto/argparse.rst:325 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -652,11 +655,11 @@ msgstr "" "if args.verbose:\n" " print(\"verbosity turned on\")" -#: ../../howto/argparse.rst:328 +#: ../../howto/argparse.rst:333 msgid "And here goes:" msgstr "而這為:" -#: ../../howto/argparse.rst:330 +#: ../../howto/argparse.rst:335 msgid "" "$ python prog.py -v\n" "verbosity turned on\n" @@ -676,19 +679,19 @@ msgstr "" " -h, --help show this help message and exit\n" " -v, --verbose increase output verbosity" -#: ../../howto/argparse.rst:341 +#: ../../howto/argparse.rst:346 msgid "Note that the new ability is also reflected in the help text." msgstr "請注意,新功能也反映在幫助文字中。" -#: ../../howto/argparse.rst:345 +#: ../../howto/argparse.rst:350 msgid "Combining Positional and Optional arguments" msgstr "組合位置引數和可選引數" -#: ../../howto/argparse.rst:347 +#: ../../howto/argparse.rst:352 msgid "Our program keeps growing in complexity::" msgstr "我們的程式的複雜性不斷增加: ::" -#: ../../howto/argparse.rst:349 +#: ../../howto/argparse.rst:354 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -716,11 +719,11 @@ msgstr "" "else:\n" " print(answer)" -#: ../../howto/argparse.rst:362 +#: ../../howto/argparse.rst:367 msgid "And now the output:" msgstr "然後現在的輸出結果:" -#: ../../howto/argparse.rst:364 +#: ../../howto/argparse.rst:369 msgid "" "$ python prog.py\n" "usage: prog.py [-h] [-v] square\n" @@ -742,15 +745,15 @@ msgstr "" "$ python prog.py --verbose 4\n" "the square of 4 equals 16" -#: ../../howto/argparse.rst:376 +#: ../../howto/argparse.rst:381 msgid "We've brought back a positional argument, hence the complaint." msgstr "我們帶回了位置引數,因而被抱怨。" -#: ../../howto/argparse.rst:378 +#: ../../howto/argparse.rst:383 msgid "Note that the order does not matter." msgstr "請注意,順序並不重要。" -#: ../../howto/argparse.rst:380 +#: ../../howto/argparse.rst:385 msgid "" "How about we give this program of ours back the ability to have multiple " "verbosity values, and actually get to use them::" @@ -758,7 +761,7 @@ msgstr "" "我們讓這個程式擁有多個訊息詳細級別 (verbosity) 之值的能力,並實際使用它" "們: ::" -#: ../../howto/argparse.rst:383 +#: ../../howto/argparse.rst:388 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -790,7 +793,7 @@ msgstr "" "else:\n" " print(answer)" -#: ../../howto/argparse.rst:400 +#: ../../howto/argparse.rst:405 msgid "" "$ python prog.py 4\n" "16\n" @@ -816,7 +819,7 @@ msgstr "" "$ python prog.py 4 -v 3\n" "16" -#: ../../howto/argparse.rst:414 +#: ../../howto/argparse.rst:419 msgid "" "These all look good except the last one, which exposes a bug in our program. " "Let's fix it by restricting the values the ``--verbosity`` option can " @@ -825,7 +828,7 @@ msgstr "" "除了最後一個外都看起來正常,它透露了我們程式中的一個錯誤。我們可透過限制 ``--" "verbosity`` 選項可以接受的值來修復它: ::" -#: ../../howto/argparse.rst:417 +#: ../../howto/argparse.rst:422 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -857,7 +860,8 @@ msgstr "" "else:\n" " print(answer)" -#: ../../howto/argparse.rst:434 +#: ../../howto/argparse.rst:439 +#, fuzzy msgid "" "$ python prog.py 4 -v 3\n" "usage: prog.py [-h] [-v {0,1,2}] square\n" @@ -871,7 +875,7 @@ msgid "" "\n" "options:\n" " -h, --help show this help message and exit\n" -" -v {0,1,2}, --verbosity {0,1,2}\n" +" -v, --verbosity {0,1,2}\n" " increase output verbosity" msgstr "" "$ python prog.py 4 -v 3\n" @@ -889,13 +893,13 @@ msgstr "" " -v {0,1,2}, --verbosity {0,1,2}\n" " increase output verbosity" -#: ../../howto/argparse.rst:450 +#: ../../howto/argparse.rst:455 msgid "" "Note that the change also reflects both in the error message as well as the " "help string." msgstr "請注意,更改也會反映在錯誤訊息和幫助字串中。" -#: ../../howto/argparse.rst:453 +#: ../../howto/argparse.rst:458 msgid "" "Now, let's use a different approach of playing with verbosity, which is " "pretty common. It also matches the way the CPython executable handles its " @@ -904,7 +908,7 @@ msgstr "" "現在,讓我們使用另一種常見方法來玩玩訊息詳細級別。它也與 CPython 執行檔處理其" "自身訊息詳細級別引數的方式相符(請見 ``python --help`` 的輸出): ::" -#: ../../howto/argparse.rst:457 +#: ../../howto/argparse.rst:462 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -936,13 +940,13 @@ msgstr "" "else:\n" " print(answer)" -#: ../../howto/argparse.rst:472 +#: ../../howto/argparse.rst:477 msgid "" "We have introduced another action, \"count\", to count the number of " "occurrences of specific options." msgstr "我們已經介紹過另一個操作 \"count\" 用來計算指定的選項出現的次數。" -#: ../../howto/argparse.rst:476 +#: ../../howto/argparse.rst:481 msgid "" "$ python prog.py 4\n" "16\n" @@ -990,7 +994,7 @@ msgstr "" "$ python prog.py 4 -vvv\n" "16" -#: ../../howto/argparse.rst:501 +#: ../../howto/argparse.rst:506 msgid "" "Yes, it's now more of a flag (similar to ``action=\"store_true\"``) in the " "previous version of our script. That should explain the complaint." @@ -998,29 +1002,29 @@ msgstr "" "是的,現在它更像是我們上一版腳本中的旗標(類似於 " "``action=\"store_true\"``),這應該可以解釋抱怨的原因。" -#: ../../howto/argparse.rst:504 +#: ../../howto/argparse.rst:509 msgid "It also behaves similar to \"store_true\" action." msgstr "它的行為也類似 \"store_true\" 操作。" -#: ../../howto/argparse.rst:506 +#: ../../howto/argparse.rst:511 msgid "" "Now here's a demonstration of what the \"count\" action gives. You've " "probably seen this sort of usage before." msgstr "現在這裡示範了 \"count\" 動作的作用。你可能以前見過這種用法。" -#: ../../howto/argparse.rst:509 +#: ../../howto/argparse.rst:514 msgid "" "And if you don't specify the ``-v`` flag, that flag is considered to have " "``None`` value." msgstr "如果你不指定 ``-v`` 旗標,則該旗標被視為具有 ``None`` 值。" -#: ../../howto/argparse.rst:512 +#: ../../howto/argparse.rst:517 msgid "" "As should be expected, specifying the long form of the flag, we should get " "the same output." msgstr "正如預期的那樣,指定長形式旗標,我們應該得到相同的輸出。" -#: ../../howto/argparse.rst:515 +#: ../../howto/argparse.rst:520 msgid "" "Sadly, our help output isn't very informative on the new ability our script " "has acquired, but that can always be fixed by improving the documentation " @@ -1029,15 +1033,15 @@ msgstr "" "遺憾的是,我們的幫助輸出對於我們腳本獲得的新功能並沒有提供太多資訊,但我們都" "可以透過改進腳本的文件來解決這個問題(例如:透過 ``help`` 關鍵字引數)。" -#: ../../howto/argparse.rst:519 +#: ../../howto/argparse.rst:524 msgid "That last output exposes a bug in our program." msgstr "最後的輸出透露了我們程式中的一個錯誤。" -#: ../../howto/argparse.rst:522 +#: ../../howto/argparse.rst:527 msgid "Let's fix::" msgstr "讓我們來解決問題: ::" -#: ../../howto/argparse.rst:524 +#: ../../howto/argparse.rst:529 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -1073,11 +1077,11 @@ msgstr "" "else:\n" " print(answer)" -#: ../../howto/argparse.rst:541 +#: ../../howto/argparse.rst:546 msgid "And this is what it gives:" msgstr "這就是它給出的:" -#: ../../howto/argparse.rst:543 +#: ../../howto/argparse.rst:548 msgid "" "$ python prog.py 4 -vvv\n" "the square of 4 equals 16\n" @@ -1099,7 +1103,7 @@ msgstr "" " if args.verbosity >= 2:\n" "TypeError: '>=' not supported between instances of 'NoneType' and 'int'" -#: ../../howto/argparse.rst:556 +#: ../../howto/argparse.rst:561 msgid "" "First output went well, and fixes the bug we had before. That is, we want " "any value >= 2 to be as verbose as possible." @@ -1107,15 +1111,15 @@ msgstr "" "第一次輸出順利進行,並修復了我們之前遇到的錯誤。也就是說,我們希望任何 >= 2 " "的值都盡可能詳細。" -#: ../../howto/argparse.rst:559 +#: ../../howto/argparse.rst:564 msgid "Third output not so good." msgstr "第三個輸出不太好。" -#: ../../howto/argparse.rst:561 +#: ../../howto/argparse.rst:566 msgid "Let's fix that bug::" msgstr "我們來修復這個錯誤: ::" -#: ../../howto/argparse.rst:563 +#: ../../howto/argparse.rst:568 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -1147,7 +1151,7 @@ msgstr "" "else:\n" " print(answer)" -#: ../../howto/argparse.rst:578 +#: ../../howto/argparse.rst:583 msgid "" "We've just introduced yet another keyword, ``default``. We've set it to " "``0`` in order to make it comparable to the other int values. Remember that " @@ -1159,11 +1163,11 @@ msgstr "" "int 值進行比較。請記住,預設情況下,如果未指定可選引數,它將獲得 ``None`` " "值,並且不能與 int 值進行比較(因此會出現 :exc:`TypeError` 例外)。" -#: ../../howto/argparse.rst:585 +#: ../../howto/argparse.rst:590 msgid "And:" msgstr "而且:" -#: ../../howto/argparse.rst:587 +#: ../../howto/argparse.rst:592 msgid "" "$ python prog.py 4\n" "16" @@ -1171,7 +1175,7 @@ msgstr "" "$ python prog.py 4\n" "16" -#: ../../howto/argparse.rst:592 +#: ../../howto/argparse.rst:597 msgid "" "You can go quite far just with what we've learned so far, and we have only " "scratched the surface. The :mod:`argparse` module is very powerful, and " @@ -1181,17 +1185,17 @@ msgstr "" "毛而已。:mod:`argparse` 模組非常強大,在結束本教學之前我們會對它進行更多探" "索。" -#: ../../howto/argparse.rst:599 +#: ../../howto/argparse.rst:604 msgid "Getting a little more advanced" msgstr "更進階一點" -#: ../../howto/argparse.rst:601 +#: ../../howto/argparse.rst:606 msgid "" "What if we wanted to expand our tiny program to perform other powers, not " "just squares::" msgstr "如果我們想擴充我們的小程式來執行其他次方的運算,而不僅是平方: ::" -#: ../../howto/argparse.rst:604 +#: ../../howto/argparse.rst:609 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -1221,11 +1225,12 @@ msgstr "" "else:\n" " print(answer)" -#: ../../howto/argparse.rst:618 ../../howto/argparse.rst:656 +#: ../../howto/argparse.rst:623 ../../howto/argparse.rst:661 +#: ../../howto/argparse.rst:877 msgid "Output:" msgstr "結果:" -#: ../../howto/argparse.rst:620 +#: ../../howto/argparse.rst:625 msgid "" "$ python prog.py\n" "usage: prog.py [-h] [-v] x y\n" @@ -1259,7 +1264,7 @@ msgstr "" "$ python prog.py 4 2 -v\n" "4^2 == 16" -#: ../../howto/argparse.rst:639 +#: ../../howto/argparse.rst:644 msgid "" "Notice that so far we've been using verbosity level to *change* the text " "that gets displayed. The following example instead uses verbosity level to " @@ -1268,7 +1273,7 @@ msgstr "" "請注意,到目前為止,我們一直在使用詳細級別來\\ *更改*\\ 顯示的文字。以下範例" "使用詳細級別來顯示\\ *更多*\\ 文字: ::" -#: ../../howto/argparse.rst:643 +#: ../../howto/argparse.rst:648 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -1296,7 +1301,7 @@ msgstr "" " print(f\"{args.x}^{args.y} == \", end=\"\")\n" "print(answer)" -#: ../../howto/argparse.rst:658 +#: ../../howto/argparse.rst:663 msgid "" "$ python prog.py 4 2\n" "16\n" @@ -1314,11 +1319,11 @@ msgstr "" "Running 'prog.py'\n" "4^2 == 16" -#: ../../howto/argparse.rst:672 +#: ../../howto/argparse.rst:677 msgid "Specifying ambiguous arguments" msgstr "指定不明確的引數" -#: ../../howto/argparse.rst:674 +#: ../../howto/argparse.rst:679 msgid "" "When there is ambiguity in deciding whether an argument is positional or for " "an argument, ``--`` can be used to tell :meth:`~ArgumentParser.parse_args` " @@ -1327,7 +1332,7 @@ msgstr "" "當決定一個引數是位置引數還是引數會有歧義,可以使用 ``--`` 來告訴 :meth:" "`~ArgumentParser.parse_args` 之後的所有內容都是位置引數: ::" -#: ../../howto/argparse.rst:678 +#: ../../howto/argparse.rst:683 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-n', nargs='+')\n" @@ -1367,11 +1372,11 @@ msgstr "" ">>> parser.parse_args(['-n', '1', '--', '2', '3'])\n" "Namespace(args=['2', '3'], n=['1'])" -#: ../../howto/argparse.rst:699 +#: ../../howto/argparse.rst:704 msgid "Conflicting options" msgstr "相互衝突的選項" -#: ../../howto/argparse.rst:701 +#: ../../howto/argparse.rst:706 msgid "" "So far, we have been working with two methods of an :class:`argparse." "ArgumentParser` instance. Let's introduce a third one, :meth:" @@ -1385,7 +1390,7 @@ msgstr "" "許我們指定彼此衝突的選項。我們還可以更改程式的其餘部分,以使得新功能更有意" "義:我們將引入 ``--quiet`` 選項,該選項與 ``--verbose`` 選項相反: ::" -#: ../../howto/argparse.rst:709 +#: ../../howto/argparse.rst:714 msgid "" "import argparse\n" "\n" @@ -1423,7 +1428,7 @@ msgstr "" "else:\n" " print(f\"{args.x}^{args.y} == {answer}\")" -#: ../../howto/argparse.rst:727 +#: ../../howto/argparse.rst:732 msgid "" "Our program is now simpler, and we've lost some functionality for the sake " "of demonstration. Anyways, here's the output:" @@ -1431,7 +1436,7 @@ msgstr "" "我們的程式現在更簡單了,我們因為功能展示失去了一些功能,但無論如何,以下這是" "輸出:" -#: ../../howto/argparse.rst:730 +#: ../../howto/argparse.rst:735 msgid "" "$ python prog.py 4 2\n" "4^2 == 16\n" @@ -1459,7 +1464,7 @@ msgstr "" "usage: prog.py [-h] [-v | -q] x y\n" "prog.py: error: argument -q/--quiet: not allowed with argument -v/--verbose" -#: ../../howto/argparse.rst:745 +#: ../../howto/argparse.rst:750 msgid "" "That should be easy to follow. I've added that last output so you can see " "the sort of flexibility you get, i.e. mixing long form options with short " @@ -1468,14 +1473,14 @@ msgstr "" "這應該很容易理解。我新增了最後一個輸出,以便看到所獲得的靈活性,即可以混合長" "形式與短形式選項。" -#: ../../howto/argparse.rst:749 +#: ../../howto/argparse.rst:754 msgid "" "Before we conclude, you probably want to tell your users the main purpose of " "your program, just in case they don't know::" msgstr "" "在我們結束之前,你可能想告訴使用者你的程式的主要目的,以防他們不知道: ::" -#: ../../howto/argparse.rst:752 +#: ../../howto/argparse.rst:757 msgid "" "import argparse\n" "\n" @@ -1515,7 +1520,7 @@ msgstr "" "else:\n" " print(f\"{args.x}^{args.y} == {answer}\")" -#: ../../howto/argparse.rst:770 +#: ../../howto/argparse.rst:775 msgid "" "Note that slight difference in the usage text. Note the ``[-v | -q]``, which " "tells us that we can either use ``-v`` or ``-q``, but not both at the same " @@ -1524,7 +1529,7 @@ msgstr "" "請注意用法文字中的細微差別。注意 ``[-v | -q]``,它告訴我們可以使用 ``-v`` 或 " "``-q``,但不能同時使用:" -#: ../../howto/argparse.rst:774 ../../howto/argparse.rst:801 +#: ../../howto/argparse.rst:779 ../../howto/argparse.rst:806 msgid "" "$ python prog.py --help\n" "usage: prog.py [-h] [-v | -q] x y\n" @@ -1554,11 +1559,11 @@ msgstr "" " -v, --verbose\n" " -q, --quiet" -#: ../../howto/argparse.rst:792 +#: ../../howto/argparse.rst:797 msgid "How to translate the argparse output" msgstr "如何翻譯 argparse 輸出" -#: ../../howto/argparse.rst:794 +#: ../../howto/argparse.rst:799 msgid "" "The output of the :mod:`argparse` module such as its help text and error " "messages are all made translatable using the :mod:`gettext` module. This " @@ -1569,11 +1574,11 @@ msgstr "" "`gettext` 模組進行翻譯。這允許應用程式能輕鬆本地化 :mod:`argparse` 生成的訊" "息。另請參閱 :ref:`i18n-howto`。" -#: ../../howto/argparse.rst:799 +#: ../../howto/argparse.rst:804 msgid "For instance, in this :mod:`argparse` output:" msgstr "例如,在此 :mod:`argparse` 輸出中:" -#: ../../howto/argparse.rst:817 +#: ../../howto/argparse.rst:822 msgid "" "The strings ``usage:``, ``positional arguments:``, ``options:`` and ``show " "this help message and exit`` are all translatable." @@ -1581,7 +1586,7 @@ msgstr "" "字串 ``usage:``、``positional arguments:``、``options:`` 和 ``show this help " "message and exit`` 都是可被翻譯的。" -#: ../../howto/argparse.rst:820 +#: ../../howto/argparse.rst:825 msgid "" "In order to translate these strings, they must first be extracted into a ``." "po`` file. For example, using `Babel `__, run this " @@ -1590,11 +1595,11 @@ msgstr "" "為了翻譯這些字串,必須先將它們提取到 ``.po`` 檔案中。例如,使用 `Babel " "`__ 並執行下列命令:" -#: ../../howto/argparse.rst:824 +#: ../../howto/argparse.rst:829 msgid "$ pybabel extract -o messages.po /usr/lib/python3.12/argparse.py" msgstr "$ pybabel extract -o messages.po /usr/lib/python3.12/argparse.py" -#: ../../howto/argparse.rst:828 +#: ../../howto/argparse.rst:833 msgid "" "This command will extract all translatable strings from the :mod:`argparse` " "module and output them into a file named ``messages.po``. This command " @@ -1603,13 +1608,13 @@ msgstr "" "此命令將從 :mod:`argparse` 模組中提取出所有可翻譯的字串,並將它們輸出到名為 " "``messages.po`` 的檔案中。這個指令假設你的 Python 是安裝在 ``/usr/lib`` 中。" -#: ../../howto/argparse.rst:832 +#: ../../howto/argparse.rst:837 msgid "" "You can find out the location of the :mod:`argparse` module on your system " "using this script::" msgstr "你可以使用以下腳本找到 :mod:`argparse` 模組在系統上的位置: ::" -#: ../../howto/argparse.rst:835 +#: ../../howto/argparse.rst:840 msgid "" "import argparse\n" "print(argparse.__file__)" @@ -1617,7 +1622,7 @@ msgstr "" "import argparse\n" "print(argparse.__file__)" -#: ../../howto/argparse.rst:838 +#: ../../howto/argparse.rst:843 msgid "" "Once the messages in the ``.po`` file are translated and the translations " "are installed using :mod:`gettext`, :mod:`argparse` will be able to display " @@ -1626,17 +1631,98 @@ msgstr "" "一旦翻譯了 ``.po`` 檔案中的訊息並使用 :mod:`gettext` 安裝了翻譯,:mod:" "`argparse` 將能夠顯示翻譯後的訊息。" -#: ../../howto/argparse.rst:842 +#: ../../howto/argparse.rst:847 msgid "" "To translate your own strings in the :mod:`argparse` output, use :mod:" "`gettext`." msgstr "若要在 :mod:`argparse` 輸出中翻譯你自己的字串,請使用 :mod:`gettext`。" -#: ../../howto/argparse.rst:845 +#: ../../howto/argparse.rst:850 +msgid "Custom type converters" +msgstr "" + +#: ../../howto/argparse.rst:852 +msgid "" +"The :mod:`argparse` module allows you to specify custom type converters for " +"your command-line arguments. This allows you to modify user input before " +"it's stored in the :class:`argparse.Namespace`. This can be useful when you " +"need to pre-process the input before it is used in your program." +msgstr "" + +#: ../../howto/argparse.rst:857 +msgid "" +"When using a custom type converter, you can use any callable that takes a " +"single string argument (the argument value) and returns the converted value. " +"However, if you need to handle more complex scenarios, you can use a custom " +"action class with the **action** parameter instead." +msgstr "" + +#: ../../howto/argparse.rst:862 +msgid "" +"For example, let's say you want to handle arguments with different prefixes " +"and process them accordingly::" +msgstr "" + +#: ../../howto/argparse.rst:865 +#, fuzzy +msgid "" +"import argparse\n" +"\n" +"parser = argparse.ArgumentParser(prefix_chars='-+')\n" +"\n" +"parser.add_argument('-a', metavar='', action='append',\n" +" type=lambda x: ('-', x))\n" +"parser.add_argument('+a', metavar='', action='append',\n" +" type=lambda x: ('+', x))\n" +"\n" +"args = parser.parse_args()\n" +"print(args)" +msgstr "" +"import argparse\n" +"parser = argparse.ArgumentParser()\n" +"parser.add_argument(\"square\", help=\"display a square of a given " +"number\",\n" +" type=int)\n" +"args = parser.parse_args()\n" +"print(args.square**2)" + +#: ../../howto/argparse.rst:879 +msgid "" +"$ python prog.py -a value1 +a value2\n" +"Namespace(a=[('-', 'value1'), ('+', 'value2')])" +msgstr "" + +#: ../../howto/argparse.rst:884 +#, fuzzy +msgid "In this example, we:" +msgstr "例如: ::" + +#: ../../howto/argparse.rst:886 +msgid "" +"Created a parser with custom prefix characters using the ``prefix_chars`` " +"parameter." +msgstr "" + +#: ../../howto/argparse.rst:889 +msgid "" +"Defined two arguments, ``-a`` and ``+a``, which used the ``type`` parameter " +"to create custom type converters to store the value in a tuple with the " +"prefix." +msgstr "" + +#: ../../howto/argparse.rst:892 +msgid "" +"Without the custom type converters, the arguments would have treated the ``-" +"a`` and ``+a`` as the same argument, which would have been undesirable. By " +"using custom type converters, we were able to differentiate between the two " +"arguments." +msgstr "" + +#: ../../howto/argparse.rst:897 msgid "Conclusion" msgstr "結論" -#: ../../howto/argparse.rst:847 +#: ../../howto/argparse.rst:899 msgid "" "The :mod:`argparse` module offers a lot more than shown here. Its docs are " "quite detailed and thorough, and full of examples. Having gone through this " @@ -1644,3 +1730,13 @@ msgid "" msgstr "" ":mod:`argparse` 模組提供的功能比此篇內容的要多得多。它的文件非常詳細與透徹並" "有很多範例。讀完本教學後,你應該可以輕鬆消化它們,而不會感到不知所措。" + +#~ msgid "" +#~ "There are two other modules that fulfill the same task, namely :mod:" +#~ "`getopt` (an equivalent for ``getopt()`` from the C language) and the " +#~ "deprecated :mod:`optparse`. Note also that :mod:`argparse` is based on :" +#~ "mod:`optparse`, and therefore very similar in terms of usage." +#~ msgstr "" +#~ "另外還有兩個模組可以完成相同的任務,即 :mod:`getopt`\\ (相當於 C 語言中" +#~ "的 ``getopt()``)和已棄用的 :mod:`optparse`。另請注意,:mod:`argparse` 是" +#~ "基於 :mod:`optparse` 的,因此在用法上非常相似。" diff --git a/howto/curses.po b/howto/curses.po index d28b8e7fb1..94b711c7f4 100644 --- a/howto/curses.po +++ b/howto/curses.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-04-24 05:56+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-" @@ -240,8 +240,8 @@ msgid "" " v = i-10\n" " stdscr.addstr(i, 0, '10 divided by {} is {}'.format(v, 10/v))\n" "\n" -" stdscr.refresh()\n" -" stdscr.getkey()\n" +" stdscr.refresh()\n" +" stdscr.getkey()\n" "\n" "wrapper(main)" msgstr "" diff --git a/howto/descriptor.po b/howto/descriptor.po index 6cc6a29c8f..dc1c96059f 100644 --- a/howto/descriptor.po +++ b/howto/descriptor.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2024-12-01 15:04+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-" @@ -95,8 +95,8 @@ msgstr "" #: ../../howto/descriptor.rst:45 msgid "" -"The :class:`Ten` class is a descriptor whose :meth:`__get__` method always " -"returns the constant ``10``:" +"The :class:`!Ten` class is a descriptor whose :meth:`~object.__get__` method " +"always returns the constant ``10``:" msgstr "" #: ../../howto/descriptor.rst:48 @@ -214,11 +214,11 @@ msgstr "" #: ../../howto/descriptor.rst:122 msgid "" "Besides showing how descriptors can run computations, this example also " -"reveals the purpose of the parameters to :meth:`__get__`. The *self* " -"parameter is *size*, an instance of *DirectorySize*. The *obj* parameter is " -"either *g* or *s*, an instance of *Directory*. It is the *obj* parameter " -"that lets the :meth:`__get__` method learn the target directory. The " -"*objtype* parameter is the class *Directory*." +"reveals the purpose of the parameters to :meth:`~object.__get__`. The " +"*self* parameter is *size*, an instance of *DirectorySize*. The *obj* " +"parameter is either *g* or *s*, an instance of *Directory*. It is the *obj* " +"parameter that lets the :meth:`~object.__get__` method learn the target " +"directory. The *objtype* parameter is the class *Directory*." msgstr "" #: ../../howto/descriptor.rst:131 @@ -230,8 +230,8 @@ 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:`__get__` and :meth:`__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 @@ -326,10 +326,10 @@ msgstr "" #: ../../howto/descriptor.rst:218 msgid "" -"In this example, the :class:`Person` class has two descriptor instances, " -"*name* and *age*. When the :class:`Person` class is defined, it makes a " -"callback to :meth:`__set_name__` in *LoggedAccess* so that the field names " -"can be recorded, giving each descriptor its own *public_name* and " +"In this example, the :class:`!Person` class has two descriptor instances, " +"*name* and *age*. When the :class:`!Person` class is defined, it makes a " +"callback to :meth:`~object.__set_name__` in *LoggedAccess* so that the field " +"names can be recorded, giving each descriptor its own *public_name* and " "*private_name*:" msgstr "" @@ -369,9 +369,9 @@ msgstr "" #: ../../howto/descriptor.rst:256 msgid "" -"An interactive session shows that the :class:`Person` class has called :meth:" -"`__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,16 +428,16 @@ msgstr "" #: ../../howto/descriptor.rst:297 msgid "" -"A :term:`descriptor` is what we call any object that defines :meth:" -"`__get__`, :meth:`__set__`, or :meth:`__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 msgid "" -"Optionally, descriptors can have a :meth:`__set_name__` method. This is " -"only used in cases where a descriptor needs to know either the class where " -"it was created or the name of class variable it was assigned to. (This " -"method, if present, is called even if the class is not a descriptor.)" +"Optionally, descriptors can have a :meth:`~object.__set_name__` method. " +"This is only used in cases where a descriptor needs to know either the class " +"where it was created or the name of class variable it was assigned to. " +"(This method, if present, is called even if the class is not a descriptor.)" msgstr "" #: ../../howto/descriptor.rst:305 @@ -498,7 +498,7 @@ msgstr "" #: ../../howto/descriptor.rst:340 msgid "" -"This :class:`Validator` class is both an :term:`abstract base class` and a " +"This :class:`!Validator` class is both an :term:`abstract base class` and a " "managed attribute descriptor:" msgstr "" @@ -542,8 +542,8 @@ msgstr "" #: ../../howto/descriptor.rst:363 msgid "" -"Custom validators need to inherit from :class:`Validator` and must supply a :" -"meth:`validate` method to test various restrictions as needed." +"Custom validators need to inherit from :class:`!Validator` and must supply " +"a :meth:`!validate` method to test various restrictions as needed." msgstr "" #: ../../howto/descriptor.rst:368 @@ -556,19 +556,19 @@ msgstr "" #: ../../howto/descriptor.rst:372 msgid "" -":class:`OneOf` verifies that a value is one of a restricted set of options." +":class:`!OneOf` verifies that a value is one of a restricted set of options." msgstr "" #: ../../howto/descriptor.rst:374 msgid "" -":class:`Number` verifies that a value is either an :class:`int` or :class:" +":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 msgid "" -":class:`String` verifies that a value is a :class:`str`. Optionally, it " +":class:`!String` verifies that a value is a :class:`str`. Optionally, it " "validates a given minimum or maximum length. It can validate a user-defined " "`predicate `_ " "as well." @@ -583,8 +583,9 @@ msgid "" "\n" " def validate(self, value):\n" " if value not in self.options:\n" -" raise ValueError(f'Expected {value!r} to be one of {self.options!" -"r}')\n" +" raise ValueError(\n" +" f'Expected {value!r} to be one of {self.options!r}'\n" +" )\n" "\n" "class Number(Validator):\n" "\n" @@ -629,15 +630,15 @@ msgid "" " )" msgstr "" -#: ../../howto/descriptor.rst:437 +#: ../../howto/descriptor.rst:439 msgid "Practical application" msgstr "" -#: ../../howto/descriptor.rst:439 +#: ../../howto/descriptor.rst:441 msgid "Here's how the data validators can be used in a real class:" msgstr "" -#: ../../howto/descriptor.rst:441 +#: ../../howto/descriptor.rst:443 msgid "" "class Component:\n" "\n" @@ -651,11 +652,11 @@ msgid "" " self.quantity = quantity" msgstr "" -#: ../../howto/descriptor.rst:454 +#: ../../howto/descriptor.rst:456 msgid "The descriptors prevent invalid instances from being created:" msgstr "" -#: ../../howto/descriptor.rst:456 +#: ../../howto/descriptor.rst:458 msgid "" ">>> Component('Widget', 'metal', 5) # Blocked: 'Widget' is not all " "uppercase\n" @@ -673,6 +674,7 @@ msgid "" "Traceback (most recent call last):\n" " ...\n" "ValueError: Expected -5 to be at least 0\n" +"\n" ">>> Component('WIDGET', 'metal', 'V') # Blocked: 'V' isn't a number\n" "Traceback (most recent call last):\n" " ...\n" @@ -681,45 +683,45 @@ msgid "" ">>> c = Component('WIDGET', 'metal', 5) # Allowed: The inputs are valid" msgstr "" -#: ../../howto/descriptor.rst:481 +#: ../../howto/descriptor.rst:484 msgid "Technical Tutorial" msgstr "" -#: ../../howto/descriptor.rst:483 +#: ../../howto/descriptor.rst:486 msgid "" "What follows is a more technical tutorial for the mechanics and details of " "how descriptors work." msgstr "" -#: ../../howto/descriptor.rst:488 +#: ../../howto/descriptor.rst:491 msgid "Abstract" msgstr "摘要" -#: ../../howto/descriptor.rst:490 +#: ../../howto/descriptor.rst:493 msgid "" "Defines descriptors, summarizes the protocol, and shows how descriptors are " "called. Provides an example showing how object relational mappings work." msgstr "" -#: ../../howto/descriptor.rst:493 +#: ../../howto/descriptor.rst:496 msgid "" "Learning about descriptors not only provides access to a larger toolset, it " "creates a deeper understanding of how Python works." msgstr "" -#: ../../howto/descriptor.rst:498 +#: ../../howto/descriptor.rst:501 msgid "Definition and introduction" msgstr "" -#: ../../howto/descriptor.rst:500 +#: ../../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:`__get__`, :meth:" -"`__set__`, and :meth:`__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:505 +#: ../../howto/descriptor.rst:508 msgid "" "The default behavior for attribute access is to get, set, or delete the " "attribute from an object's dictionary. For instance, ``a.x`` has a lookup " @@ -731,7 +733,7 @@ msgid "" "methods were defined." msgstr "" -#: ../../howto/descriptor.rst:514 +#: ../../howto/descriptor.rst:517 msgid "" "Descriptors are a powerful, general purpose protocol. They are the " "mechanism behind properties, methods, static methods, class methods, and :" @@ -740,38 +742,38 @@ msgid "" "Python programs." msgstr "" -#: ../../howto/descriptor.rst:522 +#: ../../howto/descriptor.rst:525 msgid "Descriptor protocol" msgstr "描述器協定" -#: ../../howto/descriptor.rst:524 +#: ../../howto/descriptor.rst:527 msgid "``descr.__get__(self, obj, type=None)``" msgstr "``descr.__get__(self, obj, type=None)``" -#: ../../howto/descriptor.rst:526 +#: ../../howto/descriptor.rst:529 msgid "``descr.__set__(self, obj, value)``" msgstr "``descr.__set__(self, obj, value)``" -#: ../../howto/descriptor.rst:528 +#: ../../howto/descriptor.rst:531 msgid "``descr.__delete__(self, obj)``" msgstr "``descr.__delete__(self, obj)``" -#: ../../howto/descriptor.rst:530 +#: ../../howto/descriptor.rst:533 msgid "" "That is all there is to it. Define any of these methods and an object is " "considered a descriptor and can override default behavior upon being looked " "up as an attribute." msgstr "" -#: ../../howto/descriptor.rst:534 +#: ../../howto/descriptor.rst:537 msgid "" -"If an object defines :meth:`__set__` or :meth:`__delete__`, it is considered " -"a data descriptor. Descriptors that only define :meth:`__get__` are called " -"non-data descriptors (they are often used for methods but other uses are " -"possible)." +"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)." msgstr "" -#: ../../howto/descriptor.rst:539 +#: ../../howto/descriptor.rst:542 msgid "" "Data and non-data descriptors differ in how overrides are calculated with " "respect to entries in an instance's dictionary. If an instance's dictionary " @@ -780,69 +782,69 @@ msgid "" "name as a non-data descriptor, the dictionary entry takes precedence." msgstr "" -#: ../../howto/descriptor.rst:545 +#: ../../howto/descriptor.rst:548 msgid "" -"To make a read-only data descriptor, define both :meth:`__get__` and :meth:" -"`__set__` with the :meth:`__set__` raising an :exc:`AttributeError` when " -"called. Defining the :meth:`__set__` method with an exception raising " -"placeholder is enough to make it a data descriptor." +"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." msgstr "" -#: ../../howto/descriptor.rst:552 +#: ../../howto/descriptor.rst:555 msgid "Overview of descriptor invocation" msgstr "" -#: ../../howto/descriptor.rst:554 +#: ../../howto/descriptor.rst:557 msgid "" "A descriptor can be called directly with ``desc.__get__(obj)`` or ``desc." "__get__(None, cls)``." msgstr "" -#: ../../howto/descriptor.rst:557 +#: ../../howto/descriptor.rst:560 msgid "" "But it is more common for a descriptor to be invoked automatically from " "attribute access." msgstr "" -#: ../../howto/descriptor.rst:560 +#: ../../howto/descriptor.rst:563 msgid "" "The expression ``obj.x`` looks up the attribute ``x`` in the chain of " "namespaces for ``obj``. If the search finds a descriptor outside of the " -"instance ``__dict__``, its :meth:`__get__` method is invoked according to " -"the precedence rules listed below." +"instance :attr:`~object.__dict__`, its :meth:`~object.__get__` method is " +"invoked according to the precedence rules listed below." msgstr "" -#: ../../howto/descriptor.rst:565 +#: ../../howto/descriptor.rst:568 msgid "" "The details of invocation depend on whether ``obj`` is an object, class, or " "instance of super." msgstr "" -#: ../../howto/descriptor.rst:570 +#: ../../howto/descriptor.rst:573 msgid "Invocation from an instance" msgstr "" -#: ../../howto/descriptor.rst:572 +#: ../../howto/descriptor.rst:575 msgid "" "Instance lookup scans through a chain of namespaces giving data descriptors " "the highest priority, followed by instance variables, then non-data " -"descriptors, then class variables, and lastly :meth:`__getattr__` if it is " -"provided." +"descriptors, then class variables, and lastly :meth:`~object.__getattr__` if " +"it is provided." msgstr "" -#: ../../howto/descriptor.rst:577 +#: ../../howto/descriptor.rst:580 msgid "" "If a descriptor is found for ``a.x``, then it is invoked with: ``desc." "__get__(a, type(a))``." msgstr "" -#: ../../howto/descriptor.rst:580 +#: ../../howto/descriptor.rst:583 msgid "" "The logic for a dotted lookup is in :meth:`object.__getattribute__`. Here " "is a pure Python equivalent:" msgstr "" -#: ../../howto/descriptor.rst:583 +#: ../../howto/descriptor.rst:586 msgid "" "def find_name_in_mro(cls, name, default):\n" " \"Emulate _PyType_Lookup() in Objects/typeobject.c\"\n" @@ -871,22 +873,23 @@ msgid "" " raise AttributeError(name)" msgstr "" -#: ../../howto/descriptor.rst:719 +#: ../../howto/descriptor.rst:722 msgid "" -"Note, there is no :meth:`__getattr__` hook in the :meth:`__getattribute__` " -"code. That is why calling :meth:`__getattribute__` directly or with " -"``super().__getattribute__`` will bypass :meth:`__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:723 +#: ../../howto/descriptor.rst:726 msgid "" "Instead, it is the dot operator and the :func:`getattr` function that are " -"responsible for invoking :meth:`__getattr__` whenever :meth:" -"`__getattribute__` raises an :exc:`AttributeError`. Their logic is " +"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:728 +#: ../../howto/descriptor.rst:731 msgid "" "def getattr_hook(obj, name):\n" " \"Emulate slot_tp_getattr_hook() in Objects/typeobject.c\"\n" @@ -906,39 +909,39 @@ msgstr "" " raise\n" " return type(obj).__getattr__(obj, name) # __getattr__" -#: ../../howto/descriptor.rst:773 +#: ../../howto/descriptor.rst:776 msgid "Invocation from a class" msgstr "" -#: ../../howto/descriptor.rst:775 +#: ../../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." +"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:780 +#: ../../howto/descriptor.rst:783 msgid "If a descriptor is found, it is invoked with ``desc.__get__(None, A)``." msgstr "" -#: ../../howto/descriptor.rst:782 +#: ../../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`." msgstr "" -#: ../../howto/descriptor.rst:787 +#: ../../howto/descriptor.rst:790 msgid "Invocation from super" msgstr "" -#: ../../howto/descriptor.rst:789 +#: ../../howto/descriptor.rst:792 msgid "" -"The logic for super's dotted lookup is in the :meth:`__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:792 +#: ../../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 " @@ -946,7 +949,7 @@ msgid "" "returned unchanged." msgstr "" -#: ../../howto/descriptor.rst:797 +#: ../../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 " @@ -954,98 +957,99 @@ msgid "" "#cooperation>`_." msgstr "" -#: ../../howto/descriptor.rst:804 +#: ../../howto/descriptor.rst:807 msgid "Summary of invocation logic" msgstr "" -#: ../../howto/descriptor.rst:806 +#: ../../howto/descriptor.rst:809 msgid "" -"The mechanism for descriptors is embedded in the :meth:`__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:809 +#: ../../howto/descriptor.rst:812 msgid "The important points to remember are:" msgstr "要記住的重點是:" -#: ../../howto/descriptor.rst:811 -msgid "Descriptors are invoked by the :meth:`__getattribute__` method." +#: ../../howto/descriptor.rst:814 +msgid "Descriptors are invoked by the :meth:`~object.__getattribute__` method." msgstr "" -#: ../../howto/descriptor.rst:813 +#: ../../howto/descriptor.rst:816 msgid "" "Classes inherit this machinery from :class:`object`, :class:`type`, or :func:" "`super`." msgstr "" -#: ../../howto/descriptor.rst:816 +#: ../../howto/descriptor.rst:819 msgid "" -"Overriding :meth:`__getattribute__` prevents automatic descriptor calls " -"because all the descriptor logic is in that method." +"Overriding :meth:`~object.__getattribute__` prevents automatic descriptor " +"calls because all the descriptor logic is in that method." msgstr "" -#: ../../howto/descriptor.rst:819 +#: ../../howto/descriptor.rst:822 msgid "" -":meth:`object.__getattribute__` and :meth:`type.__getattribute__` make " -"different calls to :meth:`__get__`. The first includes the instance and may " -"include the class. The second puts in ``None`` for the instance and always " -"includes the class." +":meth:`!object.__getattribute__` and :meth:`!type.__getattribute__` make " +"different calls to :meth:`~object.__get__`. The first includes the instance " +"and may include the class. The second puts in ``None`` for the instance and " +"always includes the class." msgstr "" -#: ../../howto/descriptor.rst:824 +#: ../../howto/descriptor.rst:827 msgid "Data descriptors always override instance dictionaries." msgstr "" -#: ../../howto/descriptor.rst:826 +#: ../../howto/descriptor.rst:829 msgid "Non-data descriptors may be overridden by instance dictionaries." msgstr "" -#: ../../howto/descriptor.rst:830 +#: ../../howto/descriptor.rst:833 msgid "Automatic name notification" msgstr "" -#: ../../howto/descriptor.rst:832 +#: ../../howto/descriptor.rst:835 msgid "" "Sometimes it is desirable for a descriptor to know what class variable name " "it was assigned to. When a new class is created, the :class:`type` " "metaclass scans the dictionary of the new class. If any of the entries are " -"descriptors and if they define :meth:`__set_name__`, that method is called " -"with two arguments. The *owner* is the class where the descriptor is used, " -"and the *name* is the class variable the descriptor was assigned to." +"descriptors and if they define :meth:`~object.__set_name__`, that method is " +"called with two arguments. The *owner* is the class where the descriptor is " +"used, and the *name* is the class variable the descriptor was assigned to." msgstr "" -#: ../../howto/descriptor.rst:839 +#: ../../howto/descriptor.rst:842 msgid "" "The implementation details are in :c:func:`!type_new` and :c:func:`!" "set_names` in :source:`Objects/typeobject.c`." msgstr "" -#: ../../howto/descriptor.rst:842 +#: ../../howto/descriptor.rst:845 msgid "" -"Since the update logic is in :meth:`type.__new__`, notifications only take " +"Since the update logic is in :meth:`!type.__new__`, notifications only take " "place at the time of class creation. If descriptors are added to the class " -"afterwards, :meth:`__set_name__` will need to be called manually." +"afterwards, :meth:`~object.__set_name__` will need to be called manually." msgstr "" -#: ../../howto/descriptor.rst:848 +#: ../../howto/descriptor.rst:851 msgid "ORM example" msgstr "ORM 範例" -#: ../../howto/descriptor.rst:850 +#: ../../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 `_." msgstr "" -#: ../../howto/descriptor.rst:854 +#: ../../howto/descriptor.rst:857 msgid "" "The essential idea is that the data is stored in an external database. The " "Python instances only hold keys to the database's tables. Descriptors take " "care of lookups or updates:" msgstr "" -#: ../../howto/descriptor.rst:858 +#: ../../howto/descriptor.rst:861 msgid "" "class Field:\n" "\n" @@ -1077,14 +1081,14 @@ msgstr "" " conn.execute(self.store, [value, obj.key])\n" " conn.commit()" -#: ../../howto/descriptor.rst:873 +#: ../../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:" msgstr "" -#: ../../howto/descriptor.rst:877 +#: ../../howto/descriptor.rst:880 msgid "" "class Movie:\n" " table = 'Movies' # Table name\n" @@ -1106,11 +1110,11 @@ msgid "" " self.key = key" msgstr "" -#: ../../howto/descriptor.rst:898 +#: ../../howto/descriptor.rst:901 msgid "To use the models, first connect to the database::" msgstr "" -#: ../../howto/descriptor.rst:900 +#: ../../howto/descriptor.rst:903 msgid "" ">>> import sqlite3\n" ">>> conn = sqlite3.connect('entertainment.db')" @@ -1118,13 +1122,13 @@ msgstr "" ">>> import sqlite3\n" ">>> conn = sqlite3.connect('entertainment.db')" -#: ../../howto/descriptor.rst:903 +#: ../../howto/descriptor.rst:906 msgid "" "An interactive session shows how data is retrieved from the database and how " "it can be updated:" msgstr "" -#: ../../howto/descriptor.rst:931 +#: ../../howto/descriptor.rst:934 msgid "" ">>> Movie('Star Wars').director\n" "'George Lucas'\n" @@ -1152,11 +1156,11 @@ msgstr "" ">>> Movie('Star Wars').director\n" "'J.J. Abrams'" -#: ../../howto/descriptor.rst:952 +#: ../../howto/descriptor.rst:955 msgid "Pure Python Equivalents" msgstr "" -#: ../../howto/descriptor.rst:954 +#: ../../howto/descriptor.rst:957 msgid "" "The descriptor protocol is simple and offers exciting possibilities. " "Several use cases are so common that they have been prepackaged into built-" @@ -1164,27 +1168,27 @@ msgid "" "\\_\\_slots\\_\\_ are all based on the descriptor protocol." msgstr "" -#: ../../howto/descriptor.rst:961 +#: ../../howto/descriptor.rst:964 msgid "Properties" msgstr "" -#: ../../howto/descriptor.rst:963 +#: ../../howto/descriptor.rst:966 msgid "" "Calling :func:`property` is a succinct way of building a data descriptor " "that triggers a function call upon access to an attribute. Its signature " "is::" msgstr "" -#: ../../howto/descriptor.rst:966 +#: ../../howto/descriptor.rst:969 msgid "property(fget=None, fset=None, fdel=None, doc=None) -> property" msgstr "property(fget=None, fset=None, fdel=None, doc=None) -> property" -#: ../../howto/descriptor.rst:968 +#: ../../howto/descriptor.rst:971 msgid "" "The documentation shows a typical use to define a managed attribute ``x``:" msgstr "" -#: ../../howto/descriptor.rst:970 +#: ../../howto/descriptor.rst:973 msgid "" "class C:\n" " def getx(self): return self.__x\n" @@ -1198,14 +1202,14 @@ msgstr "" " def delx(self): del self.__x\n" " x = property(getx, setx, delx, \"I'm the 'x' property.\")" -#: ../../howto/descriptor.rst:992 +#: ../../howto/descriptor.rst:995 msgid "" "To see how :func:`property` is implemented in terms of the descriptor " "protocol, here is a pure Python equivalent that implements most of the core " "functionality:" msgstr "" -#: ../../howto/descriptor.rst:995 +#: ../../howto/descriptor.rst:998 msgid "" "class Property:\n" " \"Emulate PyProperty_Type() in Objects/descrobject.c\"\n" @@ -1217,7 +1221,6 @@ msgid "" " if doc is None and fget is not None:\n" " doc = fget.__doc__\n" " self.__doc__ = doc\n" -" self.__name__ = ''\n" "\n" " def __set_name__(self, owner, name):\n" " self.__name__ = name\n" @@ -1249,14 +1252,14 @@ msgid "" " return type(self)(self.fget, self.fset, fdel, self.__doc__)" msgstr "" -#: ../../howto/descriptor.rst:1120 +#: ../../howto/descriptor.rst:1122 msgid "" "The :func:`property` builtin helps whenever a user interface has granted " "attribute access and then subsequent changes require the intervention of a " "method." msgstr "" -#: ../../howto/descriptor.rst:1124 +#: ../../howto/descriptor.rst:1126 msgid "" "For instance, a spreadsheet class may grant access to a cell value through " "``Cell('b10').value``. Subsequent improvements to the program require the " @@ -1266,7 +1269,7 @@ msgid "" "descriptor:" msgstr "" -#: ../../howto/descriptor.rst:1130 +#: ../../howto/descriptor.rst:1132 msgid "" "class Cell:\n" " ...\n" @@ -1278,23 +1281,23 @@ msgid "" " return self._value" msgstr "" -#: ../../howto/descriptor.rst:1141 +#: ../../howto/descriptor.rst:1143 msgid "" -"Either the built-in :func:`property` or our :func:`Property` equivalent " +"Either the built-in :func:`property` or our :func:`!Property` equivalent " "would work in this example." msgstr "" -#: ../../howto/descriptor.rst:1146 +#: ../../howto/descriptor.rst:1148 msgid "Functions and methods" msgstr "" -#: ../../howto/descriptor.rst:1148 +#: ../../howto/descriptor.rst:1150 msgid "" "Python's object oriented features are built upon a function based " "environment. Using non-data descriptors, the two are merged seamlessly." msgstr "" -#: ../../howto/descriptor.rst:1151 +#: ../../howto/descriptor.rst:1153 msgid "" "Functions stored in class dictionaries get turned into methods when invoked. " "Methods only differ from regular functions in that the object instance is " @@ -1302,13 +1305,13 @@ msgid "" "*self* but could be called *this* or any other variable name." msgstr "" -#: ../../howto/descriptor.rst:1156 +#: ../../howto/descriptor.rst:1158 msgid "" "Methods can be created manually with :class:`types.MethodType` which is " "roughly equivalent to:" msgstr "" -#: ../../howto/descriptor.rst:1159 +#: ../../howto/descriptor.rst:1161 msgid "" "class MethodType:\n" " \"Emulate PyMethod_Type in Objects/classobject.c\"\n" @@ -1337,15 +1340,15 @@ msgid "" " return self" msgstr "" -#: ../../howto/descriptor.rst:1187 +#: ../../howto/descriptor.rst:1189 msgid "" "To support automatic creation of methods, functions include the :meth:" -"`__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:" +"`~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:1192 +#: ../../howto/descriptor.rst:1194 msgid "" "class Function:\n" " ...\n" @@ -1357,13 +1360,13 @@ msgid "" " return MethodType(self, obj)" msgstr "" -#: ../../howto/descriptor.rst:1203 +#: ../../howto/descriptor.rst:1205 msgid "" "Running the following class in the interpreter shows how the function " "descriptor works in practice:" msgstr "" -#: ../../howto/descriptor.rst:1206 +#: ../../howto/descriptor.rst:1208 #, fuzzy msgid "" "class D:\n" @@ -1377,12 +1380,12 @@ msgstr "" " def f(self, x):\n" " return x" -#: ../../howto/descriptor.rst:1224 +#: ../../howto/descriptor.rst:1226 msgid "" "The function has a :term:`qualified name` attribute to support introspection:" msgstr "" -#: ../../howto/descriptor.rst:1226 +#: ../../howto/descriptor.rst:1228 msgid "" ">>> D.f.__qualname__\n" "'D.f'" @@ -1390,13 +1393,13 @@ msgstr "" ">>> D.f.__qualname__\n" "'D.f'" -#: ../../howto/descriptor.rst:1231 +#: ../../howto/descriptor.rst:1233 msgid "" "Accessing the function through the class dictionary does not invoke :meth:" -"`__get__`. Instead, it just returns the underlying function object::" +"`~object.__get__`. Instead, it just returns the underlying function object::" msgstr "" -#: ../../howto/descriptor.rst:1234 +#: ../../howto/descriptor.rst:1236 msgid "" ">>> D.__dict__['f']\n" "" @@ -1404,13 +1407,13 @@ msgstr "" ">>> D.__dict__['f']\n" "" -#: ../../howto/descriptor.rst:1237 +#: ../../howto/descriptor.rst:1239 msgid "" -"Dotted access from a class calls :meth:`__get__` which just returns the " -"underlying function unchanged::" +"Dotted access from a class calls :meth:`~object.__get__` which just returns " +"the underlying function unchanged::" msgstr "" -#: ../../howto/descriptor.rst:1240 +#: ../../howto/descriptor.rst:1242 msgid "" ">>> D.f\n" "" @@ -1418,13 +1421,14 @@ msgstr "" ">>> D.f\n" "" -#: ../../howto/descriptor.rst:1243 +#: ../../howto/descriptor.rst:1245 msgid "" "The interesting behavior occurs during dotted access from an instance. The " -"dotted lookup calls :meth:`__get__` which returns a bound method object::" +"dotted lookup calls :meth:`~object.__get__` which returns a bound method " +"object::" msgstr "" -#: ../../howto/descriptor.rst:1246 +#: ../../howto/descriptor.rst:1248 msgid "" ">>> d = D()\n" ">>> d.f\n" @@ -1434,13 +1438,13 @@ msgstr "" ">>> d.f\n" ">" -#: ../../howto/descriptor.rst:1250 +#: ../../howto/descriptor.rst:1252 msgid "" "Internally, the bound method stores the underlying function and the bound " "instance::" msgstr "" -#: ../../howto/descriptor.rst:1253 +#: ../../howto/descriptor.rst:1255 msgid "" ">>> d.f.__func__\n" "\n" @@ -1454,79 +1458,79 @@ msgstr "" ">>> d.f.__self__\n" "<__main__.D object at 0x00B18C90>" -#: ../../howto/descriptor.rst:1259 +#: ../../howto/descriptor.rst:1261 msgid "" "If you have ever wondered where *self* comes from in regular methods or " "where *cls* comes from in class methods, this is it!" msgstr "" -#: ../../howto/descriptor.rst:1264 +#: ../../howto/descriptor.rst:1266 msgid "Kinds of methods" msgstr "" -#: ../../howto/descriptor.rst:1266 +#: ../../howto/descriptor.rst:1268 msgid "" "Non-data descriptors provide a simple mechanism for variations on the usual " "patterns of binding functions into methods." msgstr "" -#: ../../howto/descriptor.rst:1269 +#: ../../howto/descriptor.rst:1271 msgid "" -"To recap, functions have a :meth:`__get__` method so that they can be " -"converted to a method when accessed as attributes. The non-data descriptor " -"transforms an ``obj.f(*args)`` call into ``f(obj, *args)``. Calling ``cls." -"f(*args)`` becomes ``f(*args)``." +"To recap, functions have a :meth:`~object.__get__` method so that they can " +"be converted to a method when accessed as attributes. The non-data " +"descriptor transforms an ``obj.f(*args)`` call into ``f(obj, *args)``. " +"Calling ``cls.f(*args)`` becomes ``f(*args)``." msgstr "" -#: ../../howto/descriptor.rst:1274 +#: ../../howto/descriptor.rst:1276 msgid "This chart summarizes the binding and its two most useful variants:" msgstr "" -#: ../../howto/descriptor.rst:1277 +#: ../../howto/descriptor.rst:1279 msgid "Transformation" msgstr "" -#: ../../howto/descriptor.rst:1277 +#: ../../howto/descriptor.rst:1279 msgid "Called from an object" msgstr "" -#: ../../howto/descriptor.rst:1277 +#: ../../howto/descriptor.rst:1279 msgid "Called from a class" msgstr "" -#: ../../howto/descriptor.rst:1280 +#: ../../howto/descriptor.rst:1282 msgid "function" msgstr "函式" -#: ../../howto/descriptor.rst:1280 +#: ../../howto/descriptor.rst:1282 msgid "f(obj, \\*args)" msgstr "f(obj, \\*args)" -#: ../../howto/descriptor.rst:1280 ../../howto/descriptor.rst:1282 +#: ../../howto/descriptor.rst:1282 ../../howto/descriptor.rst:1284 msgid "f(\\*args)" msgstr "f(\\*args)" -#: ../../howto/descriptor.rst:1282 +#: ../../howto/descriptor.rst:1284 msgid "staticmethod" msgstr "staticmethod" -#: ../../howto/descriptor.rst:1284 +#: ../../howto/descriptor.rst:1286 msgid "classmethod" msgstr "classmethod" -#: ../../howto/descriptor.rst:1284 +#: ../../howto/descriptor.rst:1286 msgid "f(type(obj), \\*args)" msgstr "f(type(obj), \\*args)" -#: ../../howto/descriptor.rst:1284 +#: ../../howto/descriptor.rst:1286 msgid "f(cls, \\*args)" msgstr "f(cls, \\*args)" -#: ../../howto/descriptor.rst:1289 +#: ../../howto/descriptor.rst:1291 msgid "Static methods" msgstr "" -#: ../../howto/descriptor.rst:1291 +#: ../../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." @@ -1535,13 +1539,13 @@ msgid "" "a class." msgstr "" -#: ../../howto/descriptor.rst:1297 +#: ../../howto/descriptor.rst:1299 msgid "" "Good candidates for static methods are methods that do not reference the " "``self`` variable." msgstr "" -#: ../../howto/descriptor.rst:1300 +#: ../../howto/descriptor.rst:1302 msgid "" "For instance, a statistics package may include a container class for " "experimental data. The class provides normal methods for computing the " @@ -1550,16 +1554,16 @@ msgid "" "but do not depend on the data. For instance, ``erf(x)`` is handy conversion " "routine that comes up in statistical work but does not directly depend on a " "particular dataset. It can be called either from an object or the class: " -"``s.erf(1.5) --> .9332`` or ``Sample.erf(1.5) --> .9332``." +"``s.erf(1.5) --> 0.9332`` or ``Sample.erf(1.5) --> 0.9332``." msgstr "" -#: ../../howto/descriptor.rst:1309 +#: ../../howto/descriptor.rst:1311 msgid "" "Since static methods return the underlying function with no changes, the " "example calls are unexciting:" msgstr "" -#: ../../howto/descriptor.rst:1312 +#: ../../howto/descriptor.rst:1314 msgid "" "class E:\n" " @staticmethod\n" @@ -1571,7 +1575,7 @@ msgstr "" " def f(x):\n" " return x * 10" -#: ../../howto/descriptor.rst:1319 +#: ../../howto/descriptor.rst:1321 msgid "" ">>> E.f(3)\n" "30\n" @@ -1583,13 +1587,13 @@ msgstr "" ">>> E().f(3)\n" "30" -#: ../../howto/descriptor.rst:1326 +#: ../../howto/descriptor.rst:1328 msgid "" "Using the non-data descriptor protocol, a pure Python version of :func:" "`staticmethod` would look like this:" msgstr "" -#: ../../howto/descriptor.rst:1329 +#: ../../howto/descriptor.rst:1331 msgid "" "import functools\n" "\n" @@ -1607,7 +1611,7 @@ msgid "" " return self.f(*args, **kwds)" msgstr "" -#: ../../howto/descriptor.rst:1346 +#: ../../howto/descriptor.rst:1348 msgid "" "The :func:`functools.update_wrapper` call adds a ``__wrapped__`` attribute " "that refers to the underlying function. Also it carries forward the " @@ -1616,18 +1620,18 @@ msgid "" "__doc__`, and :attr:`~function.__annotations__`." msgstr "" -#: ../../howto/descriptor.rst:1415 +#: ../../howto/descriptor.rst:1417 msgid "Class methods" msgstr "" -#: ../../howto/descriptor.rst:1417 +#: ../../howto/descriptor.rst:1419 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:1421 +#: ../../howto/descriptor.rst:1423 msgid "" "class F:\n" " @classmethod\n" @@ -1639,7 +1643,7 @@ msgstr "" " def f(cls, x):\n" " return cls.__name__, x" -#: ../../howto/descriptor.rst:1428 +#: ../../howto/descriptor.rst:1430 msgid "" ">>> F.f(3)\n" "('F', 3)\n" @@ -1651,7 +1655,7 @@ msgstr "" ">>> F().f(3)\n" "('F', 3)" -#: ../../howto/descriptor.rst:1435 +#: ../../howto/descriptor.rst:1437 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 " @@ -1660,7 +1664,7 @@ msgid "" "of keys. The pure Python equivalent is:" msgstr "" -#: ../../howto/descriptor.rst:1441 +#: ../../howto/descriptor.rst:1443 msgid "" "class Dict(dict):\n" " @classmethod\n" @@ -1672,11 +1676,11 @@ msgid "" " return d" msgstr "" -#: ../../howto/descriptor.rst:1452 +#: ../../howto/descriptor.rst:1454 msgid "Now a new dictionary of unique keys can be constructed like this:" msgstr "" -#: ../../howto/descriptor.rst:1454 +#: ../../howto/descriptor.rst:1456 msgid "" ">>> d = Dict.fromkeys('abracadabra')\n" ">>> type(d) is Dict\n" @@ -1690,13 +1694,13 @@ msgstr "" ">>> d\n" "{'a': None, 'b': None, 'r': None, 'c': None, 'd': None}" -#: ../../howto/descriptor.rst:1462 +#: ../../howto/descriptor.rst:1464 msgid "" "Using the non-data descriptor protocol, a pure Python version of :func:" "`classmethod` would look like this:" msgstr "" -#: ../../howto/descriptor.rst:1465 +#: ../../howto/descriptor.rst:1467 msgid "" "import functools\n" "\n" @@ -1713,7 +1717,7 @@ msgid "" " return MethodType(self.f, cls)" msgstr "" -#: ../../howto/descriptor.rst:1527 +#: ../../howto/descriptor.rst:1529 msgid "" "The :func:`functools.update_wrapper` call in ``ClassMethod`` adds a " "``__wrapped__`` attribute that refers to the underlying function. Also it " @@ -1723,24 +1727,24 @@ msgid "" "__annotations__`." msgstr "" -#: ../../howto/descriptor.rst:1536 +#: ../../howto/descriptor.rst:1538 msgid "Member objects and __slots__" msgstr "" -#: ../../howto/descriptor.rst:1538 +#: ../../howto/descriptor.rst:1540 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:1542 +#: ../../howto/descriptor.rst:1544 msgid "" "1. Provides immediate detection of bugs due to misspelled attribute " "assignments. Only attribute names specified in ``__slots__`` are allowed:" msgstr "" -#: ../../howto/descriptor.rst:1545 +#: ../../howto/descriptor.rst:1547 msgid "" "class Vehicle:\n" " __slots__ = ('id_number', 'make', 'model')" @@ -1748,7 +1752,7 @@ msgstr "" "class Vehicle:\n" " __slots__ = ('id_number', 'make', 'model')" -#: ../../howto/descriptor.rst:1550 +#: ../../howto/descriptor.rst:1552 msgid "" ">>> auto = Vehicle()\n" ">>> auto.id_nubmer = 'VYE483814LQEX'\n" @@ -1762,13 +1766,13 @@ msgstr "" " ...\n" "AttributeError: 'Vehicle' object has no attribute 'id_nubmer'" -#: ../../howto/descriptor.rst:1558 +#: ../../howto/descriptor.rst:1560 msgid "" "2. Helps create immutable objects where descriptors manage access to private " "attributes stored in ``__slots__``:" msgstr "" -#: ../../howto/descriptor.rst:1561 +#: ../../howto/descriptor.rst:1563 msgid "" "class Immutable:\n" "\n" @@ -1788,7 +1792,7 @@ msgid "" " return self._name" msgstr "" -#: ../../howto/descriptor.rst:1579 +#: ../../howto/descriptor.rst:1581 msgid "" ">>> mark = Immutable('Botany', 'Mark Watney')\n" ">>> mark.dept\n" @@ -1814,7 +1818,7 @@ msgstr "" " ...\n" "AttributeError: 'Immutable' object has no attribute 'location'" -#: ../../howto/descriptor.rst:1593 +#: ../../howto/descriptor.rst:1595 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 " @@ -1822,19 +1826,19 @@ msgid "" "only matters when a large number of instances are going to be created." msgstr "" -#: ../../howto/descriptor.rst:1598 +#: ../../howto/descriptor.rst:1600 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:1601 +#: ../../howto/descriptor.rst:1603 msgid "" "5. Blocks tools like :func:`functools.cached_property` which require an " "instance dictionary to function correctly:" msgstr "" -#: ../../howto/descriptor.rst:1604 +#: ../../howto/descriptor.rst:1606 msgid "" "from functools import cached_property\n" "\n" @@ -1847,7 +1851,7 @@ msgid "" " for n in reversed(range(100_000)))" msgstr "" -#: ../../howto/descriptor.rst:1616 +#: ../../howto/descriptor.rst:1618 msgid "" ">>> CP().pi\n" "Traceback (most recent call last):\n" @@ -1859,7 +1863,7 @@ msgstr "" " ...\n" "TypeError: No '__dict__' attribute on 'CP' instance to cache 'pi' property." -#: ../../howto/descriptor.rst:1623 +#: ../../howto/descriptor.rst:1625 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 " @@ -1869,7 +1873,7 @@ msgid "" "managed by member descriptors:" msgstr "" -#: ../../howto/descriptor.rst:1630 +#: ../../howto/descriptor.rst:1632 msgid "" "null = object()\n" "\n" @@ -1908,13 +1912,13 @@ msgid "" " return f''" msgstr "" -#: ../../howto/descriptor.rst:1668 +#: ../../howto/descriptor.rst:1670 msgid "" -"The :meth:`type.__new__` method takes care of adding member objects to class " -"variables:" +"The :meth:`!type.__new__` method takes care of adding member objects to " +"class variables:" msgstr "" -#: ../../howto/descriptor.rst:1671 +#: ../../howto/descriptor.rst:1673 msgid "" "class Type(type):\n" " 'Simulate how the type metaclass adds member objects for slots'\n" @@ -1928,14 +1932,14 @@ msgid "" " return type.__new__(mcls, clsname, bases, mapping, **kwargs)" msgstr "" -#: ../../howto/descriptor.rst:1684 +#: ../../howto/descriptor.rst:1686 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:1688 +#: ../../howto/descriptor.rst:1690 msgid "" "class Object:\n" " 'Simulate how object.__new__() allocates memory for __slots__'\n" @@ -1967,13 +1971,13 @@ msgid "" " super().__delattr__(name)" msgstr "" -#: ../../howto/descriptor.rst:1719 +#: ../../howto/descriptor.rst:1721 msgid "" -"To use the simulation in a real class, just inherit from :class:`Object` and " -"set the :term:`metaclass` to :class:`Type`:" +"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:1722 +#: ../../howto/descriptor.rst:1724 msgid "" "class H(Object, metaclass=Type):\n" " 'Instance variables stored in slots'\n" @@ -1985,12 +1989,12 @@ msgid "" " self.y = y" msgstr "" -#: ../../howto/descriptor.rst:1733 +#: ../../howto/descriptor.rst:1735 msgid "" "At this point, the metaclass has loaded member objects for *x* and *y*::" msgstr "" -#: ../../howto/descriptor.rst:1735 +#: ../../howto/descriptor.rst:1737 msgid "" ">>> from pprint import pp\n" ">>> pp(dict(vars(H)))\n" @@ -2010,13 +2014,13 @@ msgstr "" " 'x': ,\n" " 'y': }" -#: ../../howto/descriptor.rst:1754 +#: ../../howto/descriptor.rst:1756 msgid "" "When instances are created, they have a ``slot_values`` list where the " "attributes are stored:" msgstr "" -#: ../../howto/descriptor.rst:1757 +#: ../../howto/descriptor.rst:1759 msgid "" ">>> h = H(10, 20)\n" ">>> vars(h)\n" @@ -2032,11 +2036,11 @@ msgstr "" ">>> vars(h)\n" "{'_slotvalues': [55, 20]}" -#: ../../howto/descriptor.rst:1766 +#: ../../howto/descriptor.rst:1768 msgid "Misspelled or unassigned attributes will raise an exception:" msgstr "" -#: ../../howto/descriptor.rst:1768 +#: ../../howto/descriptor.rst:1770 msgid "" ">>> h.xz\n" "Traceback (most recent call last):\n" diff --git a/howto/enum.po b/howto/enum.po index 8e243e281d..f8f139e36a 100644 --- a/howto/enum.po +++ b/howto/enum.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-03-03 18:39+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -121,7 +121,7 @@ msgid "" msgstr "" #: ../../howto/enum.rst:67 -msgid "Enum members have an attribute that contains just their :attr:`name`::" +msgid "Enum members have an attribute that contains just their :attr:`!name`::" msgstr "" #: ../../howto/enum.rst:69 @@ -133,7 +133,7 @@ msgstr "" "TUESDAY" #: ../../howto/enum.rst:72 -msgid "Likewise, they have an attribute for their :attr:`value`::" +msgid "Likewise, they have an attribute for their :attr:`!value`::" msgstr "" #: ../../howto/enum.rst:75 @@ -148,25 +148,26 @@ msgstr "" msgid "" "Unlike many languages that treat enumerations solely as name/value pairs, " "Python Enums can have behavior added. For example, :class:`datetime.date` " -"has two methods for returning the weekday: :meth:`weekday` and :meth:" -"`isoweekday`. The difference is that one of them counts from 0-6 and the " -"other from 1-7. Rather than keep track of that ourselves we can add a method " -"to the :class:`Weekday` enum to extract the day from the :class:`date` " -"instance and return the matching enum member::" +"has two methods for returning the weekday: :meth:`~datetime.date.weekday` " +"and :meth:`~datetime.date.isoweekday`. The difference is that one of them " +"counts from 0-6 and the other from 1-7. Rather than keep track of that " +"ourselves we can add a method to the :class:`!Weekday` enum to extract the " +"day from the :class:`~datetime.date` instance and return the matching enum " +"member::" msgstr "" -#: ../../howto/enum.rst:86 +#: ../../howto/enum.rst:87 msgid "" "@classmethod\n" "def from_date(cls, date):\n" " return cls(date.isoweekday())" msgstr "" -#: ../../howto/enum.rst:90 -msgid "The complete :class:`Weekday` enum now looks like this::" +#: ../../howto/enum.rst:91 +msgid "The complete :class:`!Weekday` enum now looks like this::" msgstr "" -#: ../../howto/enum.rst:92 +#: ../../howto/enum.rst:93 msgid "" ">>> class Weekday(Enum):\n" "... MONDAY = 1\n" @@ -194,32 +195,32 @@ msgstr "" "... def from_date(cls, date):\n" "... return cls(date.isoweekday())" -#: ../../howto/enum.rst:105 +#: ../../howto/enum.rst:106 msgid "Now we can find out what today is! Observe::" msgstr "" -#: ../../howto/enum.rst:107 +#: ../../howto/enum.rst:108 msgid "" ">>> from datetime import date\n" -">>> Weekday.from_date(date.today()) \n" +">>> Weekday.from_date(date.today())\n" "" msgstr "" -#: ../../howto/enum.rst:111 +#: ../../howto/enum.rst:112 msgid "" "Of course, if you're reading this on some other day, you'll see that day " "instead." msgstr "" -#: ../../howto/enum.rst:113 +#: ../../howto/enum.rst:114 msgid "" -"This :class:`Weekday` enum is great if our variable only needs one day, but " +"This :class:`!Weekday` enum is great if our variable only needs one day, but " "what if we need several? Maybe we're writing a function to plot chores " "during a week, and don't want to use a :class:`list` -- we could use a " "different type of :class:`Enum`::" msgstr "" -#: ../../howto/enum.rst:118 +#: ../../howto/enum.rst:119 msgid "" ">>> from enum import Flag\n" ">>> class Weekday(Flag):\n" @@ -241,19 +242,19 @@ msgstr "" "... SATURDAY = 32\n" "... SUNDAY = 64" -#: ../../howto/enum.rst:128 +#: ../../howto/enum.rst:129 msgid "" "We've changed two things: we're inherited from :class:`Flag`, and the values " "are all powers of 2." msgstr "" -#: ../../howto/enum.rst:131 +#: ../../howto/enum.rst:132 msgid "" -"Just like the original :class:`Weekday` enum above, we can have a single " +"Just like the original :class:`!Weekday` enum above, we can have a single " "selection::" msgstr "" -#: ../../howto/enum.rst:133 +#: ../../howto/enum.rst:134 msgid "" ">>> first_week_day = Weekday.MONDAY\n" ">>> first_week_day\n" @@ -263,13 +264,13 @@ msgstr "" ">>> first_week_day\n" "" -#: ../../howto/enum.rst:137 +#: ../../howto/enum.rst:138 msgid "" "But :class:`Flag` also allows us to combine several members into a single " "variable::" msgstr "" -#: ../../howto/enum.rst:140 +#: ../../howto/enum.rst:141 msgid "" ">>> weekend = Weekday.SATURDAY | Weekday.SUNDAY\n" ">>> weekend\n" @@ -279,11 +280,11 @@ msgstr "" ">>> weekend\n" "" -#: ../../howto/enum.rst:144 +#: ../../howto/enum.rst:145 msgid "You can even iterate over a :class:`Flag` variable::" msgstr "" -#: ../../howto/enum.rst:146 +#: ../../howto/enum.rst:147 msgid "" ">>> for day in weekend:\n" "... print(day)\n" @@ -295,11 +296,11 @@ msgstr "" "Weekday.SATURDAY\n" "Weekday.SUNDAY" -#: ../../howto/enum.rst:151 +#: ../../howto/enum.rst:152 msgid "Okay, let's get some chores set up::" msgstr "" -#: ../../howto/enum.rst:153 +#: ../../howto/enum.rst:154 msgid "" ">>> chores_for_ethan = {\n" "... 'feed the cat': Weekday.MONDAY | Weekday.WEDNESDAY | Weekday." @@ -315,11 +316,11 @@ msgstr "" "... 'answer SO questions': Weekday.SATURDAY,\n" "... }" -#: ../../howto/enum.rst:159 +#: ../../howto/enum.rst:160 msgid "And a function to display the chores for a given day::" msgstr "" -#: ../../howto/enum.rst:161 +#: ../../howto/enum.rst:162 msgid "" ">>> def show_chores(chores, day):\n" "... for chore, days in chores.items():\n" @@ -337,13 +338,13 @@ msgstr "" ">>> show_chores(chores_for_ethan, Weekday.SATURDAY)\n" "answer SO questions" -#: ../../howto/enum.rst:169 +#: ../../howto/enum.rst:170 msgid "" "In cases where the actual values of the members do not matter, you can save " "yourself some work and use :func:`auto` for the values::" msgstr "" -#: ../../howto/enum.rst:172 +#: ../../howto/enum.rst:173 msgid "" ">>> from enum import auto\n" ">>> class Weekday(Flag):\n" @@ -367,18 +368,18 @@ msgstr "" "... SUNDAY = auto()\n" "... WEEKEND = SATURDAY | SUNDAY" -#: ../../howto/enum.rst:188 +#: ../../howto/enum.rst:189 msgid "Programmatic access to enumeration members and their attributes" msgstr "" -#: ../../howto/enum.rst:190 +#: ../../howto/enum.rst:191 msgid "" "Sometimes it's useful to access members in enumerations programmatically (i." "e. situations where ``Color.RED`` won't do because the exact color is not " "known at program-writing time). ``Enum`` allows such access::" msgstr "" -#: ../../howto/enum.rst:194 +#: ../../howto/enum.rst:195 msgid "" ">>> Color(1)\n" "\n" @@ -390,11 +391,11 @@ msgstr "" ">>> Color(3)\n" "" -#: ../../howto/enum.rst:199 +#: ../../howto/enum.rst:200 msgid "If you want to access enum members by *name*, use item access::" msgstr "" -#: ../../howto/enum.rst:201 +#: ../../howto/enum.rst:202 msgid "" ">>> Color['RED']\n" "\n" @@ -406,11 +407,12 @@ msgstr "" ">>> Color['GREEN']\n" "" -#: ../../howto/enum.rst:206 -msgid "If you have an enum member and need its :attr:`name` or :attr:`value`::" +#: ../../howto/enum.rst:207 +msgid "" +"If you have an enum member and need its :attr:`!name` or :attr:`!value`::" msgstr "" -#: ../../howto/enum.rst:208 +#: ../../howto/enum.rst:209 msgid "" ">>> member = Color.RED\n" ">>> member.name\n" @@ -424,15 +426,15 @@ msgstr "" ">>> member.value\n" "1" -#: ../../howto/enum.rst:216 +#: ../../howto/enum.rst:217 msgid "Duplicating enum members and values" msgstr "" -#: ../../howto/enum.rst:218 +#: ../../howto/enum.rst:219 msgid "Having two enum members with the same name is invalid::" msgstr "" -#: ../../howto/enum.rst:220 +#: ../../howto/enum.rst:221 msgid "" ">>> class Shape(Enum):\n" "... SQUARE = 2\n" @@ -450,7 +452,7 @@ msgstr "" "...\n" "TypeError: 'SQUARE' already defined as 2" -#: ../../howto/enum.rst:228 +#: ../../howto/enum.rst:229 msgid "" "However, an enum member can have other names associated with it. Given two " "entries ``A`` and ``B`` with the same value (and ``A`` defined first), ``B`` " @@ -459,7 +461,7 @@ msgid "" "member ``A``. By-name lookup of ``B`` will also return the member ``A``::" msgstr "" -#: ../../howto/enum.rst:234 +#: ../../howto/enum.rst:235 msgid "" ">>> class Shape(Enum):\n" "... SQUARE = 2\n" @@ -487,24 +489,24 @@ msgstr "" ">>> Shape(2)\n" "" -#: ../../howto/enum.rst:249 +#: ../../howto/enum.rst:250 msgid "" "Attempting to create a member with the same name as an already defined " "attribute (another member, a method, etc.) or attempting to create an " "attribute with the same name as a member is not allowed." msgstr "" -#: ../../howto/enum.rst:255 +#: ../../howto/enum.rst:256 msgid "Ensuring unique enumeration values" msgstr "" -#: ../../howto/enum.rst:257 +#: ../../howto/enum.rst:258 msgid "" "By default, enumerations allow multiple names as aliases for the same value. " "When this behavior isn't desired, you can use the :func:`unique` decorator::" msgstr "" -#: ../../howto/enum.rst:260 +#: ../../howto/enum.rst:261 msgid "" ">>> from enum import Enum, unique\n" ">>> @unique\n" @@ -530,15 +532,15 @@ msgstr "" "...\n" "ValueError: duplicate values found in : FOUR -> THREE" -#: ../../howto/enum.rst:274 +#: ../../howto/enum.rst:275 msgid "Using automatic values" msgstr "" -#: ../../howto/enum.rst:276 +#: ../../howto/enum.rst:277 msgid "If the exact value is unimportant you can use :class:`auto`::" msgstr "" -#: ../../howto/enum.rst:278 +#: ../../howto/enum.rst:279 msgid "" ">>> from enum import Enum, auto\n" ">>> class Color(Enum):\n" @@ -558,13 +560,13 @@ msgstr "" ">>> [member.value for member in Color]\n" "[1, 2, 3]" -#: ../../howto/enum.rst:287 +#: ../../howto/enum.rst:288 msgid "" -"The values are chosen by :func:`_generate_next_value_`, which can be " +"The values are chosen by :func:`~Enum._generate_next_value_`, which can be " "overridden::" msgstr "" -#: ../../howto/enum.rst:290 +#: ../../howto/enum.rst:291 msgid "" ">>> class AutoName(Enum):\n" "... @staticmethod\n" @@ -594,20 +596,21 @@ msgstr "" ">>> [member.value for member in Ordinal]\n" "['NORTH', 'SOUTH', 'EAST', 'WEST']" -#: ../../howto/enum.rst:306 +#: ../../howto/enum.rst:307 msgid "" -"The :meth:`_generate_next_value_` method must be defined before any members." +"The :meth:`~Enum._generate_next_value_` method must be defined before any " +"members." msgstr "" -#: ../../howto/enum.rst:309 +#: ../../howto/enum.rst:310 msgid "Iteration" msgstr "" -#: ../../howto/enum.rst:311 +#: ../../howto/enum.rst:312 msgid "Iterating over the members of an enum does not provide the aliases::" msgstr "" -#: ../../howto/enum.rst:313 +#: ../../howto/enum.rst:314 msgid "" ">>> list(Shape)\n" "[, , ]\n" @@ -623,20 +626,20 @@ msgstr "" "THURSDAY: 8>, , , ]" -#: ../../howto/enum.rst:318 +#: ../../howto/enum.rst:319 msgid "" "Note that the aliases ``Shape.ALIAS_FOR_SQUARE`` and ``Weekday.WEEKEND`` " "aren't shown." msgstr "" -#: ../../howto/enum.rst:320 +#: ../../howto/enum.rst:321 msgid "" "The special attribute ``__members__`` is a read-only ordered mapping of " "names to members. It includes all names defined in the enumeration, " "including the aliases::" msgstr "" -#: ../../howto/enum.rst:324 +#: ../../howto/enum.rst:325 msgid "" ">>> for name, member in Shape.__members__.items():\n" "... name, member\n" @@ -654,13 +657,13 @@ msgstr "" "('CIRCLE', )\n" "('ALIAS_FOR_SQUARE', )" -#: ../../howto/enum.rst:332 +#: ../../howto/enum.rst:333 msgid "" "The ``__members__`` attribute can be used for detailed programmatic access " "to the enumeration members. For example, finding all the aliases::" msgstr "" -#: ../../howto/enum.rst:335 +#: ../../howto/enum.rst:336 msgid "" ">>> [name for name, member in Shape.__members__.items() if member.name != " "name]\n" @@ -670,21 +673,21 @@ msgstr "" "name]\n" "['ALIAS_FOR_SQUARE']" -#: ../../howto/enum.rst:340 +#: ../../howto/enum.rst:341 msgid "" "Aliases for flags include values with multiple flags set, such as ``3``, and " "no flags set, i.e. ``0``." msgstr "" -#: ../../howto/enum.rst:345 +#: ../../howto/enum.rst:346 msgid "Comparisons" msgstr "比較" -#: ../../howto/enum.rst:347 +#: ../../howto/enum.rst:348 msgid "Enumeration members are compared by identity::" msgstr "" -#: ../../howto/enum.rst:349 +#: ../../howto/enum.rst:350 msgid "" ">>> Color.RED is Color.RED\n" "True\n" @@ -700,13 +703,13 @@ msgstr "" ">>> Color.RED is not Color.BLUE\n" "True" -#: ../../howto/enum.rst:356 +#: ../../howto/enum.rst:357 msgid "" "Ordered comparisons between enumeration values are *not* supported. Enum " "members are not integers (but see `IntEnum`_ below)::" msgstr "" -#: ../../howto/enum.rst:359 +#: ../../howto/enum.rst:360 msgid "" ">>> Color.RED < Color.BLUE\n" "Traceback (most recent call last):\n" @@ -718,11 +721,11 @@ msgstr "" " File \"\", line 1, in \n" "TypeError: '<' not supported between instances of 'Color' and 'Color'" -#: ../../howto/enum.rst:364 +#: ../../howto/enum.rst:365 msgid "Equality comparisons are defined though::" msgstr "" -#: ../../howto/enum.rst:366 +#: ../../howto/enum.rst:367 msgid "" ">>> Color.BLUE == Color.RED\n" "False\n" @@ -738,14 +741,14 @@ msgstr "" ">>> Color.BLUE == Color.BLUE\n" "True" -#: ../../howto/enum.rst:373 +#: ../../howto/enum.rst:374 msgid "" "Comparisons against non-enumeration values will always compare not equal " "(again, :class:`IntEnum` was explicitly designed to behave differently, see " "below)::" msgstr "" -#: ../../howto/enum.rst:377 +#: ../../howto/enum.rst:378 msgid "" ">>> Color.BLUE == 2\n" "False" @@ -753,18 +756,18 @@ msgstr "" ">>> Color.BLUE == 2\n" "False" -#: ../../howto/enum.rst:382 +#: ../../howto/enum.rst:383 msgid "" "It is possible to reload modules -- if a reloaded module contains enums, " "they will be recreated, and the new members may not compare identical/equal " "to the original members." msgstr "" -#: ../../howto/enum.rst:387 +#: ../../howto/enum.rst:388 msgid "Allowed members and attributes of enumerations" msgstr "" -#: ../../howto/enum.rst:389 +#: ../../howto/enum.rst:390 msgid "" "Most of the examples above use integers for enumeration values. Using " "integers is short and handy (and provided by default by the `Functional " @@ -773,13 +776,13 @@ msgid "" "*is* important, enumerations can have arbitrary values." msgstr "" -#: ../../howto/enum.rst:395 +#: ../../howto/enum.rst:396 msgid "" "Enumerations are Python classes, and can have methods and special methods as " "usual. If we have this enumeration::" msgstr "" -#: ../../howto/enum.rst:398 +#: ../../howto/enum.rst:399 msgid "" ">>> class Mood(Enum):\n" "... FUNKY = 1\n" @@ -799,11 +802,11 @@ msgid "" "..." msgstr "" -#: ../../howto/enum.rst:415 +#: ../../howto/enum.rst:416 msgid "Then::" msgstr "" -#: ../../howto/enum.rst:417 +#: ../../howto/enum.rst:418 msgid "" ">>> Mood.favorite_mood()\n" "\n" @@ -819,43 +822,43 @@ msgstr "" ">>> str(Mood.FUNKY)\n" "'my custom str! 1'" -#: ../../howto/enum.rst:424 +#: ../../howto/enum.rst:425 msgid "" "The rules for what is allowed are as follows: names that start and end with " "a single underscore are reserved by enum and cannot be used; all other " "attributes defined within an enumeration will become members of this " -"enumeration, with the exception of special methods (:meth:`__str__`, :meth:" -"`__add__`, etc.), descriptors (methods are also descriptors), and variable " -"names listed in :attr:`_ignore_`." +"enumeration, with the exception of special methods (:meth:`~object." +"__str__`, :meth:`~object.__add__`, etc.), descriptors (methods are also " +"descriptors), and variable names listed in :attr:`~Enum._ignore_`." msgstr "" -#: ../../howto/enum.rst:431 +#: ../../howto/enum.rst:432 msgid "" -"Note: if your enumeration defines :meth:`__new__` and/or :meth:`__init__`, " -"any value(s) given to the enum member will be passed into those methods. See " -"`Planet`_ for an example." +"Note: if your enumeration defines :meth:`~object.__new__` and/or :meth:" +"`~object.__init__`, any value(s) given to the enum member will be passed " +"into those methods. See `Planet`_ for an example." msgstr "" -#: ../../howto/enum.rst:437 +#: ../../howto/enum.rst:438 msgid "" -"The :meth:`__new__` method, if defined, is used during creation of the Enum " -"members; it is then replaced by Enum's :meth:`__new__` which is used after " -"class creation for lookup of existing members. See :ref:`new-vs-init` for " -"more details." +"The :meth:`~object.__new__` method, if defined, is used during creation of " +"the Enum members; it is then replaced by Enum's :meth:`~object.__new__` " +"which is used after class creation for lookup of existing members. See :ref:" +"`new-vs-init` for more details." msgstr "" -#: ../../howto/enum.rst:444 +#: ../../howto/enum.rst:445 msgid "Restricted Enum subclassing" msgstr "" -#: ../../howto/enum.rst:446 +#: ../../howto/enum.rst:447 msgid "" "A new :class:`Enum` class must have one base enum class, up to one concrete " "data type, and as many :class:`object`-based mixin classes as needed. The " "order of these base classes is::" msgstr "" -#: ../../howto/enum.rst:450 +#: ../../howto/enum.rst:451 msgid "" "class EnumName([mix-in, ...,] [data-type,] base-enum):\n" " pass" @@ -863,13 +866,13 @@ msgstr "" "class EnumName([mix-in, ...,] [data-type,] base-enum):\n" " pass" -#: ../../howto/enum.rst:453 +#: ../../howto/enum.rst:454 msgid "" "Also, subclassing an enumeration is allowed only if the enumeration does not " "define any members. So this is forbidden::" msgstr "" -#: ../../howto/enum.rst:456 +#: ../../howto/enum.rst:457 msgid "" ">>> class MoreColor(Color):\n" "... PINK = 17\n" @@ -885,11 +888,11 @@ msgstr "" "...\n" "TypeError: cannot extend " -#: ../../howto/enum.rst:463 +#: ../../howto/enum.rst:464 msgid "But this is allowed::" msgstr "但這是允許的:" -#: ../../howto/enum.rst:465 +#: ../../howto/enum.rst:466 msgid "" ">>> class Foo(Enum):\n" "... def some_behavior(self):\n" @@ -909,7 +912,7 @@ msgstr "" "... SAD = 2\n" "..." -#: ../../howto/enum.rst:474 +#: ../../howto/enum.rst:475 msgid "" "Allowing subclassing of enums that define members would lead to a violation " "of some important invariants of types and instances. On the other hand, it " @@ -917,17 +920,17 @@ msgid "" "enumerations. (See `OrderedEnum`_ for an example.)" msgstr "" -#: ../../howto/enum.rst:483 +#: ../../howto/enum.rst:484 msgid "Dataclass support" msgstr "" -#: ../../howto/enum.rst:485 +#: ../../howto/enum.rst:486 msgid "" "When inheriting from a :class:`~dataclasses.dataclass`, the :meth:`~Enum." "__repr__` omits the inherited class' name. For example::" msgstr "" -#: ../../howto/enum.rst:488 +#: ../../howto/enum.rst:489 msgid "" ">>> from dataclasses import dataclass, field\n" ">>> @dataclass\n" @@ -957,19 +960,19 @@ msgstr "" ">>> Creature.DOG\n" "" -#: ../../howto/enum.rst:502 +#: ../../howto/enum.rst:503 msgid "" "Use the :func:`~dataclasses.dataclass` argument ``repr=False`` to use the " "standard :func:`repr`." msgstr "" -#: ../../howto/enum.rst:505 +#: ../../howto/enum.rst:506 msgid "" "Only the dataclass fields are shown in the value area, not the dataclass' " "name." msgstr "" -#: ../../howto/enum.rst:511 +#: ../../howto/enum.rst:512 msgid "" "Adding :func:`~dataclasses.dataclass` decorator to :class:`Enum` and its " "subclasses is not supported. It will not raise any errors, but it will " @@ -977,7 +980,7 @@ msgid "" "other::" msgstr "" -#: ../../howto/enum.rst:516 +#: ../../howto/enum.rst:517 msgid "" ">>> @dataclass # don't do this: it does not make any sense\n" "... class Color(Enum):\n" @@ -990,15 +993,15 @@ msgid "" "True" msgstr "" -#: ../../howto/enum.rst:528 +#: ../../howto/enum.rst:529 msgid "Pickling" msgstr "" -#: ../../howto/enum.rst:530 +#: ../../howto/enum.rst:531 msgid "Enumerations can be pickled and unpickled::" msgstr "" -#: ../../howto/enum.rst:532 +#: ../../howto/enum.rst:533 msgid "" ">>> from test.test_enum import Fruit\n" ">>> from pickle import dumps, loads\n" @@ -1010,27 +1013,27 @@ msgstr "" ">>> Fruit.TOMATO is loads(dumps(Fruit.TOMATO))\n" "True" -#: ../../howto/enum.rst:537 +#: ../../howto/enum.rst:538 msgid "" "The usual restrictions for pickling apply: picklable enums must be defined " "in the top level of a module, since unpickling requires them to be " "importable from that module." msgstr "" -#: ../../howto/enum.rst:543 +#: ../../howto/enum.rst:544 msgid "" "With pickle protocol version 4 it is possible to easily pickle enums nested " "in other classes." msgstr "" -#: ../../howto/enum.rst:546 +#: ../../howto/enum.rst:547 msgid "" "It is possible to modify how enum members are pickled/unpickled by defining :" -"meth:`__reduce_ex__` in the enumeration class. The default method is by-" -"value, but enums with complicated values may want to use by-name::" +"meth:`~object.__reduce_ex__` in the enumeration class. The default method " +"is by-value, but enums with complicated values may want to use by-name::" msgstr "" -#: ../../howto/enum.rst:550 +#: ../../howto/enum.rst:551 msgid "" ">>> import enum\n" ">>> class MyEnum(enum.Enum):\n" @@ -1040,22 +1043,22 @@ msgstr "" ">>> class MyEnum(enum.Enum):\n" "... __reduce_ex__ = enum.pickle_by_enum_name" -#: ../../howto/enum.rst:556 +#: ../../howto/enum.rst:557 msgid "" "Using by-name for flags is not recommended, as unnamed aliases will not " "unpickle." msgstr "" -#: ../../howto/enum.rst:561 +#: ../../howto/enum.rst:562 msgid "Functional API" msgstr "" -#: ../../howto/enum.rst:563 +#: ../../howto/enum.rst:564 msgid "" "The :class:`Enum` class is callable, providing the following functional API::" msgstr "" -#: ../../howto/enum.rst:565 +#: ../../howto/enum.rst:566 msgid "" ">>> Animal = Enum('Animal', 'ANT BEE CAT DOG')\n" ">>> Animal\n" @@ -1073,13 +1076,13 @@ msgstr "" ">>> list(Animal)\n" "[, , , ]" -#: ../../howto/enum.rst:573 +#: ../../howto/enum.rst:574 msgid "" "The semantics of this API resemble :class:`~collections.namedtuple`. The " "first argument of the call to :class:`Enum` is the name of the enumeration." msgstr "" -#: ../../howto/enum.rst:576 +#: ../../howto/enum.rst:577 msgid "" "The second argument is the *source* of enumeration member names. It can be " "a whitespace-separated string of names, a sequence of names, a sequence of 2-" @@ -1088,10 +1091,10 @@ msgid "" "enumerations; the others auto-assign increasing integers starting with 1 " "(use the ``start`` parameter to specify a different starting value). A new " "class derived from :class:`Enum` is returned. In other words, the above " -"assignment to :class:`Animal` is equivalent to::" +"assignment to :class:`!Animal` is equivalent to::" msgstr "" -#: ../../howto/enum.rst:585 +#: ../../howto/enum.rst:586 msgid "" ">>> class Animal(Enum):\n" "... ANT = 1\n" @@ -1107,14 +1110,14 @@ msgstr "" "... DOG = 4\n" "..." -#: ../../howto/enum.rst:592 +#: ../../howto/enum.rst:593 msgid "" "The reason for defaulting to ``1`` as the starting number and not ``0`` is " "that ``0`` is ``False`` in a boolean sense, but by default enum members all " "evaluate to ``True``." msgstr "" -#: ../../howto/enum.rst:596 +#: ../../howto/enum.rst:597 msgid "" "Pickling enums created with the functional API can be tricky as frame stack " "implementation details are used to try and figure out which module the " @@ -1123,36 +1126,36 @@ msgid "" "Jython). The solution is to specify the module name explicitly as follows::" msgstr "" -#: ../../howto/enum.rst:602 +#: ../../howto/enum.rst:603 msgid ">>> Animal = Enum('Animal', 'ANT BEE CAT DOG', module=__name__)" msgstr ">>> Animal = Enum('Animal', 'ANT BEE CAT DOG', module=__name__)" -#: ../../howto/enum.rst:606 +#: ../../howto/enum.rst:607 msgid "" "If ``module`` is not supplied, and Enum cannot determine what it is, the new " "Enum members will not be unpicklable; to keep errors closer to the source, " "pickling will be disabled." msgstr "" -#: ../../howto/enum.rst:610 +#: ../../howto/enum.rst:611 msgid "" "The new pickle protocol 4 also, in some circumstances, relies on :attr:" -"`~definition.__qualname__` being set to the location where pickle will be " -"able to find the class. For example, if the class was made available in " -"class SomeData in the global scope::" +"`~type.__qualname__` being set to the location where pickle will be able to " +"find the class. For example, if the class was made available in class " +"SomeData in the global scope::" msgstr "" -#: ../../howto/enum.rst:615 +#: ../../howto/enum.rst:616 msgid "" ">>> Animal = Enum('Animal', 'ANT BEE CAT DOG', qualname='SomeData.Animal')" msgstr "" ">>> Animal = Enum('Animal', 'ANT BEE CAT DOG', qualname='SomeData.Animal')" -#: ../../howto/enum.rst:617 +#: ../../howto/enum.rst:618 msgid "The complete signature is::" msgstr "" -#: ../../howto/enum.rst:619 +#: ../../howto/enum.rst:620 msgid "" "Enum(\n" " value='NewEnumName',\n" @@ -1174,73 +1177,73 @@ msgstr "" " start=1,\n" " )" -#: ../../howto/enum.rst:629 +#: ../../howto/enum.rst:630 msgid "*value*: What the new enum class will record as its name." msgstr "" -#: ../../howto/enum.rst:631 +#: ../../howto/enum.rst:632 msgid "" "*names*: The enum members. This can be a whitespace- or comma-separated " "string (values will start at 1 unless otherwise specified)::" msgstr "" -#: ../../howto/enum.rst:634 +#: ../../howto/enum.rst:635 msgid "'RED GREEN BLUE' | 'RED,GREEN,BLUE' | 'RED, GREEN, BLUE'" msgstr "'RED GREEN BLUE' | 'RED,GREEN,BLUE' | 'RED, GREEN, BLUE'" -#: ../../howto/enum.rst:636 +#: ../../howto/enum.rst:637 msgid "or an iterator of names::" msgstr "" -#: ../../howto/enum.rst:638 +#: ../../howto/enum.rst:639 msgid "['RED', 'GREEN', 'BLUE']" msgstr "['RED', 'GREEN', 'BLUE']" -#: ../../howto/enum.rst:640 +#: ../../howto/enum.rst:641 msgid "or an iterator of (name, value) pairs::" msgstr "" -#: ../../howto/enum.rst:642 +#: ../../howto/enum.rst:643 msgid "[('CYAN', 4), ('MAGENTA', 5), ('YELLOW', 6)]" msgstr "[('CYAN', 4), ('MAGENTA', 5), ('YELLOW', 6)]" -#: ../../howto/enum.rst:644 +#: ../../howto/enum.rst:645 msgid "or a mapping::" msgstr "" -#: ../../howto/enum.rst:646 +#: ../../howto/enum.rst:647 msgid "{'CHARTREUSE': 7, 'SEA_GREEN': 11, 'ROSEMARY': 42}" msgstr "{'CHARTREUSE': 7, 'SEA_GREEN': 11, 'ROSEMARY': 42}" -#: ../../howto/enum.rst:648 +#: ../../howto/enum.rst:649 msgid "*module*: name of module where new enum class can be found." msgstr "" -#: ../../howto/enum.rst:650 +#: ../../howto/enum.rst:651 msgid "*qualname*: where in module new enum class can be found." msgstr "" -#: ../../howto/enum.rst:652 +#: ../../howto/enum.rst:653 msgid "*type*: type to mix in to new enum class." msgstr "" -#: ../../howto/enum.rst:654 +#: ../../howto/enum.rst:655 msgid "*start*: number to start counting at if only names are passed in." msgstr "" -#: ../../howto/enum.rst:656 +#: ../../howto/enum.rst:657 msgid "The *start* parameter was added." msgstr "" -#: ../../howto/enum.rst:661 +#: ../../howto/enum.rst:662 msgid "Derived Enumerations" msgstr "" -#: ../../howto/enum.rst:664 +#: ../../howto/enum.rst:665 msgid "IntEnum" msgstr "" -#: ../../howto/enum.rst:666 +#: ../../howto/enum.rst:667 msgid "" "The first variation of :class:`Enum` that is provided is also a subclass of :" "class:`int`. Members of an :class:`IntEnum` can be compared to integers; by " @@ -1248,7 +1251,7 @@ msgid "" "each other::" msgstr "" -#: ../../howto/enum.rst:671 +#: ../../howto/enum.rst:672 msgid "" ">>> from enum import IntEnum\n" ">>> class Shape(IntEnum):\n" @@ -1282,13 +1285,13 @@ msgstr "" ">>> Shape.CIRCLE == Request.POST\n" "True" -#: ../../howto/enum.rst:687 +#: ../../howto/enum.rst:688 msgid "" "However, they still can't be compared to standard :class:`Enum` " "enumerations::" msgstr "" -#: ../../howto/enum.rst:689 +#: ../../howto/enum.rst:690 msgid "" ">>> class Shape(IntEnum):\n" "... CIRCLE = 1\n" @@ -1312,12 +1315,12 @@ msgstr "" ">>> Shape.CIRCLE == Color.RED\n" "False" -#: ../../howto/enum.rst:700 +#: ../../howto/enum.rst:701 msgid "" ":class:`IntEnum` values behave like integers in other ways you'd expect::" msgstr "" -#: ../../howto/enum.rst:702 +#: ../../howto/enum.rst:703 msgid "" ">>> int(Shape.CIRCLE)\n" "1\n" @@ -1333,11 +1336,11 @@ msgstr "" ">>> [i for i in range(Shape.SQUARE)]\n" "[0, 1]" -#: ../../howto/enum.rst:711 +#: ../../howto/enum.rst:712 msgid "StrEnum" msgstr "StrEnum" -#: ../../howto/enum.rst:713 +#: ../../howto/enum.rst:714 msgid "" "The second variation of :class:`Enum` that is provided is also a subclass " "of :class:`str`. Members of a :class:`StrEnum` can be compared to strings; " @@ -1345,11 +1348,11 @@ msgid "" "each other." msgstr "" -#: ../../howto/enum.rst:722 +#: ../../howto/enum.rst:723 msgid "IntFlag" msgstr "IntFlag" -#: ../../howto/enum.rst:724 +#: ../../howto/enum.rst:725 msgid "" "The next variation of :class:`Enum` provided, :class:`IntFlag`, is also " "based on :class:`int`. The difference being :class:`IntFlag` members can be " @@ -1359,23 +1362,23 @@ msgid "" "is used." msgstr "" -#: ../../howto/enum.rst:732 +#: ../../howto/enum.rst:733 msgid "" "Any operation on an :class:`IntFlag` member besides the bit-wise operations " "will lose the :class:`IntFlag` membership." msgstr "" -#: ../../howto/enum.rst:735 +#: ../../howto/enum.rst:736 msgid "" "Bit-wise operations that result in invalid :class:`IntFlag` values will lose " "the :class:`IntFlag` membership. See :class:`FlagBoundary` for details." msgstr "" -#: ../../howto/enum.rst:742 +#: ../../howto/enum.rst:743 msgid "Sample :class:`IntFlag` class::" msgstr "" -#: ../../howto/enum.rst:744 +#: ../../howto/enum.rst:745 msgid "" ">>> from enum import IntFlag\n" ">>> class Perm(IntFlag):\n" @@ -1405,11 +1408,11 @@ msgstr "" ">>> Perm.R in RW\n" "True" -#: ../../howto/enum.rst:758 +#: ../../howto/enum.rst:759 msgid "It is also possible to name the combinations::" msgstr "" -#: ../../howto/enum.rst:760 +#: ../../howto/enum.rst:761 msgid "" ">>> class Perm(IntFlag):\n" "... R = 4\n" @@ -1437,20 +1440,20 @@ msgstr "" ">>> Perm(7)\n" "" -#: ../../howto/enum.rst:775 +#: ../../howto/enum.rst:776 msgid "" "Named combinations are considered aliases. Aliases do not show up during " "iteration, but can be returned from by-value lookups." msgstr "" -#: ../../howto/enum.rst:780 +#: ../../howto/enum.rst:781 msgid "" "Another important difference between :class:`IntFlag` and :class:`Enum` is " "that if no flags are set (the value is 0), its boolean evaluation is :data:" "`False`::" msgstr "" -#: ../../howto/enum.rst:783 +#: ../../howto/enum.rst:784 msgid "" ">>> Perm.R & Perm.X\n" "\n" @@ -1462,13 +1465,13 @@ msgstr "" ">>> bool(Perm.R & Perm.X)\n" "False" -#: ../../howto/enum.rst:788 +#: ../../howto/enum.rst:789 msgid "" "Because :class:`IntFlag` members are also subclasses of :class:`int` they " "can be combined with them (but may lose :class:`IntFlag` membership::" msgstr "" -#: ../../howto/enum.rst:791 +#: ../../howto/enum.rst:792 msgid "" ">>> Perm.X | 4\n" "\n" @@ -1482,13 +1485,13 @@ msgstr "" ">>> Perm.X + 8\n" "9" -#: ../../howto/enum.rst:799 +#: ../../howto/enum.rst:800 msgid "" "The negation operator, ``~``, always returns an :class:`IntFlag` member with " "a positive value::" msgstr "" -#: ../../howto/enum.rst:802 +#: ../../howto/enum.rst:803 msgid "" ">>> (~Perm.X).value == (Perm.R|Perm.W).value == 6\n" "True" @@ -1496,11 +1499,11 @@ msgstr "" ">>> (~Perm.X).value == (Perm.R|Perm.W).value == 6\n" "True" -#: ../../howto/enum.rst:805 +#: ../../howto/enum.rst:806 msgid ":class:`IntFlag` members can also be iterated over::" msgstr "" -#: ../../howto/enum.rst:807 +#: ../../howto/enum.rst:808 msgid "" ">>> list(RW)\n" "[, ]" @@ -1508,11 +1511,11 @@ msgstr "" ">>> list(RW)\n" "[, ]" -#: ../../howto/enum.rst:814 +#: ../../howto/enum.rst:815 msgid "Flag" msgstr "Flag" -#: ../../howto/enum.rst:816 +#: ../../howto/enum.rst:817 msgid "" "The last variation is :class:`Flag`. Like :class:`IntFlag`, :class:`Flag` " "members can be combined using the bitwise operators (&, \\|, ^, ~). Unlike :" @@ -1522,13 +1525,13 @@ msgid "" "value and let :class:`Flag` select an appropriate value." msgstr "" -#: ../../howto/enum.rst:825 +#: ../../howto/enum.rst:826 msgid "" "Like :class:`IntFlag`, if a combination of :class:`Flag` members results in " "no flags being set, the boolean evaluation is :data:`False`::" msgstr "" -#: ../../howto/enum.rst:828 +#: ../../howto/enum.rst:829 msgid "" ">>> from enum import Flag, auto\n" ">>> class Color(Flag):\n" @@ -1552,13 +1555,13 @@ msgstr "" ">>> bool(Color.RED & Color.GREEN)\n" "False" -#: ../../howto/enum.rst:839 +#: ../../howto/enum.rst:840 msgid "" "Individual flags should have values that are powers of two (1, 2, 4, " "8, ...), while combinations of flags will not::" msgstr "" -#: ../../howto/enum.rst:842 +#: ../../howto/enum.rst:843 msgid "" ">>> class Color(Flag):\n" "... RED = auto()\n" @@ -1578,13 +1581,13 @@ msgstr "" ">>> Color.WHITE\n" "" -#: ../../howto/enum.rst:851 +#: ../../howto/enum.rst:852 msgid "" "Giving a name to the \"no flags set\" condition does not change its boolean " "value::" msgstr "" -#: ../../howto/enum.rst:854 +#: ../../howto/enum.rst:855 msgid "" ">>> class Color(Flag):\n" "... BLACK = 0\n" @@ -1608,11 +1611,11 @@ msgstr "" ">>> bool(Color.BLACK)\n" "False" -#: ../../howto/enum.rst:865 +#: ../../howto/enum.rst:866 msgid ":class:`Flag` members can also be iterated over::" msgstr "" -#: ../../howto/enum.rst:867 +#: ../../howto/enum.rst:868 msgid "" ">>> purple = Color.RED | Color.BLUE\n" ">>> list(purple)\n" @@ -1622,7 +1625,7 @@ msgstr "" ">>> list(purple)\n" "[, ]" -#: ../../howto/enum.rst:875 +#: ../../howto/enum.rst:876 msgid "" "For the majority of new code, :class:`Enum` and :class:`Flag` are strongly " "recommended, since :class:`IntEnum` and :class:`IntFlag` break some semantic " @@ -1633,17 +1636,17 @@ msgid "" "enumerations, or for interoperability with other systems." msgstr "" -#: ../../howto/enum.rst:885 +#: ../../howto/enum.rst:886 msgid "Others" msgstr "其他" -#: ../../howto/enum.rst:887 +#: ../../howto/enum.rst:888 msgid "" "While :class:`IntEnum` is part of the :mod:`enum` module, it would be very " "simple to implement independently::" msgstr "" -#: ../../howto/enum.rst:890 +#: ../../howto/enum.rst:891 #, fuzzy msgid "" "class IntEnum(int, ReprEnum): # or Enum instead of ReprEnum\n" @@ -1652,32 +1655,32 @@ msgstr "" "class IntEnum(int, Enum):\n" " pass" -#: ../../howto/enum.rst:893 +#: ../../howto/enum.rst:894 msgid "" "This demonstrates how similar derived enumerations can be defined; for " -"example a :class:`FloatEnum` that mixes in :class:`float` instead of :class:" +"example a :class:`!FloatEnum` that mixes in :class:`float` instead of :class:" "`int`." msgstr "" -#: ../../howto/enum.rst:896 +#: ../../howto/enum.rst:897 msgid "Some rules:" msgstr "一些規則:" -#: ../../howto/enum.rst:898 +#: ../../howto/enum.rst:899 msgid "" "When subclassing :class:`Enum`, mix-in types must appear before the :class:" "`Enum` class itself in the sequence of bases, as in the :class:`IntEnum` " "example above." msgstr "" -#: ../../howto/enum.rst:901 +#: ../../howto/enum.rst:902 msgid "" "Mix-in types must be subclassable. For example, :class:`bool` and :class:" "`range` are not subclassable and will throw an error during Enum creation if " "used as the mix-in type." msgstr "" -#: ../../howto/enum.rst:904 +#: ../../howto/enum.rst:905 msgid "" "While :class:`Enum` can have members of any type, once you mix in an " "additional type, all the members must have values of that type, e.g. :class:" @@ -1685,57 +1688,60 @@ msgid "" "methods and don't specify another type." msgstr "" -#: ../../howto/enum.rst:908 +#: ../../howto/enum.rst:909 msgid "" -"When another data type is mixed in, the :attr:`value` attribute is *not the " -"same* as the enum member itself, although it is equivalent and will compare " -"equal." +"When another data type is mixed in, the :attr:`~Enum.value` attribute is " +"*not the same* as the enum member itself, although it is equivalent and will " +"compare equal." msgstr "" -#: ../../howto/enum.rst:911 +#: ../../howto/enum.rst:912 msgid "" -"A ``data type`` is a mixin that defines :meth:`__new__`, or a :class:" +"A ``data type`` is a mixin that defines :meth:`~object.__new__`, or a :class:" "`~dataclasses.dataclass`" msgstr "" -#: ../../howto/enum.rst:913 +#: ../../howto/enum.rst:914 msgid "" "%-style formatting: ``%s`` and ``%r`` call the :class:`Enum` class's :meth:" -"`__str__` and :meth:`__repr__` respectively; other codes (such as ``%i`` or " -"``%h`` for IntEnum) treat the enum member as its mixed-in type." +"`~object.__str__` and :meth:`~object.__repr__` respectively; other codes " +"(such as ``%i`` or ``%h`` for IntEnum) treat the enum member as its mixed-in " +"type." msgstr "" -#: ../../howto/enum.rst:916 +#: ../../howto/enum.rst:917 msgid "" ":ref:`Formatted string literals `, :meth:`str.format`, and :func:" -"`format` will use the enum's :meth:`__str__` method." +"`format` will use the enum's :meth:`~object.__str__` method." msgstr "" -#: ../../howto/enum.rst:921 +#: ../../howto/enum.rst:922 msgid "" "Because :class:`IntEnum`, :class:`IntFlag`, and :class:`StrEnum` are " "designed to be drop-in replacements for existing constants, their :meth:" -"`__str__` method has been reset to their data types' :meth:`__str__` method." +"`~object.__str__` method has been reset to their data types' :meth:`~object." +"__str__` method." msgstr "" -#: ../../howto/enum.rst:929 -msgid "When to use :meth:`__new__` vs. :meth:`__init__`" +#: ../../howto/enum.rst:930 +msgid "When to use :meth:`~object.__new__` vs. :meth:`~object.__init__`" msgstr "" -#: ../../howto/enum.rst:931 +#: ../../howto/enum.rst:932 msgid "" -":meth:`__new__` must be used whenever you want to customize the actual value " -"of the :class:`Enum` member. Any other modifications may go in either :meth:" -"`__new__` or :meth:`__init__`, with :meth:`__init__` being preferred." +":meth:`~object.__new__` must be used whenever you want to customize the " +"actual value of the :class:`Enum` member. Any other modifications may go in " +"either :meth:`~object.__new__` or :meth:`~object.__init__`, with :meth:" +"`~object.__init__` being preferred." msgstr "" -#: ../../howto/enum.rst:935 +#: ../../howto/enum.rst:936 msgid "" "For example, if you want to pass several items to the constructor, but only " "want one of them to be the value::" msgstr "" -#: ../../howto/enum.rst:938 +#: ../../howto/enum.rst:939 msgid "" ">>> class Coordinate(bytes, Enum):\n" "... \"\"\"\n" @@ -1760,114 +1766,115 @@ msgid "" "Coordinate.VY" msgstr "" -#: ../../howto/enum.rst:962 +#: ../../howto/enum.rst:963 msgid "" "*Do not* call ``super().__new__()``, as the lookup-only ``__new__`` is the " "one that is found; instead, use the data type directly." msgstr "" -#: ../../howto/enum.rst:967 +#: ../../howto/enum.rst:968 msgid "Finer Points" msgstr "" -#: ../../howto/enum.rst:970 +#: ../../howto/enum.rst:971 msgid "Supported ``__dunder__`` names" msgstr "" -#: ../../howto/enum.rst:972 +#: ../../howto/enum.rst:973 msgid "" -":attr:`__members__` is a read-only ordered mapping of ``member_name``:" -"``member`` items. It is only available on the class." +":attr:`~enum.EnumType.__members__` is a read-only ordered mapping of " +"``member_name``:``member`` items. It is only available on the class." msgstr "" -#: ../../howto/enum.rst:975 +#: ../../howto/enum.rst:976 msgid "" -":meth:`__new__`, if specified, must create and return the enum members; it " -"is also a very good idea to set the member's :attr:`_value_` appropriately. " -"Once all the members are created it is no longer used." +":meth:`~object.__new__`, if specified, must create and return the enum " +"members; it is also a very good idea to set the member's :attr:`~Enum." +"_value_` appropriately. Once all the members are created it is no longer " +"used." msgstr "" -#: ../../howto/enum.rst:981 +#: ../../howto/enum.rst:982 msgid "Supported ``_sunder_`` names" msgstr "" -#: ../../howto/enum.rst:983 +#: ../../howto/enum.rst:984 #, fuzzy msgid ":attr:`~Enum._name_` -- name of the member" msgstr "``_name_`` -- 成員的名稱" -#: ../../howto/enum.rst:984 +#: ../../howto/enum.rst:985 msgid ":attr:`~Enum._value_` -- value of the member; can be set in ``__new__``" msgstr "" -#: ../../howto/enum.rst:985 +#: ../../howto/enum.rst:986 msgid "" ":meth:`~Enum._missing_` -- a lookup function used when a value is not found; " "may be overridden" msgstr "" -#: ../../howto/enum.rst:987 +#: ../../howto/enum.rst:988 msgid "" ":attr:`~Enum._ignore_` -- a list of names, either as a :class:`list` or a :" "class:`str`, that will not be transformed into members, and will be removed " "from the final class" msgstr "" -#: ../../howto/enum.rst:990 +#: ../../howto/enum.rst:991 msgid "" ":meth:`~Enum._generate_next_value_` -- used to get an appropriate value for " "an enum member; may be overridden" msgstr "" -#: ../../howto/enum.rst:992 +#: ../../howto/enum.rst:993 msgid "" -":meth:`~Enum._add_alias_` -- adds a new name as an alias to an existing " +":meth:`~EnumType._add_alias_` -- adds a new name as an alias to an existing " "member." msgstr "" -#: ../../howto/enum.rst:994 +#: ../../howto/enum.rst:995 msgid "" -":meth:`~Enum._add_value_alias_` -- adds a new value as an alias to an " +":meth:`~EnumType._add_value_alias_` -- adds a new value as an alias to an " "existing member. See `MultiValueEnum`_ for an example." msgstr "" -#: ../../howto/enum.rst:999 +#: ../../howto/enum.rst:1000 msgid "" "For standard :class:`Enum` classes the next value chosen is the highest " "value seen incremented by one." msgstr "" -#: ../../howto/enum.rst:1002 +#: ../../howto/enum.rst:1003 msgid "" "For :class:`Flag` classes the next value chosen will be the next highest " "power-of-two." msgstr "" -#: ../../howto/enum.rst:1005 +#: ../../howto/enum.rst:1006 msgid "" "Prior versions would use the last seen value instead of the highest value." msgstr "" -#: ../../howto/enum.rst:1008 +#: ../../howto/enum.rst:1009 msgid "``_missing_``, ``_order_``, ``_generate_next_value_``" msgstr "``_missing_``、``_order_``、``_generate_next_value_``" -#: ../../howto/enum.rst:1009 +#: ../../howto/enum.rst:1010 msgid "``_ignore_``" msgstr "``_ignore_``" -#: ../../howto/enum.rst:1010 +#: ../../howto/enum.rst:1011 msgid "``_add_alias_``, ``_add_value_alias_``" msgstr "" -#: ../../howto/enum.rst:1012 +#: ../../howto/enum.rst:1013 msgid "" -"To help keep Python 2 / Python 3 code in sync an :attr:`_order_` attribute " -"can be provided. It will be checked against the actual order of the " -"enumeration and raise an error if the two do not match::" +"To help keep Python 2 / Python 3 code in sync an :attr:`~Enum._order_` " +"attribute can be provided. It will be checked against the actual order of " +"the enumeration and raise an error if the two do not match::" msgstr "" -#: ../../howto/enum.rst:1016 +#: ../../howto/enum.rst:1017 msgid "" ">>> class Color(Enum):\n" "... _order_ = 'RED GREEN BLUE'\n" @@ -1893,27 +1900,27 @@ msgstr "" " ['RED', 'BLUE', 'GREEN']\n" " ['RED', 'GREEN', 'BLUE']" -#: ../../howto/enum.rst:1030 +#: ../../howto/enum.rst:1031 msgid "" -"In Python 2 code the :attr:`_order_` attribute is necessary as definition " -"order is lost before it can be recorded." +"In Python 2 code the :attr:`~Enum._order_` attribute is necessary as " +"definition order is lost before it can be recorded." msgstr "" -#: ../../howto/enum.rst:1035 +#: ../../howto/enum.rst:1036 msgid "_Private__names" msgstr "_Private__names" -#: ../../howto/enum.rst:1037 +#: ../../howto/enum.rst:1038 msgid "" ":ref:`Private names ` are not converted to enum " "members, but remain normal attributes." msgstr "" -#: ../../howto/enum.rst:1044 +#: ../../howto/enum.rst:1045 msgid "``Enum`` member type" msgstr "" -#: ../../howto/enum.rst:1046 +#: ../../howto/enum.rst:1047 msgid "" "Enum members are instances of their enum class, and are normally accessed as " "``EnumClass.member``. In certain situations, such as writing custom enum " @@ -1923,18 +1930,18 @@ msgid "" "strongly recommended." msgstr "" -#: ../../howto/enum.rst:1057 +#: ../../howto/enum.rst:1058 msgid "Creating members that are mixed with other data types" msgstr "" -#: ../../howto/enum.rst:1059 +#: ../../howto/enum.rst:1060 msgid "" "When subclassing other data types, such as :class:`int` or :class:`str`, " "with an :class:`Enum`, all values after the ``=`` are passed to that data " "type's constructor. For example::" msgstr "" -#: ../../howto/enum.rst:1063 +#: ../../howto/enum.rst:1064 msgid "" ">>> class MyEnum(IntEnum): # help(int) -> int(x, base=10) -> integer\n" "... example = '11', 16 # so x='11' and base=16\n" @@ -1943,11 +1950,11 @@ msgid "" "17" msgstr "" -#: ../../howto/enum.rst:1071 +#: ../../howto/enum.rst:1072 msgid "Boolean value of ``Enum`` classes and members" msgstr "" -#: ../../howto/enum.rst:1073 +#: ../../howto/enum.rst:1074 msgid "" "Enum classes that are mixed with non-:class:`Enum` types (such as :class:" "`int`, :class:`str`, etc.) are evaluated according to the mixed-in type's " @@ -1956,7 +1963,7 @@ msgid "" "your class::" msgstr "" -#: ../../howto/enum.rst:1079 +#: ../../howto/enum.rst:1080 msgid "" "def __bool__(self):\n" " return bool(self.value)" @@ -1964,27 +1971,28 @@ msgstr "" "def __bool__(self):\n" " return bool(self.value)" -#: ../../howto/enum.rst:1082 +#: ../../howto/enum.rst:1083 msgid "Plain :class:`Enum` classes always evaluate as :data:`True`." msgstr "" -#: ../../howto/enum.rst:1086 +#: ../../howto/enum.rst:1087 msgid "``Enum`` classes with methods" msgstr "" -#: ../../howto/enum.rst:1088 +#: ../../howto/enum.rst:1089 msgid "" "If you give your enum subclass extra methods, like the `Planet`_ class " "below, those methods will show up in a :func:`dir` of the member, but not of " "the class::" msgstr "" -#: ../../howto/enum.rst:1092 +#: ../../howto/enum.rst:1093 +#, fuzzy msgid "" -">>> dir(Planet) \n" +">>> dir(Planet)\n" "['EARTH', 'JUPITER', 'MARS', 'MERCURY', 'NEPTUNE', 'SATURN', 'URANUS', " "'VENUS', '__class__', '__doc__', '__members__', '__module__']\n" -">>> dir(Planet.EARTH) \n" +">>> dir(Planet.EARTH)\n" "['__class__', '__doc__', '__module__', 'mass', 'name', 'radius', " "'surface_gravity', 'value']" msgstr "" @@ -1995,17 +2003,17 @@ msgstr "" "['__class__', '__doc__', '__module__', 'mass', 'name', 'radius', " "'surface_gravity', 'value']" -#: ../../howto/enum.rst:1099 +#: ../../howto/enum.rst:1100 msgid "Combining members of ``Flag``" msgstr "" -#: ../../howto/enum.rst:1101 +#: ../../howto/enum.rst:1102 msgid "" "Iterating over a combination of :class:`Flag` members will only return the " "members that are comprised of a single bit::" msgstr "" -#: ../../howto/enum.rst:1104 +#: ../../howto/enum.rst:1105 msgid "" ">>> class Color(Flag):\n" "... RED = auto()\n" @@ -2021,15 +2029,15 @@ msgid "" "" msgstr "" -#: ../../howto/enum.rst:1119 +#: ../../howto/enum.rst:1120 msgid "``Flag`` and ``IntFlag`` minutia" msgstr "" -#: ../../howto/enum.rst:1121 +#: ../../howto/enum.rst:1122 msgid "Using the following snippet for our examples::" msgstr "" -#: ../../howto/enum.rst:1123 +#: ../../howto/enum.rst:1124 msgid "" ">>> class Color(IntFlag):\n" "... BLACK = 0\n" @@ -2049,23 +2057,23 @@ msgstr "" "... WHITE = RED | GREEN | BLUE\n" "..." -#: ../../howto/enum.rst:1132 +#: ../../howto/enum.rst:1133 msgid "the following are true:" msgstr "" -#: ../../howto/enum.rst:1134 +#: ../../howto/enum.rst:1135 msgid "single-bit flags are canonical" msgstr "" -#: ../../howto/enum.rst:1135 +#: ../../howto/enum.rst:1136 msgid "multi-bit and zero-bit flags are aliases" msgstr "" -#: ../../howto/enum.rst:1136 +#: ../../howto/enum.rst:1137 msgid "only canonical flags are returned during iteration::" msgstr "" -#: ../../howto/enum.rst:1138 +#: ../../howto/enum.rst:1139 msgid "" ">>> list(Color.WHITE)\n" "[, , ]" @@ -2073,13 +2081,13 @@ msgstr "" ">>> list(Color.WHITE)\n" "[, , ]" -#: ../../howto/enum.rst:1141 +#: ../../howto/enum.rst:1142 msgid "" "negating a flag or flag set returns a new flag/flag set with the " "corresponding positive integer value::" msgstr "" -#: ../../howto/enum.rst:1144 +#: ../../howto/enum.rst:1145 msgid "" ">>> Color.BLUE\n" "\n" @@ -2093,11 +2101,11 @@ msgstr "" ">>> ~Color.BLUE\n" "" -#: ../../howto/enum.rst:1150 +#: ../../howto/enum.rst:1151 msgid "names of pseudo-flags are constructed from their members' names::" msgstr "" -#: ../../howto/enum.rst:1152 +#: ../../howto/enum.rst:1153 msgid "" ">>> (Color.RED | Color.GREEN).name\n" "'RED|GREEN'\n" @@ -2111,11 +2119,11 @@ msgid "" "True" msgstr "" -#: ../../howto/enum.rst:1163 +#: ../../howto/enum.rst:1164 msgid "multi-bit flags, aka aliases, can be returned from operations::" msgstr "" -#: ../../howto/enum.rst:1165 +#: ../../howto/enum.rst:1166 msgid "" ">>> Color.RED | Color.BLUE\n" "\n" @@ -2135,13 +2143,13 @@ msgstr "" ">>> Color(0)\n" "" -#: ../../howto/enum.rst:1174 +#: ../../howto/enum.rst:1175 msgid "" "membership / containment checking: zero-valued flags are always considered " "to be contained::" msgstr "" -#: ../../howto/enum.rst:1177 +#: ../../howto/enum.rst:1178 msgid "" ">>> Color.BLACK in Color.WHITE\n" "True" @@ -2149,13 +2157,13 @@ msgstr "" ">>> Color.BLACK in Color.WHITE\n" "True" -#: ../../howto/enum.rst:1180 +#: ../../howto/enum.rst:1181 msgid "" "otherwise, only if all bits of one flag are in the other flag will True be " "returned::" msgstr "" -#: ../../howto/enum.rst:1183 +#: ../../howto/enum.rst:1184 msgid "" ">>> Color.PURPLE in Color.WHITE\n" "True\n" @@ -2169,77 +2177,78 @@ msgstr "" ">>> Color.GREEN in Color.PURPLE\n" "False" -#: ../../howto/enum.rst:1189 +#: ../../howto/enum.rst:1190 msgid "" "There is a new boundary mechanism that controls how out-of-range / invalid " "bits are handled: ``STRICT``, ``CONFORM``, ``EJECT``, and ``KEEP``:" msgstr "" -#: ../../howto/enum.rst:1192 +#: ../../howto/enum.rst:1193 msgid "STRICT --> raises an exception when presented with invalid values" msgstr "" -#: ../../howto/enum.rst:1193 +#: ../../howto/enum.rst:1194 msgid "CONFORM --> discards any invalid bits" msgstr "" -#: ../../howto/enum.rst:1194 +#: ../../howto/enum.rst:1195 msgid "EJECT --> lose Flag status and become a normal int with the given value" msgstr "" -#: ../../howto/enum.rst:1195 +#: ../../howto/enum.rst:1196 msgid "KEEP --> keep the extra bits" msgstr "" -#: ../../howto/enum.rst:1197 +#: ../../howto/enum.rst:1198 msgid "keeps Flag status and extra bits" msgstr "" -#: ../../howto/enum.rst:1198 +#: ../../howto/enum.rst:1199 msgid "extra bits do not show up in iteration" msgstr "" -#: ../../howto/enum.rst:1199 +#: ../../howto/enum.rst:1200 msgid "extra bits do show up in repr() and str()" msgstr "" -#: ../../howto/enum.rst:1201 +#: ../../howto/enum.rst:1202 msgid "" "The default for Flag is ``STRICT``, the default for ``IntFlag`` is " "``EJECT``, and the default for ``_convert_`` is ``KEEP`` (see ``ssl." "Options`` for an example of when ``KEEP`` is needed)." msgstr "" -#: ../../howto/enum.rst:1209 +#: ../../howto/enum.rst:1210 msgid "How are Enums and Flags different?" msgstr "" -#: ../../howto/enum.rst:1211 +#: ../../howto/enum.rst:1212 msgid "" "Enums have a custom metaclass that affects many aspects of both derived :" "class:`Enum` classes and their instances (members)." msgstr "" -#: ../../howto/enum.rst:1216 +#: ../../howto/enum.rst:1217 msgid "Enum Classes" msgstr "" -#: ../../howto/enum.rst:1218 +#: ../../howto/enum.rst:1219 msgid "" "The :class:`EnumType` metaclass is responsible for providing the :meth:" -"`__contains__`, :meth:`__dir__`, :meth:`__iter__` and other methods that " -"allow one to do things with an :class:`Enum` class that fail on a typical " -"class, such as ``list(Color)`` or ``some_enum_var in Color``. :class:" -"`EnumType` is responsible for ensuring that various other methods on the " -"final :class:`Enum` class are correct (such as :meth:`__new__`, :meth:" -"`__getnewargs__`, :meth:`__str__` and :meth:`__repr__`)." +"`~object.__contains__`, :meth:`~object.__dir__`, :meth:`~object.__iter__` " +"and other methods that allow one to do things with an :class:`Enum` class " +"that fail on a typical class, such as ``list(Color)`` or ``some_enum_var in " +"Color``. :class:`EnumType` is responsible for ensuring that various other " +"methods on the final :class:`Enum` class are correct (such as :meth:`~object." +"__new__`, :meth:`~object.__getnewargs__`, :meth:`~object.__str__` and :meth:" +"`~object.__repr__`)." msgstr "" -#: ../../howto/enum.rst:1227 +#: ../../howto/enum.rst:1228 msgid "Flag Classes" msgstr "" -#: ../../howto/enum.rst:1229 +#: ../../howto/enum.rst:1230 msgid "" "Flags have an expanded view of aliasing: to be canonical, the value of a " "flag needs to be a power-of-two value, and not a duplicate name. So, in " @@ -2248,30 +2257,30 @@ msgid "" "considered an alias." msgstr "" -#: ../../howto/enum.rst:1235 +#: ../../howto/enum.rst:1236 msgid "Enum Members (aka instances)" msgstr "" -#: ../../howto/enum.rst:1237 +#: ../../howto/enum.rst:1238 msgid "" "The most interesting thing about enum members is that they are singletons. :" "class:`EnumType` creates them all while it is creating the enum class " -"itself, and then puts a custom :meth:`__new__` in place to ensure that no " -"new ones are ever instantiated by returning only the existing member " +"itself, and then puts a custom :meth:`~object.__new__` in place to ensure " +"that no new ones are ever instantiated by returning only the existing member " "instances." msgstr "" -#: ../../howto/enum.rst:1243 +#: ../../howto/enum.rst:1244 msgid "Flag Members" msgstr "" -#: ../../howto/enum.rst:1245 +#: ../../howto/enum.rst:1246 msgid "" "Flag members can be iterated over just like the :class:`Flag` class, and " "only the canonical members will be returned. For example::" msgstr "" -#: ../../howto/enum.rst:1248 +#: ../../howto/enum.rst:1249 msgid "" ">>> list(Color)\n" "[, , ]" @@ -2279,17 +2288,17 @@ msgstr "" ">>> list(Color)\n" "[, , ]" -#: ../../howto/enum.rst:1251 +#: ../../howto/enum.rst:1252 msgid "(Note that ``BLACK``, ``PURPLE``, and ``WHITE`` do not show up.)" msgstr "" -#: ../../howto/enum.rst:1253 +#: ../../howto/enum.rst:1254 msgid "" "Inverting a flag member returns the corresponding positive value, rather " "than a negative value --- for example::" msgstr "" -#: ../../howto/enum.rst:1256 +#: ../../howto/enum.rst:1257 msgid "" ">>> ~Color.RED\n" "" @@ -2297,13 +2306,13 @@ msgstr "" ">>> ~Color.RED\n" "" -#: ../../howto/enum.rst:1259 +#: ../../howto/enum.rst:1260 msgid "" "Flag members have a length corresponding to the number of power-of-two " "values they contain. For example::" msgstr "" -#: ../../howto/enum.rst:1262 +#: ../../howto/enum.rst:1263 msgid "" ">>> len(Color.PURPLE)\n" "2" @@ -2311,11 +2320,11 @@ msgstr "" ">>> len(Color.PURPLE)\n" "2" -#: ../../howto/enum.rst:1269 +#: ../../howto/enum.rst:1270 msgid "Enum Cookbook" msgstr "" -#: ../../howto/enum.rst:1272 +#: ../../howto/enum.rst:1273 msgid "" "While :class:`Enum`, :class:`IntEnum`, :class:`StrEnum`, :class:`Flag`, and :" "class:`IntFlag` are expected to cover the majority of use-cases, they cannot " @@ -2323,50 +2332,50 @@ msgid "" "that can be used directly, or as examples for creating one's own." msgstr "" -#: ../../howto/enum.rst:1279 +#: ../../howto/enum.rst:1280 msgid "Omitting values" msgstr "" -#: ../../howto/enum.rst:1281 +#: ../../howto/enum.rst:1282 msgid "" "In many use-cases, one doesn't care what the actual value of an enumeration " "is. There are several ways to define this type of simple enumeration:" msgstr "" -#: ../../howto/enum.rst:1284 +#: ../../howto/enum.rst:1285 msgid "use instances of :class:`auto` for the value" msgstr "" -#: ../../howto/enum.rst:1285 +#: ../../howto/enum.rst:1286 msgid "use instances of :class:`object` as the value" msgstr "" -#: ../../howto/enum.rst:1286 +#: ../../howto/enum.rst:1287 msgid "use a descriptive string as the value" msgstr "" -#: ../../howto/enum.rst:1287 +#: ../../howto/enum.rst:1288 msgid "" -"use a tuple as the value and a custom :meth:`__new__` to replace the tuple " -"with an :class:`int` value" +"use a tuple as the value and a custom :meth:`~object.__new__` to replace the " +"tuple with an :class:`int` value" msgstr "" -#: ../../howto/enum.rst:1290 +#: ../../howto/enum.rst:1291 msgid "" "Using any of these methods signifies to the user that these values are not " "important, and also enables one to add, remove, or reorder members without " "having to renumber the remaining members." msgstr "" -#: ../../howto/enum.rst:1296 +#: ../../howto/enum.rst:1297 msgid "Using :class:`auto`" msgstr "使用 :class:`auto`" -#: ../../howto/enum.rst:1298 +#: ../../howto/enum.rst:1299 msgid "Using :class:`auto` would look like::" msgstr "" -#: ../../howto/enum.rst:1300 +#: ../../howto/enum.rst:1301 msgid "" ">>> class Color(Enum):\n" "... RED = auto()\n" @@ -2384,22 +2393,23 @@ msgstr "" ">>> Color.GREEN\n" "" -#: ../../howto/enum.rst:1310 +#: ../../howto/enum.rst:1311 msgid "Using :class:`object`" msgstr "使用 :class:`object`" -#: ../../howto/enum.rst:1312 +#: ../../howto/enum.rst:1313 msgid "Using :class:`object` would look like::" msgstr "" -#: ../../howto/enum.rst:1314 +#: ../../howto/enum.rst:1315 +#, fuzzy msgid "" ">>> class Color(Enum):\n" "... RED = object()\n" "... GREEN = object()\n" "... BLUE = object()\n" "...\n" -">>> Color.GREEN \n" +">>> Color.GREEN\n" ">" msgstr "" ">>> class Color(Enum):\n" @@ -2410,13 +2420,13 @@ msgstr "" ">>> Color.GREEN \n" ">" -#: ../../howto/enum.rst:1322 +#: ../../howto/enum.rst:1323 msgid "" "This is also a good example of why you might want to write your own :meth:" -"`__repr__`::" +"`~object.__repr__`::" msgstr "" -#: ../../howto/enum.rst:1325 +#: ../../howto/enum.rst:1326 msgid "" ">>> class Color(Enum):\n" "... RED = object()\n" @@ -2438,15 +2448,15 @@ msgstr "" ">>> Color.GREEN\n" "" -#: ../../howto/enum.rst:1338 +#: ../../howto/enum.rst:1339 msgid "Using a descriptive string" msgstr "" -#: ../../howto/enum.rst:1340 +#: ../../howto/enum.rst:1341 msgid "Using a string as the value would look like::" msgstr "" -#: ../../howto/enum.rst:1342 +#: ../../howto/enum.rst:1343 msgid "" ">>> class Color(Enum):\n" "... RED = 'stop'\n" @@ -2464,15 +2474,15 @@ msgstr "" ">>> Color.GREEN\n" "" -#: ../../howto/enum.rst:1352 -msgid "Using a custom :meth:`__new__`" +#: ../../howto/enum.rst:1353 +msgid "Using a custom :meth:`~object.__new__`" msgstr "" -#: ../../howto/enum.rst:1354 -msgid "Using an auto-numbering :meth:`__new__` would look like::" +#: ../../howto/enum.rst:1355 +msgid "Using an auto-numbering :meth:`~object.__new__` would look like::" msgstr "" -#: ../../howto/enum.rst:1356 +#: ../../howto/enum.rst:1357 msgid "" ">>> class AutoNumber(Enum):\n" "... def __new__(cls):\n" @@ -2504,13 +2514,13 @@ msgstr "" ">>> Color.GREEN\n" "" -#: ../../howto/enum.rst:1371 +#: ../../howto/enum.rst:1372 msgid "" "To make a more general purpose ``AutoNumber``, add ``*args`` to the " "signature::" msgstr "" -#: ../../howto/enum.rst:1373 +#: ../../howto/enum.rst:1374 msgid "" ">>> class AutoNumber(Enum):\n" "... def __new__(cls, *args): # this is the only change from above\n" @@ -2521,13 +2531,13 @@ msgid "" "..." msgstr "" -#: ../../howto/enum.rst:1381 +#: ../../howto/enum.rst:1382 msgid "" "Then when you inherit from ``AutoNumber`` you can write your own " "``__init__`` to handle any extra arguments::" msgstr "" -#: ../../howto/enum.rst:1384 +#: ../../howto/enum.rst:1385 msgid "" ">>> class Swatch(AutoNumber):\n" "... def __init__(self, pantone='unknown'):\n" @@ -2544,35 +2554,35 @@ msgid "" "'unknown'" msgstr "" -#: ../../howto/enum.rst:1400 +#: ../../howto/enum.rst:1401 msgid "" -"The :meth:`__new__` method, if defined, is used during creation of the Enum " -"members; it is then replaced by Enum's :meth:`__new__` which is used after " -"class creation for lookup of existing members." +"The :meth:`~object.__new__` method, if defined, is used during creation of " +"the Enum members; it is then replaced by Enum's :meth:`~object.__new__` " +"which is used after class creation for lookup of existing members." msgstr "" -#: ../../howto/enum.rst:1406 +#: ../../howto/enum.rst:1407 msgid "" "*Do not* call ``super().__new__()``, as the lookup-only ``__new__`` is the " "one that is found; instead, use the data type directly -- e.g.::" msgstr "" -#: ../../howto/enum.rst:1409 +#: ../../howto/enum.rst:1410 msgid "obj = int.__new__(cls, value)" msgstr "obj = int.__new__(cls, value)" -#: ../../howto/enum.rst:1413 +#: ../../howto/enum.rst:1414 msgid "OrderedEnum" msgstr "OrderedEnum" -#: ../../howto/enum.rst:1415 +#: ../../howto/enum.rst:1416 msgid "" "An ordered enumeration that is not based on :class:`IntEnum` and so " "maintains the normal :class:`Enum` invariants (such as not being comparable " "to other enumerations)::" msgstr "" -#: ../../howto/enum.rst:1419 +#: ../../howto/enum.rst:1420 msgid "" ">>> class OrderedEnum(Enum):\n" "... def __ge__(self, other):\n" @@ -2630,17 +2640,17 @@ msgstr "" ">>> Grade.C < Grade.A\n" "True" -#: ../../howto/enum.rst:1449 +#: ../../howto/enum.rst:1450 msgid "DuplicateFreeEnum" msgstr "DuplicateFreeEnum" -#: ../../howto/enum.rst:1451 +#: ../../howto/enum.rst:1452 msgid "" "Raises an error if a duplicate member value is found instead of creating an " "alias::" msgstr "" -#: ../../howto/enum.rst:1454 +#: ../../howto/enum.rst:1455 msgid "" ">>> class DuplicateFreeEnum(Enum):\n" "... def __init__(self, *args):\n" @@ -2664,22 +2674,22 @@ msgid "" "ValueError: aliases not allowed in DuplicateFreeEnum: 'GRENE' --> 'GREEN'" msgstr "" -#: ../../howto/enum.rst:1476 +#: ../../howto/enum.rst:1477 msgid "" "This is a useful example for subclassing Enum to add or change other " "behaviors as well as disallowing aliases. If the only desired change is " "disallowing aliases, the :func:`unique` decorator can be used instead." msgstr "" -#: ../../howto/enum.rst:1482 +#: ../../howto/enum.rst:1483 msgid "MultiValueEnum" msgstr "" -#: ../../howto/enum.rst:1484 +#: ../../howto/enum.rst:1485 msgid "Supports having more than one value per member::" msgstr "" -#: ../../howto/enum.rst:1486 +#: ../../howto/enum.rst:1487 msgid "" ">>> class MultiValueEnum(Enum):\n" "... def __new__(cls, value, *values):\n" @@ -2699,17 +2709,17 @@ msgid "" "" msgstr "" -#: ../../howto/enum.rst:1505 +#: ../../howto/enum.rst:1506 msgid "Planet" msgstr "" -#: ../../howto/enum.rst:1507 +#: ../../howto/enum.rst:1508 msgid "" -"If :meth:`__new__` or :meth:`__init__` is defined, the value of the enum " -"member will be passed to those methods::" +"If :meth:`~object.__new__` or :meth:`~object.__init__` is defined, the value " +"of the enum member will be passed to those methods::" msgstr "" -#: ../../howto/enum.rst:1510 +#: ../../howto/enum.rst:1511 msgid "" ">>> class Planet(Enum):\n" "... MERCURY = (3.303e+23, 2.4397e6)\n" @@ -2735,15 +2745,15 @@ msgid "" "9.802652743337129" msgstr "" -#: ../../howto/enum.rst:1536 +#: ../../howto/enum.rst:1537 msgid "TimePeriod" msgstr "" -#: ../../howto/enum.rst:1538 -msgid "An example to show the :attr:`_ignore_` attribute in use::" +#: ../../howto/enum.rst:1539 +msgid "An example to show the :attr:`~Enum._ignore_` attribute in use::" msgstr "" -#: ../../howto/enum.rst:1540 +#: ../../howto/enum.rst:1541 msgid "" ">>> from datetime import timedelta\n" ">>> class Period(timedelta, Enum):\n" @@ -2761,11 +2771,11 @@ msgid "" "timedelta(days=366)>]" msgstr "" -#: ../../howto/enum.rst:1557 +#: ../../howto/enum.rst:1558 msgid "Subclassing EnumType" msgstr "" -#: ../../howto/enum.rst:1559 +#: ../../howto/enum.rst:1560 msgid "" "While most enum needs can be met by customizing :class:`Enum` subclasses, " "either with class decorators or custom functions, :class:`EnumType` can be " diff --git a/howto/free-threading-extensions.po b/howto/free-threading-extensions.po index 08d6aaa97a..a71d38d7bb 100644 --- a/howto/free-threading-extensions.po +++ b/howto/free-threading-extensions.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2024-09-24 07:20+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -303,11 +303,11 @@ msgid "" "to provide implementations of these functions for older Python versions." msgstr "" -#: ../../howto/free-threading-extensions.rst:185 +#: ../../howto/free-threading-extensions.rst:187 msgid "Memory Allocation APIs" msgstr "" -#: ../../howto/free-threading-extensions.rst:187 +#: ../../howto/free-threading-extensions.rst:189 msgid "" "Python's memory management C API provides functions in three different :ref:" "`allocation domains `: \"raw\", \"mem\", and \"object\". " @@ -317,36 +317,36 @@ msgid "" "where this was only a best practice and not a hard requirement." msgstr "" -#: ../../howto/free-threading-extensions.rst:196 +#: ../../howto/free-threading-extensions.rst:198 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:203 +#: ../../howto/free-threading-extensions.rst:205 msgid "Thread State and GIL APIs" msgstr "" -#: ../../howto/free-threading-extensions.rst:205 +#: ../../howto/free-threading-extensions.rst:207 msgid "" "Python provides a set of functions and macros to manage thread state and the " "GIL, such as:" msgstr "" -#: ../../howto/free-threading-extensions.rst:208 +#: ../../howto/free-threading-extensions.rst:210 msgid ":c:func:`PyGILState_Ensure` and :c:func:`PyGILState_Release`" msgstr "" -#: ../../howto/free-threading-extensions.rst:209 +#: ../../howto/free-threading-extensions.rst:211 msgid ":c:func:`PyEval_SaveThread` and :c:func:`PyEval_RestoreThread`" msgstr "" -#: ../../howto/free-threading-extensions.rst:210 +#: ../../howto/free-threading-extensions.rst:212 msgid ":c:macro:`Py_BEGIN_ALLOW_THREADS` and :c:macro:`Py_END_ALLOW_THREADS`" msgstr "" -#: ../../howto/free-threading-extensions.rst:212 +#: ../../howto/free-threading-extensions.rst:214 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 " @@ -355,7 +355,7 @@ msgid "" "Python thread state." msgstr "" -#: ../../howto/free-threading-extensions.rst:218 +#: ../../howto/free-threading-extensions.rst:220 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 " @@ -363,25 +363,25 @@ msgid "" "collector `." msgstr "" -#: ../../howto/free-threading-extensions.rst:225 +#: ../../howto/free-threading-extensions.rst:227 msgid "Protecting Internal Extension State" msgstr "" -#: ../../howto/free-threading-extensions.rst:227 +#: ../../howto/free-threading-extensions.rst:229 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:231 +#: ../../howto/free-threading-extensions.rst:233 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:234 +#: ../../howto/free-threading-extensions.rst:236 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 " @@ -389,34 +389,34 @@ msgid "" "language/storage_duration>`_." msgstr "" -#: ../../howto/free-threading-extensions.rst:241 +#: ../../howto/free-threading-extensions.rst:243 msgid "Building Extensions for the Free-Threaded Build" msgstr "" -#: ../../howto/free-threading-extensions.rst:243 +#: ../../howto/free-threading-extensions.rst:245 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:246 +#: ../../howto/free-threading-extensions.rst:248 msgid "" "`pypa/manylinux `_ supports the free-" "threaded build, with the ``t`` suffix, such as ``python3.13t``." msgstr "" -#: ../../howto/free-threading-extensions.rst:248 +#: ../../howto/free-threading-extensions.rst:250 msgid "" "`pypa/cibuildwheel `_ supports the " "free-threaded build if you set `CIBW_FREE_THREADED_SUPPORT `_." msgstr "" -#: ../../howto/free-threading-extensions.rst:253 +#: ../../howto/free-threading-extensions.rst:255 msgid "Limited C API and Stable ABI" msgstr "" -#: ../../howto/free-threading-extensions.rst:255 +#: ../../howto/free-threading-extensions.rst:257 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 new file mode 100644 index 0000000000..0b66f7083b --- /dev/null +++ b/howto/free-threading-python.po @@ -0,0 +1,257 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2001-2024, Python Software Foundation +# This file is distributed under the same license as the Python package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Python 3.13\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-02-07 08:41+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/free-threading-python.rst:5 +msgid "Python experimental support for free threading" +msgstr "" + +#: ../../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." +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." +msgstr "" + +#: ../../howto/free-threading-python.rst:17 +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 +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 +msgid "Installation" +msgstr "" + +#: ../../howto/free-threading-python.rst:30 +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 +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 +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 +msgid "Identifying free-threaded Python" +msgstr "" + +#: ../../howto/free-threading-python.rst:45 +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." +msgstr "" + +#: ../../howto/free-threading-python.rst:50 +msgid "" +"The ``sysconfig.get_config_var(\"Py_GIL_DISABLED\")`` configuration variable " +"can be used to determine whether the build supports free threading. If the " +"variable is set to ``1``, then the build supports free threading. This is " +"the recommended mechanism for decisions related to the build configuration." +msgstr "" + +#: ../../howto/free-threading-python.rst:57 +msgid "The global interpreter lock in free-threaded Python" +msgstr "" + +#: ../../howto/free-threading-python.rst:59 +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 +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 +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 +msgid "https://py-free-threading.github.io/tracking/" +msgstr "" + +#: ../../howto/free-threading-python.rst:71 +msgid "https://hugovk.github.io/free-threaded-wheels/" +msgstr "" + +#: ../../howto/free-threading-python.rst:75 +msgid "Thread safety" +msgstr "" + +#: ../../howto/free-threading-python.rst:77 +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 " +"types like :class:`dict`, :class:`list`, and :class:`set` use internal locks " +"to protect against concurrent modifications in ways that behave similarly to " +"the GIL. However, Python has not historically guaranteed specific behavior " +"for concurrent modifications to these built-in types, so this should be " +"treated as a description of the current implementation, not a guarantee of " +"current or future behavior." +msgstr "" + +#: ../../howto/free-threading-python.rst:88 +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 +msgid "Known limitations" +msgstr "" + +#: ../../howto/free-threading-python.rst:96 +msgid "" +"This section describes known limitations of the free-threaded CPython build." +msgstr "" + +#: ../../howto/free-threading-python.rst:99 +msgid "Immortalization" +msgstr "" + +#: ../../howto/free-threading-python.rst:101 +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." +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:" +msgstr "" + +#: ../../howto/free-threading-python.rst:109 +msgid "" +":ref:`function ` objects declared at the module level" +msgstr "" + +#: ../../howto/free-threading-python.rst:110 +msgid ":ref:`method ` descriptors" +msgstr "" + +#: ../../howto/free-threading-python.rst:111 +msgid ":ref:`code ` objects" +msgstr "" + +#: ../../howto/free-threading-python.rst:112 +msgid ":term:`module` objects and their dictionaries" +msgstr "" + +#: ../../howto/free-threading-python.rst:113 +msgid ":ref:`classes ` (type objects)" +msgstr "" + +#: ../../howto/free-threading-python.rst:115 +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." +msgstr "" + +#: ../../howto/free-threading-python.rst:119 +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." +msgstr "" + +#: ../../howto/free-threading-python.rst:125 +msgid "Frame objects" +msgstr "" + +#: ../../howto/free-threading-python.rst:127 +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." +msgstr "" + +#: ../../howto/free-threading-python.rst:135 +msgid "Iterators" +msgstr "" + +#: ../../howto/free-threading-python.rst:137 +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." +msgstr "" + +#: ../../howto/free-threading-python.rst:143 +msgid "Single-threaded performance" +msgstr "" + +#: ../../howto/free-threading-python.rst:145 +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." +msgstr "" diff --git a/howto/functional.po b/howto/functional.po index f55926dec9..a4fe16b526 100644 --- a/howto/functional.po +++ b/howto/functional.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-03-03 18:39+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-" @@ -993,11 +993,11 @@ msgid "" ">>> import random\n" ">>> # Generate 8 random numbers between [0, 10000)\n" ">>> rand_list = random.sample(range(10000), 8)\n" -">>> rand_list \n" +">>> rand_list\n" "[769, 7953, 9828, 6431, 8442, 9878, 6213, 2207]\n" -">>> sorted(rand_list) \n" +">>> sorted(rand_list)\n" "[769, 2207, 6213, 6431, 7953, 8442, 9828, 9878]\n" -">>> sorted(rand_list, reverse=True) \n" +">>> sorted(rand_list, reverse=True)\n" "[9878, 9828, 8442, 7953, 6431, 6213, 2207, 769]" msgstr "" diff --git a/howto/gdb_helpers.po b/howto/gdb_helpers.po index 67e53cc2e0..337d952c2b 100644 --- a/howto/gdb_helpers.po +++ b/howto/gdb_helpers.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-12 00:04+0000\n" +"POT-Creation-Date: 2024-12-15 18:10+0000\n" "PO-Revision-Date: 2024-05-11 14:42+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -389,15 +389,19 @@ msgstr "" "$4 = 42" #: ../../howto/gdb_helpers.rst:183 +#, fuzzy msgid "" "The internal structure can be revealed with a cast to :c:expr:`PyLongObject " -"*`:" +"*`::" msgstr "可以透過轉換 (cast) 為 :c:expr:`PyLongObject *` 來揭示內部結構:" #: ../../howto/gdb_helpers.rst:185 +#, fuzzy msgid "" -"(gdb) p *(PyLongObject*)some_python_integer $5 = {ob_base = {ob_base = " -"{ob_refcnt = 8, ob_type = 0x3dad39f5e0}, ob_size = 1}, ob_digit = {42}}" +"(gdb) p *(PyLongObject*)some_python_integer\n" +"$5 = {ob_base = {ob_base = {ob_refcnt = 8, ob_type = 0x3dad39f5e0}, ob_size " +"= 1},\n" +"ob_digit = {42}}" msgstr "" "(gdb) p *(PyLongObject*)some_python_integer $5 = {ob_base = {ob_base = " "{ob_refcnt = 8, ob_type = 0x3dad39f5e0}, ob_size = 1}, ob_digit = {42}}" diff --git a/howto/index.po b/howto/index.po index d0d55f2163..ea54ad59f6 100644 --- a/howto/index.po +++ b/howto/index.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2024-10-04 16:20+0000\n" "PO-Revision-Date: 2021-07-05 12:45+0800\n" "Last-Translator: Liang-Bo Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -36,103 +36,107 @@ msgstr "" "些單一、特定的主題。以 Linux 說明文件專案的 HOWTO 系列為模範,本系列的目標是" "提供比 Python 函式庫參考手冊更實用的說明文件。" -#: ../../howto/index.rst:37 +#: ../../howto/index.rst:38 msgid "General:" msgstr "" -#: ../../howto/index.rst:39 +#: ../../howto/index.rst:40 msgid ":ref:`annotations-howto`" msgstr "" -#: ../../howto/index.rst:40 +#: ../../howto/index.rst:41 msgid ":ref:`argparse-tutorial`" msgstr "" -#: ../../howto/index.rst:41 +#: ../../howto/index.rst:42 msgid ":ref:`descriptorhowto`" msgstr "" -#: ../../howto/index.rst:42 +#: ../../howto/index.rst:43 msgid ":ref:`enum-howto`" msgstr "" -#: ../../howto/index.rst:43 +#: ../../howto/index.rst:44 msgid ":ref:`functional-howto`" msgstr "" -#: ../../howto/index.rst:44 +#: ../../howto/index.rst:45 msgid ":ref:`ipaddress-howto`" msgstr "" -#: ../../howto/index.rst:45 +#: ../../howto/index.rst:46 msgid ":ref:`logging-howto`" msgstr "" -#: ../../howto/index.rst:46 +#: ../../howto/index.rst:47 msgid ":ref:`logging-cookbook`" msgstr "" -#: ../../howto/index.rst:47 +#: ../../howto/index.rst:48 msgid ":ref:`regex-howto`" msgstr "" -#: ../../howto/index.rst:48 +#: ../../howto/index.rst:49 msgid ":ref:`sortinghowto`" msgstr "" -#: ../../howto/index.rst:49 +#: ../../howto/index.rst:50 msgid ":ref:`unicode-howto`" msgstr "" -#: ../../howto/index.rst:50 +#: ../../howto/index.rst:51 msgid ":ref:`urllib-howto`" msgstr "" -#: ../../howto/index.rst:52 +#: ../../howto/index.rst:53 msgid "Advanced development:" msgstr "" -#: ../../howto/index.rst:54 +#: ../../howto/index.rst:55 msgid ":ref:`curses-howto`" msgstr "" -#: ../../howto/index.rst:55 +#: ../../howto/index.rst:56 +msgid ":ref:`freethreading-python-howto`" +msgstr "" + +#: ../../howto/index.rst:57 msgid ":ref:`freethreading-extensions-howto`" msgstr "" -#: ../../howto/index.rst:56 +#: ../../howto/index.rst:58 msgid ":ref:`isolating-extensions-howto`" msgstr "" -#: ../../howto/index.rst:57 +#: ../../howto/index.rst:59 msgid ":ref:`python_2.3_mro`" msgstr "" -#: ../../howto/index.rst:58 +#: ../../howto/index.rst:60 msgid ":ref:`socket-howto`" msgstr "" -#: ../../howto/index.rst:59 +#: ../../howto/index.rst:61 msgid ":ref:`timerfd-howto`" msgstr "" -#: ../../howto/index.rst:60 +#: ../../howto/index.rst:62 msgid ":ref:`cporting-howto`" msgstr "" -#: ../../howto/index.rst:62 +#: ../../howto/index.rst:64 msgid "Debugging and profiling:" msgstr "" -#: ../../howto/index.rst:64 +#: ../../howto/index.rst:66 msgid ":ref:`gdb`" msgstr "" -#: ../../howto/index.rst:65 +#: ../../howto/index.rst:67 msgid ":ref:`instrumentation`" msgstr "" -#: ../../howto/index.rst:66 +#: ../../howto/index.rst:68 msgid ":ref:`perf_profiling`" msgstr "" diff --git a/howto/ipaddress.po b/howto/ipaddress.po index 69bef65056..12a8e3d010 100644 --- a/howto/ipaddress.po +++ b/howto/ipaddress.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-03-03 18:39+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-" @@ -332,10 +332,11 @@ msgid "Iterating through the \"usable\" addresses on a network::" msgstr "" #: ../../howto/ipaddress.rst:192 +#, fuzzy msgid "" ">>> net4 = ipaddress.ip_network('192.0.2.0/24')\n" ">>> for x in net4.hosts():\n" -"... print(x) \n" +"... print(x)\n" "192.0.2.1\n" "192.0.2.2\n" "192.0.2.3\n" diff --git a/howto/logging-cookbook.po b/howto/logging-cookbook.po index abe416bd57..89179215b2 100644 --- a/howto/logging-cookbook.po +++ b/howto/logging-cookbook.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-03-03 18:39+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-" @@ -1102,11 +1102,32 @@ msgid "" "configured ports clash with something else in your test environment." msgstr "" -#: ../../howto/logging-cookbook.rst:843 +#: ../../howto/logging-cookbook.rst:838 +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 +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 " +"corresponding domain socket and not on a TCP socket (the ``port`` key is " +"ignored)." +msgstr "" + +#: ../../howto/logging-cookbook.rst:846 +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 msgid "Adding contextual information to your logging output" msgstr "" -#: ../../howto/logging-cookbook.rst:845 +#: ../../howto/logging-cookbook.rst:858 msgid "" "Sometimes you want logging output to contain contextual information in " "addition to the parameters passed to the logging call. For example, in a " @@ -1122,11 +1143,11 @@ msgid "" "`Logger` instances becomes effectively unbounded." msgstr "" -#: ../../howto/logging-cookbook.rst:860 +#: ../../howto/logging-cookbook.rst:873 msgid "Using LoggerAdapters to impart contextual information" msgstr "" -#: ../../howto/logging-cookbook.rst:862 +#: ../../howto/logging-cookbook.rst:875 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. " @@ -1137,7 +1158,7 @@ msgid "" "types of instances interchangeably." msgstr "" -#: ../../howto/logging-cookbook.rst:870 +#: ../../howto/logging-cookbook.rst:883 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 " @@ -1148,7 +1169,7 @@ msgid "" "of :class:`LoggerAdapter`::" msgstr "" -#: ../../howto/logging-cookbook.rst:878 +#: ../../howto/logging-cookbook.rst:891 msgid "" "def debug(self, msg, /, *args, **kwargs):\n" " \"\"\"\n" @@ -1159,7 +1180,7 @@ msgid "" " self.logger.debug(msg, *args, **kwargs)" msgstr "" -#: ../../howto/logging-cookbook.rst:886 +#: ../../howto/logging-cookbook.rst:899 msgid "" "The :meth:`~LoggerAdapter.process` method of :class:`LoggerAdapter` is where " "the contextual information is added to the logging output. It's passed the " @@ -1172,7 +1193,7 @@ msgid "" "be silently overwritten." msgstr "" -#: ../../howto/logging-cookbook.rst:895 +#: ../../howto/logging-cookbook.rst:908 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 " @@ -1183,7 +1204,7 @@ msgid "" "`~LoggerAdapter.process` to do what you need. Here is a simple example::" msgstr "" -#: ../../howto/logging-cookbook.rst:903 +#: ../../howto/logging-cookbook.rst:916 msgid "" "class CustomAdapter(logging.LoggerAdapter):\n" " \"\"\"\n" @@ -1194,27 +1215,27 @@ msgid "" " return '[%s] %s' % (self.extra['connid'], msg), kwargs" msgstr "" -#: ../../howto/logging-cookbook.rst:911 +#: ../../howto/logging-cookbook.rst:924 msgid "which you can use like this::" msgstr "" -#: ../../howto/logging-cookbook.rst:913 +#: ../../howto/logging-cookbook.rst:926 msgid "" "logger = logging.getLogger(__name__)\n" "adapter = CustomAdapter(logger, {'connid': some_conn_id})" msgstr "" -#: ../../howto/logging-cookbook.rst:916 +#: ../../howto/logging-cookbook.rst:929 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:920 +#: ../../howto/logging-cookbook.rst:933 msgid "Using objects other than dicts to pass contextual information" msgstr "" -#: ../../howto/logging-cookbook.rst:922 +#: ../../howto/logging-cookbook.rst:935 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 " @@ -1223,11 +1244,11 @@ msgid "" "would be constant)." msgstr "" -#: ../../howto/logging-cookbook.rst:931 +#: ../../howto/logging-cookbook.rst:944 msgid "Using Filters to impart contextual information" msgstr "" -#: ../../howto/logging-cookbook.rst:933 +#: ../../howto/logging-cookbook.rst:946 msgid "" "You can also add contextual information to log output using a user-defined :" "class:`Filter`. ``Filter`` instances are allowed to modify the " @@ -1236,7 +1257,7 @@ msgid "" "class:`Formatter`." msgstr "" -#: ../../howto/logging-cookbook.rst:938 +#: ../../howto/logging-cookbook.rst:951 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:" @@ -1248,7 +1269,7 @@ msgid "" "an example script::" msgstr "" -#: ../../howto/logging-cookbook.rst:947 +#: ../../howto/logging-cookbook.rst:960 msgid "" "import logging\n" "from random import choice\n" @@ -1291,11 +1312,11 @@ msgid "" "'parameters')" msgstr "" -#: ../../howto/logging-cookbook.rst:984 +#: ../../howto/logging-cookbook.rst:997 msgid "which, when run, produces something like:" msgstr "" -#: ../../howto/logging-cookbook.rst:986 +#: ../../howto/logging-cookbook.rst:999 msgid "" "2010-09-06 22:38:15,292 a.b.c DEBUG IP: 123.231.231.123 User: fred A " "debug message\n" @@ -1323,11 +1344,11 @@ msgid "" "message at INFO level with 2 parameters" msgstr "" -#: ../../howto/logging-cookbook.rst:1002 +#: ../../howto/logging-cookbook.rst:1015 msgid "Use of ``contextvars``" msgstr "" -#: ../../howto/logging-cookbook.rst:1004 +#: ../../howto/logging-cookbook.rst:1017 msgid "" "Since Python 3.7, the :mod:`contextvars` module has provided context-local " "storage which works for both :mod:`threading` and :mod:`asyncio` processing " @@ -1337,7 +1358,7 @@ msgid "" "attributes handled by web applications." msgstr "" -#: ../../howto/logging-cookbook.rst:1010 +#: ../../howto/logging-cookbook.rst:1023 msgid "" "For the purposes of illustration, say that you have different web " "applications, each independent of the other but running in the same Python " @@ -1348,11 +1369,11 @@ msgid "" "information such as client IP, HTTP request method and client username?" msgstr "" -#: ../../howto/logging-cookbook.rst:1017 +#: ../../howto/logging-cookbook.rst:1030 msgid "Let's assume that the library can be simulated by the following code:" msgstr "" -#: ../../howto/logging-cookbook.rst:1019 +#: ../../howto/logging-cookbook.rst:1032 msgid "" "# webapplib.py\n" "import logging\n" @@ -1367,14 +1388,14 @@ msgid "" " time.sleep(0.01)" msgstr "" -#: ../../howto/logging-cookbook.rst:1033 +#: ../../howto/logging-cookbook.rst:1046 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:1037 +#: ../../howto/logging-cookbook.rst:1050 msgid "" "# main.py\n" "import argparse\n" @@ -1529,7 +1550,7 @@ msgid "" " main()" msgstr "" -#: ../../howto/logging-cookbook.rst:1177 +#: ../../howto/logging-cookbook.rst:1190 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 " @@ -1540,7 +1561,7 @@ msgid "" "illustrated by the following shell output:" msgstr "" -#: ../../howto/logging-cookbook.rst:1184 +#: ../../howto/logging-cookbook.rst:1197 msgid "" "~/logging-contextual-webapp$ python main.py\n" "app1 processed 51 requests\n" @@ -1595,11 +1616,11 @@ msgid "" "147" msgstr "" -#: ../../howto/logging-cookbook.rst:1224 +#: ../../howto/logging-cookbook.rst:1237 msgid "Imparting contextual information in handlers" msgstr "" -#: ../../howto/logging-cookbook.rst:1226 +#: ../../howto/logging-cookbook.rst:1239 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 " @@ -1607,7 +1628,7 @@ msgid "" "instead of modifying it in-place, as shown in the following script::" msgstr "" -#: ../../howto/logging-cookbook.rst:1231 +#: ../../howto/logging-cookbook.rst:1244 msgid "" "import copy\n" "import logging\n" @@ -1629,11 +1650,11 @@ msgid "" " logger.info('A log message')" msgstr "" -#: ../../howto/logging-cookbook.rst:1253 +#: ../../howto/logging-cookbook.rst:1266 msgid "Logging to a single file from multiple processes" msgstr "" -#: ../../howto/logging-cookbook.rst:1255 +#: ../../howto/logging-cookbook.rst:1268 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 " @@ -1649,18 +1670,15 @@ msgid "" "you to adapt in your own applications." msgstr "" -#: ../../howto/logging-cookbook.rst:1268 +#: ../../howto/logging-cookbook.rst:1281 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 existing :class:" -"`FileHandler` and subclasses do not make use of :mod:`multiprocessing` at " -"present, though they may do so in the future. Note that at present, the :mod:" -"`multiprocessing` module does not provide working lock functionality on all " -"platforms (see https://bugs.python.org/issue3770)." +"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:1278 +#: ../../howto/logging-cookbook.rst:1288 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 " @@ -1675,7 +1693,7 @@ msgid "" "requirements::" msgstr "" -#: ../../howto/logging-cookbook.rst:1289 +#: ../../howto/logging-cookbook.rst:1299 msgid "" "# You'll need these imports in your own code\n" "import logging\n" @@ -1795,13 +1813,13 @@ msgid "" " main()" msgstr "" -#: ../../howto/logging-cookbook.rst:1394 +#: ../../howto/logging-cookbook.rst:1404 msgid "" "A variant of the above script keeps the logging in the main process, in a " "separate thread::" msgstr "" -#: ../../howto/logging-cookbook.rst:1397 +#: ../../howto/logging-cookbook.rst:1407 msgid "" "import logging\n" "import logging.config\n" @@ -1898,7 +1916,7 @@ msgid "" " lp.join()" msgstr "" -#: ../../howto/logging-cookbook.rst:1489 +#: ../../howto/logging-cookbook.rst:1499 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 " @@ -1908,36 +1926,36 @@ msgid "" "appropriate destinations." msgstr "" -#: ../../howto/logging-cookbook.rst:1496 +#: ../../howto/logging-cookbook.rst:1506 msgid "Using concurrent.futures.ProcessPoolExecutor" msgstr "" -#: ../../howto/logging-cookbook.rst:1498 +#: ../../howto/logging-cookbook.rst:1508 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:1502 +#: ../../howto/logging-cookbook.rst:1512 msgid "queue = multiprocessing.Queue(-1)" msgstr "" -#: ../../howto/logging-cookbook.rst:1506 +#: ../../howto/logging-cookbook.rst:1516 msgid "you should use" msgstr "" -#: ../../howto/logging-cookbook.rst:1508 +#: ../../howto/logging-cookbook.rst:1518 msgid "" "queue = multiprocessing.Manager().Queue(-1) # also works with the examples " "above" msgstr "" -#: ../../howto/logging-cookbook.rst:1512 +#: ../../howto/logging-cookbook.rst:1522 msgid "and you can then replace the worker creation from this::" msgstr "" -#: ../../howto/logging-cookbook.rst:1514 +#: ../../howto/logging-cookbook.rst:1524 msgid "" "workers = []\n" "for i in range(10):\n" @@ -1949,22 +1967,22 @@ msgid "" " w.join()" msgstr "" -#: ../../howto/logging-cookbook.rst:1523 +#: ../../howto/logging-cookbook.rst:1533 msgid "to this (remembering to first import :mod:`concurrent.futures`)::" msgstr "" -#: ../../howto/logging-cookbook.rst:1525 +#: ../../howto/logging-cookbook.rst:1535 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:1530 +#: ../../howto/logging-cookbook.rst:1540 msgid "Deploying Web applications using Gunicorn and uWSGI" msgstr "" -#: ../../howto/logging-cookbook.rst:1532 +#: ../../howto/logging-cookbook.rst:1542 msgid "" "When deploying Web applications using `Gunicorn `_ or " "`uWSGI `_ (or similar), " @@ -1976,11 +1994,11 @@ msgid "" "listener in production`_ for more details." msgstr "" -#: ../../howto/logging-cookbook.rst:1542 +#: ../../howto/logging-cookbook.rst:1552 msgid "Using file rotation" msgstr "" -#: ../../howto/logging-cookbook.rst:1547 +#: ../../howto/logging-cookbook.rst:1557 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, " @@ -1989,7 +2007,7 @@ msgid "" "usage pattern, the logging package provides a :class:`RotatingFileHandler`::" msgstr "" -#: ../../howto/logging-cookbook.rst:1553 +#: ../../howto/logging-cookbook.rst:1563 msgid "" "import glob\n" "import logging\n" @@ -2018,13 +2036,13 @@ msgid "" " print(filename)" msgstr "" -#: ../../howto/logging-cookbook.rst:1579 +#: ../../howto/logging-cookbook.rst:1589 msgid "" "The result should be 6 separate files, each with part of the log history for " "the application:" msgstr "" -#: ../../howto/logging-cookbook.rst:1582 +#: ../../howto/logging-cookbook.rst:1592 msgid "" "logging_rotatingfile_example.out\n" "logging_rotatingfile_example.out.1\n" @@ -2034,7 +2052,7 @@ msgid "" "logging_rotatingfile_example.out.5" msgstr "" -#: ../../howto/logging-cookbook.rst:1591 +#: ../../howto/logging-cookbook.rst:1601 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 " @@ -2042,17 +2060,17 @@ msgid "" "(``.1`` becomes ``.2``, etc.) and the ``.6`` file is erased." msgstr "" -#: ../../howto/logging-cookbook.rst:1596 +#: ../../howto/logging-cookbook.rst:1606 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:1604 +#: ../../howto/logging-cookbook.rst:1614 msgid "Use of alternative formatting styles" msgstr "" -#: ../../howto/logging-cookbook.rst:1606 +#: ../../howto/logging-cookbook.rst:1616 msgid "" "When logging was added to the Python standard library, the only way of " "formatting messages with variable content was to use the %-formatting " @@ -2061,7 +2079,7 @@ msgid "" "Python 2.6)." msgstr "" -#: ../../howto/logging-cookbook.rst:1612 +#: ../../howto/logging-cookbook.rst:1622 msgid "" "Logging (as of 3.2) provides improved support for these two additional " "formatting styles. The :class:`Formatter` class been enhanced to take an " @@ -2074,7 +2092,7 @@ msgid "" "session to show the possibilities:" msgstr "" -#: ../../howto/logging-cookbook.rst:1622 +#: ../../howto/logging-cookbook.rst:1632 msgid "" ">>> import logging\n" ">>> root = logging.getLogger()\n" @@ -2099,21 +2117,21 @@ msgid "" ">>>" msgstr "" -#: ../../howto/logging-cookbook.rst:1646 +#: ../../howto/logging-cookbook.rst:1656 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:1650 +#: ../../howto/logging-cookbook.rst:1660 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 "" -#: ../../howto/logging-cookbook.rst:1654 +#: ../../howto/logging-cookbook.rst:1664 msgid "" "Logging calls (``logger.debug()``, ``logger.info()`` etc.) only take " "positional parameters for the actual logging message itself, with keyword " @@ -2129,7 +2147,7 @@ msgid "" "strings." msgstr "" -#: ../../howto/logging-cookbook.rst:1667 +#: ../../howto/logging-cookbook.rst:1677 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 " @@ -2138,7 +2156,7 @@ msgid "" "the following two classes::" msgstr "" -#: ../../howto/logging-cookbook.rst:1673 ../../howto/logging-cookbook.rst:2761 +#: ../../howto/logging-cookbook.rst:1683 ../../howto/logging-cookbook.rst:2771 msgid "" "class BraceMessage:\n" " def __init__(self, fmt, /, *args, **kwargs):\n" @@ -2176,7 +2194,7 @@ msgstr "" " from string import Template\n" " return Template(self.fmt).substitute(**self.kwargs)" -#: ../../howto/logging-cookbook.rst:1691 +#: ../../howto/logging-cookbook.rst:1701 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 " @@ -2187,14 +2205,14 @@ msgid "" "used as a synonym/alias for :func:`gettext.gettext` or its brethren)." msgstr "" -#: ../../howto/logging-cookbook.rst:1699 +#: ../../howto/logging-cookbook.rst:1709 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:1703 +#: ../../howto/logging-cookbook.rst:1713 msgid "" ">>> from wherever import BraceMessage as __\n" ">>> print(__('Message with {0} {name}', 2, name='placeholders'))\n" @@ -2213,14 +2231,14 @@ msgid "" ">>>" msgstr "" -#: ../../howto/logging-cookbook.rst:1721 +#: ../../howto/logging-cookbook.rst:1731 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:1725 +#: ../../howto/logging-cookbook.rst:1735 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 " @@ -2231,13 +2249,13 @@ msgid "" "sugar for a constructor call to one of the :samp:`{XXX}Message` classes." msgstr "" -#: ../../howto/logging-cookbook.rst:1733 +#: ../../howto/logging-cookbook.rst:1743 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:1736 +#: ../../howto/logging-cookbook.rst:1746 msgid "" "import logging\n" "\n" @@ -2266,17 +2284,17 @@ msgid "" " main()" msgstr "" -#: ../../howto/logging-cookbook.rst:1762 +#: ../../howto/logging-cookbook.rst:1772 msgid "" "The above script should log the message ``Hello, world!`` when run with " "Python 3.8 or later." msgstr "" -#: ../../howto/logging-cookbook.rst:1771 +#: ../../howto/logging-cookbook.rst:1781 msgid "Customizing ``LogRecord``" msgstr "" -#: ../../howto/logging-cookbook.rst:1773 +#: ../../howto/logging-cookbook.rst:1783 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:" @@ -2287,13 +2305,13 @@ msgid "" "was done:" msgstr "" -#: ../../howto/logging-cookbook.rst:1780 +#: ../../howto/logging-cookbook.rst:1790 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:1783 +#: ../../howto/logging-cookbook.rst:1793 msgid "" ":func:`makeLogRecord`, which is called with a dictionary containing " "attributes to be added to the LogRecord. This is typically invoked when a " @@ -2302,27 +2320,27 @@ msgid "" "`~handlers.HTTPHandler`)." msgstr "" -#: ../../howto/logging-cookbook.rst:1789 +#: ../../howto/logging-cookbook.rst:1799 msgid "" "This has usually meant that if you need to do anything special with a :class:" "`LogRecord`, you've had to do one of the following." msgstr "" -#: ../../howto/logging-cookbook.rst:1792 +#: ../../howto/logging-cookbook.rst:1802 msgid "" "Create your own :class:`Logger` subclass, which overrides :meth:`Logger." "makeRecord`, and set it using :func:`~logging.setLoggerClass` before any " "loggers that you care about are instantiated." msgstr "" -#: ../../howto/logging-cookbook.rst:1795 +#: ../../howto/logging-cookbook.rst:1805 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:1799 +#: ../../howto/logging-cookbook.rst:1809 msgid "" "The first approach would be a little unwieldy in the scenario where (say) " "several different libraries wanted to do different things. Each would " @@ -2330,7 +2348,7 @@ msgid "" "last would win." msgstr "" -#: ../../howto/logging-cookbook.rst:1804 +#: ../../howto/logging-cookbook.rst:1814 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 " @@ -2339,11 +2357,11 @@ msgid "" "would do simply by adding new packages or modules and doing ::" msgstr "" -#: ../../howto/logging-cookbook.rst:1810 +#: ../../howto/logging-cookbook.rst:1820 msgid "logger = logging.getLogger(__name__)" msgstr "logger = logging.getLogger(__name__)" -#: ../../howto/logging-cookbook.rst:1812 +#: ../../howto/logging-cookbook.rst:1822 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` " @@ -2353,7 +2371,7 @@ msgid "" "developer." msgstr "" -#: ../../howto/logging-cookbook.rst:1818 +#: ../../howto/logging-cookbook.rst:1828 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 " @@ -2363,7 +2381,7 @@ msgid "" "`LogRecord` is the default setting for the factory." msgstr "" -#: ../../howto/logging-cookbook.rst:1825 +#: ../../howto/logging-cookbook.rst:1835 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 " @@ -2371,7 +2389,7 @@ msgid "" "this::" msgstr "" -#: ../../howto/logging-cookbook.rst:1829 +#: ../../howto/logging-cookbook.rst:1839 msgid "" "old_factory = logging.getLogRecordFactory()\n" "\n" @@ -2383,7 +2401,7 @@ msgid "" "logging.setLogRecordFactory(record_factory)" msgstr "" -#: ../../howto/logging-cookbook.rst:1838 +#: ../../howto/logging-cookbook.rst:1848 msgid "" "This pattern allows different libraries to chain factories together, and as " "long as they don't overwrite each other's attributes or unintentionally " @@ -2393,22 +2411,22 @@ msgid "" "used when the use of a :class:`Filter` does not provide the desired result." msgstr "" -#: ../../howto/logging-cookbook.rst:1850 +#: ../../howto/logging-cookbook.rst:1860 msgid "Subclassing QueueHandler and QueueListener- a ZeroMQ example" msgstr "" -#: ../../howto/logging-cookbook.rst:1853 ../../howto/logging-cookbook.rst:1986 +#: ../../howto/logging-cookbook.rst:1863 ../../howto/logging-cookbook.rst:1996 msgid "Subclass ``QueueHandler``" msgstr "" -#: ../../howto/logging-cookbook.rst:1855 +#: ../../howto/logging-cookbook.rst:1865 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:1859 +#: ../../howto/logging-cookbook.rst:1869 msgid "" "import zmq # using pyzmq, the Python binding for ZeroMQ\n" "import json # for serializing records portably\n" @@ -2425,13 +2443,13 @@ msgid "" "handler = ZeroMQSocketHandler(sock)" msgstr "" -#: ../../howto/logging-cookbook.rst:1874 +#: ../../howto/logging-cookbook.rst:1884 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:1877 +#: ../../howto/logging-cookbook.rst:1887 msgid "" "class ZeroMQSocketHandler(QueueHandler):\n" " def __init__(self, uri, socktype=zmq.PUB, ctx=None):\n" @@ -2447,17 +2465,17 @@ msgid "" " self.queue.close()" msgstr "" -#: ../../howto/logging-cookbook.rst:1892 ../../howto/logging-cookbook.rst:1922 +#: ../../howto/logging-cookbook.rst:1902 ../../howto/logging-cookbook.rst:1932 msgid "Subclass ``QueueListener``" msgstr "" -#: ../../howto/logging-cookbook.rst:1894 +#: ../../howto/logging-cookbook.rst:1904 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:1897 +#: ../../howto/logging-cookbook.rst:1907 msgid "" "class ZeroMQSocketListener(QueueListener):\n" " def __init__(self, uri, /, *handlers, **kwargs):\n" @@ -2473,11 +2491,11 @@ msgid "" " return logging.makeLogRecord(msg)" msgstr "" -#: ../../howto/logging-cookbook.rst:1912 +#: ../../howto/logging-cookbook.rst:1922 msgid "Subclassing QueueHandler and QueueListener- a ``pynng`` example" msgstr "" -#: ../../howto/logging-cookbook.rst:1914 +#: ../../howto/logging-cookbook.rst:1924 msgid "" "In a similar way to the above section, we can implement a listener and " "handler using :pypi:`pynng`, which is a Python binding to `NNG `_ of the Django documentation." msgstr "" -#: ../../howto/logging-cookbook.rst:2160 +#: ../../howto/logging-cookbook.rst:2170 msgid "Using a rotator and namer to customize log rotation processing" msgstr "" -#: ../../howto/logging-cookbook.rst:2162 +#: ../../howto/logging-cookbook.rst:2172 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:2165 +#: ../../howto/logging-cookbook.rst:2175 msgid "" "import gzip\n" "import logging\n" @@ -2860,12 +2878,12 @@ msgstr "" "for i in range(1000):\n" " root.info(f'Message no. {i + 1}')" -#: ../../howto/logging-cookbook.rst:2193 +#: ../../howto/logging-cookbook.rst:2203 msgid "" "After running this, you will see six new files, five of which are compressed:" msgstr "" -#: ../../howto/logging-cookbook.rst:2195 +#: ../../howto/logging-cookbook.rst:2205 msgid "" "$ ls rotated.log*\n" "rotated.log rotated.log.2.gz rotated.log.4.gz\n" @@ -2883,11 +2901,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:2206 +#: ../../howto/logging-cookbook.rst:2216 msgid "A more elaborate multiprocessing example" msgstr "" -#: ../../howto/logging-cookbook.rst:2208 +#: ../../howto/logging-cookbook.rst:2218 msgid "" "The following working example shows how logging can be used with " "multiprocessing using configuration files. The configurations are fairly " @@ -2895,7 +2913,7 @@ msgid "" "in a real multiprocessing scenario." msgstr "" -#: ../../howto/logging-cookbook.rst:2213 +#: ../../howto/logging-cookbook.rst:2223 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 " @@ -2908,13 +2926,13 @@ msgid "" "own scenario." msgstr "" -#: ../../howto/logging-cookbook.rst:2223 +#: ../../howto/logging-cookbook.rst:2233 msgid "" "Here's the script - the docstrings and the comments hopefully explain how it " "works::" msgstr "" -#: ../../howto/logging-cookbook.rst:2226 +#: ../../howto/logging-cookbook.rst:2236 msgid "" "import logging\n" "import logging.config\n" @@ -3137,11 +3155,11 @@ msgid "" " main()" msgstr "" -#: ../../howto/logging-cookbook.rst:2435 +#: ../../howto/logging-cookbook.rst:2445 msgid "Inserting a BOM into messages sent to a SysLogHandler" msgstr "" -#: ../../howto/logging-cookbook.rst:2437 +#: ../../howto/logging-cookbook.rst:2447 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 " @@ -3150,7 +3168,7 @@ msgid "" "<5424#section-6>`.)" msgstr "" -#: ../../howto/logging-cookbook.rst:2443 +#: ../../howto/logging-cookbook.rst:2453 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 " @@ -3158,7 +3176,7 @@ msgid "" "hence not allowing any pure-ASCII component to appear before it." msgstr "" -#: ../../howto/logging-cookbook.rst:2449 +#: ../../howto/logging-cookbook.rst:2459 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 " @@ -3167,37 +3185,37 @@ msgid "" "encoded using UTF-8, then you need to do the following:" msgstr "" -#: ../../howto/logging-cookbook.rst:2455 +#: ../../howto/logging-cookbook.rst:2465 msgid "" "Attach a :class:`~logging.Formatter` instance to your :class:`~logging." "handlers.SysLogHandler` instance, with a format string such as::" msgstr "" -#: ../../howto/logging-cookbook.rst:2459 +#: ../../howto/logging-cookbook.rst:2469 msgid "'ASCII section\\ufeffUnicode section'" msgstr "" -#: ../../howto/logging-cookbook.rst:2461 +#: ../../howto/logging-cookbook.rst:2471 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:2464 +#: ../../howto/logging-cookbook.rst:2474 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:2468 +#: ../../howto/logging-cookbook.rst:2478 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:2472 +#: ../../howto/logging-cookbook.rst:2482 msgid "" "The formatted message *will* be encoded using UTF-8 encoding by " "``SysLogHandler``. If you follow the above rules, you should be able to " @@ -3206,11 +3224,11 @@ msgid "" "daemon may complain." msgstr "" -#: ../../howto/logging-cookbook.rst:2479 +#: ../../howto/logging-cookbook.rst:2489 msgid "Implementing structured logging" msgstr "" -#: ../../howto/logging-cookbook.rst:2481 +#: ../../howto/logging-cookbook.rst:2491 msgid "" "Although most logging messages are intended for reading by humans, and thus " "not readily machine-parseable, there might be circumstances where you want " @@ -3222,7 +3240,7 @@ msgid "" "machine-parseable manner::" msgstr "" -#: ../../howto/logging-cookbook.rst:2489 +#: ../../howto/logging-cookbook.rst:2499 msgid "" "import json\n" "import logging\n" @@ -3241,11 +3259,11 @@ msgid "" "logging.info(_('message 1', foo='bar', bar='baz', num=123, fnum=123.456))" msgstr "" -#: ../../howto/logging-cookbook.rst:2505 +#: ../../howto/logging-cookbook.rst:2515 msgid "If the above script is run, it prints:" msgstr "" -#: ../../howto/logging-cookbook.rst:2507 +#: ../../howto/logging-cookbook.rst:2517 msgid "" "message 1 >>> {\"fnum\": 123.456, \"num\": 123, \"bar\": \"baz\", \"foo\": " "\"bar\"}" @@ -3253,19 +3271,19 @@ msgstr "" "message 1 >>> {\"fnum\": 123.456, \"num\": 123, \"bar\": \"baz\", \"foo\": " "\"bar\"}" -#: ../../howto/logging-cookbook.rst:2511 ../../howto/logging-cookbook.rst:2553 +#: ../../howto/logging-cookbook.rst:2521 ../../howto/logging-cookbook.rst:2563 msgid "" "Note that the order of items might be different according to the version of " "Python used." msgstr "" -#: ../../howto/logging-cookbook.rst:2514 +#: ../../howto/logging-cookbook.rst:2524 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:2517 +#: ../../howto/logging-cookbook.rst:2527 msgid "" "import json\n" "import logging\n" @@ -3298,19 +3316,19 @@ msgid "" " main()" msgstr "" -#: ../../howto/logging-cookbook.rst:2547 +#: ../../howto/logging-cookbook.rst:2557 msgid "When the above script is run, it prints:" msgstr "" -#: ../../howto/logging-cookbook.rst:2549 +#: ../../howto/logging-cookbook.rst:2559 msgid "message 1 >>> {\"snowman\": \"\\u2603\", \"set_value\": [1, 2, 3]}" msgstr "message 1 >>> {\"snowman\": \"\\u2603\", \"set_value\": [1, 2, 3]}" -#: ../../howto/logging-cookbook.rst:2562 +#: ../../howto/logging-cookbook.rst:2572 msgid "Customizing handlers with :func:`dictConfig`" msgstr "" -#: ../../howto/logging-cookbook.rst:2564 +#: ../../howto/logging-cookbook.rst:2574 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 " @@ -3320,7 +3338,7 @@ msgid "" "customize handler creation using a plain function such as::" msgstr "" -#: ../../howto/logging-cookbook.rst:2571 +#: ../../howto/logging-cookbook.rst:2581 msgid "" "def owned_file_handler(filename, mode='a', encoding=None, owner=None):\n" " if owner:\n" @@ -3336,13 +3354,13 @@ msgstr "" " shutil.chown(filename, *owner)\n" " return logging.FileHandler(filename, mode, encoding)" -#: ../../howto/logging-cookbook.rst:2578 +#: ../../howto/logging-cookbook.rst:2588 msgid "" "You can then specify, in a logging configuration passed to :func:" "`dictConfig`, that a logging handler be created by calling this function::" msgstr "" -#: ../../howto/logging-cookbook.rst:2581 +#: ../../howto/logging-cookbook.rst:2591 msgid "" "LOGGING = {\n" " 'version': 1,\n" @@ -3375,14 +3393,14 @@ msgid "" "}" msgstr "" -#: ../../howto/logging-cookbook.rst:2611 +#: ../../howto/logging-cookbook.rst:2621 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:2615 +#: ../../howto/logging-cookbook.rst:2625 msgid "" "import logging, logging.config, os, shutil\n" "\n" @@ -3428,11 +3446,11 @@ msgid "" "logger.debug('A debug message')" msgstr "" -#: ../../howto/logging-cookbook.rst:2658 +#: ../../howto/logging-cookbook.rst:2668 msgid "To run this, you will probably need to run as ``root``:" msgstr "" -#: ../../howto/logging-cookbook.rst:2660 +#: ../../howto/logging-cookbook.rst:2670 msgid "" "$ sudo python3.3 chowntest.py\n" "$ cat chowntest.log\n" @@ -3441,7 +3459,7 @@ msgid "" "-rw-r--r-- 1 pulse pulse 55 2013-11-05 09:34 chowntest.log" msgstr "" -#: ../../howto/logging-cookbook.rst:2668 +#: ../../howto/logging-cookbook.rst:2678 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 " @@ -3450,25 +3468,25 @@ msgid "" "change using e.g. :func:`os.chown`." msgstr "" -#: ../../howto/logging-cookbook.rst:2674 +#: ../../howto/logging-cookbook.rst:2684 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:2677 +#: ../../howto/logging-cookbook.rst:2687 msgid "'()': owned_file_handler," msgstr "'()': owned_file_handler," -#: ../../howto/logging-cookbook.rst:2679 +#: ../../howto/logging-cookbook.rst:2689 msgid "you could use e.g.::" msgstr "" -#: ../../howto/logging-cookbook.rst:2681 +#: ../../howto/logging-cookbook.rst:2691 msgid "'()': 'ext://project.util.owned_file_handler'," msgstr "'()': 'ext://project.util.owned_file_handler'," -#: ../../howto/logging-cookbook.rst:2683 +#: ../../howto/logging-cookbook.rst:2693 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://" @@ -3476,25 +3494,25 @@ msgid "" "resolved by :func:`dictConfig` from the ``ext://`` specification." msgstr "" -#: ../../howto/logging-cookbook.rst:2688 +#: ../../howto/logging-cookbook.rst:2698 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:2692 +#: ../../howto/logging-cookbook.rst:2702 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:2702 +#: ../../howto/logging-cookbook.rst:2712 msgid "Using particular formatting styles throughout your application" msgstr "" -#: ../../howto/logging-cookbook.rst:2704 +#: ../../howto/logging-cookbook.rst:2714 msgid "" "In Python 3.2, the :class:`~logging.Formatter` gained a ``style`` keyword " "parameter which, while defaulting to ``%`` for backward compatibility, " @@ -3505,7 +3523,7 @@ msgid "" "is constructed." msgstr "" -#: ../../howto/logging-cookbook.rst:2711 +#: ../../howto/logging-cookbook.rst:2721 msgid "" "Logging calls (:meth:`~Logger.debug`, :meth:`~Logger.info` etc.) only take " "positional parameters for the actual logging message itself, with keyword " @@ -3520,7 +3538,7 @@ msgid "" "calls which are out there in existing code will be using %-format strings." msgstr "" -#: ../../howto/logging-cookbook.rst:2723 +#: ../../howto/logging-cookbook.rst:2733 msgid "" "There have been suggestions to associate format styles with specific " "loggers, but that approach also runs into backward compatibility problems " @@ -3528,7 +3546,7 @@ msgid "" "formatting." msgstr "" -#: ../../howto/logging-cookbook.rst:2727 +#: ../../howto/logging-cookbook.rst:2737 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 " @@ -3536,11 +3554,11 @@ msgid "" "formatting styles can be accommodated." msgstr "" -#: ../../howto/logging-cookbook.rst:2734 +#: ../../howto/logging-cookbook.rst:2744 msgid "Using LogRecord factories" msgstr "" -#: ../../howto/logging-cookbook.rst:2736 +#: ../../howto/logging-cookbook.rst:2746 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 " @@ -3555,17 +3573,17 @@ msgid "" "implementation does." msgstr "" -#: ../../howto/logging-cookbook.rst:2747 +#: ../../howto/logging-cookbook.rst:2757 msgid "" "Refer to the reference documentation on :func:`setLogRecordFactory` and :" "class:`LogRecord` for more information." msgstr "" -#: ../../howto/logging-cookbook.rst:2752 +#: ../../howto/logging-cookbook.rst:2762 msgid "Using custom message objects" msgstr "" -#: ../../howto/logging-cookbook.rst:2754 +#: ../../howto/logging-cookbook.rst:2764 msgid "" "There is another, perhaps simpler way that you can use {}- and $- formatting " "to construct your individual log messages. You may recall (from :ref:" @@ -3575,7 +3593,7 @@ msgid "" "following two classes::" msgstr "" -#: ../../howto/logging-cookbook.rst:2779 +#: ../../howto/logging-cookbook.rst:2789 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 " @@ -3586,13 +3604,13 @@ msgid "" "using ``_`` for localization)." msgstr "" -#: ../../howto/logging-cookbook.rst:2787 +#: ../../howto/logging-cookbook.rst:2797 msgid "" "Examples of this approach are given below. Firstly, formatting with :meth:" "`str.format`::" msgstr "" -#: ../../howto/logging-cookbook.rst:2790 +#: ../../howto/logging-cookbook.rst:2800 msgid "" ">>> __ = BraceMessage\n" ">>> print(__('Message with {0} {1}', 2, 'placeholders'))\n" @@ -3607,11 +3625,11 @@ msgid "" "Message with coordinates: (0.50, 0.50)" msgstr "" -#: ../../howto/logging-cookbook.rst:2801 +#: ../../howto/logging-cookbook.rst:2811 msgid "Secondly, formatting with :class:`string.Template`::" msgstr "" -#: ../../howto/logging-cookbook.rst:2803 +#: ../../howto/logging-cookbook.rst:2813 msgid "" ">>> __ = DollarMessage\n" ">>> print(__('Message with $num $what', num=2, what='placeholders'))\n" @@ -3619,7 +3637,7 @@ msgid "" ">>>" msgstr "" -#: ../../howto/logging-cookbook.rst:2808 +#: ../../howto/logging-cookbook.rst:2818 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 " @@ -3631,11 +3649,11 @@ msgid "" "shown above." msgstr "" -#: ../../howto/logging-cookbook.rst:2822 +#: ../../howto/logging-cookbook.rst:2832 msgid "Configuring filters with :func:`dictConfig`" msgstr "" -#: ../../howto/logging-cookbook.rst:2824 +#: ../../howto/logging-cookbook.rst:2834 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). " @@ -3650,7 +3668,7 @@ msgid "" "complete example::" msgstr "" -#: ../../howto/logging-cookbook.rst:2835 +#: ../../howto/logging-cookbook.rst:2845 msgid "" "import logging\n" "import logging.config\n" @@ -3736,26 +3754,26 @@ msgstr "" " logging.debug('hello')\n" " logging.debug('hello - noshow')" -#: ../../howto/logging-cookbook.rst:2877 +#: ../../howto/logging-cookbook.rst:2887 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:2881 +#: ../../howto/logging-cookbook.rst:2891 msgid "changed: hello" msgstr "changed: hello" -#: ../../howto/logging-cookbook.rst:2885 +#: ../../howto/logging-cookbook.rst:2895 msgid "which shows that the filter is working as configured." msgstr "" -#: ../../howto/logging-cookbook.rst:2887 +#: ../../howto/logging-cookbook.rst:2897 msgid "A couple of extra points to note:" msgstr "" -#: ../../howto/logging-cookbook.rst:2889 +#: ../../howto/logging-cookbook.rst:2899 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 " @@ -3765,7 +3783,7 @@ msgid "" "the above example." msgstr "" -#: ../../howto/logging-cookbook.rst:2896 +#: ../../howto/logging-cookbook.rst:2906 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 " @@ -3774,11 +3792,11 @@ msgid "" "above." msgstr "" -#: ../../howto/logging-cookbook.rst:2905 +#: ../../howto/logging-cookbook.rst:2915 msgid "Customized exception formatting" msgstr "" -#: ../../howto/logging-cookbook.rst:2907 +#: ../../howto/logging-cookbook.rst:2917 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, " @@ -3786,7 +3804,7 @@ msgid "" "formatter class, as shown in the following example::" msgstr "" -#: ../../howto/logging-cookbook.rst:2912 +#: ../../howto/logging-cookbook.rst:2922 msgid "" "import logging\n" "\n" @@ -3825,11 +3843,11 @@ msgid "" " main()" msgstr "" -#: ../../howto/logging-cookbook.rst:2948 +#: ../../howto/logging-cookbook.rst:2958 msgid "When run, this produces a file with exactly two lines:" msgstr "" -#: ../../howto/logging-cookbook.rst:2950 +#: ../../howto/logging-cookbook.rst:2960 msgid "" "28/01/2015 07:21:23|INFO|Sample message|\n" "28/01/2015 07:21:23|ERROR|ZeroDivisionError: integer division or modulo by " @@ -3843,18 +3861,18 @@ msgstr "" "in main\\n x = 1 / 0\\nZeroDivisionError: integer division or modulo by " "zero'|" -#: ../../howto/logging-cookbook.rst:2955 +#: ../../howto/logging-cookbook.rst:2965 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:2962 +#: ../../howto/logging-cookbook.rst:2972 msgid "Speaking logging messages" msgstr "" -#: ../../howto/logging-cookbook.rst:2964 +#: ../../howto/logging-cookbook.rst:2974 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 " @@ -3871,7 +3889,7 @@ msgid "" "approach, which assumes that the ``espeak`` TTS package is available::" msgstr "" -#: ../../howto/logging-cookbook.rst:2977 +#: ../../howto/logging-cookbook.rst:2987 msgid "" "import logging\n" "import subprocess\n" @@ -3903,24 +3921,24 @@ msgid "" " sys.exit(main())" msgstr "" -#: ../../howto/logging-cookbook.rst:3006 +#: ../../howto/logging-cookbook.rst:3016 msgid "" "When run, this script should say \"Hello\" and then \"Goodbye\" in a female " "voice." msgstr "" -#: ../../howto/logging-cookbook.rst:3008 +#: ../../howto/logging-cookbook.rst:3018 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:3016 +#: ../../howto/logging-cookbook.rst:3026 msgid "Buffering logging messages and outputting them conditionally" msgstr "" -#: ../../howto/logging-cookbook.rst:3018 +#: ../../howto/logging-cookbook.rst:3028 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 " @@ -3930,7 +3948,7 @@ msgid "" "debug information to be output as well as the error." msgstr "" -#: ../../howto/logging-cookbook.rst:3025 +#: ../../howto/logging-cookbook.rst:3035 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 " @@ -3943,7 +3961,7 @@ msgid "" "subclass of ``MemoryHandler`` if you want custom flushing behavior." msgstr "" -#: ../../howto/logging-cookbook.rst:3035 +#: ../../howto/logging-cookbook.rst:3045 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 " @@ -3952,7 +3970,7 @@ msgid "" "levels - otherwise, it only logs at DEBUG, INFO and WARNING levels." msgstr "" -#: ../../howto/logging-cookbook.rst:3041 +#: ../../howto/logging-cookbook.rst:3051 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 " @@ -3964,11 +3982,11 @@ msgid "" "respectively." msgstr "" -#: ../../howto/logging-cookbook.rst:3049 +#: ../../howto/logging-cookbook.rst:3059 msgid "Here's the script::" msgstr "" -#: ../../howto/logging-cookbook.rst:3051 +#: ../../howto/logging-cookbook.rst:3061 msgid "" "import logging\n" "from logging.handlers import MemoryHandler\n" @@ -4034,11 +4052,11 @@ msgid "" " assert decorated_foo(True)" msgstr "" -#: ../../howto/logging-cookbook.rst:3112 +#: ../../howto/logging-cookbook.rst:3122 msgid "When this script is run, the following output should be observed:" msgstr "" -#: ../../howto/logging-cookbook.rst:3114 +#: ../../howto/logging-cookbook.rst:3124 msgid "" "Calling undecorated foo with False\n" "about to log at DEBUG ...\n" @@ -4067,29 +4085,29 @@ msgid "" "Actually logged at CRITICAL" msgstr "" -#: ../../howto/logging-cookbook.rst:3142 +#: ../../howto/logging-cookbook.rst:3152 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:3146 +#: ../../howto/logging-cookbook.rst:3156 msgid "You can of course use the conventional means of decoration::" msgstr "" -#: ../../howto/logging-cookbook.rst:3148 +#: ../../howto/logging-cookbook.rst:3158 msgid "" "@log_if_errors(logger)\n" "def foo(fail=False):\n" " ..." msgstr "" -#: ../../howto/logging-cookbook.rst:3156 +#: ../../howto/logging-cookbook.rst:3166 msgid "Sending logging messages to email, with buffering" msgstr "" -#: ../../howto/logging-cookbook.rst:3158 +#: ../../howto/logging-cookbook.rst:3168 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." @@ -4100,7 +4118,7 @@ msgid "" "argument to see the required and optional arguments.)" msgstr "" -#: ../../howto/logging-cookbook.rst:3166 +#: ../../howto/logging-cookbook.rst:3176 msgid "" "import logging\n" "import logging.handlers\n" @@ -4168,7 +4186,7 @@ msgid "" " h.close()" msgstr "" -#: ../../howto/logging-cookbook.rst:3230 +#: ../../howto/logging-cookbook.rst:3240 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 " @@ -4176,17 +4194,17 @@ msgid "" "messages. That makes up 102 messages as specified in the script." msgstr "" -#: ../../howto/logging-cookbook.rst:3238 +#: ../../howto/logging-cookbook.rst:3248 msgid "Formatting times using UTC (GMT) via configuration" msgstr "" -#: ../../howto/logging-cookbook.rst:3240 +#: ../../howto/logging-cookbook.rst:3250 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:3243 +#: ../../howto/logging-cookbook.rst:3253 msgid "" "import logging\n" "import time\n" @@ -4195,7 +4213,7 @@ msgid "" " converter = time.gmtime" msgstr "" -#: ../../howto/logging-cookbook.rst:3249 +#: ../../howto/logging-cookbook.rst:3259 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 " @@ -4203,7 +4221,7 @@ msgid "" "the following complete example::" msgstr "" -#: ../../howto/logging-cookbook.rst:3254 +#: ../../howto/logging-cookbook.rst:3264 msgid "" "import logging\n" "import logging.config\n" @@ -4244,27 +4262,27 @@ msgid "" " logging.warning('The local time is %s', time.asctime())" msgstr "" -#: ../../howto/logging-cookbook.rst:3292 +#: ../../howto/logging-cookbook.rst:3302 msgid "When this script is run, it should print something like:" msgstr "" -#: ../../howto/logging-cookbook.rst:3294 +#: ../../howto/logging-cookbook.rst:3304 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" msgstr "" -#: ../../howto/logging-cookbook.rst:3299 +#: ../../howto/logging-cookbook.rst:3309 msgid "" "showing how the time is formatted both as local time and UTC, one for each " "handler." msgstr "" -#: ../../howto/logging-cookbook.rst:3306 +#: ../../howto/logging-cookbook.rst:3316 msgid "Using a context manager for selective logging" msgstr "" -#: ../../howto/logging-cookbook.rst:3308 +#: ../../howto/logging-cookbook.rst:3318 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 " @@ -4274,7 +4292,7 @@ msgid "" "scope of the context manager::" msgstr "" -#: ../../howto/logging-cookbook.rst:3315 +#: ../../howto/logging-cookbook.rst:3325 msgid "" "import logging\n" "import sys\n" @@ -4303,7 +4321,7 @@ msgid "" " # implicit return of None => don't swallow exceptions" msgstr "" -#: ../../howto/logging-cookbook.rst:3341 +#: ../../howto/logging-cookbook.rst:3351 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 " @@ -4312,13 +4330,13 @@ msgid "" "block exit - you could do this if you don't need the handler any more." msgstr "" -#: ../../howto/logging-cookbook.rst:3347 +#: ../../howto/logging-cookbook.rst:3357 msgid "" "To illustrate how it works, we can add the following block of code to the " "above::" msgstr "" -#: ../../howto/logging-cookbook.rst:3350 +#: ../../howto/logging-cookbook.rst:3360 msgid "" "if __name__ == '__main__':\n" " logger = logging.getLogger('foo')\n" @@ -4338,7 +4356,7 @@ msgid "" " logger.debug('7. This should not appear.')" msgstr "" -#: ../../howto/logging-cookbook.rst:3365 +#: ../../howto/logging-cookbook.rst:3375 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 " @@ -4351,11 +4369,11 @@ msgid "" "(like message #1) whereas message #7 doesn't (just like message #2)." msgstr "" -#: ../../howto/logging-cookbook.rst:3375 +#: ../../howto/logging-cookbook.rst:3385 msgid "If we run the resulting script, the result is as follows:" msgstr "" -#: ../../howto/logging-cookbook.rst:3377 +#: ../../howto/logging-cookbook.rst:3387 msgid "" "$ python logctx.py\n" "1. This should appear just once on stderr.\n" @@ -4365,23 +4383,23 @@ msgid "" "6. This should appear just once on stderr." msgstr "" -#: ../../howto/logging-cookbook.rst:3386 +#: ../../howto/logging-cookbook.rst:3396 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:3389 +#: ../../howto/logging-cookbook.rst:3399 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:3394 +#: ../../howto/logging-cookbook.rst:3404 msgid "Once again, but piping ``stdout`` to ``/dev/null``, we get:" msgstr "" -#: ../../howto/logging-cookbook.rst:3396 +#: ../../howto/logging-cookbook.rst:3406 msgid "" "$ python logctx.py >/dev/null\n" "1. This should appear just once on stderr.\n" @@ -4390,42 +4408,42 @@ msgid "" "6. This should appear just once on stderr." msgstr "" -#: ../../howto/logging-cookbook.rst:3404 +#: ../../howto/logging-cookbook.rst:3414 msgid "" "In this case, the message #5 printed to ``stdout`` doesn't appear, as " "expected." msgstr "" -#: ../../howto/logging-cookbook.rst:3406 +#: ../../howto/logging-cookbook.rst:3416 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:3414 +#: ../../howto/logging-cookbook.rst:3424 msgid "A CLI application starter template" msgstr "" -#: ../../howto/logging-cookbook.rst:3416 +#: ../../howto/logging-cookbook.rst:3426 msgid "Here's an example which shows how you can:" msgstr "" -#: ../../howto/logging-cookbook.rst:3418 +#: ../../howto/logging-cookbook.rst:3428 msgid "Use a logging level based on command-line arguments" msgstr "" -#: ../../howto/logging-cookbook.rst:3419 +#: ../../howto/logging-cookbook.rst:3429 msgid "" "Dispatch to multiple subcommands in separate files, all logging at the same " "level in a consistent way" msgstr "" -#: ../../howto/logging-cookbook.rst:3421 +#: ../../howto/logging-cookbook.rst:3431 msgid "Make use of simple, minimal configuration" msgstr "" -#: ../../howto/logging-cookbook.rst:3423 +#: ../../howto/logging-cookbook.rst:3433 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 " @@ -4436,7 +4454,7 @@ msgid "" "``logging.INFO``. Here's one way that ``app.py`` could be written::" msgstr "" -#: ../../howto/logging-cookbook.rst:3431 +#: ../../howto/logging-cookbook.rst:3441 msgid "" "import argparse\n" "import importlib\n" @@ -4483,13 +4501,13 @@ msgid "" " sys.exit(main())" msgstr "" -#: ../../howto/logging-cookbook.rst:3472 +#: ../../howto/logging-cookbook.rst:3482 msgid "" "And the ``start``, ``stop`` and ``restart`` commands can be implemented in " "separate modules, like so for starting::" msgstr "" -#: ../../howto/logging-cookbook.rst:3475 +#: ../../howto/logging-cookbook.rst:3485 msgid "" "# start.py\n" "import logging\n" @@ -4502,11 +4520,11 @@ msgid "" " logger.info('Started the \\'%s\\' service.', options.name)" msgstr "" -#: ../../howto/logging-cookbook.rst:3485 +#: ../../howto/logging-cookbook.rst:3495 msgid "and thus for stopping::" msgstr "" -#: ../../howto/logging-cookbook.rst:3487 +#: ../../howto/logging-cookbook.rst:3497 msgid "" "# stop.py\n" "import logging\n" @@ -4528,11 +4546,11 @@ msgid "" " logger.info('Stopped the %s service%s.', services, plural)" msgstr "" -#: ../../howto/logging-cookbook.rst:3506 +#: ../../howto/logging-cookbook.rst:3516 msgid "and similarly for restarting::" msgstr "" -#: ../../howto/logging-cookbook.rst:3508 +#: ../../howto/logging-cookbook.rst:3518 msgid "" "# restart.py\n" "import logging\n" @@ -4554,13 +4572,13 @@ msgid "" " logger.info('Restarted the %s service%s.', services, plural)" msgstr "" -#: ../../howto/logging-cookbook.rst:3527 +#: ../../howto/logging-cookbook.rst:3537 msgid "" "If we run this application with the default log level, we get output like " "this:" msgstr "" -#: ../../howto/logging-cookbook.rst:3529 +#: ../../howto/logging-cookbook.rst:3539 msgid "" "$ python app.py start foo\n" "INFO start Started the 'foo' service.\n" @@ -4572,19 +4590,19 @@ msgid "" "INFO restart Restarted the 'foo', 'bar' and 'baz' services." msgstr "" -#: ../../howto/logging-cookbook.rst:3540 +#: ../../howto/logging-cookbook.rst:3550 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:3543 +#: ../../howto/logging-cookbook.rst:3553 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:3546 +#: ../../howto/logging-cookbook.rst:3556 msgid "" "$ python app.py --log-level DEBUG start foo\n" "DEBUG start About to start foo\n" @@ -4599,28 +4617,28 @@ msgid "" "INFO restart Restarted the 'foo', 'bar' and 'baz' services." msgstr "" -#: ../../howto/logging-cookbook.rst:3560 +#: ../../howto/logging-cookbook.rst:3570 msgid "And if we want less:" msgstr "" -#: ../../howto/logging-cookbook.rst:3562 +#: ../../howto/logging-cookbook.rst:3572 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 "" -#: ../../howto/logging-cookbook.rst:3568 +#: ../../howto/logging-cookbook.rst:3578 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:3574 +#: ../../howto/logging-cookbook.rst:3584 msgid "A Qt GUI for logging" msgstr "" -#: ../../howto/logging-cookbook.rst:3576 +#: ../../howto/logging-cookbook.rst:3586 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-" @@ -4628,7 +4646,7 @@ msgid "" "`PyQt5` libraries." msgstr "" -#: ../../howto/logging-cookbook.rst:3581 +#: ../../howto/logging-cookbook.rst:3591 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 " @@ -4638,14 +4656,14 @@ msgid "" "logging messages at random levels with random short delays in between)." msgstr "" -#: ../../howto/logging-cookbook.rst:3588 +#: ../../howto/logging-cookbook.rst:3598 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:3592 +#: ../../howto/logging-cookbook.rst:3602 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 " @@ -4653,7 +4671,7 @@ msgid "" "more detailed information." msgstr "" -#: ../../howto/logging-cookbook.rst:3597 +#: ../../howto/logging-cookbook.rst:3607 msgid "" "import datetime\n" "import logging\n" @@ -4904,11 +4922,11 @@ msgid "" " main()" msgstr "" -#: ../../howto/logging-cookbook.rst:3829 +#: ../../howto/logging-cookbook.rst:3839 msgid "Logging to syslog with RFC5424 support" msgstr "" -#: ../../howto/logging-cookbook.rst:3831 +#: ../../howto/logging-cookbook.rst:3841 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 " @@ -4918,14 +4936,14 @@ msgid "" "handlers.SysLogHandler` functionality has not been updated." msgstr "" -#: ../../howto/logging-cookbook.rst:3838 +#: ../../howto/logging-cookbook.rst:3848 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:3842 +#: ../../howto/logging-cookbook.rst:3852 msgid "" "import datetime\n" "import logging.handlers\n" @@ -4995,7 +5013,7 @@ msgid "" "{sdata} {msg}'" msgstr "" -#: ../../howto/logging-cookbook.rst:3904 +#: ../../howto/logging-cookbook.rst:3914 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 " @@ -5004,7 +5022,7 @@ msgid "" "using something like this::" msgstr "" -#: ../../howto/logging-cookbook.rst:3909 +#: ../../howto/logging-cookbook.rst:3919 msgid "" "sd = {\n" " 'foo@12345': {'bar': 'baz', 'baz': 'bozz', 'fizz': r'buzz'},\n" @@ -5015,11 +5033,11 @@ msgid "" "logger.debug('Message %d', i, extra=extra)" msgstr "" -#: ../../howto/logging-cookbook.rst:3918 +#: ../../howto/logging-cookbook.rst:3928 msgid "How to treat a logger like an output stream" msgstr "" -#: ../../howto/logging-cookbook.rst:3920 +#: ../../howto/logging-cookbook.rst:3930 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 " @@ -5027,7 +5045,7 @@ msgid "" "API. Here's a short script illustrating such a class:" msgstr "" -#: ../../howto/logging-cookbook.rst:3925 +#: ../../howto/logging-cookbook.rst:3935 msgid "" "import logging\n" "\n" @@ -5065,23 +5083,23 @@ msgid "" " main()" msgstr "" -#: ../../howto/logging-cookbook.rst:3960 +#: ../../howto/logging-cookbook.rst:3970 msgid "When this script is run, it prints" msgstr "" -#: ../../howto/logging-cookbook.rst:3962 +#: ../../howto/logging-cookbook.rst:3972 msgid "" "INFO:demo:An INFO message\n" "DEBUG:demo:A DEBUG message" msgstr "" -#: ../../howto/logging-cookbook.rst:3967 +#: ../../howto/logging-cookbook.rst:3977 msgid "" "You could also use ``LoggerWriter`` to redirect ``sys.stdout`` and ``sys." "stderr`` by doing something like this:" msgstr "" -#: ../../howto/logging-cookbook.rst:3970 +#: ../../howto/logging-cookbook.rst:3980 msgid "" "import sys\n" "\n" @@ -5089,7 +5107,7 @@ msgid "" "sys.stderr = LoggerWriter(logger, logging.WARNING)" msgstr "" -#: ../../howto/logging-cookbook.rst:3977 +#: ../../howto/logging-cookbook.rst:3987 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." @@ -5097,7 +5115,7 @@ msgid "" "Then, you'd get this kind of result:" msgstr "" -#: ../../howto/logging-cookbook.rst:3982 +#: ../../howto/logging-cookbook.rst:3992 msgid "" ">>> print('Foo')\n" "INFO:demo:Foo\n" @@ -5106,31 +5124,31 @@ msgid "" ">>>" msgstr "" -#: ../../howto/logging-cookbook.rst:3990 +#: ../../howto/logging-cookbook.rst:4000 msgid "" "Of course, the examples above show output according to the format used by :" "func:`~logging.basicConfig`, but you can use a different formatter when you " "configure logging." msgstr "" -#: ../../howto/logging-cookbook.rst:3994 +#: ../../howto/logging-cookbook.rst:4004 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:3998 +#: ../../howto/logging-cookbook.rst:4008 msgid "" "sys.stderr = LoggerWriter(logger, logging.WARNING)\n" "1 / 0" msgstr "" -#: ../../howto/logging-cookbook.rst:4003 +#: ../../howto/logging-cookbook.rst:4013 msgid "then running the script results in" msgstr "" -#: ../../howto/logging-cookbook.rst:4005 +#: ../../howto/logging-cookbook.rst:4015 msgid "" "WARNING:demo:Traceback (most recent call last):\n" "\n" @@ -5149,7 +5167,7 @@ msgid "" "WARNING:demo:division by zero" msgstr "" -#: ../../howto/logging-cookbook.rst:4021 +#: ../../howto/logging-cookbook.rst:4031 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 " @@ -5159,7 +5177,7 @@ msgid "" "``LoggerWriter``:" msgstr "" -#: ../../howto/logging-cookbook.rst:4027 +#: ../../howto/logging-cookbook.rst:4037 msgid "" "class BufferingLoggerWriter(LoggerWriter):\n" " def __init__(self, logger, level):\n" @@ -5179,13 +5197,13 @@ msgid "" " self.logger.log(self.level, part)" msgstr "" -#: ../../howto/logging-cookbook.rst:4046 +#: ../../howto/logging-cookbook.rst:4056 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:4049 +#: ../../howto/logging-cookbook.rst:4059 msgid "" "WARNING:demo:Traceback (most recent call last):\n" "WARNING:demo: File \"/home/runner/cookbook-loggerwriter/main.py\", line 55, " @@ -5197,11 +5215,11 @@ msgid "" "WARNING:demo:ZeroDivisionError: division by zero" msgstr "" -#: ../../howto/logging-cookbook.rst:4062 +#: ../../howto/logging-cookbook.rst:4072 msgid "Patterns to avoid" msgstr "" -#: ../../howto/logging-cookbook.rst:4064 +#: ../../howto/logging-cookbook.rst:4074 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 " @@ -5209,11 +5227,11 @@ msgid "" "The following sections are in no particular order." msgstr "" -#: ../../howto/logging-cookbook.rst:4070 +#: ../../howto/logging-cookbook.rst:4080 msgid "Opening the same log file multiple times" msgstr "" -#: ../../howto/logging-cookbook.rst:4072 +#: ../../howto/logging-cookbook.rst:4082 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. " @@ -5221,32 +5239,32 @@ msgid "" "file multiple times. This could be done accidentally, for example by:" msgstr "" -#: ../../howto/logging-cookbook.rst:4077 +#: ../../howto/logging-cookbook.rst:4087 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:4080 +#: ../../howto/logging-cookbook.rst:4090 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:4083 +#: ../../howto/logging-cookbook.rst:4093 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:4087 +#: ../../howto/logging-cookbook.rst:4097 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:4090 +#: ../../howto/logging-cookbook.rst:4100 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 " @@ -5255,7 +5273,7 @@ msgid "" "different handler instances which happen to point to the same file." msgstr "" -#: ../../howto/logging-cookbook.rst:4096 +#: ../../howto/logging-cookbook.rst:4106 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 " @@ -5265,17 +5283,17 @@ msgid "" "being supposedly in place." msgstr "" -#: ../../howto/logging-cookbook.rst:4103 +#: ../../howto/logging-cookbook.rst:4113 msgid "" "Use the techniques outlined in :ref:`multiple-processes` to circumvent such " "issues." msgstr "" -#: ../../howto/logging-cookbook.rst:4107 +#: ../../howto/logging-cookbook.rst:4117 msgid "Using loggers as attributes in a class or passing them as parameters" msgstr "" -#: ../../howto/logging-cookbook.rst:4109 +#: ../../howto/logging-cookbook.rst:4119 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 " @@ -5286,13 +5304,13 @@ msgid "" "module (and not the class) is the unit of software decomposition." msgstr "" -#: ../../howto/logging-cookbook.rst:4118 +#: ../../howto/logging-cookbook.rst:4128 msgid "" "Adding handlers other than :class:`~logging.NullHandler` to a logger in a " "library" msgstr "" -#: ../../howto/logging-cookbook.rst:4120 +#: ../../howto/logging-cookbook.rst:4130 msgid "" "Configuring logging by adding handlers, formatters and filters is the " "responsibility of the application developer, not the library developer. If " @@ -5300,11 +5318,11 @@ msgid "" "your loggers other than a :class:`~logging.NullHandler` instance." msgstr "" -#: ../../howto/logging-cookbook.rst:4126 +#: ../../howto/logging-cookbook.rst:4136 msgid "Creating a lot of loggers" msgstr "" -#: ../../howto/logging-cookbook.rst:4128 +#: ../../howto/logging-cookbook.rst:4138 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. " @@ -5315,38 +5333,38 @@ msgid "" "occasionally slightly more fine-grained than that)." msgstr "" -#: ../../howto/logging-cookbook.rst:4139 +#: ../../howto/logging-cookbook.rst:4149 msgid "Other resources" msgstr "" -#: ../../howto/logging-cookbook.rst:4143 +#: ../../howto/logging-cookbook.rst:4153 msgid "Module :mod:`logging`" msgstr ":mod:`logging` 模組" -#: ../../howto/logging-cookbook.rst:4144 +#: ../../howto/logging-cookbook.rst:4154 msgid "API reference for the logging module." msgstr "" -#: ../../howto/logging-cookbook.rst:4146 +#: ../../howto/logging-cookbook.rst:4156 msgid "Module :mod:`logging.config`" msgstr ":mod:`logging.config` 模組" -#: ../../howto/logging-cookbook.rst:4147 +#: ../../howto/logging-cookbook.rst:4157 msgid "Configuration API for the logging module." msgstr "" -#: ../../howto/logging-cookbook.rst:4149 +#: ../../howto/logging-cookbook.rst:4159 msgid "Module :mod:`logging.handlers`" msgstr ":mod:`logging.handlers` 模組" -#: ../../howto/logging-cookbook.rst:4150 +#: ../../howto/logging-cookbook.rst:4160 msgid "Useful handlers included with the logging module." msgstr "" -#: ../../howto/logging-cookbook.rst:4152 +#: ../../howto/logging-cookbook.rst:4162 msgid ":ref:`Basic Tutorial `" msgstr ":ref:`基礎教學 `" -#: ../../howto/logging-cookbook.rst:4154 +#: ../../howto/logging-cookbook.rst:4164 msgid ":ref:`Advanced Tutorial `" msgstr ":ref:`進階教學 `" diff --git a/howto/mro.po b/howto/mro.po index 816adb559d..9ef8ae5e1b 100644 --- a/howto/mro.po +++ b/howto/mro.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-02-07 08:41+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -527,7 +527,7 @@ msgstr "" msgid "" "A lazy programmer can obtain the MRO directly from Python 2.2, since in this " "case it coincides with the Python 2.3 linearization. It is enough to invoke " -"the .mro() method of class A:" +"the :meth:`~type.mro` method of class A:" msgstr "" #: ../../howto/mro.rst:345 @@ -614,7 +614,7 @@ msgstr "" 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." -"rembermer2buy* and not by *E.remember2buy*: nevertheless Python 2.2 gives" +"remember2buy* and not by *E.remember2buy*: nevertheless Python 2.2 gives" msgstr "" #: ../../howto/mro.rst:407 diff --git a/howto/perf_profiling.po b/howto/perf_profiling.po index d89ee4250b..198d027964 100644 --- a/howto/perf_profiling.po +++ b/howto/perf_profiling.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-04-24 05:56+0000\n" "PO-Revision-Date: 2023-12-09 17:39+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -402,8 +402,10 @@ msgid "Example, using the environment variable::" msgstr "例如,使用環境變數: ::" #: ../../howto/perf_profiling.rst:165 +#, fuzzy msgid "" -"$ PYTHONPERFSUPPORT=1 perf record -F 9999 -g -o perf.data python script.py\n" +"$ PYTHONPERFSUPPORT=1 perf record -F 9999 -g -o perf.data python my_script." +"py\n" "$ perf report -g -i perf.data" msgstr "" "$ PYTHONPERFSUPPORT=1 perf record -F 9999 -g -o perf.data python script.py\n" @@ -414,8 +416,9 @@ msgid "Example, using the :option:`!-X` option::" msgstr "例如,使用 :option:`!-X` 選項: ::" #: ../../howto/perf_profiling.rst:170 +#, fuzzy msgid "" -"$ perf record -F 9999 -g -o perf.data python -X perf script.py\n" +"$ perf record -F 9999 -g -o perf.data python -X perf my_script.py\n" "$ perf report -g -i perf.data" msgstr "" "$ perf record -F 9999 -g -o perf.data python -X perf script.py\n" @@ -535,9 +538,10 @@ msgid "" msgstr "" #: ../../howto/perf_profiling.rst:239 +#, fuzzy msgid "" -"$ perf record -F 9999 -g --call-graph dwarf -o perf.data python -Xperf_jit " -"my_script.py\n" +"$ perf record -F 9999 -g -k 1 --call-graph dwarf -o perf.data python -" +"Xperf_jit my_script.py\n" "$ perf inject -i perf.data --jit --output perf.jit.data\n" "$ perf report -g -i perf.jit.data" msgstr "" @@ -574,13 +578,55 @@ msgstr "" #: ../../howto/perf_profiling.rst:257 msgid "" -"Notice that when using ``--call-graph dwarf`` the ``perf`` tool will take " -"snapshots of the stack of the process being profiled and save the " -"information in the ``perf.data`` file. By default the size of the stack dump " -"is 8192 bytes but the user can change the size by passing the size after " -"comma like ``--call-graph dwarf,4096``. The size of the stack dump is " -"important because if the size is too small ``perf`` will not be able to " -"unwind the stack and the output will be incomplete. On the other hand, if " -"the size is too big, then ``perf`` won't be able to sample the process as " -"frequently as it would like as the overhead will be higher." +"When using ``--call-graph dwarf``, the ``perf`` tool will take snapshots of " +"the stack of the process being profiled and save the information in the " +"``perf.data`` file. By default, the size of the stack dump is 8192 bytes, " +"but you can change the size by passing it after a comma like ``--call-graph " +"dwarf,16384``." +msgstr "" + +#: ../../howto/perf_profiling.rst:263 +msgid "" +"The size of the stack dump is important because if the size is too small " +"``perf`` will not be able to unwind the stack and the output will be " +"incomplete. On the other hand, if the size is too big, then ``perf`` won't " +"be able to sample the process as frequently as it would like as the overhead " +"will be higher." +msgstr "" + +#: ../../howto/perf_profiling.rst:269 +msgid "" +"The stack size is particularly important when profiling Python code compiled " +"with low optimization levels (like ``-O0``), as these builds tend to have " +"larger stack frames. If you are compiling Python with ``-O0`` and not seeing " +"Python functions in your profiling output, try increasing the stack dump " +"size to 65528 bytes (the maximum)::" +msgstr "" + +#: ../../howto/perf_profiling.rst:275 +#, fuzzy +msgid "" +"$ perf record -F 9999 -g -k 1 --call-graph dwarf,65528 -o perf.data python -" +"Xperf_jit my_script.py" +msgstr "$ perf record -F 9999 -g -o perf.data python my_script.py" + +#: ../../howto/perf_profiling.rst:277 +msgid "Different compilation flags can significantly impact stack sizes:" +msgstr "" + +#: ../../howto/perf_profiling.rst:279 +msgid "" +"Builds with ``-O0`` typically have much larger stack frames than those with " +"``-O1`` or higher" +msgstr "" + +#: ../../howto/perf_profiling.rst:280 +msgid "" +"Adding optimizations (``-O1``, ``-O2``, etc.) typically reduces stack size" +msgstr "" + +#: ../../howto/perf_profiling.rst:281 +msgid "" +"Frame pointers (``-fno-omit-frame-pointer``) generally provide more reliable " +"stack unwinding" msgstr "" diff --git a/howto/regex.po b/howto/regex.po index 825d7f2aff..44073c8f31 100644 --- a/howto/regex.po +++ b/howto/regex.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-03-03 18:39+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-" @@ -918,9 +918,10 @@ msgid "" msgstr "" #: ../../howto/regex.rst:483 +#, fuzzy msgid "" ">>> iterator = p.finditer('12 drummers drumming, 11 ... 10 ...')\n" -">>> iterator \n" +">>> iterator\n" "\n" ">>> for match in iterator:\n" "... print(match.span())\n" @@ -954,10 +955,11 @@ msgid "" msgstr "" #: ../../howto/regex.rst:504 +#, fuzzy msgid "" ">>> print(re.match(r'From\\s+', 'Fromage amk'))\n" "None\n" -">>> re.match(r'From\\s+', 'From amk Thu May 14 19:12:10 1998') \n" +">>> re.match(r'From\\s+', 'From amk Thu May 14 19:12:10 1998')\n" "" msgstr "" ">>> print(re.match(r'From\\s+', 'Fromage amk'))\n" @@ -1069,13 +1071,13 @@ msgid "" "letters, too. Full Unicode matching also works unless the :const:`ASCII` " "flag is used to disable non-ASCII matches. When the Unicode patterns ``[a-" "z]`` or ``[A-Z]`` are used in combination with the :const:`IGNORECASE` flag, " -"they will match the 52 ASCII letters and 4 additional non-ASCII letters: 'İ' " -"(U+0130, Latin capital letter I with dot above), 'ı' (U+0131, Latin small " -"letter dotless i), 'ſ' (U+017F, Latin small letter long s) and 'K' (U+212A, " -"Kelvin sign). ``Spam`` will match ``'Spam'``, ``'spam'``, ``'spAM'``, or " -"``'ſpam'`` (the latter is matched only in Unicode mode). This lowercasing " -"doesn't take the current locale into account; it will if you also set the :" -"const:`LOCALE` flag." +"they will match the 52 ASCII letters and 4 additional non-ASCII letters: " +"'İ' (U+0130, Latin capital letter I with dot above), 'ı' (U+0131, Latin " +"small letter dotless i), 'ſ' (U+017F, Latin small letter long s) and " +"'K' (U+212A, Kelvin sign). ``Spam`` will match ``'Spam'``, ``'spam'``, " +"``'spAM'``, or ``'ſpam'`` (the latter is matched only in Unicode mode). This " +"lowercasing doesn't take the current locale into account; it will if you " +"also set the :const:`LOCALE` flag." msgstr "" #: ../../howto/regex.rst:581 @@ -1257,8 +1259,9 @@ msgid "" msgstr "" #: ../../howto/regex.rst:714 +#, fuzzy msgid "" -">>> print(re.search('^From', 'From Here to Eternity')) \n" +">>> print(re.search('^From', 'From Here to Eternity'))\n" "\n" ">>> print(re.search('^From', 'Reciting From Memory'))\n" "None" @@ -1283,12 +1286,13 @@ msgid "" msgstr "" #: ../../howto/regex.rst:725 +#, fuzzy msgid "" -">>> print(re.search('}$', '{block}')) \n" +">>> print(re.search('}$', '{block}'))\n" "\n" ">>> print(re.search('}$', '{block} '))\n" "None\n" -">>> print(re.search('}$', '{block}\\n')) \n" +">>> print(re.search('}$', '{block}\\n'))\n" "" msgstr "" ">>> print(re.search('}$', '{block}')) \n" diff --git a/howto/unicode.po b/howto/unicode.po index b7b29e8cd1..3fc75e0a1f 100644 --- a/howto/unicode.po +++ b/howto/unicode.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-03-03 18:39+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-" @@ -405,8 +405,9 @@ msgid "" msgstr "" #: ../../howto/unicode.rst:236 +#, fuzzy msgid "" -">>> b'\\x80abc'.decode(\"utf-8\", \"strict\") \n" +">>> b'\\x80abc'.decode(\"utf-8\", \"strict\")\n" "Traceback (most recent call last):\n" " ...\n" "UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0:\n" @@ -487,11 +488,12 @@ msgid "The following example shows the different results::" msgstr "" #: ../../howto/unicode.rst:282 +#, fuzzy msgid "" ">>> u = chr(40960) + 'abcd' + chr(1972)\n" ">>> u.encode('utf-8')\n" "b'\\xea\\x80\\x80abcd\\xde\\xb4'\n" -">>> u.encode('ascii') \n" +">>> u.encode('ascii')\n" "Traceback (most recent call last):\n" " ...\n" "UnicodeEncodeError: 'ascii' codec can't encode character '\\ua000' in\n" diff --git a/howto/urllib2.po b/howto/urllib2.po index 4e79e88dd9..9b78d824df 100644 --- a/howto/urllib2.po +++ b/howto/urllib2.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-03-03 18:39+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-" @@ -266,6 +266,7 @@ msgid "This is done as follows::" msgstr "" #: ../../howto/urllib2.rst:141 +#, fuzzy msgid "" ">>> import urllib.request\n" ">>> import urllib.parse\n" @@ -274,7 +275,7 @@ msgid "" ">>> data['location'] = 'Northampton'\n" ">>> data['language'] = 'Python'\n" ">>> url_values = urllib.parse.urlencode(data)\n" -">>> print(url_values) # The order may differ from below. \n" +">>> print(url_values) # The order may differ from below.\n" "name=Somebody+Here&language=Python&location=Northampton\n" ">>> url = 'http://www.example.com/example.cgi'\n" ">>> full_url = url + '?' + url_values\n" @@ -401,11 +402,12 @@ msgid "e.g. ::" msgstr "例如: ::" #: ../../howto/urllib2.rst:216 +#, fuzzy msgid "" ">>> req = urllib.request.Request('http://www.pretend_server.org')\n" ">>> try: urllib.request.urlopen(req)\n" "... except urllib.error.URLError as e:\n" -"... print(e.reason) \n" +"... print(e.reason)\n" "...\n" "(4, 'getaddrinfo failed')" msgstr "" @@ -542,13 +544,14 @@ msgid "" msgstr "" #: ../../howto/urllib2.rst:324 +#, fuzzy msgid "" ">>> req = urllib.request.Request('http://www.python.org/fish.html')\n" ">>> try:\n" "... urllib.request.urlopen(req)\n" "... except urllib.error.HTTPError as e:\n" "... print(e.code)\n" -"... print(e.read()) \n" +"... print(e.read())\n" "...\n" "404\n" "b'\n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -172,14 +172,9 @@ msgstr "" "的值可用於在整個系統中唯一標識此特定執行緒(直到執行緒終止後,該值可能被操作" "系統重新使用)。" -#: ../../library/_thread.rst:123 -#, fuzzy -msgid "" -":ref:`Availability `: Windows, FreeBSD, Linux, macOS, OpenBSD, " -"NetBSD, AIX, DragonFlyBSD, GNU/kFreeBSD." +#: ../../library/_thread.rst:123 ../../library/_thread.rst:148 +msgid "Availability" msgstr "" -":ref:`適用 `:Windows、FreeBSD、Linux、macOS、OpenBSD、NetBSD、" -"AIX、DragonFlyBSD。" #: ../../library/_thread.rst:127 msgid "Added support for GNU/kFreeBSD." @@ -213,10 +208,6 @@ msgstr "" "分配。應參考平台文檔以獲取更多訊息(4 KiB 頁面是比較普遍的;在缺乏更具體訊息" "的情況下,建議使用 4096 的倍數作為堆疊大小)。" -#: ../../library/_thread.rst:148 -msgid ":ref:`Availability `: Windows, pthreads." -msgstr ":ref:`適用 `:Windows, pthreads。" - #: ../../library/_thread.rst:150 msgid "Unix platforms with POSIX threads support." msgstr "Unix 平台上支援 POSIX 執行緒。" @@ -314,15 +305,11 @@ msgstr "**注意事項:**" #: ../../library/_thread.rst:216 msgid "" -"Threads interact strangely with interrupts: the :exc:`KeyboardInterrupt` " -"exception will be received by an arbitrary thread. (When the :mod:`signal` " -"module is available, interrupts always go to the main thread.)" +"Interrupts always go to the main thread (the :exc:`KeyboardInterrupt` " +"exception will be received by that thread.)" msgstr "" -"執行緒與中斷的互動可能會有奇怪的情況:任何一個執行緒都有可能收到 :exc:" -"`KeyboardInterrupt` 例外。(當 :mod:`signal` 模組可用時,中斷總是會進入主執行" -"緒。)" -#: ../../library/_thread.rst:220 +#: ../../library/_thread.rst:219 msgid "" "Calling :func:`sys.exit` or raising the :exc:`SystemExit` exception is " "equivalent to calling :func:`_thread.exit`." @@ -330,16 +317,19 @@ msgstr "" "呼叫 :func:`sys.exit` 函數或引發 :exc:`SystemExit` 例外等同於呼叫 :func:" "`_thread.exit` 函式。" -#: ../../library/_thread.rst:223 +#: ../../library/_thread.rst:222 +#, fuzzy msgid "" -"It is not possible to interrupt the :meth:`~threading.Lock.acquire` method " -"on a lock --- the :exc:`KeyboardInterrupt` exception will happen after the " -"lock has been acquired." +"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` 例外會在鎖被獲取後發生。" -#: ../../library/_thread.rst:227 +#: ../../library/_thread.rst:228 msgid "" "When the main thread exits, it is system defined whether the other threads " "survive. On most systems, they are killed without executing :keyword:" @@ -349,15 +339,6 @@ msgstr "" "終止,而不會執行 :keyword:`try` ... :keyword:`finally` 子句或執行物件的解構函" "式。" -#: ../../library/_thread.rst:232 -msgid "" -"When the main thread exits, it does not do any of its usual cleanup (except " -"that :keyword:`try` ... :keyword:`finally` clauses are honored), and the " -"standard I/O files are not flushed." -msgstr "" -"當主執行緒退出時,它不會執行任何通常的清理操作(除非有 :keyword:`try` ... :" -"keyword:`finally` 子句),並且標準 I/O 檔案不會被刷新。" - #: ../../library/_thread.rst:7 msgid "light-weight processes" msgstr "light-weight processes(輕量級行程)" @@ -393,3 +374,31 @@ msgstr "module(模組)" #: ../../library/_thread.rst:214 msgid "signal" msgstr "signal(訊號)" + +#, fuzzy +#~ msgid "" +#~ ":ref:`Availability `: Windows, FreeBSD, Linux, macOS, " +#~ "OpenBSD, NetBSD, AIX, DragonFlyBSD, GNU/kFreeBSD." +#~ msgstr "" +#~ ":ref:`適用 `:Windows、FreeBSD、Linux、macOS、OpenBSD、" +#~ "NetBSD、AIX、DragonFlyBSD。" + +#~ msgid ":ref:`Availability `: Windows, pthreads." +#~ msgstr ":ref:`適用 `:Windows, pthreads。" + +#~ msgid "" +#~ "Threads interact strangely with interrupts: the :exc:`KeyboardInterrupt` " +#~ "exception will be received by an arbitrary thread. (When the :mod:" +#~ "`signal` module is available, interrupts always go to the main thread.)" +#~ msgstr "" +#~ "執行緒與中斷的互動可能會有奇怪的情況:任何一個執行緒都有可能收到 :exc:" +#~ "`KeyboardInterrupt` 例外。(當 :mod:`signal` 模組可用時,中斷總是會進入主" +#~ "執行緒。)" + +#~ msgid "" +#~ "When the main thread exits, it does not do any of its usual cleanup " +#~ "(except that :keyword:`try` ... :keyword:`finally` clauses are honored), " +#~ "and the standard I/O files are not flushed." +#~ msgstr "" +#~ "當主執行緒退出時,它不會執行任何通常的清理操作(除非有 :keyword:" +#~ "`try` ... :keyword:`finally` 子句),並且標準 I/O 檔案不會被刷新。" diff --git a/library/abc.po b/library/abc.po index e6231cfde5..bc726a6c9b 100644 --- a/library/abc.po +++ b/library/abc.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-01 22:24+0800\n" +"POT-Creation-Date: 2025-03-03 18:39+0000\n" "PO-Revision-Date: 2022-11-16 03:29+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -183,11 +183,12 @@ msgid "(Must be defined as a class method.)" msgstr "(必須定義為類別方法。)" #: ../../library/abc.rst:98 +#, fuzzy msgid "" "Check whether *subclass* is considered a subclass of this ABC. This means " "that you can customize the behavior of :func:`issubclass` further without " "the need to call :meth:`register` on every class you want to consider a " -"subclass of the ABC. (This class method is called from the :meth:`~class." +"subclass of the ABC. (This class method is called from the :meth:`~type." "__subclasscheck__` method of the ABC.)" msgstr "" "檢查 *subclass* 是否該被認為是該 ABC 的子類別,也就是說你可以直接自訂 :func:" @@ -270,32 +271,35 @@ msgstr "" "MyIterable.register(Foo)" #: ../../library/abc.rst:143 +#, fuzzy msgid "" -"The ABC ``MyIterable`` defines the standard iterable method, :meth:" -"`~iterator.__iter__`, as an abstract method. The implementation given here " -"can still be called from subclasses. The :meth:`!get_iterator` method is " -"also part of the ``MyIterable`` abstract base class, but it does not have to " -"be overridden in non-abstract derived classes." +"The ABC ``MyIterable`` defines the standard iterable method, :meth:`~object." +"__iter__`, as an abstract method. The implementation given here can still " +"be called from subclasses. The :meth:`!get_iterator` method is also part of " +"the ``MyIterable`` abstract base class, but it does not have to be " +"overridden in non-abstract derived classes." msgstr "" "ABC ``MyIterable`` 定義了作為抽象方法的一個標準疊代方法 :meth:`~iterator." "__iter__`。這裡給定的實作仍可在子類別中被呼叫。:meth:`!get_iterator` 方法也" "是 ``MyIterable`` 抽象基底類別的一部分,但它不必被非抽象衍生類別覆寫。" #: ../../library/abc.rst:149 +#, fuzzy msgid "" "The :meth:`__subclasshook__` class method defined here says that any class " -"that has an :meth:`~iterator.__iter__` method in its :attr:`~object." -"__dict__` (or in that of one of its base classes, accessed via the :attr:" -"`~class.__mro__` list) is considered a ``MyIterable`` too." +"that has an :meth:`~object.__iter__` method in its :attr:`~object.__dict__` " +"(or in that of one of its base classes, accessed via the :attr:`~type." +"__mro__` list) is considered a ``MyIterable`` too." msgstr "" "這裡定義的 :meth:`__subclasshook__` 類別方法說明任何在其 :attr:`~object." "__dict__` (或在其透過 :attr:`~class.__mro__` 列表訪問的基底類別) 中具有 :" "meth:`~iterator.__iter__` 方法的類別也都會被視為 ``MyIterable``。" #: ../../library/abc.rst:154 +#, fuzzy msgid "" "Finally, the last line makes ``Foo`` a virtual subclass of ``MyIterable``, " -"even though it does not define an :meth:`~iterator.__iter__` method (it uses " +"even though it does not define an :meth:`~object.__iter__` method (it uses " "the old-style iterable protocol, defined in terms of :meth:`~object.__len__` " "and :meth:`~object.__getitem__`). Note that this will not make " "``get_iterator`` available as a method of ``Foo``, so it is provided " diff --git a/library/aifc.po b/library/aifc.po index e5750661b5..554a31336c 100644 --- a/library/aifc.po +++ b/library/aifc.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-07-20 00:03+0000\n" +"POT-Creation-Date: 2024-11-20 09:21+0000\n" "PO-Revision-Date: 2022-05-22 01:57+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -20,267 +20,50 @@ msgstr "" "X-Generator: Poedit 3.0.1\n" #: ../../library/aifc.rst:2 -msgid ":mod:`aifc` --- Read and write AIFF and AIFC files" +#, fuzzy +msgid ":mod:`!aifc` --- Read and write AIFF and AIFC files" msgstr ":mod:`aifc` --- 讀寫 AIFF 與 AIFC 檔案" -#: ../../library/aifc.rst:8 -msgid "**Source code:** :source:`Lib/aifc.py`" -msgstr "**原始碼:**\\ :source:`Lib/aifc.py`" - -#: ../../library/aifc.rst:16 -msgid "" -"The :mod:`aifc` module is deprecated (see :pep:`PEP 594 <594#aifc>` for " -"details)." -msgstr "" -":mod:`aifc` 模組 (module) 即將被棄用(詳見 :pep:`PEP 594 <594#aifc>`\\ )。" - -#: ../../library/aifc.rst:22 -msgid "" -"This module provides support for reading and writing AIFF and AIFF-C files. " -"AIFF is Audio Interchange File Format, a format for storing digital audio " -"samples in a file. AIFF-C is a newer version of the format that includes " -"the ability to compress the audio data." -msgstr "" - -#: ../../library/aifc.rst:27 -msgid "" -"Audio files have a number of parameters that describe the audio data. The " -"sampling rate or frame rate is the number of times per second the sound is " -"sampled. The number of channels indicate if the audio is mono, stereo, or " -"quadro. Each frame consists of one sample per channel. The sample size is " -"the size in bytes of each sample. Thus a frame consists of ``nchannels * " -"samplesize`` bytes, and a second's worth of audio consists of ``nchannels * " -"samplesize * framerate`` bytes." -msgstr "" - -#: ../../library/aifc.rst:35 -msgid "" -"For example, CD quality audio has a sample size of two bytes (16 bits), uses " -"two channels (stereo) and has a frame rate of 44,100 frames/second. This " -"gives a frame size of 4 bytes (2\\*2), and a second's worth occupies " -"2\\*2\\*44100 bytes (176,400 bytes)." -msgstr "" - -#: ../../library/aifc.rst:40 -msgid "Module :mod:`aifc` defines the following function:" -msgstr ":mod:`aifc` 模組定義了以下函式:" - -#: ../../library/aifc.rst:45 -msgid "" -"Open an AIFF or AIFF-C file and return an object instance with methods that " -"are described below. The argument *file* is either a string naming a file " -"or a :term:`file object`. *mode* must be ``'r'`` or ``'rb'`` when the file " -"must be opened for reading, or ``'w'`` or ``'wb'`` when the file must be " -"opened for writing. If omitted, ``file.mode`` is used if it exists, " -"otherwise ``'rb'`` is used. When used for writing, the file object should " -"be seekable, unless you know ahead of time how many samples you are going to " -"write in total and use :meth:`writeframesraw` and :meth:`setnframes`. The :" -"func:`.open` function may be used in a :keyword:`with` statement. When the :" -"keyword:`!with` block completes, the :meth:`~aifc.close` method is called." -msgstr "" - -#: ../../library/aifc.rst:56 -msgid "Support for the :keyword:`with` statement was added." -msgstr "" - -#: ../../library/aifc.rst:59 -msgid "" -"Objects returned by :func:`.open` when a file is opened for reading have the " -"following methods:" -msgstr "" - -#: ../../library/aifc.rst:65 -msgid "Return the number of audio channels (1 for mono, 2 for stereo)." -msgstr "" - -#: ../../library/aifc.rst:70 -msgid "Return the size in bytes of individual samples." -msgstr "" - -#: ../../library/aifc.rst:75 -msgid "Return the sampling rate (number of audio frames per second)." -msgstr "" - -#: ../../library/aifc.rst:80 -msgid "Return the number of audio frames in the file." -msgstr "" - -#: ../../library/aifc.rst:85 -msgid "" -"Return a bytes array of length 4 describing the type of compression used in " -"the audio file. For AIFF files, the returned value is ``b'NONE'``." -msgstr "" - -#: ../../library/aifc.rst:92 -msgid "" -"Return a bytes array convertible to a human-readable description of the type " -"of compression used in the audio file. For AIFF files, the returned value " -"is ``b'not compressed'``." -msgstr "" - -#: ../../library/aifc.rst:99 -msgid "" -"Returns a :func:`~collections.namedtuple` ``(nchannels, sampwidth, " -"framerate, nframes, comptype, compname)``, equivalent to output of the :meth:" -"`get\\*` methods." -msgstr "" - -#: ../../library/aifc.rst:106 -msgid "" -"Return a list of markers in the audio file. A marker consists of a tuple of " -"three elements. The first is the mark ID (an integer), the second is the " -"mark position in frames from the beginning of the data (an integer), the " -"third is the name of the mark (a string)." -msgstr "" - -#: ../../library/aifc.rst:114 -msgid "" -"Return the tuple as described in :meth:`getmarkers` for the mark with the " -"given *id*." -msgstr "" - -#: ../../library/aifc.rst:120 -msgid "" -"Read and return the next *nframes* frames from the audio file. The returned " -"data is a string containing for each frame the uncompressed samples of all " -"channels." -msgstr "" - -#: ../../library/aifc.rst:127 -msgid "" -"Rewind the read pointer. The next :meth:`readframes` will start from the " -"beginning." -msgstr "" - -#: ../../library/aifc.rst:133 -msgid "Seek to the specified frame number." -msgstr "" - -#: ../../library/aifc.rst:138 -msgid "Return the current frame number." -msgstr "" - -#: ../../library/aifc.rst:143 -msgid "" -"Close the AIFF file. After calling this method, the object can no longer be " -"used." -msgstr "" - -#: ../../library/aifc.rst:146 -msgid "" -"Objects returned by :func:`.open` when a file is opened for writing have all " -"the above methods, except for :meth:`readframes` and :meth:`setpos`. In " -"addition the following methods exist. The :meth:`get\\*` methods can only " -"be called after the corresponding :meth:`set\\*` methods have been called. " -"Before the first :meth:`writeframes` or :meth:`writeframesraw`, all " -"parameters except for the number of frames must be filled in." -msgstr "" - -#: ../../library/aifc.rst:156 -msgid "" -"Create an AIFF file. The default is that an AIFF-C file is created, unless " -"the name of the file ends in ``'.aiff'`` in which case the default is an " -"AIFF file." -msgstr "" - -#: ../../library/aifc.rst:162 -msgid "" -"Create an AIFF-C file. The default is that an AIFF-C file is created, " -"unless the name of the file ends in ``'.aiff'`` in which case the default is " -"an AIFF file." -msgstr "" - -#: ../../library/aifc.rst:169 -msgid "Specify the number of channels in the audio file." -msgstr "" - -#: ../../library/aifc.rst:174 -msgid "Specify the size in bytes of audio samples." -msgstr "" - -#: ../../library/aifc.rst:179 -msgid "Specify the sampling frequency in frames per second." -msgstr "" - -#: ../../library/aifc.rst:184 -msgid "" -"Specify the number of frames that are to be written to the audio file. If " -"this parameter is not set, or not set correctly, the file needs to support " -"seeking." -msgstr "" - -#: ../../library/aifc.rst:195 -msgid "" -"Specify the compression type. If not specified, the audio data will not be " -"compressed. In AIFF files, compression is not possible. The name parameter " -"should be a human-readable description of the compression type as a bytes " -"array, the type parameter should be a bytes array of length 4. Currently " -"the following compression types are supported: ``b'NONE'``, ``b'ULAW'``, " -"``b'ALAW'``, ``b'G722'``." -msgstr "" - -#: ../../library/aifc.rst:205 -msgid "" -"Set all the above parameters at once. The argument is a tuple consisting of " -"the various parameters. This means that it is possible to use the result of " -"a :meth:`getparams` call as argument to :meth:`setparams`." -msgstr "" - -#: ../../library/aifc.rst:212 -msgid "" -"Add a mark with the given id (larger than 0), and the given name at the " -"given position. This method can be called at any time before :meth:`close`." -msgstr "" - -#: ../../library/aifc.rst:219 +#: ../../library/aifc.rst:10 msgid "" -"Return the current write position in the output file. Useful in combination " -"with :meth:`setmark`." +"This module is no longer part of the Python standard library. It was :ref:" +"`removed in Python 3.13 ` after being deprecated in " +"Python 3.11. The removal was decided in :pep:`594`." msgstr "" -#: ../../library/aifc.rst:225 +#: ../../library/aifc.rst:14 msgid "" -"Write data to the output file. This method can only be called after the " -"audio file parameters have been set." +"The last version of Python that provided the :mod:`!aifc` module was `Python " +"3.12 `_." msgstr "" -#: ../../library/aifc.rst:228 ../../library/aifc.rst:237 -msgid "Any :term:`bytes-like object` is now accepted." -msgstr "" +#~ msgid "**Source code:** :source:`Lib/aifc.py`" +#~ msgstr "**原始碼:**\\ :source:`Lib/aifc.py`" -#: ../../library/aifc.rst:234 -msgid "" -"Like :meth:`writeframes`, except that the header of the audio file is not " -"updated." -msgstr "" +#~ msgid "" +#~ "The :mod:`aifc` module is deprecated (see :pep:`PEP 594 <594#aifc>` for " +#~ "details)." +#~ msgstr "" +#~ ":mod:`aifc` 模組 (module) 即將被棄用(詳見 :pep:`PEP 594 " +#~ "<594#aifc>`\\ )。" -#: ../../library/aifc.rst:244 -msgid "" -"Close the AIFF file. The header of the file is updated to reflect the " -"actual size of the audio data. After calling this method, the object can no " -"longer be used." -msgstr "" +#~ msgid "Module :mod:`aifc` defines the following function:" +#~ msgstr ":mod:`aifc` 模組定義了以下函式:" -#: ../../library/aifc.rst:10 -msgid "Audio Interchange File Format" -msgstr "Audio Interchange File Format(音訊交換檔案格式)" +#~ msgid "Audio Interchange File Format" +#~ msgstr "Audio Interchange File Format(音訊交換檔案格式)" -#: ../../library/aifc.rst:10 -msgid "AIFF" -msgstr "AIFF" +#~ msgid "AIFF" +#~ msgstr "AIFF" -#: ../../library/aifc.rst:10 -msgid "AIFF-C" -msgstr "AIFF-C" +#~ msgid "AIFF-C" +#~ msgstr "AIFF-C" -#: ../../library/aifc.rst:190 -msgid "u-LAW" -msgstr "u-LAW" +#~ msgid "u-LAW" +#~ msgstr "u-LAW" -#: ../../library/aifc.rst:190 -msgid "A-LAW" -msgstr "A-LAW" +#~ msgid "A-LAW" +#~ msgstr "A-LAW" -#: ../../library/aifc.rst:190 -msgid "G.722" -msgstr "G.722" +#~ msgid "G.722" +#~ msgstr "G.722" diff --git a/library/argparse.po b/library/argparse.po index 726a5ed8f2..d209f99f00 100644 --- a/library/argparse.po +++ b/library/argparse.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-03-03 18:39+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-" @@ -20,48 +20,57 @@ msgstr "" #: ../../library/argparse.rst:2 msgid "" -":mod:`!argparse` --- Parser for command-line options, arguments and sub-" -"commands" +":mod:`!argparse` --- Parser for command-line options, arguments and " +"subcommands" msgstr "" #: ../../library/argparse.rst:12 msgid "**Source code:** :source:`Lib/argparse.py`" msgstr "**原始碼:**\\ :source:`Lib/argparse.py`" +#: ../../library/argparse.rst:16 +msgid "" +"While :mod:`argparse` is the default recommended standard library module for " +"implementing basic command line applications, authors with more exacting " +"requirements for exactly how their command line applications behave may find " +"it doesn't provide the necessary level of control. Refer to :ref:`choosing-" +"an-argument-parser` for alternatives to consider when ``argparse`` doesn't " +"support behaviors that the application requires (such as entirely disabling " +"support for interspersed options and positional arguments, or accepting " +"option parameter values that start with ``-`` even when they correspond to " +"another defined option)." +msgstr "" + #: ../../library/argparse.rst:-1 msgid "Tutorial" msgstr "教學" -#: ../../library/argparse.rst:18 +#: ../../library/argparse.rst:30 msgid "" "This page contains the API reference information. For a more gentle " "introduction to Python command-line parsing, have a look at the :ref:" "`argparse tutorial `." msgstr "" -#: ../../library/argparse.rst:22 +#: ../../library/argparse.rst:34 msgid "" -"The :mod:`argparse` module makes it easy to write user-friendly command-line " -"interfaces. The program defines what arguments it requires, and :mod:" -"`argparse` will figure out how to parse those out of :data:`sys.argv`. The :" -"mod:`argparse` module also automatically generates help and usage messages. " -"The module will also issue errors when users give the program invalid " -"arguments." +"The :mod:`!argparse` module makes it easy to write user-friendly command-" +"line interfaces. The program defines what arguments it requires, and :mod:`!" +"argparse` will figure out how to parse those out of :data:`sys.argv`. The :" +"mod:`!argparse` module also automatically generates help and usage " +"messages. The module will also issue errors when users give the program " +"invalid arguments." msgstr "" -#: ../../library/argparse.rst:30 -msgid "Core Functionality" -msgstr "" - -#: ../../library/argparse.rst:32 +#: ../../library/argparse.rst:40 msgid "" -"The :mod:`argparse` module's support for command-line interfaces is built " +"The :mod:`!argparse` module's support for command-line interfaces is built " "around an instance of :class:`argparse.ArgumentParser`. It is a container " "for argument specifications and has options that apply to the parser as " "whole::" msgstr "" -#: ../../library/argparse.rst:36 +#: ../../library/argparse.rst:44 msgid "" "parser = argparse.ArgumentParser(\n" " prog='ProgramName',\n" @@ -69,14 +78,14 @@ msgid "" " epilog='Text at the bottom of help')" msgstr "" -#: ../../library/argparse.rst:41 +#: ../../library/argparse.rst:49 msgid "" "The :meth:`ArgumentParser.add_argument` method attaches individual argument " "specifications to the parser. It supports positional arguments, options " "that accept values, and on/off flags::" msgstr "" -#: ../../library/argparse.rst:45 +#: ../../library/argparse.rst:53 msgid "" "parser.add_argument('filename') # positional argument\n" "parser.add_argument('-c', '--count') # option that takes a value\n" @@ -84,508 +93,162 @@ msgid "" " action='store_true') # on/off flag" msgstr "" -#: ../../library/argparse.rst:50 +#: ../../library/argparse.rst:58 msgid "" "The :meth:`ArgumentParser.parse_args` method runs the parser and places the " "extracted data in a :class:`argparse.Namespace` object::" msgstr "" -#: ../../library/argparse.rst:53 +#: ../../library/argparse.rst:61 msgid "" "args = parser.parse_args()\n" "print(args.filename, args.count, args.verbose)" msgstr "" -#: ../../library/argparse.rst:58 -msgid "Quick Links for add_argument()" -msgstr "" - -#: ../../library/argparse.rst:61 -msgid "Name" -msgstr "名稱" - -#: ../../library/argparse.rst:61 -msgid "Description" -msgstr "描述" - -#: ../../library/argparse.rst:61 -msgid "Values" -msgstr "數值" - -#: ../../library/argparse.rst:63 -msgid "action_" -msgstr "action_" - -#: ../../library/argparse.rst:63 -msgid "Specify how an argument should be handled" -msgstr "" - -#: ../../library/argparse.rst:63 -msgid "" -"``'store'``, ``'store_const'``, ``'store_true'``, ``'append'``, " -"``'append_const'``, ``'count'``, ``'help'``, ``'version'``" -msgstr "" -"``'store'``, ``'store_const'``, ``'store_true'``, ``'append'``, " -"``'append_const'``, ``'count'``, ``'help'``, ``'version'``" - -#: ../../library/argparse.rst:64 -msgid "choices_" -msgstr "choices_" - -#: ../../library/argparse.rst:64 -msgid "Limit values to a specific set of choices" -msgstr "" - -#: ../../library/argparse.rst:64 -msgid "" -"``['foo', 'bar']``, ``range(1, 10)``, or :class:`~collections.abc.Container` " -"instance" -msgstr "" - #: ../../library/argparse.rst:65 -msgid "const_" -msgstr "const_" - -#: ../../library/argparse.rst:65 -msgid "Store a constant value" -msgstr "" - -#: ../../library/argparse.rst:66 -msgid "default_" -msgstr "default_" - -#: ../../library/argparse.rst:66 -msgid "Default value used when an argument is not provided" -msgstr "" - -#: ../../library/argparse.rst:66 -msgid "Defaults to ``None``" -msgstr "" - -#: ../../library/argparse.rst:67 -msgid "dest_" -msgstr "dest_" - -#: ../../library/argparse.rst:67 -msgid "Specify the attribute name used in the result namespace" -msgstr "" - -#: ../../library/argparse.rst:68 -msgid "help_" -msgstr "help_" - -#: ../../library/argparse.rst:68 -msgid "Help message for an argument" -msgstr "" - -#: ../../library/argparse.rst:69 -msgid "metavar_" -msgstr "metavar_" - -#: ../../library/argparse.rst:69 -msgid "Alternate display name for the argument as shown in help" -msgstr "" - -#: ../../library/argparse.rst:70 -msgid "nargs_" -msgstr "nargs_" - -#: ../../library/argparse.rst:70 -msgid "Number of times the argument can be used" -msgstr "" - -#: ../../library/argparse.rst:70 -msgid ":class:`int`, ``'?'``, ``'*'``, or ``'+'``" -msgstr ":class:`int`, ``'?'``, ``'*'``, or ``'+'``" - -#: ../../library/argparse.rst:71 -msgid "required_" -msgstr "required_" - -#: ../../library/argparse.rst:71 -msgid "Indicate whether an argument is required or optional" -msgstr "" - -#: ../../library/argparse.rst:71 -msgid "``True`` or ``False``" -msgstr "``True`` 或 ``False``" - -#: ../../library/argparse.rst:72 -msgid ":ref:`type `" -msgstr "" - -#: ../../library/argparse.rst:72 -msgid "Automatically convert an argument to the given type" -msgstr "" - -#: ../../library/argparse.rst:72 -msgid "" -":class:`int`, :class:`float`, ``argparse.FileType('w')``, or callable " -"function" -msgstr "" -":class:`int`、:class:`float`、``argparse.FileType('w')`` 或可呼叫的函式" - -#: ../../library/argparse.rst:77 -msgid "Example" -msgstr "範例" - -#: ../../library/argparse.rst:79 -msgid "" -"The following code is a Python program that takes a list of integers and " -"produces either the sum or the max::" -msgstr "" - -#: ../../library/argparse.rst:82 -msgid "" -"import argparse\n" -"\n" -"parser = argparse.ArgumentParser(description='Process some integers.')\n" -"parser.add_argument('integers', metavar='N', type=int, nargs='+',\n" -" help='an integer for the accumulator')\n" -"parser.add_argument('--sum', dest='accumulate', action='store_const',\n" -" const=sum, default=max,\n" -" help='sum the integers (default: find the max)')\n" -"\n" -"args = parser.parse_args()\n" -"print(args.accumulate(args.integers))" -msgstr "" -"import argparse\n" -"\n" -"parser = argparse.ArgumentParser(description='Process some integers.')\n" -"parser.add_argument('integers', metavar='N', type=int, nargs='+',\n" -" help='an integer for the accumulator')\n" -"parser.add_argument('--sum', dest='accumulate', action='store_const',\n" -" const=sum, default=max,\n" -" help='sum the integers (default: find the max)')\n" -"\n" -"args = parser.parse_args()\n" -"print(args.accumulate(args.integers))" - -#: ../../library/argparse.rst:94 -msgid "" -"Assuming the above Python code is saved into a file called ``prog.py``, it " -"can be run at the command line and it provides useful help messages:" -msgstr "" - -#: ../../library/argparse.rst:97 -msgid "" -"$ python prog.py -h\n" -"usage: prog.py [-h] [--sum] N [N ...]\n" -"\n" -"Process some integers.\n" -"\n" -"positional arguments:\n" -" N an integer for the accumulator\n" -"\n" -"options:\n" -" -h, --help show this help message and exit\n" -" --sum sum the integers (default: find the max)" -msgstr "" -"$ python prog.py -h\n" -"usage: prog.py [-h] [--sum] N [N ...]\n" -"\n" -"Process some integers.\n" -"\n" -"positional arguments:\n" -" N an integer for the accumulator\n" -"\n" -"options:\n" -" -h, --help show this help message and exit\n" -" --sum sum the integers (default: find the max)" - -#: ../../library/argparse.rst:111 -msgid "" -"When run with the appropriate arguments, it prints either the sum or the max " -"of the command-line integers:" -msgstr "" - -#: ../../library/argparse.rst:114 -msgid "" -"$ python prog.py 1 2 3 4\n" -"4\n" -"\n" -"$ python prog.py 1 2 3 4 --sum\n" -"10" -msgstr "" -"$ python prog.py 1 2 3 4\n" -"4\n" -"\n" -"$ python prog.py 1 2 3 4 --sum\n" -"10" - -#: ../../library/argparse.rst:122 -msgid "If invalid arguments are passed in, an error will be displayed:" -msgstr "" - -#: ../../library/argparse.rst:124 -msgid "" -"$ python prog.py a b c\n" -"usage: prog.py [-h] [--sum] N [N ...]\n" -"prog.py: error: argument N: invalid int value: 'a'" -msgstr "" -"$ python prog.py a b c\n" -"usage: prog.py [-h] [--sum] N [N ...]\n" -"prog.py: error: argument N: invalid int value: 'a'" - -#: ../../library/argparse.rst:130 -msgid "The following sections walk you through this example." -msgstr "" - -#: ../../library/argparse.rst:134 -msgid "Creating a parser" -msgstr "建立一個剖析器" - -#: ../../library/argparse.rst:136 -msgid "" -"The first step in using the :mod:`argparse` is creating an :class:" -"`ArgumentParser` object::" -msgstr "" - -#: ../../library/argparse.rst:139 msgid "" -">>> parser = argparse.ArgumentParser(description='Process some integers.')" +"If you're looking for a guide about how to upgrade :mod:`optparse` code to :" +"mod:`!argparse`, see :ref:`Upgrading Optparse Code `." msgstr "" -">>> parser = argparse.ArgumentParser(description='Process some integers.')" -#: ../../library/argparse.rst:141 -msgid "" -"The :class:`ArgumentParser` object will hold all the information necessary " -"to parse the command line into Python data types." -msgstr "" - -#: ../../library/argparse.rst:146 -msgid "Adding arguments" -msgstr "增加引數" - -#: ../../library/argparse.rst:148 -msgid "" -"Filling an :class:`ArgumentParser` with information about program arguments " -"is done by making calls to the :meth:`~ArgumentParser.add_argument` method. " -"Generally, these calls tell the :class:`ArgumentParser` how to take the " -"strings on the command line and turn them into objects. This information is " -"stored and used when :meth:`~ArgumentParser.parse_args` is called. For " -"example::" -msgstr "" - -#: ../../library/argparse.rst:154 -msgid "" -">>> parser.add_argument('integers', metavar='N', type=int, nargs='+',\n" -"... help='an integer for the accumulator')\n" -">>> parser.add_argument('--sum', dest='accumulate', action='store_const',\n" -"... const=sum, default=max,\n" -"... help='sum the integers (default: find the max)')" -msgstr "" -">>> parser.add_argument('integers', metavar='N', type=int, nargs='+',\n" -"... help='an integer for the accumulator')\n" -">>> parser.add_argument('--sum', dest='accumulate', action='store_const',\n" -"... const=sum, default=max,\n" -"... help='sum the integers (default: find the max)')" - -#: ../../library/argparse.rst:160 -msgid "" -"Later, calling :meth:`~ArgumentParser.parse_args` will return an object with " -"two attributes, ``integers`` and ``accumulate``. The ``integers`` attribute " -"will be a list of one or more integers, and the ``accumulate`` attribute " -"will be either the :func:`sum` function, if ``--sum`` was specified at the " -"command line, or the :func:`max` function if it was not." -msgstr "" - -#: ../../library/argparse.rst:168 -msgid "Parsing arguments" -msgstr "剖析引數" - -#: ../../library/argparse.rst:170 -msgid "" -":class:`ArgumentParser` parses arguments through the :meth:`~ArgumentParser." -"parse_args` method. This will inspect the command line, convert each " -"argument to the appropriate type and then invoke the appropriate action. In " -"most cases, this means a simple :class:`Namespace` object will be built up " -"from attributes parsed out of the command line::" -msgstr "" - -#: ../../library/argparse.rst:176 -msgid "" -">>> parser.parse_args(['--sum', '7', '-1', '42'])\n" -"Namespace(accumulate=, integers=[7, -1, 42])" -msgstr "" -">>> parser.parse_args(['--sum', '7', '-1', '42'])\n" -"Namespace(accumulate=, integers=[7, -1, 42])" - -#: ../../library/argparse.rst:179 -msgid "" -"In a script, :meth:`~ArgumentParser.parse_args` will typically be called " -"with no arguments, and the :class:`ArgumentParser` will automatically " -"determine the command-line arguments from :data:`sys.argv`." -msgstr "" - -#: ../../library/argparse.rst:185 +#: ../../library/argparse.rst:69 msgid "ArgumentParser objects" msgstr "ArgumentParser 物件" -#: ../../library/argparse.rst:194 +#: ../../library/argparse.rst:78 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:198 +#: ../../library/argparse.rst:82 msgid "" "prog_ - The name of the program (default: ``os.path.basename(sys.argv[0])``)" msgstr "" -#: ../../library/argparse.rst:201 +#: ../../library/argparse.rst:85 msgid "" "usage_ - The string describing the program usage (default: generated from " "arguments added to parser)" msgstr "" -#: ../../library/argparse.rst:204 +#: ../../library/argparse.rst:88 msgid "" "description_ - Text to display before the argument help (by default, no text)" msgstr "" -#: ../../library/argparse.rst:207 +#: ../../library/argparse.rst:91 msgid "epilog_ - Text to display after the argument help (by default, no text)" msgstr "" -#: ../../library/argparse.rst:209 +#: ../../library/argparse.rst:93 msgid "" "parents_ - A list of :class:`ArgumentParser` objects whose arguments should " "also be included" msgstr "" -#: ../../library/argparse.rst:212 +#: ../../library/argparse.rst:96 msgid "formatter_class_ - A class for customizing the help output" msgstr "" -#: ../../library/argparse.rst:214 +#: ../../library/argparse.rst:98 msgid "" "prefix_chars_ - The set of characters that prefix optional arguments " "(default: '-')" msgstr "" -#: ../../library/argparse.rst:217 +#: ../../library/argparse.rst:101 msgid "" "fromfile_prefix_chars_ - The set of characters that prefix files from which " "additional arguments should be read (default: ``None``)" msgstr "" -#: ../../library/argparse.rst:220 +#: ../../library/argparse.rst:104 msgid "" "argument_default_ - The global default value for arguments (default: " "``None``)" msgstr "" -#: ../../library/argparse.rst:223 +#: ../../library/argparse.rst:107 msgid "" "conflict_handler_ - The strategy for resolving conflicting optionals " "(usually unnecessary)" msgstr "" -#: ../../library/argparse.rst:226 +#: ../../library/argparse.rst:110 msgid "" "add_help_ - Add a ``-h/--help`` option to the parser (default: ``True``)" msgstr "" -#: ../../library/argparse.rst:228 +#: ../../library/argparse.rst:112 msgid "" "allow_abbrev_ - Allows long options to be abbreviated if the abbreviation is " "unambiguous. (default: ``True``)" msgstr "" -#: ../../library/argparse.rst:231 +#: ../../library/argparse.rst:115 msgid "" -"exit_on_error_ - Determines whether or not ArgumentParser exits with error " -"info when an error occurs. (default: ``True``)" +"exit_on_error_ - Determines whether or not :class:`!ArgumentParser` exits " +"with error info when an error occurs. (default: ``True``)" msgstr "" -#: ../../library/argparse.rst:234 +#: ../../library/argparse.rst:118 msgid "*allow_abbrev* parameter was added." msgstr "新增 *allow_abbrev* 參數。" -#: ../../library/argparse.rst:237 +#: ../../library/argparse.rst:121 msgid "" "In previous versions, *allow_abbrev* also disabled grouping of short flags " "such as ``-vv`` to mean ``-v -v``." msgstr "" -#: ../../library/argparse.rst:241 +#: ../../library/argparse.rst:125 msgid "*exit_on_error* parameter was added." msgstr "新增 *exit_on_error* 參數。" -#: ../../library/argparse.rst:244 ../../library/argparse.rst:782 +#: ../../library/argparse.rst:128 ../../library/argparse.rst:610 msgid "The following sections describe how each of these are used." msgstr "" -#: ../../library/argparse.rst:250 +#: ../../library/argparse.rst:134 msgid "prog" msgstr "" -#: ../../library/argparse.rst:252 +#: ../../library/argparse.rst:137 msgid "" -"By default, :class:`ArgumentParser` objects use ``sys.argv[0]`` to determine " -"how to display the name of the program in help messages. This default is " -"almost always desirable because it will make the help messages match how the " -"program was invoked on the command line. For example, consider a file named " -"``myprogram.py`` with the following code::" +"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:258 ../../library/argparse.rst:678 +#: ../../library/argparse.rst:140 msgid "" -"import argparse\n" -"parser = argparse.ArgumentParser()\n" -"parser.add_argument('--foo', help='foo help')\n" -"args = parser.parse_args()" +"The :func:`base name ` of ``sys.argv[0]`` if a file was " +"passed as argument." msgstr "" -"import argparse\n" -"parser = argparse.ArgumentParser()\n" -"parser.add_argument('--foo', help='foo help')\n" -"args = parser.parse_args()" -#: ../../library/argparse.rst:263 +#: ../../library/argparse.rst:142 msgid "" -"The help for this program will display ``myprogram.py`` as the program name " -"(regardless of where the program was invoked from):" +"The Python interpreter name followed by ``sys.argv[0]`` if a directory or a " +"zipfile was passed as argument." msgstr "" -#: ../../library/argparse.rst:266 +#: ../../library/argparse.rst:144 msgid "" -"$ python myprogram.py --help\n" -"usage: myprogram.py [-h] [--foo FOO]\n" -"\n" -"options:\n" -" -h, --help show this help message and exit\n" -" --foo FOO foo help\n" -"$ cd ..\n" -"$ python subdir/myprogram.py --help\n" -"usage: myprogram.py [-h] [--foo FOO]\n" -"\n" -"options:\n" -" -h, --help show this help message and exit\n" -" --foo FOO foo help" +"The Python interpreter name followed by ``-m`` followed by the module or " +"package name if the :option:`-m` option was used." msgstr "" -"$ python myprogram.py --help\n" -"usage: myprogram.py [-h] [--foo FOO]\n" -"\n" -"options:\n" -" -h, --help show this help message and exit\n" -" --foo FOO foo help\n" -"$ cd ..\n" -"$ python subdir/myprogram.py --help\n" -"usage: myprogram.py [-h] [--foo FOO]\n" -"\n" -"options:\n" -" -h, --help show this help message and exit\n" -" --foo FOO foo help" -#: ../../library/argparse.rst:282 +#: ../../library/argparse.rst:147 msgid "" -"To change this default behavior, another value can be supplied using the " -"``prog=`` argument to :class:`ArgumentParser`::" +"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 " +"line. However, to change this default behavior, another value can be " +"supplied using the ``prog=`` argument to :class:`ArgumentParser`::" msgstr "" -#: ../../library/argparse.rst:285 +#: ../../library/argparse.rst:152 msgid "" ">>> parser = argparse.ArgumentParser(prog='myprogram')\n" ">>> parser.print_help()\n" @@ -601,14 +264,14 @@ msgstr "" "options:\n" " -h, --help show this help message and exit" -#: ../../library/argparse.rst:292 +#: ../../library/argparse.rst:159 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." msgstr "" -#: ../../library/argparse.rst:298 +#: ../../library/argparse.rst:165 msgid "" ">>> parser = argparse.ArgumentParser(prog='myprogram')\n" ">>> parser.add_argument('--foo', help='foo of the %(prog)s program')\n" @@ -628,50 +291,18 @@ msgstr "" " -h, --help show this help message and exit\n" " --foo FOO foo of the myprogram program" -#: ../../library/argparse.rst:309 +#: ../../library/argparse.rst:176 msgid "usage" msgstr "" -#: ../../library/argparse.rst:311 +#: ../../library/argparse.rst:178 msgid "" "By default, :class:`ArgumentParser` calculates the usage message from the " -"arguments it contains::" +"arguments it contains. The default message can be overridden with the " +"``usage=`` keyword argument::" msgstr "" -#: ../../library/argparse.rst:314 -msgid "" -">>> parser = argparse.ArgumentParser(prog='PROG')\n" -">>> parser.add_argument('--foo', nargs='?', help='foo help')\n" -">>> parser.add_argument('bar', nargs='+', help='bar help')\n" -">>> parser.print_help()\n" -"usage: PROG [-h] [--foo [FOO]] bar [bar ...]\n" -"\n" -"positional arguments:\n" -" bar bar help\n" -"\n" -"options:\n" -" -h, --help show this help message and exit\n" -" --foo [FOO] foo help" -msgstr "" -">>> parser = argparse.ArgumentParser(prog='PROG')\n" -">>> parser.add_argument('--foo', nargs='?', help='foo help')\n" -">>> parser.add_argument('bar', nargs='+', help='bar help')\n" -">>> parser.print_help()\n" -"usage: PROG [-h] [--foo [FOO]] bar [bar ...]\n" -"\n" -"positional arguments:\n" -" bar bar help\n" -"\n" -"options:\n" -" -h, --help show this help message and exit\n" -" --foo [FOO] foo help" - -#: ../../library/argparse.rst:327 -msgid "" -"The default message can be overridden with the ``usage=`` keyword argument::" -msgstr "" - -#: ../../library/argparse.rst:329 +#: ../../library/argparse.rst:182 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', usage='%(prog)s " "[options]')\n" @@ -701,63 +332,43 @@ msgstr "" " -h, --help show this help message and exit\n" " --foo [FOO] foo help" -#: ../../library/argparse.rst:342 +#: ../../library/argparse.rst:195 msgid "" "The ``%(prog)s`` format specifier is available to fill in the program name " "in your usage messages." msgstr "" -#: ../../library/argparse.rst:349 +#: ../../library/argparse.rst:202 msgid "description" msgstr "描述" -#: ../../library/argparse.rst:351 +#: ../../library/argparse.rst:204 msgid "" "Most calls to the :class:`ArgumentParser` constructor will use the " "``description=`` keyword argument. This argument gives a brief description " "of what the program does and how it works. In help messages, the " "description is displayed between the command-line usage string and the help " -"messages for the various arguments::" -msgstr "" - -#: ../../library/argparse.rst:357 -msgid "" -">>> parser = argparse.ArgumentParser(description='A foo that bars')\n" -">>> parser.print_help()\n" -"usage: argparse.py [-h]\n" -"\n" -"A foo that bars\n" -"\n" -"options:\n" -" -h, --help show this help message and exit" +"messages for the various arguments." msgstr "" -">>> parser = argparse.ArgumentParser(description='A foo that bars')\n" -">>> parser.print_help()\n" -"usage: argparse.py [-h]\n" -"\n" -"A foo that bars\n" -"\n" -"options:\n" -" -h, --help show this help message and exit" -#: ../../library/argparse.rst:366 +#: ../../library/argparse.rst:210 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:371 +#: ../../library/argparse.rst:215 msgid "epilog" msgstr "" -#: ../../library/argparse.rst:373 +#: ../../library/argparse.rst:217 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:377 +#: ../../library/argparse.rst:221 msgid "" ">>> parser = argparse.ArgumentParser(\n" "... description='A foo that bars',\n" @@ -785,18 +396,18 @@ msgstr "" "\n" "And that's how you'd foo a bar" -#: ../../library/argparse.rst:390 +#: ../../library/argparse.rst:234 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:396 +#: ../../library/argparse.rst:240 msgid "parents" msgstr "" -#: ../../library/argparse.rst:398 +#: ../../library/argparse.rst:242 msgid "" "Sometimes, several parsers share a common set of arguments. Rather than " "repeating the definitions of these arguments, a single parser with all the " @@ -807,7 +418,7 @@ msgid "" "object being constructed::" msgstr "" -#: ../../library/argparse.rst:405 +#: ../../library/argparse.rst:249 msgid "" ">>> parent_parser = argparse.ArgumentParser(add_help=False)\n" ">>> parent_parser.add_argument('--parent', type=int)\n" @@ -835,32 +446,32 @@ msgstr "" ">>> bar_parser.parse_args(['--bar', 'YYY'])\n" "Namespace(bar='YYY', parent=None)" -#: ../../library/argparse.rst:418 +#: ../../library/argparse.rst:262 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:423 +#: ../../library/argparse.rst:267 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:431 +#: ../../library/argparse.rst:275 msgid "formatter_class" msgstr "formatter_class" -#: ../../library/argparse.rst:433 +#: ../../library/argparse.rst:277 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:442 +#: ../../library/argparse.rst:286 msgid "" ":class:`RawDescriptionHelpFormatter` and :class:`RawTextHelpFormatter` give " "more control over how textual descriptions are displayed. By default, :class:" @@ -868,7 +479,7 @@ msgid "" "command-line help messages::" msgstr "" -#: ../../library/argparse.rst:447 +#: ../../library/argparse.rst:291 msgid "" ">>> parser = argparse.ArgumentParser(\n" "... prog='PROG',\n" @@ -892,14 +503,14 @@ msgid "" "will be wrapped across a couple lines" msgstr "" -#: ../../library/argparse.rst:467 +#: ../../library/argparse.rst:311 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:471 +#: ../../library/argparse.rst:315 msgid "" ">>> parser = argparse.ArgumentParser(\n" "... prog='PROG',\n" @@ -924,21 +535,21 @@ msgid "" " -h, --help show this help message and exit" msgstr "" -#: ../../library/argparse.rst:493 +#: ../../library/argparse.rst:337 msgid "" ":class:`RawTextHelpFormatter` maintains whitespace for all sorts of help " -"text, including argument descriptions. However, multiple new lines are " +"text, including argument descriptions. However, multiple newlines are " "replaced with one. If you wish to preserve multiple blank lines, add spaces " "between the newlines." msgstr "" -#: ../../library/argparse.rst:498 +#: ../../library/argparse.rst:342 msgid "" ":class:`ArgumentDefaultsHelpFormatter` automatically adds information about " "default values to each of the argument help messages::" msgstr "" -#: ../../library/argparse.rst:501 +#: ../../library/argparse.rst:345 msgid "" ">>> parser = argparse.ArgumentParser(\n" "... prog='PROG',\n" @@ -970,14 +581,14 @@ msgstr "" " -h, --help show this help message and exit\n" " --foo FOO FOO! (default: 42)" -#: ../../library/argparse.rst:516 +#: ../../library/argparse.rst:360 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:520 +#: ../../library/argparse.rst:364 msgid "" ">>> parser = argparse.ArgumentParser(\n" "... prog='PROG',\n" @@ -1009,19 +620,19 @@ msgstr "" " -h, --help show this help message and exit\n" " --foo int" -#: ../../library/argparse.rst:537 +#: ../../library/argparse.rst:381 msgid "prefix_chars" msgstr "prefix_chars" -#: ../../library/argparse.rst:539 +#: ../../library/argparse.rst:383 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. " "for options like ``+f`` or ``/foo``, may specify them using the " -"``prefix_chars=`` argument to the ArgumentParser constructor::" +"``prefix_chars=`` argument to the :class:`ArgumentParser` constructor::" msgstr "" -#: ../../library/argparse.rst:545 +#: ../../library/argparse.rst:389 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', prefix_chars='-+')\n" ">>> parser.add_argument('+f')\n" @@ -1035,18 +646,18 @@ msgstr "" ">>> parser.parse_args('+f X ++bar Y'.split())\n" "Namespace(bar='Y', f='X')" -#: ../../library/argparse.rst:551 +#: ../../library/argparse.rst:395 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:557 +#: ../../library/argparse.rst:401 msgid "fromfile_prefix_chars" msgstr "fromfile_prefix_chars" -#: ../../library/argparse.rst:559 +#: ../../library/argparse.rst:403 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 " @@ -1056,7 +667,7 @@ msgid "" "by the arguments they contain. For example::" msgstr "" -#: ../../library/argparse.rst:566 +#: ../../library/argparse.rst:410 msgid "" ">>> with open('args.txt', 'w', encoding=sys.getfilesystemencoding()) as fp:\n" "... fp.write('-f\\nbar')\n" @@ -1074,7 +685,7 @@ msgstr "" ">>> parser.parse_args(['-f', 'foo', '@args.txt'])\n" "Namespace(f='bar')" -#: ../../library/argparse.rst:574 +#: ../../library/argparse.rst:418 msgid "" "Arguments read from a file must by default be one per line (but see also :" "meth:`~ArgumentParser.convert_arg_line_to_args`) and are treated as if they " @@ -1084,32 +695,32 @@ msgid "" "f', 'bar']``." msgstr "" -#: ../../library/argparse.rst:580 +#: ../../library/argparse.rst:424 msgid "" ":class:`ArgumentParser` uses :term:`filesystem encoding and error handler` " "to read the file containing arguments." msgstr "" -#: ../../library/argparse.rst:583 +#: ../../library/argparse.rst:427 msgid "" "The ``fromfile_prefix_chars=`` argument defaults to ``None``, meaning that " "arguments will never be treated as file references." msgstr "" -#: ../../library/argparse.rst:586 +#: ../../library/argparse.rst:430 msgid "" ":class:`ArgumentParser` changed encoding and errors to read arguments files " "from default (e.g. :func:`locale.getpreferredencoding(False) ` and ``\"strict\"``) to :term:`filesystem encoding and " -"error handler`. Arguments file should be encoded in UTF-8 instead of ANSI " -"Codepage on Windows." +"getpreferredencoding>` and ``\"strict\"``) to the :term:`filesystem encoding " +"and error handler`. Arguments file should be encoded in UTF-8 instead of " +"ANSI Codepage on Windows." msgstr "" -#: ../../library/argparse.rst:594 +#: ../../library/argparse.rst:438 msgid "argument_default" msgstr "argument_default" -#: ../../library/argparse.rst:596 +#: ../../library/argparse.rst:440 msgid "" "Generally, argument defaults are specified either by passing a default to :" "meth:`~ArgumentParser.add_argument` or by calling the :meth:`~ArgumentParser." @@ -1121,7 +732,7 @@ msgid "" "supply ``argument_default=SUPPRESS``::" msgstr "" -#: ../../library/argparse.rst:605 +#: ../../library/argparse.rst:449 msgid "" ">>> parser = argparse.ArgumentParser(argument_default=argparse.SUPPRESS)\n" ">>> parser.add_argument('--foo')\n" @@ -1139,22 +750,22 @@ msgstr "" ">>> parser.parse_args([])\n" "Namespace()" -#: ../../library/argparse.rst:616 +#: ../../library/argparse.rst:460 msgid "allow_abbrev" msgstr "allow_abbrev" -#: ../../library/argparse.rst:618 +#: ../../library/argparse.rst:462 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:622 +#: ../../library/argparse.rst:466 msgid "This feature can be disabled by setting ``allow_abbrev`` to ``False``::" msgstr "" -#: ../../library/argparse.rst:624 +#: ../../library/argparse.rst:468 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', allow_abbrev=False)\n" ">>> parser.add_argument('--foobar', action='store_true')\n" @@ -1170,11 +781,11 @@ msgstr "" "usage: PROG [-h] [--foobar] [--foonley]\n" "PROG: error: unrecognized arguments: --foon" -#: ../../library/argparse.rst:635 +#: ../../library/argparse.rst:479 msgid "conflict_handler" msgstr "conflict_handler" -#: ../../library/argparse.rst:637 +#: ../../library/argparse.rst:481 msgid "" ":class:`ArgumentParser` objects do not allow two actions with the same " "option string. By default, :class:`ArgumentParser` objects raise an " @@ -1182,7 +793,7 @@ msgid "" "that is already in use::" msgstr "" -#: ../../library/argparse.rst:642 +#: ../../library/argparse.rst:486 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-f', '--foo', help='old foo help')\n" @@ -1198,7 +809,7 @@ msgstr "" " ..\n" "ArgumentError: argument --foo: conflicting option string(s): --foo" -#: ../../library/argparse.rst:649 +#: ../../library/argparse.rst:493 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 " @@ -1206,7 +817,7 @@ msgid "" "of :class:`ArgumentParser`::" msgstr "" -#: ../../library/argparse.rst:654 +#: ../../library/argparse.rst:498 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', " "conflict_handler='resolve')\n" @@ -1232,7 +843,7 @@ msgstr "" " -f FOO old foo help\n" " --foo FOO new foo help" -#: ../../library/argparse.rst:665 +#: ../../library/argparse.rst:509 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/--" @@ -1240,47 +851,25 @@ msgid "" "option string was overridden." msgstr "" -#: ../../library/argparse.rst:672 +#: ../../library/argparse.rst:516 msgid "add_help" msgstr "add_help" -#: ../../library/argparse.rst:674 +#: ../../library/argparse.rst:518 msgid "" -"By default, ArgumentParser objects add an option which simply displays the " -"parser's help message. For example, consider a file named ``myprogram.py`` " -"containing the following code::" +"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:683 -msgid "" -"If ``-h`` or ``--help`` is supplied at the command line, the ArgumentParser " -"help will be printed:" -msgstr "" - -#: ../../library/argparse.rst:686 -msgid "" -"$ python myprogram.py --help\n" -"usage: myprogram.py [-h] [--foo FOO]\n" -"\n" -"options:\n" -" -h, --help show this help message and exit\n" -" --foo FOO foo help" -msgstr "" -"$ python myprogram.py --help\n" -"usage: myprogram.py [-h] [--foo FOO]\n" -"\n" -"options:\n" -" -h, --help show this help message and exit\n" -" --foo FOO foo help" - -#: ../../library/argparse.rst:695 +#: ../../library/argparse.rst:522 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:699 +#: ../../library/argparse.rst:526 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', add_help=False)\n" ">>> parser.add_argument('--foo', help='foo help')\n" @@ -1298,7 +887,7 @@ msgstr "" "options:\n" " --foo FOO foo help" -#: ../../library/argparse.rst:707 +#: ../../library/argparse.rst:534 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 ``-" @@ -1306,7 +895,7 @@ msgid "" "in ``prefix_chars`` is used to prefix the help options::" msgstr "" -#: ../../library/argparse.rst:713 +#: ../../library/argparse.rst:540 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', prefix_chars='+/')\n" ">>> parser.print_help()\n" @@ -1322,24 +911,24 @@ msgstr "" "options:\n" " +h, ++help show this help message and exit" -#: ../../library/argparse.rst:722 +#: ../../library/argparse.rst:549 msgid "exit_on_error" msgstr "exit_on_error" -#: ../../library/argparse.rst:724 +#: ../../library/argparse.rst:551 msgid "" "Normally, when you pass an invalid argument list to the :meth:" "`~ArgumentParser.parse_args` method of an :class:`ArgumentParser`, it will " -"exit with error info." +"print a *message* to :data:`sys.stderr` and exit with a status code of 2." msgstr "" -#: ../../library/argparse.rst:727 +#: ../../library/argparse.rst:555 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:730 +#: ../../library/argparse.rst:558 msgid "" ">>> parser = argparse.ArgumentParser(exit_on_error=False)\n" ">>> parser.add_argument('--integers', type=int)\n" @@ -1365,81 +954,81 @@ msgstr "" "...\n" "Catching an argumentError" -#: ../../library/argparse.rst:744 +#: ../../library/argparse.rst:572 msgid "The add_argument() method" msgstr "" -#: ../../library/argparse.rst:750 +#: ../../library/argparse.rst:578 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:753 +#: ../../library/argparse.rst:581 msgid "" -"`name or flags`_ - Either a name or a list of option strings, e.g. ``foo`` " -"or ``-f, --foo``." +"`name or flags`_ - Either a name or a list of option strings, e.g. ``'foo'`` " +"or ``'-f', '--foo'``." msgstr "" -#: ../../library/argparse.rst:756 +#: ../../library/argparse.rst:584 msgid "" "action_ - The basic type of action to be taken when this argument is " "encountered at the command line." msgstr "" -#: ../../library/argparse.rst:759 +#: ../../library/argparse.rst:587 msgid "nargs_ - The number of command-line arguments that should be consumed." msgstr "" -#: ../../library/argparse.rst:761 +#: ../../library/argparse.rst:589 msgid "" "const_ - A constant value required by some action_ and nargs_ selections." msgstr "" -#: ../../library/argparse.rst:763 +#: ../../library/argparse.rst:591 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:766 +#: ../../library/argparse.rst:594 msgid "" "type_ - The type to which the command-line argument should be converted." msgstr "" -#: ../../library/argparse.rst:768 +#: ../../library/argparse.rst:596 msgid "choices_ - A sequence of the allowable values for the argument." msgstr "" -#: ../../library/argparse.rst:770 +#: ../../library/argparse.rst:598 msgid "" "required_ - Whether or not the command-line option may be omitted (optionals " "only)." msgstr "" -#: ../../library/argparse.rst:773 +#: ../../library/argparse.rst:601 msgid "help_ - A brief description of what the argument does." msgstr "" -#: ../../library/argparse.rst:775 +#: ../../library/argparse.rst:603 msgid "metavar_ - A name for the argument in usage messages." msgstr "" -#: ../../library/argparse.rst:777 +#: ../../library/argparse.rst:605 msgid "" "dest_ - The name of the attribute to be added to the object returned by :" "meth:`parse_args`." msgstr "" -#: ../../library/argparse.rst:780 +#: ../../library/argparse.rst:608 msgid "deprecated_ - Whether or not use of the argument is deprecated." msgstr "" -#: ../../library/argparse.rst:788 +#: ../../library/argparse.rst:616 msgid "name or flags" msgstr "" -#: ../../library/argparse.rst:790 +#: ../../library/argparse.rst:618 msgid "" "The :meth:`~ArgumentParser.add_argument` method must know whether an " "optional argument, like ``-f`` or ``--foo``, or a positional argument, like " @@ -1448,30 +1037,30 @@ msgid "" "or a simple argument name." msgstr "" -#: ../../library/argparse.rst:796 +#: ../../library/argparse.rst:624 msgid "For example, an optional argument could be created like::" msgstr "" -#: ../../library/argparse.rst:798 +#: ../../library/argparse.rst:626 msgid ">>> parser.add_argument('-f', '--foo')" msgstr ">>> parser.add_argument('-f', '--foo')" -#: ../../library/argparse.rst:800 +#: ../../library/argparse.rst:628 msgid "while a positional argument could be created like::" msgstr "" -#: ../../library/argparse.rst:802 +#: ../../library/argparse.rst:630 msgid ">>> parser.add_argument('bar')" msgstr ">>> parser.add_argument('bar')" -#: ../../library/argparse.rst:804 +#: ../../library/argparse.rst:632 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:808 +#: ../../library/argparse.rst:636 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-f', '--foo')\n" @@ -1495,11 +1084,11 @@ msgstr "" "usage: PROG [-h] [-f FOO] bar\n" "PROG: error: the following arguments are required: bar" -#: ../../library/argparse.rst:823 +#: ../../library/argparse.rst:651 msgid "action" msgstr "" -#: ../../library/argparse.rst:825 +#: ../../library/argparse.rst:653 msgid "" ":class:`ArgumentParser` objects associate command-line arguments with " "actions. These actions can do just about anything with the command-line " @@ -1509,25 +1098,13 @@ msgid "" "be handled. The supplied actions are:" msgstr "" -#: ../../library/argparse.rst:831 +#: ../../library/argparse.rst:659 msgid "" "``'store'`` - This just stores the argument's value. This is the default " -"action. For example::" -msgstr "" - -#: ../../library/argparse.rst:834 -msgid "" -">>> parser = argparse.ArgumentParser()\n" -">>> parser.add_argument('--foo')\n" -">>> parser.parse_args('--foo 1'.split())\n" -"Namespace(foo='1')" +"action." msgstr "" -">>> parser = argparse.ArgumentParser()\n" -">>> parser.add_argument('--foo')\n" -">>> parser.parse_args('--foo 1'.split())\n" -"Namespace(foo='1')" -#: ../../library/argparse.rst:839 +#: ../../library/argparse.rst:662 msgid "" "``'store_const'`` - This stores the value specified by the const_ keyword " "argument; note that the const_ keyword argument defaults to ``None``. The " @@ -1535,7 +1112,7 @@ msgid "" "specify some sort of flag. For example::" msgstr "" -#: ../../library/argparse.rst:844 +#: ../../library/argparse.rst:667 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', action='store_const', const=42)\n" @@ -1547,15 +1124,15 @@ msgstr "" ">>> parser.parse_args(['--foo'])\n" "Namespace(foo=42)" -#: ../../library/argparse.rst:849 +#: ../../library/argparse.rst:672 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. For example::" +"``True`` respectively::" msgstr "" -#: ../../library/argparse.rst:854 +#: ../../library/argparse.rst:677 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', action='store_true')\n" @@ -1571,7 +1148,7 @@ msgstr "" ">>> parser.parse_args('--foo --bar'.split())\n" "Namespace(foo=True, bar=False, baz=True)" -#: ../../library/argparse.rst:861 +#: ../../library/argparse.rst:684 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 " @@ -1580,7 +1157,7 @@ msgid "" "after those default values. Example usage::" msgstr "" -#: ../../library/argparse.rst:867 +#: ../../library/argparse.rst:690 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', action='append')\n" @@ -1592,7 +1169,7 @@ msgstr "" ">>> parser.parse_args('--foo 1 --foo 2'.split())\n" "Namespace(foo=['1', '2'])" -#: ../../library/argparse.rst:872 +#: ../../library/argparse.rst:695 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 " @@ -1601,7 +1178,7 @@ msgid "" "example::" msgstr "" -#: ../../library/argparse.rst:878 +#: ../../library/argparse.rst:701 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--str', dest='types', action='append_const', " @@ -1619,13 +1196,38 @@ msgstr "" ">>> parser.parse_args('--str --int'.split())\n" "Namespace(types=[, ])" -#: ../../library/argparse.rst:884 +#: ../../library/argparse.rst:707 +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::" +msgstr "" + +#: ../../library/argparse.rst:715 +msgid "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument(\"--foo\", action=\"extend\", nargs=\"+\", " +"type=str)\n" +">>> parser.parse_args([\"--foo\", \"f1\", \"--foo\", \"f2\", \"f3\", " +"\"f4\"])\n" +"Namespace(foo=['f1', 'f2', 'f3', 'f4'])" +msgstr "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument(\"--foo\", action=\"extend\", nargs=\"+\", " +"type=str)\n" +">>> parser.parse_args([\"--foo\", \"f1\", \"--foo\", \"f2\", \"f3\", " +"\"f4\"])\n" +"Namespace(foo=['f1', 'f2', 'f3', 'f4'])" + +#: ../../library/argparse.rst:722 msgid "" "``'count'`` - This counts the number of times a keyword argument occurs. For " "example, this is useful for increasing verbosity levels::" msgstr "" -#: ../../library/argparse.rst:887 +#: ../../library/argparse.rst:725 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--verbose', '-v', action='count', default=0)\n" @@ -1633,11 +1235,11 @@ msgid "" "Namespace(verbose=3)" msgstr "" -#: ../../library/argparse.rst:892 +#: ../../library/argparse.rst:730 msgid "Note, the *default* will be ``None`` unless explicitly set to *0*." msgstr "" -#: ../../library/argparse.rst:894 +#: ../../library/argparse.rst:732 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 " @@ -1645,14 +1247,14 @@ msgid "" "output is created." msgstr "" -#: ../../library/argparse.rst:899 +#: ../../library/argparse.rst:737 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:903 +#: ../../library/argparse.rst:741 msgid "" ">>> import argparse\n" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" @@ -1668,37 +1270,21 @@ msgstr "" ">>> parser.parse_args(['--version'])\n" "PROG 2.0" -#: ../../library/argparse.rst:909 +#: ../../library/argparse.rst:747 msgid "" -"``'extend'`` - This stores a list, and extends each argument value to the " -"list. Example usage::" +"Only actions that consume command-line arguments (e.g. ``'store'``, " +"``'append'`` or ``'extend'``) can be used with positional arguments." msgstr "" -#: ../../library/argparse.rst:913 +#: ../../library/argparse.rst:752 msgid "" -">>> parser = argparse.ArgumentParser()\n" -">>> parser.add_argument(\"--foo\", action=\"extend\", nargs=\"+\", " -"type=str)\n" -">>> parser.parse_args([\"--foo\", \"f1\", \"--foo\", \"f2\", \"f3\", " -"\"f4\"])\n" -"Namespace(foo=['f1', 'f2', 'f3', 'f4'])" -msgstr "" -">>> parser = argparse.ArgumentParser()\n" -">>> parser.add_argument(\"--foo\", action=\"extend\", nargs=\"+\", " -"type=str)\n" -">>> parser.parse_args([\"--foo\", \"f1\", \"--foo\", \"f2\", \"f3\", " -"\"f4\"])\n" -"Namespace(foo=['f1', 'f2', 'f3', 'f4'])" - -#: ../../library/argparse.rst:920 -msgid "" -"You may also specify an arbitrary action by passing an Action subclass or " -"other object that implements the same interface. The " -"``BooleanOptionalAction`` is available in ``argparse`` and adds support for " +"You may also specify an arbitrary action by passing an :class:`Action` " +"subclass or other object that implements the same interface. The :class:`!" +"BooleanOptionalAction` is available in :mod:`!argparse` and adds support for " "boolean actions such as ``--foo`` and ``--no-foo``::" msgstr "" -#: ../../library/argparse.rst:925 +#: ../../library/argparse.rst:757 msgid "" ">>> import argparse\n" ">>> parser = argparse.ArgumentParser()\n" @@ -1712,18 +1298,20 @@ msgstr "" ">>> parser.parse_args(['--no-foo'])\n" "Namespace(foo=False)" -#: ../../library/argparse.rst:933 +#: ../../library/argparse.rst:765 msgid "" "The recommended way to create a custom action is to extend :class:`Action`, " -"overriding the ``__call__`` method and optionally the ``__init__`` and " -"``format_usage`` methods." +"overriding the :meth:`!__call__` method and optionally the :meth:`!__init__` " +"and :meth:`!format_usage` methods. You can also register custom actions " +"using the :meth:`~ArgumentParser.register` method and reference them by " +"their registered name." msgstr "" -#: ../../library/argparse.rst:937 +#: ../../library/argparse.rst:770 msgid "An example of a custom action::" msgstr "" -#: ../../library/argparse.rst:939 +#: ../../library/argparse.rst:772 msgid "" ">>> class FooAction(argparse.Action):\n" "... def __init__(self, option_strings, dest, nargs=None, **kwargs):\n" @@ -1744,29 +1332,30 @@ msgid "" "Namespace(bar='1', foo='2')" msgstr "" -#: ../../library/argparse.rst:957 +#: ../../library/argparse.rst:790 msgid "For more details, see :class:`Action`." msgstr "" -#: ../../library/argparse.rst:963 +#: ../../library/argparse.rst:796 msgid "nargs" msgstr "" -#: ../../library/argparse.rst:965 +#: ../../library/argparse.rst:798 msgid "" -"ArgumentParser objects usually associate a single command-line argument with " -"a single action to be taken. The ``nargs`` keyword argument associates a " -"different number of command-line arguments with a single action. See also :" -"ref:`specifying-ambiguous-arguments`. The supported values are:" +":class:`ArgumentParser` objects usually associate a single command-line " +"argument with a single action to be taken. The ``nargs`` keyword argument " +"associates a different number of command-line arguments with a single " +"action. See also :ref:`specifying-ambiguous-arguments`. The supported values " +"are:" msgstr "" -#: ../../library/argparse.rst:970 +#: ../../library/argparse.rst:803 msgid "" "``N`` (an integer). ``N`` arguments from the command line will be gathered " "together into a list. For example::" msgstr "" -#: ../../library/argparse.rst:973 +#: ../../library/argparse.rst:806 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', nargs=2)\n" @@ -1780,13 +1369,13 @@ msgstr "" ">>> parser.parse_args('c --foo a b'.split())\n" "Namespace(bar=['c'], foo=['a', 'b'])" -#: ../../library/argparse.rst:979 +#: ../../library/argparse.rst:812 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:984 +#: ../../library/argparse.rst:817 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 " @@ -1796,7 +1385,7 @@ msgid "" "produced. Some examples to illustrate this::" msgstr "" -#: ../../library/argparse.rst:991 +#: ../../library/argparse.rst:824 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', nargs='?', const='c', default='d')\n" @@ -1818,13 +1407,13 @@ msgstr "" ">>> parser.parse_args([])\n" "Namespace(bar='d', foo='d')" -#: ../../library/argparse.rst:1001 +#: ../../library/argparse.rst:834 msgid "" "One of the more common uses of ``nargs='?'`` is to allow optional input and " "output files::" msgstr "" -#: ../../library/argparse.rst:1004 +#: ../../library/argparse.rst:837 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('infile', nargs='?', type=argparse.FileType('r'),\n" @@ -1850,7 +1439,7 @@ msgstr "" "Namespace(infile=<_io.TextIOWrapper name='' encoding='UTF-8'>,\n" " outfile=<_io.TextIOWrapper name='' encoding='UTF-8'>)" -#: ../../library/argparse.rst:1018 +#: ../../library/argparse.rst:851 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 " @@ -1858,7 +1447,7 @@ msgid "" "``nargs='*'`` is possible. For example::" msgstr "" -#: ../../library/argparse.rst:1023 +#: ../../library/argparse.rst:856 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', nargs='*')\n" @@ -1874,14 +1463,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:1032 +#: ../../library/argparse.rst:865 msgid "" "``'+'``. Just like ``'*'``, all command-line args 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:1036 +#: ../../library/argparse.rst:869 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('foo', nargs='+')\n" @@ -1899,19 +1488,20 @@ msgstr "" "usage: PROG [-h] foo [foo ...]\n" "PROG: error: the following arguments are required: foo" -#: ../../library/argparse.rst:1044 +#: ../../library/argparse.rst:877 msgid "" "If the ``nargs`` keyword argument is not provided, the number of arguments " "consumed is determined by the action_. Generally this means a single " "command-line argument will be consumed and a single item (not a list) will " -"be produced." +"be produced. Actions that do not consume command-line arguments (e.g. " +"``'store_const'``) set ``nargs=0``." msgstr "" -#: ../../library/argparse.rst:1052 +#: ../../library/argparse.rst:887 msgid "const" msgstr "" -#: ../../library/argparse.rst:1054 +#: ../../library/argparse.rst:889 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 " @@ -1919,7 +1509,7 @@ msgid "" "common uses of it are:" msgstr "" -#: ../../library/argparse.rst:1058 +#: ../../library/argparse.rst:893 msgid "" "When :meth:`~ArgumentParser.add_argument` is called with " "``action='store_const'`` or ``action='append_const'``. These actions add " @@ -1929,7 +1519,7 @@ msgid "" "receive a default value of ``None``." msgstr "" -#: ../../library/argparse.rst:1066 +#: ../../library/argparse.rst:901 msgid "" "When :meth:`~ArgumentParser.add_argument` is called with option strings " "(like ``-f`` or ``--foo``) and ``nargs='?'``. This creates an optional " @@ -1939,17 +1529,17 @@ msgid "" "to be ``None`` instead. See the nargs_ description for examples." msgstr "" -#: ../../library/argparse.rst:1073 +#: ../../library/argparse.rst:908 msgid "" "``const=None`` by default, including when ``action='append_const'`` or " "``action='store_const'``." msgstr "" -#: ../../library/argparse.rst:1080 +#: ../../library/argparse.rst:915 msgid "default" msgstr "" -#: ../../library/argparse.rst:1082 +#: ../../library/argparse.rst:917 msgid "" "All optional arguments and some positional arguments may be omitted at the " "command line. The ``default`` keyword argument of :meth:`~ArgumentParser." @@ -1959,7 +1549,7 @@ msgid "" "command line::" msgstr "" -#: ../../library/argparse.rst:1089 +#: ../../library/argparse.rst:924 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', default=42)\n" @@ -1975,13 +1565,13 @@ msgstr "" ">>> parser.parse_args([])\n" "Namespace(foo=42)" -#: ../../library/argparse.rst:1096 +#: ../../library/argparse.rst:931 msgid "" "If the target namespace already has an attribute set, the action *default* " -"will not over write it::" +"will not overwrite it::" msgstr "" -#: ../../library/argparse.rst:1099 +#: ../../library/argparse.rst:934 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', default=42)\n" @@ -1993,7 +1583,7 @@ msgstr "" ">>> parser.parse_args([], namespace=argparse.Namespace(foo=101))\n" "Namespace(foo=101)" -#: ../../library/argparse.rst:1104 +#: ../../library/argparse.rst:939 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_ " @@ -2001,7 +1591,7 @@ msgid "" "`Namespace` return value. Otherwise, the parser uses the value as is::" msgstr "" -#: ../../library/argparse.rst:1109 +#: ../../library/argparse.rst:944 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--length', default='10', type=int)\n" @@ -2015,13 +1605,13 @@ msgstr "" ">>> parser.parse_args()\n" "Namespace(length=10, width=10.5)" -#: ../../library/argparse.rst:1115 +#: ../../library/argparse.rst:950 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:1118 +#: ../../library/argparse.rst:953 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('foo', nargs='?', default=42)\n" @@ -2037,13 +1627,20 @@ msgstr "" ">>> parser.parse_args([])\n" "Namespace(foo=42)" -#: ../../library/argparse.rst:1126 +#: ../../library/argparse.rst:960 +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:964 msgid "" "Providing ``default=argparse.SUPPRESS`` causes no attribute to be added if " "the command-line argument was not present::" msgstr "" -#: ../../library/argparse.rst:1129 +#: ../../library/argparse.rst:967 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', default=argparse.SUPPRESS)\n" @@ -2059,11 +1656,11 @@ msgstr "" ">>> parser.parse_args(['--foo', '1'])\n" "Namespace(foo='1')" -#: ../../library/argparse.rst:1140 +#: ../../library/argparse.rst:978 msgid "type" msgstr "" -#: ../../library/argparse.rst:1142 +#: ../../library/argparse.rst:980 msgid "" "By default, the parser reads command-line arguments in as simple strings. " "However, quite often the command-line string should instead be interpreted " @@ -2072,25 +1669,27 @@ msgid "" "checking and type conversions to be performed." msgstr "" -#: ../../library/argparse.rst:1148 +#: ../../library/argparse.rst:986 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:1151 +#: ../../library/argparse.rst:989 msgid "" -"The argument to ``type`` can be any callable that accepts a single string. " -"If the function raises :exc:`ArgumentTypeError`, :exc:`TypeError`, or :exc:" +"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 " +"function raises :exc:`ArgumentTypeError`, :exc:`TypeError`, or :exc:" "`ValueError`, the exception is caught and a nicely formatted error message " -"is displayed. No other exception types are handled." +"is displayed. Other exception types are not handled." msgstr "" -#: ../../library/argparse.rst:1156 +#: ../../library/argparse.rst:995 msgid "Common built-in types and functions can be used as type converters:" msgstr "" -#: ../../library/argparse.rst:1158 +#: ../../library/argparse.rst:997 +#, fuzzy msgid "" "import argparse\n" "import pathlib\n" @@ -2100,7 +1699,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('source_file', type=open)\n" "parser.add_argument('dest_file', type=argparse.FileType('w', " "encoding='latin-1'))\n" "parser.add_argument('datapath', type=pathlib.Path)" @@ -2118,11 +1716,11 @@ msgstr "" "encoding='latin-1'))\n" "parser.add_argument('datapath', type=pathlib.Path)" -#: ../../library/argparse.rst:1172 +#: ../../library/argparse.rst:1010 msgid "User defined functions can be used as well:" msgstr "" -#: ../../library/argparse.rst:1174 +#: ../../library/argparse.rst:1012 msgid "" ">>> def hyphenated(string):\n" "... return '-'.join([word[:4] for word in string.casefold().split()])\n" @@ -2140,14 +1738,14 @@ msgstr "" ">>> parser.parse_args(['\"The Tale of Two Cities\"'])\n" "Namespace(short_title='\"the-tale-of-two-citi')" -#: ../../library/argparse.rst:1184 +#: ../../library/argparse.rst:1022 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:1188 +#: ../../library/argparse.rst:1026 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 " @@ -2155,7 +1753,7 @@ msgid "" "management should be done downstream after the arguments are parsed." msgstr "" -#: ../../library/argparse.rst:1193 +#: ../../library/argparse.rst:1031 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." @@ -2163,26 +1761,27 @@ msgid "" "exception would not be handled at all." msgstr "" -#: ../../library/argparse.rst:1198 +#: ../../library/argparse.rst:1036 msgid "" "Even :class:`~argparse.FileType` has its limitations for use with the " -"``type`` keyword. If one argument uses *FileType* and then a subsequent " -"argument fails, an error is reported but the file is not automatically " -"closed. 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." +"``type`` keyword. If one argument uses :class:`~argparse.FileType` and then " +"a subsequent argument fails, an error is reported but the file is not " +"automatically closed. 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:1204 +#: ../../library/argparse.rst:1043 msgid "" "For type checkers that simply check against a fixed set of values, consider " "using the choices_ keyword instead." msgstr "" -#: ../../library/argparse.rst:1211 +#: ../../library/argparse.rst:1050 msgid "choices" msgstr "" -#: ../../library/argparse.rst:1213 +#: ../../library/argparse.rst:1052 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* " @@ -2191,7 +1790,7 @@ msgid "" "be displayed if the argument was not one of the acceptable values::" msgstr "" -#: ../../library/argparse.rst:1219 +#: ../../library/argparse.rst:1058 msgid "" ">>> parser = argparse.ArgumentParser(prog='game.py')\n" ">>> parser.add_argument('move', choices=['rock', 'paper', 'scissors'])\n" @@ -2211,44 +1810,26 @@ msgstr "" "game.py: error: argument move: invalid choice: 'fire' (choose from 'rock',\n" "'paper', 'scissors')" -#: ../../library/argparse.rst:1228 +#: ../../library/argparse.rst:1067 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::" +"sequence should match the type_ specified." msgstr "" -#: ../../library/argparse.rst:1232 -msgid "" -">>> parser = argparse.ArgumentParser(prog='doors.py')\n" -">>> parser.add_argument('door', type=int, choices=range(1, 4))\n" -">>> print(parser.parse_args(['3']))\n" -"Namespace(door=3)\n" -">>> parser.parse_args(['4'])\n" -"usage: doors.py [-h] {1,2,3}\n" -"doors.py: error: argument door: invalid choice: 4 (choose from 1, 2, 3)" -msgstr "" -">>> parser = argparse.ArgumentParser(prog='doors.py')\n" -">>> parser.add_argument('door', type=int, choices=range(1, 4))\n" -">>> print(parser.parse_args(['3']))\n" -"Namespace(door=3)\n" -">>> parser.parse_args(['4'])\n" -"usage: doors.py [-h] {1,2,3}\n" -"doors.py: error: argument door: invalid choice: 4 (choose from 1, 2, 3)" - -#: ../../library/argparse.rst:1240 +#: ../../library/argparse.rst:1071 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:1243 +#: ../../library/argparse.rst:1074 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:1246 +#: ../../library/argparse.rst:1077 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 " @@ -2256,19 +1837,19 @@ msgid "" "are many choices), just specify an explicit metavar_." msgstr "" -#: ../../library/argparse.rst:1255 +#: ../../library/argparse.rst:1086 msgid "required" msgstr "" -#: ../../library/argparse.rst:1257 +#: ../../library/argparse.rst:1088 msgid "" -"In general, the :mod:`argparse` module assumes that flags like ``-f`` and " +"In general, the :mod:`!argparse` module assumes that flags like ``-f`` and " "``--bar`` indicate *optional* arguments, which can always be omitted at the " "command line. To make an option *required*, ``True`` can be specified for " "the ``required=`` keyword argument to :meth:`~ArgumentParser.add_argument`::" msgstr "" -#: ../../library/argparse.rst:1262 +#: ../../library/argparse.rst:1093 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', required=True)\n" @@ -2286,64 +1867,32 @@ msgstr "" "usage: [-h] --foo FOO\n" ": error: the following arguments are required: --foo" -#: ../../library/argparse.rst:1270 +#: ../../library/argparse.rst:1101 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:1276 +#: ../../library/argparse.rst:1107 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:1283 +#: ../../library/argparse.rst:1114 msgid "help" msgstr "幫助" -#: ../../library/argparse.rst:1285 +#: ../../library/argparse.rst:1116 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`` " "at the command line), these ``help`` descriptions will be displayed with " -"each argument::" +"each argument." msgstr "" -#: ../../library/argparse.rst:1290 -msgid "" -">>> parser = argparse.ArgumentParser(prog='frobble')\n" -">>> parser.add_argument('--foo', action='store_true',\n" -"... help='foo the bars before frobbling')\n" -">>> parser.add_argument('bar', nargs='+',\n" -"... help='one of the bars to be frobbled')\n" -">>> parser.parse_args(['-h'])\n" -"usage: frobble [-h] [--foo] bar [bar ...]\n" -"\n" -"positional arguments:\n" -" bar one of the bars to be frobbled\n" -"\n" -"options:\n" -" -h, --help show this help message and exit\n" -" --foo foo the bars before frobbling" -msgstr "" -">>> parser = argparse.ArgumentParser(prog='frobble')\n" -">>> parser.add_argument('--foo', action='store_true',\n" -"... help='foo the bars before frobbling')\n" -">>> parser.add_argument('bar', nargs='+',\n" -"... help='one of the bars to be frobbled')\n" -">>> parser.parse_args(['-h'])\n" -"usage: frobble [-h] [--foo] bar [bar ...]\n" -"\n" -"positional arguments:\n" -" bar one of the bars to be frobbled\n" -"\n" -"options:\n" -" -h, --help show this help message and exit\n" -" --foo foo the bars before frobbling" - -#: ../../library/argparse.rst:1305 +#: ../../library/argparse.rst:1121 msgid "" "The ``help`` strings can include various format specifiers to avoid " "repetition of things like the program name or the argument default_. The " @@ -2352,7 +1901,7 @@ msgid "" "``%(type)s``, etc.::" msgstr "" -#: ../../library/argparse.rst:1310 +#: ../../library/argparse.rst:1126 msgid "" ">>> parser = argparse.ArgumentParser(prog='frobble')\n" ">>> parser.add_argument('bar', nargs='?', type=int, default=42,\n" @@ -2378,19 +1927,19 @@ msgstr "" "options:\n" " -h, --help show this help message and exit" -#: ../../library/argparse.rst:1322 +#: ../../library/argparse.rst:1138 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:1325 +#: ../../library/argparse.rst:1141 msgid "" -":mod:`argparse` supports silencing the help entry for certain options, by " +":mod:`!argparse` supports silencing the help entry for certain options, by " "setting the ``help`` value to ``argparse.SUPPRESS``::" msgstr "" -#: ../../library/argparse.rst:1328 +#: ../../library/argparse.rst:1144 msgid "" ">>> parser = argparse.ArgumentParser(prog='frobble')\n" ">>> parser.add_argument('--foo', help=argparse.SUPPRESS)\n" @@ -2408,23 +1957,23 @@ msgstr "" "options:\n" " -h, --help show this help message and exit" -#: ../../library/argparse.rst:1340 +#: ../../library/argparse.rst:1156 msgid "metavar" msgstr "" -#: ../../library/argparse.rst:1342 +#: ../../library/argparse.rst:1158 msgid "" "When :class:`ArgumentParser` generates help messages, it needs some way to " -"refer to each expected argument. By default, ArgumentParser objects use the " -"dest_ value as the \"name\" of each object. By default, for positional " -"argument actions, the dest_ value is used directly, and for optional " -"argument actions, the dest_ value is uppercased. So, a single positional " -"argument with ``dest='bar'`` will be referred to as ``bar``. A single " -"optional argument ``--foo`` that should be followed by a single command-line " -"argument will be referred to as ``FOO``. An example::" +"refer to each expected argument. By default, :class:`!ArgumentParser` " +"objects use the dest_ value as the \"name\" of each object. By default, for " +"positional argument actions, the dest_ value is used directly, and for " +"optional argument actions, the dest_ value is uppercased. So, a single " +"positional argument with ``dest='bar'`` will be referred to as ``bar``. A " +"single optional argument ``--foo`` that should be followed by a single " +"command-line argument will be referred to as ``FOO``. An example::" msgstr "" -#: ../../library/argparse.rst:1351 +#: ../../library/argparse.rst:1167 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo')\n" @@ -2456,11 +2005,11 @@ msgstr "" " -h, --help show this help message and exit\n" " --foo FOO" -#: ../../library/argparse.rst:1366 +#: ../../library/argparse.rst:1182 msgid "An alternative name can be specified with ``metavar``::" msgstr "" -#: ../../library/argparse.rst:1368 +#: ../../library/argparse.rst:1184 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', metavar='YYY')\n" @@ -2492,21 +2041,21 @@ msgstr "" " -h, --help show this help message and exit\n" " --foo YYY" -#: ../../library/argparse.rst:1383 +#: ../../library/argparse.rst:1199 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:1387 +#: ../../library/argparse.rst:1203 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:1391 +#: ../../library/argparse.rst:1207 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-x', nargs=2)\n" @@ -2530,11 +2079,11 @@ msgstr "" " -x X X\n" " --foo bar baz" -#: ../../library/argparse.rst:1406 +#: ../../library/argparse.rst:1222 msgid "dest" msgstr "" -#: ../../library/argparse.rst:1408 +#: ../../library/argparse.rst:1224 msgid "" "Most :class:`ArgumentParser` actions add some value as an attribute of the " "object returned by :meth:`~ArgumentParser.parse_args`. The name of this " @@ -2544,7 +2093,7 @@ msgid "" "add_argument`::" msgstr "" -#: ../../library/argparse.rst:1415 +#: ../../library/argparse.rst:1231 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('bar')\n" @@ -2556,7 +2105,7 @@ msgstr "" ">>> parser.parse_args(['XXX'])\n" "Namespace(bar='XXX')" -#: ../../library/argparse.rst:1420 +#: ../../library/argparse.rst:1236 msgid "" "For optional argument actions, the value of ``dest`` is normally inferred " "from the option strings. :class:`ArgumentParser` generates the value of " @@ -2568,7 +2117,7 @@ msgid "" "below illustrate this behavior::" msgstr "" -#: ../../library/argparse.rst:1429 +#: ../../library/argparse.rst:1245 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('-f', '--foo-bar', '--foo')\n" @@ -2586,11 +2135,11 @@ msgstr "" ">>> parser.parse_args('--foo 1 -y 2'.split())\n" "Namespace(foo_bar='1', x='2')" -#: ../../library/argparse.rst:1437 +#: ../../library/argparse.rst:1253 msgid "``dest`` allows a custom attribute name to be provided::" msgstr "" -#: ../../library/argparse.rst:1439 +#: ../../library/argparse.rst:1255 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', dest='bar')\n" @@ -2602,11 +2151,11 @@ msgstr "" ">>> parser.parse_args('--foo XXX'.split())\n" "Namespace(bar='XXX')" -#: ../../library/argparse.rst:1448 +#: ../../library/argparse.rst:1264 msgid "deprecated" msgstr "" -#: ../../library/argparse.rst:1450 +#: ../../library/argparse.rst:1266 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 " @@ -2614,10 +2163,10 @@ msgid "" "argument of :meth:`~ArgumentParser.add_argument`, which defaults to " "``False``, specifies if the argument is deprecated and will be removed in " "the future. For arguments, if ``deprecated`` is ``True``, then a warning " -"will be printed to standard error when the argument is used::" +"will be printed to :data:`sys.stderr` when the argument is used::" msgstr "" -#: ../../library/argparse.rst:1460 +#: ../../library/argparse.rst:1276 #, fuzzy msgid "" ">>> import argparse\n" @@ -2625,7 +2174,7 @@ msgid "" ">>> parser.add_argument('--legs', default=0, type=int, deprecated=True)\n" ">>> parser.parse_args([])\n" "Namespace(legs=0)\n" -">>> parser.parse_args(['--legs', '4']) \n" +">>> parser.parse_args(['--legs', '4'])\n" "snake.py: warning: option '--legs' is deprecated\n" "Namespace(legs=4)" msgstr "" @@ -2636,120 +2185,124 @@ msgstr "" ">>> parser.parse_args(['--foo', '1'])\n" "Namespace(foo='1')" -#: ../../library/argparse.rst:1473 +#: ../../library/argparse.rst:1289 msgid "Action classes" msgstr "" -#: ../../library/argparse.rst:1475 +#: ../../library/argparse.rst:1291 msgid "" -"Action classes implement the Action API, a callable which returns a callable " -"which processes arguments from the command-line. Any object which follows " -"this API may be passed as the ``action`` parameter to :meth:`~ArgumentParser." -"add_argument`." +":class:`!Action` classes implement the Action API, a callable which returns " +"a callable which processes arguments from the command-line. Any object which " +"follows this API may be passed as the ``action`` parameter to :meth:" +"`~ArgumentParser.add_argument`." msgstr "" -#: ../../library/argparse.rst:1484 +#: ../../library/argparse.rst:1300 msgid "" -"Action objects are used by an ArgumentParser to represent the information " -"needed to parse a single argument from one or more strings from the command " -"line. The Action class must accept the two positional arguments plus any " -"keyword arguments passed to :meth:`ArgumentParser.add_argument` except for " -"the ``action`` itself." +":class:`!Action` objects are used by an :class:`ArgumentParser` to represent " +"the information needed to parse a single argument from one or more strings " +"from the command line. The :class:`!Action` class must accept the two " +"positional arguments plus any keyword arguments passed to :meth:" +"`ArgumentParser.add_argument` except for the ``action`` itself." msgstr "" -#: ../../library/argparse.rst:1490 +#: ../../library/argparse.rst:1306 msgid "" -"Instances of Action (or return value of any callable to the ``action`` " -"parameter) should have attributes \"dest\", \"option_strings\", \"default\", " -"\"type\", \"required\", \"help\", etc. defined. The easiest way to ensure " -"these attributes are defined is to call ``Action.__init__``." +"Instances of :class:`!Action` (or return value of any callable to the " +"``action`` parameter) should have attributes :attr:`!dest`, :attr:`!" +"option_strings`, :attr:`!default`, :attr:`!type`, :attr:`!required`, :attr:`!" +"help`, etc. defined. The easiest way to ensure these attributes are defined " +"is to call :meth:`!Action.__init__`." msgstr "" -#: ../../library/argparse.rst:1495 +#: ../../library/argparse.rst:1314 msgid "" -"Action instances should be callable, so subclasses must override the " -"``__call__`` method, which should accept four parameters:" +":class:`!Action` instances should be callable, so subclasses must override " +"the :meth:`!__call__` method, which should accept four parameters:" msgstr "" -#: ../../library/argparse.rst:1498 -msgid "``parser`` - The ArgumentParser object which contains this action." +#: ../../library/argparse.rst:1317 +msgid "" +"*parser* - The :class:`ArgumentParser` object which contains this action." msgstr "" -#: ../../library/argparse.rst:1500 +#: ../../library/argparse.rst:1319 msgid "" -"``namespace`` - The :class:`Namespace` object that will be returned by :meth:" +"*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:1504 +#: ../../library/argparse.rst:1323 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`." +"*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:1508 +#: ../../library/argparse.rst:1327 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." +"*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:1512 +#: ../../library/argparse.rst:1331 msgid "" -"The ``__call__`` method may perform arbitrary actions, but will typically " -"set attributes on the ``namespace`` based on ``dest`` and ``values``." +"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:1515 +#: ../../library/argparse.rst:1336 msgid "" -"Action subclasses can define a ``format_usage`` method that takes no " -"argument and return a string which will be used when printing the usage of " -"the program. If such method is not provided, a sensible default will be used." +":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 " +"usage of the program. If such method is not provided, a sensible default " +"will be used." msgstr "" -#: ../../library/argparse.rst:1520 +#: ../../library/argparse.rst:1342 msgid "The parse_args() method" msgstr "" -#: ../../library/argparse.rst:1524 +#: ../../library/argparse.rst:1346 msgid "" "Convert argument strings to objects and assign them as attributes of the " "namespace. Return the populated namespace." msgstr "" -#: ../../library/argparse.rst:1527 +#: ../../library/argparse.rst:1349 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." +"created and how they are assigned. See the documentation for :meth:`!" +"add_argument` for details." msgstr "" -#: ../../library/argparse.rst:1531 +#: ../../library/argparse.rst:1353 msgid "" "args_ - List of strings to parse. The default is taken from :data:`sys." "argv`." msgstr "" -#: ../../library/argparse.rst:1534 +#: ../../library/argparse.rst:1356 msgid "" "namespace_ - An object to take the attributes. The default is a new empty :" "class:`Namespace` object." msgstr "" -#: ../../library/argparse.rst:1539 +#: ../../library/argparse.rst:1361 msgid "Option value syntax" msgstr "" -#: ../../library/argparse.rst:1541 +#: ../../library/argparse.rst:1363 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:1545 +#: ../../library/argparse.rst:1367 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-x')\n" @@ -2767,14 +2320,14 @@ msgstr "" ">>> parser.parse_args(['--foo', 'FOO'])\n" "Namespace(foo='FOO', x=None)" -#: ../../library/argparse.rst:1553 +#: ../../library/argparse.rst:1375 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:1557 +#: ../../library/argparse.rst:1379 msgid "" ">>> parser.parse_args(['--foo=FOO'])\n" "Namespace(foo='FOO', x=None)" @@ -2782,13 +2335,13 @@ msgstr "" ">>> parser.parse_args(['--foo=FOO'])\n" "Namespace(foo='FOO', x=None)" -#: ../../library/argparse.rst:1560 +#: ../../library/argparse.rst:1382 msgid "" "For short options (options only one character long), the option and its " "value can be concatenated::" msgstr "" -#: ../../library/argparse.rst:1563 +#: ../../library/argparse.rst:1385 msgid "" ">>> parser.parse_args(['-xX'])\n" "Namespace(foo=None, x='X')" @@ -2796,13 +2349,13 @@ msgstr "" ">>> parser.parse_args(['-xX'])\n" "Namespace(foo=None, x='X')" -#: ../../library/argparse.rst:1566 +#: ../../library/argparse.rst:1388 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:1569 +#: ../../library/argparse.rst:1391 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-x', action='store_true')\n" @@ -2818,11 +2371,11 @@ msgstr "" ">>> parser.parse_args(['-xyzZ'])\n" "Namespace(x=True, y=True, z='Z')" -#: ../../library/argparse.rst:1578 +#: ../../library/argparse.rst:1400 msgid "Invalid arguments" msgstr "" -#: ../../library/argparse.rst:1580 +#: ../../library/argparse.rst:1402 msgid "" "While parsing the command line, :meth:`~ArgumentParser.parse_args` checks " "for a variety of errors, including ambiguous options, invalid types, invalid " @@ -2830,7 +2383,7 @@ msgid "" "an error, it exits and prints the error along with a usage message::" msgstr "" -#: ../../library/argparse.rst:1585 +#: ../../library/argparse.rst:1407 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('--foo', type=int)\n" @@ -2852,11 +2405,11 @@ msgid "" "PROG: error: extra arguments found: badger" msgstr "" -#: ../../library/argparse.rst:1606 +#: ../../library/argparse.rst:1428 msgid "Arguments containing ``-``" msgstr "" -#: ../../library/argparse.rst:1608 +#: ../../library/argparse.rst:1430 msgid "" "The :meth:`~ArgumentParser.parse_args` method attempts to give errors " "whenever the user has clearly made a mistake, but some situations are " @@ -2868,7 +2421,7 @@ msgid "" "negative numbers::" msgstr "" -#: ../../library/argparse.rst:1616 +#: ../../library/argparse.rst:1438 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-x')\n" @@ -2901,7 +2454,7 @@ msgid "" "PROG: error: argument -1: expected one argument" msgstr "" -#: ../../library/argparse.rst:1646 +#: ../../library/argparse.rst:1468 msgid "" "If you have positional arguments that must begin with ``-`` and don't look " "like negative numbers, you can insert the pseudo-argument ``'--'`` which " @@ -2909,7 +2462,7 @@ msgid "" "positional argument::" msgstr "" -#: ../../library/argparse.rst:1651 +#: ../../library/argparse.rst:1473 msgid "" ">>> parser.parse_args(['--', '-f'])\n" "Namespace(foo='-f', one=None)" @@ -2917,24 +2470,24 @@ msgstr "" ">>> parser.parse_args(['--', '-f'])\n" "Namespace(foo='-f', one=None)" -#: ../../library/argparse.rst:1654 +#: ../../library/argparse.rst:1476 msgid "" "See also :ref:`the argparse howto on ambiguous arguments ` for more details." msgstr "" -#: ../../library/argparse.rst:1660 +#: ../../library/argparse.rst:1482 msgid "Argument abbreviations (prefix matching)" msgstr "" -#: ../../library/argparse.rst:1662 +#: ../../library/argparse.rst:1484 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:1666 +#: ../../library/argparse.rst:1488 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-bacon')\n" @@ -2958,25 +2511,25 @@ msgstr "" "usage: PROG [-h] [-bacon BACON] [-badger BADGER]\n" "PROG: error: ambiguous option: -ba could match -badger, -bacon" -#: ../../library/argparse.rst:1677 +#: ../../library/argparse.rst:1499 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:1683 +#: ../../library/argparse.rst:1505 msgid "Beyond ``sys.argv``" msgstr "" -#: ../../library/argparse.rst:1685 +#: ../../library/argparse.rst:1507 msgid "" -"Sometimes it may be useful to have an ArgumentParser parse arguments other " -"than those of :data:`sys.argv`. This can be accomplished by passing a list " -"of strings to :meth:`~ArgumentParser.parse_args`. This is useful for " -"testing at the interactive prompt::" +"Sometimes it may be useful to have an :class:`ArgumentParser` parse " +"arguments other than those of :data:`sys.argv`. This can be accomplished by " +"passing a list of strings to :meth:`~ArgumentParser.parse_args`. This is " +"useful for testing at the interactive prompt::" msgstr "" -#: ../../library/argparse.rst:1690 +#: ../../library/argparse.rst:1512 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument(\n" @@ -3002,24 +2555,24 @@ msgstr "" ">>> parser.parse_args(['1', '2', '3', '4', '--sum'])\n" "Namespace(accumulate=, integers=[1, 2, 3, 4])" -#: ../../library/argparse.rst:1705 +#: ../../library/argparse.rst:1527 msgid "The Namespace object" msgstr "" -#: ../../library/argparse.rst:1709 +#: ../../library/argparse.rst:1531 msgid "" "Simple class used by default by :meth:`~ArgumentParser.parse_args` to create " "an object holding attributes and return it." msgstr "" -#: ../../library/argparse.rst:1712 +#: ../../library/argparse.rst:1534 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:1716 +#: ../../library/argparse.rst:1538 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo')\n" @@ -3033,14 +2586,14 @@ msgstr "" ">>> vars(args)\n" "{'foo': 'BAR'}" -#: ../../library/argparse.rst:1722 +#: ../../library/argparse.rst:1544 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:1726 +#: ../../library/argparse.rst:1548 msgid "" ">>> class C:\n" "... pass\n" @@ -3062,98 +2615,97 @@ msgstr "" ">>> c.foo\n" "'BAR'" -#: ../../library/argparse.rst:1738 +#: ../../library/argparse.rst:1560 msgid "Other utilities" msgstr "" -#: ../../library/argparse.rst:1741 +#: ../../library/argparse.rst:1563 msgid "Sub-commands" msgstr "" -#: ../../library/argparse.rst:1748 +#: ../../library/argparse.rst:1570 msgid "" -"Many programs split up their functionality into a number of sub-commands, " -"for example, the ``svn`` program can invoke sub-commands like ``svn " -"checkout``, ``svn update``, and ``svn commit``. Splitting up functionality " -"this way can be a particularly good idea when a program performs several " -"different functions which require different kinds of command-line " -"arguments. :class:`ArgumentParser` supports the creation of such sub-" -"commands with the :meth:`add_subparsers` method. The :meth:`add_subparsers` " -"method is normally called with no arguments and returns a special action " -"object. This object has a single method, :meth:`~_SubParsersAction." -"add_parser`, which takes a command name and any :class:`ArgumentParser` " -"constructor arguments, and returns an :class:`ArgumentParser` object that " -"can be modified as usual." +"Many programs split up their functionality into a number of subcommands, for " +"example, the ``svn`` program can invoke subcommands like ``svn checkout``, " +"``svn update``, and ``svn commit``. Splitting up functionality this way can " +"be a particularly good idea when a program performs several different " +"functions which require different kinds of command-line arguments. :class:" +"`ArgumentParser` supports the creation of such subcommands with the :meth:`!" +"add_subparsers` method. The :meth:`!add_subparsers` method is normally " +"called with no arguments and returns a special action object. This object " +"has a single method, :meth:`~_SubParsersAction.add_parser`, which takes a " +"command name and any :class:`!ArgumentParser` constructor arguments, and " +"returns an :class:`!ArgumentParser` object that can be modified as usual." msgstr "" -#: ../../library/argparse.rst:1760 +#: ../../library/argparse.rst:1582 msgid "Description of parameters:" msgstr "" -#: ../../library/argparse.rst:1762 +#: ../../library/argparse.rst:1584 msgid "" -"title - title for the sub-parser group in help output; by default " +"*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:1766 +#: ../../library/argparse.rst:1588 msgid "" -"description - description for the sub-parser group in help output, by " +"*description* - description for the sub-parser group in help output, by " "default ``None``" msgstr "" -#: ../../library/argparse.rst:1769 +#: ../../library/argparse.rst:1591 msgid "" -"prog - usage information that will be displayed with sub-command help, by " +"*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:1773 +#: ../../library/argparse.rst:1595 msgid "" -"parser_class - class which will be used to create sub-parser instances, by " -"default the class of the current parser (e.g. ArgumentParser)" +"*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:1776 +#: ../../library/argparse.rst:1598 msgid "" "action_ - the basic type of action to be taken when this argument is " "encountered at the command line" msgstr "" -#: ../../library/argparse.rst:1779 +#: ../../library/argparse.rst:1601 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:1782 +#: ../../library/argparse.rst:1604 msgid "" "required_ - Whether or not a subcommand must be provided, by default " "``False`` (added in 3.7)" msgstr "" -#: ../../library/argparse.rst:1785 +#: ../../library/argparse.rst:1607 msgid "help_ - help for sub-parser group in help output, by default ``None``" msgstr "" -#: ../../library/argparse.rst:1787 +#: ../../library/argparse.rst:1609 msgid "" -"metavar_ - string presenting available sub-commands in help; by default it " -"is ``None`` and presents sub-commands in form {cmd1, cmd2, ..}" +"metavar_ - string presenting available subcommands in help; by default it is " +"``None`` and presents subcommands in form {cmd1, cmd2, ..}" msgstr "" -#: ../../library/argparse.rst:1790 +#: ../../library/argparse.rst:1612 msgid "Some example usage::" msgstr "一些使用範例: ::" -#: ../../library/argparse.rst:1792 +#: ../../library/argparse.rst:1614 msgid "" ">>> # create the top-level parser\n" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('--foo', action='store_true', help='foo help')\n" -">>> subparsers = parser.add_subparsers(help='sub-command help')\n" +">>> subparsers = parser.add_subparsers(help='subcommand help')\n" ">>>\n" ">>> # create the parser for the \"a\" command\n" ">>> parser_a = subparsers.add_parser('a', help='a help')\n" @@ -3161,7 +2713,8 @@ msgid "" ">>>\n" ">>> # create the parser for the \"b\" command\n" ">>> parser_b = subparsers.add_parser('b', help='b help')\n" -">>> parser_b.add_argument('--baz', choices='XYZ', help='baz help')\n" +">>> parser_b.add_argument('--baz', choices=('X', 'Y', 'Z'), help='baz " +"help')\n" ">>>\n" ">>> # parse some argument lists\n" ">>> parser.parse_args(['a', '12'])\n" @@ -3170,7 +2723,7 @@ msgid "" "Namespace(baz='Z', foo=True)" msgstr "" -#: ../../library/argparse.rst:1811 +#: ../../library/argparse.rst:1633 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 " @@ -3180,7 +2733,7 @@ msgid "" "``baz`` attributes are present." msgstr "" -#: ../../library/argparse.rst:1818 +#: ../../library/argparse.rst:1640 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 " @@ -3189,13 +2742,14 @@ msgid "" "to :meth:`~_SubParsersAction.add_parser` as above.)" msgstr "" -#: ../../library/argparse.rst:1826 +#: ../../library/argparse.rst:1648 +#, fuzzy msgid "" ">>> parser.parse_args(['--help'])\n" "usage: PROG [-h] [--foo] {a,b} ...\n" "\n" "positional arguments:\n" -" {a,b} sub-command help\n" +" {a,b} subcommand help\n" " a a help\n" " b b help\n" "\n" @@ -3247,14 +2801,14 @@ msgstr "" " -h, --help show this help message and exit\n" " --baz {X,Y,Z} baz help" -#: ../../library/argparse.rst:1854 +#: ../../library/argparse.rst:1676 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:1858 +#: ../../library/argparse.rst:1680 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> subparsers = parser.add_subparsers(title='subcommands',\n" @@ -3290,7 +2844,7 @@ msgstr "" "\n" " {foo,bar} additional help" -#: ../../library/argparse.rst:1875 +#: ../../library/argparse.rst:1697 msgid "" "Furthermore, :meth:`~_SubParsersAction.add_parser` supports an additional " "*aliases* argument, which allows multiple strings to refer to the same " @@ -3298,7 +2852,7 @@ msgid "" "``checkout``::" msgstr "" -#: ../../library/argparse.rst:1880 +#: ../../library/argparse.rst:1702 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> subparsers = parser.add_subparsers()\n" @@ -3314,23 +2868,23 @@ msgstr "" ">>> parser.parse_args(['co', 'bar'])\n" "Namespace(foo='bar')" -#: ../../library/argparse.rst:1887 +#: ../../library/argparse.rst:1709 msgid "" ":meth:`~_SubParsersAction.add_parser` supports also an additional " "*deprecated* argument, which allows to deprecate the subparser." msgstr "" -#: ../../library/argparse.rst:1901 +#: ../../library/argparse.rst:1723 msgid "" -"One particularly effective way of handling sub-commands is to combine the " -"use of the :meth:`add_subparsers` method with calls to :meth:`set_defaults` " -"so that each subparser knows which Python function it should execute. For " +"One particularly effective way of handling subcommands is to combine the use " +"of the :meth:`add_subparsers` method with calls to :meth:`set_defaults` so " +"that each subparser knows which Python function it should execute. For " "example::" msgstr "" -#: ../../library/argparse.rst:1906 +#: ../../library/argparse.rst:1728 msgid "" -">>> # sub-command functions\n" +">>> # subcommand functions\n" ">>> def foo(args):\n" "... print(args.x * args.y)\n" "...\n" @@ -3363,7 +2917,7 @@ msgid "" "((XYZYX))" msgstr "" -#: ../../library/argparse.rst:1938 +#: ../../library/argparse.rst:1760 msgid "" "This way, you can let :meth:`parse_args` do the job of calling the " "appropriate function after argument parsing is complete. Associating " @@ -3373,7 +2927,7 @@ msgid "" "argument to the :meth:`add_subparsers` call will work::" msgstr "" -#: ../../library/argparse.rst:1945 +#: ../../library/argparse.rst:1767 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> subparsers = parser.add_subparsers(dest='subparser_name')\n" @@ -3393,15 +2947,15 @@ msgstr "" ">>> parser.parse_args(['2', 'frobble'])\n" "Namespace(subparser_name='2', y='frobble')" -#: ../../library/argparse.rst:1954 -msgid "New *required* keyword argument." +#: ../../library/argparse.rst:1776 +msgid "New *required* keyword-only parameter." msgstr "" -#: ../../library/argparse.rst:1959 +#: ../../library/argparse.rst:1781 msgid "FileType objects" msgstr "FileType 物件" -#: ../../library/argparse.rst:1963 +#: ../../library/argparse.rst:1785 msgid "" "The :class:`FileType` factory creates objects that can be passed to the type " "argument of :meth:`ArgumentParser.add_argument`. Arguments that have :class:" @@ -3410,7 +2964,7 @@ msgid "" "the :func:`open` function for more details)::" msgstr "" -#: ../../library/argparse.rst:1969 +#: ../../library/argparse.rst:1791 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--raw', type=argparse.FileType('wb', 0))\n" @@ -3428,14 +2982,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:1975 +#: ../../library/argparse.rst:1797 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:1979 +#: ../../library/argparse.rst:1801 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('infile', type=argparse.FileType('r'))\n" @@ -3447,24 +3001,24 @@ msgstr "" ">>> parser.parse_args(['-'])\n" "Namespace(infile=<_io.TextIOWrapper name='' encoding='UTF-8'>)" -#: ../../library/argparse.rst:1984 +#: ../../library/argparse.rst:1806 msgid "Added the *encodings* and *errors* parameters." msgstr "" -#: ../../library/argparse.rst:1989 +#: ../../library/argparse.rst:1811 msgid "Argument groups" msgstr "" -#: ../../library/argparse.rst:1993 +#: ../../library/argparse.rst:1816 msgid "" "By default, :class:`ArgumentParser` groups command-line arguments into " "\"positional arguments\" and \"options\" when displaying help messages. When " "there is a better conceptual grouping of arguments than this default one, " -"appropriate groups can be created using the :meth:`add_argument_group` " +"appropriate groups can be created using the :meth:`!add_argument_group` " "method::" msgstr "" -#: ../../library/argparse.rst:1999 +#: ../../library/argparse.rst:1822 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', add_help=False)\n" ">>> group = parser.add_argument_group('group')\n" @@ -3488,18 +3042,18 @@ msgstr "" " bar bar help\n" " --foo FOO foo help" -#: ../../library/argparse.rst:2010 +#: ../../library/argparse.rst:1833 msgid "" "The :meth:`add_argument_group` method returns an argument group object which " "has an :meth:`~ArgumentParser.add_argument` method just like a regular :" "class:`ArgumentParser`. When an argument is added to the group, the parser " "treats it just like a normal argument, but displays the argument in a " -"separate group for help messages. The :meth:`add_argument_group` method " +"separate group for help messages. The :meth:`!add_argument_group` method " "accepts *title* and *description* arguments which can be used to customize " "this display::" msgstr "" -#: ../../library/argparse.rst:2018 +#: ../../library/argparse.rst:1841 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', add_help=False)\n" ">>> group1 = parser.add_argument_group('group1', 'group1 description')\n" @@ -3537,13 +3091,22 @@ msgstr "" "\n" " --bar BAR bar help" -#: ../../library/argparse.rst:2036 +#: ../../library/argparse.rst:1859 +msgid "" +"The optional, keyword-only parameters argument_default_ and " +"conflict_handler_ allow for finer-grained control of the behavior of the " +"argument group. These parameters have the same meaning as in the :class:" +"`ArgumentParser` constructor, but apply specifically to the argument group " +"rather than the entire parser." +msgstr "" + +#: ../../library/argparse.rst:1864 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:2039 +#: ../../library/argparse.rst:1867 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 " @@ -3551,18 +3114,18 @@ msgid "" "future." msgstr "" -#: ../../library/argparse.rst:2047 +#: ../../library/argparse.rst:1875 msgid "Mutual exclusion" msgstr "" -#: ../../library/argparse.rst:2051 +#: ../../library/argparse.rst:1879 msgid "" -"Create a mutually exclusive group. :mod:`argparse` will make sure that only " +"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:2055 +#: ../../library/argparse.rst:1883 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> group = parser.add_mutually_exclusive_group()\n" @@ -3588,14 +3151,14 @@ msgstr "" "usage: PROG [-h] [--foo | --bar]\n" "PROG: error: argument --bar: not allowed with argument --foo" -#: ../../library/argparse.rst:2067 +#: ../../library/argparse.rst:1895 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:2071 +#: ../../library/argparse.rst:1899 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> group = parser.add_mutually_exclusive_group(required=True)\n" @@ -3613,7 +3176,7 @@ msgstr "" "usage: PROG [-h] (--foo | --bar)\n" "PROG: error: one of the arguments --foo --bar is required" -#: ../../library/argparse.rst:2079 +#: ../../library/argparse.rst:1907 msgid "" "Note that currently mutually exclusive argument groups do not support the " "*title* and *description* arguments of :meth:`~ArgumentParser." @@ -3621,7 +3184,7 @@ msgid "" "argument group that has a title and description. For example::" msgstr "" -#: ../../library/argparse.rst:2085 +#: ../../library/argparse.rst:1913 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> group = parser.add_argument_group('Group title', 'Group description')\n" @@ -3657,7 +3220,7 @@ msgstr "" " --foo FOO foo help\n" " --bar BAR bar help" -#: ../../library/argparse.rst:2102 +#: ../../library/argparse.rst:1930 msgid "" "Calling :meth:`add_argument_group` or :meth:`add_mutually_exclusive_group` " "on a mutually exclusive group is deprecated. These features were never " @@ -3665,11 +3228,11 @@ msgid "" "by accident through inheritance and will be removed in the future." msgstr "" -#: ../../library/argparse.rst:2110 +#: ../../library/argparse.rst:1938 msgid "Parser defaults" msgstr "" -#: ../../library/argparse.rst:2114 +#: ../../library/argparse.rst:1942 msgid "" "Most of the time, the attributes of the object returned by :meth:" "`parse_args` will be fully determined by inspecting the command-line " @@ -3678,7 +3241,7 @@ msgid "" "command line to be added::" msgstr "" -#: ../../library/argparse.rst:2120 +#: ../../library/argparse.rst:1948 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('foo', type=int)\n" @@ -3692,12 +3255,12 @@ msgstr "" ">>> parser.parse_args(['736'])\n" "Namespace(bar=42, baz='badger', foo=736)" -#: ../../library/argparse.rst:2126 +#: ../../library/argparse.rst:1954 msgid "" "Note that parser-level defaults always override argument-level defaults::" msgstr "" -#: ../../library/argparse.rst:2128 +#: ../../library/argparse.rst:1956 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', default='bar')\n" @@ -3711,20 +3274,20 @@ msgstr "" ">>> parser.parse_args([])\n" "Namespace(foo='spam')" -#: ../../library/argparse.rst:2134 +#: ../../library/argparse.rst:1962 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:2140 +#: ../../library/argparse.rst:1968 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:2144 +#: ../../library/argparse.rst:1972 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', default='badger')\n" @@ -3736,54 +3299,54 @@ msgstr "" ">>> parser.get_default('foo')\n" "'badger'" -#: ../../library/argparse.rst:2151 +#: ../../library/argparse.rst:1979 msgid "Printing help" msgstr "" -#: ../../library/argparse.rst:2153 +#: ../../library/argparse.rst:1981 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:2159 +#: ../../library/argparse.rst:1987 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:2165 +#: ../../library/argparse.rst:1993 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:2169 +#: ../../library/argparse.rst:1997 msgid "" "There are also variants of these methods that simply return a string instead " "of printing it:" msgstr "" -#: ../../library/argparse.rst:2174 +#: ../../library/argparse.rst:2002 msgid "" "Return a string containing a brief description of how the :class:" "`ArgumentParser` should be invoked on the command line." msgstr "" -#: ../../library/argparse.rst:2179 +#: ../../library/argparse.rst:2007 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:2184 +#: ../../library/argparse.rst:2012 msgid "Partial parsing" msgstr "" -#: ../../library/argparse.rst:2188 +#: ../../library/argparse.rst:2016 msgid "" "Sometimes a script may only parse a few of the command-line arguments, " "passing the remaining arguments on to another script or program. In these " @@ -3794,7 +3357,7 @@ msgid "" "remaining argument strings." msgstr "" -#: ../../library/argparse.rst:2197 +#: ../../library/argparse.rst:2025 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', action='store_true')\n" @@ -3808,7 +3371,7 @@ msgstr "" ">>> parser.parse_known_args(['--foo', '--badger', 'BAR', 'spam'])\n" "(Namespace(bar='BAR', foo=True), ['--badger', 'spam'])" -#: ../../library/argparse.rst:2204 +#: ../../library/argparse.rst:2032 msgid "" ":ref:`Prefix matching ` rules apply to :meth:" "`~ArgumentParser.parse_known_args`. The parser may consume an option even if " @@ -3816,11 +3379,11 @@ msgid "" "remaining arguments list." msgstr "" -#: ../../library/argparse.rst:2211 +#: ../../library/argparse.rst:2039 msgid "Customizing file parsing" msgstr "" -#: ../../library/argparse.rst:2215 +#: ../../library/argparse.rst:2043 msgid "" "Arguments that are read from a file (see the *fromfile_prefix_chars* keyword " "argument to the :class:`ArgumentParser` constructor) are read one argument " @@ -3828,20 +3391,20 @@ msgid "" "reading." msgstr "" -#: ../../library/argparse.rst:2220 +#: ../../library/argparse.rst:2048 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:2224 +#: ../../library/argparse.rst:2052 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:2227 +#: ../../library/argparse.rst:2055 msgid "" "class MyArgumentParser(argparse.ArgumentParser):\n" " def convert_arg_line_to_args(self, arg_line):\n" @@ -3851,18 +3414,18 @@ msgstr "" " def convert_arg_line_to_args(self, arg_line):\n" " return arg_line.split()" -#: ../../library/argparse.rst:2233 +#: ../../library/argparse.rst:2061 msgid "Exiting methods" msgstr "" -#: ../../library/argparse.rst:2237 +#: ../../library/argparse.rst:2065 msgid "" "This method terminates the program, exiting with the specified *status* and, " -"if given, it prints a *message* before that. The user can override this " -"method to handle these steps differently::" +"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:2241 +#: ../../library/argparse.rst:2069 msgid "" "class ErrorCatchingArgumentParser(argparse.ArgumentParser):\n" " def exit(self, status=0, message=None):\n" @@ -3876,17 +3439,17 @@ msgstr "" " raise Exception(f'Exiting because of an error: {message}')\n" " exit(status)" -#: ../../library/argparse.rst:2249 +#: ../../library/argparse.rst:2077 msgid "" -"This method prints a usage message including the *message* to the standard " -"error and terminates the program with a status code of 2." +"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:2254 +#: ../../library/argparse.rst:2082 msgid "Intermixed parsing" msgstr "" -#: ../../library/argparse.rst:2259 +#: ../../library/argparse.rst:2087 msgid "" "A number of Unix commands allow the user to intermix optional arguments with " "positional arguments. The :meth:`~ArgumentParser.parse_intermixed_args` " @@ -3894,15 +3457,15 @@ msgid "" "parsing style." msgstr "" -#: ../../library/argparse.rst:2264 +#: ../../library/argparse.rst:2092 msgid "" -"These parsers do not support all the argparse features, and will raise " -"exceptions if unsupported features are used. In particular, subparsers, and " -"mutually exclusive groups that include both optionals and positionals are " -"not supported." +"These parsers do not support all the :mod:`!argparse` features, and will " +"raise exceptions if unsupported features are used. In particular, " +"subparsers, and mutually exclusive groups that include both optionals and " +"positionals are not supported." msgstr "" -#: ../../library/argparse.rst:2269 +#: ../../library/argparse.rst:2097 msgid "" "The following example shows the difference between :meth:`~ArgumentParser." "parse_known_args` and :meth:`~ArgumentParser.parse_intermixed_args`: the " @@ -3910,7 +3473,7 @@ msgid "" "collects all the positionals into ``rest``. ::" msgstr "" -#: ../../library/argparse.rst:2275 +#: ../../library/argparse.rst:2103 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo')\n" @@ -3930,7 +3493,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:2284 +#: ../../library/argparse.rst:2112 msgid "" ":meth:`~ArgumentParser.parse_known_intermixed_args` returns a two item tuple " "containing the populated namespace and the list of remaining argument " @@ -3938,143 +3501,412 @@ msgid "" "there are any remaining unparsed argument strings." msgstr "" -#: ../../library/argparse.rst:2294 -msgid "Upgrading optparse code" +#: ../../library/argparse.rst:2121 +msgid "Registering custom types or actions" msgstr "" -#: ../../library/argparse.rst:2296 +#: ../../library/argparse.rst:2125 msgid "" -"Originally, the :mod:`argparse` module had attempted to maintain " -"compatibility with :mod:`optparse`. However, :mod:`optparse` was difficult " -"to extend transparently, particularly with the changes required to support " -"the new ``nargs=`` specifiers and better usage messages. When most " -"everything in :mod:`optparse` had either been copy-pasted over or monkey-" -"patched, it no longer seemed practical to try to maintain the backwards " -"compatibility." +"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 " +"register custom actions or types with a parser and allow you to reference " +"the type by their registered name instead of their callable name." msgstr "" -#: ../../library/argparse.rst:2303 +#: ../../library/argparse.rst:2130 msgid "" -"The :mod:`argparse` module improves on the standard library :mod:`optparse` " -"module in a number of ways including:" -msgstr "" - -#: ../../library/argparse.rst:2306 -msgid "Handling positional arguments." -msgstr "" - -#: ../../library/argparse.rst:2307 -msgid "Supporting sub-commands." +"The :meth:`!register` method accepts three arguments - a *registry_name*, " +"specifying the internal registry where the object will be stored (e.g., " +"``action``, ``type``), *value*, which is the key under which the object will " +"be registered, and object, the callable to be registered." msgstr "" -#: ../../library/argparse.rst:2308 -msgid "Allowing alternative option prefixes like ``+`` and ``/``." -msgstr "" - -#: ../../library/argparse.rst:2309 -msgid "Handling zero-or-more and one-or-more style arguments." -msgstr "" - -#: ../../library/argparse.rst:2310 -msgid "Producing more informative usage messages." -msgstr "" - -#: ../../library/argparse.rst:2311 -msgid "Providing a much simpler interface for custom ``type`` and ``action``." -msgstr "" - -#: ../../library/argparse.rst:2313 -msgid "A partial upgrade path from :mod:`optparse` to :mod:`argparse`:" -msgstr "" - -#: ../../library/argparse.rst:2315 -msgid "" -"Replace all :meth:`optparse.OptionParser.add_option` calls with :meth:" -"`ArgumentParser.add_argument` calls." -msgstr "" - -#: ../../library/argparse.rst:2318 -msgid "" -"Replace ``(options, args) = parser.parse_args()`` with ``args = parser." -"parse_args()`` and add additional :meth:`ArgumentParser.add_argument` calls " -"for the positional arguments. Keep in mind that what was previously called " -"``options``, now in the :mod:`argparse` context is called ``args``." -msgstr "" - -#: ../../library/argparse.rst:2323 -msgid "" -"Replace :meth:`optparse.OptionParser.disable_interspersed_args` by using :" -"meth:`~ArgumentParser.parse_intermixed_args` instead of :meth:" -"`~ArgumentParser.parse_args`." -msgstr "" - -#: ../../library/argparse.rst:2327 -msgid "" -"Replace callback actions and the ``callback_*`` keyword arguments with " -"``type`` or ``action`` arguments." -msgstr "" - -#: ../../library/argparse.rst:2330 -msgid "" -"Replace string names for ``type`` keyword arguments with the corresponding " -"type objects (e.g. int, float, complex, etc)." -msgstr "" - -#: ../../library/argparse.rst:2333 -msgid "" -"Replace :class:`optparse.Values` with :class:`Namespace` and :exc:`optparse." -"OptionError` and :exc:`optparse.OptionValueError` with :exc:`ArgumentError`." -msgstr "" - -#: ../../library/argparse.rst:2337 +#: ../../library/argparse.rst:2135 msgid "" -"Replace strings with implicit arguments such as ``%default`` or ``%prog`` " -"with the standard Python syntax to use dictionaries to format strings, that " -"is, ``%(default)s`` and ``%(prog)s``." +"The following example shows how to register a custom type with a parser::" msgstr "" -#: ../../library/argparse.rst:2341 +#: ../../library/argparse.rst:2137 msgid "" -"Replace the OptionParser constructor ``version`` argument with a call to " -"``parser.add_argument('--version', action='version', version='')``." +">>> 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'" msgstr "" -#: ../../library/argparse.rst:2345 +#: ../../library/argparse.rst:2149 msgid "Exceptions" msgstr "" -#: ../../library/argparse.rst:2349 +#: ../../library/argparse.rst:2153 msgid "An error from creating or using an argument (optional or positional)." msgstr "" -#: ../../library/argparse.rst:2351 +#: ../../library/argparse.rst:2155 msgid "" "The string value of this exception is the message, augmented with " "information about the argument that caused it." msgstr "" -#: ../../library/argparse.rst:2356 +#: ../../library/argparse.rst:2160 msgid "" "Raised when something goes wrong converting a command line string to a type." msgstr "" -#: ../../library/argparse.rst:982 +#: ../../library/argparse.rst:2164 +msgid "Guides and Tutorials" +msgstr "" + +#: ../../library/argparse.rst:815 msgid "? (question mark)" msgstr "? (問號)" -#: ../../library/argparse.rst:982 ../../library/argparse.rst:1016 -#: ../../library/argparse.rst:1030 +#: ../../library/argparse.rst:815 ../../library/argparse.rst:849 +#: ../../library/argparse.rst:863 msgid "in argparse module" msgstr "於 argparse 模組中" -#: ../../library/argparse.rst:1016 +#: ../../library/argparse.rst:849 msgid "* (asterisk)" msgstr "* (星號)" -#: ../../library/argparse.rst:1030 +#: ../../library/argparse.rst:863 msgid "+ (plus)" msgstr "+ (加號)" +#~ msgid "Name" +#~ msgstr "名稱" + +#~ msgid "Description" +#~ msgstr "描述" + +#~ msgid "Values" +#~ msgstr "數值" + +#~ msgid "action_" +#~ msgstr "action_" + +#~ msgid "" +#~ "``'store'``, ``'store_const'``, ``'store_true'``, ``'append'``, " +#~ "``'append_const'``, ``'count'``, ``'help'``, ``'version'``" +#~ msgstr "" +#~ "``'store'``, ``'store_const'``, ``'store_true'``, ``'append'``, " +#~ "``'append_const'``, ``'count'``, ``'help'``, ``'version'``" + +#~ msgid "choices_" +#~ msgstr "choices_" + +#~ msgid "const_" +#~ msgstr "const_" + +#~ msgid "default_" +#~ msgstr "default_" + +#~ msgid "dest_" +#~ msgstr "dest_" + +#~ msgid "help_" +#~ msgstr "help_" + +#~ msgid "metavar_" +#~ msgstr "metavar_" + +#~ msgid "nargs_" +#~ msgstr "nargs_" + +#~ msgid ":class:`int`, ``'?'``, ``'*'``, or ``'+'``" +#~ msgstr ":class:`int`, ``'?'``, ``'*'``, or ``'+'``" + +#~ msgid "required_" +#~ msgstr "required_" + +#~ msgid "``True`` or ``False``" +#~ msgstr "``True`` 或 ``False``" + +#~ msgid "" +#~ ":class:`int`, :class:`float`, ``argparse.FileType('w')``, or callable " +#~ "function" +#~ msgstr "" +#~ ":class:`int`、:class:`float`、``argparse.FileType('w')`` 或可呼叫的函式" + +#~ msgid "Example" +#~ msgstr "範例" + +#~ msgid "" +#~ "import argparse\n" +#~ "\n" +#~ "parser = argparse.ArgumentParser(description='Process some integers.')\n" +#~ "parser.add_argument('integers', metavar='N', type=int, nargs='+',\n" +#~ " help='an integer for the accumulator')\n" +#~ "parser.add_argument('--sum', dest='accumulate', action='store_const',\n" +#~ " const=sum, default=max,\n" +#~ " help='sum the integers (default: find the max)')\n" +#~ "\n" +#~ "args = parser.parse_args()\n" +#~ "print(args.accumulate(args.integers))" +#~ msgstr "" +#~ "import argparse\n" +#~ "\n" +#~ "parser = argparse.ArgumentParser(description='Process some integers.')\n" +#~ "parser.add_argument('integers', metavar='N', type=int, nargs='+',\n" +#~ " help='an integer for the accumulator')\n" +#~ "parser.add_argument('--sum', dest='accumulate', action='store_const',\n" +#~ " const=sum, default=max,\n" +#~ " help='sum the integers (default: find the max)')\n" +#~ "\n" +#~ "args = parser.parse_args()\n" +#~ "print(args.accumulate(args.integers))" + +#~ msgid "" +#~ "$ python prog.py -h\n" +#~ "usage: prog.py [-h] [--sum] N [N ...]\n" +#~ "\n" +#~ "Process some integers.\n" +#~ "\n" +#~ "positional arguments:\n" +#~ " N an integer for the accumulator\n" +#~ "\n" +#~ "options:\n" +#~ " -h, --help show this help message and exit\n" +#~ " --sum sum the integers (default: find the max)" +#~ msgstr "" +#~ "$ python prog.py -h\n" +#~ "usage: prog.py [-h] [--sum] N [N ...]\n" +#~ "\n" +#~ "Process some integers.\n" +#~ "\n" +#~ "positional arguments:\n" +#~ " N an integer for the accumulator\n" +#~ "\n" +#~ "options:\n" +#~ " -h, --help show this help message and exit\n" +#~ " --sum sum the integers (default: find the max)" + +#~ msgid "" +#~ "$ python prog.py 1 2 3 4\n" +#~ "4\n" +#~ "\n" +#~ "$ python prog.py 1 2 3 4 --sum\n" +#~ "10" +#~ msgstr "" +#~ "$ python prog.py 1 2 3 4\n" +#~ "4\n" +#~ "\n" +#~ "$ python prog.py 1 2 3 4 --sum\n" +#~ "10" + +#~ msgid "" +#~ "$ python prog.py a b c\n" +#~ "usage: prog.py [-h] [--sum] N [N ...]\n" +#~ "prog.py: error: argument N: invalid int value: 'a'" +#~ msgstr "" +#~ "$ python prog.py a b c\n" +#~ "usage: prog.py [-h] [--sum] N [N ...]\n" +#~ "prog.py: error: argument N: invalid int value: 'a'" + +#~ msgid "Creating a parser" +#~ msgstr "建立一個剖析器" + +#~ msgid "" +#~ ">>> parser = argparse.ArgumentParser(description='Process some integers.')" +#~ msgstr "" +#~ ">>> parser = argparse.ArgumentParser(description='Process some integers.')" + +#~ msgid "Adding arguments" +#~ msgstr "增加引數" + +#~ msgid "" +#~ ">>> parser.add_argument('integers', metavar='N', type=int, nargs='+',\n" +#~ "... help='an integer for the accumulator')\n" +#~ ">>> parser.add_argument('--sum', dest='accumulate', " +#~ "action='store_const',\n" +#~ "... const=sum, default=max,\n" +#~ "... help='sum the integers (default: find the max)')" +#~ msgstr "" +#~ ">>> parser.add_argument('integers', metavar='N', type=int, nargs='+',\n" +#~ "... help='an integer for the accumulator')\n" +#~ ">>> parser.add_argument('--sum', dest='accumulate', " +#~ "action='store_const',\n" +#~ "... const=sum, default=max,\n" +#~ "... help='sum the integers (default: find the max)')" + +#~ msgid "Parsing arguments" +#~ msgstr "剖析引數" + +#~ msgid "" +#~ ">>> parser.parse_args(['--sum', '7', '-1', '42'])\n" +#~ "Namespace(accumulate=, integers=[7, -1, 42])" +#~ msgstr "" +#~ ">>> parser.parse_args(['--sum', '7', '-1', '42'])\n" +#~ "Namespace(accumulate=, integers=[7, -1, 42])" + +#~ msgid "" +#~ "import argparse\n" +#~ "parser = argparse.ArgumentParser()\n" +#~ "parser.add_argument('--foo', help='foo help')\n" +#~ "args = parser.parse_args()" +#~ msgstr "" +#~ "import argparse\n" +#~ "parser = argparse.ArgumentParser()\n" +#~ "parser.add_argument('--foo', help='foo help')\n" +#~ "args = parser.parse_args()" + +#~ msgid "" +#~ "$ python myprogram.py --help\n" +#~ "usage: myprogram.py [-h] [--foo FOO]\n" +#~ "\n" +#~ "options:\n" +#~ " -h, --help show this help message and exit\n" +#~ " --foo FOO foo help\n" +#~ "$ cd ..\n" +#~ "$ python subdir/myprogram.py --help\n" +#~ "usage: myprogram.py [-h] [--foo FOO]\n" +#~ "\n" +#~ "options:\n" +#~ " -h, --help show this help message and exit\n" +#~ " --foo FOO foo help" +#~ msgstr "" +#~ "$ python myprogram.py --help\n" +#~ "usage: myprogram.py [-h] [--foo FOO]\n" +#~ "\n" +#~ "options:\n" +#~ " -h, --help show this help message and exit\n" +#~ " --foo FOO foo help\n" +#~ "$ cd ..\n" +#~ "$ python subdir/myprogram.py --help\n" +#~ "usage: myprogram.py [-h] [--foo FOO]\n" +#~ "\n" +#~ "options:\n" +#~ " -h, --help show this help message and exit\n" +#~ " --foo FOO foo help" + +#~ msgid "" +#~ ">>> parser = argparse.ArgumentParser(prog='PROG')\n" +#~ ">>> parser.add_argument('--foo', nargs='?', help='foo help')\n" +#~ ">>> parser.add_argument('bar', nargs='+', help='bar help')\n" +#~ ">>> parser.print_help()\n" +#~ "usage: PROG [-h] [--foo [FOO]] bar [bar ...]\n" +#~ "\n" +#~ "positional arguments:\n" +#~ " bar bar help\n" +#~ "\n" +#~ "options:\n" +#~ " -h, --help show this help message and exit\n" +#~ " --foo [FOO] foo help" +#~ msgstr "" +#~ ">>> parser = argparse.ArgumentParser(prog='PROG')\n" +#~ ">>> parser.add_argument('--foo', nargs='?', help='foo help')\n" +#~ ">>> parser.add_argument('bar', nargs='+', help='bar help')\n" +#~ ">>> parser.print_help()\n" +#~ "usage: PROG [-h] [--foo [FOO]] bar [bar ...]\n" +#~ "\n" +#~ "positional arguments:\n" +#~ " bar bar help\n" +#~ "\n" +#~ "options:\n" +#~ " -h, --help show this help message and exit\n" +#~ " --foo [FOO] foo help" + +#~ msgid "" +#~ ">>> parser = argparse.ArgumentParser(description='A foo that bars')\n" +#~ ">>> parser.print_help()\n" +#~ "usage: argparse.py [-h]\n" +#~ "\n" +#~ "A foo that bars\n" +#~ "\n" +#~ "options:\n" +#~ " -h, --help show this help message and exit" +#~ msgstr "" +#~ ">>> parser = argparse.ArgumentParser(description='A foo that bars')\n" +#~ ">>> parser.print_help()\n" +#~ "usage: argparse.py [-h]\n" +#~ "\n" +#~ "A foo that bars\n" +#~ "\n" +#~ "options:\n" +#~ " -h, --help show this help message and exit" + +#~ msgid "" +#~ "$ python myprogram.py --help\n" +#~ "usage: myprogram.py [-h] [--foo FOO]\n" +#~ "\n" +#~ "options:\n" +#~ " -h, --help show this help message and exit\n" +#~ " --foo FOO foo help" +#~ msgstr "" +#~ "$ python myprogram.py --help\n" +#~ "usage: myprogram.py [-h] [--foo FOO]\n" +#~ "\n" +#~ "options:\n" +#~ " -h, --help show this help message and exit\n" +#~ " --foo FOO foo help" + +#~ msgid "" +#~ ">>> parser = argparse.ArgumentParser()\n" +#~ ">>> parser.add_argument('--foo')\n" +#~ ">>> parser.parse_args('--foo 1'.split())\n" +#~ "Namespace(foo='1')" +#~ msgstr "" +#~ ">>> parser = argparse.ArgumentParser()\n" +#~ ">>> parser.add_argument('--foo')\n" +#~ ">>> parser.parse_args('--foo 1'.split())\n" +#~ "Namespace(foo='1')" + +#~ msgid "" +#~ ">>> parser = argparse.ArgumentParser(prog='doors.py')\n" +#~ ">>> parser.add_argument('door', type=int, choices=range(1, 4))\n" +#~ ">>> print(parser.parse_args(['3']))\n" +#~ "Namespace(door=3)\n" +#~ ">>> parser.parse_args(['4'])\n" +#~ "usage: doors.py [-h] {1,2,3}\n" +#~ "doors.py: error: argument door: invalid choice: 4 (choose from 1, 2, 3)" +#~ msgstr "" +#~ ">>> parser = argparse.ArgumentParser(prog='doors.py')\n" +#~ ">>> parser.add_argument('door', type=int, choices=range(1, 4))\n" +#~ ">>> print(parser.parse_args(['3']))\n" +#~ "Namespace(door=3)\n" +#~ ">>> parser.parse_args(['4'])\n" +#~ "usage: doors.py [-h] {1,2,3}\n" +#~ "doors.py: error: argument door: invalid choice: 4 (choose from 1, 2, 3)" + +#~ msgid "" +#~ ">>> parser = argparse.ArgumentParser(prog='frobble')\n" +#~ ">>> parser.add_argument('--foo', action='store_true',\n" +#~ "... help='foo the bars before frobbling')\n" +#~ ">>> parser.add_argument('bar', nargs='+',\n" +#~ "... help='one of the bars to be frobbled')\n" +#~ ">>> parser.parse_args(['-h'])\n" +#~ "usage: frobble [-h] [--foo] bar [bar ...]\n" +#~ "\n" +#~ "positional arguments:\n" +#~ " bar one of the bars to be frobbled\n" +#~ "\n" +#~ "options:\n" +#~ " -h, --help show this help message and exit\n" +#~ " --foo foo the bars before frobbling" +#~ msgstr "" +#~ ">>> parser = argparse.ArgumentParser(prog='frobble')\n" +#~ ">>> parser.add_argument('--foo', action='store_true',\n" +#~ "... help='foo the bars before frobbling')\n" +#~ ">>> parser.add_argument('bar', nargs='+',\n" +#~ "... help='one of the bars to be frobbled')\n" +#~ ">>> parser.parse_args(['-h'])\n" +#~ "usage: frobble [-h] [--foo] bar [bar ...]\n" +#~ "\n" +#~ "positional arguments:\n" +#~ " bar one of the bars to be frobbled\n" +#~ "\n" +#~ "options:\n" +#~ " -h, --help show this help message and exit\n" +#~ " --foo foo the bars before frobbling" + #~ msgid "type_" #~ msgstr "type_" diff --git a/library/ast.po b/library/ast.po index 4a81075034..c4faa06173 100644 --- a/library/ast.po +++ b/library/ast.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-05-04 20:08+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-" @@ -439,13 +439,15 @@ msgstr "" "parse` 在預設的 ``\"exec\"`` *mode* 下生成的節點型別。" #: ../../library/ast.rst:176 -msgid "*body* is a :class:`list` of the module's :ref:`ast-statements`." +#, fuzzy +msgid "``body`` is a :class:`list` of the module's :ref:`ast-statements`." msgstr "*body* 是模組的\\ :ref:`ast-statements` 的一個 :class:`list`。" #: ../../library/ast.rst:178 +#, fuzzy msgid "" -"*type_ignores* is a :class:`list` of the module's type ignore comments; see :" -"func:`ast.parse` for more details." +"``type_ignores`` is a :class:`list` of the module's type ignore comments; " +"see :func:`ast.parse` for more details." msgstr "" "*type_ignores* 是模組的忽略型別註解的 :class:`list`;有關更多詳細資訊,請參" "閱 :func:`ast.parse`。" @@ -479,8 +481,9 @@ msgstr "" "時節點型別由 :func:`ast.parse` 生成。" #: ../../library/ast.rst:197 +#, fuzzy msgid "" -"*body* is a single node, one of the :ref:`expression types `." msgstr "" "*body* 是單個節點,是\\ :ref:`運算式型別 `\\ 的其中之一。" @@ -504,7 +507,8 @@ msgstr "" "似。當 *mode* 是 ``\"single\"`` 時節點型別由 :func:`ast.parse` 生成。" #: ../../library/ast.rst:212 -msgid "*body* is a :class:`list` of :ref:`statement nodes `." +#, fuzzy +msgid "``body`` is a :class:`list` of :ref:`statement nodes `." msgstr "" "*body* 是\\ :ref:`陳述式節點 (statement nodes) ` 的 :class:" "`list`。" @@ -559,13 +563,15 @@ msgstr "" " return a + b" #: ../../library/ast.rst:241 +#, fuzzy msgid "" -"*argtypes* is a :class:`list` of :ref:`expression nodes `." +"``argtypes`` is a :class:`list` of :ref:`expression nodes `." msgstr "" "*argtypes* 是\\ :ref:`運算式節點 `\\ 的 :class:`list`。" #: ../../library/ast.rst:243 -msgid "*returns* is a single :ref:`expression node `." +#, fuzzy +msgid "``returns`` is a single :ref:`expression node `." msgstr "*returns* 是單個\\ :ref:`運算式節點 `。" #: ../../library/ast.rst:245 @@ -1545,7 +1551,7 @@ msgstr "" "中放置一個 :class:`Tuple` 或 :class:`List` 來表示的。" #: ../../library/ast.rst:863 ../../library/ast.rst:1158 -#: ../../library/ast.rst:1352 ../../library/ast.rst:1881 +#: ../../library/ast.rst:1352 ../../library/ast.rst:1918 msgid "" "``type_comment`` is an optional string with the type annotation as a comment." msgstr "``type_comment`` 是一個可選字串,其中的註解為型別註釋。" @@ -1601,12 +1607,13 @@ msgstr "" "`Constant` 或 :class:`Name` 節點。``value`` 是單個可選節點。" #: ../../library/ast.rst:896 +#, fuzzy msgid "" "``simple`` is always either 0 (indicating a \"complex\" target) or 1 " "(indicating a \"simple\" target). A \"simple\" target consists solely of a :" "class:`Name` node that does not appear between parentheses; all other " "targets are considered complex. Only simple targets appear in the :attr:" -"`__annotations__` dictionary of modules and classes." +"`~object.__annotations__` dictionary of modules and classes." msgstr "" "``simple`` 總會是 0(表示一個「複雜」目標)或 1(表示一個「簡單」目標)。一個" "「簡單」目標僅包含一個 :class:`Name` 節點,且不出現在括號之間;所有其他目標都" @@ -2116,7 +2123,7 @@ msgstr "一個 ``while`` 迴圈。``test`` 保存條件,例如 :class:`Compare #: ../../library/ast.rst:1186 #, fuzzy msgid "" -">> print(ast.dump(ast.parse(\"\"\"\n" +">>> print(ast.dump(ast.parse(\"\"\"\n" "... while x:\n" "... ...\n" "... else:\n" @@ -3161,30 +3168,87 @@ msgstr "" " value=Constant(value=Ellipsis))])])],\n" " type_ignores=[])" -#: ../../library/ast.rst:1762 +#: ../../library/ast.rst:1761 +msgid "Type annotations" +msgstr "" + +#: ../../library/ast.rst:1765 +msgid "" +"A ``# type: ignore`` comment located at *lineno*. *tag* is the optional tag " +"specified by the form ``# type: ignore ``." +msgstr "" + +#: ../../library/ast.rst:1768 +#, fuzzy +msgid "" +">>> print(ast.dump(ast.parse('x = 1 # type: ignore', type_comments=True), " +"indent=4))\n" +"Module(\n" +" body=[\n" +" Assign(\n" +" targets=[\n" +" Name(id='x', ctx=Store())],\n" +" value=Constant(value=1))],\n" +" type_ignores=[\n" +" TypeIgnore(lineno=1, tag='')])\n" +">>> print(ast.dump(ast.parse('x: bool = 1 # type: ignore[assignment]', " +"type_comments=True), indent=4))\n" +"Module(\n" +" body=[\n" +" AnnAssign(\n" +" target=Name(id='x', ctx=Store()),\n" +" annotation=Name(id='bool', ctx=Load()),\n" +" value=Constant(value=1),\n" +" simple=1)],\n" +" type_ignores=[\n" +" TypeIgnore(lineno=1, tag='[assignment]')])" +msgstr "" +">>> print(ast.dump(ast.parse('a, *b = it'), indent=4))\n" +"Module(\n" +" body=[\n" +" Assign(\n" +" targets=[\n" +" Tuple(\n" +" elts=[\n" +" Name(id='a', ctx=Store()),\n" +" Starred(\n" +" value=Name(id='b', ctx=Store()),\n" +" ctx=Store())],\n" +" ctx=Store())],\n" +" value=Name(id='it', ctx=Load()))],\n" +" type_ignores=[])" + +#: ../../library/ast.rst:1791 +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 msgid "Type parameters" msgstr "型別參數 (type parameters)" -#: ../../library/ast.rst:1764 +#: ../../library/ast.rst:1801 msgid "" ":ref:`Type parameters ` can exist on classes, functions, and " "type aliases." msgstr ":ref:`型別參數 `\\ 可以存在於類別、函式和型別別名上。" -#: ../../library/ast.rst:1769 +#: ../../library/ast.rst:1806 #, fuzzy 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:`Tuple`, it " -"represents constraints; otherwise it represents the bound. *default_value* " -"is the default value; if the :class:`!TypeVar` has no default, this " -"attribute will be set to ``None``." +"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:" +"`Tuple`, it represents constraints; otherwise it represents the bound. " +"``default_value`` is the default value; if the :class:`!TypeVar` has no " +"default, this attribute will be set to ``None``." msgstr "" "一個 :class:`typing.TypeVar`。``name`` 是型別變數的名稱。``bound`` 是(如果有" "存在的)界限 (bound) 或約束 (constraint)。如果 ``bound`` 是一個 :class:" "`Tuple`,它代表約束;否則它代表界限。" -#: ../../library/ast.rst:1775 +#: ../../library/ast.rst:1812 #, fuzzy msgid "" ">>> print(ast.dump(ast.parse(\"type Alias[T: int = bool] = list[T]\"), " @@ -3218,23 +3282,27 @@ msgstr "" " ctx=Load()))],\n" " type_ignores=[])" -#: ../../library/ast.rst:1794 ../../library/ast.rst:1829 -#: ../../library/ast.rst:1861 +#: ../../library/ast.rst:1831 ../../library/ast.rst:1866 +#: ../../library/ast.rst:1898 #, fuzzy msgid "Added the *default_value* parameter." msgstr "新增 *indent* 選項。" -#: ../../library/ast.rst:1799 +#: ../../library/ast.rst:1836 +#, fuzzy msgid "" -"A :class:`typing.ParamSpec`. *name* is the name of the parameter " -"specification. *default_value* is the default value; if the :class:`!" +"A :class:`typing.ParamSpec`. ``name`` is the name of the parameter " +"specification. ``default_value`` is the default value; if the :class:`!" "ParamSpec` has no default, this attribute will be set to ``None``." msgstr "" +"一個 :class:`typing.TypeVar`。``name`` 是型別變數的名稱。``bound`` 是(如果有" +"存在的)界限 (bound) 或約束 (constraint)。如果 ``bound`` 是一個 :class:" +"`Tuple`,它代表約束;否則它代表界限。" -#: ../../library/ast.rst:1803 +#: ../../library/ast.rst:1840 #, fuzzy msgid "" -">>> print(ast.dump(ast.parse(\"type Alias[**P = (int, str)] = Callable[P, " +">>> print(ast.dump(ast.parse(\"type Alias[**P = [int, str]] = Callable[P, " "int]\"), indent=4))\n" "Module(\n" " body=[\n" @@ -3243,7 +3311,7 @@ msgid "" " type_params=[\n" " ParamSpec(\n" " name='P',\n" -" default_value=Tuple(\n" +" default_value=List(\n" " elts=[\n" " Name(id='int', ctx=Load()),\n" " Name(id='str', ctx=Load())],\n" @@ -3275,18 +3343,18 @@ msgstr "" " ctx=Load()))],\n" " type_ignores=[])" -#: ../../library/ast.rst:1834 +#: ../../library/ast.rst:1871 #, fuzzy msgid "" -"A :class:`typing.TypeVarTuple`. *name* is the name of the type variable " -"tuple. *default_value* is the default value; if the :class:`!TypeVarTuple` " +"A :class:`typing.TypeVarTuple`. ``name`` is the name of the type variable " +"tuple. ``default_value`` is the default value; if the :class:`!TypeVarTuple` " "has no default, this attribute will be set to ``None``." msgstr "" "一個 :class:`typing.TypeVar`。``name`` 是型別變數的名稱。``bound`` 是(如果有" "存在的)界限 (bound) 或約束 (constraint)。如果 ``bound`` 是一個 :class:" "`Tuple`,它代表約束;否則它代表界限。" -#: ../../library/ast.rst:1838 +#: ../../library/ast.rst:1875 #, fuzzy msgid "" ">>> print(ast.dump(ast.parse(\"type Alias[*Ts = ()] = tuple[*Ts]\"), " @@ -3327,27 +3395,27 @@ msgstr "" " ctx=Load()))],\n" " type_ignores=[])" -#: ../../library/ast.rst:1865 +#: ../../library/ast.rst:1902 msgid "Function and class definitions" msgstr "函式和類別定義" -#: ../../library/ast.rst:1869 +#: ../../library/ast.rst:1906 msgid "A function definition." msgstr "一個函式定義。" -#: ../../library/ast.rst:1871 +#: ../../library/ast.rst:1908 msgid "``name`` is a raw string of the function name." msgstr "``name`` 是函式名稱的原始字串。" -#: ../../library/ast.rst:1872 +#: ../../library/ast.rst:1909 msgid "``args`` is an :class:`arguments` node." msgstr "``args`` 是一個 :class:`arguments` 節點。" -#: ../../library/ast.rst:1873 +#: ../../library/ast.rst:1910 msgid "``body`` is the list of nodes inside the function." msgstr "``body`` 是函式內節點的串列。" -#: ../../library/ast.rst:1874 +#: ../../library/ast.rst:1911 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)." @@ -3355,20 +3423,20 @@ msgstr "" "``decorator_list`` 是要應用的裝飾器串列,在最外層者會被儲存在首位(即串列中首" "位將會是最後一個被應用的那個)。" -#: ../../library/ast.rst:1876 +#: ../../library/ast.rst:1913 msgid "``returns`` is the return annotation." msgstr "``returns`` 是回傳註釋。" -#: ../../library/ast.rst:1877 ../../library/ast.rst:2041 +#: ../../library/ast.rst:1914 ../../library/ast.rst:2077 msgid "``type_params`` is a list of :ref:`type parameters `." msgstr "``type_params`` 是\\ :ref:`型別參數 `\\ 的串列。" -#: ../../library/ast.rst:1883 ../../library/ast.rst:2068 -#: ../../library/ast.rst:2079 +#: ../../library/ast.rst:1920 ../../library/ast.rst:2104 +#: ../../library/ast.rst:2115 msgid "Added ``type_params``." msgstr "新增了 ``type_params``。" -#: ../../library/ast.rst:1889 +#: ../../library/ast.rst:1926 msgid "" "``lambda`` is a minimal function definition that can be used inside an " "expression. Unlike :class:`FunctionDef`, ``body`` holds a single node." @@ -3376,7 +3444,7 @@ msgstr "" "``lambda`` 是可以在運算式內使用的最小函式定義。與 :class:`FunctionDef` 不同," "``body`` 保存單個節點。" -#: ../../library/ast.rst:1892 +#: ../../library/ast.rst:1929 #, fuzzy msgid "" ">>> print(ast.dump(ast.parse('lambda x,y: ...'), indent=4))\n" @@ -3406,17 +3474,17 @@ msgstr "" " body=Constant(value=Ellipsis)))],\n" " type_ignores=[])" -#: ../../library/ast.rst:1908 +#: ../../library/ast.rst:1945 msgid "The arguments for a function." msgstr "函式的引數。" -#: ../../library/ast.rst:1910 +#: ../../library/ast.rst:1947 msgid "" "``posonlyargs``, ``args`` and ``kwonlyargs`` are lists of :class:`arg` nodes." msgstr "" "``posonlyargs``、``args`` 和 ``kwonlyargs`` 是 :class:`arg` 節點的串列。" -#: ../../library/ast.rst:1911 +#: ../../library/ast.rst:1948 msgid "" "``vararg`` and ``kwarg`` are single :class:`arg` nodes, referring to the " "``*args, **kwargs`` parameters." @@ -3424,7 +3492,7 @@ msgstr "" "``vararg`` 和 ``kwarg`` 是單個 :class:`arg` 節點,指的是 ``*args, **kwargs`` " "參數。" -#: ../../library/ast.rst:1913 +#: ../../library/ast.rst:1950 msgid "" "``kw_defaults`` is a list of default values for keyword-only arguments. If " "one is ``None``, the corresponding argument is required." @@ -3432,7 +3500,7 @@ msgstr "" "``kw_defaults`` 是僅限關鍵字引數的預設值串列。如果其中某個為 ``None``,則相應" "參數就會是必要的。" -#: ../../library/ast.rst:1915 +#: ../../library/ast.rst:1952 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 " @@ -3441,7 +3509,7 @@ msgstr "" "``defaults`` 是可以按位置傳遞的引數的預設值串列。如果預設值較少,則它們對應於" "最後 n 個引數。" -#: ../../library/ast.rst:1922 +#: ../../library/ast.rst:1959 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." @@ -3449,12 +3517,12 @@ msgstr "" "串列中的單個引數。``arg`` 是引數名稱的原始字串,``annotation`` 是它的註釋,例" "如 :class:`Name` 節點。" -#: ../../library/ast.rst:1927 +#: ../../library/ast.rst:1964 msgid "" "``type_comment`` is an optional string with the type annotation as a comment" msgstr "``type_comment`` 是一個可選字串,其註解為型別註釋" -#: ../../library/ast.rst:1929 +#: ../../library/ast.rst:1966 #, fuzzy msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\\\n" @@ -3532,11 +3600,11 @@ msgstr "" " type_params=[])],\n" " type_ignores=[])" -#: ../../library/ast.rst:1969 +#: ../../library/ast.rst:2006 msgid "A ``return`` statement." msgstr "一個 ``return`` 陳述式。" -#: ../../library/ast.rst:1971 +#: ../../library/ast.rst:2008 #, fuzzy msgid "" ">>> print(ast.dump(ast.parse('return 4'), indent=4))\n" @@ -3552,7 +3620,7 @@ msgstr "" " value=Constant(value=4))],\n" " type_ignores=[])" -#: ../../library/ast.rst:1983 +#: ../../library/ast.rst:2020 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 " @@ -3561,7 +3629,7 @@ msgstr "" "一個 ``yield`` 或 ``yield from`` 運算式。因為這些是運算式,所以如果不使用發送" "回來的值,則必須將它們包裝在 :class:`Expr` 節點中。" -#: ../../library/ast.rst:1986 +#: ../../library/ast.rst:2023 #, fuzzy msgid "" ">>> print(ast.dump(ast.parse('yield x'), indent=4))\n" @@ -3594,12 +3662,12 @@ msgstr "" " value=Name(id='x', ctx=Load())))],\n" " type_ignores=[])" -#: ../../library/ast.rst:2006 +#: ../../library/ast.rst:2043 msgid "" "``global`` and ``nonlocal`` statements. ``names`` is a list of raw strings." msgstr "``global`` 和 ``nonlocal`` 陳述式。``names`` 是原始字串的串列。" -#: ../../library/ast.rst:2008 +#: ../../library/ast.rst:2045 #, fuzzy msgid "" ">>> print(ast.dump(ast.parse('global x,y,z'), indent=4))\n" @@ -3640,39 +3708,39 @@ msgstr "" " 'z'])],\n" " type_ignores=[])" -#: ../../library/ast.rst:2031 +#: ../../library/ast.rst:2068 msgid "A class definition." msgstr "一個類別定義。" -#: ../../library/ast.rst:2033 +#: ../../library/ast.rst:2070 msgid "``name`` is a raw string for the class name" msgstr "``name`` 是類別名的原始字串" -#: ../../library/ast.rst:2034 +#: ../../library/ast.rst:2071 msgid "``bases`` is a list of nodes for explicitly specified base classes." msgstr "``bases`` 是被顯式指定的基底類別節點串列。" -#: ../../library/ast.rst:2035 +#: ../../library/ast.rst:2072 #, fuzzy msgid "" "``keywords`` is a list of :class:`.keyword` nodes, principally for " -"'metaclass'. Other keywords will be passed to the metaclass, as per " -"`PEP-3115 `_." +"'metaclass'. Other keywords will be passed to the metaclass, as per :pep:" +"`3115`." msgstr "" "``keywords`` 是一個 :class:`.keyword` 節點的串列,主要用於 'metaclass'(元類" "別)。如 :pep:`3115` 所述,其他關鍵字將被傳遞到 metaclass。" -#: ../../library/ast.rst:2038 +#: ../../library/ast.rst:2074 msgid "" "``body`` is a list of nodes representing the code within the class " "definition." msgstr "``body`` 是表示類別定義中程式碼的節點串列。" -#: ../../library/ast.rst:2040 +#: ../../library/ast.rst:2076 msgid "``decorator_list`` is a list of nodes, as in :class:`FunctionDef`." msgstr "``decorator_list`` 是一個節點串列,如 :class:`FunctionDef` 中所示。" -#: ../../library/ast.rst:2043 +#: ../../library/ast.rst:2079 #, fuzzy msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\\\n" @@ -3723,17 +3791,17 @@ msgstr "" " type_params=[])],\n" " type_ignores=[])" -#: ../../library/ast.rst:2072 +#: ../../library/ast.rst:2108 msgid "Async and await" msgstr "async 和 await" -#: ../../library/ast.rst:2076 +#: ../../library/ast.rst:2112 msgid "" "An ``async def`` function definition. Has the same fields as :class:" "`FunctionDef`." msgstr "一個 ``async def`` 函式定義。與 :class:`FunctionDef` 具有相同的欄位。" -#: ../../library/ast.rst:2085 +#: ../../library/ast.rst:2121 msgid "" "An ``await`` expression. ``value`` is what it waits for. Only valid in the " "body of an :class:`AsyncFunctionDef`." @@ -3741,7 +3809,7 @@ msgstr "" "一個 ``await`` 運算式。``value`` 是它等待的東西。僅在 :class:" "`AsyncFunctionDef` 主體 (body) 中有效。" -#: ../../library/ast.rst:2088 +#: ../../library/ast.rst:2124 #, fuzzy msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\\\n" @@ -3784,7 +3852,7 @@ msgstr "" " type_params=[])],\n" " type_ignores=[])" -#: ../../library/ast.rst:2109 +#: ../../library/ast.rst:2145 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 " @@ -3793,7 +3861,7 @@ msgstr "" "``async for`` 迴圈和 ``async with`` 情境管理器。它們分別具有與 :class:`For` " "和 :class:`With` 相同的欄位。僅在 :class:`AsyncFunctionDef` 主體中有效。" -#: ../../library/ast.rst:2114 +#: ../../library/ast.rst:2150 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." @@ -3806,11 +3874,11 @@ msgstr "" "boolop` 和 :class:`ast.expr_context`\\ )將是單例。對其中之一的更改將反映在所" "有其他出現的相同值中(例如 :class:`ast.Add`\\ )。" -#: ../../library/ast.rst:2122 +#: ../../library/ast.rst:2158 msgid ":mod:`ast` Helpers" msgstr ":mod:`ast` 輔助程式" -#: ../../library/ast.rst:2124 +#: ../../library/ast.rst:2160 msgid "" "Apart from the node classes, the :mod:`ast` module defines these utility " "functions and classes for traversing abstract syntax trees:" @@ -3818,7 +3886,7 @@ msgstr "" "除了節點類別之外,:mod:`ast` 模組還定義了這些用於遍歷 (traverse) 抽象語法樹的" "實用函式和類別:" -#: ../../library/ast.rst:2129 +#: ../../library/ast.rst:2165 #, fuzzy msgid "" "Parse the source into an AST node. Equivalent to ``compile(source, " @@ -3829,7 +3897,7 @@ msgstr "" "將原始碼剖析為 AST 節點。相當於 ``compile(source, filename, mode, ast." "PyCF_ONLY_AST)``。" -#: ../../library/ast.rst:2134 +#: ../../library/ast.rst:2170 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 " @@ -3848,7 +3916,7 @@ msgstr "" "``None``。此外,``# type: ignore`` 註釋的位置將作為 :class:`Module` 的 " "``type_ignores`` 屬性回傳(否則它始終是一個空串列)。" -#: ../../library/ast.rst:2144 +#: ../../library/ast.rst:2180 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) -> " @@ -3858,7 +3926,7 @@ msgstr "" "名型別註解 (signature type comments)」而被修改,例如 ``(str, int) -> " "List[str]``。" -#: ../../library/ast.rst:2148 +#: ../../library/ast.rst:2184 #, fuzzy msgid "" "Setting ``feature_version`` to a tuple ``(major, minor)`` will result in a " @@ -3879,12 +3947,12 @@ msgstr "" "能保證剖析(或剖析的成功)與在與 ``feature_version`` 對應的 Python 版本上運行" "時相同。" -#: ../../library/ast.rst:2158 +#: ../../library/ast.rst:2194 msgid "" "If source contains a null character (``\\0``), :exc:`ValueError` is raised." msgstr "如果來源包含 null 字元 (``\\0``),則會引發 :exc:`ValueError`。" -#: ../../library/ast.rst:2161 +#: ../../library/ast.rst:2197 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 " @@ -3898,14 +3966,14 @@ msgstr "" "原始的 ``return 42`` 為 return 陳述式生成一個有效的 AST 節點,但它不能單獨編" "譯(它需要位於函式節點內)。" -#: ../../library/ast.rst:2168 +#: ../../library/ast.rst:2204 msgid "" "In particular, :func:`ast.parse` won't do any scoping checks, which the " "compilation step does." msgstr "" "特別是 :func:`ast.parse` 不會執行任何範圍檢查,而編譯步驟才會執行此操作。" -#: ../../library/ast.rst:2172 +#: ../../library/ast.rst:2208 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." @@ -3913,17 +3981,17 @@ msgstr "" "由於 Python AST 編譯器中的堆疊 (stack) 深度限制,太大或太複雜的字串可能會導" "致 Python 直譯器崩潰。" -#: ../../library/ast.rst:2176 +#: ../../library/ast.rst:2212 msgid "Added ``type_comments``, ``mode='func_type'`` and ``feature_version``." msgstr "新增 ``type_comments``、``mode='func_type'`` 與 ``feature_version``。" -#: ../../library/ast.rst:2179 +#: ../../library/ast.rst:2215 msgid "" "The minimum supported version for ``feature_version`` is now ``(3, 7)``. The " "``optimize`` argument was added." msgstr "" -#: ../../library/ast.rst:2186 +#: ../../library/ast.rst:2222 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 :" @@ -3932,7 +4000,7 @@ msgstr "" "反剖析 :class:`ast.AST` 物件並生成一個帶有程式碼的字串,如果使用 :func:`ast." "parse` 剖析回來,該程式碼將生成等效的 :class:`ast.AST` 物件。" -#: ../../library/ast.rst:2191 +#: ../../library/ast.rst:2227 msgid "" "The produced code string will not necessarily be equal to the original code " "that generated the :class:`ast.AST` object (without any compiler " @@ -3941,13 +4009,13 @@ msgstr "" "生成的程式碼字串不一定等於生成 :class:`ast.AST` 物件的原始程式碼(沒有任何編" "譯器最佳化,例如常數元組/凍結集合)。" -#: ../../library/ast.rst:2196 +#: ../../library/ast.rst:2232 msgid "" "Trying to unparse a highly complex expression would result with :exc:" "`RecursionError`." msgstr "嘗試剖析高度複雜的運算式會導致 :exc:`RecursionError`。" -#: ../../library/ast.rst:2204 +#: ../../library/ast.rst:2240 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 " @@ -3958,7 +4026,7 @@ msgstr "" "能包含以下 Python 文本結構:字串、位元組、數字、元組、串列、字典、集合、布林" "值、``None`` 和 ``Ellipsis``。" -#: ../../library/ast.rst:2209 +#: ../../library/ast.rst:2245 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 " @@ -3967,7 +4035,7 @@ msgstr "" "這可用於為包含 Python 值的字串求值,而無需自己剖析這些值。它無法計算任意複雜" "的運算式,例如涉及運算子或索引。" -#: ../../library/ast.rst:2214 +#: ../../library/ast.rst:2250 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 " @@ -3984,13 +4052,13 @@ msgstr "" "盡或 C 堆疊耗盡,從而導致行程崩潰。某些輸入也可能會出現 CPU 消耗過多而導致拒" "絕服務的情況。因此不建議在不受信任的資料上呼叫它。" -#: ../../library/ast.rst:2224 +#: ../../library/ast.rst:2260 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:2227 +#: ../../library/ast.rst:2263 msgid "" "It can raise :exc:`ValueError`, :exc:`TypeError`, :exc:`SyntaxError`, :exc:" "`MemoryError` and :exc:`RecursionError` depending on the malformed input." @@ -3998,19 +4066,19 @@ msgstr "" "它可能會引發 :exc:`ValueError`、:exc:`TypeError`、:exc:`SyntaxError`、:exc:" "`MemoryError` 和 :exc:`RecursionError`,具體取決於格式錯誤的輸入。" -#: ../../library/ast.rst:2231 +#: ../../library/ast.rst:2267 msgid "Now allows bytes and set literals." msgstr "現在允許位元組和集合文本 (set literal)。" -#: ../../library/ast.rst:2234 +#: ../../library/ast.rst:2270 msgid "Now supports creating empty sets with ``'set()'``." msgstr "現在支援使用 ``'set()'`` 建立空集合。" -#: ../../library/ast.rst:2237 +#: ../../library/ast.rst:2273 msgid "For string inputs, leading spaces and tabs are now stripped." msgstr "對於字串輸入,前導空格和定位字元 (tab) 現在已被去除。" -#: ../../library/ast.rst:2243 +#: ../../library/ast.rst:2279 msgid "" "Return the docstring of the given *node* (which must be a :class:" "`FunctionDef`, :class:`AsyncFunctionDef`, :class:`ClassDef`, or :class:" @@ -4022,11 +4090,11 @@ msgstr "" "件字串則為 ``None``。如果 *clean* 為 true,則使用 :func:`inspect.cleandoc` 清" "理文件字串的縮排。" -#: ../../library/ast.rst:2249 +#: ../../library/ast.rst:2285 msgid ":class:`AsyncFunctionDef` is now supported." msgstr "目前已支援 :class:`AsyncFunctionDef`。" -#: ../../library/ast.rst:2255 +#: ../../library/ast.rst:2291 msgid "" "Get source code segment of the *source* that generated *node*. If some " "location information (:attr:`~ast.AST.lineno`, :attr:`~ast.AST.end_lineno`, :" @@ -4037,7 +4105,7 @@ msgstr "" "lineno`、:attr:`~ast.AST.end_lineno`、:attr:`~ast.AST.col_offset` 或 :attr:" "`~ast.AST.end_col_offset`\\ )遺漏,則回傳 ``None``。" -#: ../../library/ast.rst:2259 +#: ../../library/ast.rst:2295 msgid "" "If *padded* is ``True``, the first line of a multi-line statement will be " "padded with spaces to match its original position." @@ -4045,7 +4113,7 @@ msgstr "" "如果 *padded* 為 ``True``,則多列陳述式的第一列將用空格填充 (padded) 以匹配其" "原始位置。" -#: ../../library/ast.rst:2267 +#: ../../library/ast.rst:2303 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 " @@ -4059,7 +4127,7 @@ msgstr "" "要存在。填入生成的節點相當繁瑣,因此該輔助工具透過將這些屬性設定為父節點的" "值,在尚未設定的地方遞迴地新增這些屬性。它從 *node* 開始遞迴地作用。" -#: ../../library/ast.rst:2276 +#: ../../library/ast.rst:2312 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 " @@ -4068,7 +4136,7 @@ msgstr "" "將樹中從 *node* 開始的每個節點的列號和結束列號增加 *n*。這對於「移動程式碼」" "到檔案中的不同位置很有用。" -#: ../../library/ast.rst:2283 +#: ../../library/ast.rst:2319 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 " @@ -4078,7 +4146,7 @@ msgstr "" "attr:`~ast.AST.end_lineno` 和 :attr:`~ast.AST.end_col_offset` )從 " "*old_node* 複製到 *new_node*,並回傳 *new_node* 。" -#: ../../library/ast.rst:2290 +#: ../../library/ast.rst:2326 msgid "" "Yield a tuple of ``(fieldname, value)`` for each field in ``node._fields`` " "that is present on *node*." @@ -4086,7 +4154,7 @@ msgstr "" "為 *node* 上存在的 ``node._fields`` 中的每個欄位生成一個 ``(fieldname, " "value)`` 元組。" -#: ../../library/ast.rst:2296 +#: ../../library/ast.rst:2332 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." @@ -4094,7 +4162,7 @@ msgstr "" "生成 *node* 的所有直接子節點,即作為節點的所有欄位以及作為節點串列欄位的所有" "項目。" -#: ../../library/ast.rst:2302 +#: ../../library/ast.rst:2338 msgid "" "Recursively yield all descendant nodes in the tree starting at *node* " "(including *node* itself), in no specified order. This is useful if you " @@ -4103,7 +4171,7 @@ msgstr "" "遞迴地生成樹中從 *node* 開始的所有後代節點(包括 *node* 本身),不按指定順" "序。如果你只想就地修改節點而不關心情境,這非常有用。" -#: ../../library/ast.rst:2309 +#: ../../library/ast.rst:2345 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 " @@ -4112,13 +4180,13 @@ msgstr "" "節點訪問者基底類別,它遍歷抽象語法樹並為找到的每個節點呼叫訪問者函式。該函式" "可能會回傳一個由 :meth:`visit` 方法轉發的值。" -#: ../../library/ast.rst:2313 +#: ../../library/ast.rst:2349 msgid "" "This class is meant to be subclassed, with the subclass adding visitor " "methods." msgstr "這個類別應該被子類別化,子類別新增訪問者方法。" -#: ../../library/ast.rst:2318 +#: ../../library/ast.rst:2354 msgid "" "Visit a node. The default implementation calls the method called :samp:" "`self.visit_{classname}` where *classname* is the name of the node class, " @@ -4128,11 +4196,11 @@ msgstr "" "*classname* 是節點類別的名稱,或者在該方法不存在時呼叫 :meth:" "`generic_visit`。" -#: ../../library/ast.rst:2324 +#: ../../library/ast.rst:2360 msgid "This visitor calls :meth:`visit` on all children of the node." msgstr "該訪問者對該節點的所有子節點呼叫 :meth:`visit`。" -#: ../../library/ast.rst:2326 +#: ../../library/ast.rst:2362 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." @@ -4140,11 +4208,11 @@ msgstr "" "請注意,除非訪問者呼叫 :meth:`generic_visit` 或訪問它們本身,否則不會訪問具有" "自定義訪問者方法的節點之子節點。" -#: ../../library/ast.rst:2332 +#: ../../library/ast.rst:2368 msgid "Handles all constant nodes." msgstr "處理所有常數節點。" -#: ../../library/ast.rst:2334 +#: ../../library/ast.rst:2370 msgid "" "Don't use the :class:`NodeVisitor` if you want to apply changes to nodes " "during traversal. For this a special visitor exists (:class:" @@ -4154,7 +4222,7 @@ msgstr "" "`NodeVisitor`。為此,有個允許修改的特殊遍歷訪問者工具 :class:" "`NodeTransformer`。" -#: ../../library/ast.rst:2340 +#: ../../library/ast.rst:2376 msgid "" "Methods :meth:`!visit_Num`, :meth:`!visit_Str`, :meth:`!visit_Bytes`, :meth:" "`!visit_NameConstant` and :meth:`!visit_Ellipsis` are deprecated now and " @@ -4165,13 +4233,13 @@ msgstr "" "visit_NameConstant` 和 :meth:`!visit_Ellipsis` 方法現已棄用,並且不會在未來的" "Python 版本中被呼叫。新增 :meth:`visit_Constant` 方法來處理所有常數節點。" -#: ../../library/ast.rst:2348 +#: ../../library/ast.rst:2384 msgid "" "A :class:`NodeVisitor` subclass that walks the abstract syntax tree and " "allows modification of nodes." msgstr "一個 :class:`NodeVisitor` 子類別,它會遍歷抽象語法樹並允許修改節點。" -#: ../../library/ast.rst:2351 +#: ../../library/ast.rst:2387 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 " @@ -4183,7 +4251,7 @@ msgstr "" "點。如果訪問者方法的回傳值為 ``None``,則該節點將從其位置中刪除,否則將被替換" "為回傳值。回傳值可能是原始節點,在這種情況下不會發生替換。" -#: ../../library/ast.rst:2357 +#: ../../library/ast.rst:2393 msgid "" "Here is an example transformer that rewrites all occurrences of name lookups " "(``foo``) to ``data['foo']``::" @@ -4191,7 +4259,7 @@ msgstr "" "下面是一個示範用的 transformer,它將查找所有出現名稱 (``foo``) 並改寫為 " "``data['foo']``: ::" -#: ../../library/ast.rst:2360 +#: ../../library/ast.rst:2396 msgid "" "class RewriteName(NodeTransformer):\n" "\n" @@ -4211,7 +4279,7 @@ msgstr "" " ctx=node.ctx\n" " )" -#: ../../library/ast.rst:2369 +#: ../../library/ast.rst:2405 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." @@ -4220,7 +4288,7 @@ msgstr "" "請記住,如果你正在操作的節點有子節點,你必須自己轉換子節點或先呼叫該節點的 :" "meth:`~ast.NodeVisitor.generic_visit` 方法。" -#: ../../library/ast.rst:2373 +#: ../../library/ast.rst:2409 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 " @@ -4229,7 +4297,7 @@ msgstr "" "對於屬於陳述式總集 (collection) 一部分的節點(適用於所有陳述式節點),訪問者" "還可以回傳節點串列,而不僅僅是單個節點。" -#: ../../library/ast.rst:2377 +#: ../../library/ast.rst:2413 msgid "" "If :class:`NodeTransformer` introduces new nodes (that weren't part of " "original tree) without giving them location information (such as :attr:`~ast." @@ -4240,7 +4308,7 @@ msgstr "" "它們提供位置資訊(例如 :attr:`~ast.AST.lineno`\\ ),則應使用新的子樹呼叫 :" "func:`fix_missing_locations` 以重新計算位置資訊: ::" -#: ../../library/ast.rst:2382 +#: ../../library/ast.rst:2418 msgid "" "tree = ast.parse('foo', mode='eval')\n" "new_tree = fix_missing_locations(RewriteName().visit(tree))" @@ -4248,15 +4316,15 @@ msgstr "" "tree = ast.parse('foo', mode='eval')\n" "new_tree = fix_missing_locations(RewriteName().visit(tree))" -#: ../../library/ast.rst:2385 +#: ../../library/ast.rst:2421 msgid "Usually you use the transformer like this::" msgstr "你通常會像這樣使用 transformer: ::" -#: ../../library/ast.rst:2387 +#: ../../library/ast.rst:2423 msgid "node = YourTransformer().visit(node)" msgstr "node = YourTransformer().visit(node)" -#: ../../library/ast.rst:2392 +#: ../../library/ast.rst:2428 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 " @@ -4272,7 +4340,7 @@ msgstr "" "潔。預設情況下,不會傾印列號和行偏移量等屬性。如果需要,可以設定 " "*include_attributes* 為 true。" -#: ../../library/ast.rst:2400 +#: ../../library/ast.rst:2436 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 " @@ -4286,22 +4354,22 @@ msgstr "" "(預設值)代表選擇單列表示。使用正整數縮排可以在每個級別縮排相同數量的空格。" "如果 *indent* 是一個字串(例如 ``\"\\t\"``\\ ),則該字串用於縮排每個級別。" -#: ../../library/ast.rst:2407 +#: ../../library/ast.rst:2443 msgid "" "If *show_empty* is ``False`` (the default), empty lists and fields that are " "``None`` will be omitted from the output." msgstr "" -#: ../../library/ast.rst:2410 +#: ../../library/ast.rst:2446 msgid "Added the *indent* option." msgstr "新增 *indent* 選項。" -#: ../../library/ast.rst:2413 +#: ../../library/ast.rst:2449 #, fuzzy msgid "Added the *show_empty* option." msgstr "新增 *indent* 選項。" -#: ../../library/ast.rst:2416 +#: ../../library/ast.rst:2452 #, fuzzy msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\\\n" @@ -4354,17 +4422,17 @@ msgstr "" " type_params=[])],\n" " type_ignores=[])" -#: ../../library/ast.rst:2447 +#: ../../library/ast.rst:2483 msgid "Compiler Flags" msgstr "編譯器旗標" -#: ../../library/ast.rst:2449 +#: ../../library/ast.rst:2485 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:2454 +#: ../../library/ast.rst:2490 msgid "" "Enables support for top-level ``await``, ``async for``, ``async with`` and " "async comprehensions." @@ -4372,19 +4440,19 @@ msgstr "" "啟用對最高階 ``await``、``async for``、``async with`` 和非同步綜合運算的支" "援。" -#: ../../library/ast.rst:2461 +#: ../../library/ast.rst:2497 msgid "" "Generates and returns an abstract syntax tree instead of returning a " "compiled code object." msgstr "生成並回傳抽象語法樹,而不是回傳已編譯的程式碼物件。" -#: ../../library/ast.rst:2466 +#: ../../library/ast.rst:2502 msgid "" "The returned AST is optimized according to the *optimize* argument in :func:" "`compile` or :func:`ast.parse`." msgstr "" -#: ../../library/ast.rst:2473 +#: ../../library/ast.rst:2509 msgid "" "Enables support for :pep:`484` and :pep:`526` style type comments (``# type: " "``, ``# type: ignore ``)." @@ -4392,47 +4460,47 @@ msgstr "" "啟用對 :pep:`484` 和 :pep:`526` 樣式型別註釋的支援 (``# type: ``, ``# " "type: ignore ``)。" -#: ../../library/ast.rst:2482 +#: ../../library/ast.rst:2518 msgid "Command-Line Usage" msgstr "命令列用法" -#: ../../library/ast.rst:2486 +#: ../../library/ast.rst:2522 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:2489 +#: ../../library/ast.rst:2525 msgid "python -m ast [-m ] [-a] [infile]" msgstr "python -m ast [-m ] [-a] [infile]" -#: ../../library/ast.rst:2493 +#: ../../library/ast.rst:2529 msgid "The following options are accepted:" msgstr "以下選項可被接受:" -#: ../../library/ast.rst:2499 +#: ../../library/ast.rst:2535 msgid "Show the help message and exit." msgstr "顯示幫助訊息並退出。" -#: ../../library/ast.rst:2504 +#: ../../library/ast.rst:2540 msgid "" "Specify what kind of code must be compiled, like the *mode* argument in :" "func:`parse`." msgstr "指定必須編譯哪種類型的程式碼,像是 :func:`parse` 中的 *mode* 引數。" -#: ../../library/ast.rst:2509 +#: ../../library/ast.rst:2545 msgid "Don't parse type comments." msgstr "不要剖析型別註解。" -#: ../../library/ast.rst:2513 +#: ../../library/ast.rst:2549 msgid "Include attributes such as line numbers and column offsets." msgstr "包括列號和行偏移量等屬性。" -#: ../../library/ast.rst:2518 +#: ../../library/ast.rst:2554 msgid "Indentation of nodes in AST (number of spaces)." msgstr "AST 中節點的縮進(空格數)。" -#: ../../library/ast.rst:2520 +#: ../../library/ast.rst:2556 msgid "" "If :file:`infile` is specified its contents are parsed to AST and dumped to " "stdout. Otherwise, the content is read from stdin." @@ -4440,7 +4508,7 @@ msgstr "" "如果指定了 :file:`infile`,則其內容將被剖析為 AST 並傾印 (dump) 到 stdout。否" "則會從 stdin 讀取內容。" -#: ../../library/ast.rst:2526 +#: ../../library/ast.rst:2562 msgid "" "`Green Tree Snakes `_, an external " "documentation resource, has good details on working with Python ASTs." @@ -4448,7 +4516,7 @@ msgstr "" "`Green Tree Snakes `_ 是一個外部文件" "資源,提供了有關使用 Python AST 的詳細資訊。" -#: ../../library/ast.rst:2529 +#: ../../library/ast.rst:2565 msgid "" "`ASTTokens `_ " "annotates Python ASTs with the positions of tokens and text in the source " @@ -4459,7 +4527,7 @@ msgstr "" "用生成它們的原始碼中的標記和文本的位置來註釋 Python AST。這對於進行原始碼轉換" "的工具很有幫助。" -#: ../../library/ast.rst:2534 +#: ../../library/ast.rst:2570 msgid "" "`leoAst.py `_ unifies the token-based and parse-tree-based views of python programs " @@ -4469,7 +4537,7 @@ msgstr "" "py>`_ 透過在 token 和 ast 節點之間插入雙向鏈結,統一了 python 程式的基於 " "token 和基於剖析樹的視圖。" -#: ../../library/ast.rst:2539 +#: ../../library/ast.rst:2575 msgid "" "`LibCST `_ parses code as a Concrete Syntax " "Tree that looks like an ast tree and keeps all formatting details. It's " @@ -4479,7 +4547,7 @@ msgstr "" "(Concrete Syntax Tree),看起來像 ast 樹並保留所有格式詳細資訊。它對於建置自動" "重構 (codemod) 應用程式和 linter 非常有用。" -#: ../../library/ast.rst:2544 +#: ../../library/ast.rst:2580 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 new file mode 100644 index 0000000000..2b8afdd76d --- /dev/null +++ b/library/asynchat.po @@ -0,0 +1,39 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2001-2024, Python Software Foundation +# This file is distributed under the same license as the Python package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Python 3.13\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-11-20 09:21+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/asynchat.rst:2 +msgid ":mod:`!asynchat` --- Asynchronous socket command/response handler" +msgstr "" + +#: ../../library/asynchat.rst:10 +msgid "" +"This module is no longer part of the Python standard library. It was :ref:" +"`removed in Python 3.12 ` after being deprecated in " +"Python 3.6. The removal was decided in :pep:`594`." +msgstr "" + +#: ../../library/asynchat.rst:14 +msgid "Applications should use the :mod:`asyncio` module instead." +msgstr "" + +#: ../../library/asynchat.rst:16 +msgid "" +"The last version of Python that provided the :mod:`!asynchat` module was " +"`Python 3.11 `_." +msgstr "" diff --git a/library/asyncio-eventloop.po b/library/asyncio-eventloop.po index 3e07964e9d..eaffe2bc45 100644 --- a/library/asyncio-eventloop.po +++ b/library/asyncio-eventloop.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-04-24 05:56+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-" @@ -278,7 +278,7 @@ msgid "" "called after the event loop is closed." msgstr "此方法是冪等且不可逆的。在事件迴圈關閉後不應呼叫其他方法。" -#: ../../library/asyncio-eventloop.rst:167 +#: ../../library/asyncio-eventloop.rst:168 msgid "" "Schedule all currently open :term:`asynchronous generator` objects to close " "with an :meth:`~agen.aclose` call. After calling this method, the event " @@ -289,19 +289,19 @@ msgstr "" "用 :meth:`~agen.aclose` 呼叫來關閉。呼叫此方法後,如果疊代新的非同步產生器," "事件迴圈將發出警告。應該使用此方法可靠地完成所有已排程的非同步產生器。" -#: ../../library/asyncio-eventloop.rst:173 +#: ../../library/asyncio-eventloop.rst:174 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:176 -#: ../../library/asyncio-eventloop.rst:1269 -#: ../../library/asyncio-eventloop.rst:1712 +#: ../../library/asyncio-eventloop.rst:177 +#: ../../library/asyncio-eventloop.rst:1301 +#: ../../library/asyncio-eventloop.rst:1750 msgid "Example::" msgstr "範例: ::" -#: ../../library/asyncio-eventloop.rst:178 +#: ../../library/asyncio-eventloop.rst:179 msgid "" "try:\n" " loop.run_forever()\n" @@ -315,7 +315,7 @@ msgstr "" " loop.run_until_complete(loop.shutdown_asyncgens())\n" " loop.close()" -#: ../../library/asyncio-eventloop.rst:188 +#: ../../library/asyncio-eventloop.rst:190 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 " @@ -326,7 +326,7 @@ msgstr "" "ThreadPoolExecutor` 中的所有執行緒。一旦呼叫了此方法,使用預設執行器與 :meth:" "`loop.run_in_executor` 將引發 :exc:`RuntimeError`。" -#: ../../library/asyncio-eventloop.rst:194 +#: ../../library/asyncio-eventloop.rst:196 msgid "" "The *timeout* parameter specifies the amount of time (in :class:`float` " "seconds) the executor will be given to finish joining. With the default, " @@ -335,7 +335,7 @@ msgstr "" "*timeout* 參數指定執行器完成加入所需的時間(以 :class:`float` 秒為單位)。預" "設情況下為 ``None``,不會限制執行器所花費的時間。" -#: ../../library/asyncio-eventloop.rst:199 +#: ../../library/asyncio-eventloop.rst:201 msgid "" "If the *timeout* is reached, a :exc:`RuntimeWarning` is emitted and the " "default executor is terminated without waiting for its threads to finish " @@ -344,7 +344,7 @@ msgstr "" "如果達到 *timeout*,將發出 :exc:`RuntimeWarning` 警告,預設執行器將立即終止," "不等待其執行緒完成加入。" -#: ../../library/asyncio-eventloop.rst:205 +#: ../../library/asyncio-eventloop.rst:207 msgid "" "Do not call this method when using :func:`asyncio.run`, as the latter " "handles default executor shutdown automatically." @@ -352,34 +352,34 @@ msgstr "" "使用 :func:`asyncio.run` 時請勿呼叫此方法,因為後者會自動處理預設執行器的關" "閉。" -#: ../../library/asyncio-eventloop.rst:210 +#: ../../library/asyncio-eventloop.rst:212 msgid "Added the *timeout* parameter." msgstr "加入 *timeout* 參數。" -#: ../../library/asyncio-eventloop.rst:214 +#: ../../library/asyncio-eventloop.rst:216 msgid "Scheduling callbacks" msgstr "排程回呼函式" -#: ../../library/asyncio-eventloop.rst:218 +#: ../../library/asyncio-eventloop.rst:220 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:221 +#: ../../library/asyncio-eventloop.rst:223 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:224 +#: ../../library/asyncio-eventloop.rst:226 msgid "" "Callbacks are called in the order in which they are registered. Each " "callback will be called exactly once." msgstr "回呼函式按照其註冊的順序呼叫。每個回呼函式將被呼叫恰好一次。" -#: ../../library/asyncio-eventloop.rst:227 +#: ../../library/asyncio-eventloop.rst:229 msgid "" "The optional keyword-only *context* argument specifies a custom :class:" "`contextvars.Context` for the *callback* to run in. Callbacks use the " @@ -388,11 +388,11 @@ msgstr "" "選用的僅限關鍵字引數 *context* 指定了要給 *callback* 執行的自定義 :class:" "`contextvars.Context`。當未提供 *context* 時,回呼函式使用當前情境。" -#: ../../library/asyncio-eventloop.rst:231 +#: ../../library/asyncio-eventloop.rst:233 msgid "Unlike :meth:`call_soon_threadsafe`, this method is not thread-safe." msgstr "與 :meth:`call_soon_threadsafe` 不同,此方法不是執行緒安全的。" -#: ../../library/asyncio-eventloop.rst:235 +#: ../../library/asyncio-eventloop.rst:237 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 " @@ -401,7 +401,14 @@ msgstr "" "這是 :meth:`call_soon` 的執行緒安全變體。當從另一個執行緒排程回呼函式時,*必" "須*\\ 使用此函式,因為 :meth:`call_soon` 不是執行緒安全的。" -#: ../../library/asyncio-eventloop.rst:239 +#: ../../library/asyncio-eventloop.rst:241 +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 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." @@ -409,21 +416,21 @@ msgstr "" "如果在已關閉的迴圈上呼叫,則引發 :exc:`RuntimeError`。在主應用程式關閉時,這" "可能發生在次要執行緒上。" -#: ../../library/asyncio-eventloop.rst:243 +#: ../../library/asyncio-eventloop.rst:248 msgid "" "See the :ref:`concurrency and multithreading ` " "section of the documentation." msgstr "請參閱文件的\\ :ref:`並行和多執行緒 `\\ 部分。" -#: ../../library/asyncio-eventloop.rst:246 -#: ../../library/asyncio-eventloop.rst:296 -#: ../../library/asyncio-eventloop.rst:316 +#: ../../library/asyncio-eventloop.rst:251 +#: ../../library/asyncio-eventloop.rst:301 +#: ../../library/asyncio-eventloop.rst:321 msgid "" "The *context* keyword-only parameter was added. See :pep:`567` for more " "details." msgstr "新增了 *context* 僅限關鍵字參數。詳細資訊請參閱 :pep:`567`。" -#: ../../library/asyncio-eventloop.rst:254 +#: ../../library/asyncio-eventloop.rst:259 msgid "" "Most :mod:`asyncio` scheduling functions don't allow passing keyword " "arguments. To do that, use :func:`functools.partial`::" @@ -431,14 +438,14 @@ msgstr "" "大多數 :mod:`asyncio` 排程函式不允許傳遞關鍵字引數。要傳遞關鍵字引數,請使" "用 :func:`functools.partial`: ::" -#: ../../library/asyncio-eventloop.rst:257 +#: ../../library/asyncio-eventloop.rst:262 msgid "" "# will schedule \"print(\"Hello\", flush=True)\"\n" "loop.call_soon(\n" " functools.partial(print, \"Hello\", flush=True))" msgstr "" -#: ../../library/asyncio-eventloop.rst:261 +#: ../../library/asyncio-eventloop.rst:266 msgid "" "Using partial objects is usually more convenient than using lambdas, as " "asyncio can render partial objects better in debug and error messages." @@ -446,11 +453,11 @@ msgstr "" "通常使用 partial 物件比使用 lambda 更方便,因為 asyncio 可以在除錯和錯誤訊息" "中更好地呈現 partial 物件。" -#: ../../library/asyncio-eventloop.rst:269 +#: ../../library/asyncio-eventloop.rst:274 msgid "Scheduling delayed callbacks" msgstr "排程延遲的回呼函式" -#: ../../library/asyncio-eventloop.rst:271 +#: ../../library/asyncio-eventloop.rst:276 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." @@ -458,20 +465,20 @@ msgstr "" "事件迴圈提供為回呼函式排程在將來某個時間點才呼叫的機制。事件迴圈使用了單調時" "鐘來追蹤時間。" -#: ../../library/asyncio-eventloop.rst:278 +#: ../../library/asyncio-eventloop.rst:283 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:281 -#: ../../library/asyncio-eventloop.rst:313 +#: ../../library/asyncio-eventloop.rst:286 +#: ../../library/asyncio-eventloop.rst:318 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:284 +#: ../../library/asyncio-eventloop.rst:289 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." @@ -479,7 +486,7 @@ msgstr "" "*callback* 將只被呼叫恰好一次。如果有兩個回呼函式被排程在完全相同的時間,則其" "呼叫順序是不定的。" -#: ../../library/asyncio-eventloop.rst:288 +#: ../../library/asyncio-eventloop.rst:293 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 :" @@ -488,7 +495,7 @@ msgstr "" "可選的位置引數 *args* 將在呼叫回呼函式時傳遞。如果要使用關鍵字引數呼叫回呼函" "數,請使用 :func:`functools.partial`。" -#: ../../library/asyncio-eventloop.rst:292 +#: ../../library/asyncio-eventloop.rst:297 msgid "" "An optional keyword-only *context* argument allows specifying a custom :" "class:`contextvars.Context` for the *callback* to run in. The current " @@ -497,7 +504,7 @@ msgstr "" "可選的僅限關鍵字 *context* 引數允許為 *callback* 指定自定義的 :class:" "`contextvars.Context` 以提供運行。當未提供 *context* 時,將使用當前情境。" -#: ../../library/asyncio-eventloop.rst:300 +#: ../../library/asyncio-eventloop.rst:305 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." @@ -505,7 +512,7 @@ msgstr "" "在 Python 3.7 及更早版本中,使用預設事件迴圈實作時,*delay* 不能超過一天。這" "在 Python 3.8 中已經修復。" -#: ../../library/asyncio-eventloop.rst:307 +#: ../../library/asyncio-eventloop.rst:312 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`." @@ -513,11 +520,11 @@ msgstr "" "排程 *callback* 在給定的絕對時間戳 *when* (整數或浮點數)處呼叫,使用與 :" "meth:`loop.time` 相同的時間參照。" -#: ../../library/asyncio-eventloop.rst:311 +#: ../../library/asyncio-eventloop.rst:316 msgid "This method's behavior is the same as :meth:`call_later`." msgstr "此方法的行為與 :meth:`call_later` 相同。" -#: ../../library/asyncio-eventloop.rst:320 +#: ../../library/asyncio-eventloop.rst:325 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. " @@ -526,13 +533,13 @@ msgstr "" "在 Python 3.7 及更早版本中,使用預設事件迴圈實作時,*when* 和當前時間之間的差" "值不能超過一天。這在 Python 3.8 中已經修復。" -#: ../../library/asyncio-eventloop.rst:327 +#: ../../library/asyncio-eventloop.rst:332 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:331 +#: ../../library/asyncio-eventloop.rst:336 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." @@ -540,19 +547,19 @@ msgstr "" "在 Python 3.7 及更早版本中,超時(相對 *delay* 或絕對 *when*)不應超過一天。" "這在 Python 3.8 中已經修復。" -#: ../../library/asyncio-eventloop.rst:337 +#: ../../library/asyncio-eventloop.rst:342 msgid "The :func:`asyncio.sleep` function." msgstr "函式 :func:`asyncio.sleep`。" -#: ../../library/asyncio-eventloop.rst:341 +#: ../../library/asyncio-eventloop.rst:346 msgid "Creating Futures and Tasks" msgstr "建立 Futures 和 Tasks" -#: ../../library/asyncio-eventloop.rst:345 +#: ../../library/asyncio-eventloop.rst:350 msgid "Create an :class:`asyncio.Future` object attached to the event loop." msgstr "建立附加到事件迴圈的 :class:`asyncio.Future` 物件。" -#: ../../library/asyncio-eventloop.rst:347 +#: ../../library/asyncio-eventloop.rst:352 msgid "" "This is the preferred way to create Futures in asyncio. This lets third-" "party event loops provide alternative implementations of the Future object " @@ -561,13 +568,13 @@ msgstr "" "這是在 asyncio 中建立 Futures 的首選方式。這允許第三方事件迴圈提供 Future 物" "件的替代實作(具有更好的性能或儀器計測表現)。" -#: ../../library/asyncio-eventloop.rst:355 +#: ../../library/asyncio-eventloop.rst:360 msgid "" "Schedule the execution of :ref:`coroutine ` *coro*. Return a :" "class:`Task` object." msgstr "排程執行\\ :ref:`協程 ` *coro*。回傳 :class:`Task` 物件。" -#: ../../library/asyncio-eventloop.rst:358 +#: ../../library/asyncio-eventloop.rst:363 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:" @@ -576,7 +583,7 @@ msgstr "" "第三方事件迴圈可以使用其自己的 :class:`Task` 子類別以實現互操作性" "(interoperability)。在這種情況下,結果類型是 :class:`Task` 的子類別。" -#: ../../library/asyncio-eventloop.rst:362 +#: ../../library/asyncio-eventloop.rst:367 msgid "" "If the *name* argument is provided and not ``None``, it is set as the name " "of the task using :meth:`Task.set_name`." @@ -584,7 +591,7 @@ msgstr "" "如果提供了 *name* 引數且不為 ``None``,則將其設置為任務的名稱,使用 :meth:" "`Task.set_name`。" -#: ../../library/asyncio-eventloop.rst:365 +#: ../../library/asyncio-eventloop.rst:370 msgid "" "An optional keyword-only *context* argument allows specifying a custom :" "class:`contextvars.Context` for the *coro* to run in. The current context " @@ -594,46 +601,47 @@ msgstr "" "`contextvars.Context` 以提供運行。當未提供 *context* 時,將建立當前情境的副" "本。" -#: ../../library/asyncio-eventloop.rst:369 +#: ../../library/asyncio-eventloop.rst:374 msgid "Added the *name* parameter." msgstr "加入 *name* 參數。" -#: ../../library/asyncio-eventloop.rst:372 +#: ../../library/asyncio-eventloop.rst:377 msgid "Added the *context* parameter." msgstr "加入 *context* 參數。" -#: ../../library/asyncio-eventloop.rst:377 +#: ../../library/asyncio-eventloop.rst:382 msgid "Set a task factory that will be used by :meth:`loop.create_task`." msgstr "設置將由 :meth:`loop.create_task` 使用的任務工廠。" -#: ../../library/asyncio-eventloop.rst:380 +#: ../../library/asyncio-eventloop.rst:385 +#, fuzzy msgid "" "If *factory* is ``None`` the default task factory will be set. Otherwise, " "*factory* must be a *callable* with the signature matching ``(loop, coro, " -"context=None)``, where *loop* is a reference to the active event loop, and " -"*coro* is a coroutine object. The callable must return a :class:`asyncio." -"Future`-compatible object." +"**kwargs)``, where *loop* is a reference to the active event loop, and " +"*coro* is a coroutine object. The callable must pass on all *kwargs*, and " +"return a :class:`asyncio.Task`-compatible object." msgstr "" "如果 *factory* 為 ``None``,將設置預設的任務工廠。否則,*factory* 必須是一個" "具有匹配簽名 ``(loop, coro, context=None)`` 的 *callable*,其中 *loop* 是有效" "事件迴圈的參照,*coro* 是一個協程物件。該可呼叫物件必須回傳一個與 :class:" "`asyncio.Future` 相容的物件。" -#: ../../library/asyncio-eventloop.rst:388 +#: ../../library/asyncio-eventloop.rst:393 msgid "Return a task factory or ``None`` if the default one is in use." msgstr "回傳任務工廠,如果使用預設任務工廠則回傳 ``None``。" -#: ../../library/asyncio-eventloop.rst:392 +#: ../../library/asyncio-eventloop.rst:397 msgid "Opening network connections" msgstr "打開網路連線" -#: ../../library/asyncio-eventloop.rst:403 +#: ../../library/asyncio-eventloop.rst:409 msgid "" "Open a streaming transport connection to a given address specified by *host* " "and *port*." msgstr "打開以 *host* 和 *port* 指定之給定地址的串流傳輸連線。" -#: ../../library/asyncio-eventloop.rst:406 +#: ../../library/asyncio-eventloop.rst:412 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 " @@ -642,13 +650,13 @@ msgstr "" "根據 *host*(或提供的 *family* 引數)的情況,socket 家族可以是 :py:const:" "`~socket.AF_INET` 或 :py:const:`~socket.AF_INET6`。" -#: ../../library/asyncio-eventloop.rst:410 +#: ../../library/asyncio-eventloop.rst:416 msgid "The socket type will be :py:const:`~socket.SOCK_STREAM`." msgstr "Socket 類型將為 :py:const:`~socket.SOCK_STREAM`。" -#: ../../library/asyncio-eventloop.rst:412 -#: ../../library/asyncio-eventloop.rst:1180 -#: ../../library/asyncio-eventloop.rst:1196 +#: ../../library/asyncio-eventloop.rst:418 +#: ../../library/asyncio-eventloop.rst:1211 +#: ../../library/asyncio-eventloop.rst:1228 msgid "" "*protocol_factory* must be a callable returning an :ref:`asyncio protocol " "` implementation." @@ -656,24 +664,24 @@ msgstr "" "*protocol_factory* 必須是一個回傳 :ref:`asyncio protocol ` " "實作的可呼叫函式。" -#: ../../library/asyncio-eventloop.rst:415 +#: ../../library/asyncio-eventloop.rst:421 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:418 +#: ../../library/asyncio-eventloop.rst:424 msgid "The chronological synopsis of the underlying operation is as follows:" msgstr "底層操作的時間軸簡介如下:" -#: ../../library/asyncio-eventloop.rst:420 +#: ../../library/asyncio-eventloop.rst:426 msgid "" "The connection is established and a :ref:`transport ` is " "created for it." msgstr "建立連線並為其建立\\ :ref:`傳輸 `。" -#: ../../library/asyncio-eventloop.rst:423 +#: ../../library/asyncio-eventloop.rst:429 msgid "" "*protocol_factory* is called without arguments and is expected to return a :" "ref:`protocol ` instance." @@ -681,7 +689,7 @@ msgstr "" "*protocol_factory* 在無引數的情況下被呼叫,並且預計回傳一個 :ref:`協定 " "` 實例。" -#: ../../library/asyncio-eventloop.rst:426 +#: ../../library/asyncio-eventloop.rst:432 msgid "" "The protocol instance is coupled with the transport by calling its :meth:" "`~BaseProtocol.connection_made` method." @@ -689,21 +697,21 @@ msgstr "" "通過呼叫其 :meth:`~BaseProtocol.connection_made` 方法,將協議實例與傳輸連線在" "一起。" -#: ../../library/asyncio-eventloop.rst:429 +#: ../../library/asyncio-eventloop.rst:435 msgid "A ``(transport, protocol)`` tuple is returned on success." msgstr "成功時回傳一個 ``(transport, protocol)`` 元組。" -#: ../../library/asyncio-eventloop.rst:431 +#: ../../library/asyncio-eventloop.rst:437 msgid "" "The created transport is an implementation-dependent bidirectional stream." msgstr "建立的傳輸是一個依賴實作的雙向串流。" -#: ../../library/asyncio-eventloop.rst:434 -#: ../../library/asyncio-eventloop.rst:566 +#: ../../library/asyncio-eventloop.rst:440 +#: ../../library/asyncio-eventloop.rst:573 msgid "Other arguments:" msgstr "其他引數:" -#: ../../library/asyncio-eventloop.rst:436 +#: ../../library/asyncio-eventloop.rst:442 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` " @@ -715,11 +723,11 @@ msgstr "" "果 *ssl* 為 :class:`ssl.SSLContext` 物件,則使用該情境來建立傳輸;如果 *ssl* " "為 :const:`True`,則使用 :func:`ssl.create_default_context` 回傳的預設情境。" -#: ../../library/asyncio-eventloop.rst:442 +#: ../../library/asyncio-eventloop.rst:448 msgid ":ref:`SSL/TLS security considerations `" msgstr ":ref:`SSL/TLS 安全考量 `" -#: ../../library/asyncio-eventloop.rst:444 +#: ../../library/asyncio-eventloop.rst:450 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 " @@ -734,7 +742,7 @@ msgstr "" "預設值,必須傳遞 *server_hostname* 的值。若 *server_hostname* 為空字串,將停" "用主機名稱匹配(這是一個嚴重的安全風險,可能導致中間人攻擊)。" -#: ../../library/asyncio-eventloop.rst:452 +#: ../../library/asyncio-eventloop.rst:458 msgid "" "*family*, *proto*, *flags* are the optional address family, protocol and " "flags to be passed through to getaddrinfo() for *host* resolution. If given, " @@ -745,7 +753,7 @@ msgstr "" "getaddrinfo() 進行 *host* 解析。若有給定這些應該都是相應 :mod:`socket` 模組常" "數的整數。" -#: ../../library/asyncio-eventloop.rst:457 +#: ../../library/asyncio-eventloop.rst:463 msgid "" "*happy_eyeballs_delay*, if given, enables Happy Eyeballs for this " "connection. It should be a floating-point number representing the amount of " @@ -759,7 +767,7 @@ msgstr "" "`8305` 中定義的「連線嘗試延遲」。RFC 建議的合理預設值為 ``0.25`` 秒(250 毫" "秒)。" -#: ../../library/asyncio-eventloop.rst:465 +#: ../../library/asyncio-eventloop.rst:471 msgid "" "*interleave* controls address reordering when a host name resolves to " "multiple IP addresses. If ``0`` or unspecified, no reordering is done, and " @@ -775,7 +783,7 @@ msgstr "" "族計數」。如果未指定 *happy_eyeballs_delay*,則預設值為 ``0``,如果指定則為 " "``1``。" -#: ../../library/asyncio-eventloop.rst:474 +#: ../../library/asyncio-eventloop.rst:480 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 " @@ -786,9 +794,9 @@ msgstr "" "輸使用。如果提供了 *sock*,則不應指定 *host*、*port*、*family*、*proto*、" "*flags*、*happy_eyeballs_delay*、*interleave* 和 *local_addr* 中的任何一項。" -#: ../../library/asyncio-eventloop.rst:482 -#: ../../library/asyncio-eventloop.rst:597 -#: ../../library/asyncio-eventloop.rst:841 +#: ../../library/asyncio-eventloop.rst:488 +#: ../../library/asyncio-eventloop.rst:604 +#: ../../library/asyncio-eventloop.rst:852 msgid "" "The *sock* argument transfers ownership of the socket to the transport " "created. To close the socket, call the transport's :meth:`~asyncio." @@ -797,7 +805,7 @@ msgstr "" "引數 *sock* 將 socket 所有權轉移給所建立的傳輸 socket,請呼叫傳輸的 :meth:" "`~asyncio.BaseTransport.close` 方法。" -#: ../../library/asyncio-eventloop.rst:486 +#: ../../library/asyncio-eventloop.rst:492 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 " @@ -807,8 +815,8 @@ msgstr "" "地綁定 socket。將使用 ``getaddrinfo()`` 查找 *local_host* 和 *local_port*,方" "式類似於 *host* 和 *port*。" -#: ../../library/asyncio-eventloop.rst:490 -#: ../../library/asyncio-eventloop.rst:935 +#: ../../library/asyncio-eventloop.rst:496 +#: ../../library/asyncio-eventloop.rst:948 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. " @@ -818,10 +826,10 @@ msgstr "" "在那之前若未完成則會中斷連線。如果為 ``None`` (預設值),則會等待 ``60.0`` " "秒。" -#: ../../library/asyncio-eventloop.rst:494 -#: ../../library/asyncio-eventloop.rst:750 -#: ../../library/asyncio-eventloop.rst:852 -#: ../../library/asyncio-eventloop.rst:939 +#: ../../library/asyncio-eventloop.rst:500 +#: ../../library/asyncio-eventloop.rst:759 +#: ../../library/asyncio-eventloop.rst:863 +#: ../../library/asyncio-eventloop.rst:952 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`` " @@ -830,7 +838,7 @@ msgstr "" "*ssl_shutdown_timeout* 是等待 SSL 關閉完成以前中斷連線的時間,以秒為單位。如" "果為 ``None`` (預設值),則會等待 ``30.0`` 秒。" -#: ../../library/asyncio-eventloop.rst:498 +#: ../../library/asyncio-eventloop.rst:504 msgid "" "*all_errors* determines what exceptions are raised when a connection cannot " "be created. By default, only a single ``Exception`` is raised: the first " @@ -844,12 +852,12 @@ msgstr "" "包含所有錯誤訊息的單一 ``OSError``。當 ``all_errors`` 為 ``True`` 時,將引發" "包含所有例外的 ``ExceptionGroup`` (即使只有一個例外)。" -#: ../../library/asyncio-eventloop.rst:508 -#: ../../library/asyncio-eventloop.rst:762 +#: ../../library/asyncio-eventloop.rst:514 +#: ../../library/asyncio-eventloop.rst:771 msgid "Added support for SSL/TLS in :class:`ProactorEventLoop`." msgstr "新增 :class:`ProactorEventLoop` 中的 SSL/TLS 支援。" -#: ../../library/asyncio-eventloop.rst:512 +#: ../../library/asyncio-eventloop.rst:518 msgid "" "The socket option :ref:`socket.TCP_NODELAY ` is set " "by default for all TCP connections." @@ -857,16 +865,16 @@ msgstr "" "所有 TCP 連線都預設有 :ref:`socket.TCP_NODELAY ` " "socket 選項。" -#: ../../library/asyncio-eventloop.rst:517 -#: ../../library/asyncio-eventloop.rst:862 +#: ../../library/asyncio-eventloop.rst:523 +#: ../../library/asyncio-eventloop.rst:873 msgid "Added the *ssl_handshake_timeout* parameter." msgstr "增加 *ssl_handshake_timeout* 參數。" -#: ../../library/asyncio-eventloop.rst:521 +#: ../../library/asyncio-eventloop.rst:527 msgid "Added the *happy_eyeballs_delay* and *interleave* parameters." msgstr "加入 *happy_eyeballs_delay* 和 *interleave* 參數。" -#: ../../library/asyncio-eventloop.rst:523 +#: ../../library/asyncio-eventloop.rst:529 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 " @@ -882,24 +890,24 @@ msgstr "" "用戶端的使用者體驗變差。本文件具體說明了減少此用戶可見延遲的演算法要求並提供" "了一種演算法。" -#: ../../library/asyncio-eventloop.rst:532 +#: ../../library/asyncio-eventloop.rst:538 msgid "For more information: https://datatracker.ietf.org/doc/html/rfc6555" msgstr "更多資訊請見: https://datatracker.ietf.org/doc/html/rfc6555" -#: ../../library/asyncio-eventloop.rst:536 -#: ../../library/asyncio-eventloop.rst:660 -#: ../../library/asyncio-eventloop.rst:776 -#: ../../library/asyncio-eventloop.rst:815 -#: ../../library/asyncio-eventloop.rst:866 -#: ../../library/asyncio-eventloop.rst:947 +#: ../../library/asyncio-eventloop.rst:542 +#: ../../library/asyncio-eventloop.rst:668 +#: ../../library/asyncio-eventloop.rst:785 +#: ../../library/asyncio-eventloop.rst:825 +#: ../../library/asyncio-eventloop.rst:877 +#: ../../library/asyncio-eventloop.rst:960 msgid "Added the *ssl_shutdown_timeout* parameter." msgstr "增加 *ssl_shutdown_timeout* 參數。" -#: ../../library/asyncio-eventloop.rst:538 +#: ../../library/asyncio-eventloop.rst:544 msgid "*all_errors* was added." msgstr "已新增 *all_errors*。" -#: ../../library/asyncio-eventloop.rst:543 +#: ../../library/asyncio-eventloop.rst:549 msgid "" "The :func:`open_connection` function is a high-level alternative API. It " "returns a pair of (:class:`StreamReader`, :class:`StreamWriter`) that can be " @@ -908,11 +916,11 @@ msgstr "" "函式 :func:`open_connection` 是高階的替代 API。它回傳一對 (:class:" "`StreamReader`, :class:`StreamWriter`) 可直接在 async/await 程式碼中使用。" -#: ../../library/asyncio-eventloop.rst:553 +#: ../../library/asyncio-eventloop.rst:560 msgid "Create a datagram connection." msgstr "建立一個資料報連線。" -#: ../../library/asyncio-eventloop.rst:555 +#: ../../library/asyncio-eventloop.rst:562 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 " @@ -922,13 +930,13 @@ msgstr "" "或 :py:const:`~socket.AF_UNIX`,視乎 *host*\\ (或提供的 *family* 引數)而" "定。" -#: ../../library/asyncio-eventloop.rst:559 +#: ../../library/asyncio-eventloop.rst:566 msgid "The socket type will be :py:const:`~socket.SOCK_DGRAM`." msgstr "Socket 類型將為 :py:const:`~socket.SOCK_DGRAM`。" -#: ../../library/asyncio-eventloop.rst:561 -#: ../../library/asyncio-eventloop.rst:686 -#: ../../library/asyncio-eventloop.rst:833 +#: ../../library/asyncio-eventloop.rst:568 +#: ../../library/asyncio-eventloop.rst:695 +#: ../../library/asyncio-eventloop.rst:844 msgid "" "*protocol_factory* must be a callable returning a :ref:`protocol ` implementation." @@ -936,12 +944,12 @@ msgstr "" "*protocol_factory* 必須是可呼叫的函式,回傳 :ref:`protocol ` 實作。" -#: ../../library/asyncio-eventloop.rst:564 -#: ../../library/asyncio-eventloop.rst:642 +#: ../../library/asyncio-eventloop.rst:571 +#: ../../library/asyncio-eventloop.rst:650 msgid "A tuple of ``(transport, protocol)`` is returned on success." msgstr "成功時回傳 ``(transport, protocol)`` 元組。" -#: ../../library/asyncio-eventloop.rst:568 +#: ../../library/asyncio-eventloop.rst:575 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 :" @@ -950,7 +958,7 @@ msgstr "" "*local_addr*,如果提供,是一個 ``(local_host, local_port)`` 元組,用於在本地" "綁定 socket。*local_host* 和 *local_port* 使用 :meth:`getaddrinfo` 來查找。" -#: ../../library/asyncio-eventloop.rst:572 +#: ../../library/asyncio-eventloop.rst:579 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* " @@ -960,7 +968,7 @@ msgstr "" "socket 連線到遠端位址。 *remote_host* 和 *remote_port* 使用 :meth:" "`getaddrinfo` 來查找。" -#: ../../library/asyncio-eventloop.rst:576 +#: ../../library/asyncio-eventloop.rst:583 msgid "" "*family*, *proto*, *flags* are the optional address family, protocol and " "flags to be passed through to :meth:`getaddrinfo` for *host* resolution. If " @@ -971,7 +979,7 @@ msgstr "" "的可選地址家族、協定和旗標。如果提供,這些應該都是來自相應的 :mod:`socket` 模" "組常數的整數。" -#: ../../library/asyncio-eventloop.rst:581 +#: ../../library/asyncio-eventloop.rst:588 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 " @@ -983,13 +991,13 @@ msgstr "" "時都設定了此旗標。此選項不受 Windows 和某些 Unix 系統支援。如果未定義 :py:" "const:`~socket.SO_REUSEPORT` 常數,則不支援此功能。" -#: ../../library/asyncio-eventloop.rst:587 +#: ../../library/asyncio-eventloop.rst:594 msgid "" "*allow_broadcast* tells the kernel to allow this endpoint to send messages " "to the broadcast address." msgstr "*allow_broadcast* 告訴核心允許此端點向廣播位址發送訊息。" -#: ../../library/asyncio-eventloop.rst:590 +#: ../../library/asyncio-eventloop.rst:597 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 " @@ -1000,7 +1008,7 @@ msgstr "" "供傳輸使用。如果指定,*local_addr* 和 *remote_addr* 應省略(必須是 :const:" "`None`\\ )。" -#: ../../library/asyncio-eventloop.rst:601 +#: ../../library/asyncio-eventloop.rst:608 msgid "" "See :ref:`UDP echo client protocol ` and :" "ref:`UDP echo server protocol ` examples." @@ -1008,7 +1016,7 @@ msgstr "" "請參閱 :ref:`UDP 回應用戶端協議 ` 和 :ref:" "`UDP 回應伺服器協議 ` 範例。" -#: ../../library/asyncio-eventloop.rst:604 +#: ../../library/asyncio-eventloop.rst:611 msgid "" "The *family*, *proto*, *flags*, *reuse_address*, *reuse_port*, " "*allow_broadcast*, and *sock* parameters were added." @@ -1016,11 +1024,11 @@ msgstr "" "新增 *family*、*proto*、*flags*、*reuse_address*、*reuse_port*、" "*allow_broadcast* 和 *sock* 參數。" -#: ../../library/asyncio-eventloop.rst:608 +#: ../../library/asyncio-eventloop.rst:615 msgid "Added support for Windows." msgstr "新增對於 Windows 的支援。" -#: ../../library/asyncio-eventloop.rst:611 +#: ../../library/asyncio-eventloop.rst:618 msgid "" "The *reuse_address* parameter is no longer supported, as using :ref:`socket." "SO_REUSEADDR ` poses a significant security concern " @@ -1029,7 +1037,7 @@ msgstr "" "不再支援 *reuse_address* 參數,因為使用 :py:const:`~sockets.SO_REUSEADDR` 對" "於 UDP 存有重大的安全疑慮。明確傳遞 ``reuse_address=True`` 將引發例外。" -#: ../../library/asyncio-eventloop.rst:617 +#: ../../library/asyncio-eventloop.rst:624 msgid "" "When multiple processes with differing UIDs assign sockets to an identical " "UDP socket address with ``SO_REUSEADDR``, incoming packets can become " @@ -1038,7 +1046,7 @@ msgstr "" "當具有不同 UID 的多個行程使用 ``SO_REUSEADDR`` 將 socket 分配給相同的 UDP " "socket 地址時,傳入的封包可能會在 socket 之間隨機分佈。" -#: ../../library/asyncio-eventloop.rst:621 +#: ../../library/asyncio-eventloop.rst:628 msgid "" "For supported platforms, *reuse_port* can be used as a replacement for " "similar functionality. With *reuse_port*, :ref:`socket.SO_REUSEPORT `: Unix." -msgstr ":ref:`適用 `:Unix。" +#: ../../library/asyncio-eventloop.rst:660 +#: ../../library/asyncio-eventloop.rst:816 +#: ../../library/asyncio-eventloop.rst:1281 +#: ../../library/asyncio-eventloop.rst:1821 +#: ../../library/asyncio-eventloop.rst:1828 +msgid "Availability" +msgstr "" -#: ../../library/asyncio-eventloop.rst:654 +#: ../../library/asyncio-eventloop.rst:662 msgid "" "Added the *ssl_handshake_timeout* parameter. The *path* parameter can now be " "a :term:`path-like object`." @@ -1098,11 +1108,11 @@ msgstr "" "新增 *ssl_handshake_timeout* 參數。*path* 參數現在可以是 :term:`path-like " "object`。" -#: ../../library/asyncio-eventloop.rst:664 +#: ../../library/asyncio-eventloop.rst:672 msgid "Creating network servers" msgstr "建立網路伺服器" -#: ../../library/asyncio-eventloop.rst:679 +#: ../../library/asyncio-eventloop.rst:688 msgid "" "Create a TCP server (socket type :const:`~socket.SOCK_STREAM`) listening on " "*port* of the *host* address." @@ -1110,33 +1120,33 @@ msgstr "" "建立一個 TCP 伺服器(socket 類型 :const:`~socket.SOCK_STREAM`\\ ),監聽 " "*host* 位址的 *port*。" -#: ../../library/asyncio-eventloop.rst:682 +#: ../../library/asyncio-eventloop.rst:691 msgid "Returns a :class:`Server` object." msgstr "回傳一個 :class:`Server` 物件。" -#: ../../library/asyncio-eventloop.rst:684 +#: ../../library/asyncio-eventloop.rst:693 msgid "Arguments:" msgstr "引數:" -#: ../../library/asyncio-eventloop.rst:689 +#: ../../library/asyncio-eventloop.rst:698 msgid "" "The *host* parameter can be set to several types which determine where the " "server would be listening:" msgstr "可以將 *host* 參數設為幾種類型,以確定伺服器將監聽的位置:" -#: ../../library/asyncio-eventloop.rst:692 +#: ../../library/asyncio-eventloop.rst:701 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:695 +#: ../../library/asyncio-eventloop.rst:704 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:698 +#: ../../library/asyncio-eventloop.rst:707 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 " @@ -1145,7 +1155,7 @@ msgstr "" "若 *host* 是空字串或 ``None``,則所有介面都被假定並回傳多個 socket 的清單(可" "能一個用於 IPv4,另一個用於 IPv6)。" -#: ../../library/asyncio-eventloop.rst:702 +#: ../../library/asyncio-eventloop.rst:711 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 " @@ -1156,7 +1166,7 @@ msgstr "" "設值),將隨機選擇一個未使用的埠(請注意,如果 *host* 解析為多個網路介面,將" "為每個介面隨機選擇不同的隨機埠)。" -#: ../../library/asyncio-eventloop.rst:707 +#: ../../library/asyncio-eventloop.rst:716 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* " @@ -1166,11 +1176,11 @@ msgstr "" "制使用 IPv4 或 IPv6。如果未設定,*family* 將從主機名稱決定(預設為 :const:" "`~socket.AF_UNSPEC`\\ )。" -#: ../../library/asyncio-eventloop.rst:712 +#: ../../library/asyncio-eventloop.rst:721 msgid "*flags* is a bitmask for :meth:`getaddrinfo`." msgstr "*flags* 是 :meth:`getaddrinfo` 的位元遮罩。" -#: ../../library/asyncio-eventloop.rst:714 +#: ../../library/asyncio-eventloop.rst:723 msgid "" "*sock* can optionally be specified in order to use a preexisting socket " "object. If specified, *host* and *port* must not be specified." @@ -1178,7 +1188,7 @@ msgstr "" "可以可選地指定 *sock* 以使用現有的 socket 物件。如果指定了,*host* 和 *port* " "不能指定。" -#: ../../library/asyncio-eventloop.rst:719 +#: ../../library/asyncio-eventloop.rst:728 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." @@ -1186,7 +1196,7 @@ msgstr "" "*sock* 引數將 socket 的所有權轉移給建立的伺服器。要關閉 socket,請呼叫伺服器" "的 :meth:`~asyncio.Server.close` 方法。" -#: ../../library/asyncio-eventloop.rst:723 +#: ../../library/asyncio-eventloop.rst:732 msgid "" "*backlog* is the maximum number of queued connections passed to :meth:" "`~socket.socket.listen` (defaults to 100)." @@ -1194,14 +1204,14 @@ msgstr "" "*backlog* 是傳遞給 :meth:`~socket.socket.listen` 的最大佇列連線數(預設為 " "100)。" -#: ../../library/asyncio-eventloop.rst:726 +#: ../../library/asyncio-eventloop.rst:735 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:729 +#: ../../library/asyncio-eventloop.rst:738 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 " @@ -1210,7 +1220,7 @@ msgstr "" "*reuse_address* 告訴內核重用 ``TIME_WAIT`` 狀態下的本地 socket,而不等待其自" "然超時過期。如果未指定,在 Unix 上將自動設置為 ``True``。" -#: ../../library/asyncio-eventloop.rst:734 +#: ../../library/asyncio-eventloop.rst:743 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 " @@ -1219,18 +1229,18 @@ msgstr "" "*reuse_port* 告訴內核允許此端點繫結到與其他現有端點繫結的相同埠,只要它們在建" "立時都設置了此旗標。此選項在旗標 Windows 上不受支援。" -#: ../../library/asyncio-eventloop.rst:739 +#: ../../library/asyncio-eventloop.rst:748 msgid "" "*keep_alive* set to ``True`` keeps connections active by enabling the " "periodic transmission of messages." msgstr "" -#: ../../library/asyncio-eventloop.rst:744 +#: ../../library/asyncio-eventloop.rst:753 #, fuzzy msgid "Added the *keep_alive* parameter." msgstr "加入 *name* 參數。" -#: ../../library/asyncio-eventloop.rst:746 +#: ../../library/asyncio-eventloop.rst:755 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`` " @@ -1239,7 +1249,7 @@ msgstr "" "(對於 TLS 伺服器)\\ *ssl_handshake_timeout* 是在中斷連線之前等待 TLS 握手完" "成的時間(以秒為單位)。如果為 ``None``\\ (預設),則為 ``60.0`` 秒。" -#: ../../library/asyncio-eventloop.rst:754 +#: ../../library/asyncio-eventloop.rst:763 msgid "" "*start_serving* set to ``True`` (the default) causes the created server to " "start accepting connections immediately. When set to ``False``, the user " @@ -1250,11 +1260,11 @@ msgstr "" "接。當設置為 ``False`` 時,用戶應該等待 :meth:`Server.start_serving` 或 :" "meth:`Server.serve_forever` 來使伺服器開始接受連線。" -#: ../../library/asyncio-eventloop.rst:766 +#: ../../library/asyncio-eventloop.rst:775 msgid "The *host* parameter can be a sequence of strings." msgstr "*host* 參數可以是字串序列。" -#: ../../library/asyncio-eventloop.rst:770 +#: ../../library/asyncio-eventloop.rst:779 msgid "" "Added *ssl_handshake_timeout* and *start_serving* parameters. The socket " "option :ref:`socket.TCP_NODELAY ` is set by default " @@ -1263,7 +1273,7 @@ msgstr "" "新增 *ssl_handshake_timeout* 與 *start_serving* 參數。所有 TCP 連線都預設有 :" "ref:`socket.TCP_NODELAY ` socket 選項。" -#: ../../library/asyncio-eventloop.rst:780 +#: ../../library/asyncio-eventloop.rst:789 msgid "" "The :func:`start_server` function is a higher-level alternative API that " "returns a pair of :class:`StreamReader` and :class:`StreamWriter` that can " @@ -1272,7 +1282,7 @@ msgstr "" ":func:`start_server` 函式是一個更高階的替代 API,它回傳一對 :class:" "`StreamReader` 和 :class:`StreamWriter`,可以在 async/await 程式碼中使用。" -#: ../../library/asyncio-eventloop.rst:791 +#: ../../library/asyncio-eventloop.rst:801 msgid "" "Similar to :meth:`loop.create_server` but works with the :py:const:`~socket." "AF_UNIX` socket family." @@ -1280,7 +1290,7 @@ msgstr "" "類似 :meth:`loop.create_server`,但適用於 :py:const:`~socket.AF_UNIX` socket " "家族。" -#: ../../library/asyncio-eventloop.rst:794 +#: ../../library/asyncio-eventloop.rst:804 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`, " @@ -1290,20 +1300,20 @@ msgstr "" "象 Unix sockets、:class:`str`、:class:`bytes` 和 :class:`~pathlib.Path` 路" "徑。" -#: ../../library/asyncio-eventloop.rst:799 +#: ../../library/asyncio-eventloop.rst:809 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 " "been replaced after the server has been created." msgstr "" -#: ../../library/asyncio-eventloop.rst:803 +#: ../../library/asyncio-eventloop.rst:813 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:810 +#: ../../library/asyncio-eventloop.rst:820 msgid "" "Added the *ssl_handshake_timeout* and *start_serving* parameters. The *path* " "parameter can now be a :class:`~pathlib.Path` object." @@ -1311,27 +1321,27 @@ msgstr "" "新增 *ssl_handshake_timeout* 與 *start_serving* 參數。*path* 參數現在可為一" "個 :class:`~pathlib.Path` 物件。" -#: ../../library/asyncio-eventloop.rst:819 +#: ../../library/asyncio-eventloop.rst:829 #, fuzzy msgid "Added the *cleanup_socket* parameter." msgstr "加入 *context* 參數。" -#: ../../library/asyncio-eventloop.rst:826 +#: ../../library/asyncio-eventloop.rst:837 msgid "Wrap an already accepted connection into a transport/protocol pair." msgstr "將已接受的連線包裝成傳輸層/協議對。" -#: ../../library/asyncio-eventloop.rst:828 +#: ../../library/asyncio-eventloop.rst:839 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:831 -#: ../../library/asyncio-eventloop.rst:921 +#: ../../library/asyncio-eventloop.rst:842 +#: ../../library/asyncio-eventloop.rst:934 msgid "Parameters:" msgstr "參數:" -#: ../../library/asyncio-eventloop.rst:836 +#: ../../library/asyncio-eventloop.rst:847 msgid "" "*sock* is a preexisting socket object returned from :meth:`socket.accept " "`." @@ -1339,13 +1349,13 @@ msgstr "" "*sock* 是從 :meth:`socket.accept ` 回傳的預先存在的 " "socket 物件。" -#: ../../library/asyncio-eventloop.rst:845 +#: ../../library/asyncio-eventloop.rst:856 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:848 +#: ../../library/asyncio-eventloop.rst:859 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. " @@ -1354,29 +1364,29 @@ msgstr "" "(對於 SSL 連線)\\ *ssl_handshake_timeout* 是在中斷連線之前等待 SSL 握手完成" "的時間(以秒為單位)。如果為 ``None``\\ (預設),則為 ``60.0`` 秒。" -#: ../../library/asyncio-eventloop.rst:856 +#: ../../library/asyncio-eventloop.rst:867 msgid "Returns a ``(transport, protocol)`` pair." msgstr "回傳 ``(transport, protocol)`` 對。" -#: ../../library/asyncio-eventloop.rst:870 +#: ../../library/asyncio-eventloop.rst:881 msgid "Transferring files" msgstr "傳輸檔案" -#: ../../library/asyncio-eventloop.rst:875 +#: ../../library/asyncio-eventloop.rst:887 msgid "" "Send a *file* over a *transport*. Return the total number of bytes sent." msgstr "通過 *transport* 發送 *file*。回傳發送的總位元組數。" -#: ../../library/asyncio-eventloop.rst:878 +#: ../../library/asyncio-eventloop.rst:890 msgid "The method uses high-performance :meth:`os.sendfile` if available." msgstr "如果可用,該方法使用高性能 :meth:`os.sendfile`。" -#: ../../library/asyncio-eventloop.rst:880 +#: ../../library/asyncio-eventloop.rst:892 msgid "*file* must be a regular file object opened in binary mode." msgstr "*file* 必須是以二進位模式打開的常規檔案物件。" -#: ../../library/asyncio-eventloop.rst:882 -#: ../../library/asyncio-eventloop.rst:1127 +#: ../../library/asyncio-eventloop.rst:894 +#: ../../library/asyncio-eventloop.rst:1155 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 " @@ -1388,7 +1398,7 @@ msgstr "" "不是發送檔案直到達到 EOF。即使此方法引發錯誤時,檔案位置也始終更新,可以使" "用 :meth:`file.tell() ` 取得實際發送的位元組數。" -#: ../../library/asyncio-eventloop.rst:889 +#: ../../library/asyncio-eventloop.rst:901 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 " @@ -1397,7 +1407,7 @@ msgstr "" "將 *fallback* 設置為 ``True`` 會使 asyncio 在平台不支援 sendfile 系統呼叫時" "(例如 Windows 或 Unix 上的 SSL socket)手動讀取和發送檔案。" -#: ../../library/asyncio-eventloop.rst:893 +#: ../../library/asyncio-eventloop.rst:905 msgid "" "Raise :exc:`SendfileNotAvailableError` if the system does not support the " "*sendfile* syscall and *fallback* is ``False``." @@ -1405,15 +1415,15 @@ msgstr "" "如果系統不支援 *sendfile* 系統呼叫且 *fallback* 為 ``False``,則引發 :exc:" "`SendfileNotAvailableError`。" -#: ../../library/asyncio-eventloop.rst:900 +#: ../../library/asyncio-eventloop.rst:912 msgid "TLS Upgrade" msgstr "TLS 升級" -#: ../../library/asyncio-eventloop.rst:907 +#: ../../library/asyncio-eventloop.rst:920 msgid "Upgrade an existing transport-based connection to TLS." msgstr "將基於傳輸的現有連線升級到 TLS。" -#: ../../library/asyncio-eventloop.rst:909 +#: ../../library/asyncio-eventloop.rst:922 msgid "" "Create a TLS coder/decoder instance and insert it between the *transport* " "and the *protocol*. The coder/decoder implements both *transport*-facing " @@ -1422,7 +1432,7 @@ msgstr "" "建立 TLS 編解碼器實例並在 *transport* 和 *protocol* 之間插入它。編解碼器既實" "作了對於 *transport* 的協議,也實作了對於 *protocol* 的傳輸。" -#: ../../library/asyncio-eventloop.rst:913 +#: ../../library/asyncio-eventloop.rst:926 msgid "" "Return the created two-interface instance. After *await*, the *protocol* " "must stop using the original *transport* and communicate with the returned " @@ -1433,13 +1443,13 @@ msgstr "" "*transport*,僅與回傳的物件通信,因為編碼器快取了 *protocol* 端的資料,並且" "與 *transport* 間歇性地交換額外的 TLS session 封包。" -#: ../../library/asyncio-eventloop.rst:918 +#: ../../library/asyncio-eventloop.rst:931 msgid "" "In some situations (e.g. when the passed transport is already closing) this " "may return ``None``." msgstr "在某些情況下(例如傳入的傳輸已經關閉),此函式可能回傳 ``None``。" -#: ../../library/asyncio-eventloop.rst:923 +#: ../../library/asyncio-eventloop.rst:936 msgid "" "*transport* and *protocol* instances that methods like :meth:`~loop." "create_server` and :meth:`~loop.create_connection` return." @@ -1447,11 +1457,11 @@ msgstr "" "*transport* 和 *protocol* 實例,由像 :meth:`~loop.create_server` 和 :meth:" "`~loop.create_connection` 等方法回傳。" -#: ../../library/asyncio-eventloop.rst:927 +#: ../../library/asyncio-eventloop.rst:940 msgid "*sslcontext*: a configured instance of :class:`~ssl.SSLContext`." msgstr "*sslcontext*:配置好的 :class:`~ssl.SSLContext` 實例。" -#: ../../library/asyncio-eventloop.rst:929 +#: ../../library/asyncio-eventloop.rst:942 msgid "" "*server_side* pass ``True`` when a server-side connection is being upgraded " "(like the one created by :meth:`~loop.create_server`)." @@ -1459,17 +1469,17 @@ msgstr "" "當升級伺服器端連線時(像由 :meth:`~loop.create_server` 建立的那樣)傳遞 " "``True``。" -#: ../../library/asyncio-eventloop.rst:932 +#: ../../library/asyncio-eventloop.rst:945 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:952 +#: ../../library/asyncio-eventloop.rst:965 msgid "Watching file descriptors" msgstr "監視檔案描述器" -#: ../../library/asyncio-eventloop.rst:956 +#: ../../library/asyncio-eventloop.rst:969 msgid "" "Start monitoring the *fd* file descriptor for read availability and invoke " "*callback* with the specified arguments once *fd* is available for reading." @@ -1477,7 +1487,14 @@ msgstr "" "開始監視 *fd* 檔案描述器的讀取可用性,一但 *fd* 可讀取,使用指定引數呼叫 " "*callback*。" -#: ../../library/asyncio-eventloop.rst:962 +#: ../../library/asyncio-eventloop.rst:973 +#: ../../library/asyncio-eventloop.rst:987 +msgid "" +"Any preexisting callback registered for *fd* is cancelled and replaced by " +"*callback*." +msgstr "" + +#: ../../library/asyncio-eventloop.rst:978 msgid "" "Stop monitoring the *fd* file descriptor for read availability. Returns " "``True`` if *fd* was previously being monitored for reads." @@ -1485,7 +1502,7 @@ msgstr "" "停止監視 *fd* 檔案描述器的讀取可用性。如果 *fd* 之前正在監視讀取,則回傳 " "``True``。" -#: ../../library/asyncio-eventloop.rst:967 +#: ../../library/asyncio-eventloop.rst:983 msgid "" "Start monitoring the *fd* file descriptor for write availability and invoke " "*callback* with the specified arguments once *fd* is available for writing." @@ -1493,8 +1510,8 @@ msgstr "" "開始監視 *fd* 檔案描述器的寫入可用性,一旦 *fd* 可寫入,使用指定引數呼叫 " "*callback*。" -#: ../../library/asyncio-eventloop.rst:971 -#: ../../library/asyncio-eventloop.rst:1236 +#: ../../library/asyncio-eventloop.rst:990 +#: ../../library/asyncio-eventloop.rst:1268 msgid "" "Use :func:`functools.partial` :ref:`to pass keyword arguments ` to *callback*." @@ -1502,7 +1519,7 @@ msgstr "" "使用 :func:`functools.partial` 向 *callback* :ref:`傳送關鍵字引數 `。" -#: ../../library/asyncio-eventloop.rst:976 +#: ../../library/asyncio-eventloop.rst:995 msgid "" "Stop monitoring the *fd* file descriptor for write availability. Returns " "``True`` if *fd* was previously being monitored for writes." @@ -1510,7 +1527,7 @@ msgstr "" "停止監視 *fd* 檔案描述器的寫入可用性。如果 *fd* 之前正在監視寫入,則回傳 " "``True``。" -#: ../../library/asyncio-eventloop.rst:979 +#: ../../library/asyncio-eventloop.rst:998 msgid "" "See also :ref:`Platform Support ` section for some " "limitations of these methods." @@ -1518,11 +1535,11 @@ msgstr "" "另請參閱\\ :ref:`平台支援 `\\ 部分以了解這些方法的" "一些限制。" -#: ../../library/asyncio-eventloop.rst:984 +#: ../../library/asyncio-eventloop.rst:1003 msgid "Working with socket objects directly" msgstr "直接使用 socket 物件" -#: ../../library/asyncio-eventloop.rst:986 +#: ../../library/asyncio-eventloop.rst:1005 msgid "" "In general, protocol implementations that use transport-based APIs such as :" "meth:`loop.create_connection` and :meth:`loop.create_server` are faster than " @@ -1534,7 +1551,7 @@ msgstr "" "`loop.create_server`\\ )的協議實作比直接使用 socket 的實作更快。然而在某些情" "況下性能不是關鍵,直接使用 :class:`~socket.socket` 物件更方便。" -#: ../../library/asyncio-eventloop.rst:995 +#: ../../library/asyncio-eventloop.rst:1015 msgid "" "Receive up to *nbytes* from *sock*. Asynchronous version of :meth:`socket." "recv() `." @@ -1542,23 +1559,23 @@ msgstr "" "從 *sock* 接收最多 *nbytes*。:meth:`socket.recv() ` 的非" "同步版本。" -#: ../../library/asyncio-eventloop.rst:998 +#: ../../library/asyncio-eventloop.rst:1018 msgid "Return the received data as a bytes object." msgstr "將接收到的資料作為 bytes 物件回傳。" -#: ../../library/asyncio-eventloop.rst:1000 -#: ../../library/asyncio-eventloop.rst:1014 -#: ../../library/asyncio-eventloop.rst:1025 -#: ../../library/asyncio-eventloop.rst:1037 -#: ../../library/asyncio-eventloop.rst:1052 -#: ../../library/asyncio-eventloop.rst:1067 -#: ../../library/asyncio-eventloop.rst:1077 +#: ../../library/asyncio-eventloop.rst:1020 +#: ../../library/asyncio-eventloop.rst:1035 +#: ../../library/asyncio-eventloop.rst:1047 +#: ../../library/asyncio-eventloop.rst:1060 +#: ../../library/asyncio-eventloop.rst:1076 +#: ../../library/asyncio-eventloop.rst:1092 #: ../../library/asyncio-eventloop.rst:1103 -#: ../../library/asyncio-eventloop.rst:1141 +#: ../../library/asyncio-eventloop.rst:1130 +#: ../../library/asyncio-eventloop.rst:1169 msgid "*sock* must be a non-blocking socket." msgstr "*sock* 必須是非阻塞 socket。" -#: ../../library/asyncio-eventloop.rst:1002 +#: ../../library/asyncio-eventloop.rst:1022 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 " @@ -1567,7 +1584,7 @@ msgstr "" "儘管此方法一直記錄為協程方法,但 Python 3.7 之前的版本回傳 :class:`Future`。" "自 Python 3.7 起,這是 ``async def`` 方法。" -#: ../../library/asyncio-eventloop.rst:1009 +#: ../../library/asyncio-eventloop.rst:1030 msgid "" "Receive data from *sock* into the *buf* buffer. Modeled after the blocking :" "meth:`socket.recv_into() ` method." @@ -1575,11 +1592,11 @@ msgstr "" "從 *sock* 接收資料到 *buf* 緩衝區。仿照阻塞 :meth:`socket.recv_into() " "` 方法。" -#: ../../library/asyncio-eventloop.rst:1012 +#: ../../library/asyncio-eventloop.rst:1033 msgid "Return the number of bytes written to the buffer." msgstr "回傳寫入緩衝區位元組的數目。" -#: ../../library/asyncio-eventloop.rst:1020 +#: ../../library/asyncio-eventloop.rst:1042 msgid "" "Receive a datagram of up to *bufsize* from *sock*. Asynchronous version of :" "meth:`socket.recvfrom() `." @@ -1587,11 +1604,11 @@ msgstr "" "從 *sock* 接收最多 *bufsize* 大小的資料單元。:meth:`socket.recvfrom() " "` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1023 +#: ../../library/asyncio-eventloop.rst:1045 msgid "Return a tuple of (received data, remote address)." msgstr "回傳一個元組 (received data, remote address)。" -#: ../../library/asyncio-eventloop.rst:1031 +#: ../../library/asyncio-eventloop.rst:1054 msgid "" "Receive a datagram of up to *nbytes* from *sock* into *buf*. Asynchronous " "version of :meth:`socket.recvfrom_into() `." @@ -1599,11 +1616,11 @@ msgstr "" "從 *sock* 接收最多 *nbytes* 大小的資料單元到 *buf*。:meth:`socket." "recvfrom_into() ` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1035 +#: ../../library/asyncio-eventloop.rst:1058 msgid "Return a tuple of (number of bytes received, remote address)." msgstr "回傳一個元組 (number of bytes received, remote address)。" -#: ../../library/asyncio-eventloop.rst:1043 +#: ../../library/asyncio-eventloop.rst:1067 msgid "" "Send *data* to the *sock* socket. Asynchronous version of :meth:`socket." "sendall() `." @@ -1611,7 +1628,7 @@ msgstr "" "將 *data* 發送到 *sock* socket。:meth:`socket.sendall() ` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1046 +#: ../../library/asyncio-eventloop.rst:1070 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 " @@ -1623,8 +1640,8 @@ msgstr "" "回傳 ``None``。錯誤時引發例外。此外,沒有辦法確定接收端成功處理了多少資料(如" "果有的話)。" -#: ../../library/asyncio-eventloop.rst:1054 -#: ../../library/asyncio-eventloop.rst:1105 +#: ../../library/asyncio-eventloop.rst:1078 +#: ../../library/asyncio-eventloop.rst:1132 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 " @@ -1633,7 +1650,7 @@ msgstr "" "儘管該方法一直被記錄為協程方法,但在 Python 3.7 之前它回傳 :class:`Future`。" "從 Python 3.7 開始,這是一個 ``async def`` 方法。" -#: ../../library/asyncio-eventloop.rst:1061 +#: ../../library/asyncio-eventloop.rst:1086 msgid "" "Send a datagram from *sock* to *address*. Asynchronous version of :meth:" "`socket.sendto() `." @@ -1641,20 +1658,20 @@ msgstr "" "從 *sock* 向 *address* 發送一個資料單元。:meth:`socket.sendto() ` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1065 +#: ../../library/asyncio-eventloop.rst:1090 msgid "Return the number of bytes sent." msgstr "回傳發送的位元組數。" -#: ../../library/asyncio-eventloop.rst:1073 +#: ../../library/asyncio-eventloop.rst:1099 msgid "Connect *sock* to a remote socket at *address*." msgstr "將 *sock* 連線到位於 *address* 的遠端 socket。" -#: ../../library/asyncio-eventloop.rst:1075 +#: ../../library/asyncio-eventloop.rst:1101 msgid "" "Asynchronous version of :meth:`socket.connect() `." msgstr ":meth:`socket.connect() ` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1079 +#: ../../library/asyncio-eventloop.rst:1105 msgid "" "``address`` no longer needs to be resolved. ``sock_connect`` will try to " "check if the *address* is already resolved by calling :func:`socket." @@ -1665,7 +1682,7 @@ msgstr "" "inet_pton` 檢查 *address* 是否已解析。如果沒有,將使用 :meth:`loop." "getaddrinfo` 解析 *address*。" -#: ../../library/asyncio-eventloop.rst:1088 +#: ../../library/asyncio-eventloop.rst:1114 msgid "" ":meth:`loop.create_connection` and :func:`asyncio.open_connection() " "`." @@ -1673,7 +1690,7 @@ msgstr "" ":meth:`loop.create_connection` 和 :func:`asyncio.open_connection() " "`。" -#: ../../library/asyncio-eventloop.rst:1094 +#: ../../library/asyncio-eventloop.rst:1121 msgid "" "Accept a connection. Modeled after the blocking :meth:`socket.accept() " "` method." @@ -1681,7 +1698,7 @@ msgstr "" "接受一個連線。模擬阻塞的 :meth:`socket.accept() ` 方" "法。" -#: ../../library/asyncio-eventloop.rst:1097 +#: ../../library/asyncio-eventloop.rst:1124 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 " @@ -1692,34 +1709,34 @@ msgstr "" "中 *conn* 是一個 *新* socket 物件,可在連線上發送和接收資料,*address* 是連接" "另一端對應的 socket 地址。" -#: ../../library/asyncio-eventloop.rst:1112 +#: ../../library/asyncio-eventloop.rst:1139 msgid ":meth:`loop.create_server` and :func:`start_server`." msgstr ":meth:`loop.create_server` 和 :func:`start_server`。" -#: ../../library/asyncio-eventloop.rst:1117 +#: ../../library/asyncio-eventloop.rst:1145 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:1120 +#: ../../library/asyncio-eventloop.rst:1148 msgid "" "Asynchronous version of :meth:`socket.sendfile() `." msgstr ":meth:`socket.sendfile() ` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1122 +#: ../../library/asyncio-eventloop.rst:1150 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:1125 +#: ../../library/asyncio-eventloop.rst:1153 msgid "*file* must be a regular file object open in binary mode." msgstr "*file* 必須是以二進位模式打開的常規檔案物件。" -#: ../../library/asyncio-eventloop.rst:1134 +#: ../../library/asyncio-eventloop.rst:1162 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 " @@ -1728,7 +1745,7 @@ msgstr "" "當設置為 ``True`` 時,*fallback* 使 asyncio 在平台不支援 sendfile 系統呼叫時" "(例如 Windows 或 Unix 上的 SSL socket)手動讀取和發送檔案。" -#: ../../library/asyncio-eventloop.rst:1138 +#: ../../library/asyncio-eventloop.rst:1166 msgid "" "Raise :exc:`SendfileNotAvailableError` if the system does not support " "*sendfile* syscall and *fallback* is ``False``." @@ -1736,19 +1753,19 @@ msgstr "" "如果系統不支援 *sendfile* 系統呼叫且 *fallback* 為 ``False``,引發 :exc:" "`SendfileNotAvailableError`。" -#: ../../library/asyncio-eventloop.rst:1147 +#: ../../library/asyncio-eventloop.rst:1175 msgid "DNS" msgstr "DNS" -#: ../../library/asyncio-eventloop.rst:1152 +#: ../../library/asyncio-eventloop.rst:1181 msgid "Asynchronous version of :meth:`socket.getaddrinfo`." msgstr ":meth:`socket.getaddrinfo` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1156 +#: ../../library/asyncio-eventloop.rst:1186 msgid "Asynchronous version of :meth:`socket.getnameinfo`." msgstr ":meth:`socket.getnameinfo` 的非同步版本。" -#: ../../library/asyncio-eventloop.rst:1159 +#: ../../library/asyncio-eventloop.rst:1189 msgid "" "Both *getaddrinfo* and *getnameinfo* internally utilize their synchronous " "versions through the loop's default thread pool executor. When this executor " @@ -1758,7 +1775,7 @@ msgid "" "executor with a larger number of workers." msgstr "" -#: ../../library/asyncio-eventloop.rst:1166 +#: ../../library/asyncio-eventloop.rst:1196 msgid "" "Both *getaddrinfo* and *getnameinfo* methods were always documented to " "return a coroutine, but prior to Python 3.7 they were, in fact, returning :" @@ -1769,19 +1786,19 @@ msgstr "" "它們實際上回傳 :class:`asyncio.Future` 物件。從 Python 3.7 開始,兩個方法都是" "協程。" -#: ../../library/asyncio-eventloop.rst:1174 +#: ../../library/asyncio-eventloop.rst:1204 msgid "Working with pipes" msgstr "使用管道" -#: ../../library/asyncio-eventloop.rst:1178 +#: ../../library/asyncio-eventloop.rst:1209 msgid "Register the read end of *pipe* in the event loop." msgstr "在事件迴圈中註冊 *pipe* 的讀取端。" -#: ../../library/asyncio-eventloop.rst:1183 +#: ../../library/asyncio-eventloop.rst:1214 msgid "*pipe* is a :term:`file-like object `." msgstr "*pipe* 是 :term:`類檔案物件 `。" -#: ../../library/asyncio-eventloop.rst:1185 +#: ../../library/asyncio-eventloop.rst:1216 msgid "" "Return pair ``(transport, protocol)``, where *transport* supports the :class:" "`ReadTransport` interface and *protocol* is an object instantiated by the " @@ -1790,22 +1807,22 @@ msgstr "" "回傳 ``(transport, protocol)`` 對,其中 *transport* 支援 :class:" "`ReadTransport` 介面,*protocol* 是由 *protocol_factory* 實例化的物件。" -#: ../../library/asyncio-eventloop.rst:1189 -#: ../../library/asyncio-eventloop.rst:1205 +#: ../../library/asyncio-eventloop.rst:1220 +#: ../../library/asyncio-eventloop.rst:1237 msgid "" "With :class:`SelectorEventLoop` event loop, the *pipe* is set to non-" "blocking mode." msgstr "使用 :class:`SelectorEventLoop` 事件迴圈時,*pipe* 設置為非阻塞模式。" -#: ../../library/asyncio-eventloop.rst:1194 +#: ../../library/asyncio-eventloop.rst:1226 msgid "Register the write end of *pipe* in the event loop." msgstr "在事件迴圈中註冊 *pipe* 的寫入端。" -#: ../../library/asyncio-eventloop.rst:1199 +#: ../../library/asyncio-eventloop.rst:1231 msgid "*pipe* is :term:`file-like object `." msgstr "*pipe* 是 :term:`file-like object `。" -#: ../../library/asyncio-eventloop.rst:1201 +#: ../../library/asyncio-eventloop.rst:1233 msgid "" "Return pair ``(transport, protocol)``, where *transport* supports :class:" "`WriteTransport` interface and *protocol* is an object instantiated by the " @@ -1814,7 +1831,7 @@ msgstr "" "回傳 ``(transport, protocol)`` 對,其中 *transport* 支援 :class:" "`WriteTransport` 介面,*protocol* 是由 *protocol_factory* 實例化的物件。" -#: ../../library/asyncio-eventloop.rst:1210 +#: ../../library/asyncio-eventloop.rst:1242 msgid "" ":class:`SelectorEventLoop` does not support the above methods on Windows. " "Use :class:`ProactorEventLoop` instead for Windows." @@ -1822,20 +1839,20 @@ msgstr "" ":class:`SelectorEventLoop` 在 Windows 上不支援上述方法。對於 Windows 請使用 :" "class:`ProactorEventLoop`。" -#: ../../library/asyncio-eventloop.rst:1215 +#: ../../library/asyncio-eventloop.rst:1247 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:1220 +#: ../../library/asyncio-eventloop.rst:1252 msgid "Unix signals" msgstr "Unix 訊號" -#: ../../library/asyncio-eventloop.rst:1226 +#: ../../library/asyncio-eventloop.rst:1258 msgid "Set *callback* as the handler for the *signum* signal." msgstr "將 *callback* 設置為 *signum* 訊號的處理程式。" -#: ../../library/asyncio-eventloop.rst:1228 +#: ../../library/asyncio-eventloop.rst:1260 msgid "" "The callback will be invoked by *loop*, along with other queued callbacks " "and runnable coroutines of that event loop. Unlike signal handlers " @@ -1846,7 +1863,7 @@ msgstr "" "用 :func:`signal.signal` 註冊的訊號處理程式不同,使用此函式註冊的回呼允許與事" "件迴圈進行互動。" -#: ../../library/asyncio-eventloop.rst:1233 +#: ../../library/asyncio-eventloop.rst:1265 msgid "" "Raise :exc:`ValueError` if the signal number is invalid or uncatchable. " "Raise :exc:`RuntimeError` if there is a problem setting up the handler." @@ -1854,16 +1871,16 @@ msgstr "" "如果訊號號無效或不可捕獲,引發 :exc:`ValueError`。如果設定處理程序有問題,拋" "出 :exc:`RuntimeError`。" -#: ../../library/asyncio-eventloop.rst:1239 +#: ../../library/asyncio-eventloop.rst:1271 msgid "" "Like :func:`signal.signal`, this function must be invoked in the main thread." msgstr "像 :func:`signal.signal` 一樣,此函式必須在主執行緒中呼叫。" -#: ../../library/asyncio-eventloop.rst:1244 +#: ../../library/asyncio-eventloop.rst:1276 msgid "Remove the handler for the *sig* signal." msgstr "移除 *sig* 訊號的處理程式。" -#: ../../library/asyncio-eventloop.rst:1246 +#: ../../library/asyncio-eventloop.rst:1278 msgid "" "Return ``True`` if the signal handler was removed, or ``False`` if no " "handler was set for the given signal." @@ -1871,19 +1888,19 @@ msgstr "" "如果訊號處理程式被移除,回傳 ``True``;如果給定訊號沒有設置處理程式,回傳 " "``False``。" -#: ../../library/asyncio-eventloop.rst:1253 +#: ../../library/asyncio-eventloop.rst:1285 msgid "The :mod:`signal` module." msgstr ":mod:`signal` 模組。" -#: ../../library/asyncio-eventloop.rst:1257 +#: ../../library/asyncio-eventloop.rst:1289 msgid "Executing code in thread or process pools" msgstr "在執行緒池或行程池中執行程式碼" -#: ../../library/asyncio-eventloop.rst:1261 +#: ../../library/asyncio-eventloop.rst:1293 msgid "Arrange for *func* to be called in the specified executor." msgstr "安排在指定的執行器中呼叫 *func*。" -#: ../../library/asyncio-eventloop.rst:1263 +#: ../../library/asyncio-eventloop.rst:1295 msgid "" "The *executor* argument should be an :class:`concurrent.futures.Executor` " "instance. The default executor is used if *executor* is ``None``. The " @@ -1892,7 +1909,7 @@ msgid "" "and used by :func:`run_in_executor` if needed." msgstr "" -#: ../../library/asyncio-eventloop.rst:1271 +#: ../../library/asyncio-eventloop.rst:1303 msgid "" "import asyncio\n" "import concurrent.futures\n" @@ -1935,7 +1952,7 @@ msgid "" " asyncio.run(main())" msgstr "" -#: ../../library/asyncio-eventloop.rst:1311 +#: ../../library/asyncio-eventloop.rst:1343 msgid "" "Note that the entry point guard (``if __name__ == '__main__'``) is required " "for option 3 due to the peculiarities of :mod:`multiprocessing`, which is " @@ -1947,11 +1964,11 @@ msgstr "" "== '__main__'``\\ )。請參閱\\ :ref:`主模組的安全引入 `。" -#: ../../library/asyncio-eventloop.rst:1316 +#: ../../library/asyncio-eventloop.rst:1348 msgid "This method returns a :class:`asyncio.Future` object." msgstr "此方法回傳 :class:`asyncio.Future` 物件。" -#: ../../library/asyncio-eventloop.rst:1318 +#: ../../library/asyncio-eventloop.rst:1350 msgid "" "Use :func:`functools.partial` :ref:`to pass keyword arguments ` to *func*." @@ -1959,7 +1976,7 @@ msgstr "" "使用 :func:`functools.partial` 將來\\ :ref:`關鍵字引數傳遞 `\\ 給 *func*。" -#: ../../library/asyncio-eventloop.rst:1321 +#: ../../library/asyncio-eventloop.rst:1353 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 " @@ -1970,7 +1987,7 @@ msgstr "" "``max_workers``,而是讓執行緒池執行器(\\ :class:`~concurrent.futures." "ThreadPoolExecutor`)設定預設值。" -#: ../../library/asyncio-eventloop.rst:1330 +#: ../../library/asyncio-eventloop.rst:1362 msgid "" "Set *executor* as the default executor used by :meth:`run_in_executor`. " "*executor* must be an instance of :class:`~concurrent.futures." @@ -1979,26 +1996,26 @@ msgstr "" "將 *executor* 設置為 :meth:`run_in_executor` 使用的預設執行器。*executor* 必" "須是 :class:`~concurrent.futures.ThreadPoolExecutor` 的實例。" -#: ../../library/asyncio-eventloop.rst:1334 +#: ../../library/asyncio-eventloop.rst:1366 msgid "" "*executor* must be an instance of :class:`~concurrent.futures." "ThreadPoolExecutor`." msgstr "" "*executor* 必須是 :class:`~concurrent.futures.ThreadPoolExecutor` 的實例。" -#: ../../library/asyncio-eventloop.rst:1340 +#: ../../library/asyncio-eventloop.rst:1372 msgid "Error Handling API" msgstr "錯誤處理 API" -#: ../../library/asyncio-eventloop.rst:1342 +#: ../../library/asyncio-eventloop.rst:1374 msgid "Allows customizing how exceptions are handled in the event loop." msgstr "允許自定義事件迴圈中的例外處理方式。" -#: ../../library/asyncio-eventloop.rst:1346 +#: ../../library/asyncio-eventloop.rst:1378 msgid "Set *handler* as the new event loop exception handler." msgstr "將 *handler* 設定為新的事件迴圈例外處理程式。" -#: ../../library/asyncio-eventloop.rst:1348 +#: ../../library/asyncio-eventloop.rst:1380 msgid "" "If *handler* is ``None``, the default exception handler will be set. " "Otherwise, *handler* must be a callable with the signature matching ``(loop, " @@ -2011,7 +2028,7 @@ msgstr "" "圈的,``context`` 是包含例外詳細資訊的 ``dict`` 物件(有關情境的詳細資訊,請" "參閱 :meth:`call_exception_handler` 文件)。" -#: ../../library/asyncio-eventloop.rst:1356 +#: ../../library/asyncio-eventloop.rst:1388 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 " @@ -2020,7 +2037,7 @@ msgstr "" "如果代表 :class:`~asyncio.Task` 或 :class:`~asyncio.Handle` 呼叫處理程式,它" "將在該任務或回呼處理程式的 :class:`contextvars.Context` 中運行。" -#: ../../library/asyncio-eventloop.rst:1362 +#: ../../library/asyncio-eventloop.rst:1394 msgid "" "The handler may be called in the :class:`~contextvars.Context` of the task " "or handle where the exception originated." @@ -2028,18 +2045,18 @@ msgstr "" "處理程式可能在引發例外的任務或處理程式的 :class:`~contextvars.Context` 中被呼" "叫。" -#: ../../library/asyncio-eventloop.rst:1367 +#: ../../library/asyncio-eventloop.rst:1399 msgid "" "Return the current exception handler, or ``None`` if no custom exception " "handler was set." msgstr "" "回傳當前的例外處理程式,如果未設置自定義例外處理程式,則回傳 ``None``。" -#: ../../library/asyncio-eventloop.rst:1374 +#: ../../library/asyncio-eventloop.rst:1406 msgid "Default exception handler." msgstr "預設例外處理程式。" -#: ../../library/asyncio-eventloop.rst:1376 +#: ../../library/asyncio-eventloop.rst:1408 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 " @@ -2048,17 +2065,17 @@ msgstr "" "當發生例外且未設置例外處理程式時呼叫此函式。自定義例外處理程式可以呼叫此函式" "以轉由預設處理程式處理。" -#: ../../library/asyncio-eventloop.rst:1380 +#: ../../library/asyncio-eventloop.rst:1412 msgid "" "*context* parameter has the same meaning as in :meth:" "`call_exception_handler`." msgstr "*context* 參數與 :meth:`call_exception_handler` 中的意思相同。" -#: ../../library/asyncio-eventloop.rst:1385 +#: ../../library/asyncio-eventloop.rst:1417 msgid "Call the current event loop exception handler." msgstr "呼叫當前事件迴圈例外處理程式。" -#: ../../library/asyncio-eventloop.rst:1387 +#: ../../library/asyncio-eventloop.rst:1419 msgid "" "*context* is a ``dict`` object containing the following keys (new keys may " "be introduced in future Python versions):" @@ -2066,47 +2083,55 @@ msgstr "" "*context* 是一個包含以下鍵的 ``dict`` 物件(未來的 Python 版本中可能會引入新" "的鍵):" -#: ../../library/asyncio-eventloop.rst:1390 +#: ../../library/asyncio-eventloop.rst:1422 msgid "'message': Error message;" msgstr "'message':錯誤訊息;" -#: ../../library/asyncio-eventloop.rst:1391 +#: ../../library/asyncio-eventloop.rst:1423 msgid "'exception' (optional): Exception object;" msgstr "'exception'(可選):例外物件;" -#: ../../library/asyncio-eventloop.rst:1392 +#: ../../library/asyncio-eventloop.rst:1424 msgid "'future' (optional): :class:`asyncio.Future` instance;" msgstr "'future'(可選): :class:`asyncio.Future` 實例;" -#: ../../library/asyncio-eventloop.rst:1393 +#: ../../library/asyncio-eventloop.rst:1425 msgid "'task' (optional): :class:`asyncio.Task` instance;" msgstr "'task'(可選): :class:`asyncio.Task` 實例;" -#: ../../library/asyncio-eventloop.rst:1394 +#: ../../library/asyncio-eventloop.rst:1426 msgid "'handle' (optional): :class:`asyncio.Handle` instance;" msgstr "'handle'(可選): :class:`asyncio.Handle` 實例;" -#: ../../library/asyncio-eventloop.rst:1395 +#: ../../library/asyncio-eventloop.rst:1427 msgid "'protocol' (optional): :ref:`Protocol ` instance;" msgstr "'protocol'(可選): :ref:`Protocol ` 實例;" -#: ../../library/asyncio-eventloop.rst:1396 +#: ../../library/asyncio-eventloop.rst:1428 msgid "'transport' (optional): :ref:`Transport ` instance;" msgstr "'transport'(可選): :ref:`Transport ` 實例;" -#: ../../library/asyncio-eventloop.rst:1397 +#: ../../library/asyncio-eventloop.rst:1429 msgid "'socket' (optional): :class:`socket.socket` instance;" msgstr "'socket'(可選): :class:`socket.socket` 實例;" -#: ../../library/asyncio-eventloop.rst:1398 +#: ../../library/asyncio-eventloop.rst:1430 +msgid "'source_traceback' (optional): Traceback of the source;" +msgstr "" + +#: ../../library/asyncio-eventloop.rst:1431 +msgid "'handle_traceback' (optional): Traceback of the handle;" +msgstr "" + +#: ../../library/asyncio-eventloop.rst:1432 msgid "'asyncgen' (optional): Asynchronous generator that caused" msgstr "'asyncgen'(可選): 非同步產生器引發" -#: ../../library/asyncio-eventloop.rst:1399 +#: ../../library/asyncio-eventloop.rst:1433 msgid "the exception." msgstr "例外。" -#: ../../library/asyncio-eventloop.rst:1403 +#: ../../library/asyncio-eventloop.rst:1437 msgid "" "This method should not be overloaded in subclassed event loops. For custom " "exception handling, use the :meth:`set_exception_handler` method." @@ -2114,15 +2139,15 @@ msgstr "" "此方法不應在子類別事件迴圈中被覆寫。為了自定義例外處理,請使用 :meth:" "`set_exception_handler` 方法。" -#: ../../library/asyncio-eventloop.rst:1408 +#: ../../library/asyncio-eventloop.rst:1442 msgid "Enabling debug mode" msgstr "啟用除錯模式" -#: ../../library/asyncio-eventloop.rst:1412 +#: ../../library/asyncio-eventloop.rst:1446 msgid "Get the debug mode (:class:`bool`) of the event loop." msgstr "取得事件迴圈的除錯模式(\\ :class:`bool`\\ )。" -#: ../../library/asyncio-eventloop.rst:1414 +#: ../../library/asyncio-eventloop.rst:1448 msgid "" "The default value is ``True`` if the environment variable :envvar:" "`PYTHONASYNCIODEBUG` is set to a non-empty string, ``False`` otherwise." @@ -2130,17 +2155,17 @@ msgstr "" "如果環境變數 :envvar:`PYTHONASYNCIODEBUG` 被設定為非空字串,則預設值為 " "``True``,否則為 ``False``。" -#: ../../library/asyncio-eventloop.rst:1420 +#: ../../library/asyncio-eventloop.rst:1454 msgid "Set the debug mode of the event loop." msgstr "設定事件迴圈的除錯模式。" -#: ../../library/asyncio-eventloop.rst:1424 +#: ../../library/asyncio-eventloop.rst:1458 msgid "" "The new :ref:`Python Development Mode ` can now also be used to " "enable the debug mode." msgstr "現在也可以使用新的 :ref:`Python 開發模式 ` 啟用除錯模式。" -#: ../../library/asyncio-eventloop.rst:1429 +#: ../../library/asyncio-eventloop.rst:1463 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 " @@ -2149,19 +2174,19 @@ msgstr "" "此屬性可用於設定被視為\"慢\"的最短執行時間(以秒為單位)。啟用偵錯模式" "後,\"慢\"回呼將被記錄。" -#: ../../library/asyncio-eventloop.rst:1433 +#: ../../library/asyncio-eventloop.rst:1467 msgid "Default value is 100 milliseconds." msgstr "預設值為 100 毫秒" -#: ../../library/asyncio-eventloop.rst:1437 +#: ../../library/asyncio-eventloop.rst:1471 msgid "The :ref:`debug mode of asyncio `." msgstr ":ref:`asyncio 的除錯模式 `。" -#: ../../library/asyncio-eventloop.rst:1441 +#: ../../library/asyncio-eventloop.rst:1475 msgid "Running Subprocesses" msgstr "運行子行程" -#: ../../library/asyncio-eventloop.rst:1443 +#: ../../library/asyncio-eventloop.rst:1477 msgid "" "Methods described in this subsections are low-level. In regular async/await " "code consider using the high-level :func:`asyncio.create_subprocess_shell` " @@ -2171,7 +2196,7 @@ msgstr "" "func:`asyncio.create_subprocess_shell` 和 :func:`asyncio." "create_subprocess_exec` 輔助功能而不是。" -#: ../../library/asyncio-eventloop.rst:1450 +#: ../../library/asyncio-eventloop.rst:1484 msgid "" "On Windows, the default event loop :class:`ProactorEventLoop` supports " "subprocesses, whereas :class:`SelectorEventLoop` does not. See :ref:" @@ -2181,26 +2206,26 @@ msgstr "" "`SelectorEventLoop` 不支援。詳細資訊請參見 :ref:`Windows 上對於子行程的支援 " "`。" -#: ../../library/asyncio-eventloop.rst:1461 +#: ../../library/asyncio-eventloop.rst:1496 msgid "" "Create a subprocess from one or more string arguments specified by *args*." msgstr "從 *args* 指定的一個或多個字串引數建立子行程。" -#: ../../library/asyncio-eventloop.rst:1464 +#: ../../library/asyncio-eventloop.rst:1499 msgid "*args* must be a list of strings represented by:" msgstr "*args* 必須是由以下項表示的字串串列:" -#: ../../library/asyncio-eventloop.rst:1466 +#: ../../library/asyncio-eventloop.rst:1501 msgid ":class:`str`;" msgstr ":class:`str`;" -#: ../../library/asyncio-eventloop.rst:1467 +#: ../../library/asyncio-eventloop.rst:1502 msgid "" "or :class:`bytes`, encoded to the :ref:`filesystem encoding `." msgstr "或 :class:`bytes`,編碼為 :ref:`檔案系統編碼 `。" -#: ../../library/asyncio-eventloop.rst:1470 +#: ../../library/asyncio-eventloop.rst:1505 msgid "" "The first string specifies the program executable, and the remaining strings " "specify the arguments. Together, string arguments form the ``argv`` of the " @@ -2209,7 +2234,7 @@ msgstr "" "第一個字串指定程序可執行檔案,其餘字串指定引數。字串引數一起組成程序的 " "``argv``。" -#: ../../library/asyncio-eventloop.rst:1474 +#: ../../library/asyncio-eventloop.rst:1509 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 " @@ -2220,7 +2245,7 @@ msgstr "" "字串串列作為第一個引數傳遞;然而,:class:`~subprocess.Popen` 接受單個字串串列" "引數,*subprocess_exec* 接受多個字串引數。" -#: ../../library/asyncio-eventloop.rst:1480 +#: ../../library/asyncio-eventloop.rst:1515 msgid "" "The *protocol_factory* must be a callable returning a subclass of the :class:" "`asyncio.SubprocessProtocol` class." @@ -2228,67 +2253,67 @@ msgstr "" "*protocol_factory* 必須是回傳 :class:`asyncio.SubprocessProtocol` 子類別的可" "呼叫物件。" -#: ../../library/asyncio-eventloop.rst:1483 +#: ../../library/asyncio-eventloop.rst:1518 msgid "Other parameters:" msgstr "其他參數:" -#: ../../library/asyncio-eventloop.rst:1485 +#: ../../library/asyncio-eventloop.rst:1520 msgid "*stdin* can be any of these:" msgstr "*stdin* 可以是以下任意一個:" -#: ../../library/asyncio-eventloop.rst:1487 -#: ../../library/asyncio-eventloop.rst:1498 -#: ../../library/asyncio-eventloop.rst:1508 +#: ../../library/asyncio-eventloop.rst:1522 +#: ../../library/asyncio-eventloop.rst:1533 +#: ../../library/asyncio-eventloop.rst:1543 msgid "a file-like object" msgstr "類檔案物件" -#: ../../library/asyncio-eventloop.rst:1488 +#: ../../library/asyncio-eventloop.rst:1523 msgid "" "an existing file descriptor (a positive integer), for example those created " "with :meth:`os.pipe`" msgstr "現有的檔案描述器(正整數),例如用 :meth:`os.pipe` 建立的" -#: ../../library/asyncio-eventloop.rst:1489 -#: ../../library/asyncio-eventloop.rst:1499 -#: ../../library/asyncio-eventloop.rst:1509 +#: ../../library/asyncio-eventloop.rst:1524 +#: ../../library/asyncio-eventloop.rst:1534 +#: ../../library/asyncio-eventloop.rst:1544 msgid "" "the :const:`subprocess.PIPE` constant (default) which will create a new pipe " "and connect it," msgstr ":const:`subprocess.PIPE` 常數(預設),它將建立一個新的管道並連線," -#: ../../library/asyncio-eventloop.rst:1491 -#: ../../library/asyncio-eventloop.rst:1501 -#: ../../library/asyncio-eventloop.rst:1511 +#: ../../library/asyncio-eventloop.rst:1526 +#: ../../library/asyncio-eventloop.rst:1536 +#: ../../library/asyncio-eventloop.rst:1546 msgid "" "the value ``None`` which will make the subprocess inherit the file " "descriptor from this process" msgstr "值 ``None`` 將使子行程從此行程繼承檔案描述器" -#: ../../library/asyncio-eventloop.rst:1493 -#: ../../library/asyncio-eventloop.rst:1503 -#: ../../library/asyncio-eventloop.rst:1513 +#: ../../library/asyncio-eventloop.rst:1528 +#: ../../library/asyncio-eventloop.rst:1538 +#: ../../library/asyncio-eventloop.rst:1548 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:1496 +#: ../../library/asyncio-eventloop.rst:1531 msgid "*stdout* can be any of these:" msgstr "*stdout* 可以是以下任意一個:" -#: ../../library/asyncio-eventloop.rst:1506 +#: ../../library/asyncio-eventloop.rst:1541 msgid "*stderr* can be any of these:" msgstr "*stderr* 可以是以下任意一個:" -#: ../../library/asyncio-eventloop.rst:1515 +#: ../../library/asyncio-eventloop.rst:1550 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:1518 +#: ../../library/asyncio-eventloop.rst:1553 msgid "" "All other keyword arguments are passed to :class:`subprocess.Popen` without " "interpretation, except for *bufsize*, *universal_newlines*, *shell*, *text*, " @@ -2298,7 +2323,7 @@ msgstr "" "*bufsize*、*universal_newlines*、*shell*、*text*、*encoding* 和 *errors* 除" "外,這些不應該指定。" -#: ../../library/asyncio-eventloop.rst:1523 +#: ../../library/asyncio-eventloop.rst:1558 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 " @@ -2307,7 +2332,7 @@ msgstr "" "``asyncio`` 子行程 API 不支援將串流解碼為文本。可以使用 :func:`bytes.decode` " "將從串流回傳的位元組轉換為文本。" -#: ../../library/asyncio-eventloop.rst:1527 +#: ../../library/asyncio-eventloop.rst:1562 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:" @@ -2318,13 +2343,13 @@ msgstr "" "端應該使用 :meth:`~loop.connect_write_pipe` 或 :meth:`~loop." "connect_read_pipe` 註冊到事件迴圈中。" -#: ../../library/asyncio-eventloop.rst:1532 +#: ../../library/asyncio-eventloop.rst:1567 msgid "" "See the constructor of the :class:`subprocess.Popen` class for documentation " "on other arguments." msgstr "有關其他引數的文件,請參閱 :class:`subprocess.Popen` 類別的建構函式。" -#: ../../library/asyncio-eventloop.rst:1535 +#: ../../library/asyncio-eventloop.rst:1570 msgid "" "Returns a pair of ``(transport, protocol)``, where *transport* conforms to " "the :class:`asyncio.SubprocessTransport` base class and *protocol* is an " @@ -2334,7 +2359,7 @@ msgstr "" "SubprocessTransport` 基底類別,*protocol* 是由 *protocol_factory* 實例化的物" "件。" -#: ../../library/asyncio-eventloop.rst:1543 +#: ../../library/asyncio-eventloop.rst:1579 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:1548 +#: ../../library/asyncio-eventloop.rst:1584 msgid "" "This is similar to the standard library :class:`subprocess.Popen` class " "called with ``shell=True``." @@ -2351,7 +2376,7 @@ msgstr "" "這類似於標準函式庫中的 :class:`subprocess.Popen` 類別,使用 ``shell=True`` 呼" "叫。" -#: ../../library/asyncio-eventloop.rst:1551 +#: ../../library/asyncio-eventloop.rst:1587 msgid "" "The *protocol_factory* must be a callable returning a subclass of the :class:" "`SubprocessProtocol` class." @@ -2359,13 +2384,13 @@ msgstr "" "*protocol_factory* 必須是回傳 :class:`SubprocessProtocol` 子類別的可呼叫物" "件。" -#: ../../library/asyncio-eventloop.rst:1554 +#: ../../library/asyncio-eventloop.rst:1590 msgid "" "See :meth:`~loop.subprocess_exec` for more details about the remaining " "arguments." msgstr "有關其餘引數的更多詳細資訊,請參閱 :meth:`~loop.subprocess_exec`。" -#: ../../library/asyncio-eventloop.rst:1557 +#: ../../library/asyncio-eventloop.rst:1593 msgid "" "Returns a pair of ``(transport, protocol)``, where *transport* conforms to " "the :class:`SubprocessTransport` base class and *protocol* is an object " @@ -2375,7 +2400,7 @@ msgstr "" "`SubprocessTransport` 基底類別,而 *protocol* 是由 *protocol_factory* 實例化" "的物件。" -#: ../../library/asyncio-eventloop.rst:1562 +#: ../../library/asyncio-eventloop.rst:1598 msgid "" "It is the application's responsibility to ensure that all whitespace and " "special characters are quoted appropriately to avoid `shell injection " @@ -2388,11 +2413,11 @@ msgstr "" "wikipedia.org/wiki/Shell_injection#Shell_injection>`_\\ 風險。可以使用 :func:" "`shlex.quote` 函式來正確跳脫用於構建 shell 命令的字串中的空白和特殊字元。" -#: ../../library/asyncio-eventloop.rst:1571 +#: ../../library/asyncio-eventloop.rst:1607 msgid "Callback Handles" msgstr "回呼處理" -#: ../../library/asyncio-eventloop.rst:1575 +#: ../../library/asyncio-eventloop.rst:1611 msgid "" "A callback wrapper object returned by :meth:`loop.call_soon`, :meth:`loop." "call_soon_threadsafe`." @@ -2400,46 +2425,46 @@ msgstr "" "由 :meth:`loop.call_soon` 和 :meth:`loop.call_soon_threadsafe` 回傳的回呼包裝" "器。" -#: ../../library/asyncio-eventloop.rst:1580 +#: ../../library/asyncio-eventloop.rst:1616 msgid "" "Return the :class:`contextvars.Context` object associated with the handle." msgstr "回傳與處理相關聯的 :class:`contextvars.Context` 物件。" -#: ../../library/asyncio-eventloop.rst:1587 +#: ../../library/asyncio-eventloop.rst:1623 msgid "" "Cancel the callback. If the callback has already been canceled or executed, " "this method has no effect." msgstr "取消回呼。如果回呼已被取消或執行,此方法將不起作用。" -#: ../../library/asyncio-eventloop.rst:1592 +#: ../../library/asyncio-eventloop.rst:1628 msgid "Return ``True`` if the callback was cancelled." msgstr "如果回呼已被取消,回傳 ``True``。" -#: ../../library/asyncio-eventloop.rst:1598 +#: ../../library/asyncio-eventloop.rst:1634 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:1601 +#: ../../library/asyncio-eventloop.rst:1637 msgid "This class is a subclass of :class:`Handle`." msgstr "這個類別是 :class:`Handle` 的子類別。" -#: ../../library/asyncio-eventloop.rst:1605 +#: ../../library/asyncio-eventloop.rst:1641 msgid "Return a scheduled callback time as :class:`float` seconds." msgstr "回傳預定的回呼時間,以 :class:`float` 秒為單位。" -#: ../../library/asyncio-eventloop.rst:1607 +#: ../../library/asyncio-eventloop.rst:1643 msgid "" "The time is an absolute timestamp, using the same time reference as :meth:" "`loop.time`." msgstr "時間是一個絕對的時間戳,使用與 :meth:`loop.time` 相同的時間參照。" -#: ../../library/asyncio-eventloop.rst:1614 +#: ../../library/asyncio-eventloop.rst:1650 msgid "Server Objects" msgstr "Server 物件" -#: ../../library/asyncio-eventloop.rst:1616 +#: ../../library/asyncio-eventloop.rst:1652 msgid "" "Server objects are created by :meth:`loop.create_server`, :meth:`loop." "create_unix_server`, :func:`start_server`, and :func:`start_unix_server` " @@ -2449,11 +2474,11 @@ msgstr "" "create_unix_server`、:func:`start_server` 和 :func:`start_unix_server` 函式所" "建立。" -#: ../../library/asyncio-eventloop.rst:1620 +#: ../../library/asyncio-eventloop.rst:1656 msgid "Do not instantiate the :class:`Server` class directly." msgstr "請勿直接實例化 :class:`Server` 類別。" -#: ../../library/asyncio-eventloop.rst:1624 +#: ../../library/asyncio-eventloop.rst:1660 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 " @@ -2462,7 +2487,7 @@ msgstr "" "*Server* 物件是非同步情境管理器。當在 ``async with`` 陳述中使用時,可以保證在" "完成 ``async with`` 陳述時,Server 物件將會關閉並停止接受新的連線: ::" -#: ../../library/asyncio-eventloop.rst:1629 +#: ../../library/asyncio-eventloop.rst:1665 msgid "" "srv = await loop.create_server(...)\n" "\n" @@ -2472,30 +2497,30 @@ msgid "" "# At this point, srv is closed and no longer accepts new connections." msgstr "" -#: ../../library/asyncio-eventloop.rst:1637 +#: ../../library/asyncio-eventloop.rst:1673 msgid "Server object is an asynchronous context manager since Python 3.7." msgstr "自 Python 3.7 起,Server 物件是非同步情境管理器。" -#: ../../library/asyncio-eventloop.rst:1640 +#: ../../library/asyncio-eventloop.rst:1676 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:1645 +#: ../../library/asyncio-eventloop.rst:1681 msgid "" "Stop serving: close listening sockets and set the :attr:`sockets` attribute " "to ``None``." msgstr "停止服務:關閉監聽的 sockets 並將 :attr:`sockets` 屬性設為 ``None``。" -#: ../../library/asyncio-eventloop.rst:1648 +#: ../../library/asyncio-eventloop.rst:1684 msgid "" "The sockets that represent existing incoming client connections are left " "open." msgstr "代表現有傳入用戶端連線的 sockets 仍然保持開啟。" -#: ../../library/asyncio-eventloop.rst:1651 +#: ../../library/asyncio-eventloop.rst:1687 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)." @@ -2503,54 +2528,54 @@ msgstr "" "伺服器以非同步方式關閉;使用 :meth:`wait_close` 協程等待伺服器關閉(不再有活" "躍連線)。" -#: ../../library/asyncio-eventloop.rst:1657 +#: ../../library/asyncio-eventloop.rst:1693 #, fuzzy msgid "Close all existing incoming client connections." msgstr "代表現有傳入用戶端連線的 sockets 仍然保持開啟。" -#: ../../library/asyncio-eventloop.rst:1659 +#: ../../library/asyncio-eventloop.rst:1695 msgid "" "Calls :meth:`~asyncio.BaseTransport.close` on all associated transports." msgstr "" -#: ../../library/asyncio-eventloop.rst:1662 +#: ../../library/asyncio-eventloop.rst:1698 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:1669 +#: ../../library/asyncio-eventloop.rst:1705 msgid "" "Close all existing incoming client connections immediately, without waiting " "for pending operations to complete." msgstr "" -#: ../../library/asyncio-eventloop.rst:1672 +#: ../../library/asyncio-eventloop.rst:1708 msgid "" "Calls :meth:`~asyncio.WriteTransport.abort` on all associated transports." msgstr "" -#: ../../library/asyncio-eventloop.rst:1675 +#: ../../library/asyncio-eventloop.rst:1711 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:1682 +#: ../../library/asyncio-eventloop.rst:1718 msgid "Return the event loop associated with the server object." msgstr "回傳與伺服器物件關聯的事件迴圈。" -#: ../../library/asyncio-eventloop.rst:1688 +#: ../../library/asyncio-eventloop.rst:1725 msgid "Start accepting connections." msgstr "開始接受連線。" -#: ../../library/asyncio-eventloop.rst:1690 +#: ../../library/asyncio-eventloop.rst:1727 msgid "" "This method is idempotent, so it can be called when the server is already " "serving." msgstr "此方法是幂等的,因此可以在伺服器已經運行時呼叫。" -#: ../../library/asyncio-eventloop.rst:1693 +#: ../../library/asyncio-eventloop.rst:1730 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 " @@ -2563,14 +2588,14 @@ msgstr "" "種情況下,可以使用 ``Server.start_serving()`` 或 :meth:`Server." "serve_forever` 來使 Server 開始接受連線。" -#: ../../library/asyncio-eventloop.rst:1704 +#: ../../library/asyncio-eventloop.rst:1742 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:1708 +#: ../../library/asyncio-eventloop.rst:1746 msgid "" "This method can be called if the server is already accepting connections. " "Only one ``serve_forever`` task can exist per one *Server* object." @@ -2578,7 +2603,7 @@ msgstr "" "如果伺服器已經接受連線,則可以呼叫此方法。每個 *Server* 物件只能存在一個 " "``serve_forever`` 任務。" -#: ../../library/asyncio-eventloop.rst:1714 +#: ../../library/asyncio-eventloop.rst:1752 msgid "" "async def client_connected(reader, writer):\n" " # Communicate with the client with\n" @@ -2593,24 +2618,24 @@ msgid "" "asyncio.run(main('127.0.0.1', 0))" msgstr "" -#: ../../library/asyncio-eventloop.rst:1730 +#: ../../library/asyncio-eventloop.rst:1768 msgid "Return ``True`` if the server is accepting new connections." msgstr "如果伺服器正在接受新連線,則回傳 ``True``。" -#: ../../library/asyncio-eventloop.rst:1736 +#: ../../library/asyncio-eventloop.rst:1775 msgid "" "Wait until the :meth:`close` method completes and all active connections " "have finished." msgstr "等待 :meth:`close` 方法完成且所有活動連線都已結束。" -#: ../../library/asyncio-eventloop.rst:1741 +#: ../../library/asyncio-eventloop.rst:1780 msgid "" "List of socket-like objects, ``asyncio.trsock.TransportSocket``, which the " "server is listening on." msgstr "" "伺服器正在監聽的類似 socket 的物件串列,``asyncio.trsock.TransportSocket``。" -#: ../../library/asyncio-eventloop.rst:1744 +#: ../../library/asyncio-eventloop.rst:1783 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." @@ -2618,11 +2643,11 @@ msgstr "" "在 Python 3.7 之前,``Server.sockets`` 曾經直接回傳內部伺服器 sockets 的串" "列。在 3.7 中回傳了該串列的副本。" -#: ../../library/asyncio-eventloop.rst:1754 +#: ../../library/asyncio-eventloop.rst:1793 msgid "Event Loop Implementations" msgstr "事件迴圈實作" -#: ../../library/asyncio-eventloop.rst:1756 +#: ../../library/asyncio-eventloop.rst:1795 msgid "" "asyncio ships with two different event loop implementations: :class:" "`SelectorEventLoop` and :class:`ProactorEventLoop`." @@ -2630,21 +2655,21 @@ msgstr "" "asyncio 內附兩個不同的事件迴圈實作::class:`SelectorEventLoop` 和 :class:" "`ProactorEventLoop`。" -#: ../../library/asyncio-eventloop.rst:1759 +#: ../../library/asyncio-eventloop.rst:1798 #, fuzzy msgid "By default asyncio is configured to use :class:`EventLoop`." msgstr "" "預設情況下,asyncio 配置為在 Unix 上使用 :class:`SelectorEventLoop`,在 " "Windows 上使用 :class:`ProactorEventLoop`。" -#: ../../library/asyncio-eventloop.rst:1764 +#: ../../library/asyncio-eventloop.rst:1803 #, fuzzy msgid "" "A subclass of :class:`AbstractEventLoop` based on the :mod:`selectors` " "module." msgstr "基於 :mod:`selectors` 模組的事件迴圈。" -#: ../../library/asyncio-eventloop.rst:1767 +#: ../../library/asyncio-eventloop.rst:1806 msgid "" "Uses the most efficient *selector* available for the given platform. It is " "also possible to manually configure the exact selector implementation to be " @@ -2653,7 +2678,7 @@ msgstr "" "使用特定平台上最有效的 *selector*。也可以手動配置要使用的確切 selector 實" "作: ::" -#: ../../library/asyncio-eventloop.rst:1771 +#: ../../library/asyncio-eventloop.rst:1810 msgid "" "import asyncio\n" "import selectors\n" @@ -2675,36 +2700,29 @@ msgstr "" "\n" "asyncio.set_event_loop_policy(MyPolicy())" -#: ../../library/asyncio-eventloop.rst:1782 -msgid ":ref:`Availability `: Unix, Windows." -msgstr ":ref:`適用 `:Unix、Windows。" - -#: ../../library/asyncio-eventloop.rst:1787 +#: ../../library/asyncio-eventloop.rst:1826 #, fuzzy msgid "" "A subclass of :class:`AbstractEventLoop` for Windows that uses \"I/O " "Completion Ports\" (IOCP)." msgstr "用於 Windows 的事件迴圈,使用\"I/O 完成埠\"(IOCP)。" -#: ../../library/asyncio-eventloop.rst:1789 -msgid ":ref:`Availability `: Windows." -msgstr ":ref:`適用 `:Windows。" - -#: ../../library/asyncio-eventloop.rst:1793 +#: ../../library/asyncio-eventloop.rst:1832 +#, fuzzy msgid "" -"`MSDN documentation on I/O Completion Ports `_." +"`MSDN documentation on I/O Completion Ports `_." msgstr "" "`I/O 完成埠(I/O Completion Ports)的 MSDN 文件 `_。" -#: ../../library/asyncio-eventloop.rst:1798 +#: ../../library/asyncio-eventloop.rst:1837 msgid "" "An alias to the most efficient available subclass of :class:" "`AbstractEventLoop` for the given platform." msgstr "" -#: ../../library/asyncio-eventloop.rst:1801 +#: ../../library/asyncio-eventloop.rst:1840 #, fuzzy msgid "" "It is an alias to :class:`SelectorEventLoop` on Unix and :class:" @@ -2713,11 +2731,11 @@ msgstr "" "預設情況下,asyncio 配置為在 Unix 上使用 :class:`SelectorEventLoop`,在 " "Windows 上使用 :class:`ProactorEventLoop`。" -#: ../../library/asyncio-eventloop.rst:1807 +#: ../../library/asyncio-eventloop.rst:1846 msgid "Abstract base class for asyncio-compliant event loops." msgstr "為符合 asyncio 標準的事件迴圈的抽象基礎類別。" -#: ../../library/asyncio-eventloop.rst:1809 +#: ../../library/asyncio-eventloop.rst:1848 msgid "" "The :ref:`asyncio-event-loop-methods` section lists all methods that an " "alternative implementation of ``AbstractEventLoop`` should have defined." @@ -2725,11 +2743,11 @@ msgstr "" ":ref:`asyncio-event-loop-methods` 部分列出了替代 ``AbstractEventLoop`` 實作應" "該定義的所有方法。" -#: ../../library/asyncio-eventloop.rst:1815 +#: ../../library/asyncio-eventloop.rst:1854 msgid "Examples" msgstr "範例" -#: ../../library/asyncio-eventloop.rst:1817 +#: ../../library/asyncio-eventloop.rst:1856 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." @@ -2740,11 +2758,11 @@ msgstr "" "`loop.run_forever` 和 :meth:`loop.call_soon`。現代 asyncio 應用程式很少需要這" "種方式撰寫;請考慮使用高階的函式,如 :func:`asyncio.run`。" -#: ../../library/asyncio-eventloop.rst:1827 +#: ../../library/asyncio-eventloop.rst:1866 msgid "Hello World with call_soon()" msgstr "使用 call_soon() 的 Hello World 範例" -#: ../../library/asyncio-eventloop.rst:1829 +#: ../../library/asyncio-eventloop.rst:1868 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::" @@ -2752,7 +2770,7 @@ msgstr "" "使用 :meth:`loop.call_soon` 方法排程回呼的範例。回呼會顯示 ``\"Hello " "World\"``,然後停止事件迴圈: ::" -#: ../../library/asyncio-eventloop.rst:1833 +#: ../../library/asyncio-eventloop.rst:1872 msgid "" "import asyncio\n" "\n" @@ -2773,18 +2791,18 @@ msgid "" " loop.close()" msgstr "" -#: ../../library/asyncio-eventloop.rst:1853 +#: ../../library/asyncio-eventloop.rst:1892 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:1860 +#: ../../library/asyncio-eventloop.rst:1899 msgid "Display the current date with call_later()" msgstr "使用 call_later() 顯示目前日期" -#: ../../library/asyncio-eventloop.rst:1862 +#: ../../library/asyncio-eventloop.rst:1901 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 " @@ -2793,7 +2811,7 @@ msgstr "" "一個回呼的範例,每秒顯示目前日期。回呼使用 :meth:`loop.call_later` 方法在 5 " "秒後重新排程自己,然後停止事件迴圈: ::" -#: ../../library/asyncio-eventloop.rst:1866 +#: ../../library/asyncio-eventloop.rst:1905 msgid "" "import asyncio\n" "import datetime\n" @@ -2818,7 +2836,7 @@ msgid "" " loop.close()" msgstr "" -#: ../../library/asyncio-eventloop.rst:1890 +#: ../../library/asyncio-eventloop.rst:1929 msgid "" "A similar :ref:`current date ` example created with a " "coroutine and the :func:`run` function." @@ -2826,11 +2844,11 @@ msgstr "" "使用協程和 :func:`run` 函式建立的類似 :ref:`current date " "` 範例。" -#: ../../library/asyncio-eventloop.rst:1897 +#: ../../library/asyncio-eventloop.rst:1936 msgid "Watch a file descriptor for read events" msgstr "監聽檔案描述器以進行讀取事件" -#: ../../library/asyncio-eventloop.rst:1899 +#: ../../library/asyncio-eventloop.rst:1938 msgid "" "Wait until a file descriptor received some data using the :meth:`loop." "add_reader` method and then close the event loop::" @@ -2838,7 +2856,7 @@ msgstr "" "使用 :meth:`loop.add_reader` 方法等待檔案描述器接收到某些資料,然後關閉事件迴" "圈: ::" -#: ../../library/asyncio-eventloop.rst:1902 +#: ../../library/asyncio-eventloop.rst:1941 msgid "" "import asyncio\n" "from socket import socketpair\n" @@ -2874,7 +2892,7 @@ msgid "" " loop.close()" msgstr "" -#: ../../library/asyncio-eventloop.rst:1937 +#: ../../library/asyncio-eventloop.rst:1976 msgid "" "A similar :ref:`example ` using " "transports, protocols, and the :meth:`loop.create_connection` method." @@ -2882,7 +2900,7 @@ msgstr "" "使用傳輸、協定和 :meth:`loop.create_connection` 方法的類似 :ref:`範例 " "`。" -#: ../../library/asyncio-eventloop.rst:1941 +#: ../../library/asyncio-eventloop.rst:1980 msgid "" "Another similar :ref:`example ` " "using the high-level :func:`asyncio.open_connection` function and streams." @@ -2890,15 +2908,15 @@ msgstr "" "另一個使用高階 :func:`asyncio.open_connection` 函式和串流的類似 :ref:`範例 " "`。" -#: ../../library/asyncio-eventloop.rst:1949 +#: ../../library/asyncio-eventloop.rst:1988 msgid "Set signal handlers for SIGINT and SIGTERM" msgstr "設定 SIGINT 和 SIGTERM 的訊號處理程式" -#: ../../library/asyncio-eventloop.rst:1951 +#: ../../library/asyncio-eventloop.rst:1990 msgid "(This ``signals`` example only works on Unix.)" msgstr "(此 ``signals`` 範例僅在 Unix 上運作。)" -#: ../../library/asyncio-eventloop.rst:1953 +#: ../../library/asyncio-eventloop.rst:1992 msgid "" "Register handlers for signals :const:`~signal.SIGINT` and :const:`~signal." "SIGTERM` using the :meth:`loop.add_signal_handler` method::" @@ -2906,7 +2924,7 @@ msgstr "" "使用 :meth:`loop.add_signal_handler` 方法註冊訊號 :py:data:`SIGINT` 和 :py:" "data:`SIGTERM` 的處理程式: ::" -#: ../../library/asyncio-eventloop.rst:1956 +#: ../../library/asyncio-eventloop.rst:1995 msgid "" "import asyncio\n" "import functools\n" @@ -2932,3 +2950,12 @@ msgid "" "\n" "asyncio.run(main())" msgstr "" + +#~ msgid ":ref:`Availability `: Unix." +#~ msgstr ":ref:`適用 `:Unix。" + +#~ msgid ":ref:`Availability `: Unix, Windows." +#~ msgstr ":ref:`適用 `:Unix、Windows。" + +#~ msgid ":ref:`Availability `: Windows." +#~ msgstr ":ref:`適用 `:Windows。" diff --git a/library/asyncio-policy.po b/library/asyncio-policy.po index 78b1176d70..b45cb59d01 100644 --- a/library/asyncio-policy.po +++ b/library/asyncio-policy.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2024-10-13 17:13+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-" @@ -160,8 +160,8 @@ msgid "" msgstr "" #: ../../library/asyncio-policy.rst:131 ../../library/asyncio-policy.rst:139 -msgid ":ref:`Availability `: Windows." -msgstr ":ref:`適用 `:Windows。" +msgid "Availability" +msgstr "" #: ../../library/asyncio-policy.rst:136 msgid "" @@ -413,3 +413,6 @@ msgstr "" " return loop\n" "\n" "asyncio.set_event_loop_policy(MyEventLoopPolicy())" + +#~ msgid ":ref:`Availability `: Windows." +#~ msgstr ":ref:`適用 `:Windows。" diff --git a/library/asyncio-queue.po b/library/asyncio-queue.po index 088dea0967..0d75575589 100644 --- a/library/asyncio-queue.po +++ b/library/asyncio-queue.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-03-03 18:39+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-" @@ -103,28 +103,28 @@ msgstr "" "如果佇列用 ``maxsize=0`` (預設)初始化,則 :meth:`full` 永遠不會回傳 " "``True``。" -#: ../../library/asyncio-queue.rst:62 +#: ../../library/asyncio-queue.rst:63 msgid "" "Remove and return an item from the queue. If queue is empty, wait until an " "item is available." msgstr "從佇列中刪除並回傳一個元素。如果佇列為空,則持續等待直到佇列中有元素。" -#: ../../library/asyncio-queue.rst:65 +#: ../../library/asyncio-queue.rst:66 msgid "" "Raises :exc:`QueueShutDown` if the queue has been shut down and is empty, or " "if the queue has been shut down immediately." msgstr "" -#: ../../library/asyncio-queue.rst:70 +#: ../../library/asyncio-queue.rst:71 msgid "" "Return an item if one is immediately available, else raise :exc:`QueueEmpty`." msgstr "如果佇列內有值則立即回傳佇列中的元素,否則引發 :exc:`QueueEmpty`。" -#: ../../library/asyncio-queue.rst:75 +#: ../../library/asyncio-queue.rst:77 msgid "Block until all items in the queue have been received and processed." msgstr "持續阻塞直到佇列中所有的元素都被接收和處理完畢。" -#: ../../library/asyncio-queue.rst:77 +#: ../../library/asyncio-queue.rst:79 msgid "" "The count of unfinished tasks goes up whenever an item is added to the " "queue. The count goes down whenever a consumer coroutine calls :meth:" @@ -137,7 +137,7 @@ msgstr "" "成,未完成任務計數就會減少。當未完成計數降到零的時候,:meth:`join` 阻塞會被解" "除 (unblock)。" -#: ../../library/asyncio-queue.rst:85 +#: ../../library/asyncio-queue.rst:88 msgid "" "Put an item into the queue. If the queue is full, wait until a free slot is " "available before adding the item." @@ -145,36 +145,36 @@ msgstr "" "將一個元素放進佇列。如果佇列滿了,在新增元素之前,會持續等待直到有空閒插槽 " "(free slot) 能被使用。" -#: ../../library/asyncio-queue.rst:88 +#: ../../library/asyncio-queue.rst:91 msgid "Raises :exc:`QueueShutDown` if the queue has been shut down." msgstr "" -#: ../../library/asyncio-queue.rst:92 +#: ../../library/asyncio-queue.rst:95 msgid "Put an item into the queue without blocking." msgstr "不阻塞地將一個元素放入佇列。" -#: ../../library/asyncio-queue.rst:94 +#: ../../library/asyncio-queue.rst:97 msgid "If no free slot is immediately available, raise :exc:`QueueFull`." msgstr "如果沒有立即可用的空閒插槽,引發 :exc:`QueueFull`。" -#: ../../library/asyncio-queue.rst:98 +#: ../../library/asyncio-queue.rst:101 msgid "Return the number of items in the queue." msgstr "回傳佇列中的元素數量。" -#: ../../library/asyncio-queue.rst:102 +#: ../../library/asyncio-queue.rst:105 msgid "" "Shut down the queue, making :meth:`~Queue.get` and :meth:`~Queue.put` raise :" "exc:`QueueShutDown`." msgstr "" -#: ../../library/asyncio-queue.rst:105 +#: ../../library/asyncio-queue.rst:108 msgid "" "By default, :meth:`~Queue.get` on a shut down queue will only raise once the " "queue is empty. Set *immediate* to true to make :meth:`~Queue.get` raise " "immediately instead." msgstr "" -#: ../../library/asyncio-queue.rst:109 +#: ../../library/asyncio-queue.rst:112 msgid "" "All blocked callers of :meth:`~Queue.put` and :meth:`~Queue.get` will be " "unblocked. If *immediate* is true, a task will be marked as done for each " @@ -182,20 +182,22 @@ msgid "" "join`." msgstr "" -#: ../../library/asyncio-queue.rst:118 -msgid "Indicate that a formerly enqueued task is complete." +#: ../../library/asyncio-queue.rst:121 +#, fuzzy +msgid "Indicate that a formerly enqueued work item is complete." msgstr "表示前面一個排隊的任務已經完成。" -#: ../../library/asyncio-queue.rst:120 +#: ../../library/asyncio-queue.rst:123 +#, fuzzy msgid "" -"Used by queue consumers. For each :meth:`~Queue.get` used to fetch a task, a " -"subsequent call to :meth:`task_done` tells the queue that the processing on " -"the task is complete." +"Used by queue consumers. For each :meth:`~Queue.get` used to fetch a work " +"item, a subsequent call to :meth:`task_done` tells the queue that the " +"processing on the work item is complete." msgstr "" "由佇列消耗者使用。對於每個用於獲取一個任務的 :meth:`~Queue.get`,接續的 :" "meth:`task_done` 呼叫會告訴佇列這個任務的處理已經完成。" -#: ../../library/asyncio-queue.rst:124 +#: ../../library/asyncio-queue.rst:127 msgid "" "If a :meth:`join` is currently blocking, it will resume when all items have " "been processed (meaning that a :meth:`task_done` call was received for every " @@ -204,53 +206,53 @@ msgstr "" "如果 :meth:`join` 當前正在阻塞,在所有項目都被處理後會解除阻塞(意味著每個" "以 :meth:`~Queue.put` 放進佇列的條目都會收到一個 :meth:`task_done`\\ )。" -#: ../../library/asyncio-queue.rst:129 +#: ../../library/asyncio-queue.rst:132 msgid "" "``shutdown(immediate=True)`` calls :meth:`task_done` for each remaining item " "in the queue." msgstr "" -#: ../../library/asyncio-queue.rst:132 +#: ../../library/asyncio-queue.rst:135 msgid "" "Raises :exc:`ValueError` if called more times than there were items placed " "in the queue." msgstr "如果被呼叫的次數多於放入佇列中的項目數量,將引發 :exc:`ValueError`。" -#: ../../library/asyncio-queue.rst:137 +#: ../../library/asyncio-queue.rst:140 msgid "Priority Queue" msgstr "Priority Queue(優先佇列)" -#: ../../library/asyncio-queue.rst:141 +#: ../../library/asyncio-queue.rst:144 msgid "" "A variant of :class:`Queue`; retrieves entries in priority order (lowest " "first)." msgstr ":class:`Queue` 的變形;按優先順序取出條目 (最小的先取出)。" -#: ../../library/asyncio-queue.rst:144 +#: ../../library/asyncio-queue.rst:147 msgid "Entries are typically tuples of the form ``(priority_number, data)``." msgstr "條目通常是 ``(priority_number, data)`` 形式的 tuple(元組)。" -#: ../../library/asyncio-queue.rst:149 +#: ../../library/asyncio-queue.rst:152 msgid "LIFO Queue" msgstr "LIFO Queue" -#: ../../library/asyncio-queue.rst:153 +#: ../../library/asyncio-queue.rst:156 msgid "" "A variant of :class:`Queue` that retrieves most recently added entries first " "(last in, first out)." msgstr ":class:`Queue` 的變形,先取出最近新增的條目(後進先出)。" -#: ../../library/asyncio-queue.rst:158 +#: ../../library/asyncio-queue.rst:161 msgid "Exceptions" msgstr "例外" -#: ../../library/asyncio-queue.rst:162 +#: ../../library/asyncio-queue.rst:165 msgid "" "This exception is raised when the :meth:`~Queue.get_nowait` method is called " "on an empty queue." msgstr "當佇列為空的時候,呼叫 :meth:`~Queue.get_nowait` 方法會引發這個例外。" -#: ../../library/asyncio-queue.rst:168 +#: ../../library/asyncio-queue.rst:171 msgid "" "Exception raised when the :meth:`~Queue.put_nowait` method is called on a " "queue that has reached its *maxsize*." @@ -258,7 +260,7 @@ msgstr "" "當佇列中條目數量已經達到它的 *maxsize* 時,呼叫 :meth:`~Queue.put_nowait` 方" "法會引發這個例外。" -#: ../../library/asyncio-queue.rst:174 +#: ../../library/asyncio-queue.rst:177 #, fuzzy msgid "" "Exception raised when :meth:`~Queue.put` or :meth:`~Queue.get` is called on " @@ -267,16 +269,16 @@ msgstr "" "當佇列中條目數量已經達到它的 *maxsize* 時,呼叫 :meth:`~Queue.put_nowait` 方" "法會引發這個例外。" -#: ../../library/asyncio-queue.rst:181 +#: ../../library/asyncio-queue.rst:184 msgid "Examples" msgstr "範例" -#: ../../library/asyncio-queue.rst:185 +#: ../../library/asyncio-queue.rst:188 msgid "" "Queues can be used to distribute workload between several concurrent tasks::" msgstr "佇列能被用於多個並行任務的工作分配:" -#: ../../library/asyncio-queue.rst:188 +#: ../../library/asyncio-queue.rst:191 msgid "" "import asyncio\n" "import random\n" diff --git a/library/asyncio-stream.po b/library/asyncio-stream.po index a89301bcf9..0650eed218 100644 --- a/library/asyncio-stream.po +++ b/library/asyncio-stream.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-03-03 18:39+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:415 +#: ../../library/asyncio-stream.rst:22 ../../library/asyncio-stream.rst:430 msgid "" "import asyncio\n" "\n" @@ -96,13 +96,13 @@ msgid "" "with streams:" msgstr "下面的高階 asyncio 函式可以用來建立和處理串流:" -#: ../../library/asyncio-stream.rst:58 +#: ../../library/asyncio-stream.rst:59 msgid "" "Establish a network connection and return a pair of ``(reader, writer)`` " "objects." msgstr "建立網路連線並回傳一對 ``(reader, writer)`` 物件。" -#: ../../library/asyncio-stream.rst:61 +#: ../../library/asyncio-stream.rst:62 msgid "" "The returned *reader* and *writer* objects are instances of :class:" "`StreamReader` and :class:`StreamWriter` classes." @@ -110,7 +110,7 @@ msgstr "" "回傳的 *reader* 和 *writer* 物件是 :class:`StreamReader` 和 :class:" "`StreamWriter` 類別的實例。" -#: ../../library/asyncio-stream.rst:64 ../../library/asyncio-stream.rst:109 +#: ../../library/asyncio-stream.rst:65 ../../library/asyncio-stream.rst:112 msgid "" "*limit* determines the buffer size limit used by the returned :class:" "`StreamReader` instance. By default the *limit* is set to 64 KiB." @@ -118,43 +118,43 @@ msgstr "" "*limit* 指定了回傳的 :class:`StreamReader` 實例所使用的緩衝區 (buffer) 大小限" "制。*limit* 預設為 64 KiB。" -#: ../../library/asyncio-stream.rst:68 +#: ../../library/asyncio-stream.rst:69 msgid "" "The rest of the arguments are passed directly to :meth:`loop." "create_connection`." msgstr "其餘的引數會直接傳遞到 :meth:`loop.create_connection`。" -#: ../../library/asyncio-stream.rst:73 ../../library/asyncio-stream.rst:147 +#: ../../library/asyncio-stream.rst:74 ../../library/asyncio-stream.rst:154 msgid "" "The *sock* argument transfers ownership of the socket to the :class:" "`StreamWriter` created. To close the socket, call its :meth:`~asyncio." "StreamWriter.close` method." msgstr "" -#: ../../library/asyncio-stream.rst:77 +#: ../../library/asyncio-stream.rst:78 msgid "Added the *ssl_handshake_timeout* parameter." msgstr "新增 *ssl_handshake_timeout* 參數。" -#: ../../library/asyncio-stream.rst:80 +#: ../../library/asyncio-stream.rst:81 msgid "Added the *happy_eyeballs_delay* and *interleave* parameters." msgstr "新增 *happy_eyeballs_delay* 和 *interleave* 參數。" -#: ../../library/asyncio-stream.rst:83 ../../library/asyncio-stream.rst:125 -#: ../../library/asyncio-stream.rst:157 ../../library/asyncio-stream.rst:187 +#: ../../library/asyncio-stream.rst:84 ../../library/asyncio-stream.rst:128 +#: ../../library/asyncio-stream.rst:164 ../../library/asyncio-stream.rst:195 msgid "Removed the *loop* parameter." msgstr "移除 *loop* 參數。" -#: ../../library/asyncio-stream.rst:86 ../../library/asyncio-stream.rst:128 -#: ../../library/asyncio-stream.rst:160 ../../library/asyncio-stream.rst:190 -#: ../../library/asyncio-stream.rst:383 +#: ../../library/asyncio-stream.rst:87 ../../library/asyncio-stream.rst:131 +#: ../../library/asyncio-stream.rst:167 ../../library/asyncio-stream.rst:198 +#: ../../library/asyncio-stream.rst:397 msgid "Added the *ssl_shutdown_timeout* parameter." msgstr "新增 *ssl_shutdown_timeout* 參數。" -#: ../../library/asyncio-stream.rst:98 +#: ../../library/asyncio-stream.rst:101 msgid "Start a socket server." msgstr "啟動 socket 伺服器。" -#: ../../library/asyncio-stream.rst:100 +#: ../../library/asyncio-stream.rst:103 msgid "" "The *client_connected_cb* callback is called whenever a new client " "connection is established. It receives a ``(reader, writer)`` pair as two " @@ -165,7 +165,7 @@ msgstr "" "式會接收到一對引數 ``(reader, writer)``,分別為 :class:`StreamReader` 和 :" "class:`StreamWriter` 的實例。" -#: ../../library/asyncio-stream.rst:105 +#: ../../library/asyncio-stream.rst:108 msgid "" "*client_connected_cb* can be a plain callable or a :ref:`coroutine function " "`; if it is a coroutine function, it will be automatically " @@ -175,43 +175,48 @@ msgstr "" "ref:`協程函式 `;如果它是一個協程函式,它將自動作為 :class:`Task` " "來被排程。" -#: ../../library/asyncio-stream.rst:113 +#: ../../library/asyncio-stream.rst:116 msgid "" "The rest of the arguments are passed directly to :meth:`loop.create_server`." msgstr "剩下的引數將會直接傳遞給 :meth:`loop.create_server`。" -#: ../../library/asyncio-stream.rst:118 ../../library/asyncio-stream.rst:177 +#: ../../library/asyncio-stream.rst:121 ../../library/asyncio-stream.rst:185 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." msgstr "" -#: ../../library/asyncio-stream.rst:122 +#: ../../library/asyncio-stream.rst:125 msgid "Added the *ssl_handshake_timeout* and *start_serving* parameters." msgstr "新增 *ssl_handshake_timeout* 與 *start_serving* 參數。" -#: ../../library/asyncio-stream.rst:133 +#: ../../library/asyncio-stream.rst:134 +#, fuzzy +msgid "Added the *keep_alive* parameter." +msgstr "新增 *ssl_handshake_timeout* 參數。" + +#: ../../library/asyncio-stream.rst:139 msgid "Unix Sockets" msgstr "Unix Sockets" -#: ../../library/asyncio-stream.rst:138 +#: ../../library/asyncio-stream.rst:145 msgid "" "Establish a Unix socket connection and return a pair of ``(reader, writer)``." msgstr "建立一個 Unix socket 連線並回傳一對 ``(reader, writer)``。" -#: ../../library/asyncio-stream.rst:141 +#: ../../library/asyncio-stream.rst:148 msgid "Similar to :func:`open_connection` but operates on Unix sockets." msgstr "與 :func:`open_connection` 相似,但是是操作 Unix sockets。" -#: ../../library/asyncio-stream.rst:143 +#: ../../library/asyncio-stream.rst:150 msgid "See also the documentation of :meth:`loop.create_unix_connection`." msgstr "另請參閱 :meth:`loop.create_unix_connection` 文件。" -#: ../../library/asyncio-stream.rst:151 ../../library/asyncio-stream.rst:181 -msgid ":ref:`Availability `: Unix." -msgstr ":ref:`適用 `:Unix。" +#: ../../library/asyncio-stream.rst:158 ../../library/asyncio-stream.rst:189 +msgid "Availability" +msgstr "" -#: ../../library/asyncio-stream.rst:153 +#: ../../library/asyncio-stream.rst:160 msgid "" "Added the *ssl_handshake_timeout* parameter. The *path* parameter can now be " "a :term:`path-like object`" @@ -219,19 +224,19 @@ msgstr "" "新增 *ssl_handshake_timeout* 參數。*path* 參數現在可以是個 :term:`path-like " "object`" -#: ../../library/asyncio-stream.rst:169 +#: ../../library/asyncio-stream.rst:177 msgid "Start a Unix socket server." msgstr "啟動一個 Unix socket 伺服器。" -#: ../../library/asyncio-stream.rst:171 +#: ../../library/asyncio-stream.rst:179 msgid "Similar to :func:`start_server` but works with Unix sockets." msgstr "與 :func:`start_server` 相似,但會是操作 Unix sockets。" -#: ../../library/asyncio-stream.rst:173 +#: ../../library/asyncio-stream.rst:181 msgid "See also the documentation of :meth:`loop.create_unix_server`." msgstr "另請參閱 :meth:`loop.create_unix_server` 文件。" -#: ../../library/asyncio-stream.rst:183 +#: ../../library/asyncio-stream.rst:191 msgid "" "Added the *ssl_handshake_timeout* and *start_serving* parameters. The *path* " "parameter can now be a :term:`path-like object`." @@ -239,11 +244,11 @@ msgstr "" "新增 *ssl_handshake_timeout* 與 *start_serving* 參數。*path* 參數現在可以是" "個 :term:`path-like object`。" -#: ../../library/asyncio-stream.rst:195 +#: ../../library/asyncio-stream.rst:203 msgid "StreamReader" msgstr "StreamReader" -#: ../../library/asyncio-stream.rst:199 +#: ../../library/asyncio-stream.rst:207 msgid "" "Represents a reader object that provides APIs to read data from the IO " "stream. As an :term:`asynchronous iterable`, the object supports the :" @@ -252,7 +257,7 @@ msgstr "" "表示一個有提供 API 來從 IO 串流中讀取資料的 reader 物件。作為一個 :term:" "`asynchronous iterable`,此物件支援 :keyword:`async for` 陳述式。" -#: ../../library/asyncio-stream.rst:203 +#: ../../library/asyncio-stream.rst:211 msgid "" "It is not recommended to instantiate *StreamReader* objects directly; use :" "func:`open_connection` and :func:`start_server` instead." @@ -260,15 +265,15 @@ msgstr "" "不建議直接實例化 *StreamReader* 物件;使用 :func:`open_connection` 和 :func:" "`start_server` 會是較好的做法。" -#: ../../library/asyncio-stream.rst:209 +#: ../../library/asyncio-stream.rst:217 msgid "Acknowledge the EOF." msgstr "" -#: ../../library/asyncio-stream.rst:213 +#: ../../library/asyncio-stream.rst:222 msgid "Read up to *n* bytes from the stream." msgstr "從串流中讀取至多 *n* 個位元組的資料。" -#: ../../library/asyncio-stream.rst:215 +#: ../../library/asyncio-stream.rst:224 msgid "" "If *n* is not provided or set to ``-1``, read until EOF, then return all " "read :class:`bytes`. If EOF was received and the internal buffer is empty, " @@ -278,39 +283,39 @@ msgstr "" "的 :class:`bytes`。讀取到 EOF 且內部緩衝區是空的,則回傳一個空的 ``bytes`` 物" "件。" -#: ../../library/asyncio-stream.rst:220 +#: ../../library/asyncio-stream.rst:229 msgid "If *n* is ``0``, return an empty ``bytes`` object immediately." msgstr "如果 *n* 為 ``0``,則立即回傳一個空的 ``bytes`` 物件。" -#: ../../library/asyncio-stream.rst:222 +#: ../../library/asyncio-stream.rst:231 msgid "" "If *n* is positive, return at most *n* available ``bytes`` as soon as at " "least 1 byte is available in the internal buffer. If EOF is received before " "any byte is read, return an empty ``bytes`` object." msgstr "" -#: ../../library/asyncio-stream.rst:229 +#: ../../library/asyncio-stream.rst:239 msgid "" "Read one line, where \"line\" is a sequence of bytes ending with ``\\n``." msgstr "讀取一行,其中\"行\"指的是以 ``\\n`` 結尾的位元組序列。" -#: ../../library/asyncio-stream.rst:232 +#: ../../library/asyncio-stream.rst:242 msgid "" "If EOF is received and ``\\n`` was not found, the method returns partially " "read data." msgstr "如果讀取到 EOF 而沒有找到 ``\\n``,該方法會回傳部分的已讀取資料。" -#: ../../library/asyncio-stream.rst:235 +#: ../../library/asyncio-stream.rst:245 msgid "" "If EOF is received and the internal buffer is empty, return an empty " "``bytes`` object." msgstr "如果讀取到 EOF 且內部緩衝區是空的,則回傳一個空的 ``bytes`` 物件。" -#: ../../library/asyncio-stream.rst:240 +#: ../../library/asyncio-stream.rst:251 msgid "Read exactly *n* bytes." msgstr "讀取剛好 *n* 個位元組。" -#: ../../library/asyncio-stream.rst:242 +#: ../../library/asyncio-stream.rst:253 msgid "" "Raise an :exc:`IncompleteReadError` if EOF is reached before *n* can be " "read. Use the :attr:`IncompleteReadError.partial` attribute to get the " @@ -320,11 +325,11 @@ msgstr "" "`IncompleteReadError`。使用 :attr:`IncompleteReadError.partial` 屬性來獲取串" "流結束前已讀取的部分資料。" -#: ../../library/asyncio-stream.rst:248 +#: ../../library/asyncio-stream.rst:260 msgid "Read data from the stream until *separator* is found." msgstr "從串流中持續讀取資料直到出現 *separator*。" -#: ../../library/asyncio-stream.rst:250 +#: ../../library/asyncio-stream.rst:262 msgid "" "On success, the data and separator will be removed from the internal buffer " "(consumed). Returned data will include the separator at the end." @@ -332,7 +337,7 @@ msgstr "" "成功後,資料和 separator(分隔符號)會從內部緩衝區中刪除(或者說是被消費掉 " "(consumed))。回傳的資料在末尾會有一個 separator。" -#: ../../library/asyncio-stream.rst:254 +#: ../../library/asyncio-stream.rst:266 msgid "" "If the amount of data read exceeds the configured stream limit, a :exc:" "`LimitOverrunError` exception is raised, and the data is left in the " @@ -341,7 +346,7 @@ msgstr "" "如果讀取的資料量超過了設定的串流限制,將會引發 :exc:`LimitOverrunError` 例" "外,資料將被留在內部緩衝區中,並可以再次被讀取。" -#: ../../library/asyncio-stream.rst:258 +#: ../../library/asyncio-stream.rst:270 msgid "" "If EOF is reached before the complete separator is found, an :exc:" "`IncompleteReadError` exception is raised, and the internal buffer is " @@ -352,7 +357,7 @@ msgstr "" "`IncompleteReadError` 例外,且內部緩衝區會被重置。:attr:`IncompleteReadError." "partial` 屬性可能包含一部分的 separator。" -#: ../../library/asyncio-stream.rst:263 +#: ../../library/asyncio-stream.rst:275 msgid "" "The *separator* may also be a tuple of separators. In this case the return " "value will be the shortest possible that has any separator as the suffix. " @@ -360,24 +365,24 @@ msgid "" "separator is considered to be the one that matched." msgstr "" -#: ../../library/asyncio-stream.rst:273 +#: ../../library/asyncio-stream.rst:285 msgid "The *separator* parameter may now be a :class:`tuple` of separators." msgstr "" -#: ../../library/asyncio-stream.rst:278 +#: ../../library/asyncio-stream.rst:290 msgid "Return ``True`` if the buffer is empty and :meth:`feed_eof` was called." msgstr "如果緩衝區是空的且 :meth:`feed_eof` 曾被呼叫則回傳 ``True``。" -#: ../../library/asyncio-stream.rst:283 +#: ../../library/asyncio-stream.rst:295 msgid "StreamWriter" msgstr "StreamWriter" -#: ../../library/asyncio-stream.rst:287 +#: ../../library/asyncio-stream.rst:299 msgid "" "Represents a writer object that provides APIs to write data to the IO stream." msgstr "表示一個有提供 API 來將資料寫入 IO 串流的 writer 物件。" -#: ../../library/asyncio-stream.rst:290 +#: ../../library/asyncio-stream.rst:302 msgid "" "It is not recommended to instantiate *StreamWriter* objects directly; use :" "func:`open_connection` and :func:`start_server` instead." @@ -385,7 +390,7 @@ msgstr "" "不建議直接實例化 *StreamWriter* 物件;使用 :func:`open_connection` 和 :func:" "`start_server` 會是較好的做法。" -#: ../../library/asyncio-stream.rst:296 +#: ../../library/asyncio-stream.rst:308 msgid "" "The method attempts to write the *data* to the underlying socket " "immediately. If that fails, the data is queued in an internal write buffer " @@ -394,11 +399,11 @@ msgstr "" "此方法會嘗試立即將 *data* 寫入到底層的 socket。如果失敗,資料會被放到內部寫入" "緩衝中排隊等待 (queue),直到它可被發送。" -#: ../../library/asyncio-stream.rst:300 ../../library/asyncio-stream.rst:312 +#: ../../library/asyncio-stream.rst:312 ../../library/asyncio-stream.rst:324 msgid "The method should be used along with the ``drain()`` method::" msgstr "此方法應當與 ``drain()`` 方法一起使用: ::" -#: ../../library/asyncio-stream.rst:302 +#: ../../library/asyncio-stream.rst:314 msgid "" "stream.write(data)\n" "await stream.drain()" @@ -406,7 +411,7 @@ msgstr "" "stream.write(data)\n" "await stream.drain()" -#: ../../library/asyncio-stream.rst:307 +#: ../../library/asyncio-stream.rst:319 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 " @@ -415,7 +420,7 @@ msgstr "" "此方法會立即嘗試將一個位元組 list(或任何可疊代物件 (iterable))寫入到底層的 " "socket。如果失敗,資料會被放到內部寫入緩衝中排隊等待,直到它可被發送。" -#: ../../library/asyncio-stream.rst:314 +#: ../../library/asyncio-stream.rst:326 msgid "" "stream.writelines(lines)\n" "await stream.drain()" @@ -423,17 +428,17 @@ msgstr "" "stream.writelines(lines)\n" "await stream.drain()" -#: ../../library/asyncio-stream.rst:319 +#: ../../library/asyncio-stream.rst:331 msgid "The method closes the stream and the underlying socket." msgstr "此方法會關閉串流以及底層的 socket。" -#: ../../library/asyncio-stream.rst:321 +#: ../../library/asyncio-stream.rst:333 msgid "" "The method should be used, though not mandatory, along with the " "``wait_closed()`` method::" msgstr "此方法應與 ``wait_closed()`` 方法一起使用,但並非強制: ::" -#: ../../library/asyncio-stream.rst:324 +#: ../../library/asyncio-stream.rst:336 msgid "" "stream.close()\n" "await stream.wait_closed()" @@ -441,7 +446,7 @@ msgstr "" "stream.close()\n" "await stream.wait_closed()" -#: ../../library/asyncio-stream.rst:329 +#: ../../library/asyncio-stream.rst:341 msgid "" "Return ``True`` if the underlying transport supports the :meth:`write_eof` " "method, ``False`` otherwise." @@ -449,26 +454,26 @@ msgstr "" "如果底層的傳輸支援 :meth:`write_eof` 方法就回傳 ``True``,否則回傳 " "``False``。" -#: ../../library/asyncio-stream.rst:334 +#: ../../library/asyncio-stream.rst:346 msgid "" "Close the write end of the stream after the buffered write data is flushed." msgstr "在已緩衝的寫入資料被清理 (flush) 後關閉串流的寫入端。" -#: ../../library/asyncio-stream.rst:339 +#: ../../library/asyncio-stream.rst:351 msgid "Return the underlying asyncio transport." msgstr "回傳底層的 asyncio 傳輸。" -#: ../../library/asyncio-stream.rst:343 +#: ../../library/asyncio-stream.rst:355 msgid "" "Access optional transport information; see :meth:`BaseTransport." "get_extra_info` for details." msgstr "存取可選的傳輸資訊;詳情請見 :meth:`BaseTransport.get_extra_info`。" -#: ../../library/asyncio-stream.rst:348 +#: ../../library/asyncio-stream.rst:361 msgid "Wait until it is appropriate to resume writing to the stream. Example::" msgstr "等待直到可以繼續寫入到串流。範例: ::" -#: ../../library/asyncio-stream.rst:351 +#: ../../library/asyncio-stream.rst:364 msgid "" "writer.write(data)\n" "await writer.drain()" @@ -476,7 +481,7 @@ msgstr "" "writer.write(data)\n" "await writer.drain()" -#: ../../library/asyncio-stream.rst:354 +#: ../../library/asyncio-stream.rst:367 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()* " @@ -488,48 +493,48 @@ msgstr "" "(high watermark) 時,*drain()* 會阻塞直到緩衝區大小減少至最低標記位 (low " "watermark) 以便繼續寫入。當沒有要等待的資料時,:meth:`drain` 會立即回傳。" -#: ../../library/asyncio-stream.rst:364 +#: ../../library/asyncio-stream.rst:378 msgid "Upgrade an existing stream-based connection to TLS." msgstr "" -#: ../../library/asyncio-stream.rst:366 +#: ../../library/asyncio-stream.rst:380 msgid "Parameters:" msgstr "參數:" -#: ../../library/asyncio-stream.rst:368 +#: ../../library/asyncio-stream.rst:382 msgid "*sslcontext*: a configured instance of :class:`~ssl.SSLContext`." msgstr "" -#: ../../library/asyncio-stream.rst:370 +#: ../../library/asyncio-stream.rst:384 msgid "" "*server_hostname*: sets or overrides the host name that the target server's " "certificate will be matched against." msgstr "" -#: ../../library/asyncio-stream.rst:373 +#: ../../library/asyncio-stream.rst:387 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:377 +#: ../../library/asyncio-stream.rst:391 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:389 +#: ../../library/asyncio-stream.rst:403 msgid "" "Return ``True`` if the stream is closed or in the process of being closed." msgstr "如果串流已被關閉或正在被關閉則回傳 ``True``。" -#: ../../library/asyncio-stream.rst:396 +#: ../../library/asyncio-stream.rst:411 msgid "Wait until the stream is closed." msgstr "等待直到串流被關閉。" -#: ../../library/asyncio-stream.rst:398 +#: ../../library/asyncio-stream.rst:413 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 " @@ -538,19 +543,19 @@ msgstr "" "應當在 :meth:`close` 之後才被呼叫,這會持續等待直到底層的連線被關閉,以確保在" "這之前(例如在程式退出前)所有資料都已經被清空" -#: ../../library/asyncio-stream.rst:406 +#: ../../library/asyncio-stream.rst:421 msgid "Examples" msgstr "範例" -#: ../../library/asyncio-stream.rst:411 +#: ../../library/asyncio-stream.rst:426 msgid "TCP echo client using streams" msgstr "使用串流的 TCP echo 客戶端" -#: ../../library/asyncio-stream.rst:413 +#: ../../library/asyncio-stream.rst:428 msgid "TCP echo client using the :func:`asyncio.open_connection` function::" msgstr "使用 :func:`asyncio.open_connection` 函式的 TCP echo 客戶端: ::" -#: ../../library/asyncio-stream.rst:437 +#: ../../library/asyncio-stream.rst:452 msgid "" "The :ref:`TCP echo client protocol " "` example uses the low-level :meth:" @@ -559,15 +564,15 @@ msgstr "" "使用低階 :meth:`loop.create_connection` 方法的 :ref:`TCP echo 客戶端協定 " "`\\ 範例。" -#: ../../library/asyncio-stream.rst:444 +#: ../../library/asyncio-stream.rst:459 msgid "TCP echo server using streams" msgstr "使用串流的 TCP echo 伺服器" -#: ../../library/asyncio-stream.rst:446 +#: ../../library/asyncio-stream.rst:461 msgid "TCP echo server using the :func:`asyncio.start_server` function::" msgstr "TCP echo 伺服器使用 :func:`asyncio.start_server` 函式: ::" -#: ../../library/asyncio-stream.rst:448 +#: ../../library/asyncio-stream.rst:463 msgid "" "import asyncio\n" "\n" @@ -627,7 +632,7 @@ msgstr "" "\n" "asyncio.run(main())" -#: ../../library/asyncio-stream.rst:480 +#: ../../library/asyncio-stream.rst:495 msgid "" "The :ref:`TCP echo server protocol " "` example uses the :meth:`loop." @@ -636,16 +641,16 @@ msgstr "" "使用 :meth:`loop.create_server` 方法的 :ref:`TCP echo 伺服器協定 " "` 範例。" -#: ../../library/asyncio-stream.rst:485 +#: ../../library/asyncio-stream.rst:500 msgid "Get HTTP headers" msgstr "獲取 HTTP 標頭" -#: ../../library/asyncio-stream.rst:487 +#: ../../library/asyncio-stream.rst:502 msgid "" "Simple example querying HTTP headers of the URL passed on the command line::" msgstr "查詢自命令列傳入之 URL 所帶有 HTTP 標頭的簡單範例: ::" -#: ../../library/asyncio-stream.rst:489 +#: ../../library/asyncio-stream.rst:504 msgid "" "import asyncio\n" "import urllib.parse\n" @@ -684,34 +689,34 @@ msgid "" "asyncio.run(print_http_headers(url))" msgstr "" -#: ../../library/asyncio-stream.rst:526 +#: ../../library/asyncio-stream.rst:541 msgid "Usage::" msgstr "用法: ::" -#: ../../library/asyncio-stream.rst:528 +#: ../../library/asyncio-stream.rst:543 msgid "python example.py http://example.com/path/page.html" msgstr "python example.py http://example.com/path/page.html" -#: ../../library/asyncio-stream.rst:530 +#: ../../library/asyncio-stream.rst:545 msgid "or with HTTPS::" msgstr "或使用 HTTPS: ::" -#: ../../library/asyncio-stream.rst:532 +#: ../../library/asyncio-stream.rst:547 msgid "python example.py https://example.com/path/page.html" msgstr "python example.py https://example.com/path/page.html" -#: ../../library/asyncio-stream.rst:538 +#: ../../library/asyncio-stream.rst:553 msgid "Register an open socket to wait for data using streams" msgstr "註冊一個使用串流來等待資料的開放 socket" -#: ../../library/asyncio-stream.rst:540 +#: ../../library/asyncio-stream.rst:555 msgid "" "Coroutine waiting until a socket receives data using the :func:" "`open_connection` function::" msgstr "" "等待直到 socket 透過使用 :func:`open_connection` 函式接收到資料的協程: ::" -#: ../../library/asyncio-stream.rst:543 +#: ../../library/asyncio-stream.rst:558 msgid "" "import asyncio\n" "import socket\n" @@ -744,7 +749,7 @@ msgid "" "asyncio.run(wait_for_data())" msgstr "" -#: ../../library/asyncio-stream.rst:575 +#: ../../library/asyncio-stream.rst:590 msgid "" "The :ref:`register an open socket to wait for data using a protocol " "` example uses a low-level protocol and " @@ -754,7 +759,7 @@ msgstr "" "`\\ 範例中,有使用了低階協定以及 :meth:" "`loop.create_connection` 方法。" -#: ../../library/asyncio-stream.rst:579 +#: ../../library/asyncio-stream.rst:594 msgid "" "The :ref:`watch a file descriptor for read events " "` example uses the low-level :meth:`loop." @@ -762,3 +767,6 @@ msgid "" msgstr "" "在\\ :ref:`監視檔案描述器以讀取事件 `\\ 範例中,有" "使用低階的 :meth:`loop.add_reader` 方法來監視檔案描述器。" + +#~ msgid ":ref:`Availability `: Unix." +#~ msgstr ":ref:`適用 `:Unix。" diff --git a/library/asyncio-subprocess.po b/library/asyncio-subprocess.po index a3ffe6d7bf..6837ced289 100644 --- a/library/asyncio-subprocess.po +++ b/library/asyncio-subprocess.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-04-24 05:56+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-" @@ -127,43 +127,44 @@ msgstr "另請參閱\\ `Examples`_。" msgid "Creating Subprocesses" msgstr "建立子行程" -#: ../../library/asyncio-subprocess.rst:67 +#: ../../library/asyncio-subprocess.rst:68 msgid "Create a subprocess." msgstr "" -#: ../../library/asyncio-subprocess.rst:69 -#: ../../library/asyncio-subprocess.rst:87 +#: ../../library/asyncio-subprocess.rst:70 +#: ../../library/asyncio-subprocess.rst:89 msgid "" "The *limit* argument sets the buffer limit for :class:`StreamReader` " -"wrappers for :attr:`Process.stdout` and :attr:`Process.stderr` (if :const:" -"`subprocess.PIPE` is passed to *stdout* and *stderr* arguments)." +"wrappers for :attr:`~asyncio.subprocess.Process.stdout` and :attr:`~asyncio." +"subprocess.Process.stderr` (if :const:`subprocess.PIPE` is passed to " +"*stdout* and *stderr* arguments)." msgstr "" -#: ../../library/asyncio-subprocess.rst:73 -#: ../../library/asyncio-subprocess.rst:91 +#: ../../library/asyncio-subprocess.rst:74 +#: ../../library/asyncio-subprocess.rst:93 msgid "Return a :class:`~asyncio.subprocess.Process` instance." msgstr "" -#: ../../library/asyncio-subprocess.rst:75 +#: ../../library/asyncio-subprocess.rst:76 msgid "" "See the documentation of :meth:`loop.subprocess_exec` for other parameters." msgstr "" -#: ../../library/asyncio-subprocess.rst:78 -#: ../../library/asyncio-subprocess.rst:105 +#: ../../library/asyncio-subprocess.rst:79 +#: ../../library/asyncio-subprocess.rst:107 msgid "Removed the *loop* parameter." msgstr "" -#: ../../library/asyncio-subprocess.rst:85 +#: ../../library/asyncio-subprocess.rst:87 msgid "Run the *cmd* shell command." msgstr "" -#: ../../library/asyncio-subprocess.rst:93 +#: ../../library/asyncio-subprocess.rst:95 msgid "" "See the documentation of :meth:`loop.subprocess_shell` for other parameters." msgstr "" -#: ../../library/asyncio-subprocess.rst:98 +#: ../../library/asyncio-subprocess.rst:100 msgid "" "It is the application's responsibility to ensure that all whitespace and " "special characters are quoted appropriately to avoid `shell injection " @@ -173,14 +174,14 @@ msgid "" "be used to construct shell commands." msgstr "" -#: ../../library/asyncio-subprocess.rst:110 +#: ../../library/asyncio-subprocess.rst:112 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:116 +#: ../../library/asyncio-subprocess.rst:118 msgid "" "asyncio also has the following *low-level* APIs to work with subprocesses: :" "meth:`loop.subprocess_exec`, :meth:`loop.subprocess_shell`, :meth:`loop." @@ -189,47 +190,47 @@ msgid "" "Protocols `." msgstr "" -#: ../../library/asyncio-subprocess.rst:124 +#: ../../library/asyncio-subprocess.rst:126 msgid "Constants" msgstr "常數" -#: ../../library/asyncio-subprocess.rst:129 +#: ../../library/asyncio-subprocess.rst:131 msgid "Can be passed to the *stdin*, *stdout* or *stderr* parameters." msgstr "" -#: ../../library/asyncio-subprocess.rst:131 +#: ../../library/asyncio-subprocess.rst:133 msgid "" "If *PIPE* is passed to *stdin* argument, the :attr:`Process.stdin ` attribute will point to a :class:`StreamWriter` " -"instance." +"subprocess.Process.stdin>` attribute will point to a :class:`~asyncio." +"StreamWriter` instance." msgstr "" -#: ../../library/asyncio-subprocess.rst:135 +#: ../../library/asyncio-subprocess.rst:137 msgid "" "If *PIPE* is passed to *stdout* or *stderr* arguments, the :attr:`Process." "stdout ` and :attr:`Process.stderr " "` attributes will point to :class:" -"`StreamReader` instances." +"`~asyncio.StreamReader` instances." msgstr "" -#: ../../library/asyncio-subprocess.rst:143 +#: ../../library/asyncio-subprocess.rst:145 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:149 +#: ../../library/asyncio-subprocess.rst:151 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:155 +#: ../../library/asyncio-subprocess.rst:157 msgid "Interacting with Subprocesses" msgstr "" -#: ../../library/asyncio-subprocess.rst:157 +#: ../../library/asyncio-subprocess.rst:159 msgid "" "Both :func:`create_subprocess_exec` and :func:`create_subprocess_shell` " "functions return instances of the *Process* class. *Process* is a high-" @@ -237,61 +238,62 @@ msgid "" "their completion." msgstr "" -#: ../../library/asyncio-subprocess.rst:165 +#: ../../library/asyncio-subprocess.rst:167 msgid "" -"An object that wraps OS processes created by the :func:" -"`create_subprocess_exec` and :func:`create_subprocess_shell` functions." +"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:169 +#: ../../library/asyncio-subprocess.rst:171 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:173 +#: ../../library/asyncio-subprocess.rst:175 msgid "" "unlike Popen, Process instances do not have an equivalent to the :meth:" "`~subprocess.Popen.poll` method;" msgstr "" -#: ../../library/asyncio-subprocess.rst:176 +#: ../../library/asyncio-subprocess.rst:178 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:180 +#: ../../library/asyncio-subprocess.rst:182 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:184 +#: ../../library/asyncio-subprocess.rst:186 msgid "the *universal_newlines* parameter is not supported." msgstr "" -#: ../../library/asyncio-subprocess.rst:186 +#: ../../library/asyncio-subprocess.rst:188 msgid "This class is :ref:`not thread safe `." msgstr "" -#: ../../library/asyncio-subprocess.rst:188 +#: ../../library/asyncio-subprocess.rst:190 msgid "" "See also the :ref:`Subprocess and Threads ` " "section." msgstr "" -#: ../../library/asyncio-subprocess.rst:193 +#: ../../library/asyncio-subprocess.rst:196 msgid "Wait for the child process to terminate." msgstr "" -#: ../../library/asyncio-subprocess.rst:195 +#: ../../library/asyncio-subprocess.rst:198 msgid "Set and return the :attr:`returncode` attribute." msgstr "" -#: ../../library/asyncio-subprocess.rst:199 +#: ../../library/asyncio-subprocess.rst:202 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 " @@ -299,37 +301,37 @@ msgid "" "using pipes to avoid this condition." msgstr "" -#: ../../library/asyncio-subprocess.rst:207 +#: ../../library/asyncio-subprocess.rst:211 msgid "Interact with process:" msgstr "" -#: ../../library/asyncio-subprocess.rst:209 +#: ../../library/asyncio-subprocess.rst:213 msgid "send data to *stdin* (if *input* is not ``None``);" msgstr "" -#: ../../library/asyncio-subprocess.rst:210 +#: ../../library/asyncio-subprocess.rst:214 msgid "closes *stdin*;" msgstr "" -#: ../../library/asyncio-subprocess.rst:211 +#: ../../library/asyncio-subprocess.rst:215 msgid "read data from *stdout* and *stderr*, until EOF is reached;" msgstr "" -#: ../../library/asyncio-subprocess.rst:212 +#: ../../library/asyncio-subprocess.rst:216 msgid "wait for process to terminate." msgstr "" -#: ../../library/asyncio-subprocess.rst:214 +#: ../../library/asyncio-subprocess.rst:218 msgid "" "The optional *input* argument is the data (:class:`bytes` object) that will " "be sent to the child process." msgstr "" -#: ../../library/asyncio-subprocess.rst:217 +#: ../../library/asyncio-subprocess.rst:221 msgid "Return a tuple ``(stdout_data, stderr_data)``." msgstr "" -#: ../../library/asyncio-subprocess.rst:219 +#: ../../library/asyncio-subprocess.rst:223 msgid "" "If either :exc:`BrokenPipeError` or :exc:`ConnectionResetError` exception is " "raised when writing *input* into *stdin*, the exception is ignored. This " @@ -337,7 +339,7 @@ msgid "" "*stdin*." msgstr "" -#: ../../library/asyncio-subprocess.rst:224 +#: ../../library/asyncio-subprocess.rst:228 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 " @@ -345,75 +347,76 @@ msgid "" "``stdout=PIPE`` and/or ``stderr=PIPE`` arguments." msgstr "" -#: ../../library/asyncio-subprocess.rst:230 +#: ../../library/asyncio-subprocess.rst:234 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:235 -msgid "*stdin* gets closed when `input=None` too." +#: ../../library/asyncio-subprocess.rst:239 +msgid "*stdin* gets closed when ``input=None`` too." msgstr "" -#: ../../library/asyncio-subprocess.rst:239 +#: ../../library/asyncio-subprocess.rst:243 msgid "Sends the signal *signal* to the child process." msgstr "" -#: ../../library/asyncio-subprocess.rst:243 +#: ../../library/asyncio-subprocess.rst:247 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:250 +#: ../../library/asyncio-subprocess.rst:254 msgid "Stop the child process." msgstr "" -#: ../../library/asyncio-subprocess.rst:252 +#: ../../library/asyncio-subprocess.rst:256 msgid "" "On POSIX systems this method sends :py:const:`~signal.SIGTERM` to the child " "process." msgstr "" -#: ../../library/asyncio-subprocess.rst:255 +#: ../../library/asyncio-subprocess.rst:259 msgid "" "On Windows the Win32 API function :c:func:`!TerminateProcess` is called to " "stop the child process." msgstr "" -#: ../../library/asyncio-subprocess.rst:260 +#: ../../library/asyncio-subprocess.rst:264 msgid "Kill the child process." msgstr "" -#: ../../library/asyncio-subprocess.rst:262 +#: ../../library/asyncio-subprocess.rst:266 msgid "" -"On POSIX systems this method sends :py:data:`SIGKILL` to the child process." +"On POSIX systems this method sends :py:data:`~signal.SIGKILL` to the child " +"process." msgstr "" -#: ../../library/asyncio-subprocess.rst:265 +#: ../../library/asyncio-subprocess.rst:269 msgid "On Windows this method is an alias for :meth:`terminate`." msgstr "" -#: ../../library/asyncio-subprocess.rst:269 +#: ../../library/asyncio-subprocess.rst:273 msgid "" -"Standard input stream (:class:`StreamWriter`) or ``None`` if the process was " -"created with ``stdin=None``." +"Standard input stream (:class:`~asyncio.StreamWriter`) or ``None`` if the " +"process was created with ``stdin=None``." msgstr "" -#: ../../library/asyncio-subprocess.rst:274 +#: ../../library/asyncio-subprocess.rst:278 msgid "" -"Standard output stream (:class:`StreamReader`) or ``None`` if the process " -"was created with ``stdout=None``." +"Standard output stream (:class:`~asyncio.StreamReader`) or ``None`` if the " +"process was created with ``stdout=None``." msgstr "" -#: ../../library/asyncio-subprocess.rst:279 +#: ../../library/asyncio-subprocess.rst:283 msgid "" -"Standard error stream (:class:`StreamReader`) or ``None`` if the process was " -"created with ``stderr=None``." +"Standard error stream (:class:`~asyncio.StreamReader`) or ``None`` if the " +"process was created with ``stderr=None``." msgstr "" -#: ../../library/asyncio-subprocess.rst:284 +#: ../../library/asyncio-subprocess.rst:288 msgid "" "Use the :meth:`communicate` method rather than :attr:`process.stdin.write() " "`, :attr:`await process.stdout.read() ` or :attr:`await " @@ -421,93 +424,94 @@ msgid "" "pausing reading or writing and blocking the child process." msgstr "" -#: ../../library/asyncio-subprocess.rst:293 +#: ../../library/asyncio-subprocess.rst:297 msgid "Process identification number (PID)." msgstr "" -#: ../../library/asyncio-subprocess.rst:295 +#: ../../library/asyncio-subprocess.rst:299 msgid "" -"Note that for processes created by the :func:`create_subprocess_shell` " -"function, this attribute is the PID of the spawned shell." +"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:300 +#: ../../library/asyncio-subprocess.rst:304 msgid "Return code of the process when it exits." msgstr "" -#: ../../library/asyncio-subprocess.rst:302 +#: ../../library/asyncio-subprocess.rst:306 msgid "A ``None`` value indicates that the process has not terminated yet." msgstr "" -#: ../../library/asyncio-subprocess.rst:304 +#: ../../library/asyncio-subprocess.rst:308 msgid "" "A negative value ``-N`` indicates that the child was terminated by signal " "``N`` (POSIX only)." msgstr "" -#: ../../library/asyncio-subprocess.rst:311 +#: ../../library/asyncio-subprocess.rst:315 msgid "Subprocess and Threads" msgstr "子行程與線程" -#: ../../library/asyncio-subprocess.rst:313 +#: ../../library/asyncio-subprocess.rst:317 msgid "" "Standard asyncio event loop supports running subprocesses from different " "threads by default." msgstr "" -#: ../../library/asyncio-subprocess.rst:316 +#: ../../library/asyncio-subprocess.rst:320 msgid "" "On Windows subprocesses are provided by :class:`ProactorEventLoop` only " "(default), :class:`SelectorEventLoop` has no subprocess support." msgstr "" -#: ../../library/asyncio-subprocess.rst:319 +#: ../../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:325 +#: ../../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:328 +#: ../../library/asyncio-subprocess.rst:332 msgid "" "Spawning a subprocess with *inactive* current child watcher raises :exc:" "`RuntimeError`." msgstr "" -#: ../../library/asyncio-subprocess.rst:331 +#: ../../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:336 +#: ../../library/asyncio-subprocess.rst:340 msgid "" "The :ref:`Concurrency and multithreading in asyncio ` section." msgstr "" -#: ../../library/asyncio-subprocess.rst:341 +#: ../../library/asyncio-subprocess.rst:345 msgid "Examples" msgstr "範例" -#: ../../library/asyncio-subprocess.rst:343 +#: ../../library/asyncio-subprocess.rst:347 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:349 +#: ../../library/asyncio-subprocess.rst:353 msgid "" "The subprocess is created by the :func:`create_subprocess_exec` function::" msgstr "" -#: ../../library/asyncio-subprocess.rst:352 +#: ../../library/asyncio-subprocess.rst:356 msgid "" "import asyncio\n" "import sys\n" @@ -533,7 +537,7 @@ msgid "" "print(f\"Current date: {date}\")" msgstr "" -#: ../../library/asyncio-subprocess.rst:376 +#: ../../library/asyncio-subprocess.rst:380 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 ffee4a801a..e44a92a114 100644 --- a/library/asyncio-sync.po +++ b/library/asyncio-sync.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-03-03 18:39+0000\n" "PO-Revision-Date: 2022-02-09 19:27+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -108,8 +108,8 @@ msgid "" " # access shared state" msgstr "" -#: ../../library/asyncio-sync.rst:56 ../../library/asyncio-sync.rst:199 -#: ../../library/asyncio-sync.rst:304 +#: ../../library/asyncio-sync.rst:56 ../../library/asyncio-sync.rst:201 +#: ../../library/asyncio-sync.rst:309 msgid "which is equivalent to::" msgstr "這等價於: ::" @@ -125,17 +125,17 @@ msgid "" " lock.release()" msgstr "" -#: ../../library/asyncio-sync.rst:67 ../../library/asyncio-sync.rst:112 -#: ../../library/asyncio-sync.rst:187 ../../library/asyncio-sync.rst:292 -#: ../../library/asyncio-sync.rst:347 +#: ../../library/asyncio-sync.rst:67 ../../library/asyncio-sync.rst:113 +#: ../../library/asyncio-sync.rst:189 ../../library/asyncio-sync.rst:297 +#: ../../library/asyncio-sync.rst:353 msgid "Removed the *loop* parameter." msgstr "移除 ``loop`` 參數。" -#: ../../library/asyncio-sync.rst:72 +#: ../../library/asyncio-sync.rst:73 msgid "Acquire the lock." msgstr "獲得鎖。" -#: ../../library/asyncio-sync.rst:74 +#: ../../library/asyncio-sync.rst:75 msgid "" "This method waits until the lock is *unlocked*, sets it to *locked* and " "returns ``True``." @@ -143,7 +143,7 @@ msgstr "" "此方法會持續等待直到鎖的狀態成為 *unlocked*,並將其設置為 *locked* 和回傳 " "``True``。" -#: ../../library/asyncio-sync.rst:77 +#: ../../library/asyncio-sync.rst:78 msgid "" "When more than one coroutine is blocked in :meth:`acquire` waiting for the " "lock to be unlocked, only one coroutine eventually proceeds." @@ -151,45 +151,45 @@ msgstr "" "當多於一個的協程 (coroutine) 在 :meth:`acquire` 中等待解鎖而被阻塞,最終只會" "有其中的一個被處理。" -#: ../../library/asyncio-sync.rst:81 +#: ../../library/asyncio-sync.rst:82 msgid "" "Acquiring a lock is *fair*: the coroutine that proceeds will be the first " "coroutine that started waiting on the lock." msgstr "" "鎖的獲取方式是\\ *公平*\\ 的:被處理的協程會是最早開始等待解鎖的那一個。" -#: ../../library/asyncio-sync.rst:86 +#: ../../library/asyncio-sync.rst:87 msgid "Release the lock." msgstr "釋放鎖。" -#: ../../library/asyncio-sync.rst:88 +#: ../../library/asyncio-sync.rst:89 msgid "When the lock is *locked*, reset it to *unlocked* and return." msgstr "如果鎖的狀態為 *locked* 則將其重置為 *unlocked* 並回傳。" -#: ../../library/asyncio-sync.rst:90 +#: ../../library/asyncio-sync.rst:91 msgid "If the lock is *unlocked*, a :exc:`RuntimeError` is raised." msgstr "如果鎖的狀態為 *unlocked* 則 :exc:`RuntimeError` 會被引發。" -#: ../../library/asyncio-sync.rst:94 +#: ../../library/asyncio-sync.rst:95 msgid "Return ``True`` if the lock is *locked*." msgstr "如果鎖的狀態為 *locked* 則回傳 ``True``。" -#: ../../library/asyncio-sync.rst:98 +#: ../../library/asyncio-sync.rst:99 msgid "Event" msgstr "Event" -#: ../../library/asyncio-sync.rst:102 +#: ../../library/asyncio-sync.rst:103 msgid "An event object. Not thread-safe." msgstr "一個事件 (event) 物件。不支援執行緒安全。" -#: ../../library/asyncio-sync.rst:104 +#: ../../library/asyncio-sync.rst:105 msgid "" "An asyncio event can be used to notify multiple asyncio tasks that some " "event has happened." msgstr "" "一個 asyncio 事件可以被用於通知多個有發生某些事件於其中的 asyncio 任務。" -#: ../../library/asyncio-sync.rst:107 +#: ../../library/asyncio-sync.rst:108 msgid "" "An Event object manages an internal flag that can be set to *true* with the :" "meth:`~Event.set` method and reset to *false* with the :meth:`clear` " @@ -201,11 +201,11 @@ msgstr "" "wait` 方法會被阻塞 (block) 直到該旗標被設為 *true*。該旗標初始設置為 " "*false*。" -#: ../../library/asyncio-sync.rst:117 ../../library/asyncio-sync.rst:371 +#: ../../library/asyncio-sync.rst:118 ../../library/asyncio-sync.rst:377 msgid "Example::" msgstr "範例: ::" -#: ../../library/asyncio-sync.rst:119 +#: ../../library/asyncio-sync.rst:120 msgid "" "async def waiter(event):\n" " print('waiting for it ...')\n" @@ -229,11 +229,11 @@ msgid "" "asyncio.run(main())" msgstr "" -#: ../../library/asyncio-sync.rst:142 +#: ../../library/asyncio-sync.rst:144 msgid "Wait until the event is set." msgstr "持續等待直到事件被設置。" -#: ../../library/asyncio-sync.rst:144 +#: ../../library/asyncio-sync.rst:146 msgid "" "If the event is set, return ``True`` immediately. Otherwise block until " "another task calls :meth:`~Event.set`." @@ -241,19 +241,19 @@ msgstr "" "如果事件有被設置則立刻回傳 ``True``。否則持續阻塞直到另一個任務呼叫 :meth:" "`~Event.set`。" -#: ../../library/asyncio-sync.rst:149 +#: ../../library/asyncio-sync.rst:151 msgid "Set the event." msgstr "設置事件。" -#: ../../library/asyncio-sync.rst:151 +#: ../../library/asyncio-sync.rst:153 msgid "All tasks waiting for event to be set will be immediately awakened." msgstr "所有正在等待事件被設置的任務會立即被喚醒。" -#: ../../library/asyncio-sync.rst:156 +#: ../../library/asyncio-sync.rst:158 msgid "Clear (unset) the event." msgstr "清除(還原)事件。" -#: ../../library/asyncio-sync.rst:158 +#: ../../library/asyncio-sync.rst:160 msgid "" "Tasks awaiting on :meth:`~Event.wait` will now block until the :meth:`~Event." "set` method is called again." @@ -261,19 +261,19 @@ msgstr "" "正透過 :meth:`~Event.wait` 等待的 Tasks 現在會持續阻塞直到 :meth:`~Event." "set` 方法再次被呼叫。" -#: ../../library/asyncio-sync.rst:163 +#: ../../library/asyncio-sync.rst:165 msgid "Return ``True`` if the event is set." msgstr "如果事件有被設置則回傳 ``True``。" -#: ../../library/asyncio-sync.rst:167 +#: ../../library/asyncio-sync.rst:169 msgid "Condition" msgstr "Condition" -#: ../../library/asyncio-sync.rst:171 +#: ../../library/asyncio-sync.rst:173 msgid "A Condition object. Not thread-safe." msgstr "一個條件 (codition) 物件。不支援執行緒安全。" -#: ../../library/asyncio-sync.rst:173 +#: ../../library/asyncio-sync.rst:175 msgid "" "An asyncio condition primitive can be used by a task to wait for some event " "to happen and then get exclusive access to a shared resource." @@ -281,7 +281,7 @@ msgstr "" "一個 asyncio 條件原始物件可以被任務用來等待某事件發生,並獲得一個共享資源的獨" "佔存取權。" -#: ../../library/asyncio-sync.rst:177 +#: ../../library/asyncio-sync.rst:179 msgid "" "In essence, a Condition object combines the functionality of an :class:" "`Event` and a :class:`Lock`. It is possible to have multiple Condition " @@ -293,7 +293,7 @@ msgstr "" "個 Condition 物件共享一個 Lock 是有可能發生的,這能夠協調關注同一共享資源的不" "同狀態以獲取其獨佔存取權的多個任務。" -#: ../../library/asyncio-sync.rst:183 +#: ../../library/asyncio-sync.rst:185 msgid "" "The optional *lock* argument must be a :class:`Lock` object or ``None``. In " "the latter case a new Lock object is created automatically." @@ -301,12 +301,12 @@ msgstr "" "可選的 *lock* 引數必須是一個 :class:`Lock` 物件或者為 ``None``。如為後者則一" "個新的 Lock 物件會被自動建立。" -#: ../../library/asyncio-sync.rst:190 +#: ../../library/asyncio-sync.rst:192 msgid "" "The preferred way to use a Condition is an :keyword:`async with` statement::" msgstr "使用 Condition 的推薦方式是透過 :keyword:`async with` 陳述式: ::" -#: ../../library/asyncio-sync.rst:193 +#: ../../library/asyncio-sync.rst:195 msgid "" "cond = asyncio.Condition()\n" "\n" @@ -315,7 +315,7 @@ msgid "" " await cond.wait()" msgstr "" -#: ../../library/asyncio-sync.rst:201 +#: ../../library/asyncio-sync.rst:203 msgid "" "cond = asyncio.Condition()\n" "\n" @@ -327,11 +327,11 @@ msgid "" " cond.release()" msgstr "" -#: ../../library/asyncio-sync.rst:212 +#: ../../library/asyncio-sync.rst:215 msgid "Acquire the underlying lock." msgstr "獲取底層的鎖。" -#: ../../library/asyncio-sync.rst:214 +#: ../../library/asyncio-sync.rst:217 msgid "" "This method waits until the underlying lock is *unlocked*, sets it to " "*locked* and returns ``True``." @@ -339,7 +339,7 @@ msgstr "" "此方法會持續等待直到底層的鎖為 *unlocked*,並將其設為 *locked* 並回傳 " "``True``。" -#: ../../library/asyncio-sync.rst:219 +#: ../../library/asyncio-sync.rst:222 #, fuzzy msgid "" "Wake up *n* tasks (1 by default) waiting on this condition. If fewer than " @@ -348,7 +348,7 @@ msgstr "" "喚醒至多 *n* 個正在等待此條件的任務(預設為 1),如果沒有正在等待的任務則此方" "法為空操作 (no-op)。" -#: ../../library/asyncio-sync.rst:222 ../../library/asyncio-sync.rst:237 +#: ../../library/asyncio-sync.rst:225 ../../library/asyncio-sync.rst:240 msgid "" "The lock must be acquired before this method is called and released shortly " "after. If called with an *unlocked* lock a :exc:`RuntimeError` error is " @@ -357,31 +357,31 @@ msgstr "" "在此方法被呼叫前必須先獲得鎖,並在之後立刻將其釋放。如果呼叫於一個 " "*unlocked* 的鎖則 :exc:`RuntimeError` 錯誤會被引發。" -#: ../../library/asyncio-sync.rst:228 +#: ../../library/asyncio-sync.rst:231 msgid "Return ``True`` if the underlying lock is acquired." msgstr "如果已獲取底層的鎖則回傳 ``True``。" -#: ../../library/asyncio-sync.rst:232 +#: ../../library/asyncio-sync.rst:235 msgid "Wake up all tasks waiting on this condition." msgstr "喚醒所有正在等待此條件的任務。" -#: ../../library/asyncio-sync.rst:234 +#: ../../library/asyncio-sync.rst:237 msgid "This method acts like :meth:`notify`, but wakes up all waiting tasks." msgstr "這個方法的行為就像 :meth:`notify`,但會喚醒所有正在等待的任務。" -#: ../../library/asyncio-sync.rst:243 +#: ../../library/asyncio-sync.rst:246 msgid "Release the underlying lock." msgstr "釋放底層的鎖。" -#: ../../library/asyncio-sync.rst:245 +#: ../../library/asyncio-sync.rst:248 msgid "When invoked on an unlocked lock, a :exc:`RuntimeError` is raised." msgstr "當調用於一個未被解開的鎖之上時,會引發一個 :exc:`RuntimeError`。" -#: ../../library/asyncio-sync.rst:250 +#: ../../library/asyncio-sync.rst:254 msgid "Wait until notified." msgstr "持續等待直到被通知 (notify)。" -#: ../../library/asyncio-sync.rst:252 +#: ../../library/asyncio-sync.rst:256 msgid "" "If the calling task has not acquired the lock when this method is called, a :" "exc:`RuntimeError` is raised." @@ -389,7 +389,7 @@ msgstr "" "當此方法被呼叫時,如果呼叫它的任務還沒有獲取鎖的話,:exc:`RuntimeError` 會被" "引發。" -#: ../../library/asyncio-sync.rst:255 +#: ../../library/asyncio-sync.rst:259 msgid "" "This method releases the underlying lock, and then blocks until it is " "awakened by a :meth:`notify` or :meth:`notify_all` call. Once awakened, the " @@ -399,36 +399,37 @@ msgstr "" "`notify_all` 的呼叫所喚醒。一但被喚醒,Condition 會重新獲取該鎖且此方法會回" "傳 ``True``。" -#: ../../library/asyncio-sync.rst:260 +#: ../../library/asyncio-sync.rst:264 msgid "" "Note that a task *may* return from this call spuriously, which is why the " -"caller should always re-check the state and be prepared to :meth:`wait` " -"again. For this reason, you may prefer to use :meth:`wait_for` instead." +"caller should always re-check the state and be prepared to :meth:`~Condition." +"wait` again. For this reason, you may prefer to use :meth:`~Condition." +"wait_for` instead." msgstr "" -#: ../../library/asyncio-sync.rst:267 +#: ../../library/asyncio-sync.rst:272 msgid "Wait until a predicate becomes *true*." msgstr "持續等待直到謂語 (predicate) 成為 *true*。" -#: ../../library/asyncio-sync.rst:269 +#: ../../library/asyncio-sync.rst:274 #, fuzzy msgid "" "The predicate must be a callable which result will be interpreted as a " -"boolean value. The method will repeatedly :meth:`wait` until the predicate " -"evaluates to *true*. The final value is the return value." +"boolean value. The method will repeatedly :meth:`~Condition.wait` until the " +"predicate evaluates to *true*. The final value is the return value." msgstr "" "謂語必須是一個結果可被直譯為一個 boolean 值的可呼叫物件 (callable)。最終值為" "回傳值。" -#: ../../library/asyncio-sync.rst:276 +#: ../../library/asyncio-sync.rst:281 msgid "Semaphore" msgstr "Semaphore" -#: ../../library/asyncio-sync.rst:280 +#: ../../library/asyncio-sync.rst:285 msgid "A Semaphore object. Not thread-safe." msgstr "一個旗號 (semaphore) 物件。不支援執行緒安全。" -#: ../../library/asyncio-sync.rst:282 +#: ../../library/asyncio-sync.rst:287 msgid "" "A semaphore manages an internal counter which is decremented by each :meth:" "`acquire` call and incremented by each :meth:`release` call. The counter can " @@ -439,7 +440,7 @@ msgstr "" "呼叫 :meth:`release` 時增加一。此計數器永遠不會少於零;當 :meth:`acquire` 發" "現它是零時,它會持續阻塞並等待某任務呼叫 :meth:`release`。" -#: ../../library/asyncio-sync.rst:288 +#: ../../library/asyncio-sync.rst:293 msgid "" "The optional *value* argument gives the initial value for the internal " "counter (``1`` by default). If the given value is less than ``0`` a :exc:" @@ -448,12 +449,12 @@ msgstr "" "可選的 *value* 引數給定了內部計數器的初始值(預設為 ``1``\\ )。如給定的值少" "於 ``0`` 則 :exc:`ValueError` 會被引發。" -#: ../../library/asyncio-sync.rst:295 +#: ../../library/asyncio-sync.rst:300 msgid "" "The preferred way to use a Semaphore is an :keyword:`async with` statement::" msgstr "使用 Semaphore 的推薦方式是透過 :keyword:`async with` 陳述式: ::" -#: ../../library/asyncio-sync.rst:298 +#: ../../library/asyncio-sync.rst:303 msgid "" "sem = asyncio.Semaphore(10)\n" "\n" @@ -462,7 +463,7 @@ msgid "" " # work with shared resource" msgstr "" -#: ../../library/asyncio-sync.rst:306 +#: ../../library/asyncio-sync.rst:311 msgid "" "sem = asyncio.Semaphore(10)\n" "\n" @@ -474,11 +475,11 @@ msgid "" " sem.release()" msgstr "" -#: ../../library/asyncio-sync.rst:317 +#: ../../library/asyncio-sync.rst:323 msgid "Acquire a semaphore." msgstr "獲取一個旗號。" -#: ../../library/asyncio-sync.rst:319 +#: ../../library/asyncio-sync.rst:325 msgid "" "If the internal counter is greater than zero, decrement it by one and return " "``True`` immediately. If it is zero, wait until a :meth:`release` is called " @@ -487,11 +488,11 @@ msgstr "" "如果內部計數器大於零,將其減一並立刻回傳 ``True``。如果為零,則持續等待直到 :" "meth:`release` 被呼叫,並回傳 ``True``。" -#: ../../library/asyncio-sync.rst:325 +#: ../../library/asyncio-sync.rst:331 msgid "Returns ``True`` if semaphore can not be acquired immediately." msgstr "如果旗號無法立即被取得則回傳 ``True``。" -#: ../../library/asyncio-sync.rst:329 +#: ../../library/asyncio-sync.rst:335 msgid "" "Release a semaphore, incrementing the internal counter by one. Can wake up a " "task waiting to acquire the semaphore." @@ -499,7 +500,7 @@ msgstr "" "釋放一個旗號,並為其內部的計數器數值增加一。可以把一個正在等待獲取旗號的任務" "叫醒。" -#: ../../library/asyncio-sync.rst:332 +#: ../../library/asyncio-sync.rst:338 msgid "" "Unlike :class:`BoundedSemaphore`, :class:`Semaphore` allows making more " "``release()`` calls than ``acquire()`` calls." @@ -507,15 +508,15 @@ msgstr "" "和 :class:`BoundedSemaphore` 不同,:class:`Semaphore` 允許 ``release()`` 的呼" "叫次數多於 ``acquire()``。" -#: ../../library/asyncio-sync.rst:337 +#: ../../library/asyncio-sync.rst:343 msgid "BoundedSemaphore" msgstr "BoundedSemaphore" -#: ../../library/asyncio-sync.rst:341 +#: ../../library/asyncio-sync.rst:347 msgid "A bounded semaphore object. Not thread-safe." msgstr "一個有界的旗號物件。不支援執行緒安全。" -#: ../../library/asyncio-sync.rst:343 +#: ../../library/asyncio-sync.rst:349 msgid "" "Bounded Semaphore is a version of :class:`Semaphore` that raises a :exc:" "`ValueError` in :meth:`~Semaphore.release` if it increases the internal " @@ -525,15 +526,15 @@ msgstr "" "加至大於初始 *value* 值的話,:exc:`ValueError` 會在 :meth:`~Semaphore." "release` 時被引發。" -#: ../../library/asyncio-sync.rst:352 +#: ../../library/asyncio-sync.rst:358 msgid "Barrier" msgstr "Barrier" -#: ../../library/asyncio-sync.rst:356 +#: ../../library/asyncio-sync.rst:362 msgid "A barrier object. Not thread-safe." msgstr "一個屏障 (barrier) 物件。不支援執行緒安全。" -#: ../../library/asyncio-sync.rst:358 +#: ../../library/asyncio-sync.rst:364 msgid "" "A barrier is a simple synchronization primitive that allows to block until " "*parties* number of tasks are waiting on it. Tasks can wait on the :meth:" @@ -542,17 +543,17 @@ msgid "" "waiting tasks would unblock simultaneously." msgstr "" -#: ../../library/asyncio-sync.rst:364 +#: ../../library/asyncio-sync.rst:370 msgid "" ":keyword:`async with` can be used as an alternative to awaiting on :meth:" "`~Barrier.wait`." msgstr "" -#: ../../library/asyncio-sync.rst:367 +#: ../../library/asyncio-sync.rst:373 msgid "The barrier can be reused any number of times." msgstr "" -#: ../../library/asyncio-sync.rst:373 +#: ../../library/asyncio-sync.rst:379 msgid "" "async def example_barrier():\n" " # barrier with 3 parties\n" @@ -576,11 +577,11 @@ msgid "" "asyncio.run(example_barrier())" msgstr "" -#: ../../library/asyncio-sync.rst:394 +#: ../../library/asyncio-sync.rst:400 msgid "Result of this example is::" msgstr "" -#: ../../library/asyncio-sync.rst:396 +#: ../../library/asyncio-sync.rst:402 msgid "" "\n" "\n" @@ -592,27 +593,27 @@ msgstr "" "barrier passed\n" "" -#: ../../library/asyncio-sync.rst:405 +#: ../../library/asyncio-sync.rst:412 msgid "" "Pass the barrier. When all the tasks party to the barrier have called this " "function, they are all unblocked simultaneously." msgstr "" -#: ../../library/asyncio-sync.rst:408 +#: ../../library/asyncio-sync.rst:415 msgid "" "When a waiting or blocked task in the barrier is cancelled, this task exits " "the barrier which stays in the same state. If the state of the barrier is " "\"filling\", the number of waiting task decreases by 1." msgstr "" -#: ../../library/asyncio-sync.rst:413 +#: ../../library/asyncio-sync.rst:420 msgid "" "The return value is an integer in the range of 0 to ``parties-1``, different " "for each task. This can be used to select a task to do some special " "housekeeping, e.g.::" msgstr "" -#: ../../library/asyncio-sync.rst:417 +#: ../../library/asyncio-sync.rst:424 msgid "" "...\n" "async with barrier as position:\n" @@ -621,51 +622,52 @@ msgid "" " print('End of *draining phase*')" msgstr "" -#: ../../library/asyncio-sync.rst:423 +#: ../../library/asyncio-sync.rst:430 msgid "" "This method may raise a :class:`BrokenBarrierError` exception if the barrier " "is broken or reset while a task is waiting. It could raise a :exc:" "`CancelledError` if a task is cancelled." msgstr "" -#: ../../library/asyncio-sync.rst:429 +#: ../../library/asyncio-sync.rst:437 msgid "" "Return the barrier to the default, empty state. Any tasks waiting on it " "will receive the :class:`BrokenBarrierError` exception." msgstr "" -#: ../../library/asyncio-sync.rst:432 +#: ../../library/asyncio-sync.rst:440 msgid "" "If a barrier is broken it may be better to just leave it and create a new " "one." msgstr "" -#: ../../library/asyncio-sync.rst:436 +#: ../../library/asyncio-sync.rst:445 msgid "" "Put the barrier into a broken state. This causes any active or future calls " -"to :meth:`wait` to fail with the :class:`BrokenBarrierError`. Use this for " -"example if one of the tasks needs to abort, to avoid infinite waiting tasks." +"to :meth:`~Barrier.wait` to fail with the :class:`BrokenBarrierError`. Use " +"this for example if one of the tasks needs to abort, to avoid infinite " +"waiting tasks." msgstr "" -#: ../../library/asyncio-sync.rst:443 +#: ../../library/asyncio-sync.rst:452 msgid "The number of tasks required to pass the barrier." msgstr "" -#: ../../library/asyncio-sync.rst:447 +#: ../../library/asyncio-sync.rst:456 msgid "The number of tasks currently waiting in the barrier while filling." msgstr "" -#: ../../library/asyncio-sync.rst:451 +#: ../../library/asyncio-sync.rst:460 msgid "A boolean that is ``True`` if the barrier is in the broken state." msgstr "" -#: ../../library/asyncio-sync.rst:456 +#: ../../library/asyncio-sync.rst:465 msgid "" "This exception, a subclass of :exc:`RuntimeError`, is raised when the :class:" "`Barrier` object is reset or broken." msgstr "" -#: ../../library/asyncio-sync.rst:464 +#: ../../library/asyncio-sync.rst:473 msgid "" "Acquiring a lock using ``await lock`` or ``yield from lock`` and/or :keyword:" "`with` statement (``with await lock``, ``with (yield from lock)``) was " diff --git a/library/asyncio-task.po b/library/asyncio-task.po index 6e293fd3d1..d2437e5b17 100644 --- a/library/asyncio-task.po +++ b/library/asyncio-task.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-04-24 05:56+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-" @@ -262,7 +262,7 @@ msgid "" " # Nothing happens if we just call \"nested()\".\n" " # A coroutine object is created but not awaited,\n" " # so it *won't run at all*.\n" -" nested()\n" +" nested() # will raise a \"RuntimeWarning\".\n" "\n" " # Let's do it differently now and await it:\n" " print(await nested()) # will print \"42\".\n" @@ -435,11 +435,11 @@ msgid "" " task.add_done_callback(background_tasks.discard)" msgstr "" -#: ../../library/asyncio-task.rst:287 ../../library/asyncio-task.rst:1141 +#: ../../library/asyncio-task.rst:287 ../../library/asyncio-task.rst:1192 msgid "Added the *name* parameter." msgstr "新增 *name* 參數。" -#: ../../library/asyncio-task.rst:290 ../../library/asyncio-task.rst:1148 +#: ../../library/asyncio-task.rst:290 ../../library/asyncio-task.rst:1199 msgid "Added the *context* parameter." msgstr "新增 *context* 參數。" @@ -502,9 +502,9 @@ msgstr "" msgid "Close the given coroutine if the task group is not active." msgstr "" -#: ../../library/asyncio-task.rst:345 ../../library/asyncio-task.rst:503 -#: ../../library/asyncio-task.rst:676 ../../library/asyncio-task.rst:734 -#: ../../library/asyncio-task.rst:760 ../../library/asyncio-task.rst:800 +#: ../../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 msgid "Example::" msgstr "範例: ::" @@ -600,37 +600,93 @@ msgid "" msgstr "" #: ../../library/asyncio-task.rst:418 +msgid "Terminating a Task Group" +msgstr "" + +#: ../../library/asyncio-task.rst:420 +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 +msgid "" +"import asyncio\n" +"from asyncio import TaskGroup\n" +"\n" +"class TerminateTaskGroup(Exception):\n" +" \"\"\"Exception raised to terminate a task group.\"\"\"\n" +"\n" +"async def force_terminate_task_group():\n" +" \"\"\"Used to force termination of a task group.\"\"\"\n" +" raise TerminateTaskGroup()\n" +"\n" +"async def job(task_id, sleep_time):\n" +" print(f'Task {task_id}: start')\n" +" await asyncio.sleep(sleep_time)\n" +" print(f'Task {task_id}: done')\n" +"\n" +"async def main():\n" +" try:\n" +" async with TaskGroup() as group:\n" +" # spawn some tasks\n" +" group.create_task(job(1, 0.5))\n" +" group.create_task(job(2, 1.5))\n" +" # sleep for 1 second\n" +" await asyncio.sleep(1)\n" +" # add an exception-raising task to force the group to terminate\n" +" group.create_task(force_terminate_task_group())\n" +" except* TerminateTaskGroup:\n" +" pass\n" +"\n" +"asyncio.run(main())" +msgstr "" + +#: ../../library/asyncio-task.rst:456 +#, fuzzy +msgid "Expected output:" +msgstr "預期的輸出: ::" + +#: ../../library/asyncio-task.rst:458 +msgid "" +"Task 1: start\n" +"Task 2: start\n" +"Task 1: done" +msgstr "" + +#: ../../library/asyncio-task.rst:465 msgid "Sleeping" msgstr "" -#: ../../library/asyncio-task.rst:422 +#: ../../library/asyncio-task.rst:470 msgid "Block for *delay* seconds." msgstr "" -#: ../../library/asyncio-task.rst:424 +#: ../../library/asyncio-task.rst:472 msgid "" "If *result* is provided, it is returned to the caller when the coroutine " "completes." msgstr "" -#: ../../library/asyncio-task.rst:427 +#: ../../library/asyncio-task.rst:475 msgid "" "``sleep()`` always suspends the current task, allowing other tasks to run." msgstr "" -#: ../../library/asyncio-task.rst:430 +#: ../../library/asyncio-task.rst:478 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:436 +#: ../../library/asyncio-task.rst:484 msgid "" "Example of coroutine displaying the current date every second for 5 seconds::" msgstr "" -#: ../../library/asyncio-task.rst:439 +#: ../../library/asyncio-task.rst:487 msgid "" "import asyncio\n" "import datetime\n" @@ -660,40 +716,40 @@ msgstr "" "\n" "asyncio.run(display_date())" -#: ../../library/asyncio-task.rst:454 ../../library/asyncio-task.rst:552 -#: ../../library/asyncio-task.rst:651 ../../library/asyncio-task.rst:825 -#: ../../library/asyncio-task.rst:879 ../../library/asyncio-task.rst:936 +#: ../../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 msgid "Removed the *loop* parameter." msgstr "移除 *loop* 參數。" -#: ../../library/asyncio-task.rst:457 +#: ../../library/asyncio-task.rst:505 msgid "Raises :exc:`ValueError` if *delay* is :data:`~math.nan`." msgstr "" -#: ../../library/asyncio-task.rst:462 +#: ../../library/asyncio-task.rst:510 msgid "Running Tasks Concurrently" msgstr "" -#: ../../library/asyncio-task.rst:466 +#: ../../library/asyncio-task.rst:514 msgid "" "Run :ref:`awaitable objects ` in the *aws* sequence " "*concurrently*." msgstr "" -#: ../../library/asyncio-task.rst:469 +#: ../../library/asyncio-task.rst:517 msgid "" "If any awaitable in *aws* is a coroutine, it is automatically scheduled as a " "Task." msgstr "" -#: ../../library/asyncio-task.rst:472 +#: ../../library/asyncio-task.rst:520 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:476 +#: ../../library/asyncio-task.rst:524 msgid "" "If *return_exceptions* is ``False`` (default), the first raised exception is " "immediately propagated to the task that awaits on ``gather()``. Other " @@ -701,19 +757,19 @@ msgid "" "run." msgstr "" -#: ../../library/asyncio-task.rst:481 +#: ../../library/asyncio-task.rst:529 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:484 +#: ../../library/asyncio-task.rst:532 msgid "" "If ``gather()`` is *cancelled*, all submitted awaitables (that have not " "completed yet) are also *cancelled*." msgstr "" -#: ../../library/asyncio-task.rst:487 +#: ../../library/asyncio-task.rst:535 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** " @@ -721,7 +777,7 @@ msgid "" "submitted Task/Future to cause other Tasks/Futures to be cancelled." msgstr "" -#: ../../library/asyncio-task.rst:494 +#: ../../library/asyncio-task.rst:542 msgid "" "A new alternative to create and run tasks concurrently and wait for their " "completion is :class:`asyncio.TaskGroup`. *TaskGroup* provides stronger " @@ -731,7 +787,7 @@ msgid "" "tasks)." msgstr "" -#: ../../library/asyncio-task.rst:505 +#: ../../library/asyncio-task.rst:553 msgid "" "import asyncio\n" "\n" @@ -770,7 +826,7 @@ msgid "" "# [2, 6, 24]" msgstr "" -#: ../../library/asyncio-task.rst:541 +#: ../../library/asyncio-task.rst:589 msgid "" "If *return_exceptions* is false, cancelling gather() after it has been " "marked done won't cancel any submitted awaitables. For instance, gather can " @@ -779,28 +835,28 @@ msgid "" "the awaitables) from gather won't cancel any other awaitables." msgstr "" -#: ../../library/asyncio-task.rst:548 +#: ../../library/asyncio-task.rst:596 msgid "" "If the *gather* itself is cancelled, the cancellation is propagated " "regardless of *return_exceptions*." msgstr "" -#: ../../library/asyncio-task.rst:555 +#: ../../library/asyncio-task.rst:603 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:564 +#: ../../library/asyncio-task.rst:612 msgid "Eager Task Factory" msgstr "" -#: ../../library/asyncio-task.rst:568 +#: ../../library/asyncio-task.rst:616 msgid "A task factory for eager task execution." msgstr "" -#: ../../library/asyncio-task.rst:570 +#: ../../library/asyncio-task.rst:618 msgid "" "When using this factory (via :meth:`loop.set_task_factory(asyncio." "eager_task_factory) `), coroutines begin execution " @@ -810,13 +866,13 @@ msgid "" "synchronously." msgstr "" -#: ../../library/asyncio-task.rst:576 +#: ../../library/asyncio-task.rst:624 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:581 +#: ../../library/asyncio-task.rst:629 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 " @@ -825,46 +881,46 @@ msgid "" "the application's task execution order is likely to change." msgstr "" -#: ../../library/asyncio-task.rst:592 +#: ../../library/asyncio-task.rst:640 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:596 +#: ../../library/asyncio-task.rst:644 msgid "" "*custom_task_constructor* must be a *callable* with the signature matching " "the signature of :class:`Task.__init__ `. The callable must return a :" "class:`asyncio.Task`-compatible object." msgstr "" -#: ../../library/asyncio-task.rst:600 +#: ../../library/asyncio-task.rst:648 msgid "" "This function returns a *callable* intended to be used as a task factory of " "an event loop via :meth:`loop.set_task_factory(factory) `)." msgstr "" -#: ../../library/asyncio-task.rst:607 +#: ../../library/asyncio-task.rst:655 msgid "Shielding From Cancellation" msgstr "" -#: ../../library/asyncio-task.rst:611 +#: ../../library/asyncio-task.rst:659 msgid "" "Protect an :ref:`awaitable object ` from being :meth:" "`cancelled `." msgstr "" -#: ../../library/asyncio-task.rst:614 ../../library/asyncio-task.rst:780 +#: ../../library/asyncio-task.rst:662 ../../library/asyncio-task.rst:829 msgid "If *aw* is a coroutine it is automatically scheduled as a Task." msgstr "" -#: ../../library/asyncio-task.rst:616 +#: ../../library/asyncio-task.rst:664 msgid "The statement::" msgstr "" -#: ../../library/asyncio-task.rst:618 +#: ../../library/asyncio-task.rst:666 msgid "" "task = asyncio.create_task(something())\n" "res = await shield(task)" @@ -872,15 +928,15 @@ msgstr "" "task = asyncio.create_task(something())\n" "res = await shield(task)" -#: ../../library/asyncio-task.rst:621 +#: ../../library/asyncio-task.rst:669 msgid "is equivalent to::" msgstr "" -#: ../../library/asyncio-task.rst:623 +#: ../../library/asyncio-task.rst:671 msgid "res = await something()" msgstr "res = await something()" -#: ../../library/asyncio-task.rst:625 +#: ../../library/asyncio-task.rst:673 msgid "" "*except* that if the coroutine containing it is cancelled, the Task running " "in ``something()`` is not cancelled. From the point of view of " @@ -889,20 +945,20 @@ msgid "" "`CancelledError`." msgstr "" -#: ../../library/asyncio-task.rst:631 +#: ../../library/asyncio-task.rst:679 msgid "" "If ``something()`` is cancelled by other means (i.e. from within itself) " "that would also cancel ``shield()``." msgstr "" -#: ../../library/asyncio-task.rst:634 +#: ../../library/asyncio-task.rst:682 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:638 +#: ../../library/asyncio-task.rst:686 msgid "" "task = asyncio.create_task(something())\n" "try:\n" @@ -916,7 +972,7 @@ msgstr "" "except CancelledError:\n" " res = None" -#: ../../library/asyncio-task.rst:646 +#: ../../library/asyncio-task.rst:694 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 " @@ -924,36 +980,36 @@ msgid "" "any time, even before it's done." msgstr "" -#: ../../library/asyncio-task.rst:654 +#: ../../library/asyncio-task.rst:702 msgid "" "Deprecation warning is emitted if *aw* is not Future-like object and there " "is no running event loop." msgstr "" -#: ../../library/asyncio-task.rst:660 +#: ../../library/asyncio-task.rst:708 msgid "Timeouts" msgstr "" -#: ../../library/asyncio-task.rst:664 +#: ../../library/asyncio-task.rst:712 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:668 +#: ../../library/asyncio-task.rst:716 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:673 +#: ../../library/asyncio-task.rst:721 msgid "" "In either case, the context manager can be rescheduled after creation using :" "meth:`Timeout.reschedule`." msgstr "" -#: ../../library/asyncio-task.rst:678 +#: ../../library/asyncio-task.rst:726 msgid "" "async def main():\n" " async with asyncio.timeout(10):\n" @@ -963,7 +1019,7 @@ msgstr "" " async with asyncio.timeout(10):\n" " await long_running_task()" -#: ../../library/asyncio-task.rst:682 +#: ../../library/asyncio-task.rst:730 msgid "" "If ``long_running_task`` takes more than 10 seconds to complete, the context " "manager will cancel the current task and handle the resulting :exc:`asyncio." @@ -971,18 +1027,18 @@ msgid "" "can be caught and handled." msgstr "" -#: ../../library/asyncio-task.rst:689 +#: ../../library/asyncio-task.rst:737 msgid "" "The :func:`asyncio.timeout` context manager is what transforms the :exc:" "`asyncio.CancelledError` into a :exc:`TimeoutError`, which means the :exc:" "`TimeoutError` can only be caught *outside* of the context manager." msgstr "" -#: ../../library/asyncio-task.rst:694 +#: ../../library/asyncio-task.rst:742 msgid "Example of catching :exc:`TimeoutError`::" msgstr "" -#: ../../library/asyncio-task.rst:696 +#: ../../library/asyncio-task.rst:744 msgid "" "async def main():\n" " try:\n" @@ -994,48 +1050,48 @@ msgid "" " print(\"This statement will run regardless.\")" msgstr "" -#: ../../library/asyncio-task.rst:705 +#: ../../library/asyncio-task.rst:753 msgid "" "The context manager produced by :func:`asyncio.timeout` can be rescheduled " "to a different deadline and inspected." msgstr "" -#: ../../library/asyncio-task.rst:710 +#: ../../library/asyncio-task.rst:758 msgid "" "An :ref:`asynchronous context manager ` for " "cancelling overdue coroutines." msgstr "" -#: ../../library/asyncio-task.rst:713 +#: ../../library/asyncio-task.rst:761 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:716 +#: ../../library/asyncio-task.rst:764 msgid "If ``when`` is ``None``, the timeout will never trigger." msgstr "" -#: ../../library/asyncio-task.rst:717 +#: ../../library/asyncio-task.rst:765 msgid "" "If ``when < loop.time()``, the timeout will trigger on the next iteration of " "the event loop." msgstr "" -#: ../../library/asyncio-task.rst:722 +#: ../../library/asyncio-task.rst:770 msgid "" "Return the current deadline, or ``None`` if the current deadline is not set." msgstr "" -#: ../../library/asyncio-task.rst:727 +#: ../../library/asyncio-task.rst:775 msgid "Reschedule the timeout." msgstr "" -#: ../../library/asyncio-task.rst:731 +#: ../../library/asyncio-task.rst:779 msgid "Return whether the context manager has exceeded its deadline (expired)." msgstr "" -#: ../../library/asyncio-task.rst:736 +#: ../../library/asyncio-task.rst:784 msgid "" "async def main():\n" " try:\n" @@ -1053,17 +1109,17 @@ msgid "" " print(\"Looks like we haven't finished on time.\")" msgstr "" -#: ../../library/asyncio-task.rst:751 +#: ../../library/asyncio-task.rst:799 msgid "Timeout context managers can be safely nested." msgstr "" -#: ../../library/asyncio-task.rst:757 +#: ../../library/asyncio-task.rst:805 msgid "" "Similar to :func:`asyncio.timeout`, except *when* is the absolute time to " "stop waiting, or ``None``." msgstr "" -#: ../../library/asyncio-task.rst:762 +#: ../../library/asyncio-task.rst:810 msgid "" "async def main():\n" " loop = get_running_loop()\n" @@ -1077,41 +1133,41 @@ msgid "" " print(\"This statement will run regardless.\")" msgstr "" -#: ../../library/asyncio-task.rst:777 +#: ../../library/asyncio-task.rst:826 msgid "" "Wait for the *aw* :ref:`awaitable ` to complete with a " "timeout." msgstr "" -#: ../../library/asyncio-task.rst:782 +#: ../../library/asyncio-task.rst:831 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:786 +#: ../../library/asyncio-task.rst:835 msgid "" "If a timeout occurs, it cancels the task and raises :exc:`TimeoutError`." msgstr "" -#: ../../library/asyncio-task.rst:789 +#: ../../library/asyncio-task.rst:838 msgid "" "To avoid the task :meth:`cancellation `, wrap it in :func:" "`shield`." msgstr "" -#: ../../library/asyncio-task.rst:792 +#: ../../library/asyncio-task.rst:841 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:796 +#: ../../library/asyncio-task.rst:845 msgid "If the wait is cancelled, the future *aw* is also cancelled." msgstr "" -#: ../../library/asyncio-task.rst:802 +#: ../../library/asyncio-task.rst:851 msgid "" "async def eternity():\n" " # Sleep for one hour\n" @@ -1132,107 +1188,107 @@ msgid "" "# timeout!" msgstr "" -#: ../../library/asyncio-task.rst:820 +#: ../../library/asyncio-task.rst:869 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:828 +#: ../../library/asyncio-task.rst:877 msgid "Raises :exc:`TimeoutError` instead of :exc:`asyncio.TimeoutError`." msgstr "引發 :exc:`TimeoutError` 而不是 :exc:`asyncio.TimeoutError`。" -#: ../../library/asyncio-task.rst:833 +#: ../../library/asyncio-task.rst:882 msgid "Waiting Primitives" msgstr "" -#: ../../library/asyncio-task.rst:837 +#: ../../library/asyncio-task.rst:887 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:841 +#: ../../library/asyncio-task.rst:891 msgid "The *aws* iterable must not be empty." msgstr "" -#: ../../library/asyncio-task.rst:843 +#: ../../library/asyncio-task.rst:893 msgid "Returns two sets of Tasks/Futures: ``(done, pending)``." msgstr "" -#: ../../library/asyncio-task.rst:845 +#: ../../library/asyncio-task.rst:895 msgid "Usage::" msgstr "用法: ::" -#: ../../library/asyncio-task.rst:847 +#: ../../library/asyncio-task.rst:897 msgid "done, pending = await asyncio.wait(aws)" msgstr "done, pending = await asyncio.wait(aws)" -#: ../../library/asyncio-task.rst:849 +#: ../../library/asyncio-task.rst:899 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:852 +#: ../../library/asyncio-task.rst:902 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:856 +#: ../../library/asyncio-task.rst:906 msgid "" "*return_when* indicates when this function should return. It must be one of " "the following constants:" msgstr "" -#: ../../library/asyncio-task.rst:862 +#: ../../library/asyncio-task.rst:912 msgid "Constant" msgstr "常數" -#: ../../library/asyncio-task.rst:863 +#: ../../library/asyncio-task.rst:913 msgid "Description" msgstr "描述" -#: ../../library/asyncio-task.rst:866 +#: ../../library/asyncio-task.rst:916 msgid "The function will return when any future finishes or is cancelled." msgstr "" -#: ../../library/asyncio-task.rst:869 +#: ../../library/asyncio-task.rst:919 msgid "" "The function will return when any future finishes by raising an exception. " "If no future raises an exception then it is equivalent to :const:" "`ALL_COMPLETED`." msgstr "" -#: ../../library/asyncio-task.rst:874 +#: ../../library/asyncio-task.rst:924 msgid "The function will return when all futures finish or are cancelled." msgstr "" -#: ../../library/asyncio-task.rst:876 +#: ../../library/asyncio-task.rst:926 msgid "" "Unlike :func:`~asyncio.wait_for`, ``wait()`` does not cancel the futures " "when a timeout occurs." msgstr "" -#: ../../library/asyncio-task.rst:882 +#: ../../library/asyncio-task.rst:932 msgid "Passing coroutine objects to ``wait()`` directly is forbidden." msgstr "" -#: ../../library/asyncio-task.rst:885 ../../library/asyncio-task.rst:943 +#: ../../library/asyncio-task.rst:935 ../../library/asyncio-task.rst:993 msgid "Added support for generators yielding tasks." msgstr "" -#: ../../library/asyncio-task.rst:891 +#: ../../library/asyncio-task.rst:941 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:895 +#: ../../library/asyncio-task.rst:945 msgid "" "The object returned by ``as_completed()`` can be iterated as an :term:" "`asynchronous iterator` or a plain :term:`iterator`. When asynchronous " @@ -1241,7 +1297,7 @@ msgid "" "tasks with their results. Example::" msgstr "" -#: ../../library/asyncio-task.rst:901 +#: ../../library/asyncio-task.rst:951 msgid "" "ipv4_connect = create_task(open_connection(\"127.0.0.1\", 80))\n" "ipv6_connect = create_task(open_connection(\"::1\", 80))\n" @@ -1258,20 +1314,20 @@ msgid "" " print(\"IPv4 connection established.\")" msgstr "" -#: ../../library/asyncio-task.rst:915 +#: ../../library/asyncio-task.rst:965 msgid "" "During asynchronous iteration, implicitly-created tasks will be yielded for " "supplied awaitables that aren't tasks or futures." msgstr "" -#: ../../library/asyncio-task.rst:918 +#: ../../library/asyncio-task.rst:968 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:922 +#: ../../library/asyncio-task.rst:972 msgid "" "ipv4_connect = create_task(open_connection(\"127.0.0.1\", 80))\n" "ipv6_connect = create_task(open_connection(\"::1\", 80))\n" @@ -1284,34 +1340,34 @@ msgid "" " reader, writer = await next_connect" msgstr "" -#: ../../library/asyncio-task.rst:932 +#: ../../library/asyncio-task.rst:982 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:939 +#: ../../library/asyncio-task.rst:989 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:946 +#: ../../library/asyncio-task.rst:996 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:952 +#: ../../library/asyncio-task.rst:1002 msgid "Running in Threads" msgstr "" -#: ../../library/asyncio-task.rst:956 +#: ../../library/asyncio-task.rst:1007 msgid "Asynchronously run function *func* in a separate thread." msgstr "" -#: ../../library/asyncio-task.rst:958 +#: ../../library/asyncio-task.rst:1009 msgid "" "Any \\*args and \\*\\*kwargs supplied for this function are directly passed " "to *func*. Also, the current :class:`contextvars.Context` is propagated, " @@ -1319,19 +1375,19 @@ msgid "" "separate thread." msgstr "" -#: ../../library/asyncio-task.rst:963 +#: ../../library/asyncio-task.rst:1014 msgid "" "Return a coroutine that can be awaited to get the eventual result of *func*." msgstr "" -#: ../../library/asyncio-task.rst:965 +#: ../../library/asyncio-task.rst:1016 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:969 +#: ../../library/asyncio-task.rst:1020 msgid "" "def blocking_io():\n" " print(f\"start blocking_io at {time.strftime('%X')}\")\n" @@ -1360,7 +1416,7 @@ msgid "" "# finished main at 19:50:54" msgstr "" -#: ../../library/asyncio-task.rst:995 +#: ../../library/asyncio-task.rst:1046 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. " @@ -1368,7 +1424,7 @@ msgid "" "thread without blocking the event loop." msgstr "" -#: ../../library/asyncio-task.rst:1002 +#: ../../library/asyncio-task.rst:1053 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 " @@ -1376,27 +1432,27 @@ msgid "" "``asyncio.to_thread()`` can also be used for CPU-bound functions." msgstr "" -#: ../../library/asyncio-task.rst:1011 +#: ../../library/asyncio-task.rst:1062 msgid "Scheduling From Other Threads" msgstr "" -#: ../../library/asyncio-task.rst:1015 +#: ../../library/asyncio-task.rst:1066 msgid "Submit a coroutine to the given event loop. Thread-safe." msgstr "" -#: ../../library/asyncio-task.rst:1017 +#: ../../library/asyncio-task.rst:1068 msgid "" "Return a :class:`concurrent.futures.Future` to wait for the result from " "another OS thread." msgstr "" -#: ../../library/asyncio-task.rst:1020 +#: ../../library/asyncio-task.rst:1071 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:1023 +#: ../../library/asyncio-task.rst:1074 msgid "" "# Create a coroutine\n" "coro = asyncio.sleep(1, result=3)\n" @@ -1408,13 +1464,13 @@ msgid "" "assert future.result(timeout) == 3" msgstr "" -#: ../../library/asyncio-task.rst:1032 +#: ../../library/asyncio-task.rst:1083 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:1036 +#: ../../library/asyncio-task.rst:1087 msgid "" "try:\n" " result = future.result(timeout)\n" @@ -1427,59 +1483,59 @@ msgid "" " print(f'The coroutine returned: {result!r}')" msgstr "" -#: ../../library/asyncio-task.rst:1046 +#: ../../library/asyncio-task.rst:1097 msgid "" "See the :ref:`concurrency and multithreading ` " "section of the documentation." msgstr "" -#: ../../library/asyncio-task.rst:1049 +#: ../../library/asyncio-task.rst:1100 msgid "" "Unlike other asyncio functions this function requires the *loop* argument to " "be passed explicitly." msgstr "" -#: ../../library/asyncio-task.rst:1056 +#: ../../library/asyncio-task.rst:1107 msgid "Introspection" msgstr "" -#: ../../library/asyncio-task.rst:1061 +#: ../../library/asyncio-task.rst:1112 msgid "" "Return the currently running :class:`Task` instance, or ``None`` if no task " "is running." msgstr "" -#: ../../library/asyncio-task.rst:1064 +#: ../../library/asyncio-task.rst:1115 msgid "" "If *loop* is ``None`` :func:`get_running_loop` is used to get the current " "loop." msgstr "" -#: ../../library/asyncio-task.rst:1072 +#: ../../library/asyncio-task.rst:1123 msgid "Return a set of not yet finished :class:`Task` objects run by the loop." msgstr "" -#: ../../library/asyncio-task.rst:1075 +#: ../../library/asyncio-task.rst:1126 msgid "" "If *loop* is ``None``, :func:`get_running_loop` is used for getting current " "loop." msgstr "" -#: ../../library/asyncio-task.rst:1083 +#: ../../library/asyncio-task.rst:1134 msgid "Return ``True`` if *obj* is a coroutine object." msgstr "" -#: ../../library/asyncio-task.rst:1089 +#: ../../library/asyncio-task.rst:1140 msgid "Task Object" msgstr "" -#: ../../library/asyncio-task.rst:1093 +#: ../../library/asyncio-task.rst:1144 msgid "" "A :class:`Future-like ` object that runs a Python :ref:`coroutine " "`. Not thread-safe." msgstr "" -#: ../../library/asyncio-task.rst:1096 +#: ../../library/asyncio-task.rst:1147 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 " @@ -1487,21 +1543,21 @@ msgid "" "wrapped coroutine resumes." msgstr "" -#: ../../library/asyncio-task.rst:1102 +#: ../../library/asyncio-task.rst:1153 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:1107 +#: ../../library/asyncio-task.rst:1158 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:1112 +#: ../../library/asyncio-task.rst:1163 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 " @@ -1509,20 +1565,20 @@ msgid "" "cancellation, the Future object will be cancelled." msgstr "" -#: ../../library/asyncio-task.rst:1117 +#: ../../library/asyncio-task.rst:1168 msgid "" ":meth:`cancelled` can be used to check if the Task was cancelled. The method " "returns ``True`` if the wrapped coroutine did not suppress the :exc:" "`CancelledError` exception and was actually cancelled." msgstr "" -#: ../../library/asyncio-task.rst:1122 +#: ../../library/asyncio-task.rst:1173 msgid "" ":class:`asyncio.Task` inherits from :class:`Future` all of its APIs except :" "meth:`Future.set_result` and :meth:`Future.set_exception`." msgstr "" -#: ../../library/asyncio-task.rst:1126 +#: ../../library/asyncio-task.rst:1177 msgid "" "An optional keyword-only *context* argument allows specifying a custom :" "class:`contextvars.Context` for the *coro* to run in. If no *context* is " @@ -1530,7 +1586,7 @@ msgid "" "in the copied context." msgstr "" -#: ../../library/asyncio-task.rst:1131 +#: ../../library/asyncio-task.rst:1182 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 " @@ -1540,96 +1596,96 @@ msgid "" "eagerly and will skip scheduling to the event loop." msgstr "" -#: ../../library/asyncio-task.rst:1138 +#: ../../library/asyncio-task.rst:1189 msgid "Added support for the :mod:`contextvars` module." msgstr "" -#: ../../library/asyncio-task.rst:1144 +#: ../../library/asyncio-task.rst:1195 msgid "" "Deprecation warning is emitted if *loop* is not specified and there is no " "running event loop." msgstr "" -#: ../../library/asyncio-task.rst:1151 +#: ../../library/asyncio-task.rst:1202 msgid "Added the *eager_start* parameter." msgstr "新增 *eager_start* 參數。" -#: ../../library/asyncio-task.rst:1156 +#: ../../library/asyncio-task.rst:1207 msgid "Return ``True`` if the Task is *done*." msgstr "" -#: ../../library/asyncio-task.rst:1158 +#: ../../library/asyncio-task.rst:1209 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:1163 +#: ../../library/asyncio-task.rst:1214 msgid "Return the result of the Task." msgstr "" -#: ../../library/asyncio-task.rst:1165 +#: ../../library/asyncio-task.rst:1216 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:1169 ../../library/asyncio-task.rst:1183 +#: ../../library/asyncio-task.rst:1220 ../../library/asyncio-task.rst:1234 msgid "" "If the Task has been *cancelled*, this method raises a :exc:`CancelledError` " "exception." msgstr "" -#: ../../library/asyncio-task.rst:1172 +#: ../../library/asyncio-task.rst:1223 msgid "" "If the Task's result isn't yet available, this method raises an :exc:" "`InvalidStateError` exception." msgstr "" -#: ../../library/asyncio-task.rst:1177 +#: ../../library/asyncio-task.rst:1228 msgid "Return the exception of the Task." msgstr "" -#: ../../library/asyncio-task.rst:1179 +#: ../../library/asyncio-task.rst:1230 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:1186 +#: ../../library/asyncio-task.rst:1237 msgid "" "If the Task isn't *done* yet, this method raises an :exc:`InvalidStateError` " "exception." msgstr "" -#: ../../library/asyncio-task.rst:1191 +#: ../../library/asyncio-task.rst:1242 msgid "Add a callback to be run when the Task is *done*." msgstr "" -#: ../../library/asyncio-task.rst:1193 ../../library/asyncio-task.rst:1202 +#: ../../library/asyncio-task.rst:1244 ../../library/asyncio-task.rst:1253 msgid "This method should only be used in low-level callback-based code." msgstr "" -#: ../../library/asyncio-task.rst:1195 +#: ../../library/asyncio-task.rst:1246 msgid "" "See the documentation of :meth:`Future.add_done_callback` for more details." msgstr "" -#: ../../library/asyncio-task.rst:1200 +#: ../../library/asyncio-task.rst:1251 msgid "Remove *callback* from the callbacks list." msgstr "" -#: ../../library/asyncio-task.rst:1204 +#: ../../library/asyncio-task.rst:1255 msgid "" "See the documentation of :meth:`Future.remove_done_callback` for more " "details." msgstr "" -#: ../../library/asyncio-task.rst:1209 +#: ../../library/asyncio-task.rst:1260 msgid "Return the list of stack frames for this Task." msgstr "" -#: ../../library/asyncio-task.rst:1211 +#: ../../library/asyncio-task.rst:1262 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, " @@ -1637,15 +1693,15 @@ msgid "" "this returns the list of traceback frames." msgstr "" -#: ../../library/asyncio-task.rst:1217 +#: ../../library/asyncio-task.rst:1268 msgid "The frames are always ordered from oldest to newest." msgstr "" -#: ../../library/asyncio-task.rst:1219 +#: ../../library/asyncio-task.rst:1270 msgid "Only one stack frame is returned for a suspended coroutine." msgstr "" -#: ../../library/asyncio-task.rst:1221 +#: ../../library/asyncio-task.rst:1272 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 " @@ -1654,81 +1710,87 @@ msgid "" "are returned. (This matches the behavior of the traceback module.)" msgstr "" -#: ../../library/asyncio-task.rst:1230 +#: ../../library/asyncio-task.rst:1281 msgid "Print the stack or traceback for this Task." msgstr "" -#: ../../library/asyncio-task.rst:1232 +#: ../../library/asyncio-task.rst:1283 msgid "" "This produces output similar to that of the traceback module for the frames " "retrieved by :meth:`get_stack`." msgstr "" -#: ../../library/asyncio-task.rst:1235 +#: ../../library/asyncio-task.rst:1286 msgid "The *limit* argument is passed to :meth:`get_stack` directly." msgstr "" -#: ../../library/asyncio-task.rst:1237 +#: ../../library/asyncio-task.rst:1288 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:1242 +#: ../../library/asyncio-task.rst:1293 msgid "Return the coroutine object wrapped by the :class:`Task`." msgstr "" -#: ../../library/asyncio-task.rst:1246 +#: ../../library/asyncio-task.rst:1297 msgid "" "This will return ``None`` for Tasks which have already completed eagerly. " "See the :ref:`Eager Task Factory `." msgstr "" -#: ../../library/asyncio-task.rst:1253 +#: ../../library/asyncio-task.rst:1304 msgid "Newly added eager task execution means result may be ``None``." msgstr "" -#: ../../library/asyncio-task.rst:1257 +#: ../../library/asyncio-task.rst:1308 msgid "" "Return the :class:`contextvars.Context` object associated with the task." msgstr "" -#: ../../library/asyncio-task.rst:1264 +#: ../../library/asyncio-task.rst:1315 msgid "Return the name of the Task." msgstr "" -#: ../../library/asyncio-task.rst:1266 +#: ../../library/asyncio-task.rst:1317 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:1274 +#: ../../library/asyncio-task.rst:1325 msgid "Set the name of the Task." msgstr "" -#: ../../library/asyncio-task.rst:1276 +#: ../../library/asyncio-task.rst:1327 msgid "" "The *value* argument can be any object, which is then converted to a string." msgstr "" -#: ../../library/asyncio-task.rst:1279 +#: ../../library/asyncio-task.rst:1330 msgid "" "In the default Task implementation, the name will be visible in the :func:" "`repr` output of a task object." msgstr "" -#: ../../library/asyncio-task.rst:1286 +#: ../../library/asyncio-task.rst:1337 msgid "Request the Task to be cancelled." msgstr "" -#: ../../library/asyncio-task.rst:1288 +#: ../../library/asyncio-task.rst:1339 +msgid "" +"If the Task is already *done* or *cancelled*, return ``False``, otherwise, " +"return ``True``." +msgstr "" + +#: ../../library/asyncio-task.rst:1342 msgid "" -"This arranges for a :exc:`CancelledError` exception to be thrown into the " -"wrapped coroutine on the next cycle of the event loop." +"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:1291 +#: ../../library/asyncio-task.rst:1345 msgid "" "The coroutine then has a chance to clean up or even deny the request by " "suppressing the exception with a :keyword:`try` ... ... ``except " @@ -1740,21 +1802,21 @@ msgid "" "addition to catching the exception." msgstr "" -#: ../../library/asyncio-task.rst:1301 +#: ../../library/asyncio-task.rst:1355 msgid "Added the *msg* parameter." msgstr "新增 *msg* 參數。" -#: ../../library/asyncio-task.rst:1304 +#: ../../library/asyncio-task.rst:1358 msgid "The ``msg`` parameter is propagated from cancelled task to its awaiter." msgstr "" -#: ../../library/asyncio-task.rst:1309 +#: ../../library/asyncio-task.rst:1363 msgid "" "The following example illustrates how coroutines can intercept the " "cancellation request::" msgstr "" -#: ../../library/asyncio-task.rst:1312 +#: ../../library/asyncio-task.rst:1366 msgid "" "async def cancel_me():\n" " print('cancel_me(): before sleep')\n" @@ -1791,32 +1853,32 @@ msgid "" "# main(): cancel_me is cancelled now" msgstr "" -#: ../../library/asyncio-task.rst:1348 +#: ../../library/asyncio-task.rst:1402 msgid "Return ``True`` if the Task is *cancelled*." msgstr "" -#: ../../library/asyncio-task.rst:1350 +#: ../../library/asyncio-task.rst:1404 msgid "" "The Task is *cancelled* when the cancellation was requested with :meth:" "`cancel` and the wrapped coroutine propagated the :exc:`CancelledError` " "exception thrown into it." msgstr "" -#: ../../library/asyncio-task.rst:1356 +#: ../../library/asyncio-task.rst:1410 msgid "Decrement the count of cancellation requests to this Task." msgstr "" -#: ../../library/asyncio-task.rst:1358 +#: ../../library/asyncio-task.rst:1412 msgid "Returns the remaining number of cancellation requests." msgstr "" -#: ../../library/asyncio-task.rst:1360 +#: ../../library/asyncio-task.rst:1414 msgid "" "Note that once execution of a cancelled task completed, further calls to :" "meth:`uncancel` are ineffective." msgstr "" -#: ../../library/asyncio-task.rst:1365 +#: ../../library/asyncio-task.rst:1419 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 " @@ -1825,7 +1887,7 @@ msgid "" "respective structured block. For example::" msgstr "" -#: ../../library/asyncio-task.rst:1372 +#: ../../library/asyncio-task.rst:1426 msgid "" "async def make_request_with_timeout():\n" " try:\n" @@ -1839,7 +1901,7 @@ msgid "" " await unrelated_code()" msgstr "" -#: ../../library/asyncio-task.rst:1383 +#: ../../library/asyncio-task.rst:1437 msgid "" "While the block with ``make_request()`` and ``make_another_request()`` might " "get cancelled due to the timeout, ``unrelated_code()`` should continue " @@ -1848,14 +1910,14 @@ msgid "" "similar fashion." msgstr "" -#: ../../library/asyncio-task.rst:1389 +#: ../../library/asyncio-task.rst:1443 msgid "" "If end-user code is, for some reason, suppressing cancellation by catching :" "exc:`CancelledError`, it needs to call this method to remove the " "cancellation state." msgstr "" -#: ../../library/asyncio-task.rst:1393 +#: ../../library/asyncio-task.rst:1447 msgid "" "When this method decrements the cancellation count to zero, the method " "checks if a previous :meth:`cancel` call had arranged for :exc:" @@ -1864,17 +1926,17 @@ msgid "" "``_must_cancel`` flag)." msgstr "" -#: ../../library/asyncio-task.rst:1399 +#: ../../library/asyncio-task.rst:1453 msgid "Changed to rescind pending cancellation requests upon reaching zero." msgstr "" -#: ../../library/asyncio-task.rst:1404 +#: ../../library/asyncio-task.rst:1458 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:1408 +#: ../../library/asyncio-task.rst:1462 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 " @@ -1883,7 +1945,7 @@ msgid "" "to zero." msgstr "" -#: ../../library/asyncio-task.rst:1414 +#: ../../library/asyncio-task.rst:1468 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 f6ca78be42..d93fc66b22 100644 --- a/library/asyncio.po +++ b/library/asyncio.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2024-10-13 17:13+0000\n" "PO-Revision-Date: 2021-11-23 12:40+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -148,9 +148,8 @@ msgstr "" "based) 的函式庫與程式碼。" #: ../../includes/wasm-notavail.rst:3 -#, fuzzy -msgid ":ref:`Availability `: not WASI." -msgstr ":ref:`適用 `:非 Emscripten、非 WASI。" +msgid "Availability" +msgstr "" #: ../../includes/wasm-notavail.rst:5 #, fuzzy @@ -215,3 +214,7 @@ msgstr "參閱" #: ../../library/asyncio.rst:123 msgid "The source code for asyncio can be found in :source:`Lib/asyncio/`." msgstr "asyncio 的原始碼可以在 :source:`Lib/asyncio/` 中找到。" + +#, fuzzy +#~ msgid ":ref:`Availability `: not WASI." +#~ msgstr ":ref:`適用 `:非 Emscripten、非 WASI。" diff --git a/library/asyncore.po b/library/asyncore.po new file mode 100644 index 0000000000..84467a75b1 --- /dev/null +++ b/library/asyncore.po @@ -0,0 +1,39 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2001-2024, Python Software Foundation +# This file is distributed under the same license as the Python package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Python 3.13\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-11-20 09:21+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/asyncore.rst:2 +msgid ":mod:`!asyncore` --- Asynchronous socket handler" +msgstr "" + +#: ../../library/asyncore.rst:10 +msgid "" +"This module is no longer part of the Python standard library. It was :ref:" +"`removed in Python 3.12 ` after being deprecated in " +"Python 3.6. The removal was decided in :pep:`594`." +msgstr "" + +#: ../../library/asyncore.rst:14 +msgid "Applications should use the :mod:`asyncio` module instead." +msgstr "" + +#: ../../library/asyncore.rst:16 +msgid "" +"The last version of Python that provided the :mod:`!asyncore` module was " +"`Python 3.11 `_." +msgstr "" diff --git a/library/audioop.po b/library/audioop.po index 4de310eb6f..10bbbf1b0c 100644 --- a/library/audioop.po +++ b/library/audioop.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2024-11-20 09:21+0000\n" "PO-Revision-Date: 2022-05-22 02:00+0800\n" "Last-Translator: Liang-Bo Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -20,348 +20,38 @@ msgstr "" "X-Generator: Poedit 3.0.1\n" #: ../../library/audioop.rst:2 -msgid ":mod:`audioop` --- Manipulate raw audio data" +#, fuzzy +msgid ":mod:`!audioop` --- Manipulate raw audio data" msgstr ":mod:`audioop` --- 操作原始聲音檔案" -#: ../../library/audioop.rst:8 +#: ../../library/audioop.rst:10 msgid "" -"The :mod:`audioop` module is deprecated (see :pep:`PEP 594 <594#audioop>` " -"for details)." +"This module is no longer part of the Python standard library. It was :ref:" +"`removed in Python 3.13 ` after being deprecated in " +"Python 3.11. The removal was decided in :pep:`594`." msgstr "" -":mod:`audioop` 模組 (module) 即將被棄用(詳見 :pep:`PEP 594 " -"<594#audioop>`\\ )。" #: ../../library/audioop.rst:14 msgid "" -"The :mod:`audioop` module contains some useful operations on sound " -"fragments. It operates on sound fragments consisting of signed integer " -"samples 8, 16, 24 or 32 bits wide, stored in :term:`bytes-like objects " -"`. All scalar items are integers, unless specified " -"otherwise." +"The last version of Python that provided the :mod:`!audioop` module was " +"`Python 3.12 `_." msgstr "" -#: ../../library/audioop.rst:19 -msgid "" -"Support for 24-bit samples was added. All functions now accept any :term:" -"`bytes-like object`. String input now results in an immediate error." -msgstr "" - -#: ../../library/audioop.rst:30 -msgid "" -"This module provides support for a-LAW, u-LAW and Intel/DVI ADPCM encodings." -msgstr "" - -#: ../../library/audioop.rst:34 -msgid "" -"A few of the more complicated operations only take 16-bit samples, otherwise " -"the sample size (in bytes) is always a parameter of the operation." -msgstr "" - -#: ../../library/audioop.rst:37 -msgid "The module defines the following variables and functions:" -msgstr "" - -#: ../../library/audioop.rst:42 -msgid "" -"This exception is raised on all errors, such as unknown number of bytes per " -"sample, etc." -msgstr "" - -#: ../../library/audioop.rst:48 -msgid "" -"Return a fragment which is the addition of the two samples passed as " -"parameters. *width* is the sample width in bytes, either ``1``, ``2``, ``3`` " -"or ``4``. Both fragments should have the same length. Samples are " -"truncated in case of overflow." -msgstr "" - -#: ../../library/audioop.rst:55 -msgid "" -"Decode an Intel/DVI ADPCM coded fragment to a linear fragment. See the " -"description of :func:`lin2adpcm` for details on ADPCM coding. Return a tuple " -"``(sample, newstate)`` where the sample has the width specified in *width*." -msgstr "" - -#: ../../library/audioop.rst:62 -msgid "" -"Convert sound fragments in a-LAW encoding to linearly encoded sound " -"fragments. a-LAW encoding always uses 8 bits samples, so *width* refers only " -"to the sample width of the output fragment here." -msgstr "" - -#: ../../library/audioop.rst:69 -msgid "Return the average over all samples in the fragment." -msgstr "" - -#: ../../library/audioop.rst:74 -msgid "" -"Return the average peak-peak value over all samples in the fragment. No " -"filtering is done, so the usefulness of this routine is questionable." -msgstr "" - -#: ../../library/audioop.rst:80 -msgid "" -"Return a fragment that is the original fragment with a bias added to each " -"sample. Samples wrap around in case of overflow." -msgstr "" - -#: ../../library/audioop.rst:86 -msgid "" -"\"Byteswap\" all samples in a fragment and returns the modified fragment. " -"Converts big-endian samples to little-endian and vice versa." -msgstr "" - -#: ../../library/audioop.rst:94 -msgid "" -"Return the number of zero crossings in the fragment passed as an argument." -msgstr "" - -#: ../../library/audioop.rst:99 -msgid "" -"Return a factor *F* such that ``rms(add(fragment, mul(reference, -F)))`` is " -"minimal, i.e., return the factor with which you should multiply *reference* " -"to make it match as well as possible to *fragment*. The fragments should " -"both contain 2-byte samples." -msgstr "" - -#: ../../library/audioop.rst:104 -msgid "The time taken by this routine is proportional to ``len(fragment)``." -msgstr "" - -#: ../../library/audioop.rst:109 -msgid "" -"Try to match *reference* as well as possible to a portion of *fragment* " -"(which should be the longer fragment). This is (conceptually) done by " -"taking slices out of *fragment*, using :func:`findfactor` to compute the " -"best match, and minimizing the result. The fragments should both contain 2-" -"byte samples. Return a tuple ``(offset, factor)`` where *offset* is the " -"(integer) offset into *fragment* where the optimal match started and " -"*factor* is the (floating-point) factor as per :func:`findfactor`." -msgstr "" - -#: ../../library/audioop.rst:120 -msgid "" -"Search *fragment* for a slice of length *length* samples (not bytes!) with " -"maximum energy, i.e., return *i* for which ``rms(fragment[i*2:" -"(i+length)*2])`` is maximal. The fragments should both contain 2-byte " -"samples." -msgstr "" - -#: ../../library/audioop.rst:124 -msgid "The routine takes time proportional to ``len(fragment)``." -msgstr "" - -#: ../../library/audioop.rst:129 -msgid "Return the value of sample *index* from the fragment." -msgstr "" - -#: ../../library/audioop.rst:134 -msgid "" -"Convert samples to 4 bit Intel/DVI ADPCM encoding. ADPCM coding is an " -"adaptive coding scheme, whereby each 4 bit number is the difference between " -"one sample and the next, divided by a (varying) step. The Intel/DVI ADPCM " -"algorithm has been selected for use by the IMA, so it may well become a " -"standard." -msgstr "" - -#: ../../library/audioop.rst:139 -msgid "" -"*state* is a tuple containing the state of the coder. The coder returns a " -"tuple ``(adpcmfrag, newstate)``, and the *newstate* should be passed to the " -"next call of :func:`lin2adpcm`. In the initial call, ``None`` can be passed " -"as the state. *adpcmfrag* is the ADPCM coded fragment packed 2 4-bit values " -"per byte." -msgstr "" - -#: ../../library/audioop.rst:147 -msgid "" -"Convert samples in the audio fragment to a-LAW encoding and return this as a " -"bytes object. a-LAW is an audio encoding format whereby you get a dynamic " -"range of about 13 bits using only 8 bit samples. It is used by the Sun " -"audio hardware, among others." -msgstr "" - -#: ../../library/audioop.rst:155 -msgid "Convert samples between 1-, 2-, 3- and 4-byte formats." -msgstr "" - -#: ../../library/audioop.rst:159 -msgid "" -"In some audio formats, such as .WAV files, 16, 24 and 32 bit samples are " -"signed, but 8 bit samples are unsigned. So when converting to 8 bit wide " -"samples for these formats, you need to also add 128 to the result::" -msgstr "" - -#: ../../library/audioop.rst:163 -msgid "" -"new_frames = audioop.lin2lin(frames, old_width, 1)\n" -"new_frames = audioop.bias(new_frames, 1, 128)" -msgstr "" - -#: ../../library/audioop.rst:166 -msgid "" -"The same, in reverse, has to be applied when converting from 8 to 16, 24 or " -"32 bit width samples." -msgstr "" - -#: ../../library/audioop.rst:172 -msgid "" -"Convert samples in the audio fragment to u-LAW encoding and return this as a " -"bytes object. u-LAW is an audio encoding format whereby you get a dynamic " -"range of about 14 bits using only 8 bit samples. It is used by the Sun " -"audio hardware, among others." -msgstr "" - -#: ../../library/audioop.rst:180 -msgid "" -"Return the maximum of the *absolute value* of all samples in a fragment." -msgstr "" - -#: ../../library/audioop.rst:185 -msgid "Return the maximum peak-peak value in the sound fragment." -msgstr "" - -#: ../../library/audioop.rst:190 -msgid "" -"Return a tuple consisting of the minimum and maximum values of all samples " -"in the sound fragment." -msgstr "" - -#: ../../library/audioop.rst:196 -msgid "" -"Return a fragment that has all samples in the original fragment multiplied " -"by the floating-point value *factor*. Samples are truncated in case of " -"overflow." -msgstr "" - -#: ../../library/audioop.rst:202 -msgid "Convert the frame rate of the input fragment." -msgstr "" - -#: ../../library/audioop.rst:204 -msgid "" -"*state* is a tuple containing the state of the converter. The converter " -"returns a tuple ``(newfragment, newstate)``, and *newstate* should be passed " -"to the next call of :func:`ratecv`. The initial call should pass ``None`` " -"as the state." -msgstr "" - -#: ../../library/audioop.rst:208 -msgid "" -"The *weightA* and *weightB* arguments are parameters for a simple digital " -"filter and default to ``1`` and ``0`` respectively." -msgstr "" - -#: ../../library/audioop.rst:214 -msgid "Reverse the samples in a fragment and returns the modified fragment." -msgstr "" - -#: ../../library/audioop.rst:219 -msgid "" -"Return the root-mean-square of the fragment, i.e. ``sqrt(sum(S_i^2)/n)``." -msgstr "" - -#: ../../library/audioop.rst:221 -msgid "This is a measure of the power in an audio signal." -msgstr "" - -#: ../../library/audioop.rst:226 -msgid "" -"Convert a stereo fragment to a mono fragment. The left channel is " -"multiplied by *lfactor* and the right channel by *rfactor* before adding the " -"two channels to give a mono signal." -msgstr "" - -#: ../../library/audioop.rst:233 -msgid "" -"Generate a stereo fragment from a mono fragment. Each pair of samples in " -"the stereo fragment are computed from the mono sample, whereby left channel " -"samples are multiplied by *lfactor* and right channel samples by *rfactor*." -msgstr "" - -#: ../../library/audioop.rst:240 -msgid "" -"Convert sound fragments in u-LAW encoding to linearly encoded sound " -"fragments. u-LAW encoding always uses 8 bits samples, so *width* refers only " -"to the sample width of the output fragment here." -msgstr "" - -#: ../../library/audioop.rst:244 -msgid "" -"Note that operations such as :func:`.mul` or :func:`.max` make no " -"distinction between mono and stereo fragments, i.e. all samples are treated " -"equal. If this is a problem the stereo fragment should be split into two " -"mono fragments first and recombined later. Here is an example of how to do " -"that::" -msgstr "" - -#: ../../library/audioop.rst:249 -msgid "" -"def mul_stereo(sample, width, lfactor, rfactor):\n" -" lsample = audioop.tomono(sample, width, 1, 0)\n" -" rsample = audioop.tomono(sample, width, 0, 1)\n" -" lsample = audioop.mul(lsample, width, lfactor)\n" -" rsample = audioop.mul(rsample, width, rfactor)\n" -" lsample = audioop.tostereo(lsample, width, 1, 0)\n" -" rsample = audioop.tostereo(rsample, width, 0, 1)\n" -" return audioop.add(lsample, rsample, width)" -msgstr "" - -#: ../../library/audioop.rst:258 -msgid "" -"If you use the ADPCM coder to build network packets and you want your " -"protocol to be stateless (i.e. to be able to tolerate packet loss) you " -"should not only transmit the data but also the state. Note that you should " -"send the *initial* state (the one you passed to :func:`lin2adpcm`) along to " -"the decoder, not the final state (as returned by the coder). If you want to " -"use :class:`struct.Struct` to store the state in binary you can code the " -"first element (the predicted value) in 16 bits and the second (the delta " -"index) in 8." -msgstr "" - -#: ../../library/audioop.rst:266 -msgid "" -"The ADPCM coders have never been tried against other ADPCM coders, only " -"against themselves. It could well be that I misinterpreted the standards in " -"which case they will not be interoperable with the respective standards." -msgstr "" - -#: ../../library/audioop.rst:270 -msgid "" -"The :func:`find\\*` routines might look a bit funny at first sight. They are " -"primarily meant to do echo cancellation. A reasonably fast way to do this " -"is to pick the most energetic piece of the output sample, locate that in the " -"input sample and subtract the whole output sample from the input sample::" -msgstr "" - -#: ../../library/audioop.rst:275 -msgid "" -"def echocancel(outputdata, inputdata):\n" -" pos = audioop.findmax(outputdata, 800) # one tenth second\n" -" out_test = outputdata[pos*2:]\n" -" in_test = inputdata[pos*2:]\n" -" ipos, factor = audioop.findfit(in_test, out_test)\n" -" # Optional (for better cancellation):\n" -" # factor = audioop.findfactor(in_test[ipos*2:ipos*2+len(out_test)],\n" -" # out_test)\n" -" prefill = '\\0'*(pos+ipos)*2\n" -" postfill = '\\0'*(len(inputdata)-len(prefill)-len(outputdata))\n" -" outputdata = prefill + audioop.mul(outputdata, 2, -factor) + postfill\n" -" return audioop.add(inputdata, outputdata, 2)" -msgstr "" +#~ msgid "" +#~ "The :mod:`audioop` module is deprecated (see :pep:`PEP 594 <594#audioop>` " +#~ "for details)." +#~ msgstr "" +#~ ":mod:`audioop` 模組 (module) 即將被棄用(詳見 :pep:`PEP 594 " +#~ "<594#audioop>`\\ )。" -#: ../../library/audioop.rst:24 -msgid "Intel/DVI ADPCM" -msgstr "Intel/DVI ADPCM" +#~ msgid "Intel/DVI ADPCM" +#~ msgstr "Intel/DVI ADPCM" -#: ../../library/audioop.rst:24 -msgid "ADPCM, Intel/DVI" -msgstr "ADPCM, Intel/DVI" +#~ msgid "ADPCM, Intel/DVI" +#~ msgstr "ADPCM, Intel/DVI" -#: ../../library/audioop.rst:24 -msgid "a-LAW" -msgstr "a-LAW" +#~ msgid "a-LAW" +#~ msgstr "a-LAW" -#: ../../library/audioop.rst:24 -msgid "u-LAW" -msgstr "u-LAW" +#~ msgid "u-LAW" +#~ msgstr "u-LAW" diff --git a/library/builtins.po b/library/builtins.po index d2a6cc577f..63621acb64 100644 --- a/library/builtins.po +++ b/library/builtins.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2024-10-28 06:59+0000\n" "PO-Revision-Date: 2022-02-15 20:55+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -25,17 +25,17 @@ msgid ":mod:`!builtins` --- Built-in objects" msgstr ":mod:`!builtins` --- 內建物件" #: ../../library/builtins.rst:9 +#, fuzzy msgid "" "This module provides direct access to all 'built-in' identifiers of Python; " "for example, ``builtins.open`` is the full name for the built-in function :" -"func:`open`. See :ref:`built-in-funcs` and :ref:`built-in-consts` for " -"documentation." +"func:`open`." msgstr "" "該模組提供對 Python 所有'內建'識別符號的直接存取;例如 ``builtins.open`` 是內" "建函式 :func:`open` 的全名。請參閱\\ :ref:`built-in-funcs`\\ 和\\ :ref:" "`built-in-consts`\\ 的文件。" -#: ../../library/builtins.rst:15 +#: ../../library/builtins.rst:12 msgid "" "This module is not normally accessed explicitly by most applications, but " "can be useful in modules that provide objects with the same name as a built-" @@ -47,7 +47,7 @@ msgstr "" "能很有用,不過其中還會需要內建該名稱。例如,在一個將內建 :func:`open` 包裝起" "來以實現另一版本 :func:`open` 函式的模組中,這個模組可以直接被使用: ::" -#: ../../library/builtins.rst:21 +#: ../../library/builtins.rst:18 msgid "" "import builtins\n" "\n" @@ -67,7 +67,7 @@ msgid "" " # ..." msgstr "" -#: ../../library/builtins.rst:38 +#: ../../library/builtins.rst:35 msgid "" "As an implementation detail, most modules have the name ``__builtins__`` " "made available as part of their globals. The value of ``__builtins__`` is " @@ -79,3 +79,19 @@ msgstr "" "以提使用。``__builtins__`` 的值通常是這個模組或者這個模組的 :attr:`~object." "__dict__` 屬性值。由於這是一個實作細節,因此 Python 的其他實作可能不會使用" "它。" + +#: ../../library/builtins.rst:43 +msgid ":ref:`built-in-consts`" +msgstr "" + +#: ../../library/builtins.rst:44 +msgid ":ref:`bltin-exceptions`" +msgstr "" + +#: ../../library/builtins.rst:45 +msgid ":ref:`built-in-funcs`" +msgstr "" + +#: ../../library/builtins.rst:46 +msgid ":ref:`bltin-types`" +msgstr "" diff --git a/library/calendar.po b/library/calendar.po index 4365ce363d..1bc71bc814 100644 --- a/library/calendar.po +++ b/library/calendar.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-02-07 08:41+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-" @@ -76,19 +76,48 @@ msgstr "" "做任何格式化,這是子類別的工作。" #: ../../library/calendar.rst:41 -msgid ":class:`Calendar` instances have the following methods:" +#, fuzzy +msgid ":class:`Calendar` instances have the following methods and attributes:" msgstr ":class:`Calendar` 實例有以下方法:" #: ../../library/calendar.rst:45 +msgid "The first weekday as an integer (0--6)." +msgstr "" + +#: ../../library/calendar.rst:47 +msgid "" +"This property can also be set and read using :meth:`~Calendar." +"setfirstweekday` and :meth:`~Calendar.getfirstweekday` respectively." +msgstr "" + +#: ../../library/calendar.rst:53 +msgid "Return an :class:`int` for the current first weekday (0--6)." +msgstr "" + +#: ../../library/calendar.rst:55 +msgid "Identical to reading the :attr:`~Calendar.firstweekday` property." +msgstr "" + +#: ../../library/calendar.rst:59 +msgid "" +"Set the first weekday to *firstweekday*, passed as an :class:`int` (0--6)" +msgstr "" + +#: ../../library/calendar.rst:61 +msgid "Identical to setting the :attr:`~Calendar.firstweekday` property." +msgstr "" + +#: ../../library/calendar.rst:65 +#, fuzzy msgid "" "Return an iterator for the week day numbers that will be used for one week. " "The first value from the iterator will be the same as the value of the :attr:" -"`firstweekday` property." +"`~Calendar.firstweekday` property." msgstr "" "回傳一個以數字代表一週的每一天的疊代器 (iterator)。疊代器的第一個值和 :attr:" "`firstweekday` 屬性的值一樣。" -#: ../../library/calendar.rst:52 +#: ../../library/calendar.rst:72 msgid "" "Return an iterator for the month *month* (1--12) in the year *year*. This " "iterator will return all days (as :class:`datetime.date` objects) for the " @@ -98,7 +127,7 @@ msgstr "" "回傳一個在 *year* 年 *month* (1--12) 月的疊代器。這個疊代器會回傳該月的所有日" "期(:class:`datetime.date` 物件)以及在該月之前及之後用來組成完整一週的日期。" -#: ../../library/calendar.rst:60 +#: ../../library/calendar.rst:80 msgid "" "Return an iterator for the month *month* in the year *year* similar to :meth:" "`itermonthdates`, but not restricted by the :class:`datetime.date` range. " @@ -109,7 +138,7 @@ msgstr "" "限於 :class:`datetime.date` 的範圍。回傳的日期單純是該月當日的數字,對於該月" "之外的日期數字會是 ``0``。" -#: ../../library/calendar.rst:68 +#: ../../library/calendar.rst:88 msgid "" "Return an iterator for the month *month* in the year *year* similar to :meth:" "`itermonthdates`, but not restricted by the :class:`datetime.date` range. " @@ -120,7 +149,7 @@ msgstr "" "限於 :class:`datetime.date` 的範圍。回傳的日期是一個由該月當日的數字及代表週" "幾的數字組成的元組。" -#: ../../library/calendar.rst:76 +#: ../../library/calendar.rst:96 msgid "" "Return an iterator for the month *month* in the year *year* similar to :meth:" "`itermonthdates`, but not restricted by the :class:`datetime.date` range. " @@ -131,7 +160,7 @@ msgstr "" "限於 :class:`datetime.date` 的範圍。回傳的日期是一個由年、月、日的數字組成的" "元組。" -#: ../../library/calendar.rst:86 +#: ../../library/calendar.rst:106 msgid "" "Return an iterator for the month *month* in the year *year* similar to :meth:" "`itermonthdates`, but not restricted by the :class:`datetime.date` range. " @@ -142,7 +171,7 @@ msgstr "" "限於 :class:`datetime.date` 的範圍。回傳的日期是一個由年、月、日及代表週幾的" "數字組成的元組。" -#: ../../library/calendar.rst:96 +#: ../../library/calendar.rst:116 msgid "" "Return a list of the weeks in the month *month* of the *year* as full " "weeks. Weeks are lists of seven :class:`datetime.date` objects." @@ -150,7 +179,7 @@ msgstr "" "回傳一個在 *year* 年 *month* 月每一週組成的串列。每一週是一個串列,包含七個 :" "class:`datetime.date` 物件。" -#: ../../library/calendar.rst:102 +#: ../../library/calendar.rst:122 msgid "" "Return a list of the weeks in the month *month* of the *year* as full " "weeks. Weeks are lists of seven tuples of day numbers and weekday numbers." @@ -158,7 +187,7 @@ msgstr "" "回傳一個在 *year* 年 *month* 月每一週組成的串列。每一週是一個串列,包含七個該" "月當日的數字及代表週幾的數字組成的元組。" -#: ../../library/calendar.rst:109 +#: ../../library/calendar.rst:129 msgid "" "Return a list of the weeks in the month *month* of the *year* as full " "weeks. Weeks are lists of seven day numbers." @@ -166,7 +195,7 @@ msgstr "" "回傳一個在 *year* 年 *month* 月每一週組成的串列。每一週是一個串列,包含七個該" "月當日的數字。" -#: ../../library/calendar.rst:115 +#: ../../library/calendar.rst:135 msgid "" "Return the data for the specified year ready for formatting. The return " "value is a list of month rows. Each month row contains up to *width* months " @@ -177,7 +206,7 @@ msgstr "" "*width* 個月份組成(預設為 3)。每個月份包含四到六週,每一週包含一到七天,每" "一天則是一個 :class:`datetime.date` 物件。" -#: ../../library/calendar.rst:123 +#: ../../library/calendar.rst:143 msgid "" "Return the data for the specified year ready for formatting (similar to :" "meth:`yeardatescalendar`). Entries in the week lists are tuples of day " @@ -186,7 +215,7 @@ msgstr "" "回傳用來格式化的指定年份的資料(類似 :meth:`yeardatescalendar`)。每一天是一" "個該月當日的數字及代表週幾的數字組成的元組,該月外的日期的該月當日數字為 0。" -#: ../../library/calendar.rst:130 +#: ../../library/calendar.rst:150 msgid "" "Return the data for the specified year ready for formatting (similar to :" "meth:`yeardatescalendar`). Entries in the week lists are day numbers. Day " @@ -195,15 +224,48 @@ msgstr "" "回傳用來格式化的指定年份的資料(類似 :meth:`yeardatescalendar`)。每一天是一" "個該月當日的數字,該月外的日期的該月當日數字為 0。" -#: ../../library/calendar.rst:137 +#: ../../library/calendar.rst:157 msgid "This class can be used to generate plain text calendars." msgstr "這個類別用來產生純文字的日曆。" -#: ../../library/calendar.rst:139 +#: ../../library/calendar.rst:159 msgid ":class:`TextCalendar` instances have the following methods:" msgstr ":class:`TextCalendar` 實例有以下方法:" -#: ../../library/calendar.rst:143 +#: ../../library/calendar.rst:164 +msgid "" +"Return a string representing a single day formatted with the given *width*. " +"If *theday* is ``0``, return a string of spaces of the specified width, " +"representing an empty day. The *weekday* parameter is unused." +msgstr "" + +#: ../../library/calendar.rst:171 +#, fuzzy +msgid "" +"Return a single week in a string with no newline. If *w* is provided, it " +"specifies the width of the date columns, which are centered. Depends on the " +"first weekday as specified in the constructor or set by the :meth:" +"`setfirstweekday` method." +msgstr "" +"以多行字串的形式回傳一個月份的日曆。如果給定 *w*,它會指定置中的日期欄的寬" +"度。如果給定 *l*,它會指定每一週使用的行數。這個日曆會依據在建構函式中指定或" +"者透過 :meth:`setfirstweekday` 方法設定的一週的第一天來輸出。" + +#: ../../library/calendar.rst:178 +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 +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 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 " @@ -215,11 +277,19 @@ msgstr "" "度。如果給定 *l*,它會指定每一週使用的行數。這個日曆會依據在建構函式中指定或" "者透過 :meth:`setfirstweekday` 方法設定的一週的第一天來輸出。" -#: ../../library/calendar.rst:152 +#: ../../library/calendar.rst:198 +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 " +"*theyear* and *themonth* parameters specify the year and month for the name " +"to be formatted respectively." +msgstr "" + +#: ../../library/calendar.rst:205 msgid "Print a month's calendar as returned by :meth:`formatmonth`." msgstr "印出一個月份的日曆,內容和 :meth:`formatmonth` 回傳的一樣。" -#: ../../library/calendar.rst:157 +#: ../../library/calendar.rst:210 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 " @@ -233,20 +303,20 @@ msgstr "" "者透過 :meth:`setfirstweekday` 方法設定的一週的第一天來輸出。最早可以產生日曆" "的年份會依據平台而不同。" -#: ../../library/calendar.rst:167 +#: ../../library/calendar.rst:220 msgid "" "Print the calendar for an entire year as returned by :meth:`formatyear`." msgstr "印出一整年的日曆,內容和 :meth:`formatyear` 回傳的一樣。" -#: ../../library/calendar.rst:172 +#: ../../library/calendar.rst:225 msgid "This class can be used to generate HTML calendars." msgstr "這個類別用來產生 HTML 日曆。" -#: ../../library/calendar.rst:175 +#: ../../library/calendar.rst:228 msgid ":class:`!HTMLCalendar` instances have the following methods:" msgstr ":class:`!HTMLCalendar` 實例有以下方法:" -#: ../../library/calendar.rst:179 +#: ../../library/calendar.rst:232 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." @@ -254,14 +324,14 @@ msgstr "" "以 HTML 表格的形式回傳一個月份的日曆。如果 *withyear* 是 true 則標題會包含年" "份,否則只會有月份名稱。" -#: ../../library/calendar.rst:186 +#: ../../library/calendar.rst:239 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:192 +#: ../../library/calendar.rst:245 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 " @@ -273,7 +343,7 @@ msgstr "" "月。*css* 是要使用的 CSS (cascading style sheet) 名稱,可以給 :const:`None` " "表示不使用任何 CSS。*encoding* 指定輸出使用的編碼(預設使用系統預設編碼)。" -#: ../../library/calendar.rst:201 +#: ../../library/calendar.rst:254 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." @@ -281,28 +351,28 @@ msgstr "" "以 HTML 表列的形式回傳一個月份的名稱。如果 *withyear* 是 true 則該列會包含年" "份,否則只會有月份名稱。" -#: ../../library/calendar.rst:206 +#: ../../library/calendar.rst:259 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:211 +#: ../../library/calendar.rst:264 msgid "" "A list of CSS classes used for each weekday. The default class list is::" msgstr "對應一週每一天 CSS 類別的串列。預設的串列內容為: ::" -#: ../../library/calendar.rst:213 +#: ../../library/calendar.rst:266 msgid "" "cssclasses = [\"mon\", \"tue\", \"wed\", \"thu\", \"fri\", \"sat\", \"sun\"]" msgstr "" "cssclasses = [\"mon\", \"tue\", \"wed\", \"thu\", \"fri\", \"sat\", \"sun\"]" -#: ../../library/calendar.rst:215 +#: ../../library/calendar.rst:268 msgid "more styles can be added for each day::" msgstr "可以針對每一天增加更多樣式: ::" -#: ../../library/calendar.rst:217 +#: ../../library/calendar.rst:270 msgid "" "cssclasses = [\"mon text-bold\", \"tue\", \"wed\", \"thu\", \"fri\", " "\"sat\", \"sun red\"]" @@ -310,15 +380,15 @@ msgstr "" "cssclasses = [\"mon text-bold\", \"tue\", \"wed\", \"thu\", \"fri\", " "\"sat\", \"sun red\"]" -#: ../../library/calendar.rst:219 +#: ../../library/calendar.rst:272 msgid "Note that the length of this list must be seven items." msgstr "注意這個串列的長度必須是七個項目。" -#: ../../library/calendar.rst:224 +#: ../../library/calendar.rst:277 msgid "The CSS class for a weekday occurring in the previous or coming month." msgstr "跟當月為同一週且屬於前一個或下一個月份的日期使用的 CSS 類別。" -#: ../../library/calendar.rst:231 +#: ../../library/calendar.rst:284 msgid "" "A list of CSS classes used for weekday names in the header row. The default " "is the same as :attr:`cssclasses`." @@ -326,7 +396,7 @@ msgstr "" "在標題列中一週每一天名稱的 CSS 類別的串列。預設內容和 :attr:`cssclasses` 相" "同。" -#: ../../library/calendar.rst:239 +#: ../../library/calendar.rst:292 msgid "" "The month's head CSS class (used by :meth:`formatmonthname`). The default " "value is ``\"month\"``." @@ -334,7 +404,7 @@ msgstr "" "月份標題的 CSS 類別(由 :meth:`formatmonthname` 所使用),預設值是 " "``\"month\"``。" -#: ../../library/calendar.rst:247 +#: ../../library/calendar.rst:300 msgid "" "The CSS class for the whole month's table (used by :meth:`formatmonth`). The " "default value is ``\"month\"``." @@ -342,14 +412,14 @@ msgstr "" "整個月份表格的 CSS 類別(由 :meth:`formatmonth` 所使用),預設值是 " "``\"month\"``。" -#: ../../library/calendar.rst:255 +#: ../../library/calendar.rst:308 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:263 +#: ../../library/calendar.rst:316 msgid "" "The CSS class for the table head for the whole year (used by :meth:" "`formatyear`). The default value is ``\"year\"``." @@ -357,7 +427,7 @@ msgstr "" "整年表格標題的 CSS 類別(由 :meth:`formatyear` 所使用),預設值是 " "``\"year\"``。" -#: ../../library/calendar.rst:269 +#: ../../library/calendar.rst:322 msgid "" "Note that although the naming for the above described class attributes is " "singular (e.g. ``cssclass_month`` ``cssclass_noday``), one can replace the " @@ -367,15 +437,15 @@ msgstr "" "``cssclass_noday``),你可以使用多個以空格隔開的 CSS 類別取代單一 CSS 類別," "例如: ::" -#: ../../library/calendar.rst:273 +#: ../../library/calendar.rst:326 msgid "\"text-bold text-red\"" msgstr "\"text-bold text-red\"" -#: ../../library/calendar.rst:275 +#: ../../library/calendar.rst:328 msgid "Here is an example how :class:`!HTMLCalendar` can be customized::" msgstr "以下是客製化 :class:`!HTMLCalendar` 的範例: ::" -#: ../../library/calendar.rst:277 +#: ../../library/calendar.rst:330 msgid "" "class CustomHTMLCal(calendar.HTMLCalendar):\n" " cssclasses = [style + \" text-nowrap\" for style in\n" @@ -391,7 +461,7 @@ msgstr "" " cssclass_month = \"text-center month\"\n" " cssclass_year = \"text-italic lead\"" -#: ../../library/calendar.rst:287 +#: ../../library/calendar.rst:340 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." @@ -399,7 +469,7 @@ msgstr "" ":class:`TextCalendar` 的子類別,可以在建構函式傳入語系名稱,它會回傳指定語系" "的月份及一週每一天的名稱。" -#: ../../library/calendar.rst:293 +#: ../../library/calendar.rst:346 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." @@ -407,7 +477,7 @@ msgstr "" ":class:`HTMLCalendar` 的子類別,可以在建構函式傳入語系名稱,它會回傳指定語系" "的月份及一週每一天的名稱。" -#: ../../library/calendar.rst:299 +#: ../../library/calendar.rst:352 msgid "" "The constructor, :meth:`!formatweekday` and :meth:`!formatmonthname` methods " "of these two classes temporarily change the ``LC_TIME`` locale to the given " @@ -418,11 +488,11 @@ msgstr "" "會把 ``LC_TIME`` 語系暫時改成給定的 *locale*。因為目前的語系是屬於整個行程 " "(process-wide) 的設定,它們不是執行緒安全的。" -#: ../../library/calendar.rst:305 +#: ../../library/calendar.rst:358 msgid "For simple text calendars this module provides the following functions." msgstr "這個模組提供以下函式給單純的文字日曆使用。" -#: ../../library/calendar.rst:309 +#: ../../library/calendar.rst:362 msgid "" "Sets the weekday (``0`` is Monday, ``6`` is Sunday) to start each week. The " "values :const:`MONDAY`, :const:`TUESDAY`, :const:`WEDNESDAY`, :const:" @@ -433,7 +503,7 @@ msgstr "" "`TUESDAY`、:const:`WEDNESDAY`、:const:`THURSDAY`、:const:`FRIDAY`、:const:" "`SATURDAY` 及 :const:`SUNDAY` 可以方便設定。例如設定一週的第一天為週日: ::" -#: ../../library/calendar.rst:314 +#: ../../library/calendar.rst:367 msgid "" "import calendar\n" "calendar.setfirstweekday(calendar.SUNDAY)" @@ -441,27 +511,27 @@ msgstr "" "import calendar\n" "calendar.setfirstweekday(calendar.SUNDAY)" -#: ../../library/calendar.rst:320 +#: ../../library/calendar.rst:373 msgid "Returns the current setting for the weekday to start each week." msgstr "回傳目前設定的一週的第一天。" -#: ../../library/calendar.rst:325 +#: ../../library/calendar.rst:378 msgid "" "Returns :const:`True` if *year* is a leap year, otherwise :const:`False`." msgstr "如果 *year* 是閏年回傳 :const:`True`,否則回傳 :const:`False`。" -#: ../../library/calendar.rst:330 +#: ../../library/calendar.rst:383 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:333 +#: ../../library/calendar.rst:386 msgid "This function works for ranges spanning a century change." msgstr "這個函式也適用在跨越世紀的時間範圍。" -#: ../../library/calendar.rst:338 +#: ../../library/calendar.rst:391 msgid "" "Returns the day of the week (``0`` is Monday) for *year* (``1970``--...), " "*month* (``1``--``12``), *day* (``1``--``31``)." @@ -469,19 +539,19 @@ msgstr "" "回傳 *year* 年 (``1970``--...) *month* 月 (``1``--``12``) *day* 日 (``1``--" "``31``) 是週幾(``0`` 是星期一)。" -#: ../../library/calendar.rst:344 +#: ../../library/calendar.rst:397 msgid "" "Return a header containing abbreviated weekday names. *n* specifies the " "width in characters for one weekday." msgstr "回傳包含一週每一天的名稱縮寫的標題。*n* 指定每一天的字元寬度。" -#: ../../library/calendar.rst:350 +#: ../../library/calendar.rst:403 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:356 +#: ../../library/calendar.rst:409 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 " @@ -490,11 +560,11 @@ msgstr "" "回傳代表一個月份日曆的矩陣。每一列為一週;該月以外的日期以 0 表示。每一週以週" "一開始,除非有使用 :func:`setfirstweekday` 改變設定。" -#: ../../library/calendar.rst:363 +#: ../../library/calendar.rst:416 msgid "Prints a month's calendar as returned by :func:`month`." msgstr "印出一個月份的日曆,跟 :func:`month` 回傳的內容一樣。" -#: ../../library/calendar.rst:368 +#: ../../library/calendar.rst:421 msgid "" "Returns a month's calendar in a multi-line string using the :meth:" "`~TextCalendar.formatmonth` of the :class:`TextCalendar` class." @@ -502,12 +572,12 @@ msgstr "" "以多行字串的形式回傳一個月的日曆,使用 :class:`TextCalendar` 類別的 :meth:" "`~TextCalendar.formatmonth`。" -#: ../../library/calendar.rst:374 +#: ../../library/calendar.rst:427 msgid "" "Prints the calendar for an entire year as returned by :func:`calendar`." msgstr "印出一整年的日曆,跟 :func:`calendar` 回傳的內容一樣。" -#: ../../library/calendar.rst:379 +#: ../../library/calendar.rst:432 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." @@ -515,7 +585,7 @@ msgstr "" "以多行字串回傳三欄形式的一整年日曆,使用 :class:`TextCalendar` 類別的 :meth:" "`~TextCalendar.formatyear`。" -#: ../../library/calendar.rst:385 +#: ../../library/calendar.rst:438 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 " @@ -527,27 +597,31 @@ msgstr "" "gmtime` 函式回傳的元組,並回傳對應的 Unix 時間戳,假設從 1970 開始及 POSIX 編" "碼。事實上,:func:`time.gmtime` 和 :func:`timegm` 是彼此相反的。" -#: ../../library/calendar.rst:392 +#: ../../library/calendar.rst:445 msgid "The :mod:`calendar` module exports the following data attributes:" msgstr ":mod:`calendar` 模組匯出以下資料屬性:" -#: ../../library/calendar.rst:396 -msgid "An array that represents the days of the week in the current locale." +#: ../../library/calendar.rst:449 +#, fuzzy +msgid "" +"A sequence that represents the days of the week in the current locale, where " +"Monday is day number 0." msgstr "以目前語系來表示的一週每一天名稱的陣列。" -#: ../../library/calendar.rst:401 +#: ../../library/calendar.rst:459 +#, fuzzy msgid "" -"An array that represents the abbreviated days of the week in the current " -"locale." +"A sequence that represents the abbreviated days of the week in the current " +"locale, where Mon is day number 0." msgstr "以目前語系來表示的一週每一天縮寫名稱的陣列。" -#: ../../library/calendar.rst:412 +#: ../../library/calendar.rst:474 msgid "" "Aliases for the days of the week, where ``MONDAY`` is ``0`` and ``SUNDAY`` " "is ``6``." msgstr "一週每一天的別名,其中 ``MONDAY`` 是 ``0`` 而 ``SUNDAY`` 是 ``6``。" -#: ../../library/calendar.rst:420 +#: ../../library/calendar.rst:482 msgid "" "Enumeration defining days of the week as integer constants. The members of " "this enumeration are exported to the module scope as :data:`MONDAY` through :" @@ -556,32 +630,34 @@ msgstr "" "將一週中的幾天定義為整數常數的列舉。此列舉的成員將作為 :data:`MONDAY` 到 :" "data:`SUNDAY` 匯出到模組作用域。" -#: ../../library/calendar.rst:429 +#: ../../library/calendar.rst:491 +#, fuzzy msgid "" -"An array 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 " -"length of 13 and ``month_name[0]`` is the empty string." +"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 " +"length of 13 and ``month_name[0]`` is the empty string." msgstr "" "以目前語系來表示的一年每個月份名稱的陣列。它按照一般慣例以數字 1 代表一月,因" "此它的長度為 13,而 ``month_name[0]`` 是空字串。" -#: ../../library/calendar.rst:436 +#: ../../library/calendar.rst:502 +#, fuzzy msgid "" -"An array that represents the abbreviated months of the year in the current " +"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 " "it has a length of 13 and ``month_abbr[0]`` is the empty string." msgstr "" "以目前語系來表示的一年每個月份縮寫名稱的陣列。它按照一般慣例以數字 1 代表一" "月,因此它的長度為 13,而 ``month_abbr[0]`` 是空字串。" -#: ../../library/calendar.rst:454 +#: ../../library/calendar.rst:523 msgid "" "Aliases for the months of the year, where ``JANUARY`` is ``1`` and " "``DECEMBER`` is ``12``." msgstr "" "一年內每個月的別名,其中 ``JANUARY`` 是 ``ㄅ`` 而 ``DECEMBER`` 是 ``12``。" -#: ../../library/calendar.rst:462 +#: ../../library/calendar.rst:531 msgid "" "Enumeration defining months of the year as integer constants. The members of " "this enumeration are exported to the module scope as :data:`JANUARY` " @@ -590,61 +666,61 @@ msgstr "" "將一年中的月份定義為整數常數的列舉。此列舉的成員將作為 :data:`JANUARY` 到 :" "data:`DECEMBER` 匯出到模組作用域。" -#: ../../library/calendar.rst:469 +#: ../../library/calendar.rst:538 msgid "The :mod:`calendar` module defines the following exceptions:" msgstr ":mod:`calendar` 模組定義了以下例外:" -#: ../../library/calendar.rst:473 +#: ../../library/calendar.rst:542 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:478 +#: ../../library/calendar.rst:547 msgid "The invalid month number." msgstr "無效的月份號。" -#: ../../library/calendar.rst:483 +#: ../../library/calendar.rst:552 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:488 +#: ../../library/calendar.rst:557 msgid "The invalid weekday number." msgstr "無效的週幾編號。" -#: ../../library/calendar.rst:493 +#: ../../library/calendar.rst:562 msgid "Module :mod:`datetime`" msgstr ":mod:`datetime` 模組" -#: ../../library/calendar.rst:494 +#: ../../library/calendar.rst:563 msgid "" "Object-oriented interface to dates and times with similar functionality to " "the :mod:`time` module." msgstr "日期與時間的物件導向介面,和 :mod:`time` 模組有相似的功能。" -#: ../../library/calendar.rst:497 +#: ../../library/calendar.rst:566 msgid "Module :mod:`time`" msgstr ":mod:`time` 模組" -#: ../../library/calendar.rst:498 +#: ../../library/calendar.rst:567 msgid "Low-level time related functions." msgstr "底層的時間相關函式。" -#: ../../library/calendar.rst:504 +#: ../../library/calendar.rst:573 msgid "Command-Line Usage" msgstr "命令列用法" -#: ../../library/calendar.rst:508 +#: ../../library/calendar.rst:577 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:511 +#: ../../library/calendar.rst:580 #, fuzzy msgid "" "python -m calendar [-h] [-L LOCALE] [-e ENCODING] [-t {text,html}]\n" @@ -655,11 +731,11 @@ msgstr "" " [-w WIDTH] [-l LINES] [-s SPACING] [-m MONTHS] [-c CSS]\n" " [year] [month]" -#: ../../library/calendar.rst:518 +#: ../../library/calendar.rst:587 msgid "For example, to print a calendar for the year 2000:" msgstr "例如,要列印 2000 年的日曆:" -#: ../../library/calendar.rst:520 +#: ../../library/calendar.rst:589 msgid "" "$ python -m calendar 2000\n" " 2000\n" @@ -737,42 +813,42 @@ 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:561 +#: ../../library/calendar.rst:630 msgid "The following options are accepted:" msgstr "接受以下選項:" -#: ../../library/calendar.rst:568 +#: ../../library/calendar.rst:637 msgid "Show the help message and exit." msgstr "顯示幫助訊息並退出。" -#: ../../library/calendar.rst:573 +#: ../../library/calendar.rst:642 msgid "The locale to use for month and weekday names. Defaults to English." msgstr "用於月份和週幾名稱的語系。預設為英語。" -#: ../../library/calendar.rst:579 +#: ../../library/calendar.rst:648 msgid "" "The encoding to use for output. :option:`--encoding` is required if :option:" "`--locale` is set." msgstr "" "用於輸出的編碼。如有設定 :option:`--locale` 則必須給定 :option:`--encoding`。" -#: ../../library/calendar.rst:585 +#: ../../library/calendar.rst:654 msgid "Print the calendar to the terminal as text, or as an HTML document." msgstr "將日曆以文字或 HTML 文件的形式印出到終端機。" -#: ../../library/calendar.rst:591 +#: ../../library/calendar.rst:660 #, fuzzy msgid "" "The weekday to start each week. Must be a number between 0 (Monday) and 6 " "(Sunday). Defaults to 0." msgstr "印出日曆的年份。必須是 1 到 9999 之間的數字。預設為當前年份。" -#: ../../library/calendar.rst:599 +#: ../../library/calendar.rst:668 #, fuzzy msgid "The year to print the calendar for. Defaults to the current year." msgstr "印出日曆的年份。必須是 1 到 9999 之間的數字。預設為當前年份。" -#: ../../library/calendar.rst:605 +#: ../../library/calendar.rst:674 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 " @@ -781,11 +857,11 @@ msgstr "" "要列印日曆的指定 :option:`year` 的月份。必須是 1 到 12 之間的數字,並且只能在" "文字模式下使用。預設列印全年日曆。" -#: ../../library/calendar.rst:611 +#: ../../library/calendar.rst:680 msgid "*Text-mode options:*" msgstr "*文字模式選項:*" -#: ../../library/calendar.rst:615 +#: ../../library/calendar.rst:684 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." @@ -793,7 +869,7 @@ msgstr "" "終端機行中日期行的寬度。日期印出在行的中央。任何小於 2 的值都會被忽略。預設" "為 2。" -#: ../../library/calendar.rst:623 +#: ../../library/calendar.rst:692 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." @@ -801,21 +877,21 @@ msgstr "" "終端機列中每週的列數。日期印出時頂部會對齊。任何小於 1 的值都會被忽略。預設" "為 1。" -#: ../../library/calendar.rst:631 +#: ../../library/calendar.rst:700 msgid "" "The space between months in columns. Any value lower than 2 is ignored. " "Defaults to 6." msgstr "行中月份之間的間距。任何小於 2 的值都會被忽略。預設為 6。" -#: ../../library/calendar.rst:638 +#: ../../library/calendar.rst:707 msgid "The number of months printed per row. Defaults to 3." msgstr "每列印出的月份數量。預設為 3。" -#: ../../library/calendar.rst:642 +#: ../../library/calendar.rst:711 msgid "*HTML-mode options:*" msgstr "*HTML 模式選項:*" -#: ../../library/calendar.rst:646 +#: ../../library/calendar.rst:715 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 8f7890bfa5..cecddac9d7 100644 --- a/library/cgi.po +++ b/library/cgi.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2024-11-20 09:21+0000\n" "PO-Revision-Date: 2022-05-22 02:01+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -19,871 +19,174 @@ msgstr "" "X-Generator: Poedit 3.0.1\n" #: ../../library/cgi.rst:2 -msgid ":mod:`cgi` --- Common Gateway Interface support" +#, fuzzy +msgid ":mod:`!cgi` --- Common Gateway Interface support" msgstr ":mod:`cgi` --- 通用閘道器介面支援" -#: ../../library/cgi.rst:8 -msgid "**Source code:** :source:`Lib/cgi.py`" -msgstr "**原始碼:**\\ :source:`Lib/cgi.py`" - -#: ../../library/cgi.rst:18 -msgid "" -"The :mod:`cgi` module is deprecated (see :pep:`PEP 594 <594#cgi>` for " -"details and alternatives)." -msgstr "" -":mod:`cgi` 模組 (module) 即將被棄用(詳情與替代方案請見 :pep:`PEP 594 " -"<594#cgi>`\\ )。" - -#: ../../library/cgi.rst:22 -msgid "" -"The :class:`FieldStorage` class can typically be replaced with :func:`urllib." -"parse.parse_qsl` for ``GET`` and ``HEAD`` requests, and the :mod:`email." -"message` module or :pypi:`multipart` for ``POST`` and ``PUT``. Most :ref:" -"`utility functions ` have replacements." -msgstr "" - -#: ../../library/cgi.rst:30 -msgid "Support module for Common Gateway Interface (CGI) scripts." -msgstr "" - -#: ../../library/cgi.rst:32 -msgid "" -"This module defines a number of utilities for use by CGI scripts written in " -"Python." -msgstr "" - -#: ../../library/cgi.rst:35 -msgid "" -"The global variable ``maxlen`` can be set to an integer indicating the " -"maximum size of a POST request. POST requests larger than this size will " -"result in a :exc:`ValueError` being raised during parsing. The default value " -"of this variable is ``0``, meaning the request size is unlimited." -msgstr "" - -#: ../../includes/wasm-notavail.rst:3 -msgid ":ref:`Availability `: not Emscripten, not WASI." -msgstr "" - -#: ../../includes/wasm-notavail.rst:5 -msgid "" -"This module does not work or is not available on WebAssembly platforms " -"``wasm32-emscripten`` and ``wasm32-wasi``. See :ref:`wasm-availability` for " -"more information." -msgstr "" -"此模組在 WebAssembly 平台 ``wasm32-emscripten`` 和 ``wasm32-wasi`` 上無法作用" -"或無法使用。有關更多資訊,請參閱 :ref:`wasm-availability`。" - -#: ../../library/cgi.rst:43 -msgid "Introduction" -msgstr "簡介" - -#: ../../library/cgi.rst:47 -msgid "" -"A CGI script is invoked by an HTTP server, usually to process user input " -"submitted through an HTML ``
`` or ```` element." -msgstr "" - -#: ../../library/cgi.rst:50 -msgid "" -"Most often, CGI scripts live in the server's special :file:`cgi-bin` " -"directory. The HTTP server places all sorts of information about the request " -"(such as the client's hostname, the requested URL, the query string, and " -"lots of other goodies) in the script's shell environment, executes the " -"script, and sends the script's output back to the client." -msgstr "" - -#: ../../library/cgi.rst:56 -msgid "" -"The script's input is connected to the client too, and sometimes the form " -"data is read this way; at other times the form data is passed via the " -"\"query string\" part of the URL. This module is intended to take care of " -"the different cases and provide a simpler interface to the Python script. " -"It also provides a number of utilities that help in debugging scripts, and " -"the latest addition is support for file uploads from a form (if your browser " -"supports it)." -msgstr "" - -#: ../../library/cgi.rst:63 -msgid "" -"The output of a CGI script should consist of two sections, separated by a " -"blank line. The first section contains a number of headers, telling the " -"client what kind of data is following. Python code to generate a minimal " -"header section looks like this::" -msgstr "" - -#: ../../library/cgi.rst:68 -msgid "" -"print(\"Content-Type: text/html\") # HTML is following\n" -"print() # blank line, end of headers" -msgstr "" - -#: ../../library/cgi.rst:71 -msgid "" -"The second section is usually HTML, which allows the client software to " -"display nicely formatted text with header, in-line images, etc. Here's " -"Python code that prints a simple piece of HTML::" -msgstr "" - -#: ../../library/cgi.rst:75 -msgid "" -"print(\"CGI script output\")\n" -"print(\"

This is my first CGI script

\")\n" -"print(\"Hello, world!\")" -msgstr "" -"print(\"CGI script output\")\n" -"print(\"

This is my first CGI script

\")\n" -"print(\"Hello, world!\")" - -#: ../../library/cgi.rst:83 -msgid "Using the cgi module" -msgstr "使用 cgi 模組" - -#: ../../library/cgi.rst:85 -msgid "Begin by writing ``import cgi``." -msgstr "" - -#: ../../library/cgi.rst:87 -msgid "When you write a new script, consider adding these lines::" -msgstr "" - -#: ../../library/cgi.rst:89 ../../library/cgi.rst:505 -msgid "" -"import cgitb\n" -"cgitb.enable()" -msgstr "" -"import cgitb\n" -"cgitb.enable()" - -#: ../../library/cgi.rst:92 -msgid "" -"This activates a special exception handler that will display detailed " -"reports in the web browser if any errors occur. If you'd rather not show " -"the guts of your program to users of your script, you can have the reports " -"saved to files instead, with code like this::" -msgstr "" - -#: ../../library/cgi.rst:97 -msgid "" -"import cgitb\n" -"cgitb.enable(display=0, logdir=\"/path/to/logdir\")" -msgstr "" -"import cgitb\n" -"cgitb.enable(display=0, logdir=\"/path/to/logdir\")" - -#: ../../library/cgi.rst:100 -msgid "" -"It's very helpful to use this feature during script development. The reports " -"produced by :mod:`cgitb` provide information that can save you a lot of time " -"in tracking down bugs. You can always remove the ``cgitb`` line later when " -"you have tested your script and are confident that it works correctly." -msgstr "" - -#: ../../library/cgi.rst:105 -msgid "" -"To get at submitted form data, use the :class:`FieldStorage` class. If the " -"form contains non-ASCII characters, use the *encoding* keyword parameter set " -"to the value of the encoding defined for the document. It is usually " -"contained in the META tag in the HEAD section of the HTML document or by " -"the :mailheader:`Content-Type` header. This reads the form contents from " -"the standard input or the environment (depending on the value of various " -"environment variables set according to the CGI standard). Since it may " -"consume standard input, it should be instantiated only once." -msgstr "" - -#: ../../library/cgi.rst:114 -msgid "" -"The :class:`FieldStorage` instance can be indexed like a Python dictionary. " -"It allows membership testing with the :keyword:`in` operator, and also " -"supports the standard dictionary method :meth:`~dict.keys` and the built-in " -"function :func:`len`. Form fields containing empty strings are ignored and " -"do not appear in the dictionary; to keep such values, provide a true value " -"for the optional *keep_blank_values* keyword parameter when creating the :" -"class:`FieldStorage` instance." -msgstr "" - -#: ../../library/cgi.rst:122 -msgid "" -"For instance, the following code (which assumes that the :mailheader:" -"`Content-Type` header and blank line have already been printed) checks that " -"the fields ``name`` and ``addr`` are both set to a non-empty string::" -msgstr "" - -#: ../../library/cgi.rst:127 -msgid "" -"form = cgi.FieldStorage()\n" -"if \"name\" not in form or \"addr\" not in form:\n" -" print(\"

Error

\")\n" -" print(\"Please fill in the name and addr fields.\")\n" -" return\n" -"print(\"

name:\", form[\"name\"].value)\n" -"print(\"

addr:\", form[\"addr\"].value)\n" -"...further form processing here..." -msgstr "" - -#: ../../library/cgi.rst:136 -msgid "" -"Here the fields, accessed through ``form[key]``, are themselves instances " -"of :class:`FieldStorage` (or :class:`MiniFieldStorage`, depending on the " -"form encoding). The :attr:`~FieldStorage.value` attribute of the instance " -"yields the string value of the field. The :meth:`~FieldStorage.getvalue` " -"method returns this string value directly; it also accepts an optional " -"second argument as a default to return if the requested key is not present." -msgstr "" - -#: ../../library/cgi.rst:143 -msgid "" -"If the submitted form data contains more than one field with the same name, " -"the object retrieved by ``form[key]`` is not a :class:`FieldStorage` or :" -"class:`MiniFieldStorage` instance but a list of such instances. Similarly, " -"in this situation, ``form.getvalue(key)`` would return a list of strings. If " -"you expect this possibility (when your HTML form contains multiple fields " -"with the same name), use the :meth:`~FieldStorage.getlist` method, which " -"always returns a list of values (so that you do not need to special-case the " -"single item case). For example, this code concatenates any number of " -"username fields, separated by commas::" -msgstr "" - -#: ../../library/cgi.rst:153 -msgid "" -"value = form.getlist(\"username\")\n" -"usernames = \",\".join(value)" -msgstr "" -"value = form.getlist(\"username\")\n" -"usernames = \",\".join(value)" - -#: ../../library/cgi.rst:156 -msgid "" -"If a field represents an uploaded file, accessing the value via the :attr:" -"`~FieldStorage.value` attribute or the :meth:`~FieldStorage.getvalue` method " -"reads the entire file in memory as bytes. This may not be what you want. " -"You can test for an uploaded file by testing either the :attr:`~FieldStorage." -"filename` attribute or the :attr:`~FieldStorage.file` attribute. You can " -"then read the data from the :attr:`!file` attribute before it is " -"automatically closed as part of the garbage collection of the :class:" -"`FieldStorage` instance (the :func:`~io.RawIOBase.read` and :func:`~io." -"IOBase.readline` methods will return bytes)::" -msgstr "" - -#: ../../library/cgi.rst:167 -msgid "" -"fileitem = form[\"userfile\"]\n" -"if fileitem.file:\n" -" # It's an uploaded file; count lines\n" -" linecount = 0\n" -" while True:\n" -" line = fileitem.file.readline()\n" -" if not line: break\n" -" linecount = linecount + 1" -msgstr "" - -#: ../../library/cgi.rst:176 -msgid "" -":class:`FieldStorage` objects also support being used in a :keyword:`with` " -"statement, which will automatically close them when done." -msgstr "" - -#: ../../library/cgi.rst:179 -msgid "" -"If an error is encountered when obtaining the contents of an uploaded file " -"(for example, when the user interrupts the form submission by clicking on a " -"Back or Cancel button) the :attr:`~FieldStorage.done` attribute of the " -"object for the field will be set to the value -1." -msgstr "" - -#: ../../library/cgi.rst:184 -msgid "" -"The file upload draft standard entertains the possibility of uploading " -"multiple files from one field (using a recursive :mimetype:`multipart/\\*` " -"encoding). When this occurs, the item will be a dictionary-like :class:" -"`FieldStorage` item. This can be determined by testing its :attr:`!type` " -"attribute, which should be :mimetype:`multipart/form-data` (or perhaps " -"another MIME type matching :mimetype:`multipart/\\*`). In this case, it can " -"be iterated over recursively just like the top-level form object." -msgstr "" - -#: ../../library/cgi.rst:192 -msgid "" -"When a form is submitted in the \"old\" format (as the query string or as a " -"single data part of type :mimetype:`application/x-www-form-urlencoded`), the " -"items will actually be instances of the class :class:`MiniFieldStorage`. In " -"this case, the :attr:`!list`, :attr:`!file`, and :attr:`filename` attributes " -"are always ``None``." -msgstr "" - -#: ../../library/cgi.rst:197 -msgid "" -"A form submitted via POST that also has a query string will contain both :" -"class:`FieldStorage` and :class:`MiniFieldStorage` items." -msgstr "" - -#: ../../library/cgi.rst:200 -msgid "" -"The :attr:`~FieldStorage.file` attribute is automatically closed upon the " -"garbage collection of the creating :class:`FieldStorage` instance." -msgstr "" - -#: ../../library/cgi.rst:204 -msgid "" -"Added support for the context management protocol to the :class:" -"`FieldStorage` class." -msgstr "" - -#: ../../library/cgi.rst:210 -msgid "Higher Level Interface" -msgstr "" - -#: ../../library/cgi.rst:212 -msgid "" -"The previous section explains how to read CGI form data using the :class:" -"`FieldStorage` class. This section describes a higher level interface which " -"was added to this class to allow one to do it in a more readable and " -"intuitive way. The interface doesn't make the techniques described in " -"previous sections obsolete --- they are still useful to process file uploads " -"efficiently, for example." -msgstr "" - -#: ../../library/cgi.rst:221 -msgid "" -"The interface consists of two simple methods. Using the methods you can " -"process form data in a generic way, without the need to worry whether only " -"one or more values were posted under one name." -msgstr "" - -#: ../../library/cgi.rst:225 -msgid "" -"In the previous section, you learned to write following code anytime you " -"expected a user to post more than one value under one name::" -msgstr "" - -#: ../../library/cgi.rst:228 -msgid "" -"item = form.getvalue(\"item\")\n" -"if isinstance(item, list):\n" -" # The user is requesting more than one item.\n" -"else:\n" -" # The user is requesting only one item." -msgstr "" - -#: ../../library/cgi.rst:234 -msgid "" -"This situation is common for example when a form contains a group of " -"multiple checkboxes with the same name::" -msgstr "" - -#: ../../library/cgi.rst:237 -msgid "" -"\n" -"" -msgstr "" -"\n" -"" - -#: ../../library/cgi.rst:240 -msgid "" -"In most situations, however, there's only one form control with a particular " -"name in a form and then you expect and need only one value associated with " -"this name. So you write a script containing for example this code::" -msgstr "" - -#: ../../library/cgi.rst:244 -msgid "user = form.getvalue(\"user\").upper()" -msgstr "user = form.getvalue(\"user\").upper()" - -#: ../../library/cgi.rst:246 -msgid "" -"The problem with the code is that you should never expect that a client will " -"provide valid input to your scripts. For example, if a curious user appends " -"another ``user=foo`` pair to the query string, then the script would crash, " -"because in this situation the ``getvalue(\"user\")`` method call returns a " -"list instead of a string. Calling the :meth:`~str.upper` method on a list " -"is not valid (since lists do not have a method of this name) and results in " -"an :exc:`AttributeError` exception." -msgstr "" - -#: ../../library/cgi.rst:254 -msgid "" -"Therefore, the appropriate way to read form data values was to always use " -"the code which checks whether the obtained value is a single value or a list " -"of values. That's annoying and leads to less readable scripts." -msgstr "" - -#: ../../library/cgi.rst:258 -msgid "" -"A more convenient approach is to use the methods :meth:`~FieldStorage." -"getfirst` and :meth:`~FieldStorage.getlist` provided by this higher level " -"interface." -msgstr "" - -#: ../../library/cgi.rst:264 -msgid "" -"This method always returns only one value associated with form field *name*. " -"The method returns only the first value in case that more values were posted " -"under such name. Please note that the order in which the values are " -"received may vary from browser to browser and should not be counted on. " -"[#]_ If no such form field or value exists then the method returns the " -"value specified by the optional parameter *default*. This parameter " -"defaults to ``None`` if not specified." -msgstr "" - -#: ../../library/cgi.rst:275 -msgid "" -"This method always returns a list of values associated with form field " -"*name*. The method returns an empty list if no such form field or value " -"exists for *name*. It returns a list consisting of one item if only one " -"such value exists." -msgstr "" - -#: ../../library/cgi.rst:279 -msgid "Using these methods you can write nice compact code::" -msgstr "" - -#: ../../library/cgi.rst:281 -msgid "" -"import cgi\n" -"form = cgi.FieldStorage()\n" -"user = form.getfirst(\"user\", \"\").upper() # This way it's safe.\n" -"for item in form.getlist(\"item\"):\n" -" do_something(item)" -msgstr "" -"import cgi\n" -"form = cgi.FieldStorage()\n" -"user = form.getfirst(\"user\", \"\").upper() # 這是安全的方式。\n" -"for item in form.getlist(\"item\"):\n" -" do_something(item)" - -#: ../../library/cgi.rst:291 -msgid "Functions" -msgstr "函式" - -#: ../../library/cgi.rst:293 -msgid "" -"These are useful if you want more control, or if you want to employ some of " -"the algorithms implemented in this module in other circumstances." -msgstr "" - -#: ../../library/cgi.rst:299 -msgid "" -"Parse a query in the environment or from a file (the file defaults to ``sys." -"stdin``). The *keep_blank_values*, *strict_parsing* and *separator* " -"parameters are passed to :func:`urllib.parse.parse_qs` unchanged." -msgstr "" - -#: ../../library/cgi.rst:303 -msgid "" -"This function, like the rest of the :mod:`cgi` module, is deprecated. It can " -"be replaced by calling :func:`urllib.parse.parse_qs` directly on the desired " -"query string (except for ``multipart/form-data`` input, which can be handled " -"as described for :func:`parse_multipart`)." -msgstr "" - -#: ../../library/cgi.rst:312 -msgid "" -"Parse input of type :mimetype:`multipart/form-data` (for file uploads). " -"Arguments are *fp* for the input file, *pdict* for a dictionary containing " -"other parameters in the :mailheader:`Content-Type` header, and *encoding*, " -"the request encoding." -msgstr "" - -#: ../../library/cgi.rst:317 -msgid "" -"Returns a dictionary just like :func:`urllib.parse.parse_qs`: keys are the " -"field names, each value is a list of values for that field. For non-file " -"fields, the value is a list of strings." -msgstr "" - -#: ../../library/cgi.rst:321 -msgid "" -"This is easy to use but not much good if you are expecting megabytes to be " -"uploaded --- in that case, use the :class:`FieldStorage` class instead which " -"is much more flexible." -msgstr "" - -#: ../../library/cgi.rst:325 -msgid "" -"Added the *encoding* and *errors* parameters. For non-file fields, the " -"value is now a list of strings, not bytes." -msgstr "" - -#: ../../library/cgi.rst:329 -msgid "Added the *separator* parameter." -msgstr "新增 *separator* 參數。" - -#: ../../library/cgi.rst:332 -msgid "" -"This function, like the rest of the :mod:`cgi` module, is deprecated. It can " -"be replaced with the functionality in the :mod:`email` package (e.g. :class:" -"`email.message.EmailMessage`/:class:`email.message.Message`) which " -"implements the same MIME RFCs, or with the :pypi:`multipart` PyPI project." -msgstr "" - -#: ../../library/cgi.rst:342 -msgid "" -"Parse a MIME header (such as :mailheader:`Content-Type`) into a main value " -"and a dictionary of parameters." -msgstr "" - -#: ../../library/cgi.rst:345 -msgid "" -"This function, like the rest of the :mod:`cgi` module, is deprecated. It can " -"be replaced with the functionality in the :mod:`email` package, which " -"implements the same MIME RFCs." -msgstr "" - -#: ../../library/cgi.rst:350 -msgid "For example, with :class:`email.message.EmailMessage`::" -msgstr "" - -#: ../../library/cgi.rst:352 -msgid "" -"from email.message import EmailMessage\n" -"msg = EmailMessage()\n" -"msg['content-type'] = 'application/json; charset=\"utf8\"'\n" -"main, params = msg.get_content_type(), msg['content-type'].params" -msgstr "" -"from email.message import EmailMessage\n" -"msg = EmailMessage()\n" -"msg['content-type'] = 'application/json; charset=\"utf8\"'\n" -"main, params = msg.get_content_type(), msg['content-type'].params" - -#: ../../library/cgi.rst:360 -msgid "" -"Robust test CGI script, usable as main program. Writes minimal HTTP headers " -"and formats all information provided to the script in HTML format." -msgstr "" - -#: ../../library/cgi.rst:366 -msgid "Format the shell environment in HTML." -msgstr "" - -#: ../../library/cgi.rst:371 -msgid "Format a form in HTML." -msgstr "" - -#: ../../library/cgi.rst:376 -msgid "Format the current directory in HTML." -msgstr "" - -#: ../../library/cgi.rst:381 -msgid "Print a list of useful (used by CGI) environment variables in HTML." -msgstr "" - -#: ../../library/cgi.rst:387 -msgid "Caring about security" -msgstr "" - -#: ../../library/cgi.rst:391 -msgid "" -"There's one important rule: if you invoke an external program (via :func:`os." -"system`, :func:`os.popen` or other functions with similar functionality), " -"make very sure you don't pass arbitrary strings received from the client to " -"the shell. This is a well-known security hole whereby clever hackers " -"anywhere on the web can exploit a gullible CGI script to invoke arbitrary " -"shell commands. Even parts of the URL or field names cannot be trusted, " -"since the request doesn't have to come from your form!" -msgstr "" - -#: ../../library/cgi.rst:399 -msgid "" -"To be on the safe side, if you must pass a string gotten from a form to a " -"shell command, you should make sure the string contains only alphanumeric " -"characters, dashes, underscores, and periods." -msgstr "" - -#: ../../library/cgi.rst:405 -msgid "Installing your CGI script on a Unix system" -msgstr "" - -#: ../../library/cgi.rst:407 -msgid "" -"Read the documentation for your HTTP server and check with your local system " -"administrator to find the directory where CGI scripts should be installed; " -"usually this is in a directory :file:`cgi-bin` in the server tree." -msgstr "" - -#: ../../library/cgi.rst:411 -msgid "" -"Make sure that your script is readable and executable by \"others\"; the " -"Unix file mode should be ``0o755`` octal (use ``chmod 0755 filename``). " -"Make sure that the first line of the script contains ``#!`` starting in " -"column 1 followed by the pathname of the Python interpreter, for instance::" -msgstr "" - -#: ../../library/cgi.rst:416 -msgid "#!/usr/local/bin/python" -msgstr "#!/usr/local/bin/python" - -#: ../../library/cgi.rst:418 -msgid "" -"Make sure the Python interpreter exists and is executable by \"others\"." -msgstr "" - -#: ../../library/cgi.rst:420 -msgid "" -"Make sure that any files your script needs to read or write are readable or " -"writable, respectively, by \"others\" --- their mode should be ``0o644`` for " -"readable and ``0o666`` for writable. This is because, for security reasons, " -"the HTTP server executes your script as user \"nobody\", without any special " -"privileges. It can only read (write, execute) files that everybody can read " -"(write, execute). The current directory at execution time is also different " -"(it is usually the server's cgi-bin directory) and the set of environment " -"variables is also different from what you get when you log in. In " -"particular, don't count on the shell's search path for executables (:envvar:" -"`PATH`) or the Python module search path (:envvar:`PYTHONPATH`) to be set to " -"anything interesting." -msgstr "" - -#: ../../library/cgi.rst:431 -msgid "" -"If you need to load modules from a directory which is not on Python's " -"default module search path, you can change the path in your script, before " -"importing other modules. For example::" -msgstr "" - -#: ../../library/cgi.rst:435 -msgid "" -"import sys\n" -"sys.path.insert(0, \"/usr/home/joe/lib/python\")\n" -"sys.path.insert(0, \"/usr/local/lib/python\")" -msgstr "" -"import sys\n" -"sys.path.insert(0, \"/usr/home/joe/lib/python\")\n" -"sys.path.insert(0, \"/usr/local/lib/python\")" - -#: ../../library/cgi.rst:439 -msgid "(This way, the directory inserted last will be searched first!)" -msgstr "" - -#: ../../library/cgi.rst:441 -msgid "" -"Instructions for non-Unix systems will vary; check your HTTP server's " -"documentation (it will usually have a section on CGI scripts)." -msgstr "" - -#: ../../library/cgi.rst:446 -msgid "Testing your CGI script" -msgstr "" - -#: ../../library/cgi.rst:448 -msgid "" -"Unfortunately, a CGI script will generally not run when you try it from the " -"command line, and a script that works perfectly from the command line may " -"fail mysteriously when run from the server. There's one reason why you " -"should still test your script from the command line: if it contains a syntax " -"error, the Python interpreter won't execute it at all, and the HTTP server " -"will most likely send a cryptic error to the client." -msgstr "" - -#: ../../library/cgi.rst:455 -msgid "" -"Assuming your script has no syntax errors, yet it does not work, you have no " -"choice but to read the next section." -msgstr "" - -#: ../../library/cgi.rst:460 -msgid "Debugging CGI scripts" -msgstr "" - -#: ../../library/cgi.rst:464 -msgid "" -"First of all, check for trivial installation errors --- reading the section " -"above on installing your CGI script carefully can save you a lot of time. " -"If you wonder whether you have understood the installation procedure " -"correctly, try installing a copy of this module file (:file:`cgi.py`) as a " -"CGI script. When invoked as a script, the file will dump its environment " -"and the contents of the form in HTML format. Give it the right mode etc., " -"and send it a request. If it's installed in the standard :file:`cgi-bin` " -"directory, it should be possible to send it a request by entering a URL into " -"your browser of the form:" -msgstr "" - -#: ../../library/cgi.rst:473 -msgid "http://yourhostname/cgi-bin/cgi.py?name=Joe+Blow&addr=At+Home" -msgstr "http://yourhostname/cgi-bin/cgi.py?name=Joe+Blow&addr=At+Home" - -#: ../../library/cgi.rst:477 -msgid "" -"If this gives an error of type 404, the server cannot find the script -- " -"perhaps you need to install it in a different directory. If it gives " -"another error, there's an installation problem that you should fix before " -"trying to go any further. If you get a nicely formatted listing of the " -"environment and form content (in this example, the fields should be listed " -"as \"addr\" with value \"At Home\" and \"name\" with value \"Joe Blow\"), " -"the :file:`cgi.py` script has been installed correctly. If you follow the " -"same procedure for your own script, you should now be able to debug it." -msgstr "" - -#: ../../library/cgi.rst:486 -msgid "" -"The next step could be to call the :mod:`cgi` module's :func:`test` function " -"from your script: replace its main code with the single statement ::" -msgstr "" - -#: ../../library/cgi.rst:489 -msgid "cgi.test()" -msgstr "cgi.test()" - -#: ../../library/cgi.rst:491 -msgid "" -"This should produce the same results as those gotten from installing the :" -"file:`cgi.py` file itself." -msgstr "" - -#: ../../library/cgi.rst:494 -msgid "" -"When an ordinary Python script raises an unhandled exception (for whatever " -"reason: of a typo in a module name, a file that can't be opened, etc.), the " -"Python interpreter prints a nice traceback and exits. While the Python " -"interpreter will still do this when your CGI script raises an exception, " -"most likely the traceback will end up in one of the HTTP server's log files, " -"or be discarded altogether." -msgstr "" - -#: ../../library/cgi.rst:501 -msgid "" -"Fortunately, once you have managed to get your script to execute *some* " -"code, you can easily send tracebacks to the web browser using the :mod:" -"`cgitb` module. If you haven't done so already, just add the lines::" -msgstr "" - -#: ../../library/cgi.rst:508 -msgid "" -"to the top of your script. Then try running it again; when a problem " -"occurs, you should see a detailed report that will likely make apparent the " -"cause of the crash." -msgstr "" - -#: ../../library/cgi.rst:512 -msgid "" -"If you suspect that there may be a problem in importing the :mod:`cgitb` " -"module, you can use an even more robust approach (which only uses built-in " -"modules)::" -msgstr "" - -#: ../../library/cgi.rst:515 -msgid "" -"import sys\n" -"sys.stderr = sys.stdout\n" -"print(\"Content-Type: text/plain\")\n" -"print()\n" -"...your code here..." -msgstr "" - -#: ../../library/cgi.rst:521 -msgid "" -"This relies on the Python interpreter to print the traceback. The content " -"type of the output is set to plain text, which disables all HTML " -"processing. If your script works, the raw HTML will be displayed by your " -"client. If it raises an exception, most likely after the first two lines " -"have been printed, a traceback will be displayed. Because no HTML " -"interpretation is going on, the traceback will be readable." -msgstr "" - -#: ../../library/cgi.rst:530 -msgid "Common problems and solutions" -msgstr "" - -#: ../../library/cgi.rst:532 -msgid "" -"Most HTTP servers buffer the output from CGI scripts until the script is " -"completed. This means that it is not possible to display a progress report " -"on the client's display while the script is running." -msgstr "" - -#: ../../library/cgi.rst:536 -msgid "Check the installation instructions above." -msgstr "" - -#: ../../library/cgi.rst:538 -msgid "" -"Check the HTTP server's log files. (``tail -f logfile`` in a separate " -"window may be useful!)" -msgstr "" - -#: ../../library/cgi.rst:541 -msgid "" -"Always check a script for syntax errors first, by doing something like " -"``python script.py``." -msgstr "" - -#: ../../library/cgi.rst:544 -msgid "" -"If your script does not have any syntax errors, try adding ``import cgitb; " -"cgitb.enable()`` to the top of the script." -msgstr "" - -#: ../../library/cgi.rst:547 -msgid "" -"When invoking external programs, make sure they can be found. Usually, this " -"means using absolute path names --- :envvar:`PATH` is usually not set to a " -"very useful value in a CGI script." -msgstr "" - -#: ../../library/cgi.rst:551 +#: ../../library/cgi.rst:10 msgid "" -"When reading or writing external files, make sure they can be read or " -"written by the userid under which your CGI script will be running: this is " -"typically the userid under which the web server is running, or some " -"explicitly specified userid for a web server's ``suexec`` feature." +"This module is no longer part of the Python standard library. It was :ref:" +"`removed in Python 3.13 ` after being deprecated in " +"Python 3.11. The removal was decided in :pep:`594`." msgstr "" -#: ../../library/cgi.rst:556 +#: ../../library/cgi.rst:14 msgid "" -"Don't try to give a CGI script a set-uid mode. This doesn't work on most " -"systems, and is a security liability as well." +"A fork of the module on PyPI can be used instead: :pypi:`legacy-cgi`. This " +"is a copy of the cgi module, no longer maintained or supported by the core " +"Python team." msgstr "" -#: ../../library/cgi.rst:560 -msgid "Footnotes" -msgstr "註解" - -#: ../../library/cgi.rst:561 +#: ../../library/cgi.rst:18 msgid "" -"Note that some recent versions of the HTML specification do state what order " -"the field values should be supplied in, but knowing whether a request was " -"received from a conforming browser, or even from a browser at all, is " -"tedious and error-prone." -msgstr "" - -#: ../../library/cgi.rst:10 -msgid "WWW" -msgstr "WWW" - -#: ../../library/cgi.rst:10 -msgid "server" -msgstr "server(伺服器)" - -#: ../../library/cgi.rst:10 ../../library/cgi.rst:389 ../../library/cgi.rst:462 -msgid "CGI" -msgstr "CGI" - -#: ../../library/cgi.rst:10 -msgid "protocol" -msgstr "protocol(協定)" - -#: ../../library/cgi.rst:10 -msgid "HTTP" -msgstr "HTTP" - -#: ../../library/cgi.rst:10 -msgid "MIME" -msgstr "MIME" - -#: ../../library/cgi.rst:10 -msgid "headers" -msgstr "headers(標頭)" - -#: ../../library/cgi.rst:10 -msgid "URL" -msgstr "URL(統一資源定位器)" - -#: ../../library/cgi.rst:10 -msgid "Common Gateway Interface" -msgstr "Common Gateway Interface(通用閘道器介面)" - -#: ../../library/cgi.rst:389 -msgid "security" -msgstr "security(安全)" - -#: ../../library/cgi.rst:462 -msgid "debugging" -msgstr "debugging(除錯)" +"The last version of Python that provided the :mod:`!cgi` module was `Python " +"3.12 `_." +msgstr "" + +#~ msgid "**Source code:** :source:`Lib/cgi.py`" +#~ msgstr "**原始碼:**\\ :source:`Lib/cgi.py`" + +#~ msgid "" +#~ "The :mod:`cgi` module is deprecated (see :pep:`PEP 594 <594#cgi>` for " +#~ "details and alternatives)." +#~ msgstr "" +#~ ":mod:`cgi` 模組 (module) 即將被棄用(詳情與替代方案請見 :pep:`PEP 594 " +#~ "<594#cgi>`\\ )。" + +#~ msgid "" +#~ "This module does not work or is not available on WebAssembly platforms " +#~ "``wasm32-emscripten`` and ``wasm32-wasi``. See :ref:`wasm-availability` " +#~ "for more information." +#~ msgstr "" +#~ "此模組在 WebAssembly 平台 ``wasm32-emscripten`` 和 ``wasm32-wasi`` 上無法" +#~ "作用或無法使用。有關更多資訊,請參閱 :ref:`wasm-availability`。" + +#~ msgid "Introduction" +#~ msgstr "簡介" + +#~ msgid "" +#~ "print(\"CGI script output\")\n" +#~ "print(\"

This is my first CGI script

\")\n" +#~ "print(\"Hello, world!\")" +#~ msgstr "" +#~ "print(\"CGI script output\")\n" +#~ "print(\"

This is my first CGI script

\")\n" +#~ "print(\"Hello, world!\")" + +#~ msgid "Using the cgi module" +#~ msgstr "使用 cgi 模組" + +#~ msgid "" +#~ "import cgitb\n" +#~ "cgitb.enable()" +#~ msgstr "" +#~ "import cgitb\n" +#~ "cgitb.enable()" + +#~ msgid "" +#~ "import cgitb\n" +#~ "cgitb.enable(display=0, logdir=\"/path/to/logdir\")" +#~ msgstr "" +#~ "import cgitb\n" +#~ "cgitb.enable(display=0, logdir=\"/path/to/logdir\")" + +#~ msgid "" +#~ "value = form.getlist(\"username\")\n" +#~ "usernames = \",\".join(value)" +#~ msgstr "" +#~ "value = form.getlist(\"username\")\n" +#~ "usernames = \",\".join(value)" + +#~ msgid "" +#~ "\n" +#~ "" +#~ msgstr "" +#~ "\n" +#~ "" + +#~ msgid "user = form.getvalue(\"user\").upper()" +#~ msgstr "user = form.getvalue(\"user\").upper()" + +#~ msgid "" +#~ "import cgi\n" +#~ "form = cgi.FieldStorage()\n" +#~ "user = form.getfirst(\"user\", \"\").upper() # This way it's safe.\n" +#~ "for item in form.getlist(\"item\"):\n" +#~ " do_something(item)" +#~ msgstr "" +#~ "import cgi\n" +#~ "form = cgi.FieldStorage()\n" +#~ "user = form.getfirst(\"user\", \"\").upper() # 這是安全的方式。\n" +#~ "for item in form.getlist(\"item\"):\n" +#~ " do_something(item)" + +#~ msgid "Functions" +#~ msgstr "函式" + +#~ msgid "Added the *separator* parameter." +#~ msgstr "新增 *separator* 參數。" + +#~ msgid "" +#~ "from email.message import EmailMessage\n" +#~ "msg = EmailMessage()\n" +#~ "msg['content-type'] = 'application/json; charset=\"utf8\"'\n" +#~ "main, params = msg.get_content_type(), msg['content-type'].params" +#~ msgstr "" +#~ "from email.message import EmailMessage\n" +#~ "msg = EmailMessage()\n" +#~ "msg['content-type'] = 'application/json; charset=\"utf8\"'\n" +#~ "main, params = msg.get_content_type(), msg['content-type'].params" + +#~ msgid "#!/usr/local/bin/python" +#~ msgstr "#!/usr/local/bin/python" + +#~ msgid "" +#~ "import sys\n" +#~ "sys.path.insert(0, \"/usr/home/joe/lib/python\")\n" +#~ "sys.path.insert(0, \"/usr/local/lib/python\")" +#~ msgstr "" +#~ "import sys\n" +#~ "sys.path.insert(0, \"/usr/home/joe/lib/python\")\n" +#~ "sys.path.insert(0, \"/usr/local/lib/python\")" + +#~ msgid "http://yourhostname/cgi-bin/cgi.py?name=Joe+Blow&addr=At+Home" +#~ msgstr "http://yourhostname/cgi-bin/cgi.py?name=Joe+Blow&addr=At+Home" + +#~ msgid "cgi.test()" +#~ msgstr "cgi.test()" + +#~ msgid "Footnotes" +#~ msgstr "註解" + +#~ msgid "WWW" +#~ msgstr "WWW" + +#~ msgid "server" +#~ msgstr "server(伺服器)" + +#~ msgid "CGI" +#~ msgstr "CGI" + +#~ msgid "protocol" +#~ msgstr "protocol(協定)" + +#~ msgid "HTTP" +#~ msgstr "HTTP" + +#~ msgid "MIME" +#~ msgstr "MIME" + +#~ msgid "headers" +#~ msgstr "headers(標頭)" + +#~ msgid "URL" +#~ msgstr "URL(統一資源定位器)" + +#~ msgid "Common Gateway Interface" +#~ msgstr "Common Gateway Interface(通用閘道器介面)" + +#~ msgid "security" +#~ msgstr "security(安全)" + +#~ msgid "debugging" +#~ msgstr "debugging(除錯)" diff --git a/library/cgitb.po b/library/cgitb.po index e608145917..16bb7426ce 100644 --- a/library/cgitb.po +++ b/library/cgitb.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2024-11-20 09:21+0000\n" "PO-Revision-Date: 2022-05-22 02:02+0800\n" "Last-Translator: Liang-Bo Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -20,118 +20,58 @@ msgstr "" "X-Generator: Poedit 3.0.1\n" #: ../../library/cgitb.rst:2 -msgid ":mod:`cgitb` --- Traceback manager for CGI scripts" +#, fuzzy +msgid ":mod:`!cgitb` --- Traceback manager for CGI scripts" msgstr ":mod:`cgitb` --- CGI 腳本的回溯 (traceback) 管理程式" -#: ../../library/cgitb.rst:11 -msgid "**Source code:** :source:`Lib/cgitb.py`" -msgstr "**原始碼:**\\ :source:`Lib/cgitb.py`" - -#: ../../library/cgitb.rst:19 -msgid "" -"The :mod:`cgitb` module is deprecated (see :pep:`PEP 594 <594#cgitb>` for " -"details)." -msgstr "" -":mod:`cgitb` 模組 (module) 即將被棄用(詳見 :pep:`PEP 594 <594#cgitb>`\\ )。" - -#: ../../library/cgitb.rst:25 -msgid "" -"The :mod:`cgitb` module provides a special exception handler for Python " -"scripts. (Its name is a bit misleading. It was originally designed to " -"display extensive traceback information in HTML for CGI scripts. It was " -"later generalized to also display this information in plain text.) After " -"this module is activated, if an uncaught exception occurs, a detailed, " -"formatted report will be displayed. The report includes a traceback showing " -"excerpts of the source code for each level, as well as the values of the " -"arguments and local variables to currently running functions, to help you " -"debug the problem. Optionally, you can save this information to a file " -"instead of sending it to the browser." -msgstr "" - -#: ../../library/cgitb.rst:35 -msgid "To enable this feature, simply add this to the top of your CGI script::" -msgstr "" - -#: ../../library/cgitb.rst:37 +#: ../../library/cgitb.rst:10 msgid "" -"import cgitb\n" -"cgitb.enable()" +"This module is no longer part of the Python standard library. It was :ref:" +"`removed in Python 3.13 ` after being deprecated in " +"Python 3.11. The removal was decided in :pep:`594`." msgstr "" -"import cgitb\n" -"cgitb.enable()" -#: ../../library/cgitb.rst:40 +#: ../../library/cgitb.rst:14 msgid "" -"The options to the :func:`enable` function control whether the report is " -"displayed in the browser and whether the report is logged to a file for " -"later analysis." +"A fork of the module on PyPI can now be used instead: :pypi:`legacy-cgi`. " +"This is a copy of the cgi module, no longer maintained or supported by the " +"core Python team." msgstr "" -#: ../../library/cgitb.rst:49 +#: ../../library/cgitb.rst:18 msgid "" -"This function causes the :mod:`cgitb` module to take over the interpreter's " -"default handling for exceptions by setting the value of :attr:`sys." -"excepthook`." +"The last version of Python that provided the :mod:`!cgitb` module was " +"`Python 3.12 `_." msgstr "" -#: ../../library/cgitb.rst:52 -msgid "" -"The optional argument *display* defaults to ``1`` and can be set to ``0`` to " -"suppress sending the traceback to the browser. If the argument *logdir* is " -"present, the traceback reports are written to files. The value of *logdir* " -"should be a directory where these files will be placed. The optional " -"argument *context* is the number of lines of context to display around the " -"current line of source code in the traceback; this defaults to ``5``. If the " -"optional argument *format* is ``\"html\"``, the output is formatted as " -"HTML. Any other value forces plain text output. The default value is " -"``\"html\"``." -msgstr "" +#~ msgid "**Source code:** :source:`Lib/cgitb.py`" +#~ msgstr "**原始碼:**\\ :source:`Lib/cgitb.py`" -#: ../../library/cgitb.rst:64 -msgid "" -"This function handles the exception described by *info* (a 3-tuple " -"containing the result of :func:`sys.exc_info`), formatting its traceback as " -"text and returning the result as a string. The optional argument *context* " -"is the number of lines of context to display around the current line of " -"source code in the traceback; this defaults to ``5``." -msgstr "" +#~ msgid "" +#~ "The :mod:`cgitb` module is deprecated (see :pep:`PEP 594 <594#cgitb>` for " +#~ "details)." +#~ msgstr "" +#~ ":mod:`cgitb` 模組 (module) 即將被棄用(詳見 :pep:`PEP 594 " +#~ "<594#cgitb>`\\ )。" -#: ../../library/cgitb.rst:73 -msgid "" -"This function handles the exception described by *info* (a 3-tuple " -"containing the result of :func:`sys.exc_info`), formatting its traceback as " -"HTML and returning the result as a string. The optional argument *context* " -"is the number of lines of context to display around the current line of " -"source code in the traceback; this defaults to ``5``." -msgstr "" - -#: ../../library/cgitb.rst:82 -msgid "" -"This function handles an exception using the default settings (that is, show " -"a report in the browser, but don't log to a file). This can be used when " -"you've caught an exception and want to report it using :mod:`cgitb`. The " -"optional *info* argument should be a 3-tuple containing an exception type, " -"exception value, and traceback object, exactly like the tuple returned by :" -"func:`sys.exc_info`. If the *info* argument is not supplied, the current " -"exception is obtained from :func:`sys.exc_info`." -msgstr "" +#~ msgid "" +#~ "import cgitb\n" +#~ "cgitb.enable()" +#~ msgstr "" +#~ "import cgitb\n" +#~ "cgitb.enable()" -#: ../../library/cgitb.rst:13 -msgid "CGI" -msgstr "CGI" +#~ msgid "CGI" +#~ msgstr "CGI" -#: ../../library/cgitb.rst:13 -msgid "exceptions" -msgstr "exceptions(例外)" +#~ msgid "exceptions" +#~ msgstr "exceptions(例外)" -#: ../../library/cgitb.rst:13 -msgid "tracebacks" -msgstr "tracebacks(回溯)" +#~ msgid "tracebacks" +#~ msgstr "tracebacks(回溯)" -#: ../../library/cgitb.rst:13 -msgid "in CGI scripts" -msgstr "於 CGI 腳本中" +#~ msgid "in CGI scripts" +#~ msgstr "於 CGI 腳本中" -#: ../../library/cgitb.rst:47 -msgid "excepthook() (in module sys)" -msgstr "excepthook() (sys 模組中)" +#~ msgid "excepthook() (in module sys)" +#~ msgstr "excepthook() (sys 模組中)" diff --git a/library/chunk.po b/library/chunk.po index 96bf1cfea3..1603398782 100644 --- a/library/chunk.po +++ b/library/chunk.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-07-20 00:03+0000\n" +"POT-Creation-Date: 2024-11-20 09:21+0000\n" "PO-Revision-Date: 2022-05-22 02:03+0800\n" "Last-Translator: Liang-Bo Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -20,206 +20,71 @@ msgstr "" "X-Generator: Poedit 3.0.1\n" #: ../../library/chunk.rst:2 -msgid ":mod:`chunk` --- Read IFF chunked data" +#, fuzzy +msgid ":mod:`!chunk` --- Read IFF chunked data" msgstr ":mod:`chunk` --- 讀取 IFF 分塊資料" -#: ../../library/chunk.rst:11 -msgid "**Source code:** :source:`Lib/chunk.py`" -msgstr "**原始碼:**\\ :source:`Lib/chunk.py`" - -#: ../../library/chunk.rst:20 +#: ../../library/chunk.rst:10 msgid "" -"The :mod:`chunk` module is deprecated (see :pep:`PEP 594 <594#chunk>` for " -"details)." +"This module is no longer part of the Python standard library. It was :ref:" +"`removed in Python 3.13 ` after being deprecated in " +"Python 3.11. The removal was decided in :pep:`594`." msgstr "" -":mod:`chunk` 模組 (module) 即將被棄用(詳見 :pep:`PEP 594 <594#chunk>`\\ )。" -#: ../../library/chunk.rst:26 +#: ../../library/chunk.rst:14 msgid "" -"This module provides an interface for reading files that use EA IFF 85 " -"chunks. [#]_ This format is used in at least the Audio Interchange File " -"Format (AIFF/AIFF-C) and the Real Media File Format (RMFF). The WAVE audio " -"file format is closely related and can also be read using this module." -msgstr "" - -#: ../../library/chunk.rst:31 -msgid "A chunk has the following structure:" -msgstr "" - -#: ../../library/chunk.rst:34 -msgid "Offset" -msgstr "" - -#: ../../library/chunk.rst:34 -msgid "Length" -msgstr "長度" - -#: ../../library/chunk.rst:34 -msgid "Contents" -msgstr "內容" - -#: ../../library/chunk.rst:36 -msgid "0" -msgstr "0" - -#: ../../library/chunk.rst:36 ../../library/chunk.rst:38 -msgid "4" -msgstr "4" - -#: ../../library/chunk.rst:36 -msgid "Chunk ID" -msgstr "" - -#: ../../library/chunk.rst:38 -msgid "Size of chunk in big-endian byte order, not including the header" +"The last version of Python that provided the :mod:`!chunk` module was " +"`Python 3.12 `_." msgstr "" -#: ../../library/chunk.rst:42 -msgid "8" -msgstr "8" +#~ msgid "**Source code:** :source:`Lib/chunk.py`" +#~ msgstr "**原始碼:**\\ :source:`Lib/chunk.py`" -#: ../../library/chunk.rst:42 -msgid "*n*" -msgstr "*n*" +#~ msgid "" +#~ "The :mod:`chunk` module is deprecated (see :pep:`PEP 594 <594#chunk>` for " +#~ "details)." +#~ msgstr "" +#~ ":mod:`chunk` 模組 (module) 即將被棄用(詳見 :pep:`PEP 594 " +#~ "<594#chunk>`\\ )。" -#: ../../library/chunk.rst:42 -msgid "Data bytes, where *n* is the size given in the preceding field" -msgstr "" +#~ msgid "Length" +#~ msgstr "長度" -#: ../../library/chunk.rst:46 -msgid "8 + *n*" -msgstr "8 + *n*" +#~ msgid "Contents" +#~ msgstr "內容" -#: ../../library/chunk.rst:46 -msgid "0 or 1" -msgstr "0 或 1" +#~ msgid "0" +#~ msgstr "0" -#: ../../library/chunk.rst:46 -msgid "Pad byte needed if *n* is odd and chunk alignment is used" -msgstr "" +#~ msgid "4" +#~ msgstr "4" -#: ../../library/chunk.rst:50 -msgid "The ID is a 4-byte string which identifies the type of chunk." -msgstr "" +#~ msgid "8" +#~ msgstr "8" -#: ../../library/chunk.rst:52 -msgid "" -"The size field (a 32-bit value, encoded using big-endian byte order) gives " -"the size of the chunk data, not including the 8-byte header." -msgstr "" +#~ msgid "*n*" +#~ msgstr "*n*" -#: ../../library/chunk.rst:55 -msgid "" -"Usually an IFF-type file consists of one or more chunks. The proposed usage " -"of the :class:`Chunk` class defined here is to instantiate an instance at " -"the start of each chunk and read from the instance until it reaches the end, " -"after which a new instance can be instantiated. At the end of the file, " -"creating a new instance will fail with an :exc:`EOFError` exception." -msgstr "" +#~ msgid "8 + *n*" +#~ msgstr "8 + *n*" -#: ../../library/chunk.rst:64 -msgid "" -"Class which represents a chunk. The *file* argument is expected to be a " -"file-like object. An instance of this class is specifically allowed. The " -"only method that is needed is :meth:`~io.IOBase.read`. If the methods :meth:" -"`~io.IOBase.seek` and :meth:`~io.IOBase.tell` are present and don't raise an " -"exception, they are also used. If these methods are present and raise an " -"exception, they are expected to not have altered the object. If the " -"optional argument *align* is true, chunks are assumed to be aligned on 2-" -"byte boundaries. If *align* is false, no alignment is assumed. The default " -"value is true. If the optional argument *bigendian* is false, the chunk " -"size is assumed to be in little-endian order. This is needed for WAVE audio " -"files. The default value is true. If the optional argument *inclheader* is " -"true, the size given in the chunk header includes the size of the header. " -"The default value is false." -msgstr "" - -#: ../../library/chunk.rst:78 -msgid "A :class:`Chunk` object supports the following methods:" -msgstr "" +#~ msgid "0 or 1" +#~ msgstr "0 或 1" -#: ../../library/chunk.rst:83 -msgid "" -"Returns the name (ID) of the chunk. This is the first 4 bytes of the chunk." -msgstr "" - -#: ../../library/chunk.rst:89 -msgid "Returns the size of the chunk." -msgstr "" - -#: ../../library/chunk.rst:94 -msgid "" -"Close and skip to the end of the chunk. This does not close the underlying " -"file." -msgstr "" - -#: ../../library/chunk.rst:97 -msgid "" -"The remaining methods will raise :exc:`OSError` if called after the :meth:" -"`close` method has been called. Before Python 3.3, they used to raise :exc:" -"`IOError`, now an alias of :exc:`OSError`." -msgstr "" - -#: ../../library/chunk.rst:104 -msgid "Returns ``False``." -msgstr "" - -#: ../../library/chunk.rst:109 -msgid "" -"Set the chunk's current position. The *whence* argument is optional and " -"defaults to ``0`` (absolute file positioning); other values are ``1`` (seek " -"relative to the current position) and ``2`` (seek relative to the file's " -"end). There is no return value. If the underlying file does not allow seek, " -"only forward seeks are allowed." -msgstr "" - -#: ../../library/chunk.rst:118 -msgid "Return the current position into the chunk." -msgstr "" - -#: ../../library/chunk.rst:123 -msgid "" -"Read at most *size* bytes from the chunk (less if the read hits the end of " -"the chunk before obtaining *size* bytes). If the *size* argument is " -"negative or omitted, read all data until the end of the chunk. An empty " -"bytes object is returned when the end of the chunk is encountered " -"immediately." -msgstr "" - -#: ../../library/chunk.rst:132 -msgid "" -"Skip to the end of the chunk. All further calls to :meth:`read` for the " -"chunk will return ``b''``. If you are not interested in the contents of the " -"chunk, this method should be called so that the file points to the start of " -"the next chunk." -msgstr "" - -#: ../../library/chunk.rst:139 -msgid "Footnotes" -msgstr "註解" - -#: ../../library/chunk.rst:140 -msgid "" -"\"EA IFF 85\" Standard for Interchange Format Files, Jerry Morrison, " -"Electronic Arts, January 1985." -msgstr "" +#~ msgid "Footnotes" +#~ msgstr "註解" -#: ../../library/chunk.rst:13 -msgid "Audio Interchange File Format" -msgstr "Audio Interchange File Format(音訊交換檔案格式)" +#~ msgid "Audio Interchange File Format" +#~ msgstr "Audio Interchange File Format(音訊交換檔案格式)" -#: ../../library/chunk.rst:13 -msgid "AIFF" -msgstr "AIFF" +#~ msgid "AIFF" +#~ msgstr "AIFF" -#: ../../library/chunk.rst:13 -msgid "AIFF-C" -msgstr "AIFF-C" +#~ msgid "AIFF-C" +#~ msgstr "AIFF-C" -#: ../../library/chunk.rst:13 -msgid "Real Media File Format" -msgstr "Real Media File Format(Real Media 檔案格式)" +#~ msgid "Real Media File Format" +#~ msgstr "Real Media File Format(Real Media 檔案格式)" -#: ../../library/chunk.rst:13 -msgid "RMFF" -msgstr "RMFF" +#~ msgid "RMFF" +#~ msgstr "RMFF" diff --git a/library/cmath.po b/library/cmath.po index 40159235bf..cda3fef8d3 100644 --- a/library/cmath.po +++ b/library/cmath.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-04-24 05:56+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-" @@ -88,10 +88,300 @@ msgstr "" "1.4142135623730951j" #: ../../library/cmath.rst:42 -msgid "Conversions to and from polar coordinates" +#, fuzzy +msgid "**Conversions to and from polar coordinates**" msgstr "轉換到極座標和從極座標做轉換" #: ../../library/cmath.rst:44 +msgid ":func:`phase(z) `" +msgstr "" + +#: ../../library/cmath.rst:44 +#, fuzzy +msgid "Return the phase of *z*" +msgstr "回傳 *x* 的正弦值。" + +#: ../../library/cmath.rst:45 +msgid ":func:`polar(z) `" +msgstr "" + +#: ../../library/cmath.rst:45 +#, fuzzy +msgid "Return the representation of *z* in polar coordinates" +msgstr "轉換到極座標和從極座標做轉換" + +#: ../../library/cmath.rst:46 +msgid ":func:`rect(r, phi) `" +msgstr "" + +#: ../../library/cmath.rst:46 +#, fuzzy +msgid "Return the complex number *z* with polar coordinates *r* and *phi*" +msgstr "" +"透過極座標 *r* 和 *phi* 回傳複數 *x*。相當於 ``complex(r * math.cos(phi), r " +"* math.sin(phi))``。" + +#: ../../library/cmath.rst:48 +#, fuzzy +msgid "**Power and logarithmic functions**" +msgstr "冪函數和對數函數" + +#: ../../library/cmath.rst:50 +msgid ":func:`exp(z) `" +msgstr "" + +#: ../../library/cmath.rst:50 +msgid "Return *e* raised to the power *z*" +msgstr "" + +#: ../../library/cmath.rst:51 +msgid ":func:`log(z[, base]) `" +msgstr "" + +#: ../../library/cmath.rst:51 +msgid "Return the logarithm of *z* to the given *base* (*e* by default)" +msgstr "" + +#: ../../library/cmath.rst:52 +msgid ":func:`log10(z) `" +msgstr "" + +#: ../../library/cmath.rst:52 +#, fuzzy +msgid "Return the base-10 logarithm of *z*" +msgstr "回傳 *x* 的正切值。" + +#: ../../library/cmath.rst:53 +msgid ":func:`sqrt(z) `" +msgstr "" + +#: ../../library/cmath.rst:53 +#, fuzzy +msgid "Return the square root of *z*" +msgstr "回傳 *x* 的正弦值。" + +#: ../../library/cmath.rst:55 +#, fuzzy +msgid "**Trigonometric functions**" +msgstr "三角函數" + +#: ../../library/cmath.rst:57 +msgid ":func:`acos(z) `" +msgstr "" + +#: ../../library/cmath.rst:57 +#, fuzzy +msgid "Return the arc cosine of *z*" +msgstr "回傳 *x* 的餘弦值。" + +#: ../../library/cmath.rst:58 +msgid ":func:`asin(z) `" +msgstr "" + +#: ../../library/cmath.rst:58 +#, fuzzy +msgid "Return the arc sine of *z*" +msgstr "回傳 *x* 的餘弦值。" + +#: ../../library/cmath.rst:59 +msgid ":func:`atan(z) `" +msgstr "" + +#: ../../library/cmath.rst:59 +#, fuzzy +msgid "Return the arc tangent of *z*" +msgstr "回傳 *x* 的正切值。" + +#: ../../library/cmath.rst:60 +msgid ":func:`cos(z) `" +msgstr "" + +#: ../../library/cmath.rst:60 +#, fuzzy +msgid "Return the cosine of *z*" +msgstr "回傳 *x* 的餘弦值。" + +#: ../../library/cmath.rst:61 +msgid ":func:`sin(z) `" +msgstr "" + +#: ../../library/cmath.rst:61 +#, fuzzy +msgid "Return the sine of *z*" +msgstr "回傳 *x* 的正弦值。" + +#: ../../library/cmath.rst:62 +msgid ":func:`tan(z) `" +msgstr "" + +#: ../../library/cmath.rst:62 +#, fuzzy +msgid "Return the tangent of *z*" +msgstr "回傳 *x* 的正切值。" + +#: ../../library/cmath.rst:64 +#, fuzzy +msgid "**Hyperbolic functions**" +msgstr "雙曲函數" + +#: ../../library/cmath.rst:66 +msgid ":func:`acosh(z) `" +msgstr "" + +#: ../../library/cmath.rst:66 +#, fuzzy +msgid "Return the inverse hyperbolic cosine of *z*" +msgstr "回傳 *x* 的反雙曲餘弦值。" + +#: ../../library/cmath.rst:67 +msgid ":func:`asinh(z) `" +msgstr "" + +#: ../../library/cmath.rst:67 +#, fuzzy +msgid "Return the inverse hyperbolic sine of *z*" +msgstr "回傳 *x* 的反雙曲正弦值。" + +#: ../../library/cmath.rst:68 +msgid ":func:`atanh(z) `" +msgstr "" + +#: ../../library/cmath.rst:68 +#, fuzzy +msgid "Return the inverse hyperbolic tangent of *z*" +msgstr "回傳 *x* 的反雙曲正切值。" + +#: ../../library/cmath.rst:69 +msgid ":func:`cosh(z) `" +msgstr "" + +#: ../../library/cmath.rst:69 +#, fuzzy +msgid "Return the hyperbolic cosine of *z*" +msgstr "回傳 *x* 的反雙曲餘弦值。" + +#: ../../library/cmath.rst:70 +msgid ":func:`sinh(z) `" +msgstr "" + +#: ../../library/cmath.rst:70 +#, fuzzy +msgid "Return the hyperbolic sine of *z*" +msgstr "回傳 *x* 的反雙曲正弦值。" + +#: ../../library/cmath.rst:71 +msgid ":func:`tanh(z) `" +msgstr "" + +#: ../../library/cmath.rst:71 +#, fuzzy +msgid "Return the hyperbolic tangent of *z*" +msgstr "回傳 *x* 的反雙曲正切值。" + +#: ../../library/cmath.rst:73 +#, fuzzy +msgid "**Classification functions**" +msgstr "分類函式" + +#: ../../library/cmath.rst:75 +msgid ":func:`isfinite(z) `" +msgstr "" + +#: ../../library/cmath.rst:75 +msgid "Check if all components of *z* are finite" +msgstr "" + +#: ../../library/cmath.rst:76 +msgid ":func:`isinf(z) `" +msgstr "" + +#: ../../library/cmath.rst:76 +msgid "Check if any component of *z* is infinite" +msgstr "" + +#: ../../library/cmath.rst:77 +msgid ":func:`isnan(z) `" +msgstr "" + +#: ../../library/cmath.rst:77 +msgid "Check if any component of *z* is a NaN" +msgstr "" + +#: ../../library/cmath.rst:78 +msgid ":func:`isclose(a, b, *, rel_tol, abs_tol) `" +msgstr "" + +#: ../../library/cmath.rst:78 +#, fuzzy +msgid "Check if the values *a* and *b* are close to each other" +msgstr "如果 *a* 和 *b* 的值相互接近,則回傳 ``True``,否則回傳 ``False``。" + +#: ../../library/cmath.rst:80 +#, fuzzy +msgid "**Constants**" +msgstr "常數" + +#: ../../library/cmath.rst:82 +msgid ":data:`pi`" +msgstr "" + +#: ../../library/cmath.rst:82 +msgid "*π* = 3.141592..." +msgstr "" + +#: ../../library/cmath.rst:83 +msgid ":data:`e`" +msgstr "" + +#: ../../library/cmath.rst:83 +msgid "*e* = 2.718281..." +msgstr "" + +#: ../../library/cmath.rst:84 +msgid ":data:`tau`" +msgstr "" + +#: ../../library/cmath.rst:84 +msgid "*τ* = 2\\ *π* = 6.283185..." +msgstr "" + +#: ../../library/cmath.rst:85 +msgid ":data:`inf`" +msgstr "" + +#: ../../library/cmath.rst:85 +msgid "Positive infinity" +msgstr "" + +#: ../../library/cmath.rst:86 +msgid ":data:`infj`" +msgstr "" + +#: ../../library/cmath.rst:86 +msgid "Pure imaginary infinity" +msgstr "" + +#: ../../library/cmath.rst:87 +msgid ":data:`nan`" +msgstr "" + +#: ../../library/cmath.rst:87 +msgid "\"Not a number\" (NaN)" +msgstr "" + +#: ../../library/cmath.rst:88 +msgid ":data:`nanj`" +msgstr "" + +#: ../../library/cmath.rst:88 +msgid "Pure imaginary NaN" +msgstr "" + +#: ../../library/cmath.rst:93 +msgid "Conversions to and from polar coordinates" +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." @@ -100,7 +390,7 @@ msgstr "" "Python 複數 ``z`` 是用 *直角坐標* 或 *笛卡爾坐標* 儲存在內部的。它完全是由其 " "*實部* ``z.real`` 和 *虛部* ``z.imag`` 所決定。" -#: ../../library/cmath.rst:48 +#: ../../library/cmath.rst:99 msgid "" "*Polar coordinates* give an alternative way to represent a complex number. " "In polar coordinates, a complex number *z* is defined by the modulus *r* and " @@ -113,26 +403,27 @@ msgstr "" "*r* 和相位角 (phase) *phi* 定義。絕對值 *r* 是從 *z* 到原點的距離,而相位角 " "*phi* 是從正 x 軸到連接原點到 *z* 的線段的逆時針角度(以弧度為單位)。" -#: ../../library/cmath.rst:55 +#: ../../library/cmath.rst:106 msgid "" "The following functions can be used to convert from the native rectangular " "coordinates to polar coordinates and back." msgstr "以下的函式可用於原始直角座標與極座標之間的相互轉換。" -#: ../../library/cmath.rst:60 +#: ../../library/cmath.rst:111 +#, fuzzy msgid "" -"Return the phase of *x* (also known as the *argument* of *x*), as a float. " -"``phase(x)`` is equivalent to ``math.atan2(x.imag, x.real)``. The result " +"Return the phase of *z* (also known as the *argument* of *z*), as a float. " +"``phase(z)`` is equivalent to ``math.atan2(z.imag, z.real)``. The result " "lies in the range [-\\ *π*, *π*], and the branch cut for this operation lies " "along the negative real axis. The sign of the result is the same as the " -"sign of ``x.imag``, even when ``x.imag`` is zero::" +"sign of ``z.imag``, even when ``z.imag`` is zero::" msgstr "" "以浮點數的形式回傳 *x* 的相位角(也稱為 *x* 的 *引數* )。 ``phase(x)`` 等價" "於 ``math.atan2(x.imag, x.real)``。結果將位於 [-\\ *π*, *π*] 的範圍內,且此操" "作的分枝切割將位於負實軸上。結果的符號會與 ``x.imag`` 的符號相同,即使 ``x." "imag`` 為零: ::" -#: ../../library/cmath.rst:66 +#: ../../library/cmath.rst:117 msgid "" ">>> phase(complex(-1.0, 0.0))\n" "3.141592653589793\n" @@ -144,207 +435,226 @@ msgstr "" ">>> phase(complex(-1.0, -0.0))\n" "-3.141592653589793" -#: ../../library/cmath.rst:74 +#: ../../library/cmath.rst:125 +#, fuzzy msgid "" -"The modulus (absolute value) of a complex number *x* can be computed using " +"The modulus (absolute value) of a complex number *z* can be computed using " "the built-in :func:`abs` function. There is no separate :mod:`cmath` module " "function for this operation." msgstr "" "複數 *x* 的絕對值可以使用內建的 :func:`abs` 函式計算。沒有單獨的 :mod:" "`cmath` 模組函式適用於此操作。" -#: ../../library/cmath.rst:81 +#: ../../library/cmath.rst:132 +#, fuzzy msgid "" -"Return the representation of *x* in polar coordinates. Returns a pair ``(r, " -"phi)`` where *r* is the modulus of *x* and phi is the phase of *x*. " -"``polar(x)`` is equivalent to ``(abs(x), phase(x))``." +"Return the representation of *z* in polar coordinates. Returns a pair ``(r, " +"phi)`` where *r* is the modulus of *z* and *phi* is the phase of *z*. " +"``polar(z)`` is equivalent to ``(abs(z), phase(z))``." msgstr "" "回傳 *x* 在極座標中的表達方式。回傳一組數對 ``(r, phi)``, *r* 是 *x* 的絕對" "值, *phi* 是 *x* 的相位角。 ``polar(x)`` 相當於 ``(abs(x), phase(x))``。" -#: ../../library/cmath.rst:89 +#: ../../library/cmath.rst:140 +#, fuzzy msgid "" -"Return the complex number *x* with polar coordinates *r* and *phi*. " +"Return the complex number *z* with polar coordinates *r* and *phi*. " "Equivalent to ``complex(r * math.cos(phi), r * math.sin(phi))``." msgstr "" "透過極座標 *r* 和 *phi* 回傳複數 *x*。相當於 ``complex(r * math.cos(phi), r " "* math.sin(phi))``。" -#: ../../library/cmath.rst:94 +#: ../../library/cmath.rst:145 msgid "Power and logarithmic functions" msgstr "冪函數和對數函數" -#: ../../library/cmath.rst:98 +#: ../../library/cmath.rst:149 +#, fuzzy msgid "" -"Return *e* raised to the power *x*, where *e* is the base of natural " +"Return *e* raised to the power *z*, where *e* is the base of natural " "logarithms." msgstr "回傳 *e* 的 *x* 次方,其中 *e* 是自然對數的底數。" -#: ../../library/cmath.rst:104 +#: ../../library/cmath.rst:155 +#, fuzzy msgid "" -"Returns the logarithm of *x* to the given *base*. If the *base* is not " -"specified, returns the natural logarithm of *x*. There is one branch cut, " +"Return the logarithm of *z* to the given *base*. If the *base* is not " +"specified, returns the natural logarithm of *z*. There is one branch cut, " "from 0 along the negative real axis to -∞." msgstr "" "回傳 *x* 給定 *base* 的對數。如果未指定 *base*,則傳回 *x* 的自然對數。存在一" "條分枝切割,從 0 沿負實數軸到 -∞。" -#: ../../library/cmath.rst:111 +#: ../../library/cmath.rst:162 +#, fuzzy msgid "" -"Return the base-10 logarithm of *x*. This has the same branch cut as :func:" +"Return the base-10 logarithm of *z*. This has the same branch cut as :func:" "`log`." msgstr "回傳 *x* 以 10 為底的對數。它與 :func:`log` 具有相同的分枝切割。" -#: ../../library/cmath.rst:117 +#: ../../library/cmath.rst:168 +#, fuzzy msgid "" -"Return the square root of *x*. This has the same branch cut as :func:`log`." +"Return the square root of *z*. This has the same branch cut as :func:`log`." msgstr "回傳 *x* 的平方根。它與 :func:`log` 具有相同的分枝切割。" -#: ../../library/cmath.rst:121 +#: ../../library/cmath.rst:172 msgid "Trigonometric functions" msgstr "三角函數" -#: ../../library/cmath.rst:125 +#: ../../library/cmath.rst:176 +#, fuzzy msgid "" -"Return the arc cosine of *x*. There are two branch cuts: One extends right " +"Return the arc cosine of *z*. There are two branch cuts: One extends right " "from 1 along the real axis to ∞. The other extends left from -1 along the " "real axis to -∞." msgstr "" "回傳 *x* 的反餘弦值。存在兩條分枝切割:一條是從 1 沿著實數軸向右延伸到 ∞。另" "一條從 -1 沿實數軸向左延伸到 -∞。" -#: ../../library/cmath.rst:132 +#: ../../library/cmath.rst:183 +#, fuzzy msgid "" -"Return the arc sine of *x*. This has the same branch cuts as :func:`acos`." +"Return the arc sine of *z*. This has the same branch cuts as :func:`acos`." msgstr "回傳 *x* 的反正弦值。它與 :func:`acos` 具有相同的分枝切割。" -#: ../../library/cmath.rst:137 +#: ../../library/cmath.rst:188 +#, fuzzy msgid "" -"Return the arc tangent of *x*. There are two branch cuts: One extends from " +"Return the arc tangent of *z*. There are two branch cuts: One extends from " "``1j`` along the imaginary axis to ``∞j``. The other extends from ``-1j`` " "along the imaginary axis to ``-∞j``." msgstr "" "回傳 *x* 的反正切值。有兩條分枝切割:一條是從 ``1j`` 沿著虛軸延伸到 ``∞j``。" "另一條從 ``-1j`` 沿著虛軸延伸到 ``-∞j``。" -#: ../../library/cmath.rst:144 -msgid "Return the cosine of *x*." +#: ../../library/cmath.rst:195 +#, fuzzy +msgid "Return the cosine of *z*." msgstr "回傳 *x* 的餘弦值。" -#: ../../library/cmath.rst:149 -msgid "Return the sine of *x*." +#: ../../library/cmath.rst:200 +#, fuzzy +msgid "Return the sine of *z*." msgstr "回傳 *x* 的正弦值。" -#: ../../library/cmath.rst:154 -msgid "Return the tangent of *x*." +#: ../../library/cmath.rst:205 +#, fuzzy +msgid "Return the tangent of *z*." msgstr "回傳 *x* 的正切值。" -#: ../../library/cmath.rst:158 +#: ../../library/cmath.rst:209 msgid "Hyperbolic functions" msgstr "雙曲函數" -#: ../../library/cmath.rst:162 +#: ../../library/cmath.rst:213 +#, fuzzy msgid "" -"Return the inverse hyperbolic cosine of *x*. There is one branch cut, " +"Return the inverse hyperbolic cosine of *z*. There is one branch cut, " "extending left from 1 along the real axis to -∞." msgstr "" "回傳 *x* 的反雙曲餘弦值。存在一條分枝切割,從 1 沿實數軸向左延伸到 -∞。" -#: ../../library/cmath.rst:168 +#: ../../library/cmath.rst:219 +#, fuzzy msgid "" -"Return the inverse hyperbolic sine of *x*. There are two branch cuts: One " +"Return the inverse hyperbolic sine of *z*. There are two branch cuts: One " "extends from ``1j`` along the imaginary axis to ``∞j``. The other extends " "from ``-1j`` along the imaginary axis to ``-∞j``." msgstr "" "回傳 *x* 的反雙曲正弦值。存在兩條分枝切割:一條是從 ``1j`` 沿著虛軸延伸到 " "``∞j``。另一條從 ``-1j`` 沿著虛軸延伸到 ``-∞j``。" -#: ../../library/cmath.rst:175 +#: ../../library/cmath.rst:226 +#, fuzzy msgid "" -"Return the inverse hyperbolic tangent of *x*. There are two branch cuts: One " +"Return the inverse hyperbolic tangent of *z*. There are two branch cuts: One " "extends from ``1`` along the real axis to ``∞``. The other extends from " "``-1`` along the real axis to ``-∞``." msgstr "" "回傳 *x* 的反雙曲正切值。存在兩條分枝切割:一條是從 ``1`` 沿著實數軸延伸到 " "``∞``。另一條從 ``-1`` 沿著實數軸延伸到 ``-∞``。" -#: ../../library/cmath.rst:182 -msgid "Return the hyperbolic cosine of *x*." +#: ../../library/cmath.rst:233 +#, fuzzy +msgid "Return the hyperbolic cosine of *z*." msgstr "回傳 *x* 的反雙曲餘弦值。" -#: ../../library/cmath.rst:187 -msgid "Return the hyperbolic sine of *x*." +#: ../../library/cmath.rst:238 +#, fuzzy +msgid "Return the hyperbolic sine of *z*." msgstr "回傳 *x* 的反雙曲正弦值。" -#: ../../library/cmath.rst:192 -msgid "Return the hyperbolic tangent of *x*." +#: ../../library/cmath.rst:243 +#, fuzzy +msgid "Return the hyperbolic tangent of *z*." msgstr "回傳 *x* 的反雙曲正切值。" -#: ../../library/cmath.rst:196 +#: ../../library/cmath.rst:247 msgid "Classification functions" msgstr "分類函式" -#: ../../library/cmath.rst:200 +#: ../../library/cmath.rst:251 +#, fuzzy msgid "" -"Return ``True`` if both the real and imaginary parts of *x* are finite, and " +"Return ``True`` if both the real and imaginary parts of *z* are finite, and " "``False`` otherwise." msgstr "如果 *x* 的實部和虛部都是有限的,則回傳 ``True``,否則回傳 ``False``。" -#: ../../library/cmath.rst:208 +#: ../../library/cmath.rst:259 +#, fuzzy msgid "" -"Return ``True`` if either the real or the imaginary part of *x* is an " +"Return ``True`` if either the real or the imaginary part of *z* is an " "infinity, and ``False`` otherwise." msgstr "如果 *x* 的實部或虛部是無窮大,則回傳 ``True``,否則回傳 ``False``。" -#: ../../library/cmath.rst:214 +#: ../../library/cmath.rst:265 +#, fuzzy msgid "" -"Return ``True`` if either the real or the imaginary part of *x* is a NaN, " +"Return ``True`` if either the real or the imaginary part of *z* is a NaN, " "and ``False`` otherwise." msgstr "如果 *x* 的實部或虛部為 NaN,則回傳 ``True``,否則回傳 ``False``。" -#: ../../library/cmath.rst:220 +#: ../../library/cmath.rst:271 msgid "" "Return ``True`` if the values *a* and *b* are close to each other and " "``False`` otherwise." msgstr "如果 *a* 和 *b* 的值相互接近,則回傳 ``True``,否則回傳 ``False``。" -#: ../../library/cmath.rst:223 +#: ../../library/cmath.rst:274 +#, fuzzy msgid "" "Whether or not two values are considered close is determined according to " -"given absolute and relative tolerances." +"given absolute and relative tolerances. If no errors occur, the result will " +"be: ``abs(a-b) <= max(rel_tol * max(abs(a), abs(b)), abs_tol)``." msgstr "" "兩個值是否被認為相互接近是由給定的絕對和相對容許偏差 (tolerance) 所決定的。" -#: ../../library/cmath.rst:226 +#: ../../library/cmath.rst:278 +#, fuzzy msgid "" "*rel_tol* is the relative tolerance -- it is the maximum allowed difference " "between *a* and *b*, relative to the larger absolute value of *a* or *b*. " "For example, to set a tolerance of 5%, pass ``rel_tol=0.05``. The default " "tolerance is ``1e-09``, which assures that the two values are the same " -"within about 9 decimal digits. *rel_tol* must be greater than zero." +"within about 9 decimal digits. *rel_tol* must be nonnegative and less than " +"``1.0``." msgstr "" "*rel_tol* 是相對容許偏差 -- 它是 *a* 和 *b* 之間的最大容許偏差值,相對於 *a* " "或 *b* 的較大絕對值。例如,要設定 5% 的容許偏差,請傳遞 ``rel_tol=0.05``。預" "設容許偏差是 ``1e-09``,它確保兩個值在大約 9 位十進制數字內相同。 *rel_tol* " "必須大於零。" -#: ../../library/cmath.rst:232 +#: ../../library/cmath.rst:285 msgid "" -"*abs_tol* is the minimum absolute tolerance -- useful for comparisons near " -"zero. *abs_tol* must be at least zero." +"*abs_tol* is the absolute tolerance; it defaults to ``0.0`` and it must be " +"nonnegative. When comparing ``x`` to ``0.0``, ``isclose(x, 0)`` is computed " +"as ``abs(x) <= rel_tol * abs(x)``, which is ``False`` for any ``x`` and " +"rel_tol less than ``1.0``. So add an appropriate positive abs_tol argument " +"to the call." msgstr "" -"*abs_tol* 是最小絕對容許偏差 -- 對於接近零的比較很有用。 *abs_tol* 必須至少為" -"零。" -#: ../../library/cmath.rst:235 -msgid "" -"If no errors occur, the result will be: ``abs(a-b) <= max(rel_tol * " -"max(abs(a), abs(b)), abs_tol)``." -msgstr "" -"如果未發生錯誤,結果將為: ``abs(a-b) <= max(rel_tol * max(abs(a), abs(b)), " -"abs_tol)``。" - -#: ../../library/cmath.rst:238 +#: ../../library/cmath.rst:291 msgid "" "The IEEE 754 special values of ``NaN``, ``inf``, and ``-inf`` will be " "handled according to IEEE rules. Specifically, ``NaN`` is not considered " @@ -355,49 +665,49 @@ msgstr "" "體來說, ``NaN`` 不被認為接近任何其他值,包括 ``NaN``。 ``inf`` 和 ``-inf`` " "只被認為是接近它們自己的。" -#: ../../library/cmath.rst:247 +#: ../../library/cmath.rst:300 msgid ":pep:`485` -- A function for testing approximate equality" msgstr ":pep:`485` -- 一個用來測試近似相等的函式" -#: ../../library/cmath.rst:251 +#: ../../library/cmath.rst:304 msgid "Constants" msgstr "常數" -#: ../../library/cmath.rst:255 +#: ../../library/cmath.rst:308 msgid "The mathematical constant *π*, as a float." msgstr "數學常數 *π*,作為一個浮點數。" -#: ../../library/cmath.rst:260 +#: ../../library/cmath.rst:313 msgid "The mathematical constant *e*, as a float." msgstr "數學常數 *e*,作為一個浮點數。" -#: ../../library/cmath.rst:265 +#: ../../library/cmath.rst:318 msgid "The mathematical constant *τ*, as a float." msgstr "數學常數 *τ*,作為一個浮點數。" -#: ../../library/cmath.rst:272 +#: ../../library/cmath.rst:325 msgid "Floating-point positive infinity. Equivalent to ``float('inf')``." msgstr "正無窮大的浮點數。相當於 ``float('inf')``。" -#: ../../library/cmath.rst:279 +#: ../../library/cmath.rst:332 msgid "" "Complex number with zero real part and positive infinity imaginary part. " "Equivalent to ``complex(0.0, float('inf'))``." msgstr "實部為零和虛部為正無窮的複數。相當於 ``complex(0.0, float('inf'))``。" -#: ../../library/cmath.rst:287 +#: ../../library/cmath.rst:340 msgid "" "A floating-point \"not a number\" (NaN) value. Equivalent to " "``float('nan')``." msgstr "浮點「非數字」 (NaN) 值。相當於 ``float('nan')``。" -#: ../../library/cmath.rst:295 +#: ../../library/cmath.rst:348 msgid "" "Complex number with zero real part and NaN imaginary part. Equivalent to " "``complex(0.0, float('nan'))``." msgstr "實部為零和虛部為 NaN 的複數。相當於 ``complex(0.0, float('nan'))``。" -#: ../../library/cmath.rst:303 +#: ../../library/cmath.rst:356 msgid "" "Note that the selection of functions is similar, but not identical, to that " "in module :mod:`math`. The reason for having two modules is that some users " @@ -413,7 +723,7 @@ msgstr "" "sqrt(-1)`` 引發異常,也不願它回傳複數。另請注意, :mod:`cmath` 中所定義的函式" "始終都會回傳複數,即使答案可以表示為實數(在這種情況下,複數的虛部為零)。" -#: ../../library/cmath.rst:311 +#: ../../library/cmath.rst:364 msgid "" "A note on branch cuts: They are curves along which the given function fails " "to be continuous. They are a necessary feature of many complex functions. " @@ -428,17 +738,31 @@ msgstr "" "所有關於複變函數的(不是太初級的)書籍以獲得啟發。對於如何正確地基於數值目的" "選擇分枝切割的相關訊息,以下內容應該是一個很好的參考:" -#: ../../library/cmath.rst:321 +#: ../../library/cmath.rst:374 msgid "" "Kahan, W: Branch cuts for complex elementary functions; or, Much ado about " "nothing's sign bit. In Iserles, A., and Powell, M. (eds.), The state of the " "art in numerical analysis. Clarendon Press (1987) pp165--211." msgstr "" -#: ../../library/cmath.rst:301 +#: ../../library/cmath.rst:354 msgid "module" msgstr "module(模組)" -#: ../../library/cmath.rst:301 +#: ../../library/cmath.rst:354 msgid "math" msgstr "math(數學)" + +#~ msgid "" +#~ "*abs_tol* is the minimum absolute tolerance -- useful for comparisons " +#~ "near zero. *abs_tol* must be at least zero." +#~ msgstr "" +#~ "*abs_tol* 是最小絕對容許偏差 -- 對於接近零的比較很有用。 *abs_tol* 必須至" +#~ "少為零。" + +#~ msgid "" +#~ "If no errors occur, the result will be: ``abs(a-b) <= max(rel_tol * " +#~ "max(abs(a), abs(b)), abs_tol)``." +#~ msgstr "" +#~ "如果未發生錯誤,結果將為: ``abs(a-b) <= max(rel_tol * max(abs(a), " +#~ "abs(b)), abs_tol)``。" diff --git a/library/cmdline.po b/library/cmdline.po index ed2fd4286f..9c6ac0a2ad 100644 --- a/library/cmdline.po +++ b/library/cmdline.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-05-04 20:08+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-" @@ -62,8 +62,9 @@ msgid ":ref:`dis `" msgstr ":ref:`dis `" #: ../../library/cmdline.rst:16 -msgid ":mod:`doctest`" -msgstr ":mod:`doctest`" +#, fuzzy +msgid ":ref:`doctest `" +msgstr ":ref:`ast `" #: ../../library/cmdline.rst:17 msgid ":mod:`!encodings.rot_13`" @@ -122,8 +123,9 @@ msgid ":ref:`pickletools `" msgstr ":ref:`pickletools `" #: ../../library/cmdline.rst:31 -msgid ":mod:`platform`" -msgstr ":mod:`platform`" +#, fuzzy +msgid ":ref:`platform `" +msgstr ":ref:`ast `" #: ../../library/cmdline.rst:32 msgid ":mod:`poplib`" @@ -171,61 +173,72 @@ msgid ":ref:`sqlite3 `" msgstr ":ref:`sqlite3 `" #: ../../library/cmdline.rst:43 +#, fuzzy +msgid ":ref:`symtable `" +msgstr ":ref:`trace `" + +#: ../../library/cmdline.rst:44 msgid ":ref:`sysconfig `" msgstr ":ref:`sysconfig `" -#: ../../library/cmdline.rst:44 +#: ../../library/cmdline.rst:45 msgid ":mod:`tabnanny`" msgstr ":mod:`tabnanny`" -#: ../../library/cmdline.rst:45 +#: ../../library/cmdline.rst:46 msgid ":ref:`tarfile `" msgstr ":ref:`tarfile `" -#: ../../library/cmdline.rst:46 +#: ../../library/cmdline.rst:47 msgid ":mod:`!this`" msgstr ":mod:`!this`" -#: ../../library/cmdline.rst:47 +#: ../../library/cmdline.rst:48 msgid ":ref:`timeit `" msgstr ":ref:`timeit `" -#: ../../library/cmdline.rst:48 +#: ../../library/cmdline.rst:49 msgid ":ref:`tokenize `" msgstr ":ref:`tokenize `" -#: ../../library/cmdline.rst:49 +#: ../../library/cmdline.rst:50 msgid ":ref:`trace `" msgstr ":ref:`trace `" -#: ../../library/cmdline.rst:50 +#: ../../library/cmdline.rst:51 msgid ":mod:`turtledemo`" msgstr ":mod:`turtledemo`" -#: ../../library/cmdline.rst:51 +#: ../../library/cmdline.rst:52 msgid ":ref:`unittest `" msgstr ":ref:`unittest `" -#: ../../library/cmdline.rst:52 +#: ../../library/cmdline.rst:53 msgid ":ref:`uuid `" msgstr ":ref:`uuid `" -#: ../../library/cmdline.rst:53 +#: ../../library/cmdline.rst:54 msgid ":mod:`venv`" msgstr ":mod:`venv`" -#: ../../library/cmdline.rst:54 +#: ../../library/cmdline.rst:55 msgid ":mod:`webbrowser`" msgstr ":mod:`webbrowser`" -#: ../../library/cmdline.rst:55 +#: ../../library/cmdline.rst:56 msgid ":ref:`zipapp `" msgstr ":ref:`zipapp `" -#: ../../library/cmdline.rst:56 +#: ../../library/cmdline.rst:57 msgid ":ref:`zipfile `" msgstr ":ref:`zipfile `" -#: ../../library/cmdline.rst:58 +#: ../../library/cmdline.rst:59 msgid "See also the :ref:`Python command-line interface `." msgstr "另請見 :ref:`Python 命令列介面 `。" + +#~ msgid ":mod:`platform`" +#~ msgstr ":mod:`platform`" + +#~ msgid ":mod:`doctest`" +#~ msgstr ":mod:`doctest`" diff --git a/library/cmdlinelibs.po b/library/cmdlinelibs.po new file mode 100644 index 0000000000..7f602d81ea --- /dev/null +++ b/library/cmdlinelibs.po @@ -0,0 +1,32 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2001-2024, Python Software Foundation +# This file is distributed under the same license as the Python package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Python 3.13\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-12-29 16:19+0000\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: zh_TW\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: ../../library/cmdlinelibs.rst:5 +msgid "Command Line Interface Libraries" +msgstr "" + +#: ../../library/cmdlinelibs.rst:7 +msgid "" +"The modules described in this chapter assist with implementing command line " +"and terminal interfaces for applications." +msgstr "" + +#: ../../library/cmdlinelibs.rst:10 +msgid "Here's an overview:" +msgstr "" diff --git a/library/codecs.po b/library/codecs.po index aa60cd8b84..09b655217e 100644 --- a/library/codecs.po +++ b/library/codecs.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-04-24 05:56+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-" @@ -1537,7 +1537,7 @@ msgstr "855, IBM855" #: ../../library/codecs.rst:1106 ../../library/codecs.rst:1154 #: ../../library/codecs.rst:1219 ../../library/codecs.rst:1256 -msgid "Bulgarian, Byelorussian, Macedonian, Russian, Serbian" +msgid "Belarusian, Bulgarian, Macedonian, Russian, Serbian" msgstr "" #: ../../library/codecs.rst:1109 @@ -2652,8 +2652,8 @@ msgid "This module implements the ANSI codepage (CP_ACP)." msgstr "" #: ../../library/codecs.rst:1542 -msgid ":ref:`Availability `: Windows." -msgstr ":ref:`適用 `:Windows。" +msgid "Availability" +msgstr "" #: ../../library/codecs.rst:1544 msgid "" @@ -2767,6 +2767,9 @@ msgstr "\\N" msgid "surrogatepass" msgstr "surrogatepass" +#~ msgid ":ref:`Availability `: Windows." +#~ msgstr ":ref:`適用 `:Windows。" + #, fuzzy #~ msgid "" #~ ":meth:`!uu.encode` / :meth:`!uu.decode` (Note: :mod:`uu` is deprecated.)" diff --git a/library/collections.abc.po b/library/collections.abc.po index 0012205941..f14978c0e6 100644 --- a/library/collections.abc.po +++ b/library/collections.abc.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-07 03:11+0800\n" +"POT-Creation-Date: 2025-03-03 18:39+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-" @@ -46,7 +46,7 @@ msgstr "" #: ../../library/collections.abc.rst:30 msgid "" -"1) A newly written class can inherit directly from one of the abstract base " +"A newly written class can inherit directly from one of the abstract base " "classes. The class must supply the required abstract methods. The " "remaining mixin methods come from inheritance and can be overridden if " "desired. Other methods may be added as needed:" @@ -72,7 +72,7 @@ msgstr "" #: ../../library/collections.abc.rst:50 msgid "" -"2) Existing classes and built-in classes can be registered as \"virtual " +"Existing classes and built-in classes can be registered as \"virtual " "subclasses\" of the ABCs. Those classes should define the full API " "including all of the abstract methods and all of the mixin methods. This " "lets users rely on :func:`issubclass` or :func:`isinstance` tests to " @@ -112,11 +112,11 @@ msgstr "" #: ../../library/collections.abc.rst:82 msgid "" -"3) Some simple interfaces are directly recognizable by the presence of the " +"Some simple interfaces are directly recognizable by the presence of the " "required methods (unless those methods have been set to :const:`None`):" msgstr "" -#: ../../library/collections.abc.rst:86 +#: ../../library/collections.abc.rst:85 msgid "" "class E:\n" " def __iter__(self): ...\n" @@ -126,7 +126,7 @@ msgstr "" " def __iter__(self): ...\n" " def __next__(self): ..." -#: ../../library/collections.abc.rst:92 +#: ../../library/collections.abc.rst:91 msgid "" ">>> issubclass(E, Iterable)\n" "True\n" @@ -138,7 +138,7 @@ msgstr "" ">>> isinstance(E(), Iterable)\n" "True" -#: ../../library/collections.abc.rst:99 +#: ../../library/collections.abc.rst:98 msgid "" "Complex interfaces do not support this last technique because an interface " "is more than just the presence of method names. Interfaces specify " @@ -148,181 +148,183 @@ msgid "" "insufficient for distinguishing a :class:`Sequence` from a :class:`Mapping`." msgstr "" -#: ../../library/collections.abc.rst:107 +#: ../../library/collections.abc.rst:106 msgid "" "These abstract classes now support ``[]``. See :ref:`types-genericalias` " "and :pep:`585`." msgstr "" -#: ../../library/collections.abc.rst:114 +#: ../../library/collections.abc.rst:113 msgid "Collections Abstract Base Classes" msgstr "" -#: ../../library/collections.abc.rst:116 +#: ../../library/collections.abc.rst:115 msgid "" "The collections module offers the following :term:`ABCs `:" msgstr "" -#: ../../library/collections.abc.rst:121 +#: ../../library/collections.abc.rst:120 msgid "ABC" msgstr "ABC" -#: ../../library/collections.abc.rst:121 +#: ../../library/collections.abc.rst:120 msgid "Inherits from" msgstr "" -#: ../../library/collections.abc.rst:121 +#: ../../library/collections.abc.rst:120 msgid "Abstract Methods" msgstr "" -#: ../../library/collections.abc.rst:121 +#: ../../library/collections.abc.rst:120 msgid "Mixin Methods" msgstr "" -#: ../../library/collections.abc.rst:123 +#: ../../library/collections.abc.rst:122 msgid ":class:`Container` [1]_" msgstr ":class:`Container` [1]_" -#: ../../library/collections.abc.rst:123 +#: ../../library/collections.abc.rst:122 msgid "``__contains__``" msgstr "``__contains__``" -#: ../../library/collections.abc.rst:124 +#: ../../library/collections.abc.rst:123 msgid ":class:`Hashable` [1]_" msgstr ":class:`Hashable` [1]_" -#: ../../library/collections.abc.rst:124 +#: ../../library/collections.abc.rst:123 msgid "``__hash__``" msgstr "``__hash__``" -#: ../../library/collections.abc.rst:125 +#: ../../library/collections.abc.rst:124 msgid ":class:`Iterable` [1]_ [2]_" msgstr ":class:`Iterable` [1]_ [2]_" -#: ../../library/collections.abc.rst:125 ../../library/collections.abc.rst:126 +#: ../../library/collections.abc.rst:124 ../../library/collections.abc.rst:125 msgid "``__iter__``" msgstr "``__iter__``" -#: ../../library/collections.abc.rst:126 +#: ../../library/collections.abc.rst:125 msgid ":class:`Iterator` [1]_" msgstr ":class:`Iterator` [1]_" -#: ../../library/collections.abc.rst:126 ../../library/collections.abc.rst:127 +#: ../../library/collections.abc.rst:125 ../../library/collections.abc.rst:126 msgid ":class:`Iterable`" msgstr ":class:`Iterable`" -#: ../../library/collections.abc.rst:126 +#: ../../library/collections.abc.rst:125 msgid "``__next__``" msgstr "``__next__``" -#: ../../library/collections.abc.rst:127 +#: ../../library/collections.abc.rst:126 msgid ":class:`Reversible` [1]_" msgstr ":class:`Reversible` [1]_" -#: ../../library/collections.abc.rst:127 +#: ../../library/collections.abc.rst:126 msgid "``__reversed__``" msgstr "``__reversed__``" -#: ../../library/collections.abc.rst:128 +#: ../../library/collections.abc.rst:127 msgid ":class:`Generator` [1]_" msgstr ":class:`Generator` [1]_" -#: ../../library/collections.abc.rst:128 +#: ../../library/collections.abc.rst:127 msgid ":class:`Iterator`" msgstr ":class:`Iterator`" -#: ../../library/collections.abc.rst:128 ../../library/collections.abc.rst:176 +#: ../../library/collections.abc.rst:127 ../../library/collections.abc.rst:176 msgid "``send``, ``throw``" msgstr "``send``、``throw``" -#: ../../library/collections.abc.rst:128 +#: ../../library/collections.abc.rst:127 msgid "``close``, ``__iter__``, ``__next__``" msgstr "``close``、``__iter__``、``__next__``" -#: ../../library/collections.abc.rst:129 +#: ../../library/collections.abc.rst:128 msgid ":class:`Sized` [1]_" msgstr ":class:`Sized` [1]_" -#: ../../library/collections.abc.rst:129 ../../library/collections.abc.rst:168 +#: ../../library/collections.abc.rst:128 msgid "``__len__``" msgstr "``__len__``" -#: ../../library/collections.abc.rst:130 +#: ../../library/collections.abc.rst:129 msgid ":class:`Callable` [1]_" msgstr ":class:`Callable` [1]_" -#: ../../library/collections.abc.rst:130 +#: ../../library/collections.abc.rst:129 msgid "``__call__``" msgstr "``__call__``" -#: ../../library/collections.abc.rst:131 +#: ../../library/collections.abc.rst:130 msgid ":class:`Collection` [1]_" msgstr ":class:`Collection` [1]_" -#: ../../library/collections.abc.rst:131 +#: ../../library/collections.abc.rst:130 msgid ":class:`Sized`, :class:`Iterable`, :class:`Container`" msgstr ":class:`Sized`、:class:`Iterable`、:class:`Container`" -#: ../../library/collections.abc.rst:131 ../../library/collections.abc.rst:147 +#: ../../library/collections.abc.rst:130 ../../library/collections.abc.rst:146 msgid "``__contains__``, ``__iter__``, ``__len__``" msgstr "``__contains__``、``__iter__``、``__len__``" -#: ../../library/collections.abc.rst:135 ../../library/collections.abc.rst:138 -#: ../../library/collections.abc.rst:144 +#: ../../library/collections.abc.rst:134 ../../library/collections.abc.rst:137 +#: ../../library/collections.abc.rst:143 msgid ":class:`Sequence`" msgstr ":class:`Sequence`" -#: ../../library/collections.abc.rst:135 +#: ../../library/collections.abc.rst:134 msgid ":class:`Reversible`, :class:`Collection`" msgstr ":class:`Reversible`, :class:`Collection`" -#: ../../library/collections.abc.rst:135 ../../library/collections.abc.rst:144 +#: ../../library/collections.abc.rst:134 ../../library/collections.abc.rst:143 msgid "``__getitem__``, ``__len__``" msgstr "``__getitem__``、``__len__``" -#: ../../library/collections.abc.rst:135 +#: ../../library/collections.abc.rst:134 msgid "" "``__contains__``, ``__iter__``, ``__reversed__``, ``index``, and ``count``" msgstr "" "``__contains__``、``__iter__``、``__reversed__``、``index`` 和 ``count``" -#: ../../library/collections.abc.rst:138 +#: ../../library/collections.abc.rst:137 msgid ":class:`MutableSequence`" msgstr ":class:`MutableSequence`" -#: ../../library/collections.abc.rst:138 +#: ../../library/collections.abc.rst:137 msgid "" "``__getitem__``, ``__setitem__``, ``__delitem__``, ``__len__``, ``insert``" msgstr "" "``__getitem__``、``__setitem__``、``__delitem__``、``__len__``、``insert``" -#: ../../library/collections.abc.rst:138 +#: ../../library/collections.abc.rst:137 msgid "" "Inherited :class:`Sequence` methods and ``append``, ``clear``, ``reverse``, " "``extend``, ``pop``, ``remove``, and ``__iadd__``" msgstr "" -#: ../../library/collections.abc.rst:144 +#: ../../library/collections.abc.rst:143 msgid ":class:`ByteString`" msgstr ":class:`ByteString`" -#: ../../library/collections.abc.rst:144 +#: ../../library/collections.abc.rst:143 msgid "Inherited :class:`Sequence` methods" msgstr "" -#: ../../library/collections.abc.rst:147 ../../library/collections.abc.rst:151 +#: ../../library/collections.abc.rst:146 ../../library/collections.abc.rst:151 msgid ":class:`Set`" msgstr ":class:`Set`" -#: ../../library/collections.abc.rst:147 ../../library/collections.abc.rst:157 +#: ../../library/collections.abc.rst:146 ../../library/collections.abc.rst:157 msgid ":class:`Collection`" msgstr ":class:`Collection`" -#: ../../library/collections.abc.rst:147 +#: ../../library/collections.abc.rst:146 +#, fuzzy msgid "" "``__le__``, ``__lt__``, ``__eq__``, ``__ne__``, ``__gt__``, ``__ge__``, " -"``__and__``, ``__or__``, ``__sub__``, ``__xor__``, and ``isdisjoint``" +"``__and__``, ``__or__``, ``__sub__``, ``__rsub__``, ``__xor__``, " +"``__rxor__`` and ``isdisjoint``" msgstr "" "``__le__``、``__lt__``、``__eq__``、``__ne__``、``__gt__``、``__ge__``、" "``__and__``、``__or__``、``__sub__``、``__xor__`` 與 ``isdisjoint``" @@ -381,6 +383,11 @@ msgstr ":class:`MappingView`" msgid ":class:`Sized`" msgstr ":class:`Sized`" +#: ../../library/collections.abc.rst:168 +#, fuzzy +msgid "``__init__``, ``__len__`` and ``__repr__``" +msgstr "``__getitem__``、``__iter__``、``__len__``" + #: ../../library/collections.abc.rst:169 msgid ":class:`ItemsView`" msgstr ":class:`ItemsView`" diff --git a/library/collections.po b/library/collections.po index 28d2d79ade..98b4c56ffb 100644 --- a/library/collections.po +++ b/library/collections.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-03-03 18:39+0000\n" "PO-Revision-Date: 2024-01-22 21:42+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -1184,10 +1184,11 @@ msgstr "" "`~object.__getitem__` 所傳遞。" #: ../../library/collections.rst:750 +#, fuzzy msgid "" "Note that :meth:`__missing__` is *not* called for any operations besides :" -"meth:`~object.__getitem__`. This means that :meth:`get` will, like normal " -"dictionaries, return ``None`` as a default rather than using :attr:" +"meth:`~object.__getitem__`. This means that :meth:`~dict.get` will, like " +"normal dictionaries, return ``None`` as a default rather than using :attr:" "`default_factory`." msgstr "" "注意,:meth:`__missing__` *不會*\\ 被 :meth:`~object.__getitem__` 以外的其他" @@ -1207,7 +1208,7 @@ msgstr "" "此屬性為 :meth:`__missing__` 方法所使用。如果有引數被傳入建構函式,則此屬性會" "被初始化成第一個引數,如未提供引數則被初始化為 ``None``。" -#: ../../library/collections.rst:765 ../../library/collections.rst:1188 +#: ../../library/collections.rst:765 ../../library/collections.rst:1192 msgid "" "Added merge (``|``) and update (``|=``) operators, specified in :pep:`584`." msgstr "新增合併 (``|``) 和更新 (``|=``) 運算子,請見 :pep:`584`。" @@ -1225,13 +1226,14 @@ msgstr "" "值對序列轉換為包含 list 之字典:" #: ../../library/collections.rst:784 +#, fuzzy 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 value to the new list. When keys " +"default_factory` function which returns an 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 " +"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 "" @@ -1296,12 +1298,14 @@ msgstr "" "來存取欄位的能力。" #: ../../library/collections.rst:849 +#, fuzzy msgid "" "Returns a new tuple subclass named *typename*. The new subclass is used to " "create tuple-like objects that have fields accessible by attribute lookup as " "well as being indexable and iterable. Instances of the subclass also have a " -"helpful docstring (with typename and field_names) and a helpful :meth:" -"`__repr__` method which lists the tuple contents in a ``name=value`` format." +"helpful docstring (with *typename* and *field_names*) and a helpful :meth:" +"`~object.__repr__` method which lists the tuple contents in a ``name=value`` " +"format." msgstr "" "回傳一個名為 *typename* 的新 tuple 子類別。這個新的子類別被用於建立類似 " "tuple 的物件,可以透過屬性名稱來存取欄位,它同時也是可索引 (indexable) 和可疊" @@ -1309,7 +1313,7 @@ msgstr "" "位名 field_names)和一個好用的 :meth:`__repr__` 方法,可將 tuple 內容以 " "``name=value`` 格式列出。" -#: ../../library/collections.rst:855 +#: ../../library/collections.rst:856 msgid "" "The *field_names* are a sequence of strings such as ``['x', 'y']``. " "Alternatively, *field_names* can be a single string with each fieldname " @@ -1318,7 +1322,7 @@ msgstr "" "*field_names* 是一個像 ``['x', 'y']`` 一樣的字串序列。*field_names* 也可以是" "一個用空白或逗號分隔各個欄位名稱的字串,比如 ``'x y'`` 或者 ``'x, y'``。" -#: ../../library/collections.rst:859 +#: ../../library/collections.rst:860 msgid "" "Any valid Python identifier may be used for a fieldname except for names " "starting with an underscore. Valid identifiers consist of letters, digits, " @@ -1330,7 +1334,7 @@ msgstr "" "詞 :mod:`keyword`,例如 *class*、*for*、*return*、*global*、*pass* 或 " "*raise*。" -#: ../../library/collections.rst:865 +#: ../../library/collections.rst:866 msgid "" "If *rename* is true, invalid fieldnames are automatically replaced with " "positional names. For example, ``['abc', 'def', 'ghi', 'abc']`` is " @@ -1341,7 +1345,7 @@ msgstr "" "'def', 'ghi', 'abc']`` 會被轉換成 ``['abc', '_1', 'ghi', '_3']``,移除了關鍵" "字 ``def`` 和重複欄位名 ``abc``。" -#: ../../library/collections.rst:870 +#: ../../library/collections.rst:871 msgid "" "*defaults* can be ``None`` or an :term:`iterable` of default values. Since " "fields with a default value must come after any fields without a default, " @@ -1355,14 +1359,15 @@ msgstr "" "如 fieldnames 為 ``['x', 'y', 'z']`` 且 defaults 為 ``(1, 2)``,那麼 ``x`` 就" "必須被給定一個引數,``y`` 被預設為 ``1``,``z`` 則被預設為 ``2``。" -#: ../../library/collections.rst:877 +#: ../../library/collections.rst:878 +#, fuzzy msgid "" -"If *module* is defined, the ``__module__`` attribute of the named tuple is " -"set to that value." +"If *module* is defined, the :attr:`~type.__module__` attribute of the named " +"tuple is set to that value." msgstr "" "如果 *module* 值有被定義,named tuple 的 ``__module__`` 屬性就被設定為該值。" -#: ../../library/collections.rst:880 +#: ../../library/collections.rst:881 msgid "" "Named tuple instances do not have per-instance dictionaries, so they are " "lightweight and require no more memory than regular tuples." @@ -1370,17 +1375,17 @@ msgstr "" "Named tuple 實例中沒有字典,所以它們更加輕量,且和一般 tuple 相比佔用更少記憶" "體。" -#: ../../library/collections.rst:883 +#: ../../library/collections.rst:884 msgid "" "To support pickling, the named tuple class should be assigned to a variable " "that matches *typename*." msgstr "要支援 pickle,應將 named tuple 類別賦值給一個符合 *typename* 的變數。" -#: ../../library/collections.rst:886 +#: ../../library/collections.rst:887 msgid "Added support for *rename*." msgstr "新增對於 *rename* 的支援。" -#: ../../library/collections.rst:889 +#: ../../library/collections.rst:890 msgid "" "The *verbose* and *rename* parameters became :ref:`keyword-only arguments " "`." @@ -1388,20 +1393,23 @@ msgstr "" "*verbose* 和 *rename* 參數成為\\ :ref:`僅限關鍵字引數 `。" -#: ../../library/collections.rst:893 +#: ../../library/collections.rst:894 msgid "Added the *module* parameter." msgstr "新增 *module* 參數。" -#: ../../library/collections.rst:896 -msgid "Removed the *verbose* parameter and the :attr:`_source` attribute." +#: ../../library/collections.rst:897 +#, fuzzy +msgid "Removed the *verbose* parameter and the :attr:`!_source` attribute." msgstr "移除 *verbose* 參數和 :attr:`_source` 屬性。" -#: ../../library/collections.rst:899 +#: ../../library/collections.rst:900 +#, fuzzy msgid "" -"Added the *defaults* parameter and the :attr:`_field_defaults` attribute." +"Added the *defaults* parameter and the :attr:`~somenamedtuple." +"_field_defaults` attribute." msgstr "新增 *defaults* 參數和 :attr:`_field_defaults` 屬性。" -#: ../../library/collections.rst:903 +#: ../../library/collections.rst:904 msgid "" ">>> # Basic example\n" ">>> Point = namedtuple('Point', ['x', 'y'])\n" @@ -1418,7 +1426,7 @@ msgid "" "Point(x=11, y=22)" msgstr "" -#: ../../library/collections.rst:919 +#: ../../library/collections.rst:920 msgid "" "Named tuples are especially useful for assigning field names to result " "tuples returned by the :mod:`csv` or :mod:`sqlite3` modules::" @@ -1426,7 +1434,7 @@ msgstr "" "Named tuple 在賦予欄位名稱於 :mod:`csv` 或 :mod:`sqlite3` 模組回傳之 tuple 時" "相當有用: ::" -#: ../../library/collections.rst:922 +#: ../../library/collections.rst:923 msgid "" "EmployeeRecord = namedtuple('EmployeeRecord', 'name, age, title, department, " "paygrade')\n" @@ -1460,7 +1468,7 @@ msgstr "" "for emp in map(EmployeeRecord._make, cursor.fetchall()):\n" " print(emp.name, emp.title)" -#: ../../library/collections.rst:935 +#: ../../library/collections.rst:936 msgid "" "In addition to the methods inherited from tuples, named tuples support three " "additional methods and two attributes. To prevent conflicts with field " @@ -1469,12 +1477,12 @@ msgstr "" "除了繼承自 tuple 的方法,named tuple 還支援三個額外的方法和兩個屬性。為了防止" "欄位名稱有衝突,方法和屬性的名稱以底線開頭。" -#: ../../library/collections.rst:941 +#: ../../library/collections.rst:942 msgid "" "Class method that makes a new instance from an existing sequence or iterable." msgstr "從已存在的序列或可疊代物件建立一個新實例的類別方法。" -#: ../../library/collections.rst:943 +#: ../../library/collections.rst:944 msgid "" ">>> t = [11, 22]\n" ">>> Point._make(t)\n" @@ -1484,13 +1492,13 @@ msgstr "" ">>> Point._make(t)\n" "Point(x=11, y=22)" -#: ../../library/collections.rst:951 +#: ../../library/collections.rst:952 msgid "" "Return a new :class:`dict` which maps field names to their corresponding " "values:" msgstr "回傳一個將欄位名稱對映至對應值的 :class:`dict`:" -#: ../../library/collections.rst:954 +#: ../../library/collections.rst:955 msgid "" ">>> p = Point(x=11, y=22)\n" ">>> p._asdict()\n" @@ -1500,11 +1508,11 @@ msgstr "" ">>> p._asdict()\n" "{'x': 11, 'y': 22}" -#: ../../library/collections.rst:960 +#: ../../library/collections.rst:961 msgid "Returns an :class:`OrderedDict` instead of a regular :class:`dict`." msgstr "回傳一個 :class:`OrderedDict` 而非 :class:`dict`。" -#: ../../library/collections.rst:963 +#: ../../library/collections.rst:964 msgid "" "Returns a regular :class:`dict` instead of an :class:`OrderedDict`. As of " "Python 3.7, regular dicts are guaranteed to be ordered. If the extra " @@ -1515,13 +1523,13 @@ msgstr "" "dict 已經保證有順序性,如果需要 :class:`OrderedDict` 所專屬的特性,推薦的解法" "是將結果專換成所需的類型:``OrderedDict(nt._asdict())``。" -#: ../../library/collections.rst:972 +#: ../../library/collections.rst:973 msgid "" "Return a new instance of the named tuple replacing specified fields with new " "values::" msgstr "回傳一個新的 named tuple 實例,並將指定欄位替換為新的值: ::" -#: ../../library/collections.rst:975 +#: ../../library/collections.rst:976 msgid "" ">>> p = Point(x=11, y=22)\n" ">>> p._replace(x=33)\n" @@ -1539,18 +1547,18 @@ msgstr "" "... inventory[partnum] = record._replace(price=newprices[partnum], " "timestamp=time.now())" -#: ../../library/collections.rst:982 +#: ../../library/collections.rst:983 msgid "" "Named tuples are also supported by generic function :func:`copy.replace`." msgstr "" -#: ../../library/collections.rst:984 +#: ../../library/collections.rst:985 msgid "" "Raise :exc:`TypeError` instead of :exc:`ValueError` for invalid keyword " "arguments." msgstr "" -#: ../../library/collections.rst:990 +#: ../../library/collections.rst:991 msgid "" "Tuple of strings listing the field names. Useful for introspection and for " "creating new named tuple types from existing named tuples." @@ -1558,7 +1566,7 @@ msgstr "" "列出 tuple 欄位名稱的字串,用於自我檢查或是從現有 named tuple 建立一個新的 " "named tuple 型別。" -#: ../../library/collections.rst:993 +#: ../../library/collections.rst:994 msgid "" ">>> p._fields # view the field names\n" "('x', 'y')\n" @@ -1569,11 +1577,11 @@ msgid "" "Pixel(x=11, y=22, red=128, green=255, blue=0)" msgstr "" -#: ../../library/collections.rst:1005 +#: ../../library/collections.rst:1006 msgid "Dictionary mapping field names to default values." msgstr "將欄位名稱對映至預設值的字典。" -#: ../../library/collections.rst:1007 +#: ../../library/collections.rst:1008 msgid "" ">>> Account = namedtuple('Account', ['type', 'balance'], defaults=[0])\n" ">>> Account._field_defaults\n" @@ -1587,13 +1595,13 @@ msgstr "" ">>> Account('premium')\n" "Account(type='premium', balance=0)" -#: ../../library/collections.rst:1015 +#: ../../library/collections.rst:1016 msgid "" "To retrieve a field whose name is stored in a string, use the :func:" "`getattr` function:" msgstr "要取得這個名稱存於字串的欄位,要使用 :func:`getattr` 函式:" -#: ../../library/collections.rst:1021 +#: ../../library/collections.rst:1022 msgid "" "To convert a dictionary to a named tuple, use the double-star-operator (as " "described in :ref:`tut-unpacking-arguments`):" @@ -1601,7 +1609,7 @@ msgstr "" "(如\\ :ref:`tut-unpacking-arguments`\\ 所述)將一個字典轉換成 named tuple," "要使用 \\*\\* 雙星號運算子:" -#: ../../library/collections.rst:1028 +#: ../../library/collections.rst:1029 msgid "" "Since a named tuple is a regular Python class, it is easy to add or change " "functionality with a subclass. Here is how to add a calculated field and a " @@ -1610,7 +1618,7 @@ msgstr "" "因為一個 named tuple 是一個常規的 Python 類別,我們可以很容易的透過子類別來新" "增或更改功能,以下是如何新增一個計算得到的欄位和固定寬度的輸出列印格式:" -#: ../../library/collections.rst:1032 +#: ../../library/collections.rst:1033 msgid "" ">>> class Point(namedtuple('Point', ['x', 'y'])):\n" "... __slots__ = ()\n" @@ -1640,7 +1648,7 @@ msgstr "" "Point: x= 3.000 y= 4.000 hypot= 5.000\n" "Point: x=14.000 y= 0.714 hypot=14.018" -#: ../../library/collections.rst:1047 +#: ../../library/collections.rst:1048 msgid "" "The subclass shown above sets ``__slots__`` to an empty tuple. This helps " "keep memory requirements low by preventing the creation of instance " @@ -1649,7 +1657,7 @@ msgstr "" "上面的子類別將 ``__slots__`` 設定為空 tuple,這樣一來就防止了字典實例被建立," "因而保持了較低的記憶體用量。" -#: ../../library/collections.rst:1050 +#: ../../library/collections.rst:1051 msgid "" "Subclassing is not useful for adding new, stored fields. Instead, simply " "create a new named tuple type from the :attr:`~somenamedtuple._fields` " @@ -1658,17 +1666,17 @@ msgstr "" "子類別化無法用於增加新的、已被儲存的欄位,應當透過 :attr:`~somenamedtuple." "_fields` 屬性以建立一個新的 named tuple 來實現:" -#: ../../library/collections.rst:1055 +#: ../../library/collections.rst:1056 msgid "" "Docstrings can be customized by making direct assignments to the ``__doc__`` " "fields:" msgstr "透過直接賦值給 ``__doc__``,可以自訂說明文件字串:" -#: ../../library/collections.rst:1064 +#: ../../library/collections.rst:1065 msgid "Property docstrings became writeable." msgstr "文件字串屬性變成可寫入。" -#: ../../library/collections.rst:1069 +#: ../../library/collections.rst:1070 msgid "" "See :class:`typing.NamedTuple` for a way to add type hints for named " "tuples. It also provides an elegant notation using the :keyword:`class` " @@ -1677,7 +1685,7 @@ msgstr "" "關於為 named tuple 新增型別提示的方法,請參閱 :class:`typing.NamedTuple`,它" "運用 :keyword:`class` 關鍵字以提供了一個簡潔的表示法: ::" -#: ../../library/collections.rst:1073 +#: ../../library/collections.rst:1074 msgid "" "class Component(NamedTuple):\n" " part_number: int\n" @@ -1689,7 +1697,7 @@ msgstr "" " weight: float\n" " description: Optional[str] = None" -#: ../../library/collections.rst:1078 +#: ../../library/collections.rst:1079 msgid "" "See :meth:`types.SimpleNamespace` for a mutable namespace based on an " "underlying dictionary instead of a tuple." @@ -1697,7 +1705,7 @@ msgstr "" "關於以 dict 而非 tuple 為底層的可變命名空間,請參考 :meth:`types." "SimpleNamespace`。" -#: ../../library/collections.rst:1081 +#: ../../library/collections.rst:1082 msgid "" "The :mod:`dataclasses` module provides a decorator and functions for " "automatically adding generated special methods to user-defined classes." @@ -1705,11 +1713,11 @@ msgstr "" ":mod:`dataclasses` 模組提供了一個裝飾器和一些函式,用於自動將被生成的特殊方法" "新增到使用者定義的類別中。" -#: ../../library/collections.rst:1086 +#: ../../library/collections.rst:1087 msgid ":class:`OrderedDict` objects" msgstr ":class:`OrderedDict` 物件" -#: ../../library/collections.rst:1088 +#: ../../library/collections.rst:1089 msgid "" "Ordered dictionaries are just like regular dictionaries but have some extra " "capabilities relating to ordering operations. They have become less " @@ -1720,11 +1728,11 @@ msgstr "" "功能,但由於內建的 :class:`dict` 類別現在已經有記憶插入順序的能力(Python " "3.7 中確保了這種新行為),它們變得不那麼重要了。" -#: ../../library/collections.rst:1094 +#: ../../library/collections.rst:1095 msgid "Some differences from :class:`dict` still remain:" msgstr "仍存在一些與 :class:`dict` 的不同之處:" -#: ../../library/collections.rst:1096 +#: ../../library/collections.rst:1097 msgid "" "The regular :class:`dict` was designed to be very good at mapping " "operations. Tracking insertion order was secondary." @@ -1732,7 +1740,7 @@ msgstr "" "常規的 :class:`dict` 被設計成非常擅長於對映相關操作,追蹤插入的順序為次要目" "標。" -#: ../../library/collections.rst:1099 +#: ../../library/collections.rst:1100 msgid "" "The :class:`OrderedDict` was designed to be good at reordering operations. " "Space efficiency, iteration speed, and the performance of update operations " @@ -1741,7 +1749,7 @@ msgstr "" ":class:`OrderedDict` 則被設計成擅長於重新排序相關的操作,空間效率、疊代速度和" "更新操作的效能則為次要設計目標。" -#: ../../library/collections.rst:1103 +#: ../../library/collections.rst:1104 msgid "" "The :class:`OrderedDict` algorithm can handle frequent reordering operations " "better than :class:`dict`. As shown in the recipes below, this makes it " @@ -1750,12 +1758,12 @@ msgstr "" ":class:`OrderedDict` 比起 :class:`dict` 更適合處理頻繁的重新排序操作,如在下" "方用法中所示,這讓它適合用於多種 LRU cache 的實作中。" -#: ../../library/collections.rst:1107 +#: ../../library/collections.rst:1108 msgid "" "The equality operation for :class:`OrderedDict` checks for matching order." msgstr ":class:`OrderedDict` 之相等性運算會檢查順序是否相同。" -#: ../../library/collections.rst:1109 +#: ../../library/collections.rst:1110 msgid "" "A regular :class:`dict` can emulate the order sensitive equality test with " "``p == q and all(k1 == k2 for k1, k2 in zip(p, q))``." @@ -1763,15 +1771,17 @@ msgstr "" "一個一般的 :class:`dict` 可以用 ``p == q and all(k1 == k2 for k1, k2 in " "zip(p, q))`` 來效仿有檢查順序的相等性運算。" -#: ../../library/collections.rst:1112 +#: ../../library/collections.rst:1113 +#, fuzzy msgid "" -"The :meth:`popitem` method of :class:`OrderedDict` has a different " -"signature. It accepts an optional argument to specify which item is popped." +"The :meth:`~OrderedDict.popitem` method of :class:`OrderedDict` has a " +"different signature. It accepts an optional argument to specify which item " +"is popped." msgstr "" ":class:`OrderedDict` 類別的 :meth:`popitem` 方法有不同的函式簽名 " "(signature),它接受傳入一個選擇性引數來指定要移除哪個元素。" -#: ../../library/collections.rst:1115 +#: ../../library/collections.rst:1116 msgid "" "A regular :class:`dict` can emulate OrderedDict's ``od.popitem(last=True)`` " "with ``d.popitem()`` which is guaranteed to pop the rightmost (last) item." @@ -1779,7 +1789,7 @@ msgstr "" "一個一般的 :class:`dict` 可以用 ``d.popitem()`` 來效仿 OrderedDict 的 ``od." "popitem(last=True)``,這保證會移除最右邊(最後一個)的元素。" -#: ../../library/collections.rst:1118 +#: ../../library/collections.rst:1119 msgid "" "A regular :class:`dict` can emulate OrderedDict's ``od.popitem(last=False)`` " "with ``(k := next(iter(d)), d.pop(k))`` which will return and remove the " @@ -1789,15 +1799,16 @@ msgstr "" "OrderedDict 的 ``od.popitem(last=False)``,若最左邊(第一個)的元素存在,則將" "其回傳並移除。" -#: ../../library/collections.rst:1122 +#: ../../library/collections.rst:1123 +#, fuzzy msgid "" -":class:`OrderedDict` has a :meth:`move_to_end` method to efficiently " -"reposition an element to an endpoint." +":class:`OrderedDict` has a :meth:`~OrderedDict.move_to_end` method to " +"efficiently reposition an element to an endpoint." msgstr "" ":class:`OrderedDict` 有個 :meth:`move_to_end` 方法可有效率地將一個元素重新排" "列到任一端。" -#: ../../library/collections.rst:1125 +#: ../../library/collections.rst:1126 msgid "" "A regular :class:`dict` can emulate OrderedDict's ``od.move_to_end(k, " "last=True)`` with ``d[k] = d.pop(k)`` which will move the key and its " @@ -1807,7 +1818,7 @@ msgstr "" "``od.move_to_end(k, last=True)``,這會將該鍵與其對應到的值移動至最右(最後" "面)的位置。" -#: ../../library/collections.rst:1129 +#: ../../library/collections.rst:1130 msgid "" "A regular :class:`dict` does not have an efficient equivalent for " "OrderedDict's ``od.move_to_end(k, last=False)`` which moves the key and its " @@ -1817,18 +1828,20 @@ msgstr "" "last=False)`` 等價的有效方式,這是將鍵與其對應到的值移動至最左(最前面)位置" "的方法。" -#: ../../library/collections.rst:1133 -msgid "Until Python 3.8, :class:`dict` lacked a :meth:`__reversed__` method." +#: ../../library/collections.rst:1134 +#, fuzzy +msgid "" +"Until Python 3.8, :class:`dict` lacked a :meth:`~object.__reversed__` method." msgstr "在 Python 3.8 之前,:class:`dict` 並沒有 :meth:`__reversed__` 方法。" -#: ../../library/collections.rst:1138 +#: ../../library/collections.rst:1139 msgid "" "Return an instance of a :class:`dict` subclass that has methods specialized " "for rearranging dictionary order." msgstr "" "回傳一個 :class:`dict` 子類別的實例,它具有專門用於重新排列字典順序的方法。" -#: ../../library/collections.rst:1145 +#: ../../library/collections.rst:1146 msgid "" "The :meth:`popitem` method for ordered dictionaries returns and removes a " "(key, value) pair. The pairs are returned in :abbr:`LIFO (last-in, first-" @@ -1840,7 +1853,7 @@ msgstr "" "回傳鍵值對,否則就按 :abbr:`FIFO (first-in, first-out)` 先進先出的順序回傳鍵" "值對。" -#: ../../library/collections.rst:1152 +#: ../../library/collections.rst:1153 msgid "" "Move an existing *key* to either end of an ordered dictionary. The item is " "moved to the right end if *last* is true (the default) or to the beginning " @@ -1850,7 +1863,7 @@ msgstr "" "設值)則將元素移至右端;如果 *last* 為假值則將元素移至左端。如果 *key* 不存在" "則會引發 :exc:`KeyError`:" -#: ../../library/collections.rst:1157 +#: ../../library/collections.rst:1158 msgid "" ">>> d = OrderedDict.fromkeys('abcde')\n" ">>> d.move_to_end('b')\n" @@ -1868,7 +1881,7 @@ msgstr "" ">>> ''.join(d)\n" "'bacde'" -#: ../../library/collections.rst:1169 +#: ../../library/collections.rst:1170 msgid "" "In addition to the usual mapping methods, ordered dictionaries also support " "reverse iteration using :func:`reversed`." @@ -1876,21 +1889,26 @@ msgstr "" "除了普通的對映方法,ordered dictionary 還支援了透過 :func:`reversed` 來做倒序" "疊代。" -#: ../../library/collections.rst:1172 +#: ../../library/collections.rst:1175 msgid "" "Equality tests between :class:`OrderedDict` objects are order-sensitive and " -"are implemented as ``list(od1.items())==list(od2.items())``. Equality tests " -"between :class:`OrderedDict` objects and other :class:`~collections.abc." -"Mapping` objects are order-insensitive like regular dictionaries. This " -"allows :class:`OrderedDict` objects to be substituted anywhere a regular " -"dictionary is used." +"are roughly equivalent to ``list(od1.items())==list(od2.items())``." +msgstr "" + +#: ../../library/collections.rst:1178 +#, fuzzy +msgid "" +"Equality tests between :class:`OrderedDict` objects and other :class:" +"`~collections.abc.Mapping` objects are order-insensitive like regular " +"dictionaries. This allows :class:`OrderedDict` objects to be substituted " +"anywhere a regular dictionary is used." msgstr "" ":class:`OrderedDict` 物件之間的相等性運算是會檢查順序是否相同的,是透過 " "``list(od1.items())==list(od2.items())`` 來實現。:class:`OrderedDict` 物件和" "其他 :class:`~collections.abc.Mapping` 物件間的相等性運算則像普通字典一樣不考" "慮順序性,這使得 :class:`OrderedDict` 可於任何字典可使用的時機中被替換掉。" -#: ../../library/collections.rst:1179 +#: ../../library/collections.rst:1183 msgid "" "The items, keys, and values :term:`views ` of :class:" "`OrderedDict` now support reverse iteration using :func:`reversed`." @@ -1898,19 +1916,21 @@ msgstr "" ":class:`OrderedDict` 的項 (item)、鍵與值之\\ :term:`視圖 `\\ 現在可透過 :func:`reversed` 來倒序疊代。" -#: ../../library/collections.rst:1183 +#: ../../library/collections.rst:1187 +#, fuzzy msgid "" "With the acceptance of :pep:`468`, order is retained for keyword arguments " -"passed to the :class:`OrderedDict` constructor and its :meth:`update` method." +"passed to the :class:`OrderedDict` constructor and its :meth:`~dict.update` " +"method." msgstr "" "隨著 :pep:`468` 被核可,被傳入給 :class:`OrderedDict` 建構函式與其 :meth:" "`update` 方法的關鍵字引數之順序被保留了下來。" -#: ../../library/collections.rst:1193 +#: ../../library/collections.rst:1197 msgid ":class:`OrderedDict` Examples and Recipes" msgstr ":class:`OrderedDict` 範例與用法" -#: ../../library/collections.rst:1195 +#: ../../library/collections.rst:1199 msgid "" "It is straightforward to create an ordered dictionary variant that remembers " "the order the keys were *last* inserted. If a new entry overwrites an " @@ -1920,7 +1940,7 @@ msgstr "" "建立一個能夠記住鍵\\ *最後*\\ 插入順序的 ordered dictionary 變體很簡單。如果" "新條目覆蓋了現有條目,則原本插入位置會被更改並移動至末端: ::" -#: ../../library/collections.rst:1200 +#: ../../library/collections.rst:1204 msgid "" "class LastUpdatedOrderedDict(OrderedDict):\n" " 'Store items in the order the keys were last added'\n" @@ -1930,7 +1950,7 @@ msgid "" " self.move_to_end(key)" msgstr "" -#: ../../library/collections.rst:1207 +#: ../../library/collections.rst:1211 msgid "" "An :class:`OrderedDict` would also be useful for implementing variants of :" "func:`functools.lru_cache`:" @@ -1938,7 +1958,7 @@ msgstr "" ":class:`OrderedDict` 在實現一個 :func:`functools.lru_cache` 的變形版本時也非" "常有用:" -#: ../../library/collections.rst:1210 +#: ../../library/collections.rst:1214 msgid "" "from collections import OrderedDict\n" "from time import time\n" @@ -1965,7 +1985,7 @@ msgid "" " return result" msgstr "" -#: ../../library/collections.rst:1237 +#: ../../library/collections.rst:1241 msgid "" "class MultiHitLRUCache:\n" " \"\"\" LRU cache that defers caching a result until\n" @@ -2003,11 +2023,11 @@ msgid "" " return result" msgstr "" -#: ../../library/collections.rst:1306 +#: ../../library/collections.rst:1310 msgid ":class:`UserDict` objects" msgstr ":class:`UserDict` 物件" -#: ../../library/collections.rst:1308 +#: ../../library/collections.rst:1312 msgid "" "The class, :class:`UserDict` acts as a wrapper around dictionary objects. " "The need for this class has been partially supplanted by the ability to " @@ -2018,7 +2038,7 @@ msgstr "" "`dict` 建立子類別,這個類別的需求已部分被滿足,不過這個類別使用起來更方便,因" "為被包裝的字典可以作為其屬性來存取。" -#: ../../library/collections.rst:1316 +#: ../../library/collections.rst:1320 msgid "" "Class that simulates a dictionary. The instance's contents are kept in a " "regular dictionary, which is accessible via the :attr:`data` attribute of :" @@ -2030,23 +2050,23 @@ msgstr "" "`data` 屬性來做存取。如果有提供 *initialdata*,:attr:`data` 屬性會被初始化為" "其值;要注意指到 *initialdata* 的參照不會被保留,使其可被用於其他目的。" -#: ../../library/collections.rst:1322 +#: ../../library/collections.rst:1326 msgid "" "In addition to supporting the methods and operations of mappings, :class:" "`UserDict` instances provide the following attribute:" msgstr "" "除了支援作為對映所需的方法與操作,:class:`UserDict` 實例提供了以下屬性:" -#: ../../library/collections.rst:1327 +#: ../../library/collections.rst:1331 msgid "" "A real dictionary used to store the contents of the :class:`UserDict` class." msgstr "一個真實的字典,用於儲存 :class:`UserDict` 類別的資料內容。" -#: ../../library/collections.rst:1333 +#: ../../library/collections.rst:1337 msgid ":class:`UserList` objects" msgstr ":class:`UserList` 物件" -#: ../../library/collections.rst:1335 +#: ../../library/collections.rst:1339 msgid "" "This class acts as a wrapper around list objects. It is a useful base class " "for your own list-like classes which can inherit from them and override " @@ -2057,7 +2077,7 @@ msgstr "" "入新方法來定義你所需的一個類似於 list 的類別。如此一來,我們可以為 list 加入" "新的特性。" -#: ../../library/collections.rst:1340 +#: ../../library/collections.rst:1344 msgid "" "The need for this class has been partially supplanted by the ability to " "subclass directly from :class:`list`; however, this class can be easier to " @@ -2066,7 +2086,7 @@ msgstr "" "因為已經可以直接自 :class:`list` 建立子類別,這個類別的需求已部分被滿足,不過" "這個類別使用起來更方便,因為被包裝的 list 可以作為其屬性來存取。" -#: ../../library/collections.rst:1346 +#: ../../library/collections.rst:1350 msgid "" "Class that simulates a list. The instance's contents are kept in a regular " "list, which is accessible via the :attr:`data` attribute of :class:" @@ -2079,20 +2099,20 @@ msgstr "" "list ``[]``。*list* 可以是任何 iterable,例如一個真實的 Python list 或是一" "個 :class:`UserList` 物件。" -#: ../../library/collections.rst:1352 +#: ../../library/collections.rst:1356 msgid "" "In addition to supporting the methods and operations of mutable sequences, :" "class:`UserList` instances provide the following attribute:" msgstr "除了支援可變序列的方法與操作,:class:`UserList` 實例提供了以下屬性:" -#: ../../library/collections.rst:1357 +#: ../../library/collections.rst:1361 msgid "" "A real :class:`list` object used to store the contents of the :class:" "`UserList` class." msgstr "" "一個真實的 :class:`list` 物件,用於儲存 :class:`UserList` 類別的資料內容。" -#: ../../library/collections.rst:1360 +#: ../../library/collections.rst:1364 msgid "" "**Subclassing requirements:** Subclasses of :class:`UserList` are expected " "to offer a constructor which can be called with either no arguments or one " @@ -2106,7 +2126,7 @@ msgstr "" "例,為了達成上述目的,它假設建構函式可傳入單一參數來呼叫,該參數即是做為數據" "來源的一個序列物件。" -#: ../../library/collections.rst:1367 +#: ../../library/collections.rst:1371 msgid "" "If a derived class does not wish to comply with this requirement, all of the " "special methods supported by this class will need to be overridden; please " @@ -2116,11 +2136,11 @@ msgstr "" "如果希望一個自此獲得的子類別不遵從上述要求,那所有該類別支援的特殊方法則必須" "被覆寫;請參考原始碼來理解在這情況下哪些方法是必須提供的。" -#: ../../library/collections.rst:1373 +#: ../../library/collections.rst:1377 msgid ":class:`UserString` objects" msgstr ":class:`UserString` 物件" -#: ../../library/collections.rst:1375 +#: ../../library/collections.rst:1379 msgid "" "The class, :class:`UserString` acts as a wrapper around string objects. The " "need for this class has been partially supplanted by the ability to subclass " @@ -2131,7 +2151,7 @@ msgstr "" "建立子類別,這個類別的需求已經部分被滿足,不過這個類別使用起來更方便,因為被" "包裝的字串可以作為其屬性來存取。" -#: ../../library/collections.rst:1383 +#: ../../library/collections.rst:1387 msgid "" "Class that simulates a string object. The instance's content is kept in a " "regular string object, which is accessible via the :attr:`data` attribute " @@ -2143,21 +2163,21 @@ msgstr "" "的 :attr:`data` 屬性來做存取。實例內容被初始化為 *seq* 的複製,*seq* 引數可以" "是任何可被內建函式 :func:`str` 轉換成字串的物件。" -#: ../../library/collections.rst:1390 +#: ../../library/collections.rst:1394 msgid "" "In addition to supporting the methods and operations of strings, :class:" "`UserString` instances provide the following attribute:" msgstr "" "除了支援字串的方法和操作以外,:class:`UserString` 實例也提供了以下屬性:" -#: ../../library/collections.rst:1395 +#: ../../library/collections.rst:1399 msgid "" "A real :class:`str` object used to store the contents of the :class:" "`UserString` class." msgstr "" "一個真實的 :class:`str` 物件,用來儲存 :class:`UserString` 類別的資料內容。" -#: ../../library/collections.rst:1398 +#: ../../library/collections.rst:1402 msgid "" "New methods ``__getnewargs__``, ``__rmod__``, ``casefold``, ``format_map``, " "``isprintable``, and ``maketrans``." diff --git a/library/compileall.po b/library/compileall.po index 2f8e76a53f..abe80dc80d 100644 --- a/library/compileall.po +++ b/library/compileall.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2024-10-13 17:13+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-" @@ -36,7 +36,7 @@ msgid "" msgstr "" #: ../../includes/wasm-notavail.rst:3 -msgid ":ref:`Availability `: not WASI." +msgid "Availability" msgstr "" #: ../../includes/wasm-notavail.rst:5 diff --git a/library/concurrent.futures.po b/library/concurrent.futures.po index 061f4dc950..2b888318aa 100644 --- a/library/concurrent.futures.po +++ b/library/concurrent.futures.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2024-10-28 06:59+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-" @@ -51,9 +51,8 @@ msgstr "" "相同的介面,該介面由抽象的 :class:`Executor` 類別定義。" #: ../../includes/wasm-notavail.rst:3 -#, fuzzy -msgid ":ref:`Availability `: not WASI." -msgstr ":ref:`適用 `:非 Emscripten、非 WASI。" +msgid "Availability" +msgstr "" #: ../../includes/wasm-notavail.rst:5 #, fuzzy @@ -381,7 +380,7 @@ msgid "" " 'http://www.cnn.com/',\n" " 'http://europe.wsj.com/',\n" " 'http://www.bbc.co.uk/',\n" -" 'http://nonexistant-subdomain.python.org/']\n" +" 'http://nonexistent-subdomain.python.org/']\n" "\n" "# Retrieve a single page and report the URL and contents\n" "def load_url(url, timeout):\n" @@ -951,3 +950,7 @@ msgstr "" "`RuntimeError`),當 :class:`~concurrent.futures.ProcessPoolExecutor` 的其中" "一個 worker 以不乾淨的方式終止時將引發此例外類別(例如它是從外面被 kill 掉" "的)。" + +#, fuzzy +#~ msgid ":ref:`Availability `: not WASI." +#~ msgstr ":ref:`適用 `:非 Emscripten、非 WASI。" diff --git a/library/configparser.po b/library/configparser.po index 0943f36e02..9f43fe1449 100644 --- a/library/configparser.po +++ b/library/configparser.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-03-03 18:39+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-" @@ -69,15 +69,15 @@ msgid "" "sometimes used for configuration, but does not support comments." msgstr "" -#: ../../library/configparser.rst:60 +#: ../../library/configparser.rst:61 msgid "Quick Start" msgstr "" -#: ../../library/configparser.rst:62 +#: ../../library/configparser.rst:63 msgid "Let's take a very basic configuration file that looks like this:" msgstr "" -#: ../../library/configparser.rst:64 +#: ../../library/configparser.rst:65 msgid "" "[DEFAULT]\n" "ServerAliveInterval = 45\n" @@ -105,7 +105,7 @@ msgstr "" "Port = 50022\n" "ForwardX11 = no" -#: ../../library/configparser.rst:79 +#: ../../library/configparser.rst:80 msgid "" "The structure of INI files is described `in the following section " "<#supported-ini-file-structure>`_. Essentially, the file consists of " @@ -114,7 +114,7 @@ msgid "" "configuration file programmatically." msgstr "" -#: ../../library/configparser.rst:85 +#: ../../library/configparser.rst:86 msgid "" ">>> import configparser\n" ">>> config = configparser.ConfigParser()\n" @@ -133,20 +133,20 @@ msgid "" "..." msgstr "" -#: ../../library/configparser.rst:103 +#: ../../library/configparser.rst:104 msgid "" "As you can see, we can treat a config parser much like a dictionary. There " "are differences, `outlined later <#mapping-protocol-access>`_, but the " "behavior is very close to what you would expect from a dictionary." msgstr "" -#: ../../library/configparser.rst:107 +#: ../../library/configparser.rst:108 msgid "" "Now that we have created and saved a configuration file, let's read it back " "and explore the data it holds." msgstr "" -#: ../../library/configparser.rst:110 +#: ../../library/configparser.rst:111 msgid "" ">>> config = configparser.ConfigParser()\n" ">>> config.sections()\n" @@ -168,7 +168,7 @@ msgid "" "'no'\n" ">>> topsecret['Port']\n" "'50022'\n" -">>> for key in config['forge.example']: \n" +">>> for key in config['forge.example']:\n" "... print(key)\n" "user\n" "compressionlevel\n" @@ -179,7 +179,7 @@ msgid "" "'yes'" msgstr "" -#: ../../library/configparser.rst:142 +#: ../../library/configparser.rst:143 msgid "" "As we can see above, the API is pretty straightforward. The only bit of " "magic involves the ``DEFAULT`` section which provides default values for all " @@ -187,7 +187,7 @@ msgid "" "and stored in lowercase [1]_." msgstr "" -#: ../../library/configparser.rst:147 ../../library/configparser.rst:992 +#: ../../library/configparser.rst:148 ../../library/configparser.rst:1003 msgid "" "It is possible to read several configurations into a single :class:" "`ConfigParser`, where the most recently added configuration has the highest " @@ -197,7 +197,7 @@ msgid "" "``example.ini`` file." msgstr "" -#: ../../library/configparser.rst:154 ../../library/configparser.rst:999 +#: ../../library/configparser.rst:155 ../../library/configparser.rst:1010 msgid "" "[DEFAULT]\n" "ServerAliveInterval = -1" @@ -205,7 +205,7 @@ msgstr "" "[DEFAULT]\n" "ServerAliveInterval = -1" -#: ../../library/configparser.rst:159 ../../library/configparser.rst:1004 +#: ../../library/configparser.rst:160 ../../library/configparser.rst:1015 msgid "" ">>> config_override = configparser.ConfigParser()\n" ">>> config_override['DEFAULT'] = {'ServerAliveInterval': '-1'}\n" @@ -229,24 +229,24 @@ msgstr "" ">>> print(config_override.get('DEFAULT', 'ServerAliveInterval'))\n" "-1" -#: ../../library/configparser.rst:173 +#: ../../library/configparser.rst:174 msgid "" "This behaviour is equivalent to a :meth:`ConfigParser.read` call with " "several files passed to the *filenames* parameter." msgstr "" -#: ../../library/configparser.rst:178 +#: ../../library/configparser.rst:179 msgid "Supported Datatypes" msgstr "" -#: ../../library/configparser.rst:180 +#: ../../library/configparser.rst:181 msgid "" "Config parsers do not guess datatypes of values in configuration files, " "always storing them internally as strings. This means that if you need " "other datatypes, you should convert on your own:" msgstr "" -#: ../../library/configparser.rst:184 +#: ../../library/configparser.rst:185 msgid "" ">>> int(topsecret['Port'])\n" "50022\n" @@ -258,7 +258,7 @@ msgstr "" ">>> float(topsecret['CompressionLevel'])\n" "9.0" -#: ../../library/configparser.rst:191 +#: ../../library/configparser.rst:192 msgid "" "Since this task is so common, config parsers provide a range of handy getter " "methods to handle integers, floats and booleans. The last one is the most " @@ -269,7 +269,7 @@ msgid "" "``'true'``/``'false'`` and ``'1'``/``'0'`` [1]_. For example:" msgstr "" -#: ../../library/configparser.rst:199 +#: ../../library/configparser.rst:200 msgid "" ">>> topsecret.getboolean('ForwardX11')\n" "False\n" @@ -285,7 +285,7 @@ msgstr "" ">>> config.getboolean('forge.example', 'Compression')\n" "True" -#: ../../library/configparser.rst:208 +#: ../../library/configparser.rst:209 msgid "" "Apart from :meth:`~ConfigParser.getboolean`, config parsers also provide " "equivalent :meth:`~ConfigParser.getint` and :meth:`~ConfigParser.getfloat` " @@ -293,17 +293,17 @@ msgid "" "ones. [1]_" msgstr "" -#: ../../library/configparser.rst:214 +#: ../../library/configparser.rst:215 msgid "Fallback Values" msgstr "" -#: ../../library/configparser.rst:216 +#: ../../library/configparser.rst:217 msgid "" "As with a dictionary, you can use a section's :meth:`~ConfigParser.get` " "method to provide fallback values:" msgstr "" -#: ../../library/configparser.rst:219 +#: ../../library/configparser.rst:220 msgid "" ">>> topsecret.get('Port')\n" "'50022'\n" @@ -321,7 +321,7 @@ msgstr "" ">>> topsecret.get('Cipher', '3des-cbc')\n" "'3des-cbc'" -#: ../../library/configparser.rst:229 +#: ../../library/configparser.rst:230 msgid "" "Please note that default values have precedence over fallback values. For " "instance, in our example the ``'CompressionLevel'`` key was specified only " @@ -330,7 +330,7 @@ msgid "" "specify a fallback:" msgstr "" -#: ../../library/configparser.rst:235 +#: ../../library/configparser.rst:236 msgid "" ">>> topsecret.get('CompressionLevel', '3')\n" "'9'" @@ -338,7 +338,7 @@ msgstr "" ">>> topsecret.get('CompressionLevel', '3')\n" "'9'" -#: ../../library/configparser.rst:240 +#: ../../library/configparser.rst:241 msgid "" "One more thing to be aware of is that the parser-level :meth:`~ConfigParser." "get` method provides a custom, more complex interface, maintained for " @@ -346,21 +346,21 @@ msgid "" "provided via the ``fallback`` keyword-only argument:" msgstr "" -#: ../../library/configparser.rst:245 +#: ../../library/configparser.rst:246 msgid "" ">>> config.get('forge.example', 'monster',\n" "... fallback='No such things as monsters')\n" "'No such things as monsters'" msgstr "" -#: ../../library/configparser.rst:251 +#: ../../library/configparser.rst:252 msgid "" "The same ``fallback`` argument can be used with the :meth:`~ConfigParser." "getint`, :meth:`~ConfigParser.getfloat` and :meth:`~ConfigParser.getboolean` " "methods, for example:" msgstr "" -#: ../../library/configparser.rst:255 +#: ../../library/configparser.rst:256 msgid "" ">>> 'BatchMode' in topsecret\n" "False\n" @@ -378,11 +378,11 @@ msgstr "" ">>> topsecret.getboolean('BatchMode', fallback=True)\n" "False" -#: ../../library/configparser.rst:267 +#: ../../library/configparser.rst:268 msgid "Supported INI File Structure" msgstr "" -#: ../../library/configparser.rst:269 +#: ../../library/configparser.rst:270 msgid "" "A configuration file consists of sections, each led by a ``[section]`` " "header, followed by key/value entries separated by a specific string (``=`` " @@ -395,13 +395,13 @@ msgid "" "parts of multiline values or ignored." msgstr "" -#: ../../library/configparser.rst:279 +#: ../../library/configparser.rst:280 msgid "" "By default, a valid section name can be any string that does not contain '\\" "\\n'. To change this, see :attr:`ConfigParser.SECTCRE`." msgstr "" -#: ../../library/configparser.rst:282 +#: ../../library/configparser.rst:283 msgid "" "The first section name may be omitted if the parser is configured to allow " "an unnamed top level section with ``allow_unnamed_section=True``. In this " @@ -409,18 +409,18 @@ msgid "" "``config[UNNAMED_SECTION]``." msgstr "" -#: ../../library/configparser.rst:287 +#: ../../library/configparser.rst:288 msgid "" "Configuration files may include comments, prefixed by specific characters " "(``#`` and ``;`` by default [1]_). Comments may appear on their own on an " "otherwise empty line, possibly indented. [1]_" msgstr "" -#: ../../library/configparser.rst:291 ../../library/configparser.rst:375 +#: ../../library/configparser.rst:292 ../../library/configparser.rst:376 msgid "For example:" msgstr "舉例來說:" -#: ../../library/configparser.rst:293 +#: ../../library/configparser.rst:294 msgid "" "[Simple Values]\n" "key=value\n" @@ -465,17 +465,17 @@ msgid "" " # Did I mention we can indent comments, too?" msgstr "" -#: ../../library/configparser.rst:341 +#: ../../library/configparser.rst:342 msgid "Unnamed Sections" msgstr "" -#: ../../library/configparser.rst:343 +#: ../../library/configparser.rst:344 msgid "" "The name of the first section (or unique) may be omitted and values " "retrieved by the :const:`UNNAMED_SECTION` attribute." msgstr "" -#: ../../library/configparser.rst:346 +#: ../../library/configparser.rst:347 msgid "" ">>> config = \"\"\"\n" "... option = value\n" @@ -489,18 +489,18 @@ msgid "" "'value'" msgstr "" -#: ../../library/configparser.rst:360 +#: ../../library/configparser.rst:361 msgid "Interpolation of values" msgstr "" -#: ../../library/configparser.rst:362 +#: ../../library/configparser.rst:363 msgid "" "On top of the core functionality, :class:`ConfigParser` supports " "interpolation. This means values can be preprocessed before returning them " "from ``get()`` calls." msgstr "" -#: ../../library/configparser.rst:370 +#: ../../library/configparser.rst:371 msgid "" "The default implementation used by :class:`ConfigParser`. It enables values " "to contain format strings which refer to other values in the same section, " @@ -508,7 +508,7 @@ msgid "" "can be provided on initialization." msgstr "" -#: ../../library/configparser.rst:377 +#: ../../library/configparser.rst:378 msgid "" "[Paths]\n" "home_dir: /Users\n" @@ -521,7 +521,7 @@ msgid "" "gain: 80%%" msgstr "" -#: ../../library/configparser.rst:388 +#: ../../library/configparser.rst:389 msgid "" "In the example above, :class:`ConfigParser` with *interpolation* set to " "``BasicInterpolation()`` would resolve ``%(home_dir)s`` to the value of " @@ -531,14 +531,14 @@ msgid "" "specific order in the configuration file." msgstr "" -#: ../../library/configparser.rst:395 +#: ../../library/configparser.rst:396 msgid "" "With ``interpolation`` set to ``None``, the parser would simply return " "``%(my_dir)s/Pictures`` as the value of ``my_pictures`` and ``%(home_dir)s/" "lumberjack`` as the value of ``my_dir``." msgstr "" -#: ../../library/configparser.rst:403 +#: ../../library/configparser.rst:404 msgid "" "An alternative handler for interpolation which implements a more advanced " "syntax, used for instance in ``zc.buildout``. Extended interpolation is " @@ -548,13 +548,13 @@ msgid "" "possibly the default values from the special section)." msgstr "" -#: ../../library/configparser.rst:410 +#: ../../library/configparser.rst:411 msgid "" "For example, the configuration specified above with basic interpolation, " "would look like this with extended interpolation:" msgstr "" -#: ../../library/configparser.rst:413 +#: ../../library/configparser.rst:414 msgid "" "[Paths]\n" "home_dir: /Users\n" @@ -567,11 +567,11 @@ msgid "" "cost: $$80" msgstr "" -#: ../../library/configparser.rst:424 +#: ../../library/configparser.rst:425 msgid "Values from other sections can be fetched as well:" msgstr "" -#: ../../library/configparser.rst:426 +#: ../../library/configparser.rst:427 msgid "" "[Common]\n" "home_dir: /Users\n" @@ -607,11 +607,11 @@ msgstr "" "my_pictures: ${my_dir}/Pictures\n" "python_dir: ${Frameworks:path}/Python/Versions/${Frameworks:Python}" -#: ../../library/configparser.rst:446 +#: ../../library/configparser.rst:447 msgid "Mapping Protocol Access" msgstr "" -#: ../../library/configparser.rst:450 +#: ../../library/configparser.rst:451 msgid "" "Mapping protocol access is a generic name for functionality that enables " "using custom objects as if they were dictionaries. In case of :mod:" @@ -619,7 +619,7 @@ msgid "" "``parser['section']['option']`` notation." msgstr "" -#: ../../library/configparser.rst:455 +#: ../../library/configparser.rst:456 msgid "" "``parser['section']`` in particular returns a proxy for the section's data " "in the parser. This means that the values are not copied but they are taken " @@ -628,7 +628,7 @@ msgid "" "original parser." msgstr "" -#: ../../library/configparser.rst:461 +#: ../../library/configparser.rst:462 msgid "" ":mod:`configparser` objects behave as close to actual dictionaries as " "possible. The mapping interface is complete and adheres to the :class:" @@ -636,7 +636,7 @@ msgid "" "that should be taken into account:" msgstr "" -#: ../../library/configparser.rst:466 +#: ../../library/configparser.rst:467 msgid "" "By default, all keys in sections are accessible in a case-insensitive manner " "[1]_. E.g. ``for option in parser[\"section\"]`` yields only " @@ -645,7 +645,7 @@ msgid "" "expressions return ``True``::" msgstr "" -#: ../../library/configparser.rst:471 +#: ../../library/configparser.rst:472 msgid "" "\"a\" in parser[\"section\"]\n" "\"A\" in parser[\"section\"]" @@ -653,7 +653,7 @@ msgstr "" "\"a\" in parser[\"section\"]\n" "\"A\" in parser[\"section\"]" -#: ../../library/configparser.rst:474 +#: ../../library/configparser.rst:475 msgid "" "All sections include ``DEFAULTSECT`` values as well which means that ``." "clear()`` on a section may not leave the section visibly empty. This is " @@ -663,30 +663,30 @@ msgid "" "default value causes a :exc:`KeyError`." msgstr "" -#: ../../library/configparser.rst:481 +#: ../../library/configparser.rst:482 msgid "``DEFAULTSECT`` cannot be removed from the parser:" msgstr "" -#: ../../library/configparser.rst:483 +#: ../../library/configparser.rst:484 msgid "trying to delete it raises :exc:`ValueError`," msgstr "" -#: ../../library/configparser.rst:485 +#: ../../library/configparser.rst:486 msgid "``parser.clear()`` leaves it intact," msgstr "" -#: ../../library/configparser.rst:487 +#: ../../library/configparser.rst:488 msgid "``parser.popitem()`` never returns it." msgstr "" -#: ../../library/configparser.rst:489 +#: ../../library/configparser.rst:490 msgid "" "``parser.get(section, option, **kwargs)`` - the second argument is **not** a " "fallback value. Note however that the section-level ``get()`` methods are " "compatible both with the mapping protocol and the classic configparser API." msgstr "" -#: ../../library/configparser.rst:493 +#: ../../library/configparser.rst:494 msgid "" "``parser.items()`` is compatible with the mapping protocol (returns a list " "of *section_name*, *section_proxy* pairs including the DEFAULTSECT). " @@ -696,18 +696,18 @@ msgid "" "(unless ``raw=True`` is provided)." msgstr "" -#: ../../library/configparser.rst:500 +#: ../../library/configparser.rst:501 msgid "" "The mapping protocol is implemented on top of the existing legacy API so " "that subclasses overriding the original interface still should have mappings " "working as expected." msgstr "" -#: ../../library/configparser.rst:506 +#: ../../library/configparser.rst:507 msgid "Customizing Parser Behaviour" msgstr "" -#: ../../library/configparser.rst:508 +#: ../../library/configparser.rst:509 msgid "" "There are nearly as many INI format variants as there are applications using " "it. :mod:`configparser` goes a long way to provide support for the largest " @@ -716,17 +716,17 @@ msgid "" "customize some of the features." msgstr "" -#: ../../library/configparser.rst:514 +#: ../../library/configparser.rst:515 msgid "" "The most common way to change the way a specific config parser works is to " "use the :meth:`!__init__` options:" msgstr "" -#: ../../library/configparser.rst:517 +#: ../../library/configparser.rst:518 msgid "*defaults*, default value: ``None``" msgstr "" -#: ../../library/configparser.rst:519 +#: ../../library/configparser.rst:520 msgid "" "This option accepts a dictionary of key-value pairs which will be initially " "put in the ``DEFAULT`` section. This makes for an elegant way to support " @@ -734,17 +734,17 @@ msgid "" "the documented default." msgstr "" -#: ../../library/configparser.rst:524 +#: ../../library/configparser.rst:525 msgid "" "Hint: if you want to specify default values for a specific section, use :" "meth:`~ConfigParser.read_dict` before you read the actual file." msgstr "" -#: ../../library/configparser.rst:527 +#: ../../library/configparser.rst:528 msgid "*dict_type*, default value: :class:`dict`" msgstr "" -#: ../../library/configparser.rst:529 +#: ../../library/configparser.rst:530 msgid "" "This option has a major impact on how the mapping protocol will behave and " "how the written configuration files look. With the standard dictionary, " @@ -752,20 +752,20 @@ msgid "" "goes for options within sections." msgstr "" -#: ../../library/configparser.rst:534 +#: ../../library/configparser.rst:535 msgid "" "An alternative dictionary type can be used for example to sort sections and " "options on write-back." msgstr "" -#: ../../library/configparser.rst:537 +#: ../../library/configparser.rst:538 msgid "" "Please note: there are ways to add a set of key-value pairs in a single " "operation. When you use a regular dictionary in those operations, the order " "of the keys will be ordered. For example:" msgstr "" -#: ../../library/configparser.rst:541 +#: ../../library/configparser.rst:542 msgid "" ">>> parser = configparser.ConfigParser()\n" ">>> parser.read_dict({'section1': {'key1': 'value1',\n" @@ -799,11 +799,11 @@ msgstr "" ">>> [option for option in parser['section3']]\n" "['foo', 'bar', 'baz']" -#: ../../library/configparser.rst:559 +#: ../../library/configparser.rst:560 msgid "*allow_no_value*, default value: ``False``" msgstr "" -#: ../../library/configparser.rst:561 +#: ../../library/configparser.rst:562 msgid "" "Some configuration files are known to include settings without values, but " "which otherwise conform to the syntax supported by :mod:`configparser`. The " @@ -811,7 +811,7 @@ msgid "" "such values should be accepted:" msgstr "" -#: ../../library/configparser.rst:566 +#: ../../library/configparser.rst:567 msgid "" ">>> import configparser\n" "\n" @@ -842,32 +842,32 @@ msgid "" "KeyError: 'does-not-exist'" msgstr "" -#: ../../library/configparser.rst:596 +#: ../../library/configparser.rst:597 msgid "*delimiters*, default value: ``('=', ':')``" msgstr "" -#: ../../library/configparser.rst:598 +#: ../../library/configparser.rst:599 msgid "" "Delimiters are substrings that delimit keys from values within a section. " "The first occurrence of a delimiting substring on a line is considered a " "delimiter. This means values (but not keys) can contain the delimiters." msgstr "" -#: ../../library/configparser.rst:602 +#: ../../library/configparser.rst:603 msgid "" "See also the *space_around_delimiters* argument to :meth:`ConfigParser." "write`." msgstr "" -#: ../../library/configparser.rst:605 +#: ../../library/configparser.rst:606 msgid "*comment_prefixes*, default value: ``('#', ';')``" msgstr "" -#: ../../library/configparser.rst:607 +#: ../../library/configparser.rst:608 msgid "*inline_comment_prefixes*, default value: ``None``" msgstr "" -#: ../../library/configparser.rst:609 +#: ../../library/configparser.rst:610 msgid "" "Comment prefixes are strings that indicate the start of a valid comment " "within a config file. *comment_prefixes* are used only on otherwise empty " @@ -877,13 +877,13 @@ msgid "" "used as prefixes for whole line comments." msgstr "" -#: ../../library/configparser.rst:616 +#: ../../library/configparser.rst:617 msgid "" "In previous versions of :mod:`configparser` behaviour matched " "``comment_prefixes=('#',';')`` and ``inline_comment_prefixes=(';',)``." msgstr "" -#: ../../library/configparser.rst:620 +#: ../../library/configparser.rst:621 msgid "" "Please note that config parsers don't support escaping of comment prefixes " "so using *inline_comment_prefixes* may prevent users from specifying option " @@ -893,7 +893,7 @@ msgid "" "values is to interpolate the prefix, for example::" msgstr "" -#: ../../library/configparser.rst:627 +#: ../../library/configparser.rst:628 msgid "" ">>> from configparser import ConfigParser, ExtendedInterpolation\n" ">>> parser = ConfigParser(interpolation=ExtendedInterpolation())\n" @@ -935,11 +935,11 @@ msgid "" "line #3" msgstr "" -#: ../../library/configparser.rst:666 +#: ../../library/configparser.rst:667 msgid "*strict*, default value: ``True``" msgstr "" -#: ../../library/configparser.rst:668 +#: ../../library/configparser.rst:669 msgid "" "When set to ``True``, the parser will not allow for any section or option " "duplicates while reading from a single source (using :meth:`~ConfigParser." @@ -947,17 +947,17 @@ msgid "" "read_dict`). It is recommended to use strict parsers in new applications." msgstr "" -#: ../../library/configparser.rst:673 +#: ../../library/configparser.rst:674 msgid "" "In previous versions of :mod:`configparser` behaviour matched " "``strict=False``." msgstr "" -#: ../../library/configparser.rst:677 +#: ../../library/configparser.rst:678 msgid "*empty_lines_in_values*, default value: ``True``" msgstr "" -#: ../../library/configparser.rst:679 +#: ../../library/configparser.rst:680 msgid "" "In config parsers, values can span multiple lines as long as they are " "indented more than the key that holds them. By default parsers also let " @@ -967,7 +967,7 @@ msgid "" "lose track of the file structure. Take for instance:" msgstr "" -#: ../../library/configparser.rst:686 +#: ../../library/configparser.rst:687 msgid "" "[Section]\n" "key = multiline\n" @@ -976,7 +976,7 @@ msgid "" " this = is still a part of the multiline value of 'key'" msgstr "" -#: ../../library/configparser.rst:694 +#: ../../library/configparser.rst:695 msgid "" "This can be especially problematic for the user to see if she's using a " "proportional font to edit the file. That is why when your application does " @@ -985,13 +985,13 @@ msgid "" "would produce two keys, ``key`` and ``this``." msgstr "" -#: ../../library/configparser.rst:700 +#: ../../library/configparser.rst:701 msgid "" "*default_section*, default value: ``configparser.DEFAULTSECT`` (that is: " "``\"DEFAULT\"``)" msgstr "" -#: ../../library/configparser.rst:703 +#: ../../library/configparser.rst:704 msgid "" "The convention of allowing a special section of default values for other " "sections or interpolation purposes is a powerful concept of this library, " @@ -1005,11 +1005,11 @@ msgid "" "files from one format to another)." msgstr "" -#: ../../library/configparser.rst:714 +#: ../../library/configparser.rst:715 msgid "*interpolation*, default value: ``configparser.BasicInterpolation``" msgstr "" -#: ../../library/configparser.rst:716 +#: ../../library/configparser.rst:717 msgid "" "Interpolation behaviour may be customized by providing a custom handler " "through the *interpolation* argument. ``None`` can be used to turn off " @@ -1019,11 +1019,11 @@ msgid "" "`RawConfigParser` has a default value of ``None``." msgstr "" -#: ../../library/configparser.rst:723 +#: ../../library/configparser.rst:724 msgid "*converters*, default value: not set" msgstr "" -#: ../../library/configparser.rst:725 +#: ../../library/configparser.rst:726 msgid "" "Config parsers provide option value getters that perform type conversion. " "By default :meth:`~ConfigParser.getint`, :meth:`~ConfigParser.getfloat`, " @@ -1037,7 +1037,7 @@ msgid "" "``parser_instance['section'].getdecimal('key', 0)``." msgstr "" -#: ../../library/configparser.rst:736 +#: ../../library/configparser.rst:737 msgid "" "If the converter needs to access the state of the parser, it can be " "implemented as a method on a config parser subclass. If the name of this " @@ -1045,14 +1045,14 @@ msgid "" "the dict-compatible form (see the ``getdecimal()`` example above)." msgstr "" -#: ../../library/configparser.rst:741 +#: ../../library/configparser.rst:742 msgid "" "More advanced customization may be achieved by overriding default values of " "these parser attributes. The defaults are defined on the classes, so they " "may be overridden by subclasses or by attribute assignment." msgstr "" -#: ../../library/configparser.rst:747 +#: ../../library/configparser.rst:748 msgid "" "By default when using :meth:`~ConfigParser.getboolean`, config parsers " "consider the following values ``True``: ``'1'``, ``'yes'``, ``'true'``, " @@ -1061,7 +1061,7 @@ msgid "" "strings and their Boolean outcomes. For example:" msgstr "" -#: ../../library/configparser.rst:753 +#: ../../library/configparser.rst:754 msgid "" ">>> custom = configparser.ConfigParser()\n" ">>> custom['section1'] = {'funky': 'nope'}\n" @@ -1083,13 +1083,13 @@ msgstr "" ">>> custom['section1'].getboolean('funky')\n" "False" -#: ../../library/configparser.rst:765 +#: ../../library/configparser.rst:766 msgid "" "Other typical Boolean pairs include ``accept``/``reject`` or ``enabled``/" "``disabled``." msgstr "" -#: ../../library/configparser.rst:771 +#: ../../library/configparser.rst:772 msgid "" "This method transforms option names on every read, get, or set operation. " "The default converts the name to lowercase. This also means that when a " @@ -1097,7 +1097,7 @@ msgid "" "method if that's unsuitable. For example:" msgstr "" -#: ../../library/configparser.rst:777 +#: ../../library/configparser.rst:778 msgid "" ">>> config = \"\"\"\n" "... [Section1]\n" @@ -1141,14 +1141,14 @@ msgstr "" ">>> list(custom['Section2'].keys())\n" "['AnotherKey']" -#: ../../library/configparser.rst:801 +#: ../../library/configparser.rst:802 msgid "" "The optionxform function transforms option names to a canonical form. This " "should be an idempotent function: if the name is already in canonical form, " "it should be returned unchanged." msgstr "" -#: ../../library/configparser.rst:808 +#: ../../library/configparser.rst:809 msgid "" "A compiled regular expression used to parse section headers. The default " "matches ``[section]`` to the name ``\"section\"``. Whitespace is considered " @@ -1157,7 +1157,7 @@ msgid "" "example:" msgstr "" -#: ../../library/configparser.rst:814 +#: ../../library/configparser.rst:815 msgid "" ">>> import re\n" ">>> config = \"\"\"\n" @@ -1195,18 +1195,18 @@ msgstr "" ">>> custom.sections()\n" "['Section 1', 'Section 2']" -#: ../../library/configparser.rst:836 +#: ../../library/configparser.rst:837 msgid "" "While ConfigParser objects also use an ``OPTCRE`` attribute for recognizing " "option lines, it's not recommended to override it because that would " "interfere with constructor options *allow_no_value* and *delimiters*." msgstr "" -#: ../../library/configparser.rst:842 +#: ../../library/configparser.rst:843 msgid "Legacy API Examples" msgstr "" -#: ../../library/configparser.rst:844 +#: ../../library/configparser.rst:845 msgid "" "Mainly because of backwards compatibility concerns, :mod:`configparser` " "provides also a legacy API with explicit ``get``/``set`` methods. While " @@ -1215,11 +1215,11 @@ msgid "" "advanced, low-level and downright counterintuitive." msgstr "" -#: ../../library/configparser.rst:850 +#: ../../library/configparser.rst:851 msgid "An example of writing to a configuration file::" msgstr "" -#: ../../library/configparser.rst:852 +#: ../../library/configparser.rst:853 msgid "" "import configparser\n" "\n" @@ -1243,11 +1243,11 @@ msgid "" " config.write(configfile)" msgstr "" -#: ../../library/configparser.rst:873 +#: ../../library/configparser.rst:874 msgid "An example of reading the configuration file again::" msgstr "" -#: ../../library/configparser.rst:875 +#: ../../library/configparser.rst:876 msgid "" "import configparser\n" "\n" @@ -1266,11 +1266,11 @@ msgid "" " print(config.get('Section1', 'foo'))" msgstr "" -#: ../../library/configparser.rst:891 +#: ../../library/configparser.rst:892 msgid "To get interpolation, use :class:`ConfigParser`::" msgstr "" -#: ../../library/configparser.rst:893 +#: ../../library/configparser.rst:894 msgid "" "import configparser\n" "\n" @@ -1305,13 +1305,13 @@ msgid "" " # -> None" msgstr "" -#: ../../library/configparser.rst:924 +#: ../../library/configparser.rst:925 msgid "" "Default values are available in both types of ConfigParsers. They are used " "in interpolation if an option used is not defined elsewhere. ::" msgstr "" -#: ../../library/configparser.rst:927 +#: ../../library/configparser.rst:928 msgid "" "import configparser\n" "\n" @@ -1325,11 +1325,11 @@ msgid "" "print(config.get('Section1', 'foo')) # -> \"Life is hard!\"" msgstr "" -#: ../../library/configparser.rst:942 +#: ../../library/configparser.rst:943 msgid "ConfigParser Objects" msgstr "ConfigParser 物件" -#: ../../library/configparser.rst:946 +#: ../../library/configparser.rst:953 msgid "" "The main configuration parser. When *defaults* is given, it is initialized " "into the dictionary of intrinsic defaults. When *dict_type* is given, it " @@ -1337,7 +1337,7 @@ msgid "" "the options within a section, and for the default values." msgstr "" -#: ../../library/configparser.rst:951 +#: ../../library/configparser.rst:958 msgid "" "When *delimiters* is given, it is used as the set of substrings that divide " "keys from values. When *comment_prefixes* is given, it will be used as the " @@ -1346,7 +1346,7 @@ msgid "" "as the set of substrings that prefix comments in non-empty lines." msgstr "" -#: ../../library/configparser.rst:957 +#: ../../library/configparser.rst:964 msgid "" "When *strict* is ``True`` (the default), the parser won't allow for any " "section or option duplicates while reading from a single source (file, " @@ -1359,7 +1359,7 @@ msgid "" "without the trailing delimiter." msgstr "" -#: ../../library/configparser.rst:967 +#: ../../library/configparser.rst:974 msgid "" "When *default_section* is given, it specifies the name for the special " "section holding default values for other sections and interpolation purposes " @@ -1369,7 +1369,7 @@ msgid "" "settings to a new config file." msgstr "" -#: ../../library/configparser.rst:974 +#: ../../library/configparser.rst:981 msgid "" "Interpolation behaviour may be customized by providing a custom handler " "through the *interpolation* argument. ``None`` can be used to turn off " @@ -1378,7 +1378,7 @@ msgid "" "`dedicated documentation section <#interpolation-of-values>`_." msgstr "" -#: ../../library/configparser.rst:980 +#: ../../library/configparser.rst:987 msgid "" "All option names used in interpolation will be passed through the :meth:" "`optionxform` method just like any other option name reference. For " @@ -1387,7 +1387,7 @@ msgid "" "%(BAR)s`` are equivalent." msgstr "" -#: ../../library/configparser.rst:986 +#: ../../library/configparser.rst:993 msgid "" "When *converters* is given, it should be a dictionary where each key " "represents the name of a type converter and each value is a callable " @@ -1396,50 +1396,62 @@ msgid "" "object and section proxies." msgstr "" -#: ../../library/configparser.rst:1017 +#: ../../library/configparser.rst:999 +msgid "" +"When *allow_unnamed_section* is ``True`` (default: ``False``), the first " +"section name can be omitted. See the `\"Unnamed Sections\" section <#unnamed-" +"sections>`_." +msgstr "" + +#: ../../library/configparser.rst:1028 msgid "The default *dict_type* is :class:`collections.OrderedDict`." msgstr "" -#: ../../library/configparser.rst:1020 +#: ../../library/configparser.rst:1031 ../../library/configparser.rst:1320 msgid "" "*allow_no_value*, *delimiters*, *comment_prefixes*, *strict*, " "*empty_lines_in_values*, *default_section* and *interpolation* were added." msgstr "" -#: ../../library/configparser.rst:1025 +#: ../../library/configparser.rst:1036 ../../library/configparser.rst:1325 msgid "The *converters* argument was added." msgstr "新增 *converters* 引數。" -#: ../../library/configparser.rst:1028 +#: ../../library/configparser.rst:1039 msgid "" "The *defaults* argument is read with :meth:`read_dict`, providing consistent " "behavior across the parser: non-string keys and values are implicitly " "converted to strings." msgstr "" -#: ../../library/configparser.rst:1033 ../../library/configparser.rst:1305 +#: ../../library/configparser.rst:1044 ../../library/configparser.rst:1328 msgid "" "The default *dict_type* is :class:`dict`, since it now preserves insertion " "order." msgstr "" -#: ../../library/configparser.rst:1037 +#: ../../library/configparser.rst:1048 msgid "" "Raise a :exc:`MultilineContinuationError` when *allow_no_value* is ``True``, " "and a key without a value is continued with an indented line." msgstr "" -#: ../../library/configparser.rst:1043 +#: ../../library/configparser.rst:1052 ../../library/configparser.rst:1332 +#, fuzzy +msgid "The *allow_unnamed_section* argument was added." +msgstr "新增 *converters* 引數。" + +#: ../../library/configparser.rst:1057 msgid "Return a dictionary containing the instance-wide defaults." msgstr "" -#: ../../library/configparser.rst:1048 +#: ../../library/configparser.rst:1062 msgid "" "Return a list of the sections available; the *default section* is not " "included in the list." msgstr "" -#: ../../library/configparser.rst:1054 +#: ../../library/configparser.rst:1068 msgid "" "Add a section named *section* to the instance. If a section by the given " "name already exists, :exc:`DuplicateSectionError` is raised. If the " @@ -1447,34 +1459,34 @@ msgid "" "the section must be a string; if not, :exc:`TypeError` is raised." msgstr "" -#: ../../library/configparser.rst:1059 +#: ../../library/configparser.rst:1073 msgid "Non-string section names raise :exc:`TypeError`." msgstr "" -#: ../../library/configparser.rst:1065 +#: ../../library/configparser.rst:1079 msgid "" "Indicates whether the named *section* is present in the configuration. The " "*default section* is not acknowledged." msgstr "" -#: ../../library/configparser.rst:1071 +#: ../../library/configparser.rst:1085 msgid "Return a list of options available in the specified *section*." msgstr "" -#: ../../library/configparser.rst:1076 +#: ../../library/configparser.rst:1090 msgid "" "If the given *section* exists, and contains the given *option*, return :" "const:`True`; otherwise return :const:`False`. If the specified *section* " "is :const:`None` or an empty string, DEFAULT is assumed." msgstr "" -#: ../../library/configparser.rst:1083 +#: ../../library/configparser.rst:1097 msgid "" "Attempt to read and parse an iterable of filenames, returning a list of " "filenames which were successfully parsed." msgstr "" -#: ../../library/configparser.rst:1086 +#: ../../library/configparser.rst:1100 msgid "" "If *filenames* is a string, a :class:`bytes` object or a :term:`path-like " "object`, it is treated as a single filename. If a file named in *filenames* " @@ -1485,7 +1497,7 @@ msgid "" "be read." msgstr "" -#: ../../library/configparser.rst:1095 +#: ../../library/configparser.rst:1109 msgid "" "If none of the named files exist, the :class:`ConfigParser` instance will " "contain an empty dataset. An application which requires initial values to " @@ -1493,7 +1505,7 @@ msgid "" "`read_file` before calling :meth:`read` for any optional files::" msgstr "" -#: ../../library/configparser.rst:1101 +#: ../../library/configparser.rst:1115 msgid "" "import configparser, os\n" "\n" @@ -1509,49 +1521,49 @@ msgstr "" "config.read(['site.cfg', os.path.expanduser('~/.myapp.cfg')],\n" " encoding='cp1250')" -#: ../../library/configparser.rst:1108 +#: ../../library/configparser.rst:1122 msgid "" "Added the *encoding* parameter. Previously, all files were read using the " "default encoding for :func:`open`." msgstr "" -#: ../../library/configparser.rst:1112 +#: ../../library/configparser.rst:1126 msgid "The *filenames* parameter accepts a :term:`path-like object`." msgstr "" -#: ../../library/configparser.rst:1115 +#: ../../library/configparser.rst:1129 msgid "The *filenames* parameter accepts a :class:`bytes` object." msgstr "" -#: ../../library/configparser.rst:1121 +#: ../../library/configparser.rst:1135 msgid "" "Read and parse configuration data from *f* which must be an iterable " "yielding Unicode strings (for example files opened in text mode)." msgstr "" -#: ../../library/configparser.rst:1124 +#: ../../library/configparser.rst:1138 msgid "" "Optional argument *source* specifies the name of the file being read. If " "not given and *f* has a :attr:`!name` attribute, that is used for *source*; " "the default is ``''``." msgstr "" -#: ../../library/configparser.rst:1128 +#: ../../library/configparser.rst:1142 msgid "Replaces :meth:`!readfp`." msgstr "取代 :meth:`!readfp`。" -#: ../../library/configparser.rst:1133 +#: ../../library/configparser.rst:1147 msgid "Parse configuration data from a string." msgstr "" -#: ../../library/configparser.rst:1135 +#: ../../library/configparser.rst:1149 msgid "" "Optional argument *source* specifies a context-specific name of the string " "passed. If not given, ``''`` is used. This should commonly be a " "filesystem path or a URL." msgstr "" -#: ../../library/configparser.rst:1144 +#: ../../library/configparser.rst:1158 msgid "" "Load configuration from any object that provides a dict-like ``items()`` " "method. Keys are section names, values are dictionaries with keys and " @@ -1560,17 +1572,17 @@ msgid "" "automatically converted to strings." msgstr "" -#: ../../library/configparser.rst:1150 +#: ../../library/configparser.rst:1164 msgid "" "Optional argument *source* specifies a context-specific name of the " "dictionary passed. If not given, ```` is used." msgstr "" -#: ../../library/configparser.rst:1153 +#: ../../library/configparser.rst:1167 msgid "This method can be used to copy state between parsers." msgstr "" -#: ../../library/configparser.rst:1160 +#: ../../library/configparser.rst:1174 msgid "" "Get an *option* value for the named *section*. If *vars* is provided, it " "must be a dictionary. The *option* is looked up in *vars* (if provided), " @@ -1579,35 +1591,35 @@ msgid "" "provided as a *fallback* value." msgstr "" -#: ../../library/configparser.rst:1166 +#: ../../library/configparser.rst:1180 msgid "" "All the ``'%'`` interpolations are expanded in the return values, unless the " "*raw* argument is true. Values for interpolation keys are looked up in the " "same manner as the option." msgstr "" -#: ../../library/configparser.rst:1170 +#: ../../library/configparser.rst:1184 msgid "" "Arguments *raw*, *vars* and *fallback* are keyword only to protect users " "from trying to use the third argument as the *fallback* fallback (especially " "when using the mapping protocol)." msgstr "" -#: ../../library/configparser.rst:1178 +#: ../../library/configparser.rst:1192 msgid "" "A convenience method which coerces the *option* in the specified *section* " "to an integer. See :meth:`get` for explanation of *raw*, *vars* and " "*fallback*." msgstr "" -#: ../../library/configparser.rst:1185 +#: ../../library/configparser.rst:1199 msgid "" "A convenience method which coerces the *option* in the specified *section* " "to a floating-point number. See :meth:`get` for explanation of *raw*, " "*vars* and *fallback*." msgstr "" -#: ../../library/configparser.rst:1192 +#: ../../library/configparser.rst:1206 msgid "" "A convenience method which coerces the *option* in the specified *section* " "to a Boolean value. Note that the accepted values for the option are " @@ -1619,34 +1631,34 @@ msgid "" "*fallback*." msgstr "" -#: ../../library/configparser.rst:1205 +#: ../../library/configparser.rst:1219 msgid "" "When *section* is not given, return a list of *section_name*, " "*section_proxy* pairs, including DEFAULTSECT." msgstr "" -#: ../../library/configparser.rst:1208 +#: ../../library/configparser.rst:1222 msgid "" "Otherwise, return a list of *name*, *value* pairs for the options in the " "given *section*. Optional arguments have the same meaning as for the :meth:" "`get` method." msgstr "" -#: ../../library/configparser.rst:1212 +#: ../../library/configparser.rst:1226 msgid "" "Items present in *vars* no longer appear in the result. The previous " "behaviour mixed actual parser options with variables provided for " "interpolation." msgstr "" -#: ../../library/configparser.rst:1220 +#: ../../library/configparser.rst:1234 msgid "" "If the given section exists, set the given option to the specified value; " "otherwise raise :exc:`NoSectionError`. *option* and *value* must be " "strings; if not, :exc:`TypeError` is raised." msgstr "" -#: ../../library/configparser.rst:1227 +#: ../../library/configparser.rst:1241 msgid "" "Write a representation of the configuration to the specified :term:`file " "object`, which must be opened in text mode (accepting strings). This " @@ -1655,27 +1667,27 @@ msgid "" "surrounded by spaces." msgstr "" -#: ../../library/configparser.rst:1235 +#: ../../library/configparser.rst:1249 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:1243 +#: ../../library/configparser.rst:1257 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:1251 +#: ../../library/configparser.rst:1265 msgid "" "Remove the specified *section* from the configuration. If the section in " "fact existed, return ``True``. Otherwise return ``False``." msgstr "" -#: ../../library/configparser.rst:1257 +#: ../../library/configparser.rst:1271 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 " @@ -1684,7 +1696,7 @@ msgid "" "of this name on instances to affect this behavior." msgstr "" -#: ../../library/configparser.rst:1263 +#: ../../library/configparser.rst:1277 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 " @@ -1692,7 +1704,7 @@ msgid "" "sensitive::" msgstr "" -#: ../../library/configparser.rst:1268 +#: ../../library/configparser.rst:1282 msgid "" "cfgparser = ConfigParser()\n" "cfgparser.optionxform = str" @@ -1700,30 +1712,30 @@ msgstr "" "cfgparser = ConfigParser()\n" "cfgparser.optionxform = str" -#: ../../library/configparser.rst:1271 +#: ../../library/configparser.rst:1285 msgid "" "Note that when reading configuration files, whitespace around the option " "names is stripped before :meth:`optionxform` is called." msgstr "" -#: ../../library/configparser.rst:1277 +#: ../../library/configparser.rst:1291 msgid "" "A special object representing a section name used to reference the unnamed " "section (see :ref:`unnamed-sections`)." msgstr "" -#: ../../library/configparser.rst:1282 +#: ../../library/configparser.rst:1296 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:1290 +#: ../../library/configparser.rst:1304 msgid "RawConfigParser Objects" msgstr "RawConfigParser 物件" -#: ../../library/configparser.rst:1300 +#: ../../library/configparser.rst:1315 msgid "" "Legacy variant of the :class:`ConfigParser`. It has interpolation disabled " "by default and allows for non-string section names, option names, and values " @@ -1731,27 +1743,27 @@ msgid "" "``defaults=`` keyword argument handling." msgstr "" -#: ../../library/configparser.rst:1310 +#: ../../library/configparser.rst:1336 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:1317 +#: ../../library/configparser.rst:1343 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." msgstr "" -#: ../../library/configparser.rst:1321 +#: ../../library/configparser.rst:1347 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:1327 +#: ../../library/configparser.rst:1353 msgid "" "If the given section exists, set the given option to the specified value; " "otherwise raise :exc:`NoSectionError`. While it is possible to use :class:" @@ -1761,7 +1773,7 @@ msgid "" "string values." msgstr "" -#: ../../library/configparser.rst:1334 +#: ../../library/configparser.rst:1360 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 " @@ -1769,32 +1781,32 @@ msgid "" "not allow such assignments to take place." msgstr "" -#: ../../library/configparser.rst:1341 +#: ../../library/configparser.rst:1367 msgid "Exceptions" msgstr "例外" -#: ../../library/configparser.rst:1345 +#: ../../library/configparser.rst:1371 msgid "Base class for all other :mod:`configparser` exceptions." msgstr "" -#: ../../library/configparser.rst:1350 +#: ../../library/configparser.rst:1376 msgid "Exception raised when a specified section is not found." msgstr "" -#: ../../library/configparser.rst:1355 +#: ../../library/configparser.rst:1381 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:1359 +#: ../../library/configparser.rst:1385 msgid "" "Added the optional *source* and *lineno* attributes and parameters to :meth:" "`!__init__`." msgstr "" -#: ../../library/configparser.rst:1366 +#: ../../library/configparser.rst:1392 msgid "" "Exception raised by strict parsers if a single option appears twice during " "reading from a single file, string or dictionary. This catches misspellings " @@ -1802,64 +1814,64 @@ msgid "" "representing the same case-insensitive configuration key." msgstr "" -#: ../../library/configparser.rst:1374 +#: ../../library/configparser.rst:1400 msgid "" "Exception raised when a specified option is not found in the specified " "section." msgstr "" -#: ../../library/configparser.rst:1380 +#: ../../library/configparser.rst:1406 msgid "" "Base class for exceptions raised when problems occur performing string " "interpolation." msgstr "" -#: ../../library/configparser.rst:1386 +#: ../../library/configparser.rst:1412 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:1393 +#: ../../library/configparser.rst:1419 msgid "" "Exception raised when an option referenced from a value does not exist. " "Subclass of :exc:`InterpolationError`." msgstr "" -#: ../../library/configparser.rst:1399 +#: ../../library/configparser.rst:1425 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:1405 +#: ../../library/configparser.rst:1431 msgid "" "Exception raised when attempting to parse a file which has no section " "headers." msgstr "" -#: ../../library/configparser.rst:1411 +#: ../../library/configparser.rst:1437 msgid "Exception raised when errors occur attempting to parse a file." msgstr "" -#: ../../library/configparser.rst:1413 +#: ../../library/configparser.rst:1439 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:1419 +#: ../../library/configparser.rst:1445 msgid "" "Exception raised when a key without a corresponding value is continued with " "an indented line." msgstr "" -#: ../../library/configparser.rst:1425 +#: ../../library/configparser.rst:1451 msgid "Footnotes" msgstr "註解" -#: ../../library/configparser.rst:1426 +#: ../../library/configparser.rst:1452 msgid "" "Config parsers allow for heavy customization. If you are interested in " "changing the behaviour outlined by the footnote reference, consult the " @@ -1886,14 +1898,14 @@ msgstr "ini file(ini 檔案)" msgid "Windows ini file" msgstr "Windows ini file(Windows ini 檔案)" -#: ../../library/configparser.rst:366 +#: ../../library/configparser.rst:367 msgid "% (percent)" msgstr "% (百分號)" -#: ../../library/configparser.rst:366 ../../library/configparser.rst:399 +#: ../../library/configparser.rst:367 ../../library/configparser.rst:400 msgid "interpolation in configuration files" msgstr "interpolation in configuration files(設定檔中的插值)" -#: ../../library/configparser.rst:399 +#: ../../library/configparser.rst:400 msgid "$ (dollar)" msgstr "$ (金錢符號)" diff --git a/library/constants.po b/library/constants.po index 9fd1624475..fc6b1f3586 100644 --- a/library/constants.po +++ b/library/constants.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-07 03:11+0800\n" +"POT-Creation-Date: 2025-03-03 18:39+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-" @@ -96,16 +96,17 @@ msgid "See :ref:`implementing-the-arithmetic-operations` for examples." msgstr "請參見 :ref:`implementing-the-arithmetic-operations` 以找到更多範例。" #: ../../library/constants.rst:51 +#, fuzzy msgid "" -"``NotImplementedError`` and :data:`!NotImplemented` are not interchangeable, " -"even though they have similar names and purposes. See :exc:" -"`NotImplementedError` for details on when to use it." +":data:`!NotImplemented` and :exc:`!NotImplementedError` are not " +"interchangeable. This constant should only be used as described above; see :" +"exc:`NotImplementedError` for details on correct usage of the exception." msgstr "" "``NotImplementedError`` 與 :data:`!NotImplemented` 並不一樣且不可互換。即使它" "們有相似的名稱與用途。欲知更多如何使用它們的細節,請參見 :exc:" "`NotImplementedError`。" -#: ../../library/constants.rst:55 +#: ../../library/constants.rst:56 msgid "" "Evaluating :data:`!NotImplemented` in a boolean context is deprecated. While " "it currently evaluates as true, it will emit a :exc:`DeprecationWarning`. It " @@ -115,7 +116,7 @@ msgstr "" "被解讀成 true,但會發出一個 :exc:`DeprecationWarning`。在未來版本的 Python 將" "會拋出 :exc:`TypeError`。" -#: ../../library/constants.rst:64 +#: ../../library/constants.rst:65 msgid "" "The same as the ellipsis literal \"``...``\". Special value used mostly in " "conjunction with extended slicing syntax for user-defined container data " @@ -126,7 +127,7 @@ msgstr "" "伸切片語法 (extended slicing syntax)。``Ellipsis`` 是型別 :data:`types." "EllipsisType` 的唯一實例。" -#: ../../library/constants.rst:71 +#: ../../library/constants.rst:72 msgid "" "This constant is true if Python was not started with an :option:`-O` option. " "See also the :keyword:`assert` statement." @@ -134,7 +135,7 @@ msgstr "" "如果 Python 沒有被以 :option:`-O` 選項啟動,則此常數為 true。請參見 :keyword:" "`assert` 陳述式。" -#: ../../library/constants.rst:77 +#: ../../library/constants.rst:78 msgid "" "The names :data:`None`, :data:`False`, :data:`True` and :data:`__debug__` " "cannot be reassigned (assignments to them, even as an attribute name, raise :" @@ -144,11 +145,11 @@ msgstr "" "重新賦值的(任何對它們的賦值,即使是屬性的名稱,也會拋出 :exc:" "`SyntaxError`)。因此,它們可以被視為”真正的”常數。" -#: ../../library/constants.rst:85 +#: ../../library/constants.rst:86 msgid "Constants added by the :mod:`site` module" msgstr "由 :mod:`site` module(模組)所添增的常數" -#: ../../library/constants.rst:87 +#: ../../library/constants.rst:88 msgid "" "The :mod:`site` module (which is imported automatically during startup, " "except if the :option:`-S` command-line option is given) adds several " @@ -159,7 +160,7 @@ msgstr "" "指令行選項)會添增一些常數到內建命名空間 (built-in namespace) 中。它們在互動" "式直譯器中是很有幫助的,但不應該在程式 (programs) 中被使用。" -#: ../../library/constants.rst:95 +#: ../../library/constants.rst:96 msgid "" "Objects that when printed, print a message like \"Use quit() or Ctrl-D (i.e. " "EOF) to exit\", and when called, raise :exc:`SystemExit` with the specified " @@ -168,7 +169,7 @@ msgstr "" "當印出物件時,會印出一個訊息: \"Use quit() or Ctrl-D (i.e. EOF) to exit\" 。" "當被呼叫時,則會拋出 :exc:`SystemExit` 並帶有指定的返回碼(exit code)。" -#: ../../library/constants.rst:102 +#: ../../library/constants.rst:103 msgid "" "Object that when printed, prints the message \"Type help() for interactive " "help, or help(object) for help about object.\", and when called, acts as " @@ -178,13 +179,13 @@ msgstr "" "help(object) for help about object.\",並在呼叫時按所述的方式操作 :func:" "`elsewhere `。" -#: ../../library/constants.rst:109 +#: ../../library/constants.rst:110 msgid "" "Objects that when printed or called, print the text of copyright or credits, " "respectively." msgstr "當印出或是呼叫此物件時,分別會印出版權與致謝的文字。" -#: ../../library/constants.rst:114 +#: ../../library/constants.rst:115 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 " @@ -193,10 +194,10 @@ msgstr "" "當印出此物件時,會印出訊息 \"Type license() to see the full license text\"," "並在呼叫時以分頁形式印出完整的許可證文字(一次一整個畫面)。" -#: ../../library/constants.rst:61 +#: ../../library/constants.rst:62 msgid "..." msgstr "..." -#: ../../library/constants.rst:61 +#: ../../library/constants.rst:62 msgid "ellipsis literal" msgstr "ellipsis literal(刪節號)" diff --git a/library/contextlib.po b/library/contextlib.po index 5785f5506e..3ae04e771a 100644 --- a/library/contextlib.po +++ b/library/contextlib.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-04-24 05:56+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-" @@ -73,7 +73,7 @@ msgid "" "While many objects natively support use in with statements, sometimes a " "resource needs to be managed that isn't a context manager in its own right, " "and doesn't implement a ``close()`` method for use with ``contextlib." -"closing``" +"closing``." msgstr "" #: ../../library/contextlib.rst:54 @@ -982,37 +982,37 @@ msgid "" "be used instead." msgstr "" -#: ../../library/contextlib.rst:634 +#: ../../library/contextlib.rst:635 msgid "" "Similar to :meth:`ExitStack.enter_context` but expects an asynchronous " "context manager." msgstr "" -#: ../../library/contextlib.rst:637 +#: ../../library/contextlib.rst:638 msgid "" "Raises :exc:`TypeError` instead of :exc:`AttributeError` if *cm* is not an " "asynchronous context manager." msgstr "" -#: ../../library/contextlib.rst:643 +#: ../../library/contextlib.rst:644 msgid "" "Similar to :meth:`ExitStack.push` but expects either an asynchronous context " "manager or a coroutine function." msgstr "" -#: ../../library/contextlib.rst:648 +#: ../../library/contextlib.rst:649 msgid "Similar to :meth:`ExitStack.callback` but expects a coroutine function." msgstr "" -#: ../../library/contextlib.rst:652 +#: ../../library/contextlib.rst:654 msgid "Similar to :meth:`ExitStack.close` but properly handles awaitables." msgstr "" -#: ../../library/contextlib.rst:654 +#: ../../library/contextlib.rst:656 msgid "Continuing the example for :func:`asynccontextmanager`::" msgstr "" -#: ../../library/contextlib.rst:656 +#: ../../library/contextlib.rst:658 msgid "" "async with AsyncExitStack() as stack:\n" " connections = [await stack.enter_async_context(get_connection())\n" @@ -1022,21 +1022,21 @@ msgid "" " # later in the list raise an exception." msgstr "" -#: ../../library/contextlib.rst:666 +#: ../../library/contextlib.rst:668 msgid "Examples and Recipes" msgstr "" -#: ../../library/contextlib.rst:668 +#: ../../library/contextlib.rst:670 msgid "" "This section describes some examples and recipes for making effective use of " "the tools provided by :mod:`contextlib`." msgstr "" -#: ../../library/contextlib.rst:673 +#: ../../library/contextlib.rst:675 msgid "Supporting a variable number of context managers" msgstr "" -#: ../../library/contextlib.rst:675 +#: ../../library/contextlib.rst:677 msgid "" "The primary use case for :class:`ExitStack` is the one given in the class " "documentation: supporting a variable number of context managers and other " @@ -1046,7 +1046,7 @@ msgid "" "of the context managers being optional::" msgstr "" -#: ../../library/contextlib.rst:682 +#: ../../library/contextlib.rst:684 msgid "" "with ExitStack() as stack:\n" " for resource in resources:\n" @@ -1057,18 +1057,18 @@ msgid "" " # Perform operations that use the acquired resources" msgstr "" -#: ../../library/contextlib.rst:690 +#: ../../library/contextlib.rst:692 msgid "" "As shown, :class:`ExitStack` also makes it quite easy to use :keyword:`with` " "statements to manage arbitrary resources that don't natively support the " "context management protocol." msgstr "" -#: ../../library/contextlib.rst:696 +#: ../../library/contextlib.rst:698 msgid "Catching exceptions from ``__enter__`` methods" msgstr "" -#: ../../library/contextlib.rst:698 +#: ../../library/contextlib.rst:700 msgid "" "It is occasionally desirable to catch exceptions from an ``__enter__`` " "method implementation, *without* inadvertently catching exceptions from the :" @@ -1077,7 +1077,7 @@ msgid "" "be separated slightly in order to allow this::" msgstr "" -#: ../../library/contextlib.rst:704 +#: ../../library/contextlib.rst:706 msgid "" "stack = ExitStack()\n" "try:\n" @@ -1089,7 +1089,7 @@ msgid "" " # Handle normal case" msgstr "" -#: ../../library/contextlib.rst:713 +#: ../../library/contextlib.rst:715 msgid "" "Actually needing to do this is likely to indicate that the underlying API " "should be providing a direct resource management interface for use with :" @@ -1100,25 +1100,25 @@ msgid "" "`with` statement." msgstr "" -#: ../../library/contextlib.rst:723 +#: ../../library/contextlib.rst:725 msgid "Cleaning up in an ``__enter__`` implementation" msgstr "" -#: ../../library/contextlib.rst:725 +#: ../../library/contextlib.rst:727 msgid "" "As noted in the documentation of :meth:`ExitStack.push`, this method can be " "useful in cleaning up an already allocated resource if later steps in the :" "meth:`~object.__enter__` implementation fail." msgstr "" -#: ../../library/contextlib.rst:729 +#: ../../library/contextlib.rst:731 msgid "" "Here's an example of doing this for a context manager that accepts resource " "acquisition and release functions, along with an optional validation " "function, and maps them to the context management protocol::" msgstr "" -#: ../../library/contextlib.rst:733 +#: ../../library/contextlib.rst:735 msgid "" "from contextlib import contextmanager, AbstractContextManager, ExitStack\n" "\n" @@ -1156,11 +1156,11 @@ msgid "" " self.release_resource()" msgstr "" -#: ../../library/contextlib.rst:769 +#: ../../library/contextlib.rst:771 msgid "Replacing any use of ``try-finally`` and flag variables" msgstr "" -#: ../../library/contextlib.rst:771 +#: ../../library/contextlib.rst:773 msgid "" "A pattern you will sometimes see is a ``try-finally`` statement with a flag " "variable to indicate whether or not the body of the ``finally`` clause " @@ -1168,7 +1168,7 @@ msgid "" "by using an ``except`` clause instead), it looks something like this::" msgstr "" -#: ../../library/contextlib.rst:776 +#: ../../library/contextlib.rst:778 msgid "" "cleanup_needed = True\n" "try:\n" @@ -1188,21 +1188,21 @@ msgstr "" " if cleanup_needed:\n" " cleanup_resources()" -#: ../../library/contextlib.rst:785 +#: ../../library/contextlib.rst:787 msgid "" "As with any ``try`` statement based code, this can cause problems for " "development and review, because the setup code and the cleanup code can end " "up being separated by arbitrarily long sections of code." msgstr "" -#: ../../library/contextlib.rst:789 +#: ../../library/contextlib.rst:791 msgid "" ":class:`ExitStack` makes it possible to instead register a callback for " "execution at the end of a ``with`` statement, and then later decide to skip " "executing that callback::" msgstr "" -#: ../../library/contextlib.rst:793 +#: ../../library/contextlib.rst:795 msgid "" "from contextlib import ExitStack\n" "\n" @@ -1220,19 +1220,19 @@ msgstr "" " if result:\n" " stack.pop_all()" -#: ../../library/contextlib.rst:801 +#: ../../library/contextlib.rst:803 msgid "" "This allows the intended cleanup behaviour to be made explicit up front, " "rather than requiring a separate flag variable." msgstr "" -#: ../../library/contextlib.rst:804 +#: ../../library/contextlib.rst:806 msgid "" "If a particular application uses this pattern a lot, it can be simplified " "even further by means of a small helper class::" msgstr "" -#: ../../library/contextlib.rst:807 +#: ../../library/contextlib.rst:809 msgid "" "from contextlib import ExitStack\n" "\n" @@ -1264,14 +1264,14 @@ msgstr "" " if result:\n" " cb.cancel()" -#: ../../library/contextlib.rst:822 +#: ../../library/contextlib.rst:824 msgid "" "If the resource cleanup isn't already neatly bundled into a standalone " "function, then it is still possible to use the decorator form of :meth:" "`ExitStack.callback` to declare the resource cleanup in advance::" msgstr "" -#: ../../library/contextlib.rst:827 +#: ../../library/contextlib.rst:829 msgid "" "from contextlib import ExitStack\n" "\n" @@ -1293,24 +1293,24 @@ msgstr "" " if result:\n" " stack.pop_all()" -#: ../../library/contextlib.rst:837 +#: ../../library/contextlib.rst:839 msgid "" "Due to the way the decorator protocol works, a callback function declared " "this way cannot take any parameters. Instead, any resources to be released " "must be accessed as closure variables." msgstr "" -#: ../../library/contextlib.rst:843 +#: ../../library/contextlib.rst:845 msgid "Using a context manager as a function decorator" msgstr "" -#: ../../library/contextlib.rst:845 +#: ../../library/contextlib.rst:847 msgid "" ":class:`ContextDecorator` makes it possible to use a context manager in both " "an ordinary ``with`` statement and also as a function decorator." msgstr "" -#: ../../library/contextlib.rst:848 +#: ../../library/contextlib.rst:850 msgid "" "For example, it is sometimes useful to wrap functions or groups of " "statements with a logger that can track the time of entry and time of exit. " @@ -1319,7 +1319,7 @@ msgid "" "in a single definition::" msgstr "" -#: ../../library/contextlib.rst:854 +#: ../../library/contextlib.rst:856 msgid "" "from contextlib import ContextDecorator\n" "import logging\n" @@ -1351,11 +1351,11 @@ msgstr "" " def __exit__(self, exc_type, exc, exc_tb):\n" " logging.info('Exiting: %s', self.name)" -#: ../../library/contextlib.rst:869 +#: ../../library/contextlib.rst:871 msgid "Instances of this class can be used as both a context manager::" msgstr "" -#: ../../library/contextlib.rst:871 +#: ../../library/contextlib.rst:873 msgid "" "with track_entry_and_exit('widget loader'):\n" " print('Some time consuming activity goes here')\n" @@ -1365,11 +1365,11 @@ msgstr "" " print('Some time consuming activity goes here')\n" " load_widget()" -#: ../../library/contextlib.rst:875 +#: ../../library/contextlib.rst:877 msgid "And also as a function decorator::" msgstr "" -#: ../../library/contextlib.rst:877 +#: ../../library/contextlib.rst:879 msgid "" "@track_entry_and_exit('widget loader')\n" "def activity():\n" @@ -1381,7 +1381,7 @@ msgstr "" " print('Some time consuming activity goes here')\n" " load_widget()" -#: ../../library/contextlib.rst:882 +#: ../../library/contextlib.rst:884 msgid "" "Note that there is one additional limitation when using context managers as " "function decorators: there's no way to access the return value of :meth:" @@ -1389,21 +1389,21 @@ msgid "" "use an explicit ``with`` statement." msgstr "" -#: ../../library/contextlib.rst:889 +#: ../../library/contextlib.rst:891 msgid ":pep:`343` - The \"with\" statement" msgstr ":pep:`343` - \"with\" 陳述式" -#: ../../library/contextlib.rst:890 +#: ../../library/contextlib.rst:892 msgid "" "The specification, background, and examples for the Python :keyword:`with` " "statement." msgstr "" -#: ../../library/contextlib.rst:896 +#: ../../library/contextlib.rst:898 msgid "Single use, reusable and reentrant context managers" msgstr "" -#: ../../library/contextlib.rst:898 +#: ../../library/contextlib.rst:900 msgid "" "Most context managers are written in a way that means they can only be used " "effectively in a :keyword:`with` statement once. These single use context " @@ -1411,28 +1411,28 @@ msgid "" "them a second time will trigger an exception or otherwise not work correctly." msgstr "" -#: ../../library/contextlib.rst:904 +#: ../../library/contextlib.rst:906 msgid "" "This common limitation means that it is generally advisable to create " "context managers directly in the header of the :keyword:`with` statement " "where they are used (as shown in all of the usage examples above)." msgstr "" -#: ../../library/contextlib.rst:908 +#: ../../library/contextlib.rst:910 msgid "" "Files are an example of effectively single use context managers, since the " "first :keyword:`with` statement will close the file, preventing any further " "IO operations using that file object." msgstr "" -#: ../../library/contextlib.rst:912 +#: ../../library/contextlib.rst:914 msgid "" "Context managers created using :func:`contextmanager` are also single use " "context managers, and will complain about the underlying generator failing " "to yield if an attempt is made to use them a second time::" msgstr "" -#: ../../library/contextlib.rst:916 +#: ../../library/contextlib.rst:918 msgid "" ">>> from contextlib import contextmanager\n" ">>> @contextmanager\n" @@ -1474,11 +1474,11 @@ msgstr "" " ...\n" "RuntimeError: generator didn't yield" -#: ../../library/contextlib.rst:940 +#: ../../library/contextlib.rst:942 msgid "Reentrant context managers" msgstr "" -#: ../../library/contextlib.rst:942 +#: ../../library/contextlib.rst:944 msgid "" "More sophisticated context managers may be \"reentrant\". These context " "managers can not only be used in multiple :keyword:`with` statements, but " @@ -1486,14 +1486,14 @@ msgid "" "the same context manager." msgstr "" -#: ../../library/contextlib.rst:947 +#: ../../library/contextlib.rst:949 msgid "" ":class:`threading.RLock` is an example of a reentrant context manager, as " "are :func:`suppress`, :func:`redirect_stdout`, and :func:`chdir`. Here's a " "very simple example of reentrant use::" msgstr "" -#: ../../library/contextlib.rst:951 +#: ../../library/contextlib.rst:953 msgid "" ">>> from contextlib import redirect_stdout\n" ">>> from io import StringIO\n" @@ -1525,14 +1525,14 @@ msgstr "" "This is written to the stream rather than stdout\n" "This is also written to the stream" -#: ../../library/contextlib.rst:966 +#: ../../library/contextlib.rst:968 msgid "" "Real world examples of reentrancy are more likely to involve multiple " "functions calling each other and hence be far more complicated than this " "example." msgstr "" -#: ../../library/contextlib.rst:970 +#: ../../library/contextlib.rst:972 msgid "" "Note also that being reentrant is *not* the same thing as being thread " "safe. :func:`redirect_stdout`, for example, is definitely not thread safe, " @@ -1540,11 +1540,11 @@ msgid "" "stdout` to a different stream." msgstr "" -#: ../../library/contextlib.rst:979 +#: ../../library/contextlib.rst:981 msgid "Reusable context managers" msgstr "" -#: ../../library/contextlib.rst:981 +#: ../../library/contextlib.rst:983 msgid "" "Distinct from both single use and reentrant context managers are " "\"reusable\" context managers (or, to be completely explicit, \"reusable, " @@ -1554,21 +1554,21 @@ msgid "" "manager instance has already been used in a containing with statement." msgstr "" -#: ../../library/contextlib.rst:988 +#: ../../library/contextlib.rst:990 msgid "" ":class:`threading.Lock` is an example of a reusable, but not reentrant, " "context manager (for a reentrant lock, it is necessary to use :class:" "`threading.RLock` instead)." msgstr "" -#: ../../library/contextlib.rst:992 +#: ../../library/contextlib.rst:994 msgid "" "Another example of a reusable, but not reentrant, context manager is :class:" "`ExitStack`, as it invokes *all* currently registered callbacks when leaving " "any with statement, regardless of where those callbacks were added::" msgstr "" -#: ../../library/contextlib.rst:997 +#: ../../library/contextlib.rst:999 msgid "" ">>> from contextlib import ExitStack\n" ">>> stack = ExitStack()\n" @@ -1622,7 +1622,7 @@ msgstr "" "Callback: from outer context\n" "Leaving outer context" -#: ../../library/contextlib.rst:1023 +#: ../../library/contextlib.rst:1025 msgid "" "As the output from the example shows, reusing a single stack object across " "multiple with statements works correctly, but attempting to nest them will " @@ -1630,13 +1630,13 @@ msgid "" "which is unlikely to be desirable behaviour." msgstr "" -#: ../../library/contextlib.rst:1028 +#: ../../library/contextlib.rst:1030 msgid "" "Using separate :class:`ExitStack` instances instead of reusing a single " "instance avoids that problem::" msgstr "" -#: ../../library/contextlib.rst:1031 +#: ../../library/contextlib.rst:1033 msgid "" ">>> from contextlib import ExitStack\n" ">>> with ExitStack() as outer_stack:\n" diff --git a/library/contextvars.po b/library/contextvars.po index b90483b630..60997afbaf 100644 --- a/library/contextvars.po +++ b/library/contextvars.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2024-11-20 09:21+0000\n" "PO-Revision-Date: 2018-07-15 18:56+0800\n" "Last-Translator: \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -203,45 +203,91 @@ msgstr "" #: ../../library/contextvars.rst:147 msgid "" -"Every thread will have a different top-level :class:`~contextvars.Context` " -"object. This means that a :class:`ContextVar` object behaves in a similar " -"fashion to :func:`threading.local` when values are assigned in different " -"threads." +"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 "" #: ../../library/contextvars.rst:152 -msgid "Context implements the :class:`collections.abc.Mapping` interface." +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 " +"the current thread's context stack." msgstr "" #: ../../library/contextvars.rst:156 msgid "" -"Execute ``callable(*args, **kwargs)`` code in the context object the *run* " -"method is called on. Return the result of the execution or propagate an " -"exception if one occurred." +"*Exiting* from the current context, which can be done by returning from the " +"callback passed to the :meth:`~Context.run` method, restores the current " +"context to what it was before the context was entered by popping the context " +"off the top of the context stack." msgstr "" -#: ../../library/contextvars.rst:160 +#: ../../library/contextvars.rst:161 msgid "" -"Any changes to any context variables that *callable* makes will be contained " -"in the context object::" +"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 "" -#: ../../library/contextvars.rst:163 +#: ../../library/contextvars.rst:165 msgid "" -"var = ContextVar('var')\n" +"Attempting to enter an already entered context, including contexts entered " +"in other threads, raises a :exc:`RuntimeError`." +msgstr "" + +#: ../../library/contextvars.rst:168 +msgid "After exiting a context, it can later be re-entered (from any thread)." +msgstr "" + +#: ../../library/contextvars.rst:170 +msgid "" +"Any changes to :class:`ContextVar` values via the :meth:`ContextVar.set` " +"method are recorded in the current context. The :meth:`ContextVar.get` " +"method returns the value associated with the current context. Exiting a " +"context effectively reverts any changes made to context variables while the " +"context was entered (if needed, the values can be restored by re-entering " +"the context)." +msgstr "" + +#: ../../library/contextvars.rst:177 +msgid "Context implements the :class:`collections.abc.Mapping` interface." +msgstr "" + +#: ../../library/contextvars.rst:181 +msgid "" +"Enters the Context, executes ``callable(*args, **kwargs)``, then exits the " +"Context. Returns *callable*'s return value, or propagates an exception if " +"one occurred." +msgstr "" + +#: ../../library/contextvars.rst:185 +#, fuzzy +msgid "Example:" +msgstr "舉例來說: ::" + +#: ../../library/contextvars.rst:187 +msgid "" +"import contextvars\n" +"\n" +"var = contextvars.ContextVar('var')\n" "var.set('spam')\n" +"print(var.get()) # 'spam'\n" +"\n" +"ctx = contextvars.copy_context()\n" "\n" "def main():\n" " # 'var' was set to 'spam' before\n" " # calling 'copy_context()' and 'ctx.run(main)', so:\n" -" # var.get() == ctx[var] == 'spam'\n" +" print(var.get()) # 'spam'\n" +" print(ctx[var]) # 'spam'\n" "\n" " var.set('ham')\n" "\n" " # Now, after setting 'var' to 'ham':\n" -" # var.get() == ctx[var] == 'ham'\n" -"\n" -"ctx = copy_context()\n" +" print(var.get()) # 'ham'\n" +" print(ctx[var]) # 'ham'\n" "\n" "# Any changes that the 'main' function makes to 'var'\n" "# will be contained in 'ctx'.\n" @@ -249,67 +295,61 @@ msgid "" "\n" "# The 'main()' function was run in the 'ctx' context,\n" "# so changes to 'var' are contained in it:\n" -"# ctx[var] == 'ham'\n" +"print(ctx[var]) # 'ham'\n" "\n" "# However, outside of 'ctx', 'var' is still set to 'spam':\n" -"# var.get() == 'spam'" -msgstr "" - -#: ../../library/contextvars.rst:189 -msgid "" -"The method raises a :exc:`RuntimeError` when called on the same context " -"object from more than one OS thread, or when called recursively." +"print(var.get()) # 'spam'" msgstr "" -#: ../../library/contextvars.rst:195 +#: ../../library/contextvars.rst:233 msgid "Return a shallow copy of the context object." msgstr "" -#: ../../library/contextvars.rst:199 +#: ../../library/contextvars.rst:237 msgid "" "Return ``True`` if the *context* has a value for *var* set; return ``False`` " "otherwise." msgstr "" -#: ../../library/contextvars.rst:204 +#: ../../library/contextvars.rst:242 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." msgstr "" -#: ../../library/contextvars.rst:210 +#: ../../library/contextvars.rst:248 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 "" -#: ../../library/contextvars.rst:216 +#: ../../library/contextvars.rst:254 msgid "Return an iterator over the variables stored in the context object." msgstr "" -#: ../../library/contextvars.rst:221 +#: ../../library/contextvars.rst:259 msgid "Return the number of variables set in the context object." msgstr "" -#: ../../library/contextvars.rst:225 +#: ../../library/contextvars.rst:263 msgid "Return a list of all variables in the context object." msgstr "" -#: ../../library/contextvars.rst:229 +#: ../../library/contextvars.rst:267 msgid "Return a list of all variables' values in the context object." msgstr "" -#: ../../library/contextvars.rst:234 +#: ../../library/contextvars.rst:272 msgid "" "Return a list of 2-tuples containing all variables and their values in the " "context object." msgstr "" -#: ../../library/contextvars.rst:239 +#: ../../library/contextvars.rst:277 msgid "asyncio support" msgstr "" -#: ../../library/contextvars.rst:241 +#: ../../library/contextvars.rst:279 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 " @@ -317,7 +357,7 @@ msgid "" "available in the Task that handles that client::" msgstr "" -#: ../../library/contextvars.rst:247 +#: ../../library/contextvars.rst:285 msgid "" "import asyncio\n" "import contextvars\n" @@ -329,7 +369,7 @@ msgid "" " # without passing it explicitly to this function.\n" "\n" " client_addr = client_addr_var.get()\n" -" return f'Good bye, client @ {client_addr}\\n'.encode()\n" +" return f'Good bye, client @ {client_addr}\\r\\n'.encode()\n" "\n" "async def handle_request(reader, writer):\n" " addr = writer.transport.get_extra_info('socket').getpeername()\n" @@ -343,9 +383,10 @@ msgid "" " print(line)\n" " if not line.strip():\n" " break\n" -" writer.write(line)\n" "\n" -" writer.write(render_goodbye())\n" +" writer.write(b'HTTP/1.1 200 OK\\r\\n') # status line\n" +" writer.write(b'\\r\\n') # headers\n" +" writer.write(render_goodbye()) # body\n" " writer.close()\n" "\n" "async def main():\n" @@ -357,6 +398,7 @@ msgid "" "\n" "asyncio.run(main())\n" "\n" -"# To test it you can use telnet:\n" -"# telnet 127.0.0.1 8081" +"# To test it you can use telnet or curl:\n" +"# telnet 127.0.0.1 8081\n" +"# curl 127.0.0.1:8081" msgstr "" diff --git a/library/crypt.po b/library/crypt.po index 4f37bcb814..68a9c63f16 100644 --- a/library/crypt.po +++ b/library/crypt.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2024-11-20 09:21+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-" @@ -18,260 +18,118 @@ msgstr "" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/crypt.rst:2 -msgid ":mod:`crypt` --- Function to check Unix passwords" +#, fuzzy +msgid ":mod:`!crypt` --- Function to check Unix passwords" msgstr ":mod:`crypt` --- 用於檢查 Unix 密碼的函式" -#: ../../library/crypt.rst:13 -msgid "**Source code:** :source:`Lib/crypt.py`" -msgstr "**原始碼:**\\ :source:`Lib/crypt.py`" - -#: ../../library/crypt.rst:19 -msgid "" -"The :mod:`crypt` module is deprecated (see :pep:`PEP 594 <594#crypt>` for " -"details and alternatives). The :mod:`hashlib` module is a potential " -"replacement for certain use cases. The :pypi:`passlib` package can replace " -"all use cases of this module." -msgstr "" - -#: ../../library/crypt.rst:27 -msgid "" -"This module implements an interface to the :manpage:`crypt(3)` routine, " -"which is a one-way hash function based upon a modified DES algorithm; see " -"the Unix man page for further details. Possible uses include storing hashed " -"passwords so you can check passwords without storing the actual password, or " -"attempting to crack Unix passwords with a dictionary." -msgstr "" - -#: ../../library/crypt.rst:35 -msgid "" -"Notice that the behavior of this module depends on the actual " -"implementation of the :manpage:`crypt(3)` routine in the running system. " -"Therefore, any extensions available on the current implementation will also " -"be available on this module." -msgstr "" - -#: ../../library/crypt.rst:40 -msgid ":ref:`Availability `: Unix, not VxWorks." -msgstr ":ref:`適用 `:Unix,非 VxWorks。" - -#: ../../includes/wasm-notavail.rst:3 -msgid ":ref:`Availability `: not Emscripten, not WASI." -msgstr "" - -#: ../../includes/wasm-notavail.rst:5 -msgid "" -"This module does not work or is not available on WebAssembly platforms " -"``wasm32-emscripten`` and ``wasm32-wasi``. See :ref:`wasm-availability` for " -"more information." -msgstr "" -"此模組在 WebAssembly 平台 ``wasm32-emscripten`` 和 ``wasm32-wasi`` 上無法作用" -"或無法使用。有關更多資訊,請參閱 :ref:`wasm-availability`。" - -#: ../../library/crypt.rst:45 -msgid "Hashing Methods" -msgstr "雜湊方法" - -#: ../../library/crypt.rst:49 -msgid "" -"The :mod:`crypt` module defines the list of hashing methods (not all methods " -"are available on all platforms):" -msgstr "" - -#: ../../library/crypt.rst:54 -msgid "" -"A Modular Crypt Format method with 16 character salt and 86 character hash " -"based on the SHA-512 hash function. This is the strongest method." -msgstr "" - -#: ../../library/crypt.rst:59 -msgid "" -"Another Modular Crypt Format method with 16 character salt and 43 character " -"hash based on the SHA-256 hash function." -msgstr "" - -#: ../../library/crypt.rst:64 -msgid "" -"Another Modular Crypt Format method with 22 character salt and 31 character " -"hash based on the Blowfish cipher." -msgstr "" - -#: ../../library/crypt.rst:71 -msgid "" -"Another Modular Crypt Format method with 8 character salt and 22 character " -"hash based on the MD5 hash function." -msgstr "" - -#: ../../library/crypt.rst:76 -msgid "" -"The traditional method with a 2 character salt and 13 characters of hash. " -"This is the weakest method." -msgstr "" - -#: ../../library/crypt.rst:81 -msgid "Module Attributes" -msgstr "模組屬性" - -#: ../../library/crypt.rst:87 -msgid "" -"A list of available password hashing algorithms, as ``crypt.METHOD_*`` " -"objects. This list is sorted from strongest to weakest." -msgstr "" - -#: ../../library/crypt.rst:93 -msgid "Module Functions" -msgstr "模組函式" - -#: ../../library/crypt.rst:95 -msgid "The :mod:`crypt` module defines the following functions:" -msgstr ":mod:`crypt` 模組定義了以下函式:" - -#: ../../library/crypt.rst:99 -msgid "" -"*word* will usually be a user's password as typed at a prompt or in a " -"graphical interface. The optional *salt* is either a string as returned " -"from :func:`mksalt`, one of the ``crypt.METHOD_*`` values (though not all " -"may be available on all platforms), or a full encrypted password including " -"salt, as returned by this function. If *salt* is not provided, the " -"strongest method available in :attr:`methods` will be used." -msgstr "" - -#: ../../library/crypt.rst:106 -msgid "" -"Checking a password is usually done by passing the plain-text password as " -"*word* and the full results of a previous :func:`crypt` call, which should " -"be the same as the results of this call." -msgstr "" - -#: ../../library/crypt.rst:110 -msgid "" -"*salt* (either a random 2 or 16 character string, possibly prefixed with " -"``$digit$`` to indicate the method) which will be used to perturb the " -"encryption algorithm. The characters in *salt* must be in the set ``[./a-zA-" -"Z0-9]``, with the exception of Modular Crypt Format which prefixes a " -"``$digit$``." -msgstr "" - -#: ../../library/crypt.rst:116 -msgid "" -"Returns the hashed password as a string, which will be composed of " -"characters from the same alphabet as the salt." -msgstr "" - -#: ../../library/crypt.rst:121 -msgid "" -"Since a few :manpage:`crypt(3)` extensions allow different values, with " -"different sizes in the *salt*, it is recommended to use the full crypted " -"password as salt when checking for a password." -msgstr "" - -#: ../../library/crypt.rst:125 -msgid "Accept ``crypt.METHOD_*`` values in addition to strings for *salt*." -msgstr "" - -#: ../../library/crypt.rst:131 +#: ../../library/crypt.rst:10 msgid "" -"Return a randomly generated salt of the specified method. If no *method* is " -"given, the strongest method available in :attr:`methods` is used." +"This module is no longer part of the Python standard library. It was :ref:" +"`removed in Python 3.13 ` after being deprecated in " +"Python 3.11. The removal was decided in :pep:`594`." msgstr "" -#: ../../library/crypt.rst:135 +#: ../../library/crypt.rst:14 msgid "" -"The return value is a string suitable for passing as the *salt* argument to :" -"func:`crypt`." +"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." msgstr "" -#: ../../library/crypt.rst:138 -msgid "" -"*rounds* specifies the number of rounds for ``METHOD_SHA256``, " -"``METHOD_SHA512`` and ``METHOD_BLOWFISH``. For ``METHOD_SHA256`` and " -"``METHOD_SHA512`` it must be an integer between ``1000`` and " -"``999_999_999``, the default is ``5000``. For ``METHOD_BLOWFISH`` it must " -"be a power of two between ``16`` (2\\ :sup:`4`) and ``2_147_483_648`` (2\\ :" -"sup:`31`), the default is ``4096`` (2\\ :sup:`12`)." -msgstr "" - -#: ../../library/crypt.rst:148 -msgid "Added the *rounds* parameter." -msgstr "新增 *rounds* 參數。" - -#: ../../library/crypt.rst:153 -msgid "Examples" -msgstr "範例" - -#: ../../library/crypt.rst:155 -msgid "" -"A simple example illustrating typical use (a constant-time comparison " -"operation is needed to limit exposure to timing attacks. :func:`hmac." -"compare_digest` is suitable for this purpose)::" -msgstr "" - -#: ../../library/crypt.rst:159 -msgid "" -"import pwd\n" -"import crypt\n" -"import getpass\n" -"from hmac import compare_digest as compare_hash\n" -"\n" -"def login():\n" -" username = input('Python login: ')\n" -" cryptedpasswd = pwd.getpwnam(username)[1]\n" -" if cryptedpasswd:\n" -" if cryptedpasswd == 'x' or cryptedpasswd == '*':\n" -" raise ValueError('no support for shadow passwords')\n" -" cleartext = getpass.getpass()\n" -" return compare_hash(crypt.crypt(cleartext, cryptedpasswd), " -"cryptedpasswd)\n" -" else:\n" -" return True" -msgstr "" -"import pwd\n" -"import crypt\n" -"import getpass\n" -"from hmac import compare_digest as compare_hash\n" -"\n" -"def login():\n" -" username = input('Python login: ')\n" -" cryptedpasswd = pwd.getpwnam(username)[1]\n" -" if cryptedpasswd:\n" -" if cryptedpasswd == 'x' or cryptedpasswd == '*':\n" -" raise ValueError('no support for shadow passwords')\n" -" cleartext = getpass.getpass()\n" -" return compare_hash(crypt.crypt(cleartext, cryptedpasswd), " -"cryptedpasswd)\n" -" else:\n" -" return True" - -#: ../../library/crypt.rst:175 -msgid "" -"To generate a hash of a password using the strongest available method and " -"check it against the original::" -msgstr "" - -#: ../../library/crypt.rst:178 +#: ../../library/crypt.rst:19 msgid "" -"import crypt\n" -"from hmac import compare_digest as compare_hash\n" -"\n" -"hashed = crypt.crypt(plaintext)\n" -"if not compare_hash(hashed, crypt.crypt(plaintext, hashed)):\n" -" raise ValueError(\"hashed version doesn't validate against original\")" -msgstr "" -"import crypt\n" -"from hmac import compare_digest as compare_hash\n" -"\n" -"hashed = crypt.crypt(plaintext)\n" -"if not compare_hash(hashed, crypt.crypt(plaintext, hashed)):\n" -" raise ValueError(\"hashed version doesn't validate against original\")" - -#: ../../library/crypt.rst:15 ../../library/crypt.rst:33 -#: ../../library/crypt.rst:119 -msgid "crypt(3)" -msgstr "crypt(3)" - -#: ../../library/crypt.rst:15 -msgid "cipher" -msgstr "cipher" - -#: ../../library/crypt.rst:15 -msgid "DES" -msgstr "DES" +"The last version of Python that provided the :mod:`!crypt` module was " +"`Python 3.12 `_." +msgstr "" + +#~ msgid "**Source code:** :source:`Lib/crypt.py`" +#~ msgstr "**原始碼:**\\ :source:`Lib/crypt.py`" + +#~ msgid ":ref:`Availability `: Unix, not VxWorks." +#~ msgstr ":ref:`適用 `:Unix,非 VxWorks。" + +#~ msgid "" +#~ "This module does not work or is not available on WebAssembly platforms " +#~ "``wasm32-emscripten`` and ``wasm32-wasi``. See :ref:`wasm-availability` " +#~ "for more information." +#~ msgstr "" +#~ "此模組在 WebAssembly 平台 ``wasm32-emscripten`` 和 ``wasm32-wasi`` 上無法" +#~ "作用或無法使用。有關更多資訊,請參閱 :ref:`wasm-availability`。" + +#~ msgid "Hashing Methods" +#~ msgstr "雜湊方法" + +#~ msgid "Module Attributes" +#~ msgstr "模組屬性" + +#~ msgid "Module Functions" +#~ msgstr "模組函式" + +#~ msgid "The :mod:`crypt` module defines the following functions:" +#~ msgstr ":mod:`crypt` 模組定義了以下函式:" + +#~ msgid "Added the *rounds* parameter." +#~ msgstr "新增 *rounds* 參數。" + +#~ msgid "Examples" +#~ msgstr "範例" + +#~ msgid "" +#~ "import pwd\n" +#~ "import crypt\n" +#~ "import getpass\n" +#~ "from hmac import compare_digest as compare_hash\n" +#~ "\n" +#~ "def login():\n" +#~ " username = input('Python login: ')\n" +#~ " cryptedpasswd = pwd.getpwnam(username)[1]\n" +#~ " if cryptedpasswd:\n" +#~ " if cryptedpasswd == 'x' or cryptedpasswd == '*':\n" +#~ " raise ValueError('no support for shadow passwords')\n" +#~ " cleartext = getpass.getpass()\n" +#~ " return compare_hash(crypt.crypt(cleartext, cryptedpasswd), " +#~ "cryptedpasswd)\n" +#~ " else:\n" +#~ " return True" +#~ msgstr "" +#~ "import pwd\n" +#~ "import crypt\n" +#~ "import getpass\n" +#~ "from hmac import compare_digest as compare_hash\n" +#~ "\n" +#~ "def login():\n" +#~ " username = input('Python login: ')\n" +#~ " cryptedpasswd = pwd.getpwnam(username)[1]\n" +#~ " if cryptedpasswd:\n" +#~ " if cryptedpasswd == 'x' or cryptedpasswd == '*':\n" +#~ " raise ValueError('no support for shadow passwords')\n" +#~ " cleartext = getpass.getpass()\n" +#~ " return compare_hash(crypt.crypt(cleartext, cryptedpasswd), " +#~ "cryptedpasswd)\n" +#~ " else:\n" +#~ " return True" + +#~ msgid "" +#~ "import crypt\n" +#~ "from hmac import compare_digest as compare_hash\n" +#~ "\n" +#~ "hashed = crypt.crypt(plaintext)\n" +#~ "if not compare_hash(hashed, crypt.crypt(plaintext, hashed)):\n" +#~ " raise ValueError(\"hashed version doesn't validate against original\")" +#~ msgstr "" +#~ "import crypt\n" +#~ "from hmac import compare_digest as compare_hash\n" +#~ "\n" +#~ "hashed = crypt.crypt(plaintext)\n" +#~ "if not compare_hash(hashed, crypt.crypt(plaintext, hashed)):\n" +#~ " raise ValueError(\"hashed version doesn't validate against original\")" + +#~ msgid "crypt(3)" +#~ msgstr "crypt(3)" + +#~ msgid "cipher" +#~ msgstr "cipher" + +#~ msgid "DES" +#~ msgstr "DES" diff --git a/library/ctypes.po b/library/ctypes.po index 048c245976..b76d8972d9 100644 --- a/library/ctypes.po +++ b/library/ctypes.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-03-03 18:39+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-" @@ -83,18 +83,19 @@ msgstr "" #: ../../library/ctypes.rst:53 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::" +"C library containing most standard C functions, and uses the ``cdecl`` " +"calling convention::" msgstr "" #: ../../library/ctypes.rst:57 +#, fuzzy msgid "" ">>> from ctypes import *\n" -">>> print(windll.kernel32) \n" +">>> print(windll.kernel32)\n" "\n" -">>> print(cdll.msvcrt) \n" +">>> print(cdll.msvcrt)\n" "\n" -">>> libc = cdll.msvcrt \n" +">>> libc = cdll.msvcrt\n" ">>>" msgstr "" ">>> from ctypes import *\n" @@ -127,11 +128,12 @@ msgid "" msgstr "" #: ../../library/ctypes.rst:79 +#, fuzzy msgid "" -">>> cdll.LoadLibrary(\"libc.so.6\") \n" +">>> cdll.LoadLibrary(\"libc.so.6\")\n" "\n" -">>> libc = CDLL(\"libc.so.6\") \n" -">>> libc \n" +">>> libc = CDLL(\"libc.so.6\")\n" +">>> libc\n" "\n" ">>>" msgstr "" @@ -151,12 +153,13 @@ msgid "Functions are accessed as attributes of dll objects::" msgstr "" #: ../../library/ctypes.rst:96 +#, fuzzy msgid "" ">>> libc.printf\n" "<_FuncPtr object at 0x...>\n" -">>> print(windll.kernel32.GetModuleHandleA) \n" +">>> print(windll.kernel32.GetModuleHandleA)\n" "<_FuncPtr object at 0x...>\n" -">>> print(windll.kernel32.MyOwnFunction) \n" +">>> print(windll.kernel32.MyOwnFunction)\n" "Traceback (most recent call last):\n" " File \"\", line 1, in \n" " File \"ctypes.py\", line 239, in __getattr__\n" @@ -214,8 +217,9 @@ msgid "" msgstr "" #: ../../library/ctypes.rst:129 +#, fuzzy msgid "" -">>> getattr(cdll.msvcrt, \"??2@YAPAXI@Z\") \n" +">>> getattr(cdll.msvcrt, \"??2@YAPAXI@Z\")\n" "<_FuncPtr object at 0x...>\n" ">>>" msgstr "" @@ -231,10 +235,11 @@ msgid "" msgstr "" #: ../../library/ctypes.rst:136 +#, fuzzy msgid "" -">>> cdll.kernel32[1] \n" +">>> cdll.kernel32[1]\n" "<_FuncPtr object at 0x...>\n" -">>> cdll.kernel32[0] \n" +">>> cdll.kernel32[0]\n" "Traceback (most recent call last):\n" " File \"\", line 1, in \n" " File \"ctypes.py\", line 310, in __getitem__\n" @@ -264,8 +269,9 @@ msgid "" msgstr "" #: ../../library/ctypes.rst:155 +#, fuzzy msgid "" -">>> print(libc.rand()) \n" +">>> print(libc.rand())\n" "1804289383" msgstr "" ">>> print(libc.rand()) \n" @@ -279,8 +285,9 @@ msgid "" msgstr "" #: ../../library/ctypes.rst:161 +#, fuzzy msgid "" -">>> print(hex(windll.kernel32.GetModuleHandleA(None))) \n" +">>> print(hex(windll.kernel32.GetModuleHandleA(None)))\n" "0x1d000000\n" ">>>" msgstr "" @@ -295,15 +302,16 @@ msgid "" msgstr "" #: ../../library/ctypes.rst:168 +#, fuzzy msgid "" -">>> cdll.kernel32.GetModuleHandleA(None) \n" +">>> cdll.kernel32.GetModuleHandleA(None)\n" "Traceback (most recent call last):\n" " File \"\", line 1, in \n" "ValueError: Procedure probably called with not enough arguments (4 bytes " "missing)\n" ">>>\n" "\n" -">>> windll.msvcrt.printf(b\"spam\") \n" +">>> windll.msvcrt.printf(b\"spam\")\n" "Traceback (most recent call last):\n" " File \"\", line 1, in \n" "ValueError: Procedure probably called with too many arguments (4 bytes in " @@ -338,8 +346,9 @@ msgid "" msgstr "" #: ../../library/ctypes.rst:187 +#, fuzzy msgid "" -">>> windll.kernel32.GetModuleHandleA(32) \n" +">>> windll.kernel32.GetModuleHandleA(32)\n" "Traceback (most recent call last):\n" " File \"\", line 1, in \n" "OSError: exception: access violation reading 0x00000020\n" @@ -376,7 +385,7 @@ msgid "" "learn more about :mod:`ctypes` data types." msgstr "" -#: ../../library/ctypes.rst:212 ../../library/ctypes.rst:2203 +#: ../../library/ctypes.rst:212 ../../library/ctypes.rst:2242 msgid "Fundamental data types" msgstr "" @@ -667,7 +676,7 @@ 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 " "point to, *not the contents* of the memory block (of course not, because " -"Python bytes objects are immutable)::" +"Python string objects are immutable)::" msgstr "" #: ../../library/ctypes.rst:297 @@ -809,7 +818,7 @@ msgstr "" #: ../../library/ctypes.rst:386 msgid "" -"On those platforms it is required to specify the :attr:`~_FuncPtr.argtypes` " +"On those platforms it is required to specify the :attr:`~_CFuncPtr.argtypes` " "attribute for the regular, non-variadic, function arguments:" msgstr "" @@ -820,7 +829,7 @@ msgstr "libc.printf.argtypes = [ctypes.c_char_p]" #: ../../library/ctypes.rst:393 msgid "" "Because specifying the attribute does not inhibit portability it is advised " -"to always specify :attr:`~_FuncPtr.argtypes` for all variadic functions." +"to always specify :attr:`~_CFuncPtr.argtypes` for all variadic functions." msgstr "" #: ../../library/ctypes.rst:400 @@ -872,12 +881,12 @@ msgstr "" #: ../../library/ctypes.rst:428 msgid "" "It is possible to specify the required argument types of functions exported " -"from DLLs by setting the :attr:`~_FuncPtr.argtypes` attribute." +"from DLLs by setting the :attr:`~_CFuncPtr.argtypes` attribute." msgstr "" #: ../../library/ctypes.rst:431 msgid "" -":attr:`~_FuncPtr.argtypes` must be a sequence of C data types (the :func:`!" +":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 " "variable number and different types of parameters depending on the format " "string, on the other hand this is quite handy to experiment with this " @@ -931,7 +940,7 @@ msgstr "" 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 " -"able to use them in the :attr:`~_FuncPtr.argtypes` sequence. The :meth:" +"able to use them in the :attr:`~_CFuncPtr.argtypes` sequence. The :meth:" "`~_CData.from_param` class method receives the Python object passed to the " "function call, it should do a typecheck or whatever is needed to make sure " "this object is acceptable, and then return the object itself, its :attr:`!" @@ -948,7 +957,7 @@ msgstr "" #: ../../library/ctypes.rst:478 msgid "" "By default functions are assumed to return the C :c:expr:`int` type. Other " -"return types can be specified by setting the :attr:`~_FuncPtr.restype` " +"return types can be specified by setting the :attr:`~_CFuncPtr.restype` " "attribute of the function object." msgstr "" @@ -964,7 +973,7 @@ msgid ">>> libc.time.restype = c_time_t" msgstr ">>> libc.time.restype = c_time_t" #: ../../library/ctypes.rst:488 -msgid "The argument types can be specified using :attr:`~_FuncPtr.argtypes`::" +msgid "The argument types can be specified using :attr:`~_CFuncPtr.argtypes`::" msgstr "" #: ../../library/ctypes.rst:490 @@ -978,8 +987,9 @@ msgid "" msgstr "" #: ../../library/ctypes.rst:494 +#, fuzzy msgid "" -">>> print(libc.time(None)) \n" +">>> print(libc.time(None))\n" "1150640792" msgstr "" ">>> print(libc.time(None)) \n" @@ -992,9 +1002,10 @@ msgid "" msgstr "" #: ../../library/ctypes.rst:500 +#, fuzzy msgid "" ">>> strchr = libc.strchr\n" -">>> strchr(b\"abcdef\", ord(\"d\")) \n" +">>> strchr(b\"abcdef\", ord(\"d\"))\n" "8059983\n" ">>> strchr.restype = c_char_p # c_char_p is a pointer to a string\n" ">>> strchr(b\"abcdef\", ord(\"d\"))\n" @@ -1016,7 +1027,7 @@ msgstr "" #: ../../library/ctypes.rst:510 msgid "" "If you want to avoid the :func:`ord(\"x\") ` calls above, you can set " -"the :attr:`~_FuncPtr.argtypes` attribute, and the second argument will be " +"the :attr:`~_CFuncPtr.argtypes` attribute, and the second argument will be " "converted from a single character Python bytes object into a C char:" msgstr "" @@ -1053,26 +1064,27 @@ msgstr "" #: ../../library/ctypes.rst:529 msgid "" "You can also use a callable Python object (a function or a class for " -"example) as the :attr:`~_FuncPtr.restype` attribute, if the foreign function " -"returns an integer. The callable will be called with the *integer* the C " -"function returns, and the result of this call will be used as the result of " -"your function call. This is useful to check for error return values and " -"automatically raise an exception::" +"example) as the :attr:`~_CFuncPtr.restype` attribute, if the foreign " +"function returns an integer. The callable will be called with the *integer* " +"the C function returns, and the result of this call will be used as the " +"result of your function call. This is useful to check for error return " +"values and automatically raise an exception::" msgstr "" #: ../../library/ctypes.rst:535 +#, fuzzy msgid "" -">>> GetModuleHandle = windll.kernel32.GetModuleHandleA \n" +">>> GetModuleHandle = windll.kernel32.GetModuleHandleA\n" ">>> def ValidHandle(value):\n" "... if value == 0:\n" "... raise WinError()\n" "... return value\n" "...\n" ">>>\n" -">>> GetModuleHandle.restype = ValidHandle \n" -">>> GetModuleHandle(None) \n" +">>> GetModuleHandle.restype = ValidHandle\n" +">>> GetModuleHandle(None)\n" "486539264\n" -">>> GetModuleHandle(\"something silly\") \n" +">>> GetModuleHandle(\"something silly\")\n" "Traceback (most recent call last):\n" " File \"\", line 1, in \n" " File \"\", line 3, in ValidHandle\n" @@ -1107,7 +1119,7 @@ msgstr "" #: ../../library/ctypes.rst:557 msgid "" "Please note that a much more powerful error checking mechanism is available " -"through the :attr:`~_FuncPtr.errcheck` attribute; see the reference manual " +"through the :attr:`~_CFuncPtr.errcheck` attribute; see the reference manual " "for details." msgstr "" @@ -1311,7 +1323,7 @@ msgid "" "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 " +"specifying a :attr:`~Structure._align_` class attribute in the subclass " "definition." msgstr "" @@ -1665,7 +1677,7 @@ msgstr "" #: ../../library/ctypes.rst:861 msgid "" "Usually, ctypes does strict type checking. This means, if you have " -"``POINTER(c_int)`` in the :attr:`~_FuncPtr.argtypes` list of a function or " +"``POINTER(c_int)`` in the :attr:`~_CFuncPtr.argtypes` list of a function or " "as the type of a member field in a structure definition, only instances of " "exactly the same type are accepted. There are some exceptions to this rule, " "where ctypes accepts other objects. For example, you can pass compatible " @@ -1706,7 +1718,7 @@ msgstr "" #: ../../library/ctypes.rst:882 msgid "" "In addition, if a function argument is explicitly declared to be a pointer " -"type (such as ``POINTER(c_int)``) in :attr:`~_FuncPtr.argtypes`, an object " +"type (such as ``POINTER(c_int)``) in :attr:`~_CFuncPtr.argtypes`, an object " "of the pointed type (``c_int`` in this case) can be passed to the function. " "ctypes will apply the required :func:`byref` conversion in this case " "automatically." @@ -2008,8 +2020,9 @@ msgid "The result::" msgstr "結果為: ::" #: ../../library/ctypes.rst:1043 +#, fuzzy msgid "" -">>> qsort(ia, len(ia), sizeof(c_int), cmp_func) \n" +">>> qsort(ia, len(ia), sizeof(c_int), cmp_func)\n" "py_cmp_func 5 1\n" "py_cmp_func 33 99\n" "py_cmp_func 7 33\n" @@ -2030,13 +2043,14 @@ msgid "Now we can actually compare the two items and return a useful result::" msgstr "" #: ../../library/ctypes.rst:1053 +#, fuzzy msgid "" ">>> def py_cmp_func(a, b):\n" "... print(\"py_cmp_func\", a[0], b[0])\n" "... return a[0] - b[0]\n" "...\n" ">>>\n" -">>> qsort(ia, len(ia), sizeof(c_int), CMPFUNC(py_cmp_func)) \n" +">>> qsort(ia, len(ia), sizeof(c_int), CMPFUNC(py_cmp_func))\n" "py_cmp_func 5 1\n" "py_cmp_func 33 99\n" "py_cmp_func 7 33\n" @@ -2497,7 +2511,7 @@ msgid "" "If no library can be found, returns ``None``." msgstr "" -#: ../../library/ctypes.rst:1316 ../../library/ctypes.rst:1977 +#: ../../library/ctypes.rst:1316 ../../library/ctypes.rst:2002 msgid "The exact functionality is system dependent." msgstr "" @@ -2615,8 +2629,8 @@ msgid "" "determine which one is not found using Windows debugging and tracing tools." msgstr "" -#: ../../library/ctypes.rst:1388 ../../library/ctypes.rst:1411 -#: ../../library/ctypes.rst:1422 ../../library/ctypes.rst:1439 +#: ../../library/ctypes.rst:1388 ../../library/ctypes.rst:1413 +#: ../../library/ctypes.rst:1426 ../../library/ctypes.rst:1444 msgid "The *name* parameter can now be a :term:`path-like object`." msgstr "" @@ -2628,34 +2642,44 @@ msgstr "" #: ../../library/ctypes.rst:1398 msgid "" -"Windows only: Instances of this class represent loaded shared libraries, " -"functions in these libraries use the ``stdcall`` calling convention, and are " -"assumed to return the windows specific :class:`HRESULT` code. :class:" -"`HRESULT` values contain information specifying whether the function call " -"failed or succeeded, together with additional error code. If the return " -"value signals a failure, an :class:`OSError` is automatically raised." +"Instances of this class represent loaded shared libraries, functions in " +"these libraries use the ``stdcall`` calling convention, and are assumed to " +"return the windows specific :class:`HRESULT` code. :class:`HRESULT` values " +"contain information specifying whether the function call failed or " +"succeeded, together with additional error code. If the return value signals " +"a failure, an :class:`OSError` is automatically raised." +msgstr "" + +#: ../../library/ctypes.rst:1405 ../../library/ctypes.rst:1422 +#: ../../library/ctypes.rst:1566 ../../library/ctypes.rst:1574 +#: ../../library/ctypes.rst:1751 ../../library/ctypes.rst:1982 +#: ../../library/ctypes.rst:1991 ../../library/ctypes.rst:2016 +#: ../../library/ctypes.rst:2025 ../../library/ctypes.rst:2034 +#: ../../library/ctypes.rst:2049 ../../library/ctypes.rst:2106 +#: ../../library/ctypes.rst:2134 ../../library/ctypes.rst:2478 +msgid "Availability" msgstr "" -#: ../../library/ctypes.rst:1405 +#: ../../library/ctypes.rst:1407 msgid "" ":exc:`WindowsError` used to be raised, which is now an alias of :exc:" "`OSError`." msgstr "" -#: ../../library/ctypes.rst:1416 +#: ../../library/ctypes.rst:1418 msgid "" -"Windows only: 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." +"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:1424 +#: ../../library/ctypes.rst:1429 msgid "" "The Python :term:`global interpreter lock` is released before calling any " "function exported by these libraries, and reacquired afterwards." msgstr "" -#: ../../library/ctypes.rst:1430 +#: ../../library/ctypes.rst:1435 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 " @@ -2663,11 +2687,11 @@ msgid "" "set, a Python exception is raised." msgstr "" -#: ../../library/ctypes.rst:1435 +#: ../../library/ctypes.rst:1440 msgid "Thus, this is only useful to call Python C api functions directly." msgstr "" -#: ../../library/ctypes.rst:1441 +#: ../../library/ctypes.rst:1446 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 " @@ -2677,7 +2701,7 @@ msgid "" "the process, and to get a handle to it." msgstr "" -#: ../../library/ctypes.rst:1448 +#: ../../library/ctypes.rst:1453 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 " @@ -2685,7 +2709,7 @@ msgid "" "configurable." msgstr "" -#: ../../library/ctypes.rst:1453 +#: ../../library/ctypes.rst:1458 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:" @@ -2695,14 +2719,14 @@ msgid "" "private copy, the same happens immediately after the function call." msgstr "" -#: ../../library/ctypes.rst:1460 +#: ../../library/ctypes.rst:1465 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:1464 +#: ../../library/ctypes.rst:1469 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 :" @@ -2711,7 +2735,7 @@ msgid "" "private copy of the windows error code." msgstr "" -#: ../../library/ctypes.rst:1470 +#: ../../library/ctypes.rst:1475 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 " @@ -2721,29 +2745,29 @@ msgid "" "ensure the correct library and dependencies are loaded." msgstr "" -#: ../../library/ctypes.rst:1477 +#: ../../library/ctypes.rst:1482 msgid "Added *winmode* parameter." msgstr "新增 *winmode* 參數。" -#: ../../library/ctypes.rst:1484 +#: ../../library/ctypes.rst:1489 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:1491 +#: ../../library/ctypes.rst:1496 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:1498 +#: ../../library/ctypes.rst:1503 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:1501 +#: ../../library/ctypes.rst:1506 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 " @@ -2752,7 +2776,7 @@ msgid "" "other hand, accessing it through an index returns a new object each time::" msgstr "" -#: ../../library/ctypes.rst:1507 +#: ../../library/ctypes.rst:1512 msgid "" ">>> from ctypes import CDLL\n" ">>> libc = CDLL(\"libc.so.6\") # On Linux\n" @@ -2768,21 +2792,21 @@ msgstr "" ">>> libc['time'] == libc['time']\n" "False" -#: ../../library/ctypes.rst:1514 +#: ../../library/ctypes.rst:1519 msgid "" "The following public attributes are available, their name starts with an " "underscore to not clash with exported function names:" msgstr "" -#: ../../library/ctypes.rst:1520 +#: ../../library/ctypes.rst:1525 msgid "The system handle used to access the library." msgstr "" -#: ../../library/ctypes.rst:1525 +#: ../../library/ctypes.rst:1530 msgid "The name of the library passed in the constructor." msgstr "" -#: ../../library/ctypes.rst:1527 +#: ../../library/ctypes.rst:1532 msgid "" "Shared libraries can also be loaded by using one of the prefabricated " "objects, which are instances of the :class:`LibraryLoader` class, either by " @@ -2790,13 +2814,13 @@ msgid "" "library as attribute of the loader instance." msgstr "" -#: ../../library/ctypes.rst:1535 +#: ../../library/ctypes.rst:1540 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:1538 +#: ../../library/ctypes.rst:1543 msgid "" ":meth:`!__getattr__` has special behavior: It allows loading a shared " "library by accessing it as attribute of a library loader instance. The " @@ -2804,39 +2828,39 @@ msgid "" "each time." msgstr "" -#: ../../library/ctypes.rst:1544 +#: ../../library/ctypes.rst:1549 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:1548 +#: ../../library/ctypes.rst:1553 msgid "These prefabricated library loaders are available:" msgstr "" -#: ../../library/ctypes.rst:1553 +#: ../../library/ctypes.rst:1558 msgid "Creates :class:`CDLL` instances." msgstr "" -#: ../../library/ctypes.rst:1559 -msgid "Windows only: Creates :class:`WinDLL` instances." +#: ../../library/ctypes.rst:1564 +msgid "Creates :class:`WinDLL` instances." msgstr "" -#: ../../library/ctypes.rst:1565 -msgid "Windows only: Creates :class:`OleDLL` instances." +#: ../../library/ctypes.rst:1572 +msgid "Creates :class:`OleDLL` instances." msgstr "" -#: ../../library/ctypes.rst:1571 +#: ../../library/ctypes.rst:1580 msgid "Creates :class:`PyDLL` instances." msgstr "" -#: ../../library/ctypes.rst:1574 +#: ../../library/ctypes.rst:1583 msgid "" "For accessing the C Python api directly, a ready-to-use Python shared " "library object is available:" msgstr "" -#: ../../library/ctypes.rst:1580 +#: ../../library/ctypes.rst:1589 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:" @@ -2844,63 +2868,79 @@ msgid "" "correct :attr:`!restype` attribute to use these functions." msgstr "" -#: ../../library/ctypes.rst:1585 ../../library/ctypes.rst:1587 +#: ../../library/ctypes.rst:1594 ../../library/ctypes.rst:1596 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:1591 ../../library/ctypes.rst:1593 +#: ../../library/ctypes.rst:1600 ../../library/ctypes.rst:1602 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:1597 ../../library/ctypes.rst:1599 +#: ../../library/ctypes.rst:1606 ../../library/ctypes.rst:1608 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:1606 +#: ../../library/ctypes.rst:1615 msgid "Foreign functions" msgstr "" -#: ../../library/ctypes.rst:1608 +#: ../../library/ctypes.rst:1617 msgid "" "As explained in the previous section, foreign functions can be accessed as " "attributes of loaded shared libraries. The function objects created in this " "way by default accept any number of arguments, accept any ctypes data " "instances as arguments, and return the default result type specified by the " -"library loader. They are instances of a private class:" +"library loader." msgstr "" -#: ../../library/ctypes.rst:1617 +#: ../../library/ctypes.rst:1622 +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:1625 +msgid "" +">>> import ctypes\n" +">>> lib = ctypes.CDLL(None)\n" +">>> issubclass(lib._FuncPtr, ctypes._CFuncPtr)\n" +"True\n" +">>> lib._FuncPtr is ctypes._CFuncPtr\n" +"False" +msgstr "" + +#: ../../library/ctypes.rst:1636 msgid "Base class for C callable foreign functions." msgstr "" -#: ../../library/ctypes.rst:1619 +#: ../../library/ctypes.rst:1638 msgid "" "Instances of foreign functions are also C compatible data types; they " "represent C function pointers." msgstr "" -#: ../../library/ctypes.rst:1622 +#: ../../library/ctypes.rst:1641 msgid "" "This behavior can be customized by assigning to special attributes of the " "foreign function object." msgstr "" -#: ../../library/ctypes.rst:1627 +#: ../../library/ctypes.rst:1646 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:1630 +#: ../../library/ctypes.rst:1649 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 " @@ -2910,7 +2950,7 @@ msgid "" "callable to the :attr:`errcheck` attribute." msgstr "" -#: ../../library/ctypes.rst:1639 +#: ../../library/ctypes.rst:1658 msgid "" "Assign a tuple of ctypes types to specify the argument types that the " "function accepts. Functions using the ``stdcall`` calling convention can " @@ -2919,7 +2959,7 @@ msgid "" "unspecified arguments as well." msgstr "" -#: ../../library/ctypes.rst:1645 +#: ../../library/ctypes.rst:1664 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` " @@ -2929,7 +2969,7 @@ msgid "" "object using ctypes conversion rules." msgstr "" -#: ../../library/ctypes.rst:1652 +#: ../../library/ctypes.rst:1671 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 " @@ -2937,44 +2977,44 @@ msgid "" "defining adapters that can adapt custom objects as function parameters." msgstr "" -#: ../../library/ctypes.rst:1659 +#: ../../library/ctypes.rst:1678 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:1666 +#: ../../library/ctypes.rst:1685 msgid "" "*result* is what the foreign function returns, as specified by the :attr:`!" "restype` attribute." msgstr "" -#: ../../library/ctypes.rst:1669 +#: ../../library/ctypes.rst:1688 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:1673 +#: ../../library/ctypes.rst:1692 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:1677 +#: ../../library/ctypes.rst:1696 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:1684 +#: ../../library/ctypes.rst:1703 msgid "" "This exception is raised when a foreign function call cannot convert one of " "the passed arguments." msgstr "" -#: ../../library/ctypes.rst:1688 ../../library/ctypes.rst:1690 +#: ../../library/ctypes.rst:1707 ../../library/ctypes.rst:1709 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 " @@ -2983,18 +3023,18 @@ msgid "" "hook to replace the exception with its own." msgstr "" -#: ../../library/ctypes.rst:1696 ../../library/ctypes.rst:1698 +#: ../../library/ctypes.rst:1715 ../../library/ctypes.rst:1717 msgid "" "Some ways to invoke foreign function calls may raise an auditing event " "``ctypes.call_function`` with arguments ``function pointer`` and " "``arguments``." msgstr "" -#: ../../library/ctypes.rst:1704 +#: ../../library/ctypes.rst:1723 msgid "Function prototypes" msgstr "" -#: ../../library/ctypes.rst:1706 +#: ../../library/ctypes.rst:1725 msgid "" "Foreign functions can also be created by instantiating function prototypes. " "Function prototypes are similar to function prototypes in C; they describe a " @@ -3005,7 +3045,7 @@ msgid "" "``@wrapper`` syntax. See :ref:`ctypes-callback-functions` for examples." msgstr "" -#: ../../library/ctypes.rst:1717 +#: ../../library/ctypes.rst:1736 msgid "" "The returned function prototype creates functions that use the standard C " "calling convention. The function will release the GIL during the call. If " @@ -3014,37 +3054,37 @@ msgid "" "after the call; *use_last_error* does the same for the Windows error code." msgstr "" -#: ../../library/ctypes.rst:1727 +#: ../../library/ctypes.rst:1746 msgid "" -"Windows only: 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." +"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:1735 +#: ../../library/ctypes.rst:1756 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:1738 +#: ../../library/ctypes.rst:1759 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:1745 +#: ../../library/ctypes.rst:1766 msgid "" "Returns a foreign function at the specified address which must be an integer." msgstr "" -#: ../../library/ctypes.rst:1752 +#: ../../library/ctypes.rst:1773 msgid "" "Create a C callable function (a callback function) from a Python *callable*." msgstr "" -#: ../../library/ctypes.rst:1759 +#: ../../library/ctypes.rst:1780 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 " @@ -3052,7 +3092,7 @@ msgid "" "small integer. The second item is the shared library instance." msgstr "" -#: ../../library/ctypes.rst:1769 +#: ../../library/ctypes.rst:1790 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* " @@ -3060,79 +3100,79 @@ msgid "" "identifier which is used in extended error reporting." msgstr "" -#: ../../library/ctypes.rst:1774 +#: ../../library/ctypes.rst:1795 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:1778 +#: ../../library/ctypes.rst:1799 msgid "" "The optional *paramflags* parameter creates foreign function wrappers with " "much more functionality than the features described above." msgstr "" -#: ../../library/ctypes.rst:1781 +#: ../../library/ctypes.rst:1802 msgid "" -"*paramflags* must be a tuple of the same length as :attr:`~_FuncPtr." +"*paramflags* must be a tuple of the same length as :attr:`~_CFuncPtr." "argtypes`." msgstr "" -#: ../../library/ctypes.rst:1783 +#: ../../library/ctypes.rst:1804 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:1786 +#: ../../library/ctypes.rst:1807 msgid "" "The first item is an integer containing a combination of direction flags for " "the parameter:" msgstr "" -#: ../../library/ctypes.rst:1789 +#: ../../library/ctypes.rst:1810 msgid "1" msgstr "1" -#: ../../library/ctypes.rst:1790 +#: ../../library/ctypes.rst:1811 msgid "Specifies an input parameter to the function." msgstr "" -#: ../../library/ctypes.rst:1792 +#: ../../library/ctypes.rst:1813 msgid "2" msgstr "2" -#: ../../library/ctypes.rst:1793 +#: ../../library/ctypes.rst:1814 msgid "Output parameter. The foreign function fills in a value." msgstr "" -#: ../../library/ctypes.rst:1795 +#: ../../library/ctypes.rst:1816 msgid "4" msgstr "4" -#: ../../library/ctypes.rst:1796 +#: ../../library/ctypes.rst:1817 msgid "Input parameter which defaults to the integer zero." msgstr "" -#: ../../library/ctypes.rst:1798 +#: ../../library/ctypes.rst:1819 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:1801 +#: ../../library/ctypes.rst:1822 msgid "The optional third item is the default value for this parameter." msgstr "" -#: ../../library/ctypes.rst:1804 +#: ../../library/ctypes.rst:1825 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:1808 +#: ../../library/ctypes.rst:1829 msgid "" "WINUSERAPI int WINAPI\n" "MessageBoxW(\n" @@ -3148,11 +3188,11 @@ msgstr "" " LPCWSTR lpCaption,\n" " UINT uType);" -#: ../../library/ctypes.rst:1815 ../../library/ctypes.rst:1838 +#: ../../library/ctypes.rst:1836 ../../library/ctypes.rst:1859 msgid "Here is the wrapping with :mod:`ctypes`::" msgstr "" -#: ../../library/ctypes.rst:1817 +#: ../../library/ctypes.rst:1838 msgid "" ">>> from ctypes import c_int, WINFUNCTYPE, windll\n" ">>> from ctypes.wintypes import HWND, LPCWSTR, UINT\n" @@ -3168,11 +3208,11 @@ msgstr "" "\"Hello from ctypes\"), (1, \"flags\", 0)\n" ">>> MessageBox = prototype((\"MessageBoxW\", windll.user32), paramflags)" -#: ../../library/ctypes.rst:1823 +#: ../../library/ctypes.rst:1844 msgid "The ``MessageBox`` foreign function can now be called in these ways::" msgstr "" -#: ../../library/ctypes.rst:1825 +#: ../../library/ctypes.rst:1846 msgid "" ">>> MessageBox()\n" ">>> MessageBox(text=\"Spam, spam, spam\")\n" @@ -3182,7 +3222,7 @@ msgstr "" ">>> MessageBox(text=\"Spam, spam, spam\")\n" ">>> MessageBox(flags=2, text=\"foo bar\")" -#: ../../library/ctypes.rst:1829 +#: ../../library/ctypes.rst:1850 msgid "" "A second example demonstrates output parameters. The win32 " "``GetWindowRect`` function retrieves the dimensions of a specified window by " @@ -3190,7 +3230,7 @@ msgid "" "the C declaration::" msgstr "" -#: ../../library/ctypes.rst:1833 +#: ../../library/ctypes.rst:1854 msgid "" "WINUSERAPI BOOL WINAPI\n" "GetWindowRect(\n" @@ -3202,7 +3242,7 @@ msgstr "" " HWND hWnd,\n" " LPRECT lpRect);" -#: ../../library/ctypes.rst:1840 +#: ../../library/ctypes.rst:1861 msgid "" ">>> from ctypes import POINTER, WINFUNCTYPE, windll, WinError\n" ">>> from ctypes.wintypes import BOOL, HWND, RECT\n" @@ -3220,7 +3260,7 @@ msgstr "" "paramflags)\n" ">>>" -#: ../../library/ctypes.rst:1847 +#: ../../library/ctypes.rst:1868 msgid "" "Functions with output parameters will automatically return the output " "parameter value if there is a single one, or a tuple containing the output " @@ -3228,16 +3268,16 @@ msgid "" "now returns a RECT instance, when called." msgstr "" -#: ../../library/ctypes.rst:1852 +#: ../../library/ctypes.rst:1873 msgid "" -"Output parameters can be combined with the :attr:`~_FuncPtr.errcheck` " +"Output parameters can be combined with the :attr:`~_CFuncPtr.errcheck` " "protocol to do further output processing and error checking. The win32 " "``GetWindowRect`` api function returns a ``BOOL`` to signal success or " "failure, so this function could do the error checking, and raises an " "exception when the api call failed::" msgstr "" -#: ../../library/ctypes.rst:1857 +#: ../../library/ctypes.rst:1878 msgid "" ">>> def errcheck(result, func, args):\n" "... if not result:\n" @@ -3255,16 +3295,16 @@ msgstr "" ">>> GetWindowRect.errcheck = errcheck\n" ">>>" -#: ../../library/ctypes.rst:1865 +#: ../../library/ctypes.rst:1886 msgid "" -"If the :attr:`~_FuncPtr.errcheck` function returns the argument tuple it " +"If the :attr:`~_CFuncPtr.errcheck` function returns the argument tuple it " "receives unchanged, :mod:`ctypes` continues the normal processing it does on " "the output parameters. If you want to return a tuple of window coordinates " "instead of a ``RECT`` instance, you can retrieve the fields in the function " "and return them instead, the normal processing will no longer take place::" msgstr "" -#: ../../library/ctypes.rst:1871 +#: ../../library/ctypes.rst:1892 msgid "" ">>> def errcheck(result, func, args):\n" "... if not result:\n" @@ -3284,17 +3324,17 @@ msgstr "" ">>> GetWindowRect.errcheck = errcheck\n" ">>>" -#: ../../library/ctypes.rst:1884 +#: ../../library/ctypes.rst:1905 msgid "Utility functions" msgstr "" -#: ../../library/ctypes.rst:1888 +#: ../../library/ctypes.rst:1909 msgid "" "Returns the address of the memory buffer as integer. *obj* must be an " "instance of a ctypes type." msgstr "" -#: ../../library/ctypes.rst:1891 +#: ../../library/ctypes.rst:1912 msgid "" "Raises an :ref:`auditing event ` ``ctypes.addressof`` with " "argument ``obj``." @@ -3302,34 +3342,34 @@ msgstr "" "引發一個附帶引數 ``obj`` 的\\ :ref:`稽核事件 ` ``ctypes." "addressof``。" -#: ../../library/ctypes.rst:1896 +#: ../../library/ctypes.rst:1917 msgid "" "Returns the alignment requirements of a ctypes type. *obj_or_type* must be a " "ctypes type or instance." msgstr "" -#: ../../library/ctypes.rst:1902 +#: ../../library/ctypes.rst:1923 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:1906 +#: ../../library/ctypes.rst:1927 msgid "``byref(obj, offset)`` corresponds to this C code::" msgstr "" -#: ../../library/ctypes.rst:1908 +#: ../../library/ctypes.rst:1929 msgid "(((char *)&obj) + offset)" msgstr "(((char *)&obj) + offset)" -#: ../../library/ctypes.rst:1910 +#: ../../library/ctypes.rst:1931 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:1916 +#: ../../library/ctypes.rst:1937 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* " @@ -3337,19 +3377,19 @@ msgid "" "as a pointer." msgstr "" -#: ../../library/ctypes.rst:1924 +#: ../../library/ctypes.rst:1945 msgid "" "This function creates a mutable character buffer. The returned object is a " "ctypes array of :class:`c_char`." msgstr "" -#: ../../library/ctypes.rst:1927 +#: ../../library/ctypes.rst:1948 msgid "" "*init_or_size* must be an integer which specifies the size of the array, or " "a bytes object which will be used to initialize the array items." msgstr "" -#: ../../library/ctypes.rst:1930 +#: ../../library/ctypes.rst:1951 msgid "" "If a bytes object is specified as first argument, the buffer is made one " "item larger than its length so that the last element in the array is a NUL " @@ -3358,7 +3398,7 @@ msgid "" "not be used." msgstr "" -#: ../../library/ctypes.rst:1935 +#: ../../library/ctypes.rst:1956 msgid "" "Raises an :ref:`auditing event ` ``ctypes.create_string_buffer`` " "with arguments ``init``, ``size``." @@ -3366,19 +3406,19 @@ msgstr "" "引發一個附帶引數 ``init`` 與 ``size`` 的\\ :ref:`稽核事件 ` " "``ctypes.create_string_buffer``。" -#: ../../library/ctypes.rst:1940 +#: ../../library/ctypes.rst:1961 msgid "" "This function creates a mutable unicode character buffer. The returned " "object is a ctypes array of :class:`c_wchar`." msgstr "" -#: ../../library/ctypes.rst:1943 +#: ../../library/ctypes.rst:1964 msgid "" "*init_or_size* must be an integer which specifies the size of the array, or " "a string which will be used to initialize the array items." msgstr "" -#: ../../library/ctypes.rst:1946 +#: ../../library/ctypes.rst:1967 msgid "" "If a string is specified as first argument, the buffer is made one item " "larger than the length of the string so that the last element in the array " @@ -3387,7 +3427,7 @@ msgid "" "should not be used." msgstr "" -#: ../../library/ctypes.rst:1952 +#: ../../library/ctypes.rst:1973 msgid "" "Raises an :ref:`auditing event ` ``ctypes.create_unicode_buffer`` " "with arguments ``init``, ``size``." @@ -3395,21 +3435,21 @@ msgstr "" "引發一個附帶引數 ``init`` 與 ``size`` 的\\ :ref:`稽核事件 ` " "``ctypes.create_unicode_buffer``。" -#: ../../library/ctypes.rst:1957 +#: ../../library/ctypes.rst:1978 msgid "" -"Windows only: 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." +"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:1964 +#: ../../library/ctypes.rst:1987 msgid "" -"Windows only: 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." +"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:1972 +#: ../../library/ctypes.rst:1997 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 " @@ -3417,94 +3457,94 @@ msgid "" "If no library can be found, returns ``None``." msgstr "" -#: ../../library/ctypes.rst:1983 +#: ../../library/ctypes.rst:2008 msgid "" -"Windows only: return 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." +"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:1987 +#: ../../library/ctypes.rst:2012 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:1994 +#: ../../library/ctypes.rst:2021 msgid "" -"Windows only: 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." +"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." msgstr "" -#: ../../library/ctypes.rst:2001 +#: ../../library/ctypes.rst:2030 msgid "" -"Windows only: 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." +"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:2007 +#: ../../library/ctypes.rst:2039 msgid "" "Returns the current value of the ctypes-private copy of the system :data:" "`errno` variable in the calling thread." msgstr "" -#: ../../library/ctypes.rst:2010 +#: ../../library/ctypes.rst:2042 msgid "" "Raises an :ref:`auditing event ` ``ctypes.get_errno`` with no " "arguments." msgstr "" "引發一個不附帶引數的\\ :ref:`稽核事件 ` ``ctypes.get_errno``。" -#: ../../library/ctypes.rst:2014 +#: ../../library/ctypes.rst:2046 msgid "" -"Windows only: returns the current value of the ctypes-private copy of the " -"system :data:`!LastError` variable in the calling thread." +"Returns the current value of the ctypes-private copy of the system :data:`!" +"LastError` variable in the calling thread." msgstr "" -#: ../../library/ctypes.rst:2017 +#: ../../library/ctypes.rst:2051 msgid "" "Raises an :ref:`auditing event ` ``ctypes.get_last_error`` with no " "arguments." msgstr "" "引發一個不附帶引數的\\ :ref:`稽核事件 ` ``ctypes.get_last_error``。" -#: ../../library/ctypes.rst:2021 +#: ../../library/ctypes.rst:2056 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:2028 +#: ../../library/ctypes.rst:2063 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:2035 +#: ../../library/ctypes.rst:2070 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." msgstr "" -#: ../../library/ctypes.rst:2042 +#: ../../library/ctypes.rst:2077 msgid "" "Create a new pointer instance, pointing to *obj*. The returned object is of " "the type ``POINTER(type(obj))``." msgstr "" -#: ../../library/ctypes.rst:2045 +#: ../../library/ctypes.rst:2080 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:2051 +#: ../../library/ctypes.rst:2086 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 " @@ -3512,13 +3552,13 @@ msgid "" "but it is possible to enlarge the buffer." msgstr "" -#: ../../library/ctypes.rst:2059 +#: ../../library/ctypes.rst:2094 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:2062 +#: ../../library/ctypes.rst:2097 msgid "" "Raises an :ref:`auditing event ` ``ctypes.set_errno`` with " "argument ``errno``." @@ -3526,14 +3566,14 @@ msgstr "" "引發一個附帶引數 ``errno`` 的\\ :ref:`稽核事件 ` ``ctypes." "set_errno``。" -#: ../../library/ctypes.rst:2067 +#: ../../library/ctypes.rst:2102 msgid "" -"Windows only: set 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." +"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:2071 +#: ../../library/ctypes.rst:2108 msgid "" "Raises an :ref:`auditing event ` ``ctypes.set_last_error`` with " "argument ``error``." @@ -3541,19 +3581,19 @@ msgstr "" "引發一個附帶引數 ``error`` 的\\ :ref:`稽核事件 ` ``ctypes." "set_last_error``。" -#: ../../library/ctypes.rst:2076 +#: ../../library/ctypes.rst:2113 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:2082 +#: ../../library/ctypes.rst:2119 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:2086 +#: ../../library/ctypes.rst:2123 msgid "" "Raises an :ref:`auditing event ` ``ctypes.string_at`` with " "arguments ``ptr``, ``size``." @@ -3561,29 +3601,28 @@ msgstr "" "引發一個附帶引數 ``ptr``、``size`` 的\\ :ref:`稽核事件 ` ``ctypes." "string_at``。" -#: ../../library/ctypes.rst:2091 +#: ../../library/ctypes.rst:2128 msgid "" -"Windows only: 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." +"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." msgstr "" -#: ../../library/ctypes.rst:2097 +#: ../../library/ctypes.rst:2136 msgid "" "An instance of :exc:`WindowsError` used to be created, which is now an alias " "of :exc:`OSError`." msgstr "" -#: ../../library/ctypes.rst:2104 +#: ../../library/ctypes.rst:2143 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:2109 +#: ../../library/ctypes.rst:2148 msgid "" "Raises an :ref:`auditing event ` ``ctypes.wstring_at`` with " "arguments ``ptr``, ``size``." @@ -3591,11 +3630,11 @@ msgstr "" "引發一個附帶引數 ``ptr``、``size`` 的\\ :ref:`稽核事件 ` ``ctypes." "wstring_at``。" -#: ../../library/ctypes.rst:2115 +#: ../../library/ctypes.rst:2154 msgid "Data types" msgstr "" -#: ../../library/ctypes.rst:2120 +#: ../../library/ctypes.rst:2159 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 " @@ -3605,13 +3644,13 @@ msgid "" "alive in case the memory block contains pointers." msgstr "" -#: ../../library/ctypes.rst:2127 +#: ../../library/ctypes.rst:2166 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:2132 +#: ../../library/ctypes.rst:2171 msgid "" "This method returns a ctypes instance that shares the buffer of the *source* " "object. The *source* object must support the writeable buffer interface. " @@ -3620,7 +3659,7 @@ msgid "" "exc:`ValueError` is raised." msgstr "" -#: ../../library/ctypes.rst:2138 ../../library/ctypes.rst:2148 +#: ../../library/ctypes.rst:2177 ../../library/ctypes.rst:2187 msgid "" "Raises an :ref:`auditing event ` ``ctypes.cdata/buffer`` with " "arguments ``pointer``, ``size``, ``offset``." @@ -3628,7 +3667,7 @@ msgstr "" "引發一個附帶引數 ``pointer``、``size``、``offset`` 的\\ :ref:`稽核事件 " "` ``ctypes.cdata/buffer``。" -#: ../../library/ctypes.rst:2142 +#: ../../library/ctypes.rst:2181 msgid "" "This method creates a ctypes instance, copying the buffer from the *source* " "object buffer which must be readable. The optional *offset* parameter " @@ -3636,45 +3675,45 @@ msgid "" "If the source buffer is not large enough a :exc:`ValueError` is raised." msgstr "" -#: ../../library/ctypes.rst:2152 +#: ../../library/ctypes.rst:2191 msgid "" "This method returns a ctypes type instance using the memory specified by " "*address* which must be an integer." msgstr "" -#: ../../library/ctypes.rst:2155 ../../library/ctypes.rst:2157 +#: ../../library/ctypes.rst:2194 ../../library/ctypes.rst:2196 msgid "" "This method, and others that indirectly call this method, raises an :ref:" "`auditing event ` ``ctypes.cdata`` with argument ``address``." msgstr "" -#: ../../library/ctypes.rst:2163 +#: ../../library/ctypes.rst:2202 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 " -"foreign function's :attr:`~_FuncPtr.argtypes` tuple; it must return an " +"foreign function's :attr:`~_CFuncPtr.argtypes` tuple; it must return an " "object that can be used as a function call parameter." msgstr "" -#: ../../library/ctypes.rst:2168 +#: ../../library/ctypes.rst:2207 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:2174 +#: ../../library/ctypes.rst:2213 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:2178 +#: ../../library/ctypes.rst:2217 msgid "Common instance variables of ctypes data types:" msgstr "" -#: ../../library/ctypes.rst:2182 +#: ../../library/ctypes.rst:2221 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:" @@ -3682,13 +3721,13 @@ msgid "" "block." msgstr "" -#: ../../library/ctypes.rst:2189 +#: ../../library/ctypes.rst:2228 msgid "" "This read-only variable is true when the ctypes data instance has allocated " "the memory block itself, false otherwise." msgstr "" -#: ../../library/ctypes.rst:2194 +#: ../../library/ctypes.rst:2233 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. " @@ -3696,7 +3735,7 @@ msgid "" "dictionary." msgstr "" -#: ../../library/ctypes.rst:2207 +#: ../../library/ctypes.rst:2246 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 " @@ -3705,11 +3744,11 @@ msgid "" "types that are not and do not contain pointers can now be pickled." msgstr "" -#: ../../library/ctypes.rst:2213 +#: ../../library/ctypes.rst:2252 msgid "Instances have a single attribute:" msgstr "" -#: ../../library/ctypes.rst:2217 +#: ../../library/ctypes.rst:2256 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 " @@ -3717,7 +3756,7 @@ msgid "" "bytes object or string." msgstr "" -#: ../../library/ctypes.rst:2222 +#: ../../library/ctypes.rst:2261 msgid "" "When the ``value`` attribute is retrieved from a ctypes instance, usually a " "new object is returned each time. :mod:`ctypes` does *not* implement " @@ -3725,17 +3764,17 @@ msgid "" "true for all other ctypes object instances." msgstr "" -#: ../../library/ctypes.rst:2228 +#: ../../library/ctypes.rst:2267 msgid "" "Fundamental data types, when returned as foreign function call results, or, " "for example, by retrieving structure field members or array items, are " "transparently converted to native Python types. In other words, if a " -"foreign function has a :attr:`~_FuncPtr.restype` of :class:`c_char_p`, you " +"foreign function has a :attr:`~_CFuncPtr.restype` of :class:`c_char_p`, you " "will always receive a Python bytes object, *not* a :class:`c_char_p` " "instance." msgstr "" -#: ../../library/ctypes.rst:2236 +#: ../../library/ctypes.rst:2275 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 " @@ -3743,25 +3782,25 @@ msgid "" "you can get the value of the pointer by accessing the ``value`` attribute." msgstr "" -#: ../../library/ctypes.rst:2241 +#: ../../library/ctypes.rst:2280 msgid "These are the fundamental ctypes data types:" msgstr "" -#: ../../library/ctypes.rst:2245 +#: ../../library/ctypes.rst:2284 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:2252 +#: ../../library/ctypes.rst:2291 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:2259 +#: ../../library/ctypes.rst:2298 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 " @@ -3769,182 +3808,182 @@ msgid "" "integer address, or a bytes object." msgstr "" -#: ../../library/ctypes.rst:2267 +#: ../../library/ctypes.rst:2306 msgid "" "Represents the C :c:expr:`double` datatype. The constructor accepts an " "optional float initializer." msgstr "" -#: ../../library/ctypes.rst:2273 +#: ../../library/ctypes.rst:2312 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:2279 +#: ../../library/ctypes.rst:2318 msgid "" "Represents the C :c:expr:`float` datatype. The constructor accepts an " "optional float initializer." msgstr "" -#: ../../library/ctypes.rst:2285 +#: ../../library/ctypes.rst:2324 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:2292 +#: ../../library/ctypes.rst:2331 msgid "" "Represents the C 8-bit :c:expr:`signed int` datatype. Usually an alias for :" "class:`c_byte`." msgstr "" -#: ../../library/ctypes.rst:2298 +#: ../../library/ctypes.rst:2337 msgid "" "Represents the C 16-bit :c:expr:`signed int` datatype. Usually an alias " "for :class:`c_short`." msgstr "" -#: ../../library/ctypes.rst:2304 +#: ../../library/ctypes.rst:2343 msgid "" "Represents the C 32-bit :c:expr:`signed int` datatype. Usually an alias " "for :class:`c_int`." msgstr "" -#: ../../library/ctypes.rst:2310 +#: ../../library/ctypes.rst:2349 msgid "" "Represents the C 64-bit :c:expr:`signed int` datatype. Usually an alias " "for :class:`c_longlong`." msgstr "" -#: ../../library/ctypes.rst:2316 +#: ../../library/ctypes.rst:2355 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:2322 +#: ../../library/ctypes.rst:2361 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:2328 +#: ../../library/ctypes.rst:2367 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:2334 +#: ../../library/ctypes.rst:2373 msgid "Represents the C :c:type:`size_t` datatype." msgstr "" -#: ../../library/ctypes.rst:2339 +#: ../../library/ctypes.rst:2378 msgid "Represents the C :c:type:`ssize_t` datatype." msgstr "" -#: ../../library/ctypes.rst:2346 +#: ../../library/ctypes.rst:2385 msgid "Represents the C :c:type:`time_t` datatype." msgstr "" -#: ../../library/ctypes.rst:2353 +#: ../../library/ctypes.rst:2392 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:2360 +#: ../../library/ctypes.rst:2399 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:2367 +#: ../../library/ctypes.rst:2406 msgid "" "Represents the C 8-bit :c:expr:`unsigned int` datatype. Usually an alias " "for :class:`c_ubyte`." msgstr "" -#: ../../library/ctypes.rst:2373 +#: ../../library/ctypes.rst:2412 msgid "" "Represents the C 16-bit :c:expr:`unsigned int` datatype. Usually an alias " "for :class:`c_ushort`." msgstr "" -#: ../../library/ctypes.rst:2379 +#: ../../library/ctypes.rst:2418 msgid "" "Represents the C 32-bit :c:expr:`unsigned int` datatype. Usually an alias " "for :class:`c_uint`." msgstr "" -#: ../../library/ctypes.rst:2385 +#: ../../library/ctypes.rst:2424 msgid "" "Represents the C 64-bit :c:expr:`unsigned int` datatype. Usually an alias " "for :class:`c_ulonglong`." msgstr "" -#: ../../library/ctypes.rst:2391 +#: ../../library/ctypes.rst:2430 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:2397 +#: ../../library/ctypes.rst:2436 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:2403 +#: ../../library/ctypes.rst:2442 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:2409 +#: ../../library/ctypes.rst:2448 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:2415 +#: ../../library/ctypes.rst:2454 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:2422 +#: ../../library/ctypes.rst:2461 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:2429 +#: ../../library/ctypes.rst:2468 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:2436 +#: ../../library/ctypes.rst:2475 msgid "" -"Windows only: Represents a :c:type:`!HRESULT` value, which contains success " -"or error information for a function or method call." +"Represents a :c:type:`!HRESULT` value, which contains success or error " +"information for a function or method call." msgstr "" -#: ../../library/ctypes.rst:2442 +#: ../../library/ctypes.rst:2483 msgid "" "Represents the C :c:expr:`PyObject *` datatype. Calling this without an " "argument creates a ``NULL`` :c:expr:`PyObject *` pointer." msgstr "" -#: ../../library/ctypes.rst:2445 +#: ../../library/ctypes.rst:2486 msgid "" "The :mod:`!ctypes.wintypes` module provides quite some other Windows " "specific data types, for example :c:type:`!HWND`, :c:type:`!WPARAM`, or :c:" @@ -3952,41 +3991,41 @@ msgid "" "are also defined." msgstr "" -#: ../../library/ctypes.rst:2453 +#: ../../library/ctypes.rst:2494 msgid "Structured data types" msgstr "" -#: ../../library/ctypes.rst:2458 +#: ../../library/ctypes.rst:2499 msgid "Abstract base class for unions in native byte order." msgstr "" -#: ../../library/ctypes.rst:2463 +#: ../../library/ctypes.rst:2504 msgid "Abstract base class for unions in *big endian* byte order." msgstr "" -#: ../../library/ctypes.rst:2469 +#: ../../library/ctypes.rst:2510 msgid "Abstract base class for unions in *little endian* byte order." msgstr "" -#: ../../library/ctypes.rst:2475 +#: ../../library/ctypes.rst:2516 msgid "Abstract base class for structures in *big endian* byte order." msgstr "" -#: ../../library/ctypes.rst:2480 +#: ../../library/ctypes.rst:2521 msgid "Abstract base class for structures in *little endian* byte order." msgstr "" -#: ../../library/ctypes.rst:2482 +#: ../../library/ctypes.rst:2523 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:2488 +#: ../../library/ctypes.rst:2529 msgid "Abstract base class for structures in *native* byte order." msgstr "" -#: ../../library/ctypes.rst:2490 +#: ../../library/ctypes.rst:2531 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:" @@ -3994,34 +4033,34 @@ msgid "" "the fields by direct attribute accesses. These are the" msgstr "" -#: ../../library/ctypes.rst:2498 +#: ../../library/ctypes.rst:2539 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:2502 +#: ../../library/ctypes.rst:2543 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:2506 +#: ../../library/ctypes.rst:2547 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:2509 +#: ../../library/ctypes.rst:2550 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:2513 +#: ../../library/ctypes.rst:2554 msgid "" "class List(Structure):\n" " pass\n" @@ -4035,7 +4074,7 @@ msgstr "" " ...\n" " ]" -#: ../../library/ctypes.rst:2519 +#: ../../library/ctypes.rst:2560 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, " @@ -4043,14 +4082,14 @@ msgid "" "raise an AttributeError." msgstr "" -#: ../../library/ctypes.rst:2524 +#: ../../library/ctypes.rst:2565 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." msgstr "" -#: ../../library/ctypes.rst:2531 +#: ../../library/ctypes.rst:2572 msgid "" "An optional small integer that allows overriding the alignment of structure " "fields in the instance. :attr:`_pack_` must already be defined when :attr:" @@ -4058,21 +4097,21 @@ msgid "" "attribute to 0 is the same as not setting it at all." msgstr "" -#: ../../library/ctypes.rst:2539 +#: ../../library/ctypes.rst:2580 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." msgstr "" -#: ../../library/ctypes.rst:2545 +#: ../../library/ctypes.rst:2588 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:2549 +#: ../../library/ctypes.rst:2592 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 " @@ -4080,11 +4119,11 @@ msgid "" "structure or union field." msgstr "" -#: ../../library/ctypes.rst:2554 +#: ../../library/ctypes.rst:2597 msgid "Here is an example type (Windows)::" msgstr "" -#: ../../library/ctypes.rst:2556 +#: ../../library/ctypes.rst:2599 msgid "" "class _U(Union):\n" " _fields_ = [(\"lptdesc\", POINTER(TYPEDESC)),\n" @@ -4106,7 +4145,7 @@ msgstr "" " _fields_ = [(\"u\", _U),\n" " (\"vt\", VARTYPE)]" -#: ../../library/ctypes.rst:2567 +#: ../../library/ctypes.rst:2610 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 " @@ -4116,7 +4155,7 @@ msgid "" "temporary union instance::" msgstr "" -#: ../../library/ctypes.rst:2574 +#: ../../library/ctypes.rst:2617 msgid "" "td = TYPEDESC()\n" "td.vt = VT_PTR\n" @@ -4128,7 +4167,7 @@ msgstr "" "td.lptdesc = POINTER(some_type)\n" "td.u.lptdesc = POINTER(some_type)" -#: ../../library/ctypes.rst:2579 +#: ../../library/ctypes.rst:2622 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:" @@ -4136,7 +4175,7 @@ msgid "" "of the base class." msgstr "" -#: ../../library/ctypes.rst:2584 +#: ../../library/ctypes.rst:2627 msgid "" "Structure and union constructors accept both positional and keyword " "arguments. Positional arguments are used to initialize member fields in the " @@ -4146,15 +4185,15 @@ msgid "" "names not present in :attr:`_fields_`." msgstr "" -#: ../../library/ctypes.rst:2595 +#: ../../library/ctypes.rst:2638 msgid "Arrays and pointers" msgstr "" -#: ../../library/ctypes.rst:2599 +#: ../../library/ctypes.rst:2642 msgid "Abstract base class for arrays." msgstr "" -#: ../../library/ctypes.rst:2601 +#: ../../library/ctypes.rst:2644 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 " @@ -4164,46 +4203,46 @@ msgid "" "an :class:`Array`." msgstr "" -#: ../../library/ctypes.rst:2611 +#: ../../library/ctypes.rst:2654 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:2618 +#: ../../library/ctypes.rst:2661 msgid "Specifies the type of each element in the array." msgstr "" -#: ../../library/ctypes.rst:2621 +#: ../../library/ctypes.rst:2664 msgid "" "Array subclass constructors accept positional arguments, used to initialize " "the elements in order." msgstr "" -#: ../../library/ctypes.rst:2626 +#: ../../library/ctypes.rst:2669 msgid "" "Create an array. Equivalent to ``type * length``, where *type* is a :mod:" "`ctypes` data type and *length* an integer." msgstr "" -#: ../../library/ctypes.rst:2630 +#: ../../library/ctypes.rst:2673 msgid "" "This function is :term:`soft deprecated` in favor of multiplication. There " "are no plans to remove it." msgstr "" -#: ../../library/ctypes.rst:2636 +#: ../../library/ctypes.rst:2679 msgid "Private, abstract base class for pointers." msgstr "" -#: ../../library/ctypes.rst:2638 +#: ../../library/ctypes.rst:2681 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:2642 +#: ../../library/ctypes.rst:2685 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 :" @@ -4212,11 +4251,11 @@ msgid "" "probably crash with an access violation (if you're lucky)." msgstr "" -#: ../../library/ctypes.rst:2652 +#: ../../library/ctypes.rst:2695 msgid "Specifies the type pointed to." msgstr "" -#: ../../library/ctypes.rst:2656 +#: ../../library/ctypes.rst:2699 msgid "" "Returns the object to which to pointer points. Assigning to this attribute " "changes the pointer to point to the assigned object." diff --git a/library/curses.po b/library/curses.po index e2707a4f1a..22177e6b68 100644 --- a/library/curses.po +++ b/library/curses.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2024-10-13 17:13+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-" @@ -40,16 +40,14 @@ msgid "" "curses library hosted on Linux and the BSD variants of Unix." msgstr "" -#: ../../includes/wasm-ios-notavail.rst:3 -msgid ":ref:`Availability `: not WASI, not iOS." +#: ../../includes/wasm-mobile-notavail.rst:3 +msgid "Availability" msgstr "" -#: ../../includes/wasm-ios-notavail.rst:5 +#: ../../includes/wasm-mobile-notavail.rst:5 msgid "" -"This module does not work or is not available on WebAssembly platforms, or " -"on iOS. See :ref:`wasm-availability` for more information on WASM " -"availability; see :ref:`iOS-availability` for more information on iOS " -"availability." +"This module is not supported on :ref:`mobile platforms ` or :ref:`WebAssembly platforms `." msgstr "" #: ../../library/curses.rst:28 diff --git a/library/dataclasses.po b/library/dataclasses.po index 3725bca2be..9ca4bf1f0e 100644 --- a/library/dataclasses.po +++ b/library/dataclasses.po @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-04-24 05:56+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-" @@ -332,10 +332,11 @@ msgstr "" #, fuzzy msgid "" "*match_args*: If true (the default is ``True``), the :attr:`~object." -"__match_args__` tuple will be created from the list of parameters to the " -"generated :meth:`~object.__init__` method (even if :meth:`!__init__` is not " -"generated, see above). If false, or if :attr:`!__match_args__` is already " -"defined in the class, then :attr:`!__match_args__` will not be generated." +"__match_args__` tuple will be created from the list of non keyword-only " +"parameters to the generated :meth:`~object.__init__` method (even if :meth:`!" +"__init__` is not generated, see above). If false, or if :attr:`!" +"__match_args__` is already defined in the class, then :attr:`!" +"__match_args__` will not be generated." msgstr "" "*match_args*:如果為真(預設為 ``True``),``__match_args__`` 元組將從參數列" "表建立到生成的 :meth:`~object.__init__` 方法(即使 :meth: `!__init__` 未生" @@ -349,9 +350,8 @@ msgid "" "marked as keyword-only. If a field is marked as keyword-only, then the only " "effect is that the :meth:`~object.__init__` parameter generated from a " "keyword-only field must be specified with a keyword when :meth:`!__init__` " -"is called. There is no effect on any other aspect of dataclasses. See the :" -"term:`parameter` glossary entry for details. Also see the :const:`KW_ONLY` " -"section." +"is called. See the :term:`parameter` glossary entry for details. Also see " +"the :const:`KW_ONLY` section." msgstr "" "``kw_only``:如果為 true(預設值為 ``False``),則所有欄位將被標記為僅限關鍵" "字。如果一個欄位被標記為僅限關鍵字,那麼唯一的影響是從僅限關鍵字欄位生成的 :" @@ -359,7 +359,11 @@ msgstr "" "類別的任何其他方面都沒有影響。有關詳細資訊,請參閱 :term:`parameter` 詞彙表條" "目。另請參閱 :const:`KW_ONLY` 部分。" -#: ../../library/dataclasses.rst:185 +#: ../../library/dataclasses.rst:182 +msgid "Keyword-only fields are not included in :attr:`!__match_args__`." +msgstr "" + +#: ../../library/dataclasses.rst:186 #, fuzzy msgid "" "*slots*: If true (the default is ``False``), :attr:`~object.__slots__` " @@ -371,7 +375,7 @@ msgstr "" "屬性並回傳新類而不是原始類。如果 :attr:`!__slots__` 已經在類中定義,則 :exc:" "`TypeError` 被引發。" -#: ../../library/dataclasses.rst:191 +#: ../../library/dataclasses.rst:192 #, fuzzy msgid "" "Calling no-arg :func:`super` in dataclasses using ``slots=True`` will result " @@ -383,7 +387,7 @@ msgstr "" "屬性並回傳新類而不是原始類。如果 :attr:`!__slots__` 已經在類中定義,則 :exc:" "`TypeError` 被引發。" -#: ../../library/dataclasses.rst:198 +#: ../../library/dataclasses.rst:199 msgid "" "Passing parameters to a base class :meth:`~object.__init_subclass__` when " "using ``slots=True`` will result in a :exc:`TypeError`. Either use " @@ -391,7 +395,7 @@ msgid "" "workaround. See :gh:`91126` for full details." msgstr "" -#: ../../library/dataclasses.rst:206 +#: ../../library/dataclasses.rst:207 #, fuzzy msgid "" "If a field name is already included in the :attr:`!__slots__` of a base " @@ -407,7 +411,7 @@ msgstr "" "夠確定繼承的插槽,基底類別 :attr:`!__slots__` 可以是任何可疊代的,但*不是*疊" "代器。" -#: ../../library/dataclasses.rst:216 +#: ../../library/dataclasses.rst:217 #, fuzzy msgid "" "*weakref_slot*: If true (the default is ``False``), add a slot named " @@ -419,14 +423,14 @@ msgstr "" "插槽,這是使實例可弱引用所必需的。在沒有指定 ``slots=True`` 的情況下指定 " "``weakref_slot=True`` 是錯誤的。" -#: ../../library/dataclasses.rst:224 +#: ../../library/dataclasses.rst:225 #, fuzzy msgid "" "``field``\\s may optionally specify a default value, using normal Python " "syntax::" msgstr "``field``\\s 可以選擇指定一個預設值,使用普通的 Python 語法: ::" -#: ../../library/dataclasses.rst:227 +#: ../../library/dataclasses.rst:228 msgid "" "@dataclass\n" "class C:\n" @@ -434,7 +438,7 @@ msgid "" " b: int = 0 # assign a default value for 'b'" msgstr "" -#: ../../library/dataclasses.rst:232 +#: ../../library/dataclasses.rst:233 #, fuzzy msgid "" "In this example, both :attr:`!a` and :attr:`!b` will be included in the " @@ -443,11 +447,11 @@ msgstr "" "在此示例中,:attr:`!a` 和 :attr:`!b` 都將包含在新增的 :meth:`~object." "__init__` 方法中,該方法將定義為: ::" -#: ../../library/dataclasses.rst:235 +#: ../../library/dataclasses.rst:236 msgid "def __init__(self, a: int, b: int = 0):" msgstr "" -#: ../../library/dataclasses.rst:237 +#: ../../library/dataclasses.rst:238 #, fuzzy msgid "" ":exc:`TypeError` will be raised if a field without a default value follows a " @@ -457,7 +461,7 @@ msgstr "" ":exc:`TypeError` 如果沒有預設值的欄位跟在具有預設值的欄位之後,將引發。無論這" "發生在單個類中還是作為類繼承的結果,都是如此。" -#: ../../library/dataclasses.rst:243 +#: ../../library/dataclasses.rst:244 #, fuzzy msgid "" "For common and simple use cases, no other functionality is required. There " @@ -470,7 +474,7 @@ msgstr "" "位資訊。為了滿足這種對附加資訊的需求,你可以通過呼叫提供的 :func:`!field` 函" "式來替換預設欄位值。例如: ::" -#: ../../library/dataclasses.rst:249 +#: ../../library/dataclasses.rst:250 msgid "" "@dataclass\n" "class C:\n" @@ -480,7 +484,7 @@ msgid "" "c.mylist += [1, 2, 3]" msgstr "" -#: ../../library/dataclasses.rst:256 +#: ../../library/dataclasses.rst:257 #, fuzzy msgid "" "As shown above, the :const:`MISSING` value is a sentinel object used to " @@ -492,11 +496,11 @@ msgstr "" "供。使用此標記是因為“None”對於某些具有不同含義的參數是有效值。任何程式碼都不" "應直接使用 :const:`MISSING` 值。" -#: ../../library/dataclasses.rst:261 +#: ../../library/dataclasses.rst:262 msgid "The parameters to :func:`!field` are:" msgstr ":func:`!field` 的參數是:" -#: ../../library/dataclasses.rst:263 +#: ../../library/dataclasses.rst:264 #, fuzzy msgid "" "*default*: If provided, this will be the default value for this field. This " @@ -506,7 +510,7 @@ msgstr "" "*default*:如果提供,這將是該欄位的預設值。這是必需的,因為 :meth:`!field` 呼" "叫本身會替換預設值的正常位置。" -#: ../../library/dataclasses.rst:267 +#: ../../library/dataclasses.rst:268 #, fuzzy msgid "" "*default_factory*: If provided, it must be a zero-argument callable that " @@ -519,7 +523,7 @@ msgstr "" "時將被呼叫。除其他用途外,這可用於指定具有可變預設值的欄位,如下所述。同時指" "定 *default* 和 *default_factory* 是錯誤的。" -#: ../../library/dataclasses.rst:273 +#: ../../library/dataclasses.rst:274 #, fuzzy msgid "" "*init*: If true (the default), this field is included as a parameter to the " @@ -528,7 +532,7 @@ msgstr "" "*init*:如果為 true(預設值),則此欄位將作為生成的 :meth:`~object.__init__` " "方法的參數包含在內。" -#: ../../library/dataclasses.rst:276 +#: ../../library/dataclasses.rst:277 #, fuzzy msgid "" "*repr*: If true (the default), this field is included in the string returned " @@ -537,21 +541,23 @@ msgstr "" "*repr*:如果為真(預設值),則此欄位包含在生成的 :meth:`~object.__repr__` 方" "法回傳的字串中。" -#: ../../library/dataclasses.rst:279 +#: ../../library/dataclasses.rst:280 #, fuzzy msgid "" "*hash*: This can be a bool or ``None``. If true, this field is included in " -"the generated :meth:`~object.__hash__` method. If ``None`` (the default), " -"use the value of *compare*: this would normally be the expected behavior. A " -"field should be considered in the hash if it's used for comparisons. " -"Setting this value to anything other than ``None`` is discouraged." +"the generated :meth:`~object.__hash__` method. If false, this field is " +"excluded from the generated :meth:`~object.__hash__`. If ``None`` (the " +"default), use the value of *compare*: this would normally be the expected " +"behavior, since a field should be included in the hash if it's used for " +"comparisons. Setting this value to anything other than ``None`` is " +"discouraged." msgstr "" "*hash*:這可以是 bool 或 ``None``。如果為真,則此欄位包含在生成的 :meth:" "`__hash__` 方法中。如果“無”(預設值),則使用“比較”的值:這通常是預期的行為。" "如果一個欄位用於比較,則應在雜湊中考慮該欄位。不鼓勵將此值設定為“無”以外的任" "何值。" -#: ../../library/dataclasses.rst:286 +#: ../../library/dataclasses.rst:288 #, fuzzy msgid "" "One possible reason to set ``hash=False`` but ``compare=True`` would be if a " @@ -564,7 +570,7 @@ msgstr "" "湊值的成本很高,則需要該欄位進行相等性測試,並且還有其他欄位有助於型別的雜湊" "值。即使一個欄位被排除在雜湊之外,它仍然會被用於比較。" -#: ../../library/dataclasses.rst:292 +#: ../../library/dataclasses.rst:294 #, fuzzy msgid "" "*compare*: If true (the default), this field is included in the generated " @@ -574,7 +580,7 @@ msgstr "" "*compare*:如果為真(預設值),則此欄位包含在生成的相等和比較方法中(:meth:" "`~object.__eq__`、:meth:`~object.__gt__` 等)。" -#: ../../library/dataclasses.rst:296 +#: ../../library/dataclasses.rst:298 #, fuzzy msgid "" "*metadata*: This can be a mapping or ``None``. ``None`` is treated as an " @@ -589,7 +595,7 @@ msgstr "" "不被資料類別使用,而是作為第三方擴充機制提供的。多個第三方可以各自擁有自己的" "密鑰,用作元資料中的命名空間。" -#: ../../library/dataclasses.rst:304 +#: ../../library/dataclasses.rst:306 #, fuzzy msgid "" "*kw_only*: If true, this field will be marked as keyword-only. This is used " @@ -599,6 +605,10 @@ msgstr "" "`~object.__init__` 方法的參數時使用。" #: ../../library/dataclasses.rst:310 +msgid "Keyword-only fields are also not included in :attr:`!__match_args__`." +msgstr "" + +#: ../../library/dataclasses.rst:314 #, fuzzy msgid "" "If the default value of a field is specified by a call to :func:`!field`, " @@ -614,7 +624,7 @@ msgstr "" "在 :func:`@dataclass ` 裝飾器運行後,類別屬性將全部包含欄位的預設" "值,就像預設值本身已指定一樣。例如,在: ::" -#: ../../library/dataclasses.rst:319 +#: ../../library/dataclasses.rst:323 msgid "" "@dataclass\n" "class C:\n" @@ -624,7 +634,7 @@ msgid "" " t: int = 20" msgstr "" -#: ../../library/dataclasses.rst:326 +#: ../../library/dataclasses.rst:330 #, fuzzy msgid "" "The class attribute :attr:`!C.z` will be ``10``, the class attribute :attr:`!" @@ -634,7 +644,7 @@ msgstr "" "類別屬性 :attr:`!C.z` 將為 ``10``,類別屬性 :attr:`!C.t` 將為 ``20``,類別屬" "性 :attr:`!C.x` 和 :attr:`!C.y` 將不會放。" -#: ../../library/dataclasses.rst:332 +#: ../../library/dataclasses.rst:336 #, fuzzy msgid "" ":class:`!Field` objects describe each defined field. These objects are " @@ -646,15 +656,15 @@ msgstr "" "`fields` 模組級方法回傳(見下文)。使用者不應該直接實例化 :class:`!Field` 物" "件。它記錄的屬性是:" -#: ../../library/dataclasses.rst:337 +#: ../../library/dataclasses.rst:341 msgid ":attr:`!name`: The name of the field." msgstr ":attr:`!name`:欄位的名稱。" -#: ../../library/dataclasses.rst:338 +#: ../../library/dataclasses.rst:342 msgid ":attr:`!type`: The type of the field." msgstr ":attr:`!type`:欄位的型別。" -#: ../../library/dataclasses.rst:339 +#: ../../library/dataclasses.rst:343 #, fuzzy msgid "" ":attr:`!default`, :attr:`!default_factory`, :attr:`!init`, :attr:`!repr`, :" @@ -665,14 +675,23 @@ msgstr "" "attr:`!hash`、:attr:`!compare`, :attr:`!metadata` 和 :attr:`!kw_only` 有與它" "們在 :func:`field` 函式中的含義和值相同。" -#: ../../library/dataclasses.rst:343 +#: ../../library/dataclasses.rst:347 #, fuzzy msgid "" "Other attributes may exist, but they are private and must not be inspected " "or relied on." msgstr "可能存在其他屬性,但它們是私有的,不得檢查或依賴。" -#: ../../library/dataclasses.rst:348 +#: ../../library/dataclasses.rst:352 +msgid "" +"``InitVar[T]`` type annotations describe variables that are :ref:`init-only " +"`. Fields annotated with :class:`!InitVar` " +"are considered pseudo-fields, and thus are neither returned by the :func:" +"`fields` function nor used in any way except adding them as parameters to :" +"meth:`~object.__init__` and an optional :meth:`__post_init__`." +msgstr "" + +#: ../../library/dataclasses.rst:361 #, fuzzy msgid "" "Returns a tuple of :class:`Field` objects that define the fields for this " @@ -684,7 +703,7 @@ msgstr "" "實例。如果未傳遞資料類別或其中一個實例,則引發 :exc:`TypeError`。不回傳 " "``ClassVar`` 或 ``InitVar`` 的偽欄位。" -#: ../../library/dataclasses.rst:355 +#: ../../library/dataclasses.rst:368 #, fuzzy msgid "" "Converts the dataclass *obj* to a dict (by using the factory function " @@ -696,12 +715,12 @@ msgstr "" "都被轉換為其欄位的字典,作為 ``name: value`` 對。資料類別、字典、列表和元組被" "遞迴到。其他物件使用 :func:`copy.deepcopy` 複製。" -#: ../../library/dataclasses.rst:361 +#: ../../library/dataclasses.rst:374 #, fuzzy msgid "Example of using :func:`!asdict` on nested dataclasses::" msgstr "在嵌套資料類別上使用 :func:`!asdict` 的範例: ::" -#: ../../library/dataclasses.rst:363 +#: ../../library/dataclasses.rst:376 msgid "" "@dataclass\n" "class Point:\n" @@ -719,22 +738,22 @@ msgid "" "assert asdict(c) == {'mylist': [{'x': 0, 'y': 0}, {'x': 10, 'y': 4}]}" msgstr "" -#: ../../library/dataclasses.rst:378 ../../library/dataclasses.rst:398 +#: ../../library/dataclasses.rst:391 ../../library/dataclasses.rst:411 #, fuzzy msgid "To create a shallow copy, the following workaround may be used::" msgstr "要建立淺複製,可以使用以下解決方法:" -#: ../../library/dataclasses.rst:380 +#: ../../library/dataclasses.rst:393 msgid "{field.name: getattr(obj, field.name) for field in fields(obj)}" msgstr "" -#: ../../library/dataclasses.rst:382 +#: ../../library/dataclasses.rst:395 #, fuzzy msgid "" ":func:`!asdict` raises :exc:`TypeError` if *obj* is not a dataclass instance." msgstr ":func:`!asdict` 如果 *obj* 不是資料類別實例,則引發 :exc:`TypeError`。" -#: ../../library/dataclasses.rst:387 +#: ../../library/dataclasses.rst:400 #, fuzzy msgid "" "Converts the dataclass *obj* to a tuple (by using the factory function " @@ -746,21 +765,21 @@ msgstr "" "都被轉換為其欄位值的元組。資料類別、字典、列表和元組被遞迴到。其他物件使用 :" "func:`copy.deepcopy` 複製。" -#: ../../library/dataclasses.rst:393 +#: ../../library/dataclasses.rst:406 msgid "Continuing from the previous example::" msgstr "從前面的例子繼續: ::" -#: ../../library/dataclasses.rst:395 +#: ../../library/dataclasses.rst:408 msgid "" "assert astuple(p) == (10, 20)\n" "assert astuple(c) == ([(0, 0), (10, 4)],)" msgstr "" -#: ../../library/dataclasses.rst:400 +#: ../../library/dataclasses.rst:413 msgid "tuple(getattr(obj, field.name) for field in dataclasses.fields(obj))" msgstr "" -#: ../../library/dataclasses.rst:402 +#: ../../library/dataclasses.rst:415 #, fuzzy msgid "" ":func:`!astuple` raises :exc:`TypeError` if *obj* is not a dataclass " @@ -768,7 +787,7 @@ msgid "" msgstr "" ":func:`!astuple` 如果 *obj* 不是資料類別實例,則引發 :exc:`TypeError`。" -#: ../../library/dataclasses.rst:407 +#: ../../library/dataclasses.rst:420 #, fuzzy msgid "" "Creates a new dataclass with name *cls_name*, fields as defined in *fields*, " @@ -788,13 +807,13 @@ msgstr "" "``kw_only`` 的值, ``slots`` 和 ``weakref_slot`` 與它們在 :func:`dataclass` 中" "的含義相同。" -#: ../../library/dataclasses.rst:417 +#: ../../library/dataclasses.rst:430 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:421 +#: ../../library/dataclasses.rst:434 #, fuzzy msgid "" "This function is not strictly required, because any Python mechanism for " @@ -806,7 +825,7 @@ msgstr "" "制都可以應用 :func:`dataclass` 函式將該類轉換為資料類別。提供此功能是為了方" "便。例如: ::" -#: ../../library/dataclasses.rst:427 +#: ../../library/dataclasses.rst:440 msgid "" "C = make_dataclass('C',\n" " [('x', int),\n" @@ -815,11 +834,11 @@ msgid "" " namespace={'add_one': lambda self: self.x + 1})" msgstr "" -#: ../../library/dataclasses.rst:433 +#: ../../library/dataclasses.rst:446 msgid "Is equivalent to::" msgstr "相當於: ::" -#: ../../library/dataclasses.rst:435 +#: ../../library/dataclasses.rst:448 msgid "" "@dataclass\n" "class C:\n" @@ -831,7 +850,7 @@ msgid "" " return self.x + 1" msgstr "" -#: ../../library/dataclasses.rst:446 +#: ../../library/dataclasses.rst:459 #, fuzzy msgid "" "Creates a new object of the same type as *obj*, replacing fields with values " @@ -843,7 +862,7 @@ msgstr "" "``obj`` 不是資料類別,則引發 :exc:`TypeError`。如果 ``changes`` 中的值未指定" "欄位,則引發 :exc:`TypeError`。" -#: ../../library/dataclasses.rst:451 +#: ../../library/dataclasses.rst:464 #, fuzzy msgid "" "The newly returned object is created by calling the :meth:`~object.__init__` " @@ -853,7 +872,7 @@ msgstr "" "新回傳的對像是通過呼叫資料類別的 :meth:`~object.__init__` 方法建立的。這確" "保 :meth:`__post_init__`(如果存在)也被呼叫。" -#: ../../library/dataclasses.rst:455 +#: ../../library/dataclasses.rst:468 #, fuzzy msgid "" "Init-only variables without default values, if any exist, must be specified " @@ -863,7 +882,7 @@ msgstr "" "沒有預設值的僅初始化變數(如果存在)必須在呼叫 :func:`replace` 時指定,以便它" "們可以傳遞給 :meth:`__init__` 和 :meth:`__post_init__`。" -#: ../../library/dataclasses.rst:459 +#: ../../library/dataclasses.rst:472 #, fuzzy msgid "" "It is an error for *changes* to contain any fields that are defined as " @@ -872,7 +891,7 @@ msgstr "" "*changes* 包含任何定義為具有 ``init=False`` 的欄位是錯誤的。在這種情況下將引" "發 :exc:`ValueError`。" -#: ../../library/dataclasses.rst:463 +#: ../../library/dataclasses.rst:476 #, fuzzy msgid "" "Be forewarned about how ``init=False`` fields work during a call to :func:`!" @@ -889,13 +908,13 @@ msgstr "" "造函式可能是明智的,或者可能是處理實例複製的自定義:func:`!replace` (或類似命" "名的)方法。" -#: ../../library/dataclasses.rst:472 +#: ../../library/dataclasses.rst:485 msgid "" "Dataclass instances are also supported by generic function :func:`copy." "replace`." msgstr "" -#: ../../library/dataclasses.rst:476 +#: ../../library/dataclasses.rst:489 #, fuzzy msgid "" "Return ``True`` if its parameter is a dataclass (including subclasses of a " @@ -903,7 +922,7 @@ msgid "" msgstr "" "如果它的參數是一個資料類別或一個實例,則回傳 ``True``,否則回傳 ``False``。" -#: ../../library/dataclasses.rst:479 +#: ../../library/dataclasses.rst:492 #, fuzzy msgid "" "If you need to know if a class is an instance of a dataclass (and not a " @@ -913,18 +932,18 @@ msgstr "" "如果你需要知道一個類是否是資料類別的實例(而不是資料類別本身),那麼新增一個" "進一步的檢查 ``not isinstance(obj, type)``: ::" -#: ../../library/dataclasses.rst:483 +#: ../../library/dataclasses.rst:496 msgid "" "def is_dataclass_instance(obj):\n" " return is_dataclass(obj) and not isinstance(obj, type)" msgstr "" -#: ../../library/dataclasses.rst:488 +#: ../../library/dataclasses.rst:501 #, fuzzy msgid "A sentinel value signifying a missing default or default_factory." msgstr "表示缺少 default 或 default_factory 的標記值。" -#: ../../library/dataclasses.rst:492 +#: ../../library/dataclasses.rst:505 #, fuzzy msgid "" "A sentinel value used as a type annotation. Any fields after a pseudo-field " @@ -940,14 +959,14 @@ msgstr "" "類欄位的名稱。按照慣例,名稱 ``_`` 用於 :const:`!KW_ONLY` 欄位。僅關鍵字欄位" "表示 :meth:`~object.__init__` 參數,在實例化類時必須將其指定為關鍵字。" -#: ../../library/dataclasses.rst:501 +#: ../../library/dataclasses.rst:514 #, fuzzy msgid "" "In this example, the fields ``y`` and ``z`` will be marked as keyword-only " "fields::" msgstr "在此示例中,欄位 ``y`` 和 ``z`` 將被標記為僅關鍵字欄位: ::" -#: ../../library/dataclasses.rst:503 +#: ../../library/dataclasses.rst:516 msgid "" "@dataclass\n" "class Point:\n" @@ -959,14 +978,14 @@ msgid "" "p = Point(0, y=1.5, z=2.0)" msgstr "" -#: ../../library/dataclasses.rst:512 +#: ../../library/dataclasses.rst:525 #, 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:519 +#: ../../library/dataclasses.rst:532 #, fuzzy msgid "" "Raised when an implicitly defined :meth:`~object.__setattr__` or :meth:" @@ -976,12 +995,12 @@ msgstr "" "當在使用 frozen=True 定義的資料類別上呼叫隱式定義的 :meth:`__setattr__` 或 :" "meth:`__delattr__` 時引發。它是 :exc:`AttributeError` 的子類別。" -#: ../../library/dataclasses.rst:526 +#: ../../library/dataclasses.rst:539 #, fuzzy msgid "Post-init processing" msgstr "初始化後處理" -#: ../../library/dataclasses.rst:530 +#: ../../library/dataclasses.rst:543 #, fuzzy msgid "" "When defined on the class, it will be called by the generated :meth:`~object." @@ -997,14 +1016,14 @@ msgstr "" "按照它們在類中定義的順序傳遞給 :meth:`!__post_init__` 。如果沒有生成 :meth:`!" "__init__` 方法,那麼 :meth:`!__post_init__` 將不會被自動呼叫。" -#: ../../library/dataclasses.rst:537 +#: ../../library/dataclasses.rst:550 #, 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:540 +#: ../../library/dataclasses.rst:553 msgid "" "@dataclass\n" "class C:\n" @@ -1016,7 +1035,7 @@ msgid "" " self.c = self.a + self.b" msgstr "" -#: ../../library/dataclasses.rst:549 +#: ../../library/dataclasses.rst:562 #, fuzzy msgid "" "The :meth:`~object.__init__` method generated by :func:`@dataclass " @@ -1028,7 +1047,7 @@ msgstr "" "類別 :meth:`!__init__` 方法。如果基底類別有一個必須呼叫的 :meth:`!__init__` " "方法,通常在 :meth:`__post_init__` 方法中呼叫此方法: ::" -#: ../../library/dataclasses.rst:554 +#: ../../library/dataclasses.rst:567 msgid "" "class Rectangle:\n" " def __init__(self, height, width):\n" @@ -1043,7 +1062,7 @@ msgid "" " super().__init__(self.side, self.side)" msgstr "" -#: ../../library/dataclasses.rst:566 +#: ../../library/dataclasses.rst:579 #, fuzzy msgid "" "Note, however, that in general the dataclass-generated :meth:`!__init__` " @@ -1053,7 +1072,7 @@ msgstr "" "但是請注意,通常不需要呼叫資料類別生成的 :meth:`!__init__` 方法,因為派生資料" "類別將負責初始化作為資料類別本身的任何基底類別的所有欄位。" -#: ../../library/dataclasses.rst:570 +#: ../../library/dataclasses.rst:583 #, fuzzy msgid "" "See the section below on init-only variables for ways to pass parameters to :" @@ -1063,11 +1082,11 @@ msgstr "" "請參閱下面有關僅初始化變數的部分,了解將參數傳遞給 :meth:`!__post_init__` 的" "方法。另請參閱有關 :func:`replace` 如何處理 ``init=False`` 欄位的警告。" -#: ../../library/dataclasses.rst:577 +#: ../../library/dataclasses.rst:590 msgid "Class variables" msgstr "類別變數" -#: ../../library/dataclasses.rst:579 +#: ../../library/dataclasses.rst:592 #, fuzzy msgid "" "One of the few places where :func:`@dataclass ` actually inspects " @@ -1084,18 +1103,18 @@ msgstr "" "外,並被資料類別機制忽略。模組級 :func:`fields` 函式不會回傳此類別 " "``ClassVar`` 偽欄位。" -#: ../../library/dataclasses.rst:590 +#: ../../library/dataclasses.rst:603 #, fuzzy msgid "Init-only variables" msgstr "僅初始化變數" -#: ../../library/dataclasses.rst:592 +#: ../../library/dataclasses.rst:605 #, 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 ``dataclasses.InitVar``. " -"If a field is an ``InitVar``, it is considered a pseudo-field called an init-" +"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 " @@ -1109,14 +1128,14 @@ msgstr "" "的 :meth:`~object.__init__` 方法,並傳遞給可選的 :meth:`__post_init__` 方法。" "它們不被資料類使用。" -#: ../../library/dataclasses.rst:602 +#: ../../library/dataclasses.rst:615 #, 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:605 +#: ../../library/dataclasses.rst:618 msgid "" "@dataclass\n" "class C:\n" @@ -1131,7 +1150,7 @@ msgid "" "c = C(10, database=my_database)" msgstr "" -#: ../../library/dataclasses.rst:617 +#: ../../library/dataclasses.rst:630 #, fuzzy msgid "" "In this case, :func:`fields` will return :class:`Field` objects for :attr:`!" @@ -1140,11 +1159,11 @@ msgstr "" "在這種情況下,:func:`fields` 將為 :attr:`!i` 和 :attr:`!j` 回傳 :class:" "`Field` 物件,但不會為 :attr:`!database` 回傳。" -#: ../../library/dataclasses.rst:623 +#: ../../library/dataclasses.rst:636 msgid "Frozen instances" msgstr "凍結實例" -#: ../../library/dataclasses.rst:625 +#: ../../library/dataclasses.rst:638 #, fuzzy msgid "" "It is not possible to create truly immutable Python objects. However, by " @@ -1158,7 +1177,7 @@ msgstr "" "別將向類新增 :meth:`~object.__setattr__` 和 :meth:`~object.__delattr__` 方" "法。這些方法在呼叫時會引發 :exc:`FrozenInstanceError`。" -#: ../../library/dataclasses.rst:631 +#: ../../library/dataclasses.rst:644 #, fuzzy msgid "" "There is a tiny performance penalty when using ``frozen=True``: :meth:" @@ -1168,11 +1187,11 @@ msgstr "" "使用 ``frozen=True`` 時有一個微小的性能損失::meth:`~object.__init__` 不能使" "用簡單賦值來初始化欄位,必須使用 :meth:`!object.__setattr__`。" -#: ../../library/dataclasses.rst:640 +#: ../../library/dataclasses.rst:653 msgid "Inheritance" msgstr "繼承" -#: ../../library/dataclasses.rst:642 +#: ../../library/dataclasses.rst:655 #, fuzzy msgid "" "When the dataclass is being created by the :func:`@dataclass ` " @@ -1190,7 +1209,7 @@ msgstr "" "將自己的欄位新增到有序映射中。所有生成的方法都將使用這種組合的、計算的有序欄" "位映射。因為欄位是按插入順序排列的,所以派生類會覆蓋基底類別。一個例子: ::" -#: ../../library/dataclasses.rst:652 +#: ../../library/dataclasses.rst:665 msgid "" "@dataclass\n" "class Base:\n" @@ -1203,7 +1222,7 @@ msgid "" " x: int = 15" msgstr "" -#: ../../library/dataclasses.rst:662 +#: ../../library/dataclasses.rst:675 #, fuzzy msgid "" "The final list of fields is, in order, :attr:`!x`, :attr:`!y`, :attr:`!z`. " @@ -1213,23 +1232,23 @@ msgstr "" "最終的欄位列表按順序為 :attr:`!x`、:attr:`!y`、:attr:`!z`。:attr:`!x` 的最終" "型別是 :class:`int`,如類別 :class:`!C` 中指定的那樣。" -#: ../../library/dataclasses.rst:665 +#: ../../library/dataclasses.rst:678 #, fuzzy msgid "" "The generated :meth:`~object.__init__` method for :class:`!C` will look " "like::" msgstr "為 :class:`!C` 生成的 :meth:`~object.__init__` 方法將如下所示: ::" -#: ../../library/dataclasses.rst:667 +#: ../../library/dataclasses.rst:680 msgid "def __init__(self, x: int = 15, y: int = 0, z: int = 10):" msgstr "" -#: ../../library/dataclasses.rst:670 +#: ../../library/dataclasses.rst:683 #, fuzzy msgid "Re-ordering of keyword-only parameters in :meth:`!__init__`" msgstr ":meth:`!__init__` 中僅關鍵字參數的重新排序" -#: ../../library/dataclasses.rst:672 +#: ../../library/dataclasses.rst:685 #, fuzzy msgid "" "After the parameters needed for :meth:`~object.__init__` are computed, any " @@ -1241,7 +1260,7 @@ msgstr "" "僅關鍵字)參數之後。這是如何在 Python 中實作僅關鍵字參數的要求:它們必須位於" "非僅關鍵字參數之後。" -#: ../../library/dataclasses.rst:678 +#: ../../library/dataclasses.rst:691 #, fuzzy msgid "" "In this example, :attr:`!Base.y`, :attr:`!Base.w`, and :attr:`!D.t` are " @@ -1251,7 +1270,7 @@ msgstr "" "在此示例中,:attr:`!Base.y`、:attr:`!Base.w` 和 :attr:`!D.t` 是僅限關鍵字的欄" "位,:attr:`!Base.x` 和 :attr:`!D.z` 是常規欄位: ::" -#: ../../library/dataclasses.rst:681 +#: ../../library/dataclasses.rst:694 msgid "" "@dataclass\n" "class Base:\n" @@ -1266,18 +1285,18 @@ msgid "" " t: int = field(kw_only=True, default=0)" msgstr "" -#: ../../library/dataclasses.rst:693 +#: ../../library/dataclasses.rst:706 #, fuzzy msgid "The generated :meth:`!__init__` method for :class:`!D` will look like::" msgstr "為 :class:`!D` 生成的 :meth:`!__init__` 方法將如下所示: ::" -#: ../../library/dataclasses.rst:695 +#: ../../library/dataclasses.rst:708 msgid "" "def __init__(self, x: Any = 15.0, z: int = 10, *, y: int = 0, w: int = 1, t: " "int = 0):" msgstr "" -#: ../../library/dataclasses.rst:697 +#: ../../library/dataclasses.rst:710 #, fuzzy msgid "" "Note that the parameters have been re-ordered from how they appear in the " @@ -1287,18 +1306,18 @@ msgstr "" "請注意,參數已根據它們在欄位列表中的顯示方式重新排序:從常規欄位派生的參數後" "跟從僅關鍵字欄位派生的參數。" -#: ../../library/dataclasses.rst:701 +#: ../../library/dataclasses.rst:714 #, 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:706 +#: ../../library/dataclasses.rst:719 msgid "Default factory functions" msgstr "預設工廠函式" -#: ../../library/dataclasses.rst:708 +#: ../../library/dataclasses.rst:721 #, fuzzy msgid "" "If a :func:`field` specifies a *default_factory*, it is called with zero " @@ -1308,11 +1327,11 @@ msgstr "" "如果 :func:`field` 指定了 *default_factory*,當需要該欄位的預設值時,它會以零" "引數呼叫。例如,要建立列表的新實例,請使用: ::" -#: ../../library/dataclasses.rst:712 +#: ../../library/dataclasses.rst:725 msgid "mylist: list = field(default_factory=list)" msgstr "" -#: ../../library/dataclasses.rst:714 +#: ../../library/dataclasses.rst:727 #, fuzzy msgid "" "If a field is excluded from :meth:`~object.__init__` (using ``init=False``) " @@ -1325,11 +1344,11 @@ msgstr "" "位還指定了 ``default_factory``,那麼預設工廠函式將始終從生成的 :meth:" "`__init__ 中呼叫`功能。發生這種情況是因為沒有其他方法可以為該欄位賦予初始值。" -#: ../../library/dataclasses.rst:721 +#: ../../library/dataclasses.rst:734 msgid "Mutable default values" msgstr "可變預設值" -#: ../../library/dataclasses.rst:723 +#: ../../library/dataclasses.rst:736 #, fuzzy msgid "" "Python stores default member variable values in class attributes. Consider " @@ -1337,7 +1356,7 @@ msgid "" msgstr "" "Python 將預設成員變數值存儲在類別屬性中。考慮這個例子,不使用資料類別: ::" -#: ../../library/dataclasses.rst:726 +#: ../../library/dataclasses.rst:739 msgid "" "class C:\n" " x = []\n" @@ -1352,7 +1371,7 @@ msgid "" "assert o1.x is o2.x" msgstr "" -#: ../../library/dataclasses.rst:738 +#: ../../library/dataclasses.rst:751 #, fuzzy msgid "" "Note that the two instances of class :class:`!C` share the same class " @@ -1361,12 +1380,12 @@ msgstr "" "請注意,類別 :class:`!C` 的兩個實例共享同一個類別變數 :attr:`!x`,正如預期的" "那樣。" -#: ../../library/dataclasses.rst:741 +#: ../../library/dataclasses.rst:754 #, fuzzy msgid "Using dataclasses, *if* this code was valid::" msgstr "使用資料類別,*如果*此程式碼有效: ::" -#: ../../library/dataclasses.rst:743 +#: ../../library/dataclasses.rst:756 msgid "" "@dataclass\n" "class D:\n" @@ -1375,11 +1394,11 @@ msgid "" " self.x.append(element)" msgstr "" -#: ../../library/dataclasses.rst:749 +#: ../../library/dataclasses.rst:762 msgid "it would generate code similar to::" msgstr "它會生成類似的程式碼: ::" -#: ../../library/dataclasses.rst:751 +#: ../../library/dataclasses.rst:764 msgid "" "class D:\n" " x = []\n" @@ -1391,7 +1410,7 @@ msgid "" "assert D().x is D().x" msgstr "" -#: ../../library/dataclasses.rst:760 +#: ../../library/dataclasses.rst:773 #, fuzzy msgid "" "This has the same issue as the original example using class :class:`!C`. " @@ -1411,14 +1430,14 @@ msgstr "" "到不可散列的預設參數,它將引發 :exc:`TypeError`。假設是如果一個值是不可散列" "的,那麼它就是可變的。這是一個部分解決方案,但它確實可以防止許多常見錯誤。" -#: ../../library/dataclasses.rst:771 +#: ../../library/dataclasses.rst:784 #, 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:774 +#: ../../library/dataclasses.rst:787 msgid "" "@dataclass\n" "class D:\n" @@ -1427,7 +1446,7 @@ msgid "" "assert D().x is not D().x" msgstr "" -#: ../../library/dataclasses.rst:780 +#: ../../library/dataclasses.rst:793 #, fuzzy msgid "" "Instead of looking for and disallowing objects of type :class:`list`, :class:" @@ -1437,12 +1456,12 @@ msgstr "" "不再查找和禁止型別為 :class:`list`、:class:`dict` 或 :class:`set` 的物件,現" "在不允許使用不可散列的對像作為預設值。不可散列性用於近似可變性。" -#: ../../library/dataclasses.rst:787 +#: ../../library/dataclasses.rst:800 #, fuzzy msgid "Descriptor-typed fields" msgstr "描述器型別的欄位" -#: ../../library/dataclasses.rst:789 +#: ../../library/dataclasses.rst:802 #, fuzzy msgid "" "Fields that are assigned :ref:`descriptor objects ` as their " @@ -1450,7 +1469,7 @@ msgid "" msgstr "" "指定為\\ :ref:`描述器物件 `\\ 作為預設值的欄位具有以下特殊行為:" -#: ../../library/dataclasses.rst:792 +#: ../../library/dataclasses.rst:805 #, fuzzy msgid "" "The value for the field passed to the dataclass's :meth:`~object.__init__` " @@ -1460,7 +1479,7 @@ msgstr "" "傳遞給資料類別的 :meth:`~object.__init__` 方法的欄位值被傳遞給描述器的 :meth:" "`~object.__set__` 方法,而不是覆蓋描述器物件。" -#: ../../library/dataclasses.rst:796 +#: ../../library/dataclasses.rst:809 #, fuzzy msgid "" "Similarly, when getting or setting the field, the descriptor's :meth:" @@ -1470,7 +1489,7 @@ msgstr "" "同樣,在獲取或設定欄位時,將呼叫描述器的 :meth:`~object.__get__` 或 :meth:`!" "__set__` 方法,而不是回傳或覆蓋描述器物件。" -#: ../../library/dataclasses.rst:800 +#: ../../library/dataclasses.rst:813 #, fuzzy msgid "" "To determine whether a field contains a default value, :func:`@dataclass " @@ -1486,7 +1505,7 @@ msgstr "" "面,如果描述器在這種情況下引發 :exc:`AttributeError`,則不會為該欄位提供預設" "值。" -#: ../../library/dataclasses.rst:810 +#: ../../library/dataclasses.rst:823 msgid "" "class IntConversionDescriptor:\n" " def __init__(self, *, default):\n" @@ -1515,7 +1534,7 @@ msgid "" "print(i.quantity_on_hand) # 2" msgstr "" -#: ../../library/dataclasses.rst:835 +#: ../../library/dataclasses.rst:848 #, fuzzy msgid "" "Note that if a field is annotated with a descriptor type, but is not " diff --git a/library/datetime.po b/library/datetime.po index 886165ae86..4f538cc15f 100644 --- a/library/datetime.po +++ b/library/datetime.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-05-11 14:27+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-" @@ -270,7 +270,8 @@ msgid "" msgstr "" #: ../../library/datetime.rst:183 -msgid "A :class:`.datetime` object *d* is aware if both of the following hold:" +msgid "" +"A :class:`.datetime` object ``d`` is aware if both of the following hold:" msgstr "" #: ../../library/datetime.rst:185 @@ -282,11 +283,12 @@ msgid "``d.tzinfo.utcoffset(d)`` does not return ``None``" msgstr "``d.tzinfo.utcoffset(d)`` 不會回傳 ``None``" #: ../../library/datetime.rst:188 -msgid "Otherwise, *d* is naive." +#, fuzzy +msgid "Otherwise, ``d`` is naive." msgstr "否則 *d* 會是 naive 的。" #: ../../library/datetime.rst:190 -msgid "A :class:`.time` object *t* is aware if both of the following hold:" +msgid "A :class:`.time` object ``t`` is aware if both of the following hold:" msgstr "" #: ../../library/datetime.rst:192 @@ -298,8 +300,9 @@ msgid "``t.tzinfo.utcoffset(None)`` does not return ``None``." msgstr "``t.tzinfo.utcoffset(None)`` 沒有回傳 ``None``。" #: ../../library/datetime.rst:195 -msgid "Otherwise, *t* is naive." -msgstr "" +#, fuzzy +msgid "Otherwise, ``t`` is naive." +msgstr "否則 *d* 會是 naive 的。" #: ../../library/datetime.rst:197 msgid "" @@ -422,236 +425,278 @@ msgstr "" ">>> (d.days, d.seconds, d.microseconds)\n" "(-1, 86399, 999999)" -#: ../../library/datetime.rst:265 ../../library/datetime.rst:552 -#: ../../library/datetime.rst:1108 ../../library/datetime.rst:1746 -#: ../../library/datetime.rst:2351 +#: ../../library/datetime.rst:264 +msgid "" +"Since the string representation of :class:`!timedelta` objects can be " +"confusing, use the following recipe to produce a more readable format:" +msgstr "" + +#: ../../library/datetime.rst:267 +msgid "" +">>> 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)'" +msgstr "" + +#: ../../library/datetime.rst:281 ../../library/datetime.rst:582 +#: ../../library/datetime.rst:1142 ../../library/datetime.rst:1780 +#: ../../library/datetime.rst:2385 msgid "Class attributes:" msgstr "類別屬性:" -#: ../../library/datetime.rst:269 +#: ../../library/datetime.rst:285 msgid "The most negative :class:`timedelta` object, ``timedelta(-999999999)``." msgstr "" -#: ../../library/datetime.rst:274 +#: ../../library/datetime.rst:290 msgid "" "The most positive :class:`timedelta` object, ``timedelta(days=999999999, " "hours=23, minutes=59, seconds=59, microseconds=999999)``." msgstr "" -#: ../../library/datetime.rst:280 +#: ../../library/datetime.rst:296 msgid "" "The smallest possible difference between non-equal :class:`timedelta` " "objects, ``timedelta(microseconds=1)``." msgstr "" -#: ../../library/datetime.rst:283 +#: ../../library/datetime.rst:299 msgid "" "Note that, because of normalization, ``timedelta.max`` is greater than ``-" "timedelta.min``. ``-timedelta.max`` is not representable as a :class:" "`timedelta` object." msgstr "" -#: ../../library/datetime.rst:287 ../../library/datetime.rst:570 -#: ../../library/datetime.rst:1128 ../../library/datetime.rst:1766 +#: ../../library/datetime.rst:303 ../../library/datetime.rst:600 +#: ../../library/datetime.rst:1162 ../../library/datetime.rst:1800 msgid "Instance attributes (read-only):" msgstr "" -#: ../../library/datetime.rst:291 +#: ../../library/datetime.rst:307 msgid "Between -999,999,999 and 999,999,999 inclusive." msgstr "在 -999,999,999 到 999,999,999 (含)之間" -#: ../../library/datetime.rst:296 +#: ../../library/datetime.rst:312 msgid "Between 0 and 86,399 inclusive." msgstr "在 0 到 86,399 (含)之間" -#: ../../library/datetime.rst:301 +#: ../../library/datetime.rst:316 +msgid "" +"It is a somewhat common bug for code to unintentionally use this attribute " +"when it is actually intended to get a :meth:`~timedelta.total_seconds` value " +"instead:" +msgstr "" + +#: ../../library/datetime.rst:320 +#, fuzzy +msgid "" +">>> from datetime import timedelta\n" +">>> duration = timedelta(seconds=11235813)\n" +">>> duration.days, duration.seconds\n" +"(130, 3813)\n" +">>> duration.total_seconds()\n" +"11235813.0" +msgstr "" +">>> from datetime import timedelta\n" +">>> d = timedelta(microseconds=-1)\n" +">>> (d.days, d.seconds, d.microseconds)\n" +"(-1, 86399, 999999)" + +#: ../../library/datetime.rst:331 msgid "Between 0 and 999,999 inclusive." msgstr "在 0 到 999,999 (含)之間" -#: ../../library/datetime.rst:304 ../../library/datetime.rst:587 -#: ../../library/datetime.rst:1181 +#: ../../library/datetime.rst:334 ../../library/datetime.rst:617 +#: ../../library/datetime.rst:1215 msgid "Supported operations:" msgstr "" -#: ../../library/datetime.rst:309 ../../library/datetime.rst:590 -#: ../../library/datetime.rst:1184 +#: ../../library/datetime.rst:339 ../../library/datetime.rst:620 +#: ../../library/datetime.rst:1218 msgid "Operation" msgstr "" -#: ../../library/datetime.rst:309 ../../library/datetime.rst:590 -#: ../../library/datetime.rst:1184 +#: ../../library/datetime.rst:339 ../../library/datetime.rst:620 +#: ../../library/datetime.rst:1218 msgid "Result" msgstr "" -#: ../../library/datetime.rst:311 +#: ../../library/datetime.rst:341 msgid "``t1 = t2 + t3``" msgstr "``t1 = t2 + t3``" -#: ../../library/datetime.rst:311 +#: ../../library/datetime.rst:341 msgid "" "Sum of ``t2`` and ``t3``. Afterwards ``t1 - t2 == t3`` and ``t1 - t3 == t2`` " "are true. (1)" msgstr "" -#: ../../library/datetime.rst:315 +#: ../../library/datetime.rst:345 msgid "``t1 = t2 - t3``" msgstr "``t1 = t2 - t3``" -#: ../../library/datetime.rst:315 +#: ../../library/datetime.rst:345 msgid "" "Difference of ``t2`` and ``t3``. Afterwards ``t1 == t2 - t3`` and ``t2 == " "t1 + t3`` are true. (1)(6)" msgstr "" -#: ../../library/datetime.rst:319 +#: ../../library/datetime.rst:349 msgid "``t1 = t2 * i or t1 = i * t2``" msgstr "``t1 = t2 * i or t1 = i * t2``" -#: ../../library/datetime.rst:319 +#: ../../library/datetime.rst:349 msgid "" "Delta multiplied by an integer. Afterwards ``t1 // i == t2`` is true, " "provided ``i != 0``." msgstr "" -#: ../../library/datetime.rst:323 +#: ../../library/datetime.rst:353 msgid "In general, ``t1 * i == t1 * (i-1) + t1`` is true. (1)" msgstr "" -#: ../../library/datetime.rst:326 +#: ../../library/datetime.rst:356 msgid "``t1 = t2 * f or t1 = f * t2``" msgstr "``t1 = t2 * f or t1 = f * t2``" -#: ../../library/datetime.rst:326 +#: ../../library/datetime.rst:356 msgid "" "Delta multiplied by a float. The result is rounded to the nearest multiple " "of timedelta.resolution using round-half-to-even." msgstr "" -#: ../../library/datetime.rst:330 +#: ../../library/datetime.rst:360 msgid "``f = t2 / t3``" msgstr "``f = t2 / t3``" -#: ../../library/datetime.rst:330 +#: ../../library/datetime.rst:360 msgid "" "Division (3) of overall duration ``t2`` by interval unit ``t3``. Returns a :" "class:`float` object." msgstr "" -#: ../../library/datetime.rst:334 +#: ../../library/datetime.rst:364 msgid "``t1 = t2 / f or t1 = t2 / i``" msgstr "``t1 = t2 / f or t1 = t2 / i``" -#: ../../library/datetime.rst:334 +#: ../../library/datetime.rst:364 msgid "" "Delta divided by a float or an int. The result is rounded to the nearest " "multiple of timedelta.resolution using round-half-to-even." msgstr "" -#: ../../library/datetime.rst:338 +#: ../../library/datetime.rst:368 msgid "``t1 = t2 // i`` or ``t1 = t2 // t3``" msgstr "``t1 = t2 // i`` or ``t1 = t2 // t3``" -#: ../../library/datetime.rst:338 +#: ../../library/datetime.rst:368 msgid "" "The floor is computed and the remainder (if any) is thrown away. In the " "second case, an integer is returned. (3)" msgstr "" -#: ../../library/datetime.rst:342 +#: ../../library/datetime.rst:372 msgid "``t1 = t2 % t3``" msgstr "``t1 = t2 % t3``" -#: ../../library/datetime.rst:342 +#: ../../library/datetime.rst:372 msgid "The remainder is computed as a :class:`timedelta` object. (3)" msgstr "" -#: ../../library/datetime.rst:345 +#: ../../library/datetime.rst:375 msgid "``q, r = divmod(t1, t2)``" msgstr "``q, r = divmod(t1, t2)``" -#: ../../library/datetime.rst:345 +#: ../../library/datetime.rst:375 msgid "" "Computes the quotient and the remainder: ``q = t1 // t2`` (3) and ``r = t1 % " -"t2``. q is an integer and r is a :class:`timedelta` object." +"t2``. ``q`` is an integer and ``r`` is a :class:`timedelta` object." msgstr "" -#: ../../library/datetime.rst:350 +#: ../../library/datetime.rst:380 msgid "``+t1``" msgstr "``+t1``" -#: ../../library/datetime.rst:350 +#: ../../library/datetime.rst:380 msgid "Returns a :class:`timedelta` object with the same value. (2)" msgstr "" -#: ../../library/datetime.rst:353 +#: ../../library/datetime.rst:383 msgid "``-t1``" msgstr "``-t1``" -#: ../../library/datetime.rst:353 +#: ../../library/datetime.rst:383 msgid "" -"Equivalent to ``timedelta(-t1.days, -t1.seconds*, -t1.microseconds)``, and " -"to ``t1 * -1``. (1)(4)" +"Equivalent to ``timedelta(-t1.days, -t1.seconds, -t1.microseconds)``, and to " +"``t1 * -1``. (1)(4)" msgstr "" -#: ../../library/datetime.rst:357 +#: ../../library/datetime.rst:387 msgid "``abs(t)``" msgstr "``abs(t)``" -#: ../../library/datetime.rst:357 +#: ../../library/datetime.rst:387 msgid "" "Equivalent to ``+t`` when ``t.days >= 0``, and to ``-t`` when ``t.days < " "0``. (2)" msgstr "" -#: ../../library/datetime.rst:360 +#: ../../library/datetime.rst:390 msgid "``str(t)``" msgstr "``str(t)``" -#: ../../library/datetime.rst:360 +#: ../../library/datetime.rst:390 msgid "" "Returns a string in the form ``[D day[s], ][H]H:MM:SS[.UUUUUU]``, where D is " "negative for negative ``t``. (5)" msgstr "" -#: ../../library/datetime.rst:364 +#: ../../library/datetime.rst:394 msgid "``repr(t)``" msgstr "``repr(t)``" -#: ../../library/datetime.rst:364 +#: ../../library/datetime.rst:394 msgid "" "Returns a string representation of the :class:`timedelta` object as a " "constructor call with canonical attribute values." msgstr "" -#: ../../library/datetime.rst:370 ../../library/datetime.rst:609 -#: ../../library/datetime.rst:2582 +#: ../../library/datetime.rst:400 ../../library/datetime.rst:639 +#: ../../library/datetime.rst:2616 msgid "Notes:" msgstr "註解:" -#: ../../library/datetime.rst:373 +#: ../../library/datetime.rst:403 msgid "This is exact but may overflow." msgstr "這是精確的,但可能會溢位。" -#: ../../library/datetime.rst:376 +#: ../../library/datetime.rst:406 msgid "This is exact and cannot overflow." msgstr "這是精確的,且不會溢位。" -#: ../../library/datetime.rst:379 +#: ../../library/datetime.rst:409 msgid "Division by zero raises :exc:`ZeroDivisionError`." msgstr "" -#: ../../library/datetime.rst:382 +#: ../../library/datetime.rst:412 msgid "``-timedelta.max`` is not representable as a :class:`timedelta` object." msgstr "" -#: ../../library/datetime.rst:385 +#: ../../library/datetime.rst:415 msgid "" "String representations of :class:`timedelta` objects are normalized " "similarly to their internal representation. This leads to somewhat unusual " "results for negative timedeltas. For example::" msgstr "" -#: ../../library/datetime.rst:389 +#: ../../library/datetime.rst:419 msgid "" ">>> timedelta(hours=-5)\n" "datetime.timedelta(days=-1, seconds=68400)\n" @@ -663,21 +708,21 @@ msgstr "" ">>> print(_)\n" "-1 day, 19:00:00" -#: ../../library/datetime.rst:395 +#: ../../library/datetime.rst:425 msgid "" "The expression ``t2 - t3`` will always be equal to the expression ``t2 + (-" "t3)`` except when t3 is equal to ``timedelta.max``; in that case the former " "will produce a result while the latter will overflow." msgstr "" -#: ../../library/datetime.rst:399 +#: ../../library/datetime.rst:429 msgid "" "In addition to the operations listed above, :class:`timedelta` objects " "support certain additions and subtractions with :class:`date` and :class:`." "datetime` objects (see below)." msgstr "" -#: ../../library/datetime.rst:403 +#: ../../library/datetime.rst:433 msgid "" "Floor division and true division of a :class:`timedelta` object by another :" "class:`timedelta` object are now supported, as are remainder operations and " @@ -685,43 +730,43 @@ msgid "" "`timedelta` object by a :class:`float` object are now supported." msgstr "" -#: ../../library/datetime.rst:409 +#: ../../library/datetime.rst:439 msgid ":class:`timedelta` objects support equality and order comparisons." msgstr "" -#: ../../library/datetime.rst:411 +#: ../../library/datetime.rst:441 msgid "" "In Boolean contexts, a :class:`timedelta` object is considered to be true if " "and only if it isn't equal to ``timedelta(0)``." msgstr "" -#: ../../library/datetime.rst:414 ../../library/datetime.rst:651 -#: ../../library/datetime.rst:1271 ../../library/datetime.rst:1873 +#: ../../library/datetime.rst:444 ../../library/datetime.rst:681 +#: ../../library/datetime.rst:1305 ../../library/datetime.rst:1907 msgid "Instance methods:" msgstr "實例方法:" -#: ../../library/datetime.rst:418 +#: ../../library/datetime.rst:448 msgid "" "Return the total number of seconds contained in the duration. Equivalent to " "``td / timedelta(seconds=1)``. For interval units other than seconds, use " "the division form directly (e.g. ``td / timedelta(microseconds=1)``)." msgstr "" -#: ../../library/datetime.rst:422 +#: ../../library/datetime.rst:452 msgid "" "Note that for very large time intervals (greater than 270 years on most " "platforms) this method will lose microsecond accuracy." msgstr "" -#: ../../library/datetime.rst:428 +#: ../../library/datetime.rst:458 msgid "Examples of usage: :class:`timedelta`" msgstr "用法範例::class:`timedelta`" -#: ../../library/datetime.rst:430 +#: ../../library/datetime.rst:460 msgid "An additional example of normalization::" msgstr "" -#: ../../library/datetime.rst:432 +#: ../../library/datetime.rst:462 msgid "" ">>> # Components of another_year add up to exactly 365 days\n" ">>> from datetime import timedelta\n" @@ -734,11 +779,11 @@ msgid "" "31536000.0" msgstr "" -#: ../../library/datetime.rst:442 +#: ../../library/datetime.rst:472 msgid "Examples of :class:`timedelta` arithmetic::" msgstr "" -#: ../../library/datetime.rst:444 +#: ../../library/datetime.rst:474 msgid "" ">>> from datetime import timedelta\n" ">>> year = timedelta(days=365)\n" @@ -768,65 +813,65 @@ msgstr "" ">>> three_years, three_years.days // 365\n" "(datetime.timedelta(days=1095), 3)" -#: ../../library/datetime.rst:461 +#: ../../library/datetime.rst:491 msgid ":class:`date` Objects" msgstr ":class:`date` 物件" -#: ../../library/datetime.rst:463 +#: ../../library/datetime.rst:493 msgid "" "A :class:`date` object represents a date (year, month and day) in an " "idealized calendar, the current Gregorian calendar indefinitely extended in " "both directions." msgstr "" -#: ../../library/datetime.rst:467 +#: ../../library/datetime.rst:497 msgid "" "January 1 of year 1 is called day number 1, January 2 of year 1 is called " "day number 2, and so on. [#]_" msgstr "" -#: ../../library/datetime.rst:472 +#: ../../library/datetime.rst:502 msgid "" "All arguments are required. Arguments must be integers, in the following " "ranges:" msgstr "" -#: ../../library/datetime.rst:475 +#: ../../library/datetime.rst:505 msgid "``MINYEAR <= year <= MAXYEAR``" msgstr "``MINYEAR <= year <= MAXYEAR``" -#: ../../library/datetime.rst:476 +#: ../../library/datetime.rst:506 msgid "``1 <= month <= 12``" msgstr "``1 <= month <= 12``" -#: ../../library/datetime.rst:477 +#: ../../library/datetime.rst:507 msgid "``1 <= day <= number of days in the given month and year``" msgstr "" -#: ../../library/datetime.rst:479 ../../library/datetime.rst:869 +#: ../../library/datetime.rst:509 ../../library/datetime.rst:899 msgid "" "If an argument outside those ranges is given, :exc:`ValueError` is raised." msgstr "" -#: ../../library/datetime.rst:482 ../../library/datetime.rst:874 +#: ../../library/datetime.rst:512 ../../library/datetime.rst:904 msgid "Other constructors, all class methods:" msgstr "" -#: ../../library/datetime.rst:486 +#: ../../library/datetime.rst:516 msgid "Return the current local date." msgstr "回傳目前的本地日期。" -#: ../../library/datetime.rst:488 +#: ../../library/datetime.rst:518 msgid "This is equivalent to ``date.fromtimestamp(time.time())``." msgstr "這等同於 ``date.fromtimestamp(time.time())``。" -#: ../../library/datetime.rst:492 +#: ../../library/datetime.rst:522 msgid "" "Return the local date corresponding to the POSIX timestamp, such as is " "returned by :func:`time.time`." msgstr "" -#: ../../library/datetime.rst:495 +#: ../../library/datetime.rst:525 msgid "" "This may raise :exc:`OverflowError`, if the timestamp is out of the range of " "values supported by the platform C :c:func:`localtime` function, and :exc:" @@ -836,7 +881,7 @@ msgid "" "ignored by :meth:`fromtimestamp`." msgstr "" -#: ../../library/datetime.rst:502 +#: ../../library/datetime.rst:532 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` " @@ -844,45 +889,45 @@ msgid "" "`localtime` failure." msgstr "" -#: ../../library/datetime.rst:511 +#: ../../library/datetime.rst:541 msgid "" "Return the date corresponding to the proleptic Gregorian ordinal, where " "January 1 of year 1 has ordinal 1." msgstr "" -#: ../../library/datetime.rst:514 +#: ../../library/datetime.rst:544 msgid "" ":exc:`ValueError` is raised unless ``1 <= ordinal <= date.max.toordinal()``. " -"For any date *d*, ``date.fromordinal(d.toordinal()) == d``." +"For any date ``d``, ``date.fromordinal(d.toordinal()) == d``." msgstr "" -#: ../../library/datetime.rst:521 +#: ../../library/datetime.rst:551 msgid "" "Return a :class:`date` corresponding to a *date_string* given in any valid " "ISO 8601 format, with the following exceptions:" msgstr "" -#: ../../library/datetime.rst:524 ../../library/datetime.rst:1030 +#: ../../library/datetime.rst:554 ../../library/datetime.rst:1064 msgid "" "Reduced precision dates are not currently supported (``YYYY-MM``, ``YYYY``)." msgstr "" -#: ../../library/datetime.rst:526 ../../library/datetime.rst:1032 +#: ../../library/datetime.rst:556 ../../library/datetime.rst:1066 msgid "" "Extended date representations are not currently supported (``±YYYYYY-MM-" "DD``)." msgstr "" -#: ../../library/datetime.rst:528 ../../library/datetime.rst:1034 +#: ../../library/datetime.rst:558 ../../library/datetime.rst:1068 msgid "Ordinal dates are not currently supported (``YYYY-OOO``)." msgstr "" -#: ../../library/datetime.rst:530 ../../library/datetime.rst:1036 -#: ../../library/datetime.rst:1502 +#: ../../library/datetime.rst:560 ../../library/datetime.rst:1070 +#: ../../library/datetime.rst:1536 msgid "Examples::" msgstr "範例: ::" -#: ../../library/datetime.rst:532 +#: ../../library/datetime.rst:562 msgid "" ">>> from datetime import date\n" ">>> date.fromisoformat('2019-12-04')\n" @@ -900,64 +945,64 @@ msgstr "" ">>> date.fromisoformat('2021-W01-1')\n" "datetime.date(2021, 1, 4)" -#: ../../library/datetime.rst:541 +#: ../../library/datetime.rst:571 msgid "Previously, this method only supported the format ``YYYY-MM-DD``." msgstr "" -#: ../../library/datetime.rst:546 +#: ../../library/datetime.rst:576 msgid "" "Return a :class:`date` corresponding to the ISO calendar date specified by " "year, week and day. This is the inverse of the function :meth:`date." "isocalendar`." msgstr "" -#: ../../library/datetime.rst:556 +#: ../../library/datetime.rst:586 msgid "The earliest representable date, ``date(MINYEAR, 1, 1)``." msgstr "" -#: ../../library/datetime.rst:561 +#: ../../library/datetime.rst:591 msgid "The latest representable date, ``date(MAXYEAR, 12, 31)``." msgstr "" -#: ../../library/datetime.rst:566 +#: ../../library/datetime.rst:596 msgid "" "The smallest possible difference between non-equal date objects, " "``timedelta(days=1)``." msgstr "" -#: ../../library/datetime.rst:574 ../../library/datetime.rst:1132 +#: ../../library/datetime.rst:604 ../../library/datetime.rst:1166 msgid "Between :const:`MINYEAR` and :const:`MAXYEAR` inclusive." msgstr "" -#: ../../library/datetime.rst:579 ../../library/datetime.rst:1137 +#: ../../library/datetime.rst:609 ../../library/datetime.rst:1171 msgid "Between 1 and 12 inclusive." msgstr "在 1 到 12 (含)之間。" -#: ../../library/datetime.rst:584 ../../library/datetime.rst:1142 +#: ../../library/datetime.rst:614 ../../library/datetime.rst:1176 msgid "Between 1 and the number of days in the given month of the given year." msgstr "" -#: ../../library/datetime.rst:592 +#: ../../library/datetime.rst:622 msgid "``date2 = date1 + timedelta``" msgstr "``date2 = date1 + timedelta``" -#: ../../library/datetime.rst:592 +#: ../../library/datetime.rst:622 msgid "``date2`` will be ``timedelta.days`` days after ``date1``. (1)" msgstr "" -#: ../../library/datetime.rst:595 +#: ../../library/datetime.rst:625 msgid "``date2 = date1 - timedelta``" msgstr "``date2 = date1 - timedelta``" -#: ../../library/datetime.rst:595 +#: ../../library/datetime.rst:625 msgid "Computes ``date2`` such that ``date2 + timedelta == date1``. (2)" msgstr "" -#: ../../library/datetime.rst:598 +#: ../../library/datetime.rst:628 msgid "``timedelta = date1 - date2``" msgstr "``timedelta = date1 - date2``" -#: ../../library/datetime.rst:598 ../../library/datetime.rst:1190 +#: ../../library/datetime.rst:628 ../../library/datetime.rst:1224 msgid "\\(3)" msgstr "\\(3)" @@ -969,7 +1014,7 @@ msgstr "``date1 == date2``" msgid "``date1 != date2``" msgstr "``date1 != date2``" -#: ../../library/datetime.rst:600 ../../library/datetime.rst:1192 +#: ../../library/datetime.rst:630 ../../library/datetime.rst:1226 msgid "Equality comparison. (4)" msgstr "" @@ -989,11 +1034,11 @@ msgstr "``date1 <= date2``" msgid "``date1 >= date2``" msgstr "``date1 >= date2``" -#: ../../library/datetime.rst:603 ../../library/datetime.rst:1195 +#: ../../library/datetime.rst:633 ../../library/datetime.rst:1229 msgid "Order comparison. (5)" msgstr "" -#: ../../library/datetime.rst:612 +#: ../../library/datetime.rst:642 msgid "" "*date2* is moved forward in time if ``timedelta.days > 0``, or backward if " "``timedelta.days < 0``. Afterward ``date2 - date1 == timedelta.days``. " @@ -1002,41 +1047,41 @@ msgid "" "`MINYEAR` or larger than :const:`MAXYEAR`." msgstr "" -#: ../../library/datetime.rst:619 +#: ../../library/datetime.rst:649 msgid "``timedelta.seconds`` and ``timedelta.microseconds`` are ignored." msgstr "``timedelta.seconds`` 和 ``timedelta.microseconds`` 被忽略。" -#: ../../library/datetime.rst:622 +#: ../../library/datetime.rst:652 msgid "" "This is exact, and cannot overflow. ``timedelta.seconds`` and ``timedelta." "microseconds`` are 0, and ``date2 + timedelta == date1`` after." msgstr "" -#: ../../library/datetime.rst:626 +#: ../../library/datetime.rst:656 msgid ":class:`date` objects are equal if they represent the same date." msgstr "" -#: ../../library/datetime.rst:628 +#: ../../library/datetime.rst:658 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:633 +#: ../../library/datetime.rst:663 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:637 +#: ../../library/datetime.rst:667 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:641 ../../library/datetime.rst:1263 +#: ../../library/datetime.rst:671 ../../library/datetime.rst:1297 msgid "" "Comparison between :class:`.datetime` object and an instance of the :class:" "`date` subclass that is not a :class:`!datetime` subclass no longer converts " @@ -1045,22 +1090,22 @@ msgid "" "in subclasses." msgstr "" -#: ../../library/datetime.rst:649 +#: ../../library/datetime.rst:679 msgid "" "In Boolean contexts, all :class:`date` objects are considered to be true." msgstr "" -#: ../../library/datetime.rst:655 +#: ../../library/datetime.rst:685 msgid "" -"Return a date with the same value, except for those parameters given new " -"values by whichever keyword arguments are specified." +"Return a new :class:`date` object with the same values, but with specified " +"parameters updated." msgstr "" -#: ../../library/datetime.rst:658 ../../library/datetime.rst:1919 +#: ../../library/datetime.rst:688 ../../library/datetime.rst:1953 msgid "Example::" msgstr "範例: ::" -#: ../../library/datetime.rst:660 +#: ../../library/datetime.rst:690 msgid "" ">>> from datetime import date\n" ">>> d = date(2002, 12, 31)\n" @@ -1072,47 +1117,47 @@ msgstr "" ">>> d.replace(day=26)\n" "datetime.date(2002, 12, 26)" -#: ../../library/datetime.rst:665 +#: ../../library/datetime.rst:695 msgid "" -":class:`date` objects are also supported by generic function :func:`copy." -"replace`." +"The generic function :func:`copy.replace` also supports :class:`date` " +"objects." msgstr "" -#: ../../library/datetime.rst:671 ../../library/datetime.rst:1387 +#: ../../library/datetime.rst:701 ../../library/datetime.rst:1421 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:673 +#: ../../library/datetime.rst:703 msgid "The hours, minutes and seconds are 0, and the DST flag is -1." msgstr "" -#: ../../library/datetime.rst:675 ../../library/datetime.rst:1389 +#: ../../library/datetime.rst:705 ../../library/datetime.rst:1423 msgid "``d.timetuple()`` is equivalent to::" msgstr "``d.timetuple()`` 等價於: ::" -#: ../../library/datetime.rst:677 +#: ../../library/datetime.rst:707 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:679 +#: ../../library/datetime.rst:709 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:685 +#: ../../library/datetime.rst:715 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." +"1 has ordinal 1. For any :class:`date` object ``d``, ``date.fromordinal(d." "toordinal()) == d``." msgstr "" -#: ../../library/datetime.rst:692 +#: ../../library/datetime.rst:722 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 :" @@ -1121,25 +1166,25 @@ msgstr "" "回傳一個代表星期幾的整數,星期一為 0、星期日為 6。例如 ``date(2002, 12, 4)." "weekday() == 2`` 為星期三。也請參考 :meth:`isoweekday`。" -#: ../../library/datetime.rst:699 +#: ../../library/datetime.rst:729 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:706 +#: ../../library/datetime.rst:736 msgid "" "Return a :term:`named tuple` object with three components: ``year``, " "``week`` and ``weekday``." msgstr "" -#: ../../library/datetime.rst:709 +#: ../../library/datetime.rst:739 msgid "" "The ISO calendar is a widely used variant of the Gregorian calendar. [#]_" msgstr "" -#: ../../library/datetime.rst:711 +#: ../../library/datetime.rst:741 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 " @@ -1148,13 +1193,13 @@ msgid "" "Gregorian year." msgstr "" -#: ../../library/datetime.rst:716 +#: ../../library/datetime.rst:746 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:719 +#: ../../library/datetime.rst:749 msgid "" ">>> from datetime import date\n" ">>> date(2003, 12, 29).isocalendar()\n" @@ -1168,16 +1213,16 @@ msgstr "" ">>> date(2004, 1, 4).isocalendar()\n" "datetime.IsoCalendarDate(year=2004, week=1, weekday=7)" -#: ../../library/datetime.rst:725 +#: ../../library/datetime.rst:755 msgid "Result changed from a tuple to a :term:`named tuple`." msgstr "" -#: ../../library/datetime.rst:730 +#: ../../library/datetime.rst:760 msgid "" "Return a string representing the date in ISO 8601 format, ``YYYY-MM-DD``::" msgstr "回傳一以 ISO 8601 格式 ``YYYY-MM-DD`` 表示的日期字串: ::" -#: ../../library/datetime.rst:732 +#: ../../library/datetime.rst:762 msgid "" ">>> from datetime import date\n" ">>> date(2002, 12, 4).isoformat()\n" @@ -1187,15 +1232,15 @@ msgstr "" ">>> date(2002, 12, 4).isoformat()\n" "'2002-12-04'" -#: ../../library/datetime.rst:738 -msgid "For a date *d*, ``str(d)`` is equivalent to ``d.isoformat()``." +#: ../../library/datetime.rst:768 +msgid "For a date ``d``, ``str(d)`` is equivalent to ``d.isoformat()``." msgstr "" -#: ../../library/datetime.rst:743 +#: ../../library/datetime.rst:773 msgid "Return a string representing the date::" msgstr "" -#: ../../library/datetime.rst:745 +#: ../../library/datetime.rst:775 msgid "" ">>> from datetime import date\n" ">>> date(2002, 12, 4).ctime()\n" @@ -1205,22 +1250,22 @@ msgstr "" ">>> date(2002, 12, 4).ctime()\n" "'Wed Dec 4 00:00:00 2002'" -#: ../../library/datetime.rst:749 ../../library/datetime.rst:1573 +#: ../../library/datetime.rst:779 ../../library/datetime.rst:1607 msgid "``d.ctime()`` is equivalent to::" msgstr "``d.ctime()`` 等價於: ::" -#: ../../library/datetime.rst:751 ../../library/datetime.rst:1575 +#: ../../library/datetime.rst:781 ../../library/datetime.rst:1609 msgid "time.ctime(time.mktime(d.timetuple()))" msgstr "time.ctime(time.mktime(d.timetuple()))" -#: ../../library/datetime.rst:753 +#: ../../library/datetime.rst:783 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:760 +#: ../../library/datetime.rst:790 msgid "" "Return a string representing the date, controlled by an explicit format " "string. Format codes referring to hours, minutes or seconds will see 0 " @@ -1228,7 +1273,7 @@ msgid "" "isoformat`." msgstr "" -#: ../../library/datetime.rst:767 +#: ../../library/datetime.rst:797 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" @@ -1280,11 +1325,11 @@ msgstr "" ">>> time_to_birthday.days\n" "202" -#: ../../library/datetime.rst:794 +#: ../../library/datetime.rst:824 msgid "More examples of working with :class:`date`:" msgstr "更多 :class:`date` 的用法範例:" -#: ../../library/datetime.rst:796 +#: ../../library/datetime.rst:826 msgid "" ">>> from datetime import date\n" ">>> d = date.fromordinal(730920) # 730920th day after 1. 1. 0001\n" @@ -1305,7 +1350,7 @@ msgid "" "\n" ">>> # Methods for to extracting 'components' under different calendars\n" ">>> t = d.timetuple()\n" -">>> for i in t: \n" +">>> for i in t:\n" "... print(i)\n" "2002 # year\n" "3 # month\n" @@ -1317,7 +1362,7 @@ msgid "" "70 # 70th day in the year\n" "-1\n" ">>> ic = d.isocalendar()\n" -">>> for i in ic: \n" +">>> for i in ic:\n" "... print(i)\n" "2002 # ISO year\n" "11 # ISO week number\n" @@ -1328,17 +1373,17 @@ msgid "" "datetime.date(2005, 3, 11)" msgstr "" -#: ../../library/datetime.rst:843 +#: ../../library/datetime.rst:873 msgid ":class:`.datetime` Objects" msgstr ":class:`.datetime` 物件" -#: ../../library/datetime.rst:845 +#: ../../library/datetime.rst:875 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:848 +#: ../../library/datetime.rst:878 msgid "" "Like a :class:`date` object, :class:`.datetime` assumes the current " "Gregorian calendar extended in both directions; like a :class:`.time` " @@ -1346,81 +1391,81 @@ msgid "" "every day." msgstr "" -#: ../../library/datetime.rst:852 +#: ../../library/datetime.rst:882 msgid "Constructor:" msgstr "" -#: ../../library/datetime.rst:856 +#: ../../library/datetime.rst:886 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:860 +#: ../../library/datetime.rst:890 msgid "``MINYEAR <= year <= MAXYEAR``," msgstr "``MINYEAR <= year <= MAXYEAR``," -#: ../../library/datetime.rst:861 +#: ../../library/datetime.rst:891 msgid "``1 <= month <= 12``," msgstr "``1 <= month <= 12``," -#: ../../library/datetime.rst:862 +#: ../../library/datetime.rst:892 msgid "``1 <= day <= number of days in the given month and year``," msgstr "" -#: ../../library/datetime.rst:863 ../../library/datetime.rst:1737 +#: ../../library/datetime.rst:893 ../../library/datetime.rst:1771 msgid "``0 <= hour < 24``," msgstr "``0 <= hour < 24``," -#: ../../library/datetime.rst:864 ../../library/datetime.rst:1738 +#: ../../library/datetime.rst:894 ../../library/datetime.rst:1772 msgid "``0 <= minute < 60``," msgstr "``0 <= minute < 60``," -#: ../../library/datetime.rst:865 ../../library/datetime.rst:1739 +#: ../../library/datetime.rst:895 ../../library/datetime.rst:1773 msgid "``0 <= second < 60``," msgstr "``0 <= second < 60``," -#: ../../library/datetime.rst:866 ../../library/datetime.rst:1740 +#: ../../library/datetime.rst:896 ../../library/datetime.rst:1774 msgid "``0 <= microsecond < 1000000``," msgstr "``0 <= microsecond < 1000000``," -#: ../../library/datetime.rst:867 ../../library/datetime.rst:1741 +#: ../../library/datetime.rst:897 ../../library/datetime.rst:1775 msgid "``fold in [0, 1]``." msgstr "" -#: ../../library/datetime.rst:871 ../../library/datetime.rst:1308 -#: ../../library/datetime.rst:1886 +#: ../../library/datetime.rst:901 ../../library/datetime.rst:1342 +#: ../../library/datetime.rst:1920 msgid "Added the *fold* parameter." msgstr "新增 *fold* 參數。" -#: ../../library/datetime.rst:878 +#: ../../library/datetime.rst:908 msgid "Return the current local date and time, with :attr:`.tzinfo` ``None``." msgstr "回傳目前的本地日期與時間,且 :attr:`.tzinfo` 為 ``None``。" -#: ../../library/datetime.rst:880 +#: ../../library/datetime.rst:910 msgid "Equivalent to::" msgstr "等價於: ::" -#: ../../library/datetime.rst:882 +#: ../../library/datetime.rst:912 msgid "datetime.fromtimestamp(time.time())" msgstr "datetime.fromtimestamp(time.time())" -#: ../../library/datetime.rst:884 +#: ../../library/datetime.rst:914 msgid "See also :meth:`now`, :meth:`fromtimestamp`." msgstr "也請見 :meth:`now`、:meth:`fromtimestamp`。" -#: ../../library/datetime.rst:886 +#: ../../library/datetime.rst:916 msgid "" "This method is functionally equivalent to :meth:`now`, but without a ``tz`` " "parameter." msgstr "" -#: ../../library/datetime.rst:891 +#: ../../library/datetime.rst:921 msgid "Return the current local date and time." msgstr "" -#: ../../library/datetime.rst:893 +#: ../../library/datetime.rst:923 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 " @@ -1431,28 +1476,34 @@ msgstr "" "供比透過 :func:`time.time` 取得的時間戳記更多位數的資訊(例如,這在有提供 C :" "c:func:`gettimeofday` 函式的平台上可能可行)。" -#: ../../library/datetime.rst:899 +#: ../../library/datetime.rst:929 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:902 +#: ../../library/datetime.rst:932 msgid "This function is preferred over :meth:`today` and :meth:`utcnow`." msgstr "" -#: ../../library/datetime.rst:907 +#: ../../library/datetime.rst:936 +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 msgid "Return the current UTC date and time, with :attr:`.tzinfo` ``None``." msgstr "" -#: ../../library/datetime.rst:909 +#: ../../library/datetime.rst:943 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:915 +#: ../../library/datetime.rst:949 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 " @@ -1460,11 +1511,11 @@ msgid "" "current time in UTC is by calling ``datetime.now(timezone.utc)``." msgstr "" -#: ../../library/datetime.rst:922 -msgid "Use :meth:`datetime.now` with :attr:`UTC` instead." +#: ../../library/datetime.rst:956 +msgid "Use :meth:`datetime.now` with :const:`UTC` instead." msgstr "" -#: ../../library/datetime.rst:927 +#: ../../library/datetime.rst:961 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 " @@ -1472,13 +1523,13 @@ msgid "" "time, and the returned :class:`.datetime` object is naive." msgstr "" -#: ../../library/datetime.rst:932 +#: ../../library/datetime.rst:966 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:935 +#: ../../library/datetime.rst:969 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` " @@ -1491,7 +1542,7 @@ msgid "" "preferred over :meth:`utcfromtimestamp`." msgstr "" -#: ../../library/datetime.rst:946 +#: ../../library/datetime.rst:980 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` " @@ -1499,17 +1550,17 @@ msgid "" "`ValueError` on :c:func:`localtime` or :c:func:`gmtime` failure." msgstr "" -#: ../../library/datetime.rst:953 +#: ../../library/datetime.rst:987 msgid ":meth:`fromtimestamp` may return instances with :attr:`.fold` set to 1." msgstr "" -#: ../../library/datetime.rst:958 +#: ../../library/datetime.rst:992 msgid "" "Return the UTC :class:`.datetime` corresponding to the POSIX timestamp, " "with :attr:`.tzinfo` ``None``. (The resulting object is naive.)" msgstr "" -#: ../../library/datetime.rst:961 +#: ../../library/datetime.rst:995 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:" @@ -1517,33 +1568,33 @@ msgid "" "to years in 1970 through 2038." msgstr "" -#: ../../library/datetime.rst:966 +#: ../../library/datetime.rst:1000 msgid "To get an aware :class:`.datetime` object, call :meth:`fromtimestamp`::" msgstr "" -#: ../../library/datetime.rst:968 +#: ../../library/datetime.rst:1002 msgid "datetime.fromtimestamp(timestamp, timezone.utc)" msgstr "datetime.fromtimestamp(timestamp, timezone.utc)" -#: ../../library/datetime.rst:970 +#: ../../library/datetime.rst:1004 msgid "" "On the POSIX compliant platforms, it is equivalent to the following " "expression::" msgstr "" -#: ../../library/datetime.rst:973 +#: ../../library/datetime.rst:1007 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:975 +#: ../../library/datetime.rst:1009 msgid "" "except the latter formula always supports the full years range: between :" "const:`MINYEAR` and :const:`MAXYEAR` inclusive." msgstr "" -#: ../../library/datetime.rst:980 +#: ../../library/datetime.rst:1014 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 " @@ -1552,7 +1603,7 @@ msgid "" "tz=timezone.utc)``." msgstr "" -#: ../../library/datetime.rst:986 +#: ../../library/datetime.rst:1020 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` " @@ -1560,11 +1611,11 @@ msgid "" "`gmtime` failure." msgstr "" -#: ../../library/datetime.rst:994 -msgid "Use :meth:`datetime.fromtimestamp` with :attr:`UTC` instead." +#: ../../library/datetime.rst:1028 +msgid "Use :meth:`datetime.fromtimestamp` with :const:`UTC` instead." msgstr "" -#: ../../library/datetime.rst:999 +#: ../../library/datetime.rst:1033 msgid "" "Return the :class:`.datetime` corresponding to the proleptic Gregorian " "ordinal, where January 1 of year 1 has ordinal 1. :exc:`ValueError` is " @@ -1573,7 +1624,7 @@ msgid "" "is ``None``." msgstr "" -#: ../../library/datetime.rst:1007 +#: ../../library/datetime.rst:1041 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 " @@ -1584,35 +1635,36 @@ msgid "" "attr:`.tzinfo` attributes are ignored." msgstr "" -#: ../../library/datetime.rst:1015 +#: ../../library/datetime.rst:1049 msgid "" -"For any :class:`.datetime` object *d*, ``d == datetime.combine(d.date(), d." +"For any :class:`.datetime` object ``d``, ``d == datetime.combine(d.date(), d." "time(), d.tzinfo)``." msgstr "" -#: ../../library/datetime.rst:1018 +#: ../../library/datetime.rst:1052 msgid "Added the *tzinfo* argument." msgstr "新增 *tzinfo* 引數。" -#: ../../library/datetime.rst:1024 +#: ../../library/datetime.rst:1058 msgid "" "Return a :class:`.datetime` corresponding to a *date_string* in any valid " "ISO 8601 format, with the following exceptions:" msgstr "" -#: ../../library/datetime.rst:1027 ../../library/datetime.rst:1837 +#: ../../library/datetime.rst:1061 ../../library/datetime.rst:1871 msgid "Time zone offsets may have fractional seconds." msgstr "" -#: ../../library/datetime.rst:1028 +#: ../../library/datetime.rst:1062 msgid "The ``T`` separator may be replaced by any single unicode character." msgstr "" -#: ../../library/datetime.rst:1029 ../../library/datetime.rst:1842 +#: ../../library/datetime.rst:1063 ../../library/datetime.rst:1876 msgid "Fractional hours and minutes are not supported." msgstr "" -#: ../../library/datetime.rst:1038 +#: ../../library/datetime.rst:1072 +#, fuzzy msgid "" ">>> from datetime import datetime\n" ">>> datetime.fromisoformat('2011-11-04')\n" @@ -1632,7 +1684,7 @@ msgid "" ">>> datetime.fromisoformat('2011-11-04 00:05:23.283+00:00')\n" "datetime.datetime(2011, 11, 4, 0, 5, 23, 283000, tzinfo=datetime.timezone." "utc)\n" -">>> datetime.fromisoformat('2011-11-04T00:05:23+04:00') \n" +">>> datetime.fromisoformat('2011-11-04T00:05:23+04:00')\n" "datetime.datetime(2011, 11, 4, 0, 5, 23,\n" " tzinfo=datetime.timezone(datetime.timedelta(seconds=14400)))" msgstr "" @@ -1658,13 +1710,13 @@ msgstr "" "datetime.datetime(2011, 11, 4, 0, 5, 23,\n" " tzinfo=datetime.timezone(datetime.timedelta(seconds=14400)))" -#: ../../library/datetime.rst:1060 +#: ../../library/datetime.rst:1094 msgid "" "Previously, this method only supported formats that could be emitted by :" "meth:`date.isoformat` or :meth:`datetime.isoformat`." msgstr "" -#: ../../library/datetime.rst:1067 +#: ../../library/datetime.rst:1101 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 " @@ -1672,23 +1724,23 @@ msgid "" "`datetime.isocalendar`." msgstr "" -#: ../../library/datetime.rst:1076 +#: ../../library/datetime.rst:1110 msgid "" "Return a :class:`.datetime` corresponding to *date_string*, parsed according " "to *format*." msgstr "" -#: ../../library/datetime.rst:1079 +#: ../../library/datetime.rst:1113 msgid "" "If *format* does not contain microseconds or time zone information, this is " "equivalent to::" msgstr "" -#: ../../library/datetime.rst:1081 ../../library/datetime.rst:2562 +#: ../../library/datetime.rst:1115 ../../library/datetime.rst:2596 msgid "datetime(*(time.strptime(date_string, format)[0:6]))" msgstr "datetime(*(time.strptime(date_string, format)[0:6]))" -#: ../../library/datetime.rst:1083 +#: ../../library/datetime.rst:1117 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. " @@ -1696,7 +1748,7 @@ msgid "" "fromisoformat`." msgstr "" -#: ../../library/datetime.rst:1090 +#: ../../library/datetime.rst:1124 msgid "" "If *format* specifies a day of month without a year a :exc:" "`DeprecationWarning` is now emitted. This is to avoid a quadrennial leap " @@ -1707,54 +1759,54 @@ msgid "" "not have a year, explicitly add a year that is a leap year before parsing:" msgstr "" -#: ../../library/datetime.rst:1099 +#: ../../library/datetime.rst:1133 msgid "" ">>> from datetime import datetime\n" ">>> date_string = \"02/29\"\n" ">>> when = datetime.strptime(f\"{date_string};1984\", \"%m/%d;%Y\") # " "Avoids leap year bug.\n" -">>> when.strftime(\"%B %d\") \n" +">>> when.strftime(\"%B %d\")\n" "'February 29'" msgstr "" -#: ../../library/datetime.rst:1112 +#: ../../library/datetime.rst:1146 msgid "" "The earliest representable :class:`.datetime`, ``datetime(MINYEAR, 1, 1, " "tzinfo=None)``." msgstr "" -#: ../../library/datetime.rst:1118 +#: ../../library/datetime.rst:1152 msgid "" "The latest representable :class:`.datetime`, ``datetime(MAXYEAR, 12, 31, 23, " "59, 59, 999999, tzinfo=None)``." msgstr "" -#: ../../library/datetime.rst:1124 +#: ../../library/datetime.rst:1158 msgid "" "The smallest possible difference between non-equal :class:`.datetime` " "objects, ``timedelta(microseconds=1)``." msgstr "" -#: ../../library/datetime.rst:1147 ../../library/datetime.rst:1770 +#: ../../library/datetime.rst:1181 ../../library/datetime.rst:1804 msgid "In ``range(24)``." msgstr "" -#: ../../library/datetime.rst:1152 ../../library/datetime.rst:1157 -#: ../../library/datetime.rst:1775 ../../library/datetime.rst:1780 +#: ../../library/datetime.rst:1186 ../../library/datetime.rst:1191 +#: ../../library/datetime.rst:1809 ../../library/datetime.rst:1814 msgid "In ``range(60)``." msgstr "" -#: ../../library/datetime.rst:1162 ../../library/datetime.rst:1785 +#: ../../library/datetime.rst:1196 ../../library/datetime.rst:1819 msgid "In ``range(1000000)``." msgstr "" -#: ../../library/datetime.rst:1167 +#: ../../library/datetime.rst:1201 msgid "" "The object passed as the *tzinfo* argument to the :class:`.datetime` " "constructor, or ``None`` if none was passed." msgstr "" -#: ../../library/datetime.rst:1173 ../../library/datetime.rst:1796 +#: ../../library/datetime.rst:1207 ../../library/datetime.rst:1830 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 " @@ -1764,26 +1816,26 @@ msgid "" "time representation." msgstr "" -#: ../../library/datetime.rst:1186 +#: ../../library/datetime.rst:1220 msgid "``datetime2 = datetime1 + timedelta``" msgstr "``datetime2 = datetime1 + timedelta``" -#: ../../library/datetime.rst:1186 ../../library/datetime.rst:2409 -#: ../../library/datetime.rst:2414 ../../library/datetime.rst:2426 -#: ../../library/datetime.rst:2431 ../../library/datetime.rst:2491 -#: ../../library/datetime.rst:2496 ../../library/datetime.rst:2500 +#: ../../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 msgid "\\(1)" msgstr "\\(1)" -#: ../../library/datetime.rst:1188 +#: ../../library/datetime.rst:1222 msgid "``datetime2 = datetime1 - timedelta``" msgstr "``datetime2 = datetime1 - timedelta``" -#: ../../library/datetime.rst:1188 ../../library/datetime.rst:2442 +#: ../../library/datetime.rst:1222 ../../library/datetime.rst:2476 msgid "\\(2)" msgstr "\\(2)" -#: ../../library/datetime.rst:1190 +#: ../../library/datetime.rst:1224 msgid "``timedelta = datetime1 - datetime2``" msgstr "``timedelta = datetime1 - datetime2``" @@ -1811,7 +1863,7 @@ msgstr "``datetime1 <= datetime2``" msgid "``datetime1 >= datetime2``" msgstr "``datetime1 >= datetime2``" -#: ../../library/datetime.rst:1202 +#: ../../library/datetime.rst:1236 msgid "" "``datetime2`` is a duration of ``timedelta`` removed from ``datetime1``, " "moving forward in time if ``timedelta.days > 0``, or backward if ``timedelta." @@ -1822,7 +1874,7 @@ msgid "" "adjustments are done even if the input is an aware object." msgstr "" -#: ../../library/datetime.rst:1211 +#: ../../library/datetime.rst:1245 msgid "" "Computes the ``datetime2`` such that ``datetime2 + timedelta == datetime1``. " "As for addition, the result has the same :attr:`~.datetime.tzinfo` attribute " @@ -1830,41 +1882,41 @@ msgid "" "input is aware." msgstr "" -#: ../../library/datetime.rst:1216 +#: ../../library/datetime.rst:1250 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:1220 +#: ../../library/datetime.rst:1254 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 " -"the result is a :class:`timedelta` object *t* such that ``datetime2 + t == " +"the result is a :class:`timedelta` object ``t`` such that ``datetime2 + t == " "datetime1``. No time zone adjustments are done in this case." msgstr "" -#: ../../library/datetime.rst:1225 +#: ../../library/datetime.rst:1259 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 datetimes. " -"The result is ``(a.replace(tzinfo=None) - a.utcoffset()) - (b." +"``a-b`` acts as if ``a`` and ``b`` were first converted to naive UTC " +"datetimes. The result is ``(a.replace(tzinfo=None) - a.utcoffset()) - (b." "replace(tzinfo=None) - b.utcoffset())`` except that the implementation never " "overflows." msgstr "" -#: ../../library/datetime.rst:1231 +#: ../../library/datetime.rst:1265 msgid "" ":class:`.datetime` objects are equal if they represent the same date and " "time, taking into account the time zone." msgstr "" -#: ../../library/datetime.rst:1234 +#: ../../library/datetime.rst:1268 msgid "Naive and aware :class:`!datetime` objects are never equal." msgstr "" -#: ../../library/datetime.rst:1236 +#: ../../library/datetime.rst:1270 msgid "" "If both comparands are aware, and have the same :attr:`!tzinfo` attribute, " "the :attr:`!tzinfo` and :attr:`~.datetime.fold` attributes are ignored and " @@ -1875,19 +1927,19 @@ msgid "" "interval are never equal to :class:`!datetime` instances in other time zone." msgstr "" -#: ../../library/datetime.rst:1246 +#: ../../library/datetime.rst:1280 msgid "" "*datetime1* is considered less than *datetime2* when *datetime1* precedes " "*datetime2* in time, taking into account the time zone." msgstr "" -#: ../../library/datetime.rst:1249 +#: ../../library/datetime.rst:1283 msgid "" "Order comparison between naive and aware :class:`.datetime` objects raises :" "exc:`TypeError`." msgstr "" -#: ../../library/datetime.rst:1252 +#: ../../library/datetime.rst:1286 msgid "" "If both comparands are aware, and have the same :attr:`!tzinfo` attribute, " "the :attr:`!tzinfo` and :attr:`~.datetime.fold` attributes are ignored and " @@ -1897,61 +1949,61 @@ msgid "" "implementation never overflows." msgstr "" -#: ../../library/datetime.rst:1259 +#: ../../library/datetime.rst:1293 msgid "" "Equality comparisons between aware and naive :class:`.datetime` instances " "don't raise :exc:`TypeError`." msgstr "" -#: ../../library/datetime.rst:1275 +#: ../../library/datetime.rst:1309 msgid "Return :class:`date` object with same year, month and day." msgstr "" -#: ../../library/datetime.rst:1280 +#: ../../library/datetime.rst:1314 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:1283 ../../library/datetime.rst:1292 +#: ../../library/datetime.rst:1317 ../../library/datetime.rst:1326 msgid "The fold value is copied to the returned :class:`.time` object." msgstr "" -#: ../../library/datetime.rst:1289 +#: ../../library/datetime.rst:1323 msgid "" "Return :class:`.time` object with same hour, minute, second, microsecond, " "fold, and tzinfo attributes. See also method :meth:`time`." msgstr "" -#: ../../library/datetime.rst:1300 +#: ../../library/datetime.rst:1334 msgid "" -"Return a datetime with the same attributes, except for those attributes " -"given new values by whichever keyword arguments are specified. Note that " -"``tzinfo=None`` can be specified to create a naive datetime from an aware " -"datetime with no conversion of date and time data." +"Return a new :class:`datetime` object with the same attributes, but with " +"specified parameters updated. Note that ``tzinfo=None`` can be specified to " +"create a naive datetime from an aware datetime with no conversion of date " +"and time data." msgstr "" -#: ../../library/datetime.rst:1305 +#: ../../library/datetime.rst:1339 msgid "" ":class:`.datetime` objects are also supported by generic function :func:" "`copy.replace`." msgstr "" -#: ../../library/datetime.rst:1314 +#: ../../library/datetime.rst:1348 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:1318 +#: ../../library/datetime.rst:1352 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:1322 +#: ../../library/datetime.rst:1356 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 " @@ -1959,7 +2011,7 @@ msgid "" "with the zone name and offset obtained from the OS." msgstr "" -#: ../../library/datetime.rst:1327 +#: ../../library/datetime.rst:1361 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 " @@ -1968,7 +2020,7 @@ msgid "" "date and time data as ``dt - dt.utcoffset()``." msgstr "" -#: ../../library/datetime.rst:1333 +#: ../../library/datetime.rst:1367 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." @@ -1977,14 +2029,14 @@ msgid "" "use ``dt.replace(tzinfo=None)``." msgstr "" -#: ../../library/datetime.rst:1338 +#: ../../library/datetime.rst:1372 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:1342 +#: ../../library/datetime.rst:1376 msgid "" "def astimezone(self, tz):\n" " if self.tzinfo is tz:\n" @@ -1995,49 +2047,49 @@ msgid "" " return tz.fromutc(utc)" msgstr "" -#: ../../library/datetime.rst:1350 +#: ../../library/datetime.rst:1384 msgid "*tz* now can be omitted." msgstr "" -#: ../../library/datetime.rst:1353 +#: ../../library/datetime.rst:1387 msgid "" "The :meth:`astimezone` method can now be called on naive instances that are " "presumed to represent system local time." msgstr "" -#: ../../library/datetime.rst:1360 +#: ../../library/datetime.rst:1394 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:1364 ../../library/datetime.rst:1959 -#: ../../library/datetime.rst:2066 ../../library/datetime.rst:2311 -#: ../../library/datetime.rst:2323 ../../library/datetime.rst:2635 +#: ../../library/datetime.rst:1398 ../../library/datetime.rst:1993 +#: ../../library/datetime.rst:2100 ../../library/datetime.rst:2345 +#: ../../library/datetime.rst:2357 ../../library/datetime.rst:2669 msgid "The UTC offset is not restricted to a whole number of minutes." msgstr "" -#: ../../library/datetime.rst:1370 +#: ../../library/datetime.rst:1404 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:1374 ../../library/datetime.rst:1969 -#: ../../library/datetime.rst:2120 +#: ../../library/datetime.rst:1408 ../../library/datetime.rst:2003 +#: ../../library/datetime.rst:2154 msgid "The DST offset is not restricted to a whole number of minutes." msgstr "" -#: ../../library/datetime.rst:1380 +#: ../../library/datetime.rst:1414 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:1391 +#: ../../library/datetime.rst:1425 msgid "" "time.struct_time((d.year, d.month, d.day,\n" " d.hour, d.minute, d.second,\n" @@ -2047,7 +2099,7 @@ msgstr "" " d.hour, d.minute, d.second,\n" " d.weekday(), yday, dst))" -#: ../../library/datetime.rst:1395 +#: ../../library/datetime.rst:1429 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 :" @@ -2058,24 +2110,24 @@ msgid "" "to 0." msgstr "" -#: ../../library/datetime.rst:1406 +#: ../../library/datetime.rst:1440 msgid "" -"If :class:`.datetime` instance *d* is naive, this is the same as ``d." +"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 " "regardless of what ``d.dst()`` returns. DST is never in effect for a UTC " "time." msgstr "" -#: ../../library/datetime.rst:1410 +#: ../../library/datetime.rst:1444 msgid "" -"If *d* is aware, *d* is normalized to UTC time, by subtracting ``d." +"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 " "returned. :attr:`!tm_isdst` is forced to 0. Note that an :exc:" "`OverflowError` may be raised if ``d.year`` was ``MINYEAR`` or ``MAXYEAR`` " "and UTC adjustment spills over a year boundary." msgstr "" -#: ../../library/datetime.rst:1419 +#: ../../library/datetime.rst:1453 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 " @@ -2085,20 +2137,20 @@ msgid "" "meth:`.datetime.timetuple`." msgstr "" -#: ../../library/datetime.rst:1428 +#: ../../library/datetime.rst:1462 msgid "" "Return the proleptic Gregorian ordinal of the date. The same as ``self." "date().toordinal()``." msgstr "" -#: ../../library/datetime.rst:1433 +#: ../../library/datetime.rst:1467 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:1437 +#: ../../library/datetime.rst:1471 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 " @@ -2108,22 +2160,22 @@ msgid "" "future." msgstr "" -#: ../../library/datetime.rst:1444 +#: ../../library/datetime.rst:1478 msgid "" "For aware :class:`.datetime` instances, the return value is computed as::" msgstr "" -#: ../../library/datetime.rst:1447 +#: ../../library/datetime.rst:1481 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:1451 +#: ../../library/datetime.rst:1485 msgid "" "The :meth:`timestamp` method uses the :attr:`.fold` attribute to " "disambiguate the times during a repeated interval." msgstr "" -#: ../../library/datetime.rst:1457 +#: ../../library/datetime.rst:1491 msgid "" "There is no method to obtain the POSIX timestamp directly from a naive :" "class:`.datetime` instance representing UTC time. If your application uses " @@ -2131,57 +2183,57 @@ msgid "" "the POSIX timestamp by supplying ``tzinfo=timezone.utc``::" msgstr "" -#: ../../library/datetime.rst:1463 +#: ../../library/datetime.rst:1497 msgid "timestamp = dt.replace(tzinfo=timezone.utc).timestamp()" msgstr "timestamp = dt.replace(tzinfo=timezone.utc).timestamp()" -#: ../../library/datetime.rst:1465 +#: ../../library/datetime.rst:1499 msgid "or by calculating the timestamp directly::" msgstr "" -#: ../../library/datetime.rst:1467 +#: ../../library/datetime.rst:1501 msgid "timestamp = (dt - datetime(1970, 1, 1)) / timedelta(seconds=1)" msgstr "timestamp = (dt - datetime(1970, 1, 1)) / timedelta(seconds=1)" -#: ../../library/datetime.rst:1471 +#: ../../library/datetime.rst:1505 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:1477 +#: ../../library/datetime.rst:1511 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:1484 +#: ../../library/datetime.rst:1518 msgid "" "Return a :term:`named tuple` with three components: ``year``, ``week`` and " "``weekday``. The same as ``self.date().isocalendar()``." msgstr "" -#: ../../library/datetime.rst:1490 +#: ../../library/datetime.rst:1524 msgid "Return a string representing the date and time in ISO 8601 format:" msgstr "" -#: ../../library/datetime.rst:1492 +#: ../../library/datetime.rst:1526 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:1493 +#: ../../library/datetime.rst:1527 msgid "``YYYY-MM-DDTHH:MM:SS``, if :attr:`microsecond` is 0" msgstr "``YYYY-MM-DDTHH:MM:SS``,如果 :attr:`microsecond` 是 0" -#: ../../library/datetime.rst:1495 +#: ../../library/datetime.rst:1529 msgid "" "If :meth:`utcoffset` does not return ``None``, a string is appended, giving " "the UTC offset:" msgstr "" "如果 :meth:`utcoffset` 没有回傳 ``None``,則會附加一个字串,給出 UTC 偏移:" -#: ../../library/datetime.rst:1498 +#: ../../library/datetime.rst:1532 msgid "" "``YYYY-MM-DDTHH:MM:SS.ffffff+HH:MM[:SS[.ffffff]]``, if :attr:`microsecond` " "is not 0" @@ -2189,13 +2241,13 @@ msgstr "" "``YYYY-MM-DDTHH:MM:SS.ffffff+HH:MM[:SS[.ffffff]]``,如果 :attr:`microsecond` " "不是 0" -#: ../../library/datetime.rst:1500 +#: ../../library/datetime.rst:1534 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:1504 +#: ../../library/datetime.rst:1538 msgid "" ">>> from datetime import datetime, timezone\n" ">>> datetime(2019, 5, 18, 15, 17, 8, 132263).isoformat()\n" @@ -2209,13 +2261,13 @@ msgstr "" ">>> datetime(2019, 5, 18, 15, 17, tzinfo=timezone.utc).isoformat()\n" "'2019-05-18T15:17:00+00:00'" -#: ../../library/datetime.rst:1510 +#: ../../library/datetime.rst:1544 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:1513 +#: ../../library/datetime.rst:1547 msgid "" ">>> from datetime import tzinfo, timedelta, datetime\n" ">>> class TZ(tzinfo):\n" @@ -2229,56 +2281,57 @@ msgid "" "'2009-11-27T00:00:00.000100-06:39'" msgstr "" -#: ../../library/datetime.rst:1524 ../../library/datetime.rst:1899 +#: ../../library/datetime.rst:1558 ../../library/datetime.rst:1933 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:1528 ../../library/datetime.rst:1903 +#: ../../library/datetime.rst:1562 ../../library/datetime.rst:1937 msgid "" "``'auto'``: Same as ``'seconds'`` if :attr:`microsecond` is 0, same as " "``'microseconds'`` otherwise." msgstr "" -#: ../../library/datetime.rst:1530 ../../library/datetime.rst:1905 +#: ../../library/datetime.rst:1564 ../../library/datetime.rst:1939 msgid "``'hours'``: Include the :attr:`hour` in the two-digit ``HH`` format." msgstr "" -#: ../../library/datetime.rst:1531 ../../library/datetime.rst:1906 +#: ../../library/datetime.rst:1565 ../../library/datetime.rst:1940 msgid "" "``'minutes'``: Include :attr:`hour` and :attr:`minute` in ``HH:MM`` format." msgstr "" -#: ../../library/datetime.rst:1532 ../../library/datetime.rst:1907 +#: ../../library/datetime.rst:1566 ../../library/datetime.rst:1941 msgid "" "``'seconds'``: Include :attr:`hour`, :attr:`minute`, and :attr:`second` in " "``HH:MM:SS`` format." msgstr "" -#: ../../library/datetime.rst:1534 ../../library/datetime.rst:1909 +#: ../../library/datetime.rst:1568 ../../library/datetime.rst:1943 msgid "" "``'milliseconds'``: Include full time, but truncate fractional second part " "to milliseconds. ``HH:MM:SS.sss`` format." msgstr "" -#: ../../library/datetime.rst:1536 ../../library/datetime.rst:1911 +#: ../../library/datetime.rst:1570 ../../library/datetime.rst:1945 msgid "``'microseconds'``: Include full time in ``HH:MM:SS.ffffff`` format." msgstr "" -#: ../../library/datetime.rst:1540 ../../library/datetime.rst:1915 +#: ../../library/datetime.rst:1574 ../../library/datetime.rst:1949 msgid "Excluded time components are truncated, not rounded." msgstr "" -#: ../../library/datetime.rst:1542 +#: ../../library/datetime.rst:1576 msgid ":exc:`ValueError` will be raised on an invalid *timespec* argument::" msgstr "" -#: ../../library/datetime.rst:1545 +#: ../../library/datetime.rst:1579 +#, fuzzy msgid "" ">>> from datetime import datetime\n" -">>> datetime.now().isoformat(timespec='minutes') \n" +">>> datetime.now().isoformat(timespec='minutes')\n" "'2002-12-25T00:00'\n" ">>> dt = datetime(2015, 1, 1, 12, 30, 59, 0)\n" ">>> dt.isoformat(timespec='microseconds')\n" @@ -2291,21 +2344,21 @@ msgstr "" ">>> dt.isoformat(timespec='microseconds')\n" "'2015-01-01T12:30:59.000000'" -#: ../../library/datetime.rst:1552 ../../library/datetime.rst:1930 +#: ../../library/datetime.rst:1586 ../../library/datetime.rst:1964 msgid "Added the *timespec* parameter." msgstr "新增 *timespec* 參數。" -#: ../../library/datetime.rst:1558 +#: ../../library/datetime.rst:1592 msgid "" -"For a :class:`.datetime` instance *d*, ``str(d)`` is equivalent to ``d." +"For a :class:`.datetime` instance ``d``, ``str(d)`` is equivalent to ``d." "isoformat(' ')``." msgstr "" -#: ../../library/datetime.rst:1564 +#: ../../library/datetime.rst:1598 msgid "Return a string representing the date and time::" msgstr "" -#: ../../library/datetime.rst:1566 +#: ../../library/datetime.rst:1600 msgid "" ">>> from datetime import datetime\n" ">>> datetime(2002, 12, 4, 20, 30, 40).ctime()\n" @@ -2315,27 +2368,27 @@ msgstr "" ">>> datetime(2002, 12, 4, 20, 30, 40).ctime()\n" "'Wed Dec 4 20:30:40 2002'" -#: ../../library/datetime.rst:1570 +#: ../../library/datetime.rst:1604 msgid "" "The output string will *not* include time zone information, regardless of " "whether the input is aware or naive." msgstr "" -#: ../../library/datetime.rst:1577 +#: ../../library/datetime.rst:1611 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:1584 +#: ../../library/datetime.rst:1618 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:1591 +#: ../../library/datetime.rst:1625 msgid "" "Same as :meth:`.datetime.strftime`. This makes it possible to specify a " "format string for a :class:`.datetime` object in :ref:`formatted string " @@ -2343,15 +2396,15 @@ msgid "" "`strftime-strptime-behavior` and :meth:`datetime.isoformat`." msgstr "" -#: ../../library/datetime.rst:1598 +#: ../../library/datetime.rst:1632 msgid "Examples of Usage: :class:`.datetime`" msgstr "用法範例::class:`.datetime`" -#: ../../library/datetime.rst:1600 +#: ../../library/datetime.rst:1634 msgid "Examples of working with :class:`.datetime` objects:" msgstr "更多 :class:`.datetime` 的用法範例:" -#: ../../library/datetime.rst:1602 +#: ../../library/datetime.rst:1636 msgid "" ">>> from datetime import datetime, date, time, timezone\n" "\n" @@ -2362,9 +2415,9 @@ msgid "" "datetime.datetime(2005, 7, 14, 12, 30)\n" "\n" ">>> # Using datetime.now()\n" -">>> datetime.now() \n" +">>> datetime.now()\n" "datetime.datetime(2007, 12, 6, 16, 29, 43, 79043) # GMT +1\n" -">>> datetime.now(timezone.utc) \n" +">>> datetime.now(timezone.utc)\n" "datetime.datetime(2007, 12, 6, 15, 29, 43, 79060, tzinfo=datetime.timezone." "utc)\n" "\n" @@ -2375,7 +2428,7 @@ msgid "" "\n" ">>> # Using datetime.timetuple() to get tuple of all attributes\n" ">>> tt = dt.timetuple()\n" -">>> for it in tt: \n" +">>> for it in tt:\n" "... print(it)\n" "...\n" "2006 # year\n" @@ -2390,7 +2443,7 @@ msgid "" "\n" ">>> # Date in ISO format\n" ">>> ic = dt.isocalendar()\n" -">>> for it in ic: \n" +">>> for it in ic:\n" "... print(it)\n" "...\n" "2006 # ISO year\n" @@ -2405,14 +2458,14 @@ msgid "" "'The day is 21, the month is November, the time is 04:30PM.'" msgstr "" -#: ../../library/datetime.rst:1653 +#: ../../library/datetime.rst:1687 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:1657 +#: ../../library/datetime.rst:1691 msgid "" "from datetime import timedelta, datetime, tzinfo, timezone\n" "\n" @@ -2459,11 +2512,11 @@ msgid "" " return \"+04\"" msgstr "" -#: ../../library/datetime.rst:1700 +#: ../../library/datetime.rst:1734 msgid "Usage of ``KabulTz`` from above::" msgstr "" -#: ../../library/datetime.rst:1702 +#: ../../library/datetime.rst:1736 msgid "" ">>> tz1 = KabulTz()\n" "\n" @@ -2487,63 +2540,63 @@ msgid "" "True" msgstr "" -#: ../../library/datetime.rst:1726 +#: ../../library/datetime.rst:1760 msgid ":class:`.time` Objects" msgstr ":class:`.time` 物件" -#: ../../library/datetime.rst:1728 +#: ../../library/datetime.rst:1762 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:1733 +#: ../../library/datetime.rst:1767 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:1743 +#: ../../library/datetime.rst:1777 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:1751 +#: ../../library/datetime.rst:1785 msgid "The earliest representable :class:`.time`, ``time(0, 0, 0, 0)``." msgstr "" -#: ../../library/datetime.rst:1756 +#: ../../library/datetime.rst:1790 msgid "The latest representable :class:`.time`, ``time(23, 59, 59, 999999)``." msgstr "" -#: ../../library/datetime.rst:1761 +#: ../../library/datetime.rst:1795 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:1790 +#: ../../library/datetime.rst:1824 msgid "" "The object passed as the tzinfo argument to the :class:`.time` constructor, " "or ``None`` if none was passed." msgstr "" -#: ../../library/datetime.rst:1804 +#: ../../library/datetime.rst:1838 msgid "" -":class:`.time` objects support equality and order comparisons, where *a* is " -"considered less than *b* when *a* precedes *b* in time." +":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:1807 +#: ../../library/datetime.rst:1841 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:1811 +#: ../../library/datetime.rst:1845 msgid "" "If both comparands are aware, and have the same :attr:`~.time.tzinfo` " "attribute, the :attr:`!tzinfo` and :attr:`!fold` attributes are ignored and " @@ -2552,18 +2605,18 @@ msgid "" "subtracting their UTC offsets (obtained from ``self.utcoffset()``)." msgstr "" -#: ../../library/datetime.rst:1817 +#: ../../library/datetime.rst:1851 msgid "" "Equality comparisons between aware and naive :class:`.time` instances don't " "raise :exc:`TypeError`." msgstr "" -#: ../../library/datetime.rst:1821 +#: ../../library/datetime.rst:1855 msgid "" "In Boolean contexts, a :class:`.time` object is always considered to be true." msgstr "" -#: ../../library/datetime.rst:1823 +#: ../../library/datetime.rst:1857 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-" @@ -2571,33 +2624,33 @@ msgid "" "details." msgstr "" -#: ../../library/datetime.rst:1830 +#: ../../library/datetime.rst:1864 msgid "Other constructor:" msgstr "" -#: ../../library/datetime.rst:1834 +#: ../../library/datetime.rst:1868 msgid "" "Return a :class:`.time` corresponding to a *time_string* in any valid ISO " "8601 format, with the following exceptions:" msgstr "" -#: ../../library/datetime.rst:1838 +#: ../../library/datetime.rst:1872 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:1840 +#: ../../library/datetime.rst:1874 msgid "" "Fractional seconds may have any number of digits (anything beyond 6 will be " "truncated)." msgstr "" -#: ../../library/datetime.rst:1844 +#: ../../library/datetime.rst:1878 msgid "Examples:" msgstr "範例: ::" -#: ../../library/datetime.rst:1846 +#: ../../library/datetime.rst:1880 msgid "" ">>> from datetime import time\n" ">>> time.fromisoformat('04:23:01')\n" @@ -2637,55 +2690,55 @@ msgstr "" ">>> time.fromisoformat('04:23:01+00:00')\n" "datetime.time(4, 23, 1, tzinfo=datetime.timezone.utc)" -#: ../../library/datetime.rst:1868 +#: ../../library/datetime.rst:1902 msgid "" "Previously, this method only supported formats that could be emitted by :" "meth:`time.isoformat`." msgstr "" -#: ../../library/datetime.rst:1878 +#: ../../library/datetime.rst:1912 msgid "" -"Return a :class:`.time` with the same value, except for those attributes " -"given new values by whichever keyword arguments are specified. Note that " -"``tzinfo=None`` can be specified to create a naive :class:`.time` from an " -"aware :class:`.time`, without conversion of the time data." +"Return a new :class:`.time` with the same values, but with specified " +"parameters updated. Note that ``tzinfo=None`` can be specified to create a " +"naive :class:`.time` from an aware :class:`.time`, without conversion of the " +"time data." msgstr "" -#: ../../library/datetime.rst:1883 +#: ../../library/datetime.rst:1917 msgid "" ":class:`.time` objects are also supported by generic function :func:`copy." "replace`." msgstr "" -#: ../../library/datetime.rst:1892 +#: ../../library/datetime.rst:1926 msgid "Return a string representing the time in ISO 8601 format, one of:" msgstr "" -#: ../../library/datetime.rst:1894 +#: ../../library/datetime.rst:1928 msgid "``HH:MM:SS.ffffff``, if :attr:`microsecond` is not 0" msgstr "" -#: ../../library/datetime.rst:1895 +#: ../../library/datetime.rst:1929 msgid "``HH:MM:SS``, if :attr:`microsecond` is 0" msgstr "" -#: ../../library/datetime.rst:1896 +#: ../../library/datetime.rst:1930 msgid "" "``HH:MM:SS.ffffff+HH:MM[:SS[.ffffff]]``, if :meth:`utcoffset` does not " "return ``None``" msgstr "" -#: ../../library/datetime.rst:1897 +#: ../../library/datetime.rst:1931 msgid "" "``HH:MM:SS+HH:MM[:SS[.ffffff]]``, if :attr:`microsecond` is 0 and :meth:" "`utcoffset` does not return ``None``" msgstr "" -#: ../../library/datetime.rst:1917 +#: ../../library/datetime.rst:1951 msgid ":exc:`ValueError` will be raised on an invalid *timespec* argument." msgstr "" -#: ../../library/datetime.rst:1921 +#: ../../library/datetime.rst:1955 msgid "" ">>> from datetime import time\n" ">>> time(hour=12, minute=34, second=56, microsecond=123456)." @@ -2707,18 +2760,18 @@ msgstr "" ">>> dt.isoformat(timespec='auto')\n" "'12:34:56'" -#: ../../library/datetime.rst:1936 -msgid "For a time *t*, ``str(t)`` is equivalent to ``t.isoformat()``." +#: ../../library/datetime.rst:1970 +msgid "For a time ``t``, ``str(t)`` is equivalent to ``t.isoformat()``." msgstr "" -#: ../../library/datetime.rst:1941 +#: ../../library/datetime.rst:1975 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:1947 +#: ../../library/datetime.rst:1981 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" @@ -2807,18 +2860,18 @@ msgstr "" ">>> 'The {} is {:%H:%M}.'.format(\"time\", t)\n" "'The time is 12:10.'" -#: ../../library/datetime.rst:2012 +#: ../../library/datetime.rst:2046 msgid ":class:`tzinfo` Objects" msgstr ":class:`tzinfo` 物件" -#: ../../library/datetime.rst:2016 +#: ../../library/datetime.rst:2050 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:2020 +#: ../../library/datetime.rst:2054 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 " @@ -2828,7 +2881,7 @@ msgid "" "object passed to them." msgstr "" -#: ../../library/datetime.rst:2026 +#: ../../library/datetime.rst:2060 msgid "" "You need to derive a concrete subclass, and (at least) supply " "implementations of the standard :class:`tzinfo` methods needed by the :class:" @@ -2838,7 +2891,7 @@ msgid "" "American EST and EDT." msgstr "" -#: ../../library/datetime.rst:2033 +#: ../../library/datetime.rst:2067 msgid "" "Special requirement for pickling: A :class:`tzinfo` subclass must have an :" "meth:`~object.__init__` method that can be called with no arguments, " @@ -2846,20 +2899,20 @@ msgid "" "technical requirement that may be relaxed in the future." msgstr "" -#: ../../library/datetime.rst:2039 +#: ../../library/datetime.rst:2073 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:2046 +#: ../../library/datetime.rst:2080 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:2049 +#: ../../library/datetime.rst:2083 msgid "" "This represents the *total* offset from UTC; for example, if a :class:" "`tzinfo` object represents both time zone and DST adjustments, :meth:" @@ -2870,31 +2923,31 @@ msgid "" "meth:`utcoffset` will probably look like one of these two::" msgstr "" -#: ../../library/datetime.rst:2057 +#: ../../library/datetime.rst:2091 msgid "" "return CONSTANT # fixed-offset class\n" "return CONSTANT + self.dst(dt) # daylight-aware class" msgstr "" -#: ../../library/datetime.rst:2060 +#: ../../library/datetime.rst:2094 msgid "" "If :meth:`utcoffset` does not return ``None``, :meth:`dst` should not return " "``None`` either." msgstr "" -#: ../../library/datetime.rst:2063 +#: ../../library/datetime.rst:2097 msgid "" "The default implementation of :meth:`utcoffset` raises :exc:" "`NotImplementedError`." msgstr "" -#: ../../library/datetime.rst:2072 +#: ../../library/datetime.rst:2106 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:2076 +#: ../../library/datetime.rst:2110 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 " @@ -2907,17 +2960,17 @@ msgid "" "to account for DST changes when crossing time zones." msgstr "" -#: ../../library/datetime.rst:2086 +#: ../../library/datetime.rst:2120 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:2089 +#: ../../library/datetime.rst:2123 msgid "``tz.utcoffset(dt) - tz.dst(dt)``" msgstr "``tz.utcoffset(dt) - tz.dst(dt)``" -#: ../../library/datetime.rst:2091 +#: ../../library/datetime.rst:2125 msgid "" "must return the same result for every :class:`.datetime` *dt* with ``dt." "tzinfo == tz``. For sane :class:`tzinfo` subclasses, this expression yields " @@ -2930,24 +2983,24 @@ msgid "" "astimezone` regardless." msgstr "" -#: ../../library/datetime.rst:2100 +#: ../../library/datetime.rst:2134 msgid "" "Most implementations of :meth:`dst` will probably look like one of these " "two::" msgstr "" -#: ../../library/datetime.rst:2102 +#: ../../library/datetime.rst:2136 msgid "" "def dst(self, dt):\n" " # a fixed-offset class: doesn't account for DST\n" " return timedelta(0)" msgstr "" -#: ../../library/datetime.rst:2106 +#: ../../library/datetime.rst:2140 msgid "or::" msgstr "或是: ::" -#: ../../library/datetime.rst:2108 +#: ../../library/datetime.rst:2142 msgid "" "def dst(self, dt):\n" " # Code to set dston and dstoff to the time zone's DST\n" @@ -2960,12 +3013,12 @@ msgid "" " return timedelta(0)" msgstr "" -#: ../../library/datetime.rst:2118 +#: ../../library/datetime.rst:2152 msgid "" "The default implementation of :meth:`dst` raises :exc:`NotImplementedError`." msgstr "" -#: ../../library/datetime.rst:2126 +#: ../../library/datetime.rst:2160 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:`!" @@ -2979,13 +3032,13 @@ msgid "" "accounting for daylight time." msgstr "" -#: ../../library/datetime.rst:2136 +#: ../../library/datetime.rst:2170 msgid "" "The default implementation of :meth:`tzname` raises :exc:" "`NotImplementedError`." msgstr "" -#: ../../library/datetime.rst:2139 +#: ../../library/datetime.rst:2173 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 " @@ -2995,7 +3048,7 @@ msgid "" "datetime`." msgstr "" -#: ../../library/datetime.rst:2145 +#: ../../library/datetime.rst:2179 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 " @@ -3004,7 +3057,7 @@ msgid "" "offset, as there is no other convention for discovering the standard offset." msgstr "" -#: ../../library/datetime.rst:2151 +#: ../../library/datetime.rst:2185 msgid "" "When a :class:`.datetime` object is passed in response to a :class:`." "datetime` method, ``dt.tzinfo`` is the same object as *self*. :class:" @@ -3014,13 +3067,13 @@ msgid "" "zones." msgstr "" -#: ../../library/datetime.rst:2157 +#: ../../library/datetime.rst:2191 msgid "" "There is one more :class:`tzinfo` method that a subclass may wish to " "override:" msgstr "" -#: ../../library/datetime.rst:2162 +#: ../../library/datetime.rst:2196 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 " @@ -3029,7 +3082,7 @@ msgid "" "datetime in *self*'s local time." msgstr "" -#: ../../library/datetime.rst:2168 +#: ../../library/datetime.rst:2202 msgid "" "Most :class:`tzinfo` subclasses should be able to inherit the default :meth:" "`fromutc` implementation without problems. It's strong enough to handle " @@ -3044,13 +3097,13 @@ msgid "" "offset changes." msgstr "" -#: ../../library/datetime.rst:2179 +#: ../../library/datetime.rst:2213 msgid "" "Skipping code for error cases, the default :meth:`fromutc` implementation " "acts like::" msgstr "" -#: ../../library/datetime.rst:2182 +#: ../../library/datetime.rst:2216 msgid "" "def fromutc(self, dt):\n" " # raise ValueError error if dt.tzinfo is not self\n" @@ -3068,13 +3121,13 @@ msgid "" " return dt" msgstr "" -#: ../../library/datetime.rst:2197 +#: ../../library/datetime.rst:2231 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:2201 +#: ../../library/datetime.rst:2235 msgid "" "from datetime import tzinfo, timedelta, datetime\n" "\n" @@ -3254,7 +3307,7 @@ msgid "" "Pacific = USTimeZone(-8, \"Pacific\", \"PST\", \"PDT\")\n" msgstr "" -#: ../../library/datetime.rst:2203 +#: ../../library/datetime.rst:2237 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 " @@ -3263,7 +3316,7 @@ msgid "" "ends the minute after 1:59 (EDT) on the first Sunday in November::" msgstr "" -#: ../../library/datetime.rst:2209 +#: ../../library/datetime.rst:2243 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" @@ -3281,7 +3334,7 @@ msgstr "" "\n" " end 23:MM 0:MM 1:MM 1:MM 2:MM 3:MM" -#: ../../library/datetime.rst:2217 +#: ../../library/datetime.rst:2251 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, " @@ -3290,7 +3343,7 @@ msgid "" "get::" msgstr "" -#: ../../library/datetime.rst:2222 +#: ../../library/datetime.rst:2256 msgid "" ">>> from datetime import datetime, timezone\n" ">>> from tzinfo_examples import HOUR, Eastern\n" @@ -3318,7 +3371,7 @@ msgstr "" "07:00:00 UTC = 03:00:00 EDT\n" "08:00:00 UTC = 04:00:00 EDT" -#: ../../library/datetime.rst:2236 +#: ../../library/datetime.rst:2270 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 " @@ -3333,7 +3386,7 @@ msgid "" "Fall back transition of 2016, we get::" msgstr "" -#: ../../library/datetime.rst:2247 +#: ../../library/datetime.rst:2281 msgid "" ">>> u0 = datetime(2016, 11, 6, 4, tzinfo=timezone.utc)\n" ">>> for i in range(4):\n" @@ -3357,13 +3410,13 @@ msgstr "" "06:00:00 UTC = 01:00:00 EST 1\n" "07:00:00 UTC = 02:00:00 EST 0" -#: ../../library/datetime.rst:2258 +#: ../../library/datetime.rst:2292 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:2261 +#: ../../library/datetime.rst:2295 msgid "" "Applications that can't bear wall-time ambiguities should explicitly check " "the value of the :attr:`~.datetime.fold` attribute or avoid using hybrid :" @@ -3373,28 +3426,28 @@ msgid "" "offset -4 hours))." msgstr "" -#: ../../library/datetime.rst:2269 +#: ../../library/datetime.rst:2303 msgid ":mod:`zoneinfo`" msgstr ":mod:`zoneinfo`" -#: ../../library/datetime.rst:2270 +#: ../../library/datetime.rst:2304 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:2274 +#: ../../library/datetime.rst:2308 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:2277 +#: ../../library/datetime.rst:2311 msgid "`IANA time zone database `_" msgstr "`IANA 時區資料庫 `_" -#: ../../library/datetime.rst:2278 +#: ../../library/datetime.rst:2312 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 " @@ -3403,24 +3456,24 @@ msgid "" "saving rules." msgstr "" -#: ../../library/datetime.rst:2288 +#: ../../library/datetime.rst:2322 msgid ":class:`timezone` Objects" msgstr ":class:`timezone` 物件" -#: ../../library/datetime.rst:2290 +#: ../../library/datetime.rst:2324 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:2294 +#: ../../library/datetime.rst:2328 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:2301 +#: ../../library/datetime.rst:2335 msgid "" "The *offset* argument must be specified as a :class:`timedelta` object " "representing the difference between the local time and UTC. It must be " @@ -3428,25 +3481,25 @@ msgid "" "otherwise :exc:`ValueError` is raised." msgstr "" -#: ../../library/datetime.rst:2306 +#: ../../library/datetime.rst:2340 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:2317 ../../library/datetime.rst:2328 +#: ../../library/datetime.rst:2351 ../../library/datetime.rst:2362 msgid "" "Return the fixed value specified when the :class:`timezone` instance is " "constructed." msgstr "" -#: ../../library/datetime.rst:2320 +#: ../../library/datetime.rst:2354 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:2331 +#: ../../library/datetime.rst:2365 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 " @@ -3455,119 +3508,119 @@ msgid "" "are two digits of ``offset.hours`` and ``offset.minutes`` respectively." msgstr "" -#: ../../library/datetime.rst:2337 +#: ../../library/datetime.rst:2371 msgid "" "Name generated from ``offset=timedelta(0)`` is now plain ``'UTC'``, not " "``'UTC+00:00'``." msgstr "" -#: ../../library/datetime.rst:2344 +#: ../../library/datetime.rst:2378 msgid "Always returns ``None``." msgstr "總是回傳 ``None``。" -#: ../../library/datetime.rst:2348 +#: ../../library/datetime.rst:2382 msgid "" "Return ``dt + offset``. The *dt* argument must be an aware :class:`." "datetime` instance, with ``tzinfo`` set to ``self``." msgstr "" -#: ../../library/datetime.rst:2355 +#: ../../library/datetime.rst:2389 msgid "The UTC time zone, ``timezone(timedelta(0))``." msgstr "UTC 時區,``timezone(timedelta(0))``。" -#: ../../library/datetime.rst:2364 +#: ../../library/datetime.rst:2398 msgid ":meth:`~.datetime.strftime` and :meth:`~.datetime.strptime` Behavior" msgstr ":meth:`~.datetime.strftime` 與 :meth:`~.datetime.strptime` 的行為" -#: ../../library/datetime.rst:2366 +#: ../../library/datetime.rst:2400 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:2370 +#: ../../library/datetime.rst:2404 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." msgstr "" -#: ../../library/datetime.rst:2374 +#: ../../library/datetime.rst:2408 msgid "" "The table below provides a high-level comparison of :meth:`~.datetime." "strftime` versus :meth:`~.datetime.strptime`:" msgstr "" -#: ../../library/datetime.rst:2378 +#: ../../library/datetime.rst:2412 msgid "``strftime``" msgstr "``strftime``" -#: ../../library/datetime.rst:2378 +#: ../../library/datetime.rst:2412 msgid "``strptime``" msgstr "``strptime``" -#: ../../library/datetime.rst:2380 +#: ../../library/datetime.rst:2414 msgid "Usage" msgstr "用法" -#: ../../library/datetime.rst:2380 +#: ../../library/datetime.rst:2414 msgid "Convert object to a string according to a given format" msgstr "" -#: ../../library/datetime.rst:2380 +#: ../../library/datetime.rst:2414 msgid "" "Parse a string into a :class:`.datetime` object given a corresponding format" msgstr "" -#: ../../library/datetime.rst:2382 +#: ../../library/datetime.rst:2416 msgid "Type of method" msgstr "" -#: ../../library/datetime.rst:2382 +#: ../../library/datetime.rst:2416 msgid "Instance method" msgstr "實例方法" -#: ../../library/datetime.rst:2382 +#: ../../library/datetime.rst:2416 msgid "Class method" msgstr "類別方法" -#: ../../library/datetime.rst:2384 +#: ../../library/datetime.rst:2418 msgid "Method of" msgstr "" -#: ../../library/datetime.rst:2384 +#: ../../library/datetime.rst:2418 msgid ":class:`date`; :class:`.datetime`; :class:`.time`" msgstr ":class:`date`; :class:`.datetime`; :class:`.time`" -#: ../../library/datetime.rst:2384 +#: ../../library/datetime.rst:2418 msgid ":class:`.datetime`" msgstr ":class:`.datetime`" -#: ../../library/datetime.rst:2386 +#: ../../library/datetime.rst:2420 msgid "Signature" msgstr "" -#: ../../library/datetime.rst:2386 +#: ../../library/datetime.rst:2420 msgid "``strftime(format)``" msgstr "``strftime(format)``" -#: ../../library/datetime.rst:2386 +#: ../../library/datetime.rst:2420 msgid "``strptime(date_string, format)``" msgstr "``strptime(date_string, format)``" -#: ../../library/datetime.rst:2393 +#: ../../library/datetime.rst:2427 msgid "" ":meth:`~.datetime.strftime` and :meth:`~.datetime.strptime` Format Codes" msgstr ":meth:`~.datetime.strftime` 與 :meth:`~.datetime.strptime` 格式碼" -#: ../../library/datetime.rst:2395 +#: ../../library/datetime.rst:2429 msgid "" "These methods accept format codes that can be used to parse and format " "dates::" msgstr "" -#: ../../library/datetime.rst:2397 +#: ../../library/datetime.rst:2431 msgid "" ">>> datetime.strptime('31/01/22 23:59:59.999999',\n" "... '%d/%m/%y %H:%M:%S.%f')\n" @@ -3581,33 +3634,33 @@ msgstr "" ">>> _.strftime('%a %d %b %Y, %I:%M%p')\n" "'Mon 31 Jan 2022, 11:59PM'" -#: ../../library/datetime.rst:2403 +#: ../../library/datetime.rst:2437 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:2407 ../../library/datetime.rst:2510 +#: ../../library/datetime.rst:2441 ../../library/datetime.rst:2544 msgid "Directive" msgstr "" -#: ../../library/datetime.rst:2407 ../../library/datetime.rst:2510 +#: ../../library/datetime.rst:2441 ../../library/datetime.rst:2544 msgid "Meaning" msgstr "含義" -#: ../../library/datetime.rst:2407 ../../library/datetime.rst:2510 +#: ../../library/datetime.rst:2441 ../../library/datetime.rst:2544 msgid "Example" msgstr "範例" -#: ../../library/datetime.rst:2407 ../../library/datetime.rst:2510 +#: ../../library/datetime.rst:2441 ../../library/datetime.rst:2544 msgid "Notes" msgstr "註解" -#: ../../library/datetime.rst:2409 +#: ../../library/datetime.rst:2443 msgid "``%a``" msgstr "``%a``" -#: ../../library/datetime.rst:2409 +#: ../../library/datetime.rst:2443 msgid "Weekday as locale's abbreviated name." msgstr "" @@ -3619,11 +3672,11 @@ msgstr "" msgid "So, Mo, ..., Sa (de_DE)" msgstr "" -#: ../../library/datetime.rst:2414 +#: ../../library/datetime.rst:2448 msgid "``%A``" msgstr "``%A``" -#: ../../library/datetime.rst:2414 +#: ../../library/datetime.rst:2448 msgid "Weekday as locale's full name." msgstr "" @@ -3635,42 +3688,42 @@ msgstr "" msgid "Sonntag, Montag, ..., Samstag (de_DE)" msgstr "" -#: ../../library/datetime.rst:2419 +#: ../../library/datetime.rst:2453 msgid "``%w``" msgstr "``%w``" -#: ../../library/datetime.rst:2419 +#: ../../library/datetime.rst:2453 msgid "Weekday as a decimal number, where 0 is Sunday and 6 is Saturday." msgstr "" -#: ../../library/datetime.rst:2419 +#: ../../library/datetime.rst:2453 msgid "0, 1, ..., 6" msgstr "0, 1, ..., 6" -#: ../../library/datetime.rst:2423 +#: ../../library/datetime.rst:2457 msgid "``%d``" msgstr "``%d``" -#: ../../library/datetime.rst:2423 +#: ../../library/datetime.rst:2457 msgid "Day of the month as a zero-padded decimal number." msgstr "" -#: ../../library/datetime.rst:2423 +#: ../../library/datetime.rst:2457 msgid "01, 02, ..., 31" msgstr "01, 02, ..., 31" -#: ../../library/datetime.rst:2423 ../../library/datetime.rst:2436 -#: ../../library/datetime.rst:2439 ../../library/datetime.rst:2445 -#: ../../library/datetime.rst:2448 ../../library/datetime.rst:2454 -#: ../../library/datetime.rst:2472 +#: ../../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 msgid "\\(9)" msgstr "\\(9)" -#: ../../library/datetime.rst:2426 +#: ../../library/datetime.rst:2460 msgid "``%b``" msgstr "``%b``" -#: ../../library/datetime.rst:2426 +#: ../../library/datetime.rst:2460 msgid "Month as locale's abbreviated name." msgstr "" @@ -3682,11 +3735,11 @@ msgstr "" msgid "Jan, Feb, ..., Dez (de_DE)" msgstr "" -#: ../../library/datetime.rst:2431 +#: ../../library/datetime.rst:2465 msgid "``%B``" msgstr "``%B``" -#: ../../library/datetime.rst:2431 +#: ../../library/datetime.rst:2465 msgid "Month as locale's full name." msgstr "" @@ -3698,67 +3751,67 @@ msgstr "" msgid "Januar, Februar, ..., Dezember (de_DE)" msgstr "" -#: ../../library/datetime.rst:2436 +#: ../../library/datetime.rst:2470 msgid "``%m``" msgstr "``%m``" -#: ../../library/datetime.rst:2436 +#: ../../library/datetime.rst:2470 msgid "Month as a zero-padded decimal number." msgstr "以零填充的並以十進位數字表示的月份。" -#: ../../library/datetime.rst:2436 ../../library/datetime.rst:2448 +#: ../../library/datetime.rst:2470 ../../library/datetime.rst:2482 msgid "01, 02, ..., 12" msgstr "01, 02, ..., 12" -#: ../../library/datetime.rst:2439 +#: ../../library/datetime.rst:2473 msgid "``%y``" msgstr "``%y``" -#: ../../library/datetime.rst:2439 +#: ../../library/datetime.rst:2473 msgid "Year without century as a zero-padded decimal number." msgstr "" -#: ../../library/datetime.rst:2439 +#: ../../library/datetime.rst:2473 msgid "00, 01, ..., 99" msgstr "00, 01, ..., 99" -#: ../../library/datetime.rst:2442 +#: ../../library/datetime.rst:2476 msgid "``%Y``" msgstr "``%Y``" -#: ../../library/datetime.rst:2442 +#: ../../library/datetime.rst:2476 msgid "Year with century as a decimal number." msgstr "" -#: ../../library/datetime.rst:2442 ../../library/datetime.rst:2512 +#: ../../library/datetime.rst:2476 ../../library/datetime.rst:2546 msgid "0001, 0002, ..., 2013, 2014, ..., 9998, 9999" msgstr "0001, 0002, ..., 2013, 2014, ..., 9998, 9999" -#: ../../library/datetime.rst:2445 +#: ../../library/datetime.rst:2479 msgid "``%H``" msgstr "``%H``" -#: ../../library/datetime.rst:2445 +#: ../../library/datetime.rst:2479 msgid "Hour (24-hour clock) as a zero-padded decimal number." msgstr "" -#: ../../library/datetime.rst:2445 +#: ../../library/datetime.rst:2479 msgid "00, 01, ..., 23" msgstr "00, 01, ..., 23" -#: ../../library/datetime.rst:2448 +#: ../../library/datetime.rst:2482 msgid "``%I``" msgstr "``%I``" -#: ../../library/datetime.rst:2448 +#: ../../library/datetime.rst:2482 msgid "Hour (12-hour clock) as a zero-padded decimal number." msgstr "" -#: ../../library/datetime.rst:2451 +#: ../../library/datetime.rst:2485 msgid "``%p``" msgstr "``%p``" -#: ../../library/datetime.rst:2451 +#: ../../library/datetime.rst:2485 msgid "Locale's equivalent of either AM or PM." msgstr "" @@ -3770,128 +3823,128 @@ msgstr "AM, PM (en_US);" msgid "am, pm (de_DE)" msgstr "am, pm (de_DE)" -#: ../../library/datetime.rst:2451 +#: ../../library/datetime.rst:2485 msgid "\\(1), \\(3)" msgstr "\\(1), \\(3)" -#: ../../library/datetime.rst:2454 +#: ../../library/datetime.rst:2488 msgid "``%M``" msgstr "``%M``" -#: ../../library/datetime.rst:2454 +#: ../../library/datetime.rst:2488 msgid "Minute as a zero-padded decimal number." msgstr "" -#: ../../library/datetime.rst:2454 ../../library/datetime.rst:2457 +#: ../../library/datetime.rst:2488 ../../library/datetime.rst:2491 msgid "00, 01, ..., 59" msgstr "00, 01, ..., 59" -#: ../../library/datetime.rst:2457 +#: ../../library/datetime.rst:2491 msgid "``%S``" msgstr "``%S``" -#: ../../library/datetime.rst:2457 +#: ../../library/datetime.rst:2491 msgid "Second as a zero-padded decimal number." msgstr "" -#: ../../library/datetime.rst:2457 +#: ../../library/datetime.rst:2491 msgid "\\(4), \\(9)" msgstr "\\(4), \\(9)" -#: ../../library/datetime.rst:2460 +#: ../../library/datetime.rst:2494 msgid "``%f``" msgstr "``%f``" -#: ../../library/datetime.rst:2460 +#: ../../library/datetime.rst:2494 msgid "Microsecond as a decimal number, zero-padded to 6 digits." msgstr "" -#: ../../library/datetime.rst:2460 +#: ../../library/datetime.rst:2494 msgid "000000, 000001, ..., 999999" msgstr "000000, 000001, ..., 999999" -#: ../../library/datetime.rst:2460 +#: ../../library/datetime.rst:2494 msgid "\\(5)" msgstr "\\(5)" -#: ../../library/datetime.rst:2464 ../../library/datetime.rst:2623 +#: ../../library/datetime.rst:2498 ../../library/datetime.rst:2657 msgid "``%z``" msgstr "``%z``" -#: ../../library/datetime.rst:2464 +#: ../../library/datetime.rst:2498 msgid "" "UTC offset in the form ``±HHMM[SS[.ffffff]]`` (empty string if the object is " "naive)." msgstr "" -#: ../../library/datetime.rst:2464 +#: ../../library/datetime.rst:2498 msgid "(empty), +0000, -0400, +1030, +063415, -030712.345216" msgstr "" -#: ../../library/datetime.rst:2464 ../../library/datetime.rst:2469 -#: ../../library/datetime.rst:2526 +#: ../../library/datetime.rst:2498 ../../library/datetime.rst:2503 +#: ../../library/datetime.rst:2560 msgid "\\(6)" msgstr "\\(6)" -#: ../../library/datetime.rst:2469 ../../library/datetime.rst:2649 +#: ../../library/datetime.rst:2503 ../../library/datetime.rst:2683 msgid "``%Z``" msgstr "``%Z``" -#: ../../library/datetime.rst:2469 +#: ../../library/datetime.rst:2503 msgid "Time zone name (empty string if the object is naive)." msgstr "" -#: ../../library/datetime.rst:2469 +#: ../../library/datetime.rst:2503 msgid "(empty), UTC, GMT" msgstr "" -#: ../../library/datetime.rst:2472 +#: ../../library/datetime.rst:2506 msgid "``%j``" msgstr "``%j``" -#: ../../library/datetime.rst:2472 +#: ../../library/datetime.rst:2506 msgid "Day of the year as a zero-padded decimal number." msgstr "" -#: ../../library/datetime.rst:2472 +#: ../../library/datetime.rst:2506 msgid "001, 002, ..., 366" msgstr "001, 002, ..., 366" -#: ../../library/datetime.rst:2475 +#: ../../library/datetime.rst:2509 msgid "``%U``" msgstr "``%U``" -#: ../../library/datetime.rst:2475 +#: ../../library/datetime.rst:2509 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:2475 ../../library/datetime.rst:2483 +#: ../../library/datetime.rst:2509 ../../library/datetime.rst:2517 msgid "00, 01, ..., 53" msgstr "00, 01, ..., 53" -#: ../../library/datetime.rst:2475 ../../library/datetime.rst:2483 +#: ../../library/datetime.rst:2509 ../../library/datetime.rst:2517 msgid "\\(7), \\(9)" msgstr "\\(7), \\(9)" -#: ../../library/datetime.rst:2483 +#: ../../library/datetime.rst:2517 msgid "``%W``" msgstr "``%W``" -#: ../../library/datetime.rst:2483 +#: ../../library/datetime.rst:2517 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:2491 +#: ../../library/datetime.rst:2525 msgid "``%c``" msgstr "``%c``" -#: ../../library/datetime.rst:2491 +#: ../../library/datetime.rst:2525 msgid "Locale's appropriate date and time representation." msgstr "" @@ -3903,11 +3956,11 @@ msgstr "" msgid "Di 16 Aug 21:30:00 1988 (de_DE)" msgstr "" -#: ../../library/datetime.rst:2496 +#: ../../library/datetime.rst:2530 msgid "``%x``" msgstr "``%x``" -#: ../../library/datetime.rst:2496 +#: ../../library/datetime.rst:2530 msgid "Locale's appropriate date representation." msgstr "" @@ -3923,11 +3976,11 @@ msgstr "" msgid "16.08.1988 (de_DE)" msgstr "" -#: ../../library/datetime.rst:2500 +#: ../../library/datetime.rst:2534 msgid "``%X``" msgstr "``%X``" -#: ../../library/datetime.rst:2500 +#: ../../library/datetime.rst:2534 msgid "Locale's appropriate time representation." msgstr "" @@ -3939,83 +3992,83 @@ msgstr "" msgid "21:30:00 (de_DE)" msgstr "" -#: ../../library/datetime.rst:2503 +#: ../../library/datetime.rst:2537 msgid "``%%``" msgstr "``%%``" -#: ../../library/datetime.rst:2503 +#: ../../library/datetime.rst:2537 msgid "A literal ``'%'`` character." msgstr "" -#: ../../library/datetime.rst:2503 +#: ../../library/datetime.rst:2537 msgid "%" msgstr "%" -#: ../../library/datetime.rst:2506 +#: ../../library/datetime.rst:2540 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:2512 +#: ../../library/datetime.rst:2546 msgid "``%G``" msgstr "``%G``" -#: ../../library/datetime.rst:2512 +#: ../../library/datetime.rst:2546 msgid "" "ISO 8601 year with century representing the year that contains the greater " "part of the ISO week (``%V``)." msgstr "" -#: ../../library/datetime.rst:2512 +#: ../../library/datetime.rst:2546 msgid "\\(8)" msgstr "\\(8)" -#: ../../library/datetime.rst:2517 +#: ../../library/datetime.rst:2551 msgid "``%u``" msgstr "``%u``" -#: ../../library/datetime.rst:2517 +#: ../../library/datetime.rst:2551 msgid "ISO 8601 weekday as a decimal number where 1 is Monday." msgstr "" -#: ../../library/datetime.rst:2517 +#: ../../library/datetime.rst:2551 msgid "1, 2, ..., 7" msgstr "1, 2, ..., 7" -#: ../../library/datetime.rst:2520 +#: ../../library/datetime.rst:2554 msgid "``%V``" msgstr "``%V``" -#: ../../library/datetime.rst:2520 +#: ../../library/datetime.rst:2554 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:2520 +#: ../../library/datetime.rst:2554 msgid "01, 02, ..., 53" msgstr "01, 02, ..., 53" -#: ../../library/datetime.rst:2520 +#: ../../library/datetime.rst:2554 msgid "\\(8), \\(9)" msgstr "\\(8), \\(9)" -#: ../../library/datetime.rst:2526 ../../library/datetime.rst:2645 +#: ../../library/datetime.rst:2560 ../../library/datetime.rst:2679 msgid "``%:z``" msgstr "``%:z``" -#: ../../library/datetime.rst:2526 +#: ../../library/datetime.rst:2560 msgid "" "UTC offset in the form ``±HH:MM[:SS[.ffffff]]`` (empty string if the object " "is naive)." msgstr "" -#: ../../library/datetime.rst:2526 +#: ../../library/datetime.rst:2560 msgid "(empty), +00:00, -04:00, +10:30, +06:34:15, -03:07:12.345216" msgstr "" -#: ../../library/datetime.rst:2532 +#: ../../library/datetime.rst:2566 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 " @@ -4024,7 +4077,7 @@ msgid "" "directives will raise a :exc:`ValueError`." msgstr "" -#: ../../library/datetime.rst:2537 +#: ../../library/datetime.rst:2571 msgid "" "The full set of format codes supported varies across platforms, because " "Python calls the platform C library's :c:func:`strftime` function, and " @@ -4034,44 +4087,44 @@ msgid "" "unsupported format specifiers." msgstr "" -#: ../../library/datetime.rst:2543 +#: ../../library/datetime.rst:2577 msgid "``%G``, ``%u`` and ``%V`` were added." msgstr "新增 ``%G``、``%u`` 與 ``%V``。" -#: ../../library/datetime.rst:2546 +#: ../../library/datetime.rst:2580 msgid "``%:z`` was added." msgstr "新增 ``%:z``。" -#: ../../library/datetime.rst:2550 +#: ../../library/datetime.rst:2584 msgid "Technical Detail" msgstr "技術細節" -#: ../../library/datetime.rst:2552 +#: ../../library/datetime.rst:2586 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:2556 +#: ../../library/datetime.rst:2590 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:2560 +#: ../../library/datetime.rst:2594 msgid "Using ``datetime.strptime(date_string, format)`` is equivalent to::" msgstr "" -#: ../../library/datetime.rst:2564 +#: ../../library/datetime.rst:2598 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:2568 +#: ../../library/datetime.rst:2602 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 " @@ -4081,7 +4134,7 @@ msgstr "" "time` 物件並沒有這些值。如果使用這些格式碼,年份會以 1900 代替、月及日會以 1 " "代替。" -#: ../../library/datetime.rst:2572 +#: ../../library/datetime.rst:2606 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 " @@ -4090,7 +4143,7 @@ msgstr "" "對 :class:`.date` 物件來說,不應該使用時、分、秒、微秒的格式碼,因為 :class:" "`date` 物件並沒有這些值。如果使用這些格式碼,這些值都會以 0 代替。" -#: ../../library/datetime.rst:2576 +#: ../../library/datetime.rst:2610 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 " @@ -4099,7 +4152,7 @@ msgid "" "`UnicodeError` or return an empty string instead." msgstr "" -#: ../../library/datetime.rst:2585 +#: ../../library/datetime.rst:2619 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 " @@ -4107,38 +4160,38 @@ msgid "" "contain non-ASCII characters." msgstr "" -#: ../../library/datetime.rst:2591 +#: ../../library/datetime.rst:2625 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:2594 +#: ../../library/datetime.rst:2628 msgid "" "In previous versions, :meth:`~.datetime.strftime` method was restricted to " "years >= 1900." msgstr "" -#: ../../library/datetime.rst:2598 +#: ../../library/datetime.rst:2632 msgid "" "In version 3.2, :meth:`~.datetime.strftime` method was restricted to years " ">= 1000." msgstr "" -#: ../../library/datetime.rst:2603 +#: ../../library/datetime.rst:2637 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:2607 +#: ../../library/datetime.rst:2641 msgid "" "Unlike the :mod:`time` module, the :mod:`!datetime` module does not support " "leap seconds." msgstr "" -#: ../../library/datetime.rst:2611 +#: ../../library/datetime.rst:2645 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 " @@ -4146,17 +4199,17 @@ msgid "" "separately in datetime objects, and therefore always available)." msgstr "" -#: ../../library/datetime.rst:2618 +#: ../../library/datetime.rst:2652 msgid "" "For a naive object, the ``%z``, ``%:z`` and ``%Z`` format codes are replaced " "by empty strings." msgstr "" -#: ../../library/datetime.rst:2621 +#: ../../library/datetime.rst:2655 msgid "For an aware object:" msgstr "" -#: ../../library/datetime.rst:2624 +#: ../../library/datetime.rst:2658 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 " @@ -4170,7 +4223,7 @@ msgid "" "replaced with the string ``'-0330'``." msgstr "" -#: ../../library/datetime.rst:2638 +#: ../../library/datetime.rst:2672 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, " @@ -4179,53 +4232,53 @@ msgid "" "``'+00:00'``." msgstr "" -#: ../../library/datetime.rst:2646 +#: ../../library/datetime.rst:2680 msgid "" "Behaves exactly as ``%z``, but has a colon separator added between hours, " "minutes and seconds." msgstr "" -#: ../../library/datetime.rst:2650 +#: ../../library/datetime.rst:2684 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:2654 +#: ../../library/datetime.rst:2688 msgid ":meth:`~.datetime.strptime` only accepts certain values for ``%Z``:" msgstr "" -#: ../../library/datetime.rst:2656 +#: ../../library/datetime.rst:2690 msgid "any value in ``time.tzname`` for your machine's locale" msgstr "" -#: ../../library/datetime.rst:2657 +#: ../../library/datetime.rst:2691 msgid "the hard-coded values ``UTC`` and ``GMT``" msgstr "" -#: ../../library/datetime.rst:2659 +#: ../../library/datetime.rst:2693 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:2663 +#: ../../library/datetime.rst:2697 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:2669 +#: ../../library/datetime.rst:2703 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:2674 +#: ../../library/datetime.rst:2708 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:`~." @@ -4233,7 +4286,7 @@ msgid "" "interchangeable." msgstr "" -#: ../../library/datetime.rst:2680 +#: ../../library/datetime.rst:2714 msgid "" "When used with the :meth:`~.datetime.strptime` method, the leading zero is " "optional for formats ``%d``, ``%m``, ``%H``, ``%I``, ``%M``, ``%S``, " @@ -4241,7 +4294,7 @@ msgid "" "zero." msgstr "" -#: ../../library/datetime.rst:2685 +#: ../../library/datetime.rst:2719 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, " @@ -4250,7 +4303,7 @@ msgid "" "parser is not a leap year. Users run into this bug every four years..." msgstr "" -#: ../../library/datetime.rst:2691 +#: ../../library/datetime.rst:2725 msgid "" ">>> month_day = \"02/29\"\n" ">>> datetime.strptime(f\"{month_day};1984\", \"%m/%d;%Y\") # No leap year " @@ -4258,7 +4311,7 @@ msgid "" "datetime.datetime(1984, 2, 29, 0, 0)" msgstr "" -#: ../../library/datetime.rst:2697 +#: ../../library/datetime.rst:2731 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 " @@ -4266,15 +4319,15 @@ msgid "" "See :gh:`70647`." msgstr "" -#: ../../library/datetime.rst:2704 +#: ../../library/datetime.rst:2738 msgid "Footnotes" msgstr "註解" -#: ../../library/datetime.rst:2705 +#: ../../library/datetime.rst:2739 msgid "If, that is, we ignore the effects of Relativity" msgstr "也就是說,我們會忽略相對論的效應" -#: ../../library/datetime.rst:2707 +#: ../../library/datetime.rst:2741 msgid "" "This matches the definition of the \"proleptic Gregorian\" calendar in " "Dershowitz and Reingold's book *Calendrical Calculations*, where it's the " @@ -4283,23 +4336,23 @@ msgid "" "systems." msgstr "" -#: ../../library/datetime.rst:2713 +#: ../../library/datetime.rst:2747 msgid "" "See R. H. van Gent's `guide to the mathematics of the ISO 8601 calendar " "`_ for a good explanation." msgstr "" -#: ../../library/datetime.rst:2717 +#: ../../library/datetime.rst:2751 msgid "" "Passing ``datetime.strptime('Feb 29', '%b %d')`` will fail since 1900 is not " "a leap year." msgstr "" -#: ../../library/datetime.rst:2358 +#: ../../library/datetime.rst:2392 msgid "% (percent)" msgstr "% (百分號)" -#: ../../library/datetime.rst:2358 +#: ../../library/datetime.rst:2392 msgid "datetime format" msgstr "datetime format(日期時間格式)" diff --git a/library/dbm.po b/library/dbm.po index c93cd0d4b0..3072192a9d 100644 --- a/library/dbm.po +++ b/library/dbm.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-02-16 08:33+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-" @@ -50,56 +50,44 @@ msgid "" "`_ to the Oracle Berkeley DB." msgstr "" -#: ../../includes/wasm-ios-notavail.rst:3 -msgid ":ref:`Availability `: not WASI, not iOS." -msgstr "" - -#: ../../includes/wasm-ios-notavail.rst:5 -msgid "" -"This module does not work or is not available on WebAssembly platforms, or " -"on iOS. See :ref:`wasm-availability` for more information on WASM " -"availability; see :ref:`iOS-availability` for more information on iOS " -"availability." -msgstr "" - -#: ../../library/dbm.rst:26 +#: ../../library/dbm.rst:24 msgid "" "A tuple containing the exceptions that can be raised by each of the " "supported modules, with a unique exception also named :exc:`dbm.error` as " "the first item --- the latter is used when :exc:`dbm.error` is raised." msgstr "" -#: ../../library/dbm.rst:33 +#: ../../library/dbm.rst:31 msgid "" "This function attempts to guess which of the several simple database modules " "available --- :mod:`dbm.sqlite3`, :mod:`dbm.gnu`, :mod:`dbm.ndbm`, or :mod:" "`dbm.dumb` --- should be used to open a given file." msgstr "" -#: ../../library/dbm.rst:37 +#: ../../library/dbm.rst:35 msgid "Return one of the following values:" msgstr "回傳以下其中一個值:" -#: ../../library/dbm.rst:39 +#: ../../library/dbm.rst:37 msgid "" "``None`` if the file can't be opened because it's unreadable or doesn't exist" msgstr "" -#: ../../library/dbm.rst:40 +#: ../../library/dbm.rst:38 msgid "the empty string (``''``) if the file's format can't be guessed" msgstr "" -#: ../../library/dbm.rst:41 +#: ../../library/dbm.rst:39 msgid "" "a string containing the required module name, such as ``'dbm.ndbm'`` or " "``'dbm.gnu'``" msgstr "" -#: ../../library/dbm.rst:43 ../../library/dbm.rst:248 ../../library/dbm.rst:444 +#: ../../library/dbm.rst:41 ../../library/dbm.rst:250 ../../library/dbm.rst:448 msgid "*filename* accepts a :term:`path-like object`." msgstr "" -#: ../../library/dbm.rst:67 +#: ../../library/dbm.rst:65 msgid "Open a database and return the corresponding database object." msgstr "" @@ -107,7 +95,7 @@ msgstr "" msgid "Parameters" msgstr "參數" -#: ../../library/dbm.rst:69 +#: ../../library/dbm.rst:67 msgid "" "The database file to open. If the database file already exists, the :func:" "`whichdb` function is used to determine its type and the appropriate module " @@ -115,18 +103,18 @@ msgid "" "imported is used." msgstr "" -#: ../../library/dbm.rst:70 ../../library/dbm.rst:220 +#: ../../library/dbm.rst:68 ../../library/dbm.rst:222 msgid "The database file to open." msgstr "要打開的資料庫檔案" -#: ../../library/dbm.rst:72 +#: ../../library/dbm.rst:70 msgid "" "If the database file already exists, the :func:`whichdb` function is used to " "determine its type and the appropriate module is used; if it does not exist, " "the first submodule listed above that can be imported is used." msgstr "" -#: ../../library/dbm.rst:77 ../../library/dbm.rst:178 ../../library/dbm.rst:349 +#: ../../library/dbm.rst:75 ../../library/dbm.rst:178 ../../library/dbm.rst:353 msgid "" "* ``'r'`` (default): |flag_r| * ``'w'``: |flag_w| * ``'c'``: |flag_c| * " "``'n'``: |flag_n|" @@ -134,36 +122,36 @@ msgstr "" "* ``'r'`` (default): |flag_r| * ``'w'``: |flag_w| * ``'c'``: |flag_c| * " "``'n'``: |flag_n|" -#: ../../library/dbm.rst:78 ../../library/dbm.rst:180 ../../library/dbm.rst:225 -#: ../../library/dbm.rst:350 +#: ../../library/dbm.rst:76 ../../library/dbm.rst:180 ../../library/dbm.rst:227 +#: ../../library/dbm.rst:354 msgid "``'r'`` (default): |flag_r|" msgstr "``'r'`` (default): |flag_r|" -#: ../../library/dbm.rst:79 ../../library/dbm.rst:181 ../../library/dbm.rst:226 -#: ../../library/dbm.rst:351 ../../library/dbm.rst:425 +#: ../../library/dbm.rst:77 ../../library/dbm.rst:181 ../../library/dbm.rst:228 +#: ../../library/dbm.rst:355 ../../library/dbm.rst:429 msgid "``'w'``: |flag_w|" msgstr "``'w'``: |flag_w|" -#: ../../library/dbm.rst:80 ../../library/dbm.rst:182 ../../library/dbm.rst:227 -#: ../../library/dbm.rst:352 +#: ../../library/dbm.rst:78 ../../library/dbm.rst:182 ../../library/dbm.rst:229 +#: ../../library/dbm.rst:356 msgid "``'c'``: |flag_c|" msgstr "``'c'``: |flag_c|" -#: ../../library/dbm.rst:81 ../../library/dbm.rst:183 ../../library/dbm.rst:228 -#: ../../library/dbm.rst:353 ../../library/dbm.rst:427 +#: ../../library/dbm.rst:79 ../../library/dbm.rst:183 ../../library/dbm.rst:230 +#: ../../library/dbm.rst:357 ../../library/dbm.rst:431 msgid "``'n'``: |flag_n|" msgstr "``'n'``: |flag_n|" -#: ../../library/dbm.rst:83 ../../library/dbm.rst:242 ../../library/dbm.rst:355 -#: ../../library/dbm.rst:429 +#: ../../library/dbm.rst:81 ../../library/dbm.rst:244 ../../library/dbm.rst:359 +#: ../../library/dbm.rst:433 msgid "|mode_param_doc|" msgstr "|mode_param_doc|" -#: ../../library/dbm.rst:86 +#: ../../library/dbm.rst:84 msgid "*file* accepts a :term:`path-like object`." msgstr "*file* 接受一個\\ :term:`類路徑物件 `。" -#: ../../library/dbm.rst:89 +#: ../../library/dbm.rst:87 msgid "" "The object returned by :func:`~dbm.open` supports the same basic " "functionality as a :class:`dict`; keys and their corresponding values can be " @@ -172,44 +160,44 @@ msgid "" "setdefault` methods." msgstr "" -#: ../../library/dbm.rst:94 +#: ../../library/dbm.rst:92 msgid "" "Key and values are always stored as :class:`bytes`. This means that when " "strings are used they are implicitly converted to the default encoding " "before being stored." msgstr "" -#: ../../library/dbm.rst:98 +#: ../../library/dbm.rst:96 msgid "" "These objects also support being used in a :keyword:`with` statement, which " "will automatically close them when done." msgstr "" -#: ../../library/dbm.rst:101 +#: ../../library/dbm.rst:99 msgid "" ":meth:`!get` and :meth:`!setdefault` methods are now available for all :mod:" "`dbm` backends." msgstr "" -#: ../../library/dbm.rst:105 +#: ../../library/dbm.rst:103 msgid "" "Added native support for the context management protocol to the objects " "returned by :func:`~dbm.open`." msgstr "" -#: ../../library/dbm.rst:109 +#: ../../library/dbm.rst:107 msgid "" "Deleting a key from a read-only database raises a database module specific " "exception instead of :exc:`KeyError`." msgstr "" -#: ../../library/dbm.rst:113 +#: ../../library/dbm.rst:111 msgid "" "The following example records some hostnames and a corresponding title, and " "then prints out the contents of the database::" msgstr "" -#: ../../library/dbm.rst:116 +#: ../../library/dbm.rst:114 msgid "" "import dbm\n" "\n" @@ -236,28 +224,28 @@ msgid "" "# db is automatically closed when leaving the with statement." msgstr "" -#: ../../library/dbm.rst:143 +#: ../../library/dbm.rst:141 msgid "Module :mod:`shelve`" msgstr ":mod:`shelve` 模組" -#: ../../library/dbm.rst:144 +#: ../../library/dbm.rst:142 msgid "Persistence module which stores non-string data." msgstr "" -#: ../../library/dbm.rst:147 +#: ../../library/dbm.rst:145 msgid "The individual submodules are described in the following sections." msgstr "" -#: ../../library/dbm.rst:150 +#: ../../library/dbm.rst:148 msgid ":mod:`dbm.sqlite3` --- SQLite backend for dbm" msgstr "" -#: ../../library/dbm.rst:158 +#: ../../library/dbm.rst:156 #, fuzzy msgid "**Source code:** :source:`Lib/dbm/sqlite3.py`" msgstr "**原始碼:**\\ :source:`Lib/dbm/gnu.py`" -#: ../../library/dbm.rst:162 +#: ../../library/dbm.rst:160 msgid "" "This module uses the standard library :mod:`sqlite3` module to provide an " "SQLite backend for the :mod:`dbm` module. The files created by :mod:`dbm." @@ -265,6 +253,16 @@ msgid "" "including the SQLite CLI." msgstr "" +#: ../../includes/wasm-mobile-notavail.rst:3 ../../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/dbm.rst:169 msgid "" "Open an SQLite database. The returned object behaves like a :term:`mapping`, " @@ -298,24 +296,30 @@ msgid "" "functionality like crash tolerance." msgstr "" -#: ../../library/dbm.rst:207 ../../library/dbm.rst:319 +#: ../../library/dbm.rst:207 ../../library/dbm.rst:321 msgid "" "The file formats created by :mod:`dbm.gnu` and :mod:`dbm.ndbm` are " "incompatible and can not be used interchangeably." msgstr "" -#: ../../library/dbm.rst:212 +#: ../../includes/wasm-mobile-notavail.rst:5 +msgid "" +"This module is not supported on :ref:`mobile platforms ` or :ref:`WebAssembly platforms `." +msgstr "" + +#: ../../library/dbm.rst:214 msgid "" "Raised on :mod:`dbm.gnu`-specific errors, such as I/O errors. :exc:" "`KeyError` is raised for general mapping errors like specifying an incorrect " "key." msgstr "" -#: ../../library/dbm.rst:218 +#: ../../library/dbm.rst:220 msgid "Open a GDBM database and return a :class:`!gdbm` object." msgstr "" -#: ../../library/dbm.rst:224 +#: ../../library/dbm.rst:226 msgid "" "* ``'r'`` (default): |flag_r| * ``'w'``: |flag_w| * ``'c'``: |flag_c| * " "``'n'``: |flag_n| The following additional characters may be appended to " @@ -327,29 +331,29 @@ msgid "" "flag characters." msgstr "" -#: ../../library/dbm.rst:230 +#: ../../library/dbm.rst:232 msgid "" "The following additional characters may be appended to control how the " "database is opened:" msgstr "" -#: ../../library/dbm.rst:233 +#: ../../library/dbm.rst:235 msgid "" "``'f'``: Open the database in fast mode. Writes to the database will not be " "synchronized." msgstr "" -#: ../../library/dbm.rst:235 +#: ../../library/dbm.rst:237 msgid "" "``'s'``: Synchronized mode. Changes to the database will be written " "immediately to the file." msgstr "" -#: ../../library/dbm.rst:237 +#: ../../library/dbm.rst:239 msgid "``'u'``: Do not lock database." msgstr "``'u'``: 不要鎖住資料庫。" -#: ../../library/dbm.rst:239 +#: ../../library/dbm.rst:241 msgid "" "Not all flags are valid for all versions of GDBM. See the :data:`open_flags` " "member for a list of supported flag characters." @@ -359,24 +363,24 @@ msgstr "" msgid "Raises" msgstr "引發" -#: ../../library/dbm.rst:245 +#: ../../library/dbm.rst:247 msgid "If an invalid *flag* argument is passed." msgstr "如果一個無效的 *flag* 引數被傳入。" -#: ../../library/dbm.rst:253 +#: ../../library/dbm.rst:255 msgid "" "A string of characters the *flag* parameter of :meth:`~dbm.gnu.open` " "supports." msgstr "" -#: ../../library/dbm.rst:255 +#: ../../library/dbm.rst:257 msgid "" ":class:`!gdbm` objects behave similar to :term:`mappings `, but :" "meth:`!items` and :meth:`!values` methods are not supported. The following " "methods are also provided:" msgstr "" -#: ../../library/dbm.rst:261 +#: ../../library/dbm.rst:263 msgid "" "It's possible to loop over every key in the database using this method and " "the :meth:`nextkey` method. The traversal is ordered by GDBM's internal " @@ -384,14 +388,14 @@ msgid "" "starting key." msgstr "" -#: ../../library/dbm.rst:268 +#: ../../library/dbm.rst:270 msgid "" "Returns the key that follows *key* in the traversal. The following code " "prints every key in the database ``db``, without having to create a list in " "memory that contains them all::" msgstr "" -#: ../../library/dbm.rst:272 +#: ../../library/dbm.rst:274 msgid "" "k = db.firstkey()\n" "while k is not None:\n" @@ -403,7 +407,7 @@ msgstr "" " print(k)\n" " k = db.nextkey(k)" -#: ../../library/dbm.rst:279 +#: ../../library/dbm.rst:281 msgid "" "If you have carried out a lot of deletions and would like to shrink the " "space used by the GDBM file, this routine will reorganize the database. :" @@ -412,37 +416,37 @@ msgid "" "reused as new (key, value) pairs are added." msgstr "" -#: ../../library/dbm.rst:287 +#: ../../library/dbm.rst:289 msgid "" "When the database has been opened in fast mode, this method forces any " "unwritten data to be written to the disk." msgstr "" -#: ../../library/dbm.rst:292 +#: ../../library/dbm.rst:294 msgid "Close the GDBM database." msgstr "關閉 GDBM 資料庫。" -#: ../../library/dbm.rst:296 +#: ../../library/dbm.rst:298 #, fuzzy msgid "Remove all items from the GDBM database." msgstr "關閉 GDBM 資料庫。" -#: ../../library/dbm.rst:302 +#: ../../library/dbm.rst:304 msgid ":mod:`dbm.ndbm` --- New Database Manager" msgstr ":mod:`dbm.ndbm` --- 新資料庫管理器" -#: ../../library/dbm.rst:308 +#: ../../library/dbm.rst:310 msgid "**Source code:** :source:`Lib/dbm/ndbm.py`" msgstr "**原始碼:**\\ :source:`Lib/dbm/ndbm.py`" -#: ../../library/dbm.rst:312 +#: ../../library/dbm.rst:314 msgid "" "The :mod:`dbm.ndbm` module provides an interface to the :abbr:`NDBM (New " "Database Manager)` library. This module can be used with the \"classic\" " "NDBM interface or the :abbr:`GDBM (GNU dbm)` compatibility interface." msgstr "" -#: ../../library/dbm.rst:324 +#: ../../library/dbm.rst:326 msgid "" "The NDBM library shipped as part of macOS has an undocumented limitation on " "the size of values, which can result in corrupted database files when " @@ -450,56 +454,56 @@ msgid "" "result in a hard crash (segmentation fault)." msgstr "" -#: ../../library/dbm.rst:331 +#: ../../library/dbm.rst:335 msgid "" "Raised on :mod:`dbm.ndbm`-specific errors, such as I/O errors. :exc:" "`KeyError` is raised for general mapping errors like specifying an incorrect " "key." msgstr "" -#: ../../library/dbm.rst:337 +#: ../../library/dbm.rst:341 msgid "Name of the NDBM implementation library used." msgstr "" -#: ../../library/dbm.rst:342 +#: ../../library/dbm.rst:346 msgid "Open an NDBM database and return an :class:`!ndbm` object." msgstr "" -#: ../../library/dbm.rst:344 +#: ../../library/dbm.rst:348 msgid "" "The basename of the database file (without the :file:`.dir` or :file:`.pag` " "extensions)." msgstr "" -#: ../../library/dbm.rst:358 +#: ../../library/dbm.rst:362 msgid "" ":class:`!ndbm` objects behave similar to :term:`mappings `, but :" "meth:`!items` and :meth:`!values` methods are not supported. The following " "methods are also provided:" msgstr "" -#: ../../library/dbm.rst:362 +#: ../../library/dbm.rst:366 msgid "Accepts :term:`path-like object` for filename." msgstr "" -#: ../../library/dbm.rst:367 +#: ../../library/dbm.rst:371 msgid "Close the NDBM database." msgstr "關閉 NDBM 資料庫。" -#: ../../library/dbm.rst:371 +#: ../../library/dbm.rst:375 #, fuzzy msgid "Remove all items from the NDBM database." msgstr "關閉 NDBM 資料庫。" -#: ../../library/dbm.rst:377 +#: ../../library/dbm.rst:381 msgid ":mod:`dbm.dumb` --- Portable DBM implementation" msgstr ":mod:`dbm.dumb` --- 可攜式 DBM 實作" -#: ../../library/dbm.rst:382 +#: ../../library/dbm.rst:386 msgid "**Source code:** :source:`Lib/dbm/dumb.py`" msgstr "**原始碼:**\\ :source:`Lib/dbm/dumb.py`" -#: ../../library/dbm.rst:388 +#: ../../library/dbm.rst:392 msgid "" "The :mod:`dbm.dumb` module is intended as a last resort fallback for the :" "mod:`dbm` module when a more robust module is not available. The :mod:`dbm." @@ -507,53 +511,53 @@ msgid "" "the other database modules." msgstr "" -#: ../../library/dbm.rst:395 +#: ../../library/dbm.rst:399 msgid "" "The :mod:`dbm.dumb` module provides a persistent :class:`dict`-like " "interface which is written entirely in Python. Unlike other :mod:`dbm` " "backends, such as :mod:`dbm.gnu`, no external library is required." msgstr "" -#: ../../library/dbm.rst:400 +#: ../../library/dbm.rst:404 msgid "The :mod:`!dbm.dumb` module defines the following:" msgstr ":mod:`!dbm.dumb` 模組定義了以下項目:" -#: ../../library/dbm.rst:404 +#: ../../library/dbm.rst:408 msgid "" "Raised on :mod:`dbm.dumb`-specific errors, such as I/O errors. :exc:" "`KeyError` is raised for general mapping errors like specifying an incorrect " "key." msgstr "" -#: ../../library/dbm.rst:410 +#: ../../library/dbm.rst:414 msgid "" "Open a :mod:`!dbm.dumb` database. The returned database object behaves " "similar to a :term:`mapping`, in addition to providing :meth:`~dumbdbm.sync` " "and :meth:`~dumbdbm.close` methods." msgstr "" -#: ../../library/dbm.rst:415 +#: ../../library/dbm.rst:419 msgid "" "The basename of the database file (without extensions). A new database " "creates the following files: - :file:`{filename}.dat` - :file:`{filename}." "dir`" msgstr "" -#: ../../library/dbm.rst:416 +#: ../../library/dbm.rst:420 msgid "" "The basename of the database file (without extensions). A new database " "creates the following files:" msgstr "" -#: ../../library/dbm.rst:419 +#: ../../library/dbm.rst:423 msgid ":file:`{filename}.dat`" msgstr ":file:`{filename}.dat`" -#: ../../library/dbm.rst:420 +#: ../../library/dbm.rst:424 msgid ":file:`{filename}.dir`" msgstr ":file:`{filename}.dir`" -#: ../../library/dbm.rst:423 +#: ../../library/dbm.rst:427 msgid "" "* ``'r'``: |flag_r| * ``'w'``: |flag_w| * ``'c'`` (default): |flag_c| * " "``'n'``: |flag_n|" @@ -561,49 +565,49 @@ msgstr "" "* ``'r'``: |flag_r| * ``'w'``: |flag_w| * ``'c'`` (default): |flag_c| * " "``'n'``: |flag_n|" -#: ../../library/dbm.rst:424 +#: ../../library/dbm.rst:428 msgid "``'r'``: |flag_r|" msgstr "``'r'``: |flag_r|" -#: ../../library/dbm.rst:426 +#: ../../library/dbm.rst:430 msgid "``'c'`` (default): |flag_c|" msgstr "``'c'`` (default): |flag_c|" -#: ../../library/dbm.rst:433 +#: ../../library/dbm.rst:437 msgid "" "It is possible to crash the Python interpreter when loading a database with " "a sufficiently large/complex entry due to stack depth limitations in " "Python's AST compiler." msgstr "" -#: ../../library/dbm.rst:437 +#: ../../library/dbm.rst:441 msgid "" ":func:`~dbm.dumb.open` always creates a new database when *flag* is ``'n'``." msgstr "" -#: ../../library/dbm.rst:440 +#: ../../library/dbm.rst:444 msgid "" "A database opened read-only if *flag* is ``'r'``. A database is not created " "if it does not exist if *flag* is ``'r'`` or ``'w'``." msgstr "" -#: ../../library/dbm.rst:447 +#: ../../library/dbm.rst:451 msgid "" "In addition to the methods provided by the :class:`collections.abc." "MutableMapping` class, the following methods are provided:" msgstr "" -#: ../../library/dbm.rst:453 +#: ../../library/dbm.rst:457 msgid "" "Synchronize the on-disk directory and data files. This method is called by " -"the :meth:`Shelve.sync` method." +"the :meth:`shelve.Shelf.sync` method." msgstr "" -#: ../../library/dbm.rst:458 +#: ../../library/dbm.rst:462 msgid "Close the database." msgstr "關閉資料庫。" -#: ../../library/dbm.rst:384 +#: ../../library/dbm.rst:388 msgid "databases" msgstr "databases(資料庫)" diff --git a/library/decimal.po b/library/decimal.po index 0ab719a400..1b62b499f9 100644 --- a/library/decimal.po +++ b/library/decimal.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-05-04 20:08+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-" @@ -542,10 +542,12 @@ msgid "" "Other Unicode decimal digits are also permitted where ``digit`` appears " "above. These include decimal digits from various other alphabets (for " "example, Arabic-Indic and Devanāgarī digits) along with the fullwidth digits " -"``'\\uff10'`` through ``'\\uff19'``." +"``'\\uff10'`` through ``'\\uff19'``. Case is not significant, so, for " +"example, ``inf``, ``Inf``, ``INFINITY``, and ``iNfINity`` are all acceptable " +"spellings for positive infinity." msgstr "" -#: ../../library/decimal.rst:371 +#: ../../library/decimal.rst:373 msgid "" "If *value* is a :class:`tuple`, it should have three components, a sign " "(``0`` for positive or ``1`` for negative), a :class:`tuple` of digits, and " @@ -553,7 +555,7 @@ msgid "" "``Decimal('1.414')``." msgstr "" -#: ../../library/decimal.rst:376 +#: ../../library/decimal.rst:378 msgid "" "If *value* is a :class:`float`, the binary floating-point value is " "losslessly converted to its exact decimal equivalent. This conversion can " @@ -562,7 +564,7 @@ msgid "" "``Decimal('1.100000000000000088817841970012523233890533447265625')``." msgstr "" -#: ../../library/decimal.rst:382 +#: ../../library/decimal.rst:384 msgid "" "The *context* precision does not affect how many digits are stored. That is " "determined exclusively by the number of digits in *value*. For example, " @@ -570,7 +572,7 @@ msgid "" "is only three." msgstr "" -#: ../../library/decimal.rst:387 +#: ../../library/decimal.rst:389 msgid "" "The purpose of the *context* argument is determining what to do if *value* " "is a malformed string. If the context traps :const:`InvalidOperation`, an " @@ -578,29 +580,29 @@ msgid "" "the value of ``NaN``." msgstr "" -#: ../../library/decimal.rst:392 +#: ../../library/decimal.rst:394 msgid "Once constructed, :class:`Decimal` objects are immutable." msgstr "" -#: ../../library/decimal.rst:394 +#: ../../library/decimal.rst:396 msgid "" "The argument to the constructor is now permitted to be a :class:`float` " "instance." msgstr "" -#: ../../library/decimal.rst:398 +#: ../../library/decimal.rst:400 msgid "" ":class:`float` arguments raise an exception if the :exc:`FloatOperation` " "trap is set. By default the trap is off." msgstr "" -#: ../../library/decimal.rst:402 +#: ../../library/decimal.rst:404 msgid "" "Underscores are allowed for grouping, as with integral and floating-point " "literals in code." msgstr "" -#: ../../library/decimal.rst:406 +#: ../../library/decimal.rst:408 msgid "" "Decimal floating-point objects share many properties with the other built-in " "numeric types such as :class:`float` and :class:`int`. All of the usual " @@ -610,7 +612,7 @@ msgid "" "class:`int`)." msgstr "" -#: ../../library/decimal.rst:413 +#: ../../library/decimal.rst:415 msgid "" "There are some small differences between arithmetic on Decimal objects and " "arithmetic on integers and floats. When the remainder operator ``%`` is " @@ -618,7 +620,7 @@ msgid "" "*dividend* rather than the sign of the divisor::" msgstr "" -#: ../../library/decimal.rst:418 +#: ../../library/decimal.rst:420 msgid "" ">>> (-7) % 4\n" "1\n" @@ -630,14 +632,14 @@ msgstr "" ">>> Decimal(-7) % Decimal(4)\n" "Decimal('-3')" -#: ../../library/decimal.rst:423 +#: ../../library/decimal.rst:425 msgid "" "The integer division operator ``//`` behaves analogously, returning the " "integer part of the true quotient (truncating towards zero) rather than its " "floor, so as to preserve the usual identity ``x == (x // y) * y + x % y``::" msgstr "" -#: ../../library/decimal.rst:427 +#: ../../library/decimal.rst:429 msgid "" ">>> -7 // 4\n" "-2\n" @@ -649,13 +651,13 @@ msgstr "" ">>> Decimal(-7) // Decimal(4)\n" "Decimal('-1')" -#: ../../library/decimal.rst:432 +#: ../../library/decimal.rst:434 msgid "" "The ``%`` and ``//`` operators implement the ``remainder`` and ``divide-" "integer`` operations (respectively) as described in the specification." msgstr "" -#: ../../library/decimal.rst:436 +#: ../../library/decimal.rst:438 msgid "" "Decimal objects cannot generally be combined with floats or instances of :" "class:`fractions.Fraction` in arithmetic operations: an attempt to add a :" @@ -666,19 +668,19 @@ msgid "" "numbers of different types." msgstr "" -#: ../../library/decimal.rst:444 +#: ../../library/decimal.rst:446 msgid "" "Mixed-type comparisons between :class:`Decimal` instances and other numeric " "types are now fully supported." msgstr "" -#: ../../library/decimal.rst:448 +#: ../../library/decimal.rst:450 msgid "" "In addition to the standard numeric properties, decimal floating-point " "objects also have a number of specialized methods:" msgstr "" -#: ../../library/decimal.rst:454 +#: ../../library/decimal.rst:456 msgid "" "Return the adjusted exponent after shifting out the coefficient's rightmost " "digits until only the lead digit remains: ``Decimal('321e+5').adjusted()`` " @@ -686,14 +688,14 @@ msgid "" "digit with respect to the decimal point." msgstr "" -#: ../../library/decimal.rst:461 +#: ../../library/decimal.rst:463 msgid "" "Return a pair ``(n, d)`` of integers that represent the given :class:" "`Decimal` instance as a fraction, in lowest terms and with a positive " "denominator::" msgstr "" -#: ../../library/decimal.rst:465 +#: ../../library/decimal.rst:467 msgid "" ">>> Decimal('-3.14').as_integer_ratio()\n" "(-157, 50)" @@ -701,32 +703,32 @@ msgstr "" ">>> Decimal('-3.14').as_integer_ratio()\n" "(-157, 50)" -#: ../../library/decimal.rst:468 +#: ../../library/decimal.rst:470 msgid "" "The conversion is exact. Raise OverflowError on infinities and ValueError " "on NaNs." msgstr "" -#: ../../library/decimal.rst:475 +#: ../../library/decimal.rst:477 msgid "" "Return a :term:`named tuple` representation of the number: " "``DecimalTuple(sign, digits, exponent)``." msgstr "" -#: ../../library/decimal.rst:481 +#: ../../library/decimal.rst:483 msgid "" "Return the canonical encoding of the argument. Currently, the encoding of " "a :class:`Decimal` instance is always canonical, so this operation returns " "its argument unchanged." msgstr "" -#: ../../library/decimal.rst:487 +#: ../../library/decimal.rst:489 msgid "" "Compare the values of two Decimal instances. :meth:`compare` returns a " "Decimal instance, and if either operand is a NaN then the result is a NaN::" msgstr "" -#: ../../library/decimal.rst:491 +#: ../../library/decimal.rst:493 msgid "" "a or b is a NaN ==> Decimal('NaN')\n" "a < b ==> Decimal('-1')\n" @@ -738,14 +740,14 @@ msgstr "" "a == b ==> Decimal('0')\n" "a > b ==> Decimal('1')" -#: ../../library/decimal.rst:498 +#: ../../library/decimal.rst:500 msgid "" "This operation is identical to the :meth:`compare` method, except that all " "NaNs signal. That is, if neither operand is a signaling NaN then any quiet " "NaN operand is treated as though it were a signaling NaN." msgstr "" -#: ../../library/decimal.rst:504 +#: ../../library/decimal.rst:506 msgid "" "Compare two operands using their abstract representation rather than their " "numerical value. Similar to the :meth:`compare` method, but the result " @@ -754,7 +756,7 @@ msgid "" "unequal in this ordering:" msgstr "" -#: ../../library/decimal.rst:513 +#: ../../library/decimal.rst:515 msgid "" "Quiet and signaling NaNs are also included in the total ordering. The " "result of this function is ``Decimal('0')`` if both operands have the same " @@ -764,15 +766,15 @@ msgid "" "details of the total order." msgstr "" -#: ../../library/decimal.rst:520 ../../library/decimal.rst:531 -#: ../../library/decimal.rst:559 ../../library/decimal.rst:846 +#: ../../library/decimal.rst:522 ../../library/decimal.rst:533 +#: ../../library/decimal.rst:561 ../../library/decimal.rst:848 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 " "InvalidOperation if the second operand cannot be converted exactly." msgstr "" -#: ../../library/decimal.rst:526 +#: ../../library/decimal.rst:528 msgid "" "Compare two operands using their abstract representation rather than their " "value as in :meth:`compare_total`, but ignoring the sign of each operand. " @@ -780,44 +782,44 @@ msgid "" "copy_abs())``." msgstr "" -#: ../../library/decimal.rst:537 +#: ../../library/decimal.rst:539 msgid "" "Just returns self, this method is only to comply with the Decimal " "Specification." msgstr "" -#: ../../library/decimal.rst:542 +#: ../../library/decimal.rst:544 msgid "" "Return the absolute value of the argument. This operation is unaffected by " "the context and is quiet: no flags are changed and no rounding is performed." msgstr "" -#: ../../library/decimal.rst:548 +#: ../../library/decimal.rst:550 msgid "" "Return the negation of the argument. This operation is unaffected by the " "context and is quiet: no flags are changed and no rounding is performed." msgstr "" -#: ../../library/decimal.rst:553 +#: ../../library/decimal.rst:555 msgid "" "Return a copy of the first operand with the sign set to be the same as the " "sign of the second operand. For example:" msgstr "" -#: ../../library/decimal.rst:565 +#: ../../library/decimal.rst:567 msgid "" "Return the value of the (natural) exponential function ``e**x`` at the given " "number. The result is correctly rounded using the :const:`ROUND_HALF_EVEN` " "rounding mode." msgstr "" -#: ../../library/decimal.rst:576 +#: ../../library/decimal.rst:578 msgid "" "Alternative constructor that only accepts instances of :class:`float` or :" "class:`int`." msgstr "" -#: ../../library/decimal.rst:579 +#: ../../library/decimal.rst:581 msgid "" "Note ``Decimal.from_float(0.1)`` is not the same as ``Decimal('0.1')``. " "Since 0.1 is not exactly representable in binary floating point, the value " @@ -826,13 +828,13 @@ msgid "" "``0.1000000000000000055511151231257827021181583404541015625``." msgstr "" -#: ../../library/decimal.rst:585 +#: ../../library/decimal.rst:587 msgid "" "From Python 3.2 onwards, a :class:`Decimal` instance can also be constructed " "directly from a :class:`float`." msgstr "" -#: ../../library/decimal.rst:588 +#: ../../library/decimal.rst:590 msgid "" ">>> Decimal.from_float(0.1)\n" "Decimal('0.1000000000000000055511151231257827021181583404541015625')\n" @@ -852,86 +854,86 @@ msgstr "" ">>> Decimal.from_float(float('-inf'))\n" "Decimal('-Infinity')" -#: ../../library/decimal.rst:603 +#: ../../library/decimal.rst:605 msgid "" "Fused multiply-add. Return self*other+third with no rounding of the " "intermediate product self*other." msgstr "" -#: ../../library/decimal.rst:611 +#: ../../library/decimal.rst:613 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:617 +#: ../../library/decimal.rst:619 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:622 +#: ../../library/decimal.rst:624 msgid "" "Return :const:`True` if the argument is either positive or negative infinity " "and :const:`False` otherwise." msgstr "" -#: ../../library/decimal.rst:627 +#: ../../library/decimal.rst:629 msgid "" "Return :const:`True` if the argument is a (quiet or signaling) NaN and :" "const:`False` otherwise." msgstr "" -#: ../../library/decimal.rst:632 +#: ../../library/decimal.rst:634 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:637 +#: ../../library/decimal.rst:639 msgid "" "Return :const:`True` if the argument is a quiet NaN, and :const:`False` " "otherwise." msgstr "" -#: ../../library/decimal.rst:642 +#: ../../library/decimal.rst:644 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:647 +#: ../../library/decimal.rst:649 msgid "" "Return :const:`True` if the argument is a signaling NaN and :const:`False` " "otherwise." msgstr "" -#: ../../library/decimal.rst:652 +#: ../../library/decimal.rst:654 msgid "" "Return :const:`True` if the argument is subnormal, and :const:`False` " "otherwise." msgstr "" -#: ../../library/decimal.rst:657 +#: ../../library/decimal.rst:659 msgid "" "Return :const:`True` if the argument is a (positive or negative) zero and :" "const:`False` otherwise." msgstr "" -#: ../../library/decimal.rst:662 +#: ../../library/decimal.rst:664 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:667 +#: ../../library/decimal.rst:669 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:672 +#: ../../library/decimal.rst:674 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('-" @@ -939,74 +941,74 @@ msgid "" "the operand is an infinity then ``Decimal('Infinity')`` is returned." msgstr "" -#: ../../library/decimal.rst:680 +#: ../../library/decimal.rst:682 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:686 +#: ../../library/decimal.rst:688 msgid "" ":meth:`logical_invert` is a logical operation. The result is the digit-wise " "inversion of the operand." msgstr "" -#: ../../library/decimal.rst:691 +#: ../../library/decimal.rst:693 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:697 +#: ../../library/decimal.rst:699 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:703 +#: ../../library/decimal.rst:705 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:710 +#: ../../library/decimal.rst:712 msgid "" "Similar to the :meth:`.max` method, but the comparison is done using the " "absolute values of the operands." msgstr "" -#: ../../library/decimal.rst:715 +#: ../../library/decimal.rst:717 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:722 +#: ../../library/decimal.rst:724 msgid "" "Similar to the :meth:`.min` method, but the comparison is done using the " "absolute values of the operands." msgstr "" -#: ../../library/decimal.rst:727 +#: ../../library/decimal.rst:729 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:733 +#: ../../library/decimal.rst:735 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:739 +#: ../../library/decimal.rst:741 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 " @@ -1014,13 +1016,13 @@ msgid "" "be the same as the sign of the second operand." msgstr "" -#: ../../library/decimal.rst:746 +#: ../../library/decimal.rst:748 msgid "" "Used for producing canonical values of an equivalence class within either " "the current context or the specified context." msgstr "" -#: ../../library/decimal.rst:749 +#: ../../library/decimal.rst:751 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 " @@ -1030,79 +1032,79 @@ msgid "" "exponent is set to 0. In all cases the sign is unchanged." msgstr "" -#: ../../library/decimal.rst:756 +#: ../../library/decimal.rst:758 msgid "" "For example, ``Decimal('32.100')`` and ``Decimal('0.321000e+2')`` both " "normalize to the equivalent value ``Decimal('32.1')``." msgstr "" -#: ../../library/decimal.rst:759 +#: ../../library/decimal.rst:761 msgid "Note that rounding is applied *before* reducing to simplest form." msgstr "" -#: ../../library/decimal.rst:761 +#: ../../library/decimal.rst:763 msgid "" "In the latest versions of the specification, this operation is also known as " "``reduce``." msgstr "" -#: ../../library/decimal.rst:766 +#: ../../library/decimal.rst:768 msgid "" "Return a string describing the *class* of the operand. The returned value " "is one of the following ten strings." msgstr "" -#: ../../library/decimal.rst:769 +#: ../../library/decimal.rst:771 msgid "``\"-Infinity\"``, indicating that the operand is negative infinity." msgstr "" -#: ../../library/decimal.rst:770 +#: ../../library/decimal.rst:772 msgid "" "``\"-Normal\"``, indicating that the operand is a negative normal number." msgstr "" -#: ../../library/decimal.rst:771 +#: ../../library/decimal.rst:773 msgid "" "``\"-Subnormal\"``, indicating that the operand is negative and subnormal." msgstr "" -#: ../../library/decimal.rst:772 +#: ../../library/decimal.rst:774 msgid "``\"-Zero\"``, indicating that the operand is a negative zero." msgstr "" -#: ../../library/decimal.rst:773 +#: ../../library/decimal.rst:775 msgid "``\"+Zero\"``, indicating that the operand is a positive zero." msgstr "" -#: ../../library/decimal.rst:774 +#: ../../library/decimal.rst:776 msgid "" "``\"+Subnormal\"``, indicating that the operand is positive and subnormal." msgstr "" -#: ../../library/decimal.rst:775 +#: ../../library/decimal.rst:777 msgid "" "``\"+Normal\"``, indicating that the operand is a positive normal number." msgstr "" -#: ../../library/decimal.rst:776 +#: ../../library/decimal.rst:778 msgid "``\"+Infinity\"``, indicating that the operand is positive infinity." msgstr "" -#: ../../library/decimal.rst:777 +#: ../../library/decimal.rst:779 msgid "``\"NaN\"``, indicating that the operand is a quiet NaN (Not a Number)." msgstr "" -#: ../../library/decimal.rst:778 +#: ../../library/decimal.rst:780 msgid "``\"sNaN\"``, indicating that the operand is a signaling NaN." msgstr "" -#: ../../library/decimal.rst:782 +#: ../../library/decimal.rst:784 msgid "" "Return a value equal to the first operand after rounding and having the " "exponent of the second operand." msgstr "" -#: ../../library/decimal.rst:788 +#: ../../library/decimal.rst:790 msgid "" "Unlike other operations, if the length of the coefficient after the quantize " "operation would be greater than precision, then an :const:`InvalidOperation` " @@ -1110,13 +1112,13 @@ msgid "" "quantized exponent is always equal to that of the right-hand operand." msgstr "" -#: ../../library/decimal.rst:794 +#: ../../library/decimal.rst:796 msgid "" "Also unlike other operations, quantize never signals Underflow, even if the " "result is subnormal and inexact." msgstr "" -#: ../../library/decimal.rst:797 +#: ../../library/decimal.rst:799 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 " @@ -1125,19 +1127,19 @@ msgid "" "context is used." msgstr "" -#: ../../library/decimal.rst:803 +#: ../../library/decimal.rst:805 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:808 +#: ../../library/decimal.rst:810 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:814 +#: ../../library/decimal.rst:816 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 " @@ -1146,11 +1148,11 @@ msgid "" "other``, and if two integers are equally near then the even one is chosen." msgstr "" -#: ../../library/decimal.rst:821 +#: ../../library/decimal.rst:823 msgid "If the result is zero then its sign will be the sign of *self*." msgstr "" -#: ../../library/decimal.rst:832 +#: ../../library/decimal.rst:834 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 " @@ -1162,20 +1164,20 @@ msgid "" "are unchanged." msgstr "" -#: ../../library/decimal.rst:843 +#: ../../library/decimal.rst:845 msgid "" "Test whether self and other have the same exponent or whether both are " "``NaN``." msgstr "" -#: ../../library/decimal.rst:852 +#: ../../library/decimal.rst:854 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:858 +#: ../../library/decimal.rst:860 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 " @@ -1186,34 +1188,34 @@ msgid "" "exponent of the first operand are unchanged." msgstr "" -#: ../../library/decimal.rst:868 +#: ../../library/decimal.rst:870 msgid "Return the square root of the argument to full precision." msgstr "" -#: ../../library/decimal.rst:873 ../../library/decimal.rst:1510 +#: ../../library/decimal.rst:875 ../../library/decimal.rst:1512 msgid "" "Convert to a string, using engineering notation if an exponent is needed." msgstr "" -#: ../../library/decimal.rst:875 ../../library/decimal.rst:1512 +#: ../../library/decimal.rst:877 ../../library/decimal.rst:1514 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:879 +#: ../../library/decimal.rst:881 msgid "" "For example, this converts ``Decimal('123E+1')`` to ``Decimal('1.23E+3')``." msgstr "" -#: ../../library/decimal.rst:883 +#: ../../library/decimal.rst:885 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:888 +#: ../../library/decimal.rst:890 msgid "" "Round to the nearest integer, signaling :const:`Inexact` or :const:`Rounded` " "as appropriate if rounding occurs. The rounding mode is determined by the " @@ -1221,18 +1223,18 @@ msgid "" "parameter is given then the rounding mode of the current context is used." msgstr "" -#: ../../library/decimal.rst:896 +#: ../../library/decimal.rst:898 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:900 +#: ../../library/decimal.rst:902 msgid "Decimal numbers can be rounded using the :func:`.round` function:" msgstr "" -#: ../../library/decimal.rst:905 +#: ../../library/decimal.rst:907 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 :" @@ -1240,7 +1242,7 @@ msgid "" "infinity or :exc:`ValueError` if it is a (quiet or signaling) NaN." msgstr "" -#: ../../library/decimal.rst:911 +#: ../../library/decimal.rst:913 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 " @@ -1252,27 +1254,27 @@ msgid "" "the current context's precision. In other words, for the non-corner cases:" msgstr "" -#: ../../library/decimal.rst:921 +#: ../../library/decimal.rst:923 msgid "" "if *ndigits* is positive, return *number* rounded to *ndigits* decimal " "places;" msgstr "" -#: ../../library/decimal.rst:923 +#: ../../library/decimal.rst:925 msgid "if *ndigits* is zero, return *number* rounded to the nearest integer;" msgstr "" -#: ../../library/decimal.rst:924 +#: ../../library/decimal.rst:926 msgid "" "if *ndigits* is negative, return *number* rounded to the nearest multiple of " "``10**abs(ndigits)``." msgstr "" -#: ../../library/decimal.rst:927 +#: ../../library/decimal.rst:929 msgid "For example::" msgstr "" -#: ../../library/decimal.rst:929 +#: ../../library/decimal.rst:931 msgid "" ">>> from decimal import Decimal, getcontext, ROUND_DOWN\n" ">>> getcontext().rounding = ROUND_DOWN\n" @@ -1288,11 +1290,11 @@ msgid "" "Decimal('0E+1')" msgstr "" -#: ../../library/decimal.rst:946 +#: ../../library/decimal.rst:948 msgid "Logical operands" msgstr "" -#: ../../library/decimal.rst:948 +#: ../../library/decimal.rst:950 msgid "" "The :meth:`~Decimal.logical_and`, :meth:`~Decimal.logical_invert`, :meth:" "`~Decimal.logical_or`, and :meth:`~Decimal.logical_xor` methods expect their " @@ -1301,38 +1303,38 @@ msgid "" "are all either ``0`` or ``1``." msgstr "" -#: ../../library/decimal.rst:960 +#: ../../library/decimal.rst:962 msgid "Context objects" msgstr "" -#: ../../library/decimal.rst:962 +#: ../../library/decimal.rst:964 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:966 +#: ../../library/decimal.rst:968 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:972 +#: ../../library/decimal.rst:974 msgid "Return the current context for the active thread." msgstr "" -#: ../../library/decimal.rst:977 +#: ../../library/decimal.rst:979 msgid "Set the current context for the active thread to *c*." msgstr "" -#: ../../library/decimal.rst:979 +#: ../../library/decimal.rst:981 msgid "" "You can also use the :keyword:`with` statement and the :func:`localcontext` " "function to temporarily change the active context." msgstr "" -#: ../../library/decimal.rst:984 +#: ../../library/decimal.rst:986 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 " @@ -1341,14 +1343,14 @@ msgid "" "used to set the attributes of the new context." msgstr "" -#: ../../library/decimal.rst:990 +#: ../../library/decimal.rst:992 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:993 +#: ../../library/decimal.rst:995 msgid "" "from decimal import localcontext\n" "\n" @@ -1358,11 +1360,11 @@ msgid "" "s = +s # Round the final result back to the default precision" msgstr "" -#: ../../library/decimal.rst:1000 +#: ../../library/decimal.rst:1002 msgid "Using keyword arguments, the code would be the following::" msgstr "" -#: ../../library/decimal.rst:1002 +#: ../../library/decimal.rst:1004 msgid "" "from decimal import localcontext\n" "\n" @@ -1376,26 +1378,26 @@ msgstr "" " s = calculate_something()\n" "s = +s" -#: ../../library/decimal.rst:1008 +#: ../../library/decimal.rst:1010 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:1012 +#: ../../library/decimal.rst:1014 msgid "" ":meth:`localcontext` now supports setting context attributes through the use " "of keyword arguments." msgstr "" -#: ../../library/decimal.rst:1015 +#: ../../library/decimal.rst:1017 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:1021 +#: ../../library/decimal.rst:1023 msgid "" "This is a standard context defined by the General Decimal Arithmetic " "Specification. Precision is set to nine. Rounding is set to :const:" @@ -1404,12 +1406,12 @@ msgid "" "`Subnormal`." msgstr "" -#: ../../library/decimal.rst:1027 +#: ../../library/decimal.rst:1029 msgid "" "Because many of the traps are enabled, this context is useful for debugging." msgstr "" -#: ../../library/decimal.rst:1032 +#: ../../library/decimal.rst:1034 msgid "" "This is a standard context defined by the General Decimal Arithmetic " "Specification. Precision is set to nine. Rounding is set to :const:" @@ -1417,7 +1419,7 @@ msgid "" "exceptions are not raised during computations)." msgstr "" -#: ../../library/decimal.rst:1037 +#: ../../library/decimal.rst:1039 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 " @@ -1425,7 +1427,7 @@ msgid "" "conditions that would otherwise halt the program." msgstr "" -#: ../../library/decimal.rst:1045 +#: ../../library/decimal.rst:1047 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 " @@ -1433,7 +1435,7 @@ msgid "" "constructor." msgstr "" -#: ../../library/decimal.rst:1049 +#: ../../library/decimal.rst:1051 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 " @@ -1441,65 +1443,65 @@ msgid "" "as it would require thread synchronization to prevent race conditions." msgstr "" -#: ../../library/decimal.rst:1054 +#: ../../library/decimal.rst:1056 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:1057 +#: ../../library/decimal.rst:1059 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:1062 +#: ../../library/decimal.rst:1064 msgid "" "In addition to the three supplied contexts, new contexts can be created with " "the :class:`Context` constructor." msgstr "" -#: ../../library/decimal.rst:1068 +#: ../../library/decimal.rst:1070 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:1072 +#: ../../library/decimal.rst:1074 msgid "" "*prec* is an integer in the range [``1``, :const:`MAX_PREC`] that sets the " "precision for arithmetic operations in the context." msgstr "" -#: ../../library/decimal.rst:1075 +#: ../../library/decimal.rst:1077 msgid "" "The *rounding* option is one of the constants listed in the section " "`Rounding Modes`_." msgstr "" -#: ../../library/decimal.rst:1078 +#: ../../library/decimal.rst:1080 msgid "" "The *traps* and *flags* fields list any signals to be set. Generally, new " "contexts should only set traps and leave the flags clear." msgstr "" -#: ../../library/decimal.rst:1081 +#: ../../library/decimal.rst:1083 msgid "" "The *Emin* and *Emax* fields are 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:1085 +#: ../../library/decimal.rst:1087 msgid "" "The *capitals* field is 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:1089 +#: ../../library/decimal.rst:1091 msgid "" "The *clamp* field is either ``0`` (the default) or ``1``. If set to ``1``, " "the exponent ``e`` of a :class:`Decimal` instance representable in this " @@ -1513,7 +1515,7 @@ msgid "" "For example::" msgstr "" -#: ../../library/decimal.rst:1101 +#: ../../library/decimal.rst:1103 msgid "" ">>> Context(prec=6, Emax=999, clamp=1).create_decimal('1.23e999')\n" "Decimal('1.23000E+999')" @@ -1521,13 +1523,13 @@ msgstr "" ">>> Context(prec=6, Emax=999, clamp=1).create_decimal('1.23e999')\n" "Decimal('1.23000E+999')" -#: ../../library/decimal.rst:1104 +#: ../../library/decimal.rst:1106 msgid "" "A *clamp* value of ``1`` allows compatibility with the fixed-width decimal " "interchange formats specified in IEEE 754." msgstr "" -#: ../../library/decimal.rst:1107 +#: ../../library/decimal.rst:1109 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 " @@ -1540,30 +1542,30 @@ msgid "" "instance of :class:`int`) anywhere that a Decimal instance is accepted." msgstr "" -#: ../../library/decimal.rst:1120 +#: ../../library/decimal.rst:1122 msgid "Resets all of the flags to ``0``." msgstr "" -#: ../../library/decimal.rst:1124 +#: ../../library/decimal.rst:1126 msgid "Resets all of the traps to ``0``." msgstr "" -#: ../../library/decimal.rst:1130 +#: ../../library/decimal.rst:1132 msgid "Return a duplicate of the context." msgstr "" -#: ../../library/decimal.rst:1134 +#: ../../library/decimal.rst:1136 msgid "Return a copy of the Decimal instance num." msgstr "" -#: ../../library/decimal.rst:1138 +#: ../../library/decimal.rst:1140 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:1142 +#: ../../library/decimal.rst:1144 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 " @@ -1572,7 +1574,7 @@ msgid "" "sum can change the result:" msgstr "" -#: ../../library/decimal.rst:1148 +#: ../../library/decimal.rst:1150 msgid "" ">>> getcontext().prec = 3\n" ">>> Decimal('3.4445') + Decimal('1.0023')\n" @@ -1586,14 +1588,14 @@ msgstr "" ">>> Decimal('3.4445') + Decimal(0) + Decimal('1.0023')\n" "Decimal('4.44')" -#: ../../library/decimal.rst:1156 +#: ../../library/decimal.rst:1158 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:1162 +#: ../../library/decimal.rst:1164 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 " @@ -1601,7 +1603,7 @@ msgid "" "conversion." msgstr "" -#: ../../library/decimal.rst:1167 +#: ../../library/decimal.rst:1169 msgid "" ">>> context = Context(prec=5, rounding=ROUND_DOWN)\n" ">>> context.create_decimal_from_float(math.pi)\n" @@ -1621,18 +1623,18 @@ msgstr "" " ...\n" "decimal.Inexact: None" -#: ../../library/decimal.rst:1182 +#: ../../library/decimal.rst:1184 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:1188 +#: ../../library/decimal.rst:1190 msgid "Returns a value equal to ``Emax - prec + 1``." msgstr "" -#: ../../library/decimal.rst:1190 +#: ../../library/decimal.rst:1192 msgid "" "The usual approach to working with decimals is to create :class:`Decimal` " "instances and then apply arithmetic operations which take place within the " @@ -1642,189 +1644,189 @@ msgid "" "recounted here." msgstr "" -#: ../../library/decimal.rst:1200 +#: ../../library/decimal.rst:1202 msgid "Returns the absolute value of *x*." msgstr "" -#: ../../library/decimal.rst:1205 +#: ../../library/decimal.rst:1207 msgid "Return the sum of *x* and *y*." msgstr "" -#: ../../library/decimal.rst:1210 +#: ../../library/decimal.rst:1212 msgid "Returns the same Decimal object *x*." msgstr "" -#: ../../library/decimal.rst:1215 +#: ../../library/decimal.rst:1217 msgid "Compares *x* and *y* numerically." msgstr "" -#: ../../library/decimal.rst:1220 +#: ../../library/decimal.rst:1222 msgid "Compares the values of the two operands numerically." msgstr "" -#: ../../library/decimal.rst:1225 +#: ../../library/decimal.rst:1227 msgid "Compares two operands using their abstract representation." msgstr "" -#: ../../library/decimal.rst:1230 +#: ../../library/decimal.rst:1232 msgid "" "Compares two operands using their abstract representation, ignoring sign." msgstr "" -#: ../../library/decimal.rst:1235 +#: ../../library/decimal.rst:1237 msgid "Returns a copy of *x* with the sign set to 0." msgstr "" -#: ../../library/decimal.rst:1240 +#: ../../library/decimal.rst:1242 msgid "Returns a copy of *x* with the sign inverted." msgstr "" -#: ../../library/decimal.rst:1245 +#: ../../library/decimal.rst:1247 msgid "Copies the sign from *y* to *x*." msgstr "" -#: ../../library/decimal.rst:1250 +#: ../../library/decimal.rst:1252 msgid "Return *x* divided by *y*." msgstr "" -#: ../../library/decimal.rst:1255 +#: ../../library/decimal.rst:1257 msgid "Return *x* divided by *y*, truncated to an integer." msgstr "" -#: ../../library/decimal.rst:1260 +#: ../../library/decimal.rst:1262 msgid "Divides two numbers and returns the integer part of the result." msgstr "" -#: ../../library/decimal.rst:1265 +#: ../../library/decimal.rst:1267 msgid "Returns ``e ** x``." msgstr "" -#: ../../library/decimal.rst:1270 +#: ../../library/decimal.rst:1272 msgid "Returns *x* multiplied by *y*, plus *z*." msgstr "" -#: ../../library/decimal.rst:1275 +#: ../../library/decimal.rst:1277 msgid "Returns ``True`` if *x* is canonical; otherwise returns ``False``." msgstr "" -#: ../../library/decimal.rst:1280 +#: ../../library/decimal.rst:1282 msgid "Returns ``True`` if *x* is finite; otherwise returns ``False``." msgstr "" -#: ../../library/decimal.rst:1285 +#: ../../library/decimal.rst:1287 msgid "Returns ``True`` if *x* is infinite; otherwise returns ``False``." msgstr "" -#: ../../library/decimal.rst:1290 +#: ../../library/decimal.rst:1292 msgid "Returns ``True`` if *x* is a qNaN or sNaN; otherwise returns ``False``." msgstr "" -#: ../../library/decimal.rst:1295 +#: ../../library/decimal.rst:1297 msgid "" "Returns ``True`` if *x* is a normal number; otherwise returns ``False``." msgstr "" -#: ../../library/decimal.rst:1300 +#: ../../library/decimal.rst:1302 msgid "Returns ``True`` if *x* is a quiet NaN; otherwise returns ``False``." msgstr "" -#: ../../library/decimal.rst:1305 +#: ../../library/decimal.rst:1307 msgid "Returns ``True`` if *x* is negative; otherwise returns ``False``." msgstr "" -#: ../../library/decimal.rst:1310 +#: ../../library/decimal.rst:1312 msgid "" "Returns ``True`` if *x* is a signaling NaN; otherwise returns ``False``." msgstr "" -#: ../../library/decimal.rst:1315 +#: ../../library/decimal.rst:1317 msgid "Returns ``True`` if *x* is subnormal; otherwise returns ``False``." msgstr "" -#: ../../library/decimal.rst:1320 +#: ../../library/decimal.rst:1322 msgid "Returns ``True`` if *x* is a zero; otherwise returns ``False``." msgstr "" -#: ../../library/decimal.rst:1325 +#: ../../library/decimal.rst:1327 msgid "Returns the natural (base e) logarithm of *x*." msgstr "" -#: ../../library/decimal.rst:1330 +#: ../../library/decimal.rst:1332 msgid "Returns the base 10 logarithm of *x*." msgstr "" -#: ../../library/decimal.rst:1335 +#: ../../library/decimal.rst:1337 msgid "Returns the exponent of the magnitude of the operand's MSD." msgstr "" -#: ../../library/decimal.rst:1340 +#: ../../library/decimal.rst:1342 msgid "Applies the logical operation *and* between each operand's digits." msgstr "" -#: ../../library/decimal.rst:1345 +#: ../../library/decimal.rst:1347 msgid "Invert all the digits in *x*." msgstr "" -#: ../../library/decimal.rst:1350 +#: ../../library/decimal.rst:1352 msgid "Applies the logical operation *or* between each operand's digits." msgstr "" -#: ../../library/decimal.rst:1355 +#: ../../library/decimal.rst:1357 msgid "Applies the logical operation *xor* between each operand's digits." msgstr "" -#: ../../library/decimal.rst:1360 +#: ../../library/decimal.rst:1362 msgid "Compares two values numerically and returns the maximum." msgstr "" -#: ../../library/decimal.rst:1365 ../../library/decimal.rst:1375 +#: ../../library/decimal.rst:1367 ../../library/decimal.rst:1377 msgid "Compares the values numerically with their sign ignored." msgstr "" -#: ../../library/decimal.rst:1370 +#: ../../library/decimal.rst:1372 msgid "Compares two values numerically and returns the minimum." msgstr "" -#: ../../library/decimal.rst:1380 +#: ../../library/decimal.rst:1382 msgid "Minus corresponds to the unary prefix minus operator in Python." msgstr "" -#: ../../library/decimal.rst:1385 +#: ../../library/decimal.rst:1387 msgid "Return the product of *x* and *y*." msgstr "" -#: ../../library/decimal.rst:1390 +#: ../../library/decimal.rst:1392 msgid "Returns the largest representable number smaller than *x*." msgstr "" -#: ../../library/decimal.rst:1395 +#: ../../library/decimal.rst:1397 msgid "Returns the smallest representable number larger than *x*." msgstr "" -#: ../../library/decimal.rst:1400 +#: ../../library/decimal.rst:1402 msgid "Returns the number closest to *x*, in direction towards *y*." msgstr "" -#: ../../library/decimal.rst:1405 +#: ../../library/decimal.rst:1407 msgid "Reduces *x* to its simplest form." msgstr "" -#: ../../library/decimal.rst:1410 +#: ../../library/decimal.rst:1412 msgid "Returns an indication of the class of *x*." msgstr "" -#: ../../library/decimal.rst:1415 +#: ../../library/decimal.rst:1417 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:1422 +#: ../../library/decimal.rst:1424 msgid "Return ``x`` to the power of ``y``, reduced modulo ``modulo`` if given." msgstr "" -#: ../../library/decimal.rst:1424 +#: ../../library/decimal.rst:1426 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 " @@ -1833,42 +1835,42 @@ msgid "" "in the Python version." msgstr "" -#: ../../library/decimal.rst:1430 +#: ../../library/decimal.rst:1432 msgid "" "``Decimal(0) ** Decimal(0)`` results in ``InvalidOperation``, and if " "``InvalidOperation`` is not trapped, then results in ``Decimal('NaN')``." msgstr "" -#: ../../library/decimal.rst:1433 +#: ../../library/decimal.rst:1435 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:1438 +#: ../../library/decimal.rst:1440 msgid "" "With three arguments, compute ``(x**y) % modulo``. For the three argument " "form, the following restrictions on the arguments hold:" msgstr "" -#: ../../library/decimal.rst:1441 +#: ../../library/decimal.rst:1443 msgid "all three arguments must be integral" msgstr "" -#: ../../library/decimal.rst:1442 +#: ../../library/decimal.rst:1444 msgid "``y`` must be nonnegative" msgstr "" -#: ../../library/decimal.rst:1443 +#: ../../library/decimal.rst:1445 msgid "at least one of ``x`` or ``y`` must be nonzero" msgstr "" -#: ../../library/decimal.rst:1444 +#: ../../library/decimal.rst:1446 msgid "``modulo`` must be nonzero and have at most 'precision' digits" msgstr "" -#: ../../library/decimal.rst:1446 +#: ../../library/decimal.rst:1448 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 " @@ -1877,110 +1879,110 @@ msgid "" "result is always exact." msgstr "" -#: ../../library/decimal.rst:1456 +#: ../../library/decimal.rst:1458 msgid "Returns a value equal to *x* (rounded), having the exponent of *y*." msgstr "" -#: ../../library/decimal.rst:1461 +#: ../../library/decimal.rst:1463 msgid "Just returns 10, as this is Decimal, :)" msgstr "" -#: ../../library/decimal.rst:1466 +#: ../../library/decimal.rst:1468 msgid "Returns the remainder from integer division." msgstr "" -#: ../../library/decimal.rst:1468 +#: ../../library/decimal.rst:1470 msgid "" "The sign of the result, if non-zero, is the same as that of the original " "dividend." msgstr "" -#: ../../library/decimal.rst:1474 +#: ../../library/decimal.rst:1476 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:1480 +#: ../../library/decimal.rst:1482 msgid "Returns a rotated copy of *x*, *y* times." msgstr "" -#: ../../library/decimal.rst:1485 +#: ../../library/decimal.rst:1487 msgid "Returns ``True`` if the two operands have the same exponent." msgstr "" -#: ../../library/decimal.rst:1490 +#: ../../library/decimal.rst:1492 msgid "Returns the first operand after adding the second value its exp." msgstr "" -#: ../../library/decimal.rst:1495 +#: ../../library/decimal.rst:1497 msgid "Returns a shifted copy of *x*, *y* times." msgstr "" -#: ../../library/decimal.rst:1500 +#: ../../library/decimal.rst:1502 msgid "Square root of a non-negative number to context precision." msgstr "" -#: ../../library/decimal.rst:1505 +#: ../../library/decimal.rst:1507 msgid "Return the difference between *x* and *y*." msgstr "" -#: ../../library/decimal.rst:1519 +#: ../../library/decimal.rst:1521 msgid "Rounds to an integer." msgstr "" -#: ../../library/decimal.rst:1524 +#: ../../library/decimal.rst:1526 msgid "Converts a number to a string using scientific notation." msgstr "" -#: ../../library/decimal.rst:1531 +#: ../../library/decimal.rst:1533 msgid "Constants" msgstr "常數" -#: ../../library/decimal.rst:1533 +#: ../../library/decimal.rst:1535 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:1537 +#: ../../library/decimal.rst:1539 msgid "32-bit" msgstr "32 位元" -#: ../../library/decimal.rst:1537 +#: ../../library/decimal.rst:1539 msgid "64-bit" msgstr "64 位元" -#: ../../library/decimal.rst:1539 ../../library/decimal.rst:1541 +#: ../../library/decimal.rst:1541 ../../library/decimal.rst:1543 msgid "``425000000``" msgstr "``425000000``" -#: ../../library/decimal.rst:1539 ../../library/decimal.rst:1541 +#: ../../library/decimal.rst:1541 ../../library/decimal.rst:1543 msgid "``999999999999999999``" msgstr "``999999999999999999``" -#: ../../library/decimal.rst:1543 +#: ../../library/decimal.rst:1545 msgid "``-425000000``" msgstr "``-425000000``" -#: ../../library/decimal.rst:1543 +#: ../../library/decimal.rst:1545 msgid "``-999999999999999999``" msgstr "``-999999999999999999``" -#: ../../library/decimal.rst:1545 +#: ../../library/decimal.rst:1547 msgid "``-849999999``" msgstr "``-849999999``" -#: ../../library/decimal.rst:1545 +#: ../../library/decimal.rst:1547 msgid "``-1999999999999999997``" msgstr "``-1999999999999999997``" -#: ../../library/decimal.rst:1551 +#: ../../library/decimal.rst:1553 msgid "" "The value is ``True``. Deprecated, because Python now always has threads." msgstr "" -#: ../../library/decimal.rst:1557 +#: ../../library/decimal.rst:1559 msgid "" "The default value is ``True``. If Python is :option:`configured using the --" "without-decimal-contextvar option <--without-decimal-contextvar>`, the C " @@ -1989,55 +1991,55 @@ msgid "" "scenarios." msgstr "" -#: ../../library/decimal.rst:1566 +#: ../../library/decimal.rst:1568 msgid "Rounding modes" msgstr "" -#: ../../library/decimal.rst:1570 +#: ../../library/decimal.rst:1572 msgid "Round towards ``Infinity``." msgstr "" -#: ../../library/decimal.rst:1574 +#: ../../library/decimal.rst:1576 msgid "Round towards zero." msgstr "" -#: ../../library/decimal.rst:1578 +#: ../../library/decimal.rst:1580 msgid "Round towards ``-Infinity``." msgstr "" -#: ../../library/decimal.rst:1582 +#: ../../library/decimal.rst:1584 msgid "Round to nearest with ties going towards zero." msgstr "" -#: ../../library/decimal.rst:1586 +#: ../../library/decimal.rst:1588 msgid "Round to nearest with ties going to nearest even integer." msgstr "" -#: ../../library/decimal.rst:1590 +#: ../../library/decimal.rst:1592 msgid "Round to nearest with ties going away from zero." msgstr "" -#: ../../library/decimal.rst:1594 +#: ../../library/decimal.rst:1596 msgid "Round away from zero." msgstr "" -#: ../../library/decimal.rst:1598 +#: ../../library/decimal.rst:1600 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:1605 +#: ../../library/decimal.rst:1607 msgid "Signals" msgstr "" -#: ../../library/decimal.rst:1607 +#: ../../library/decimal.rst:1609 msgid "" "Signals represent conditions that arise during computation. Each corresponds " "to one context flag and one context trap enabler." msgstr "" -#: ../../library/decimal.rst:1610 +#: ../../library/decimal.rst:1612 msgid "" "The context flag is set whenever the condition is encountered. After the " "computation, flags may be checked for informational purposes (for instance, " @@ -2045,7 +2047,7 @@ msgid "" "sure to clear all flags before starting the next computation." msgstr "" -#: ../../library/decimal.rst:1615 +#: ../../library/decimal.rst:1617 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:" @@ -2053,54 +2055,54 @@ msgid "" "raised upon encountering the condition." msgstr "" -#: ../../library/decimal.rst:1623 +#: ../../library/decimal.rst:1625 msgid "Altered an exponent to fit representation constraints." msgstr "" -#: ../../library/decimal.rst:1625 +#: ../../library/decimal.rst:1627 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:1632 +#: ../../library/decimal.rst:1634 msgid "Base class for other signals and a subclass of :exc:`ArithmeticError`." msgstr "" -#: ../../library/decimal.rst:1637 +#: ../../library/decimal.rst:1639 msgid "Signals the division of a non-infinite number by zero." msgstr "" -#: ../../library/decimal.rst:1639 +#: ../../library/decimal.rst:1641 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:1646 +#: ../../library/decimal.rst:1648 msgid "Indicates that rounding occurred and the result is not exact." msgstr "" -#: ../../library/decimal.rst:1648 +#: ../../library/decimal.rst:1650 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:1655 +#: ../../library/decimal.rst:1657 msgid "An invalid operation was performed." msgstr "" -#: ../../library/decimal.rst:1657 +#: ../../library/decimal.rst:1659 msgid "" "Indicates that an operation was requested that does not make sense. If not " "trapped, returns ``NaN``. Possible causes include::" msgstr "" -#: ../../library/decimal.rst:1660 +#: ../../library/decimal.rst:1662 msgid "" "Infinity - Infinity\n" "0 * Infinity\n" @@ -2122,11 +2124,11 @@ msgstr "" "x ** (non-integer)\n" "x ** Infinity" -#: ../../library/decimal.rst:1673 +#: ../../library/decimal.rst:1675 msgid "Numerical overflow." msgstr "" -#: ../../library/decimal.rst:1675 +#: ../../library/decimal.rst:1677 msgid "" "Indicates the exponent is larger than :attr:`Context.Emax` after rounding " "has occurred. If not trapped, the result depends on the rounding mode, " @@ -2135,42 +2137,42 @@ msgid "" "`Rounded` are also signaled." msgstr "" -#: ../../library/decimal.rst:1684 +#: ../../library/decimal.rst:1686 msgid "Rounding occurred though possibly no information was lost." msgstr "" -#: ../../library/decimal.rst:1686 +#: ../../library/decimal.rst:1688 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:1694 +#: ../../library/decimal.rst:1696 msgid "Exponent was lower than :attr:`~Context.Emin` prior to rounding." msgstr "" -#: ../../library/decimal.rst:1696 +#: ../../library/decimal.rst:1698 msgid "" "Occurs when an operation result is subnormal (the exponent is too small). If " "not trapped, returns the result unchanged." msgstr "" -#: ../../library/decimal.rst:1702 +#: ../../library/decimal.rst:1704 msgid "Numerical underflow with result rounded to zero." msgstr "" -#: ../../library/decimal.rst:1704 +#: ../../library/decimal.rst:1706 msgid "" "Occurs when a subnormal result is pushed to zero by rounding. :class:" "`Inexact` and :class:`Subnormal` are also signaled." msgstr "" -#: ../../library/decimal.rst:1710 +#: ../../library/decimal.rst:1712 msgid "Enable stricter semantics for mixing floats and Decimals." msgstr "" -#: ../../library/decimal.rst:1712 +#: ../../library/decimal.rst:1714 msgid "" "If the signal is not trapped (default), mixing floats and Decimals is " "permitted in the :class:`~decimal.Decimal` constructor, :meth:`~decimal." @@ -2181,18 +2183,18 @@ msgid "" "Context.create_decimal_from_float` do not set the flag." msgstr "" -#: ../../library/decimal.rst:1720 +#: ../../library/decimal.rst:1722 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:1724 +#: ../../library/decimal.rst:1726 msgid "The following table summarizes the hierarchy of signals::" msgstr "" -#: ../../library/decimal.rst:1726 +#: ../../library/decimal.rst:1728 msgid "" "exceptions.ArithmeticError(exceptions.Exception)\n" " DecimalException\n" @@ -2218,15 +2220,15 @@ msgstr "" " Subnormal\n" " FloatOperation(DecimalException, exceptions.TypeError)" -#: ../../library/decimal.rst:1745 +#: ../../library/decimal.rst:1747 msgid "Floating-Point Notes" msgstr "" -#: ../../library/decimal.rst:1749 +#: ../../library/decimal.rst:1751 msgid "Mitigating round-off error with increased precision" msgstr "" -#: ../../library/decimal.rst:1751 +#: ../../library/decimal.rst:1753 msgid "" "The use of decimal floating point eliminates decimal representation error " "(making it possible to represent ``0.1`` exactly); however, some operations " @@ -2234,7 +2236,7 @@ msgid "" "precision." msgstr "" -#: ../../library/decimal.rst:1755 +#: ../../library/decimal.rst:1757 msgid "" "The effects of round-off error can be amplified by the addition or " "subtraction of nearly offsetting quantities resulting in loss of " @@ -2243,7 +2245,7 @@ msgid "" "of the associative and distributive properties of addition:" msgstr "" -#: ../../library/decimal.rst:1761 +#: ../../library/decimal.rst:1763 msgid "" "# Examples from Seminumerical Algorithms, Section 4.2.2.\n" ">>> from decimal import Decimal, getcontext\n" @@ -2262,13 +2264,13 @@ msgid "" "Decimal('0.0060000')" msgstr "" -#: ../../library/decimal.rst:1779 +#: ../../library/decimal.rst:1781 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:1782 +#: ../../library/decimal.rst:1784 msgid "" ">>> getcontext().prec = 20\n" ">>> u, v, w = Decimal(11111113), Decimal(-11111111), Decimal('7.51111111')\n" @@ -2284,18 +2286,18 @@ msgid "" "Decimal('0.0060000')" msgstr "" -#: ../../library/decimal.rst:1799 +#: ../../library/decimal.rst:1801 msgid "Special values" msgstr "特殊值" -#: ../../library/decimal.rst:1801 +#: ../../library/decimal.rst:1803 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:1805 +#: ../../library/decimal.rst:1807 msgid "" "Infinities can be constructed directly with: ``Decimal('Infinity')``. Also, " "they can arise from dividing by zero when the :exc:`DivisionByZero` signal " @@ -2304,14 +2306,14 @@ msgid "" "representable number." msgstr "" -#: ../../library/decimal.rst:1810 +#: ../../library/decimal.rst:1812 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:1814 +#: ../../library/decimal.rst:1816 msgid "" "Some operations are indeterminate and return ``NaN``, or if the :exc:" "`InvalidOperation` signal is trapped, raise an exception. For example, " @@ -2322,14 +2324,14 @@ msgid "" "the calculation to proceed while flagging specific results as invalid." msgstr "" -#: ../../library/decimal.rst:1822 +#: ../../library/decimal.rst:1824 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:1826 +#: ../../library/decimal.rst:1828 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 " @@ -2346,7 +2348,7 @@ msgid "" "compare_signal` methods instead." msgstr "" -#: ../../library/decimal.rst:1839 +#: ../../library/decimal.rst:1841 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 " @@ -2354,7 +2356,7 @@ msgid "" "negative zeros are treated as equal and their sign is informational." msgstr "" -#: ../../library/decimal.rst:1844 +#: ../../library/decimal.rst:1846 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 " @@ -2363,11 +2365,11 @@ msgid "" "that the following calculation returns a value equal to zero:" msgstr "" -#: ../../library/decimal.rst:1859 +#: ../../library/decimal.rst:1861 msgid "Working with threads" msgstr "" -#: ../../library/decimal.rst:1861 +#: ../../library/decimal.rst:1863 msgid "" "The :func:`getcontext` function accesses a different :class:`Context` object " "for each thread. Having separate thread contexts means that threads may " @@ -2375,20 +2377,20 @@ msgid "" "other threads." msgstr "" -#: ../../library/decimal.rst:1865 +#: ../../library/decimal.rst:1867 msgid "" "Likewise, the :func:`setcontext` function automatically assigns its target " "to the current thread." msgstr "" -#: ../../library/decimal.rst:1868 +#: ../../library/decimal.rst:1870 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." msgstr "" -#: ../../library/decimal.rst:1872 +#: ../../library/decimal.rst:1874 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 " @@ -2397,7 +2399,7 @@ msgid "" "a race condition between threads calling :func:`getcontext`. For example::" msgstr "" -#: ../../library/decimal.rst:1878 +#: ../../library/decimal.rst:1880 msgid "" "# Set applicationwide defaults for all threads about to be launched\n" "DefaultContext.prec = 12\n" @@ -2413,17 +2415,17 @@ msgid "" " . . ." msgstr "" -#: ../../library/decimal.rst:1897 +#: ../../library/decimal.rst:1899 msgid "Recipes" msgstr "" -#: ../../library/decimal.rst:1899 +#: ../../library/decimal.rst:1901 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:1902 +#: ../../library/decimal.rst:1904 msgid "" "def moneyfmt(value, places=2, curr='', sep=',', dp='.',\n" " pos='', neg='-', trailneg=''):\n" @@ -2572,41 +2574,41 @@ msgid "" " return +s" msgstr "" -#: ../../library/decimal.rst:2054 +#: ../../library/decimal.rst:2056 msgid "Decimal FAQ" msgstr "" -#: ../../library/decimal.rst:2056 +#: ../../library/decimal.rst:2058 msgid "" "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:2059 +#: ../../library/decimal.rst:2061 msgid "A. Some users abbreviate the constructor to just a single letter:" msgstr "" -#: ../../library/decimal.rst:2065 +#: ../../library/decimal.rst:2067 msgid "" "Q. In a fixed-point application with two decimal places, some inputs have " "many places and need to be rounded. Others are not supposed to have excess " "digits and need to be validated. What methods should be used?" msgstr "" -#: ../../library/decimal.rst:2069 +#: ../../library/decimal.rst:2071 msgid "" "A. The :meth:`~Decimal.quantize` method rounds to a fixed number of decimal " "places. If the :const:`Inexact` trap is set, it is also useful for " "validation:" msgstr "" -#: ../../library/decimal.rst:2087 +#: ../../library/decimal.rst:2089 msgid "" "Q. Once I have valid two place inputs, how do I maintain that invariant " "throughout an application?" msgstr "" -#: ../../library/decimal.rst:2090 +#: ../../library/decimal.rst:2092 msgid "" "A. Some operations like addition, subtraction, and multiplication by an " "integer will automatically preserve fixed point. Others operations, like " @@ -2614,13 +2616,13 @@ msgid "" "places and need to be followed-up with a :meth:`~Decimal.quantize` step:" msgstr "" -#: ../../library/decimal.rst:2108 +#: ../../library/decimal.rst:2110 msgid "" "In developing fixed-point applications, it is convenient to define functions " "to handle the :meth:`~Decimal.quantize` step:" msgstr "" -#: ../../library/decimal.rst:2122 +#: ../../library/decimal.rst:2124 msgid "" "Q. There are many ways to express the same value. The numbers ``200``, " "``200.000``, ``2E2``, and ``.02E+4`` all have the same value at various " @@ -2628,17 +2630,17 @@ msgid "" "canonical value?" msgstr "" -#: ../../library/decimal.rst:2127 +#: ../../library/decimal.rst:2129 msgid "" "A. The :meth:`~Decimal.normalize` method maps all equivalent values to a " "single representative:" msgstr "" -#: ../../library/decimal.rst:2134 +#: ../../library/decimal.rst:2136 msgid "Q. When does rounding occur in a computation?" msgstr "" -#: ../../library/decimal.rst:2136 +#: ../../library/decimal.rst:2138 msgid "" "A. It occurs *after* the computation. The philosophy of the decimal " "specification is that numbers are considered exact and are created " @@ -2648,7 +2650,7 @@ msgid "" "computation::" msgstr "" -#: ../../library/decimal.rst:2143 +#: ../../library/decimal.rst:2145 msgid "" ">>> getcontext().prec = 5\n" ">>> pi = Decimal('3.1415926535') # More than 5 digits\n" @@ -2662,13 +2664,13 @@ msgid "" "Decimal('3.1416')" msgstr "" -#: ../../library/decimal.rst:2154 +#: ../../library/decimal.rst:2156 msgid "" "Q. Some decimal values always print with exponential notation. Is there a " "way to get a non-exponential representation?" msgstr "" -#: ../../library/decimal.rst:2157 +#: ../../library/decimal.rst:2159 msgid "" "A. For some values, exponential notation is the only way to express the " "number of significant places in the coefficient. For example, expressing " @@ -2676,25 +2678,25 @@ msgid "" "original's two-place significance." msgstr "" -#: ../../library/decimal.rst:2162 +#: ../../library/decimal.rst:2164 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:2172 +#: ../../library/decimal.rst:2174 msgid "Q. Is there a way to convert a regular float to a :class:`Decimal`?" msgstr "" -#: ../../library/decimal.rst:2174 +#: ../../library/decimal.rst:2176 msgid "" "A. Yes, any binary floating-point number can be exactly expressed as a " "Decimal though an exact conversion may take more precision than intuition " "would suggest:" msgstr "" -#: ../../library/decimal.rst:2178 +#: ../../library/decimal.rst:2180 msgid "" ">>> Decimal(math.pi)\n" "Decimal('3.141592653589793115997963468544185161590576171875')" @@ -2702,13 +2704,13 @@ msgstr "" ">>> Decimal(math.pi)\n" "Decimal('3.141592653589793115997963468544185161590576171875')" -#: ../../library/decimal.rst:2183 +#: ../../library/decimal.rst:2185 msgid "" "Q. Within a complex calculation, how can I make sure that I haven't gotten a " "spurious result because of insufficient precision or rounding anomalies." msgstr "" -#: ../../library/decimal.rst:2186 +#: ../../library/decimal.rst:2188 msgid "" "A. The decimal module makes it easy to test results. A best practice is to " "re-run calculations using greater precision and with various rounding modes. " @@ -2716,14 +2718,14 @@ msgid "" "issues, ill-conditioned inputs, or a numerically unstable algorithm." msgstr "" -#: ../../library/decimal.rst:2191 +#: ../../library/decimal.rst:2193 msgid "" "Q. I noticed that context precision is applied to the results of operations " "but not to the inputs. Is there anything to watch out for when mixing " "values of different precisions?" msgstr "" -#: ../../library/decimal.rst:2195 +#: ../../library/decimal.rst:2197 msgid "" "A. Yes. The principle is that all values are considered to be exact and so " "is the arithmetic on those values. Only the results are rounded. The " @@ -2732,7 +2734,7 @@ msgid "" "haven't been rounded:" msgstr "" -#: ../../library/decimal.rst:2200 +#: ../../library/decimal.rst:2202 msgid "" ">>> getcontext().prec = 3\n" ">>> Decimal('3.104') + Decimal('2.104')\n" @@ -2746,30 +2748,30 @@ msgstr "" ">>> Decimal('3.104') + Decimal('0.000') + Decimal('2.104')\n" "Decimal('5.20')" -#: ../../library/decimal.rst:2208 +#: ../../library/decimal.rst:2210 msgid "" "The solution is either to increase precision or to force rounding of inputs " "using the unary plus operation:" msgstr "" -#: ../../library/decimal.rst:2211 +#: ../../library/decimal.rst:2213 msgid "" ">>> getcontext().prec = 3\n" ">>> +Decimal('1.23456789') # unary plus triggers rounding\n" "Decimal('1.23')" msgstr "" -#: ../../library/decimal.rst:2217 +#: ../../library/decimal.rst:2219 msgid "" "Alternatively, inputs can be rounded upon creation using the :meth:`Context." "create_decimal` method:" msgstr "" -#: ../../library/decimal.rst:2223 +#: ../../library/decimal.rst:2225 msgid "Q. Is the CPython implementation fast for large numbers?" msgstr "" -#: ../../library/decimal.rst:2225 +#: ../../library/decimal.rst:2227 msgid "" "A. Yes. In the CPython and PyPy3 implementations, the C/CFFI versions of " "the decimal module integrate the high speed `libmpdec >> setcontext(Context(prec=MAX_PREC, Emax=MAX_EMAX, Emin=MIN_EMIN))\n" ">>> x = Decimal(2) ** 256\n" @@ -2808,13 +2810,13 @@ msgstr "" ">>> x / 128\n" "Decimal('904625697166532776746648320380374280103671755200316906558262375061821325312')" -#: ../../library/decimal.rst:2248 +#: ../../library/decimal.rst:2250 msgid "" -"For inexact results, :attr:`MAX_PREC` is far too large on 64-bit platforms " +"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:2251 +#: ../../library/decimal.rst:2253 msgid "" ">>> Decimal(1) / 3\n" "Traceback (most recent call last):\n" @@ -2826,7 +2828,7 @@ msgstr "" " File \"\", line 1, in \n" "MemoryError" -#: ../../library/decimal.rst:2256 +#: ../../library/decimal.rst:2258 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 " @@ -2834,7 +2836,7 @@ msgid "" "of 500MB each::" msgstr "" -#: ../../library/decimal.rst:2260 +#: ../../library/decimal.rst:2262 msgid "" ">>> import sys\n" ">>>\n" @@ -2858,14 +2860,14 @@ msgid "" " decimal.Inexact: []" msgstr "" -#: ../../library/decimal.rst:2280 +#: ../../library/decimal.rst:2282 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:2289 +#: ../../library/decimal.rst:2291 msgid "" "This approach now works for all exact results except for non-integer powers." msgstr "" diff --git a/library/dis.po b/library/dis.po index 1d488345c8..e7ae667596 100644 --- a/library/dis.po +++ b/library/dis.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-04-24 05:56+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-" @@ -152,43 +152,43 @@ msgstr "" msgid "Show inline caches." msgstr "" -#: ../../library/dis.rst:104 +#: ../../library/dis.rst:106 msgid "Show offsets of instructions." msgstr "" -#: ../../library/dis.rst:106 +#: ../../library/dis.rst:110 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:110 +#: ../../library/dis.rst:114 msgid "Bytecode analysis" msgstr "" -#: ../../library/dis.rst:114 +#: ../../library/dis.rst:118 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." msgstr "" -#: ../../library/dis.rst:121 +#: ../../library/dis.rst:125 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:125 +#: ../../library/dis.rst:129 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:129 ../../library/dis.rst:326 +#: ../../library/dis.rst:133 ../../library/dis.rst:330 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 +196,73 @@ msgid "" "code object." msgstr "" -#: ../../library/dis.rst:134 +#: ../../library/dis.rst:138 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:138 +#: ../../library/dis.rst:142 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:141 +#: ../../library/dis.rst:145 msgid "" "If *adaptive* is ``True``, :meth:`.dis` will display specialized bytecode " "that may be different from the original bytecode." msgstr "" -#: ../../library/dis.rst:144 +#: ../../library/dis.rst:148 msgid "" "If *show_offsets* is ``True``, :meth:`.dis` will include instruction offsets " "in the output." msgstr "" -#: ../../library/dis.rst:149 +#: ../../library/dis.rst:153 msgid "" "Construct a :class:`Bytecode` instance from the given traceback, setting " "*current_offset* to the instruction responsible for the exception." msgstr "" -#: ../../library/dis.rst:154 +#: ../../library/dis.rst:158 msgid "The compiled code object." msgstr "" -#: ../../library/dis.rst:158 +#: ../../library/dis.rst:162 msgid "The first source line of the code object (if available)" msgstr "" -#: ../../library/dis.rst:162 +#: ../../library/dis.rst:166 msgid "" "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:167 +#: ../../library/dis.rst:171 msgid "" "Return a formatted multi-line string with detailed information about the " "code object, like :func:`code_info`." msgstr "" -#: ../../library/dis.rst:170 ../../library/dis.rst:210 -#: ../../library/dis.rst:262 +#: ../../library/dis.rst:174 ../../library/dis.rst:214 +#: ../../library/dis.rst:266 msgid "This can now handle coroutine and asynchronous generator objects." msgstr "" -#: ../../library/dis.rst:173 ../../library/dis.rst:265 -#: ../../library/dis.rst:282 ../../library/dis.rst:312 -#: ../../library/dis.rst:335 +#: ../../library/dis.rst:177 ../../library/dis.rst:269 +#: ../../library/dis.rst:286 ../../library/dis.rst:316 +#: ../../library/dis.rst:339 msgid "Added the *show_caches* and *adaptive* parameters." msgstr "新增 *show_caches* 與 *adaptive* 參數。" -#: ../../library/dis.rst:176 +#: ../../library/dis.rst:180 msgid "Example:" msgstr "範例:" -#: ../../library/dis.rst:178 +#: ../../library/dis.rst:182 msgid "" ">>> bytecode = dis.Bytecode(myfunc)\n" ">>> for instr in bytecode:\n" @@ -284,11 +284,11 @@ msgstr "" "CALL\n" "RETURN_VALUE" -#: ../../library/dis.rst:192 +#: ../../library/dis.rst:196 msgid "Analysis functions" msgstr "" -#: ../../library/dis.rst:194 +#: ../../library/dis.rst:198 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 +296,39 @@ msgid "" "isn't useful:" msgstr "" -#: ../../library/dis.rst:200 +#: ../../library/dis.rst:204 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:204 +#: ../../library/dis.rst:208 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:216 +#: ../../library/dis.rst:220 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:220 +#: ../../library/dis.rst:224 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:225 ../../library/dis.rst:256 -#: ../../library/dis.rst:279 ../../library/dis.rst:309 +#: ../../library/dis.rst:229 ../../library/dis.rst:260 +#: ../../library/dis.rst:283 ../../library/dis.rst:313 msgid "Added *file* parameter." msgstr "新增 *file* 參數。" -#: ../../library/dis.rst:231 +#: ../../library/dis.rst:235 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 +344,103 @@ msgid "" "disassembles the last traceback." msgstr "" -#: ../../library/dis.rst:244 ../../library/dis.rst:276 -#: ../../library/dis.rst:306 +#: ../../library/dis.rst:248 ../../library/dis.rst:280 +#: ../../library/dis.rst:310 msgid "" "The disassembly is written as text to the supplied *file* argument if " "provided and to ``sys.stdout`` otherwise." msgstr "" -#: ../../library/dis.rst:247 +#: ../../library/dis.rst:251 msgid "" "The maximal depth of recursion is limited by *depth* unless it is ``None``. " "``depth=0`` means no recursion." msgstr "" -#: ../../library/dis.rst:250 +#: ../../library/dis.rst:254 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:253 +#: ../../library/dis.rst:257 msgid "" "If *adaptive* is ``True``, this function will display specialized bytecode " "that may be different from the original bytecode." msgstr "" -#: ../../library/dis.rst:259 +#: ../../library/dis.rst:263 msgid "Implemented recursive disassembling and added *depth* parameter." msgstr "" -#: ../../library/dis.rst:272 +#: ../../library/dis.rst:276 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:285 ../../library/dis.rst:315 +#: ../../library/dis.rst:289 ../../library/dis.rst:319 msgid "Added the *show_offsets* parameter." msgstr "新增 *show_offsets* 參數。" -#: ../../library/dis.rst:292 +#: ../../library/dis.rst:296 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:295 +#: ../../library/dis.rst:299 msgid "the line number, for the first instruction of each line" msgstr "" -#: ../../library/dis.rst:296 +#: ../../library/dis.rst:300 msgid "the current instruction, indicated as ``-->``," msgstr "" -#: ../../library/dis.rst:297 +#: ../../library/dis.rst:301 msgid "a labelled instruction, indicated with ``>>``," msgstr "" -#: ../../library/dis.rst:298 +#: ../../library/dis.rst:302 msgid "the address of the instruction," msgstr "" -#: ../../library/dis.rst:299 +#: ../../library/dis.rst:303 msgid "the operation code name," msgstr "" -#: ../../library/dis.rst:300 +#: ../../library/dis.rst:304 msgid "operation parameters, and" msgstr "" -#: ../../library/dis.rst:301 +#: ../../library/dis.rst:305 msgid "interpretation of the parameters in parentheses." msgstr "" -#: ../../library/dis.rst:303 +#: ../../library/dis.rst:307 msgid "" "The parameter interpretation recognizes local and global variable names, " "constant values, branch targets, and compare operators." msgstr "" -#: ../../library/dis.rst:320 +#: ../../library/dis.rst:324 msgid "" "Return an iterator over the instructions in the supplied function, method, " "source code string or code object." msgstr "" -#: ../../library/dis.rst:323 +#: ../../library/dis.rst:327 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:331 +#: ../../library/dis.rst:335 msgid "The *adaptive* parameter works as it does in :func:`dis`." msgstr "" -#: ../../library/dis.rst:338 +#: ../../library/dis.rst:342 msgid "" "The *show_caches* parameter is deprecated and has no effect. The iterator " "generates the :class:`Instruction` instances with the *cache_info* field " @@ -448,7 +448,7 @@ msgid "" "generates separate items for the cache entries." msgstr "" -#: ../../library/dis.rst:346 +#: ../../library/dis.rst:350 msgid "" "This generator function uses the :meth:`~codeobject.co_lines` method of the :" "ref:`code object ` *code* to find the offsets which are starts " @@ -456,33 +456,33 @@ msgid "" "pairs." msgstr "" -#: ../../library/dis.rst:351 +#: ../../library/dis.rst:355 msgid "Line numbers can be decreasing. Before, they were always increasing." msgstr "" -#: ../../library/dis.rst:354 +#: ../../library/dis.rst:358 msgid "" "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:359 +#: ../../library/dis.rst:363 msgid "" "Line numbers can be ``None`` for bytecode that does not map to source lines." msgstr "" -#: ../../library/dis.rst:365 +#: ../../library/dis.rst:369 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:371 +#: ../../library/dis.rst:375 msgid "Compute the stack effect of *opcode* with argument *oparg*." msgstr "" -#: ../../library/dis.rst:373 +#: ../../library/dis.rst:377 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 +490,11 @@ msgid "" "it will return the maximal stack effect of both cases." msgstr "" -#: ../../library/dis.rst:380 +#: ../../library/dis.rst:384 msgid "Added *jump* parameter." msgstr "新增 *jump* 參數。" -#: ../../library/dis.rst:383 +#: ../../library/dis.rst:387 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,170 +502,178 @@ msgid "" "does not use it; the ``oparg`` in this case is ignored." msgstr "" -#: ../../library/dis.rst:393 +#: ../../library/dis.rst:397 msgid "Python Bytecode Instructions" msgstr "" -#: ../../library/dis.rst:395 +#: ../../library/dis.rst:399 msgid "" "The :func:`get_instructions` function and :class:`Bytecode` class provide " "details of bytecode instructions as :class:`Instruction` instances:" msgstr "" -#: ../../library/dis.rst:400 +#: ../../library/dis.rst:404 msgid "Details for a bytecode operation" msgstr "" -#: ../../library/dis.rst:404 +#: ../../library/dis.rst:408 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:410 +#: ../../library/dis.rst:414 msgid "human readable name for operation" msgstr "" -#: ../../library/dis.rst:415 +#: ../../library/dis.rst:419 msgid "" "numeric code for the base operation if operation is specialized; otherwise " "equal to :data:`opcode`" msgstr "" -#: ../../library/dis.rst:421 +#: ../../library/dis.rst:425 msgid "" "human readable name for the base operation if operation is specialized; " "otherwise equal to :data:`opname`" msgstr "" -#: ../../library/dis.rst:427 +#: ../../library/dis.rst:431 msgid "numeric argument to operation (if any), otherwise ``None``" msgstr "" -#: ../../library/dis.rst:431 +#: ../../library/dis.rst:435 msgid "alias for :data:`arg`" msgstr "" -#: ../../library/dis.rst:435 +#: ../../library/dis.rst:439 msgid "resolved arg value (if any), otherwise ``None``" msgstr "" -#: ../../library/dis.rst:440 +#: ../../library/dis.rst:444 msgid "" "human readable description of operation argument (if any), otherwise an " "empty string." msgstr "" -#: ../../library/dis.rst:446 +#: ../../library/dis.rst:450 msgid "start index of operation within bytecode sequence" msgstr "" -#: ../../library/dis.rst:451 +#: ../../library/dis.rst:455 msgid "" "start index of operation within bytecode sequence, including prefixed " "``EXTENDED_ARG`` operations if present; otherwise equal to :data:`offset`" msgstr "" -#: ../../library/dis.rst:457 +#: ../../library/dis.rst:461 msgid "start index of the cache entries following the operation" msgstr "" -#: ../../library/dis.rst:462 +#: ../../library/dis.rst:466 msgid "end index of the cache entries following the operation" msgstr "" -#: ../../library/dis.rst:467 +#: ../../library/dis.rst:471 msgid "``True`` if this opcode starts a source line, otherwise ``False``" msgstr "" -#: ../../library/dis.rst:472 +#: ../../library/dis.rst:476 msgid "" "source line number associated with this opcode (if any), otherwise ``None``" msgstr "" -#: ../../library/dis.rst:477 +#: ../../library/dis.rst:481 msgid "``True`` if other code jumps to here, otherwise ``False``" msgstr "" -#: ../../library/dis.rst:482 +#: ../../library/dis.rst:486 msgid "" "bytecode index of the jump target if this is a jump operation, otherwise " "``None``" msgstr "" -#: ../../library/dis.rst:488 +#: ../../library/dis.rst:492 msgid "" ":class:`dis.Positions` object holding the start and end locations that are " "covered by this instruction." msgstr "" -#: ../../library/dis.rst:503 -msgid "Field ``positions`` is added." +#: ../../library/dis.rst:497 +msgid "" +"Information about the cache entries of this instruction, as triplets of the " +"form ``(name, size, data)``, where the ``name`` and ``size`` describe the " +"cache format and data is the contents of the cache. ``cache_info`` is " +"``None`` if the instruction does not have caches." msgstr "" #: ../../library/dis.rst:507 +msgid "Field ``positions`` is added." +msgstr "" + +#: ../../library/dis.rst:511 msgid "Changed field ``starts_line``." msgstr "" -#: ../../library/dis.rst:509 +#: ../../library/dis.rst:513 msgid "" "Added fields ``start_offset``, ``cache_offset``, ``end_offset``, " "``baseopname``, ``baseopcode``, ``jump_target``, ``oparg``, ``line_number`` " "and ``cache_info``." msgstr "" -#: ../../library/dis.rst:516 +#: ../../library/dis.rst:520 msgid "" "In case the information is not available, some fields might be ``None``." msgstr "" -#: ../../library/dis.rst:526 +#: ../../library/dis.rst:530 msgid "" "The Python compiler currently generates the following bytecode instructions." msgstr "" -#: ../../library/dis.rst:529 +#: ../../library/dis.rst:533 msgid "**General instructions**" msgstr "" -#: ../../library/dis.rst:531 +#: ../../library/dis.rst:535 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:537 +#: ../../library/dis.rst:541 msgid "" "Do nothing code. Used as a placeholder by the bytecode optimizer, and to " "generate line tracing events." msgstr "" -#: ../../library/dis.rst:543 +#: ../../library/dis.rst:547 msgid "Removes the top-of-stack item::" msgstr "" -#: ../../library/dis.rst:545 +#: ../../library/dis.rst:549 msgid "STACK.pop()" msgstr "STACK.pop()" -#: ../../library/dis.rst:550 +#: ../../library/dis.rst:554 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:559 +#: ../../library/dis.rst:563 msgid "Implements ``del STACK[-2]``. Used to clean up when a generator exits." msgstr "" -#: ../../library/dis.rst:567 +#: ../../library/dis.rst:571 msgid "" "Push the i-th item to the top of the stack without removing it from its " "original location::" msgstr "" -#: ../../library/dis.rst:570 +#: ../../library/dis.rst:574 msgid "" "assert i > 0\n" "STACK.append(STACK[-i])" @@ -673,15 +681,15 @@ msgstr "" "assert i > 0\n" "STACK.append(STACK[-i])" -#: ../../library/dis.rst:578 +#: ../../library/dis.rst:582 msgid "Swap the top of the stack with the i-th element::" msgstr "" -#: ../../library/dis.rst:580 +#: ../../library/dis.rst:584 msgid "STACK[-i], STACK[-1] = STACK[-1], STACK[-i]" msgstr "STACK[-i], STACK[-1] = STACK[-1], STACK[-i]" -#: ../../library/dis.rst:587 +#: ../../library/dis.rst:591 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 " @@ -689,86 +697,86 @@ msgid "" "viewed with ``show_caches=True``." msgstr "" -#: ../../library/dis.rst:592 +#: ../../library/dis.rst:596 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:596 +#: ../../library/dis.rst:600 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:603 +#: ../../library/dis.rst:607 msgid "**Unary operations**" msgstr "" -#: ../../library/dis.rst:605 +#: ../../library/dis.rst:609 msgid "" "Unary operations take the top of the stack, apply the operation, and push " "the result back on the stack." msgstr "" -#: ../../library/dis.rst:611 +#: ../../library/dis.rst:615 msgid "Implements ``STACK[-1] = -STACK[-1]``." msgstr "" -#: ../../library/dis.rst:616 +#: ../../library/dis.rst:620 msgid "Implements ``STACK[-1] = not STACK[-1]``." msgstr "" -#: ../../library/dis.rst:618 ../../library/dis.rst:1313 -#: ../../library/dis.rst:1329 +#: ../../library/dis.rst:622 ../../library/dis.rst:1318 +#: ../../library/dis.rst:1334 msgid "This instruction now requires an exact :class:`bool` operand." msgstr "" -#: ../../library/dis.rst:624 +#: ../../library/dis.rst:628 msgid "Implements ``STACK[-1] = ~STACK[-1]``." msgstr "" -#: ../../library/dis.rst:629 +#: ../../library/dis.rst:633 msgid "Implements ``STACK[-1] = iter(STACK[-1])``." msgstr "" -#: ../../library/dis.rst:634 +#: ../../library/dis.rst:638 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:642 +#: ../../library/dis.rst:646 msgid "Implements ``STACK[-1] = bool(STACK[-1])``." msgstr "" -#: ../../library/dis.rst:647 +#: ../../library/dis.rst:651 msgid "**Binary and in-place operations**" msgstr "" -#: ../../library/dis.rst:649 +#: ../../library/dis.rst:653 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:652 +#: ../../library/dis.rst:656 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:659 +#: ../../library/dis.rst:663 msgid "" "Implements the binary and in-place operators (depending on the value of " "*op*)::" msgstr "" -#: ../../library/dis.rst:662 +#: ../../library/dis.rst:666 msgid "" "rhs = STACK.pop()\n" "lhs = STACK.pop()\n" @@ -778,17 +786,17 @@ msgstr "" "lhs = STACK.pop()\n" "STACK.append(lhs op rhs)" -#: ../../library/dis.rst:671 ../../library/dis.rst:680 -#: ../../library/dis.rst:690 ../../library/dis.rst:698 -#: ../../library/dis.rst:710 ../../library/dis.rst:798 -#: ../../library/dis.rst:808 ../../library/dis.rst:818 -#: ../../library/dis.rst:1041 ../../library/dis.rst:1052 -#: ../../library/dis.rst:1156 ../../library/dis.rst:1168 -#: ../../library/dis.rst:1180 +#: ../../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:673 +#: ../../library/dis.rst:677 msgid "" "key = STACK.pop()\n" "container = STACK.pop()\n" @@ -798,7 +806,7 @@ msgstr "" "container = STACK.pop()\n" "STACK.append(container[key])" -#: ../../library/dis.rst:682 +#: ../../library/dis.rst:686 msgid "" "key = STACK.pop()\n" "container = STACK.pop()\n" @@ -810,7 +818,7 @@ msgstr "" "value = STACK.pop()\n" "container[key] = value" -#: ../../library/dis.rst:692 +#: ../../library/dis.rst:696 msgid "" "key = STACK.pop()\n" "container = STACK.pop()\n" @@ -820,7 +828,7 @@ msgstr "" "container = STACK.pop()\n" "del container[key]" -#: ../../library/dis.rst:700 +#: ../../library/dis.rst:704 msgid "" "end = STACK.pop()\n" "start = STACK.pop()\n" @@ -832,7 +840,7 @@ msgstr "" "container = STACK.pop()\n" "STACK.append(container[start:end])" -#: ../../library/dis.rst:712 +#: ../../library/dis.rst:716 msgid "" "end = STACK.pop()\n" "start = STACK.pop()\n" @@ -846,11 +854,11 @@ msgstr "" "values = STACK.pop()\n" "container[start:end] = value" -#: ../../library/dis.rst:721 +#: ../../library/dis.rst:725 msgid "**Coroutine opcodes**" msgstr "" -#: ../../library/dis.rst:725 +#: ../../library/dis.rst:729 msgid "" "Implements ``STACK[-1] = get_awaitable(STACK[-1])``, where " "``get_awaitable(o)`` returns ``o`` if ``o`` is a coroutine object or a " @@ -858,39 +866,39 @@ msgid "" "resolves ``o.__await__``." msgstr "" -#: ../../library/dis.rst:730 +#: ../../library/dis.rst:734 msgid "" "If the ``where`` operand is nonzero, it indicates where the instruction " "occurs:" msgstr "" -#: ../../library/dis.rst:733 +#: ../../library/dis.rst:737 msgid "``1``: After a call to ``__aenter__``" msgstr "" -#: ../../library/dis.rst:734 +#: ../../library/dis.rst:738 msgid "``2``: After a call to ``__aexit__``" msgstr "" -#: ../../library/dis.rst:738 +#: ../../library/dis.rst:742 msgid "Previously, this instruction did not have an oparg." msgstr "" -#: ../../library/dis.rst:744 +#: ../../library/dis.rst:748 msgid "Implements ``STACK[-1] = STACK[-1].__aiter__()``." msgstr "" -#: ../../library/dis.rst:747 +#: ../../library/dis.rst:751 msgid "Returning awaitable objects from ``__aiter__`` is no longer supported." msgstr "" -#: ../../library/dis.rst:754 +#: ../../library/dis.rst:758 msgid "" "Implement ``STACK.append(get_awaitable(STACK[-1].__anext__()))`` to the " "stack. See ``GET_AWAITABLE`` for details about ``get_awaitable``." msgstr "" -#: ../../library/dis.rst:762 +#: ../../library/dis.rst:766 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]`` " @@ -898,13 +906,13 @@ msgid "" "is not :exc:`StopAsyncIteration`, it is re-raised." msgstr "" -#: ../../library/dis.rst:769 ../../library/dis.rst:877 -#: ../../library/dis.rst:888 +#: ../../library/dis.rst:773 ../../library/dis.rst:881 +#: ../../library/dis.rst:892 msgid "" "Exception representation on the stack now consist of one, not three, items." msgstr "" -#: ../../library/dis.rst:775 +#: ../../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 " @@ -912,21 +920,21 @@ msgid "" "its ``value`` member. Otherwise, re-raise ``STACK[-1]``." msgstr "" -#: ../../library/dis.rst:785 +#: ../../library/dis.rst:789 msgid "" "Resolves ``__aenter__`` and ``__aexit__`` from ``STACK[-1]``. Pushes " "``__aexit__`` and result of ``__aenter__()`` to the stack::" msgstr "" -#: ../../library/dis.rst:788 +#: ../../library/dis.rst:792 msgid "STACK.extend((__aexit__, __aenter__())" msgstr "STACK.extend((__aexit__, __aenter__())" -#: ../../library/dis.rst:794 +#: ../../library/dis.rst:798 msgid "**Miscellaneous opcodes**" msgstr "" -#: ../../library/dis.rst:800 +#: ../../library/dis.rst:804 msgid "" "item = STACK.pop()\n" "set.add(STACK[-i], item)" @@ -934,11 +942,11 @@ msgstr "" "item = STACK.pop()\n" "set.add(STACK[-i], item)" -#: ../../library/dis.rst:803 +#: ../../library/dis.rst:807 msgid "Used to implement set comprehensions." msgstr "" -#: ../../library/dis.rst:810 +#: ../../library/dis.rst:814 msgid "" "item = STACK.pop()\n" "list.append(STACK[-i], item)" @@ -946,11 +954,11 @@ msgstr "" "item = STACK.pop()\n" "list.append(STACK[-i], item)" -#: ../../library/dis.rst:813 +#: ../../library/dis.rst:817 msgid "Used to implement list comprehensions." msgstr "" -#: ../../library/dis.rst:820 +#: ../../library/dis.rst:824 msgid "" "value = STACK.pop()\n" "key = STACK.pop()\n" @@ -960,17 +968,17 @@ msgstr "" "key = STACK.pop()\n" "dict.__setitem__(STACK[-i], key, value)" -#: ../../library/dis.rst:824 +#: ../../library/dis.rst:828 msgid "Used to implement dict comprehensions." msgstr "" -#: ../../library/dis.rst:827 +#: ../../library/dis.rst:831 msgid "" "Map value is ``STACK[-1]`` and map key is ``STACK[-2]``. Before, those were " "reversed." msgstr "" -#: ../../library/dis.rst:831 +#: ../../library/dis.rst:835 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 " @@ -978,35 +986,35 @@ msgid "" "further iterations of the loop." msgstr "" -#: ../../library/dis.rst:839 +#: ../../library/dis.rst:843 msgid "Returns with ``STACK[-1]`` to the caller of the function." msgstr "" -#: ../../library/dis.rst:844 +#: ../../library/dis.rst:848 msgid "Returns with ``co_consts[consti]`` to the caller of the function." msgstr "" -#: ../../library/dis.rst:851 +#: ../../library/dis.rst:855 msgid "Yields ``STACK.pop()`` from a :term:`generator`." msgstr "" -#: ../../library/dis.rst:853 +#: ../../library/dis.rst:857 msgid "oparg set to be the stack depth." msgstr "" -#: ../../library/dis.rst:856 +#: ../../library/dis.rst:860 msgid "" "oparg set to be the exception block depth, for efficient closing of " "generators." msgstr "" -#: ../../library/dis.rst:859 +#: ../../library/dis.rst:863 msgid "" "oparg is ``1`` if this instruction is part of a yield-from or await, and " "``0`` otherwise." msgstr "" -#: ../../library/dis.rst:865 +#: ../../library/dis.rst:869 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 " @@ -1014,39 +1022,39 @@ msgid "" "statically." msgstr "" -#: ../../library/dis.rst:875 +#: ../../library/dis.rst:879 msgid "" "Pops a value from the stack, which is used to restore the exception state." msgstr "" -#: ../../library/dis.rst:882 +#: ../../library/dis.rst:886 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." msgstr "" -#: ../../library/dis.rst:893 +#: ../../library/dis.rst:897 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:901 +#: ../../library/dis.rst:905 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:909 +#: ../../library/dis.rst:913 msgid "" "Performs exception matching for ``except*``. Applies ``split(STACK[-1])`` on " "the exception group representing ``STACK[-2]``." msgstr "" -#: ../../library/dis.rst:912 +#: ../../library/dis.rst:916 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 " @@ -1054,7 +1062,7 @@ msgid "" "``None``." msgstr "" -#: ../../library/dis.rst:921 +#: ../../library/dis.rst:925 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 " @@ -1062,25 +1070,25 @@ msgid "" "occurred in a :keyword:`with` statement." msgstr "" -#: ../../library/dis.rst:928 +#: ../../library/dis.rst:932 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:935 +#: ../../library/dis.rst:939 msgid "" "Pushes :exc:`AssertionError` onto the stack. Used by the :keyword:`assert` " "statement." msgstr "" -#: ../../library/dis.rst:943 +#: ../../library/dis.rst:947 msgid "" "Pushes :func:`!builtins.__build_class__` onto the stack. It is later called " "to construct a class." msgstr "" -#: ../../library/dis.rst:949 +#: ../../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 " @@ -1089,11 +1097,13 @@ msgid "" "``__enter__()`` method is pushed onto the stack." msgstr "" -#: ../../library/dis.rst:960 -msgid "Perform ``STACK.append(len(STACK[-1]))``." +#: ../../library/dis.rst:964 +msgid "" +"Perform ``STACK.append(len(STACK[-1]))``. Used in :keyword:`match` " +"statements where comparison with structure of pattern is needed." msgstr "" -#: ../../library/dis.rst:967 +#: ../../library/dis.rst:972 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 " @@ -1101,7 +1111,7 @@ msgid "" "Otherwise, push ``False``." msgstr "" -#: ../../library/dis.rst:977 +#: ../../library/dis.rst:982 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, " @@ -1110,20 +1120,20 @@ msgid "" "Otherwise, push ``False``." msgstr "" -#: ../../library/dis.rst:987 +#: ../../library/dis.rst:992 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``." msgstr "" -#: ../../library/dis.rst:993 ../../library/dis.rst:1664 +#: ../../library/dis.rst:998 ../../library/dis.rst:1684 msgid "" "Previously, this instruction also pushed a boolean value indicating success " "(``True``) or failure (``False``)." msgstr "" -#: ../../library/dis.rst:1000 +#: ../../library/dis.rst:1005 msgid "" "Implements ``name = STACK.pop()``. *namei* is the index of *name* in the " "attribute :attr:`~codeobject.co_names` of the :ref:`code object `." msgstr "" -#: ../../library/dis.rst:1013 +#: ../../library/dis.rst:1018 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:1016 +#: ../../library/dis.rst:1021 msgid "" "assert(len(STACK[-1]) == count)\n" "STACK.extend(STACK.pop()[:-count-1:-1])" @@ -1151,7 +1161,7 @@ msgstr "" "assert(len(STACK[-1]) == count)\n" "STACK.extend(STACK.pop()[:-count-1:-1])" -#: ../../library/dis.rst:1022 +#: ../../library/dis.rst:1027 msgid "" "Implements assignment with a starred target: Unpacks an iterable in " "``STACK[-1]`` into individual values, where the total number of values can " @@ -1159,11 +1169,11 @@ msgid "" "will be a list of all leftover items." msgstr "" -#: ../../library/dis.rst:1027 +#: ../../library/dis.rst:1032 msgid "The number of values before and after the list value is limited to 255." msgstr "" -#: ../../library/dis.rst:1029 +#: ../../library/dis.rst:1034 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 " @@ -1172,13 +1182,13 @@ msgid "" "list value, the high byte of *counts* the number of values after it." msgstr "" -#: ../../library/dis.rst:1035 +#: ../../library/dis.rst:1040 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:1043 +#: ../../library/dis.rst:1048 msgid "" "obj = STACK.pop()\n" "value = STACK.pop()\n" @@ -1188,13 +1198,13 @@ msgstr "" "value = STACK.pop()\n" "obj.name = value" -#: ../../library/dis.rst:1047 +#: ../../library/dis.rst:1052 msgid "" "where *namei* is the index of name in :attr:`~codeobject.co_names` of the :" "ref:`code object `." msgstr "" -#: ../../library/dis.rst:1054 +#: ../../library/dis.rst:1059 msgid "" "obj = STACK.pop()\n" "del obj.name" @@ -1202,38 +1212,38 @@ msgstr "" "obj = STACK.pop()\n" "del obj.name" -#: ../../library/dis.rst:1057 +#: ../../library/dis.rst:1062 msgid "" "where *namei* is the index of name into :attr:`~codeobject.co_names` of the :" "ref:`code object `." msgstr "" -#: ../../library/dis.rst:1063 +#: ../../library/dis.rst:1068 msgid "Works as :opcode:`STORE_NAME`, but stores the name as a global." msgstr "" -#: ../../library/dis.rst:1068 +#: ../../library/dis.rst:1073 msgid "Works as :opcode:`DELETE_NAME`, but deletes a global name." msgstr "" -#: ../../library/dis.rst:1073 +#: ../../library/dis.rst:1078 msgid "Pushes ``co_consts[consti]`` onto the stack." msgstr "" -#: ../../library/dis.rst:1078 +#: ../../library/dis.rst:1083 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:1084 +#: ../../library/dis.rst:1089 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`." msgstr "" -#: ../../library/dis.rst:1093 +#: ../../library/dis.rst:1098 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 " @@ -1242,13 +1252,13 @@ msgid "" "bodies." msgstr "" -#: ../../library/dis.rst:1104 +#: ../../library/dis.rst:1109 msgid "" "Creates a tuple consuming *count* items from the stack, and pushes the " "resulting tuple onto the stack::" msgstr "" -#: ../../library/dis.rst:1107 +#: ../../library/dis.rst:1112 msgid "" "if count == 0:\n" " value = ()\n" @@ -1266,41 +1276,41 @@ msgstr "" "\n" "STACK.append(value)" -#: ../../library/dis.rst:1118 +#: ../../library/dis.rst:1123 msgid "Works as :opcode:`BUILD_TUPLE`, but creates a list." msgstr "" -#: ../../library/dis.rst:1123 +#: ../../library/dis.rst:1128 msgid "Works as :opcode:`BUILD_TUPLE`, but creates a set." msgstr "" -#: ../../library/dis.rst:1128 +#: ../../library/dis.rst:1133 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:1132 +#: ../../library/dis.rst:1137 msgid "" "The dictionary is created from stack items instead of creating an empty " "dictionary pre-sized to hold *count* items." msgstr "" -#: ../../library/dis.rst:1139 +#: ../../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:1148 +#: ../../library/dis.rst:1153 msgid "" "Concatenates *count* strings from the stack and pushes the resulting string " "onto the stack." msgstr "" -#: ../../library/dis.rst:1158 +#: ../../library/dis.rst:1163 msgid "" "seq = STACK.pop()\n" "list.extend(STACK[-i], seq)" @@ -1308,11 +1318,11 @@ msgstr "" "seq = STACK.pop()\n" "list.extend(STACK[-i], seq)" -#: ../../library/dis.rst:1161 +#: ../../library/dis.rst:1166 msgid "Used to build lists." msgstr "" -#: ../../library/dis.rst:1170 +#: ../../library/dis.rst:1175 msgid "" "seq = STACK.pop()\n" "set.update(STACK[-i], seq)" @@ -1320,11 +1330,11 @@ msgstr "" "seq = STACK.pop()\n" "set.update(STACK[-i], seq)" -#: ../../library/dis.rst:1173 +#: ../../library/dis.rst:1178 msgid "Used to build sets." msgstr "" -#: ../../library/dis.rst:1182 +#: ../../library/dis.rst:1187 msgid "" "map = STACK.pop()\n" "dict.update(STACK[-i], map)" @@ -1332,21 +1342,21 @@ msgstr "" "map = STACK.pop()\n" "dict.update(STACK[-i], map)" -#: ../../library/dis.rst:1185 +#: ../../library/dis.rst:1190 msgid "Used to build dicts." msgstr "" -#: ../../library/dis.rst:1192 +#: ../../library/dis.rst:1197 msgid "Like :opcode:`DICT_UPDATE` but raises an exception for duplicate keys." msgstr "" -#: ../../library/dis.rst:1199 +#: ../../library/dis.rst:1204 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:1202 +#: ../../library/dis.rst:1207 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 " @@ -1358,76 +1368,76 @@ msgid "" "pushed." msgstr "" -#: ../../library/dis.rst:1211 +#: ../../library/dis.rst:1216 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:1218 +#: ../../library/dis.rst:1223 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:1222 +#: ../../library/dis.rst:1227 msgid "It pops three values from the stack (from top of stack down):" msgstr "" -#: ../../library/dis.rst:1224 +#: ../../library/dis.rst:1229 msgid "``self``: the first argument to the current method" msgstr "" -#: ../../library/dis.rst:1225 +#: ../../library/dis.rst:1230 msgid "``cls``: the class within which the current method was defined" msgstr "" -#: ../../library/dis.rst:1226 +#: ../../library/dis.rst:1231 msgid "the global ``super``" msgstr "" -#: ../../library/dis.rst:1228 +#: ../../library/dis.rst:1233 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:1231 +#: ../../library/dis.rst:1236 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." msgstr "" -#: ../../library/dis.rst:1235 +#: ../../library/dis.rst:1240 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:1243 +#: ../../library/dis.rst:1248 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:1247 +#: ../../library/dis.rst:1252 msgid "" "The fifth-lowest bit of the oparg now indicates a forced conversion to :" "class:`bool`." msgstr "" -#: ../../library/dis.rst:1254 +#: ../../library/dis.rst:1259 msgid "Performs ``is`` comparison, or ``is not`` if ``invert`` is 1." msgstr "" -#: ../../library/dis.rst:1261 +#: ../../library/dis.rst:1266 msgid "Performs ``in`` comparison, or ``not in`` if ``invert`` is 1." msgstr "" -#: ../../library/dis.rst:1268 +#: ../../library/dis.rst:1273 msgid "" "Imports the module ``co_names[namei]``. ``STACK[-1]`` and ``STACK[-2]`` are " "popped and provide the *fromlist* and *level* arguments of :func:" @@ -1436,68 +1446,62 @@ msgid "" "opcode:`STORE_FAST` instruction modifies the namespace." msgstr "" -#: ../../library/dis.rst:1276 +#: ../../library/dis.rst:1281 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:1283 +#: ../../library/dis.rst:1288 msgid "Increments bytecode counter by *delta*." msgstr "" -#: ../../library/dis.rst:1288 +#: ../../library/dis.rst:1293 msgid "Decrements bytecode counter by *delta*. Checks for interrupts." msgstr "" -#: ../../library/dis.rst:1295 +#: ../../library/dis.rst:1300 msgid "Decrements bytecode counter by *delta*. Does not check for interrupts." msgstr "" -#: ../../library/dis.rst:1302 +#: ../../library/dis.rst:1307 msgid "" "If ``STACK[-1]`` is true, increments the bytecode counter by *delta*. " "``STACK[-1]`` is popped." msgstr "" -#: ../../library/dis.rst:1305 ../../library/dis.rst:1321 +#: ../../library/dis.rst:1310 ../../library/dis.rst:1326 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:1310 ../../library/dis.rst:1326 -#: ../../library/dis.rst:1342 ../../library/dis.rst:1356 +#: ../../library/dis.rst:1315 ../../library/dis.rst:1331 +#: ../../library/dis.rst:1344 ../../library/dis.rst:1355 msgid "This is no longer a pseudo-instruction." msgstr "" -#: ../../library/dis.rst:1318 +#: ../../library/dis.rst:1323 msgid "" "If ``STACK[-1]`` is false, increments the bytecode counter by *delta*. " "``STACK[-1]`` is popped." msgstr "" -#: ../../library/dis.rst:1334 +#: ../../library/dis.rst:1339 msgid "" "If ``STACK[-1]`` is not ``None``, increments the bytecode counter by " "*delta*. ``STACK[-1]`` is popped." msgstr "" -#: ../../library/dis.rst:1337 ../../library/dis.rst:1351 -msgid "" -"This opcode is a pseudo-instruction, replaced in final bytecode by the " -"directed versions (forward/backward)." -msgstr "" - -#: ../../library/dis.rst:1348 +#: ../../library/dis.rst:1350 msgid "" "If ``STACK[-1]`` is ``None``, increments the bytecode counter by *delta*. " "``STACK[-1]`` is popped." msgstr "" -#: ../../library/dis.rst:1361 +#: ../../library/dis.rst:1360 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 " @@ -1505,186 +1509,207 @@ msgid "" "code counter is incremented by *delta*." msgstr "" -#: ../../library/dis.rst:1366 +#: ../../library/dis.rst:1365 msgid "Up until 3.11 the iterator was popped when it was exhausted." msgstr "" -#: ../../library/dis.rst:1371 +#: ../../library/dis.rst:1370 msgid "Loads the global named ``co_names[namei>>1]`` onto the stack." msgstr "" -#: ../../library/dis.rst:1373 +#: ../../library/dis.rst:1372 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:1379 +#: ../../library/dis.rst:1378 msgid "" "Pushes a reference to the local ``co_varnames[var_num]`` onto the stack." msgstr "" -#: ../../library/dis.rst:1381 +#: ../../library/dis.rst:1380 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:1387 +#: ../../library/dis.rst:1386 +msgid "" +"Pushes references to ``co_varnames[var_nums >> 4]`` and " +"``co_varnames[var_nums & 15]`` onto the stack." +msgstr "" + +#: ../../library/dis.rst:1393 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:1395 +#: ../../library/dis.rst:1401 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:1403 +#: ../../library/dis.rst:1409 msgid "Stores ``STACK.pop()`` into the local ``co_varnames[var_num]``." msgstr "" -#: ../../library/dis.rst:1408 +#: ../../library/dis.rst:1413 +msgid "" +"Stores ``STACK[-1]`` into ``co_varnames[var_nums >> 4]`` and ``STACK[-2]`` " +"into ``co_varnames[var_nums & 15]``." +msgstr "" + +#: ../../library/dis.rst:1420 +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 msgid "Deletes local ``co_varnames[var_num]``." msgstr "" -#: ../../library/dis.rst:1413 +#: ../../library/dis.rst:1433 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:1421 +#: ../../library/dis.rst:1441 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:1424 ../../library/dis.rst:1446 -#: ../../library/dis.rst:1457 +#: ../../library/dis.rst:1444 ../../library/dis.rst:1466 +#: ../../library/dis.rst:1477 msgid "" "``i`` is no longer offset by the length of :attr:`~codeobject.co_varnames`." msgstr "" -#: ../../library/dis.rst:1430 +#: ../../library/dis.rst:1450 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 free variables in class bodies " -"(which previously used :opcode:`!LOAD_CLASSDEREF`) and in :ref:`annotation " -"scopes ` within class bodies." +"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:1443 +#: ../../library/dis.rst:1463 msgid "" "Stores ``STACK.pop()`` into the cell contained in slot ``i`` of the \"fast " "locals\" storage." msgstr "" -#: ../../library/dis.rst:1452 +#: ../../library/dis.rst:1472 msgid "" "Empties the cell contained in slot ``i`` of the \"fast locals\" storage. " "Used by the :keyword:`del` statement." msgstr "" -#: ../../library/dis.rst:1463 +#: ../../library/dis.rst:1483 msgid "" -"Copies the ``n`` free variables from the closure into the frame. Removes the " -"need for special code on the caller's side when calling closures." +"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:1472 +#: ../../library/dis.rst:1492 msgid "" "Raises an exception using one of the 3 forms of the ``raise`` statement, " "depending on the value of *argc*:" msgstr "" -#: ../../library/dis.rst:1475 +#: ../../library/dis.rst:1495 msgid "0: ``raise`` (re-raise previous exception)" msgstr "" -#: ../../library/dis.rst:1476 +#: ../../library/dis.rst:1496 msgid "" "1: ``raise STACK[-1]`` (raise exception instance or type at ``STACK[-1]``)" msgstr "" -#: ../../library/dis.rst:1477 +#: ../../library/dis.rst:1497 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:1483 +#: ../../library/dis.rst:1503 msgid "" "Calls a callable object with the number of arguments specified by ``argc``. " "On the stack are (in ascending order):" msgstr "" -#: ../../library/dis.rst:1486 ../../library/dis.rst:1510 +#: ../../library/dis.rst:1506 ../../library/dis.rst:1530 msgid "The callable" msgstr "" -#: ../../library/dis.rst:1487 ../../library/dis.rst:1511 +#: ../../library/dis.rst:1507 ../../library/dis.rst:1531 msgid "``self`` or ``NULL``" msgstr "" -#: ../../library/dis.rst:1488 ../../library/dis.rst:1512 +#: ../../library/dis.rst:1508 ../../library/dis.rst:1532 msgid "The remaining positional arguments" msgstr "" -#: ../../library/dis.rst:1490 +#: ../../library/dis.rst:1510 msgid "``argc`` is the total of the positional arguments, excluding ``self``." msgstr "" -#: ../../library/dis.rst:1492 +#: ../../library/dis.rst:1512 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:1498 +#: ../../library/dis.rst:1518 msgid "The callable now always appears at the same position on the stack." msgstr "" -#: ../../library/dis.rst:1501 +#: ../../library/dis.rst:1521 msgid "Calls with keyword arguments are now handled by :opcode:`CALL_KW`." msgstr "" -#: ../../library/dis.rst:1507 +#: ../../library/dis.rst:1527 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:1513 +#: ../../library/dis.rst:1533 msgid "The named arguments" msgstr "" -#: ../../library/dis.rst:1514 +#: ../../library/dis.rst:1534 msgid "A :class:`tuple` of keyword argument names" msgstr "" -#: ../../library/dis.rst:1516 +#: ../../library/dis.rst:1536 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:1519 +#: ../../library/dis.rst:1539 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:1528 +#: ../../library/dis.rst:1548 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 " @@ -1696,33 +1721,33 @@ msgid "" "arguments, and pushes the return value returned by the callable object." msgstr "" -#: ../../library/dis.rst:1543 +#: ../../library/dis.rst:1563 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." msgstr "" -#: ../../library/dis.rst:1552 +#: ../../library/dis.rst:1572 msgid "" "Pushes a new function object on the stack built from the code object at " -"``STACK[1]``." +"``STACK[-1]``." msgstr "" -#: ../../library/dis.rst:1554 +#: ../../library/dis.rst:1574 msgid "Flag value ``0x04`` is a tuple of strings instead of dictionary" msgstr "" -#: ../../library/dis.rst:1557 +#: ../../library/dis.rst:1577 msgid "Qualified name at ``STACK[-1]`` was removed." msgstr "" -#: ../../library/dis.rst:1560 +#: ../../library/dis.rst:1580 msgid "" "Extra function attributes on the stack, signaled by oparg flags, were " "removed. They now use :opcode:`SET_FUNCTION_ATTRIBUTE`." msgstr "" -#: ../../library/dis.rst:1567 +#: ../../library/dis.rst:1587 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 " @@ -1730,42 +1755,42 @@ msgid "" "attribute to set:" msgstr "" -#: ../../library/dis.rst:1571 +#: ../../library/dis.rst:1591 msgid "" "``0x01`` a tuple of default values for positional-only and positional-or-" "keyword parameters in positional order" msgstr "" -#: ../../library/dis.rst:1573 +#: ../../library/dis.rst:1593 msgid "``0x02`` a dictionary of keyword-only parameters' default values" msgstr "" -#: ../../library/dis.rst:1574 +#: ../../library/dis.rst:1594 msgid "``0x04`` a tuple of strings containing parameters' annotations" msgstr "" -#: ../../library/dis.rst:1575 +#: ../../library/dis.rst:1595 msgid "``0x08`` a tuple containing cells for free variables, making a closure" msgstr "" -#: ../../library/dis.rst:1584 +#: ../../library/dis.rst:1604 msgid "" "Pushes a slice object on the stack. *argc* must be 2 or 3. If it is 2, " "implements::" msgstr "" -#: ../../library/dis.rst:1586 +#: ../../library/dis.rst:1606 msgid "" "end = STACK.pop()\n" "start = STACK.pop()\n" "STACK.append(slice(start, end))" msgstr "" -#: ../../library/dis.rst:1590 +#: ../../library/dis.rst:1610 msgid "if it is 3, implements::" msgstr "" -#: ../../library/dis.rst:1592 +#: ../../library/dis.rst:1612 msgid "" "step = STACK.pop()\n" "end = STACK.pop()\n" @@ -1777,11 +1802,11 @@ msgstr "" "start = STACK.pop()\n" "STACK.append(slice(start, end, step))" -#: ../../library/dis.rst:1597 +#: ../../library/dis.rst:1617 msgid "See the :func:`slice` built-in function for more information." msgstr "" -#: ../../library/dis.rst:1602 +#: ../../library/dis.rst:1622 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 " @@ -1789,11 +1814,11 @@ msgid "" "allowed, forming an argument from two-byte to four-byte." msgstr "" -#: ../../library/dis.rst:1610 +#: ../../library/dis.rst:1630 msgid "Convert value to a string, depending on ``oparg``::" msgstr "" -#: ../../library/dis.rst:1612 +#: ../../library/dis.rst:1632 msgid "" "value = STACK.pop()\n" "result = func(value)\n" @@ -1803,28 +1828,28 @@ msgstr "" "result = func(value)\n" "STACK.append(result)" -#: ../../library/dis.rst:1616 +#: ../../library/dis.rst:1636 msgid "``oparg == 1``: call :func:`str` on *value*" msgstr "" -#: ../../library/dis.rst:1617 +#: ../../library/dis.rst:1637 msgid "``oparg == 2``: call :func:`repr` on *value*" msgstr "" -#: ../../library/dis.rst:1618 +#: ../../library/dis.rst:1638 msgid "``oparg == 3``: call :func:`ascii` on *value*" msgstr "" -#: ../../library/dis.rst:1620 ../../library/dis.rst:1633 -#: ../../library/dis.rst:1646 -msgid "Used for implementing formatted literal strings (f-strings)." +#: ../../library/dis.rst:1640 ../../library/dis.rst:1653 +#: ../../library/dis.rst:1666 +msgid "Used for implementing formatted string literals (f-strings)." msgstr "" -#: ../../library/dis.rst:1627 +#: ../../library/dis.rst:1647 msgid "Formats the value on top of stack::" msgstr "" -#: ../../library/dis.rst:1629 +#: ../../library/dis.rst:1649 msgid "" "value = STACK.pop()\n" "result = value.__format__(\"\")\n" @@ -1834,11 +1859,11 @@ msgstr "" "result = value.__format__(\"\")\n" "STACK.append(result)" -#: ../../library/dis.rst:1639 +#: ../../library/dis.rst:1659 msgid "Formats the given value with the given format spec::" msgstr "" -#: ../../library/dis.rst:1641 +#: ../../library/dis.rst:1661 msgid "" "spec = STACK.pop()\n" "value = STACK.pop()\n" @@ -1850,14 +1875,14 @@ msgstr "" "result = value.__format__(spec)\n" "STACK.append(result)" -#: ../../library/dis.rst:1653 +#: ../../library/dis.rst:1673 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:1657 +#: ../../library/dis.rst:1677 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 " @@ -1865,219 +1890,219 @@ msgid "" "Otherwise, push ``None``." msgstr "" -#: ../../library/dis.rst:1671 +#: ../../library/dis.rst:1691 msgid "A no-op. Performs internal tracing, debugging and optimization checks." msgstr "" -#: ../../library/dis.rst:1673 +#: ../../library/dis.rst:1693 msgid "" "The ``context`` oparand consists of two parts. The lowest two bits indicate " "where the ``RESUME`` occurs:" msgstr "" -#: ../../library/dis.rst:1676 +#: ../../library/dis.rst:1696 msgid "" "``0`` The start of a function, which is neither a generator, coroutine nor " "an async generator" msgstr "" -#: ../../library/dis.rst:1678 +#: ../../library/dis.rst:1698 msgid "``1`` After a ``yield`` expression" msgstr "" -#: ../../library/dis.rst:1679 +#: ../../library/dis.rst:1699 msgid "``2`` After a ``yield from`` expression" msgstr "" -#: ../../library/dis.rst:1680 +#: ../../library/dis.rst:1700 msgid "``3`` After an ``await`` expression" msgstr "" -#: ../../library/dis.rst:1682 +#: ../../library/dis.rst:1702 msgid "" "The next bit is ``1`` if the RESUME is at except-depth ``1``, and ``0`` " "otherwise." msgstr "" -#: ../../library/dis.rst:1687 +#: ../../library/dis.rst:1707 msgid "The oparg value changed to include information about except-depth" msgstr "" -#: ../../library/dis.rst:1693 +#: ../../library/dis.rst:1713 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:1702 +#: ../../library/dis.rst:1722 msgid "" "Equivalent to ``STACK[-1] = STACK[-2].send(STACK[-1])``. Used in ``yield " "from`` and ``await`` statements." msgstr "" -#: ../../library/dis.rst:1705 +#: ../../library/dis.rst:1725 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:1714 +#: ../../library/dis.rst:1734 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:1718 +#: ../../library/dis.rst:1738 msgid "" "If your application uses pseudo instructions or specialized instructions, " "use the :data:`hasarg` collection instead." msgstr "" -#: ../../library/dis.rst:1721 +#: ../../library/dis.rst:1741 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:1725 +#: ../../library/dis.rst:1745 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:1730 +#: ../../library/dis.rst:1750 msgid "Use :data:`hasarg` instead." msgstr "" -#: ../../library/dis.rst:1735 +#: ../../library/dis.rst:1755 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:1739 ../../library/dis.rst:1793 +#: ../../library/dis.rst:1759 ../../library/dis.rst:1813 msgid "The operand determines which intrinsic function is called:" msgstr "" -#: ../../library/dis.rst:1742 ../../library/dis.rst:1796 +#: ../../library/dis.rst:1762 ../../library/dis.rst:1816 msgid "Operand" msgstr "" -#: ../../library/dis.rst:1742 ../../library/dis.rst:1796 +#: ../../library/dis.rst:1762 ../../library/dis.rst:1816 msgid "Description" msgstr "" -#: ../../library/dis.rst:1744 +#: ../../library/dis.rst:1764 msgid "``INTRINSIC_1_INVALID``" msgstr "``INTRINSIC_1_INVALID``" -#: ../../library/dis.rst:1744 ../../library/dis.rst:1798 +#: ../../library/dis.rst:1764 ../../library/dis.rst:1818 msgid "Not valid" msgstr "" -#: ../../library/dis.rst:1746 +#: ../../library/dis.rst:1766 msgid "``INTRINSIC_PRINT``" msgstr "``INTRINSIC_PRINT``" -#: ../../library/dis.rst:1746 +#: ../../library/dis.rst:1766 msgid "Prints the argument to standard out. Used in the REPL." msgstr "" -#: ../../library/dis.rst:1749 +#: ../../library/dis.rst:1769 msgid "``INTRINSIC_IMPORT_STAR``" msgstr "``INTRINSIC_IMPORT_STAR``" -#: ../../library/dis.rst:1749 +#: ../../library/dis.rst:1769 msgid "Performs ``import *`` for the named module." msgstr "" -#: ../../library/dis.rst:1752 +#: ../../library/dis.rst:1772 msgid "``INTRINSIC_STOPITERATION_ERROR``" msgstr "``INTRINSIC_STOPITERATION_ERROR``" -#: ../../library/dis.rst:1752 +#: ../../library/dis.rst:1772 msgid "Extracts the return value from a ``StopIteration`` exception." msgstr "" -#: ../../library/dis.rst:1755 +#: ../../library/dis.rst:1775 msgid "``INTRINSIC_ASYNC_GEN_WRAP``" msgstr "``INTRINSIC_ASYNC_GEN_WRAP``" -#: ../../library/dis.rst:1755 +#: ../../library/dis.rst:1775 msgid "Wraps an async generator value" msgstr "" -#: ../../library/dis.rst:1757 +#: ../../library/dis.rst:1777 msgid "``INTRINSIC_UNARY_POSITIVE``" msgstr "``INTRINSIC_UNARY_POSITIVE``" -#: ../../library/dis.rst:1757 +#: ../../library/dis.rst:1777 msgid "Performs the unary ``+`` operation" msgstr "" -#: ../../library/dis.rst:1760 +#: ../../library/dis.rst:1780 msgid "``INTRINSIC_LIST_TO_TUPLE``" msgstr "``INTRINSIC_LIST_TO_TUPLE``" -#: ../../library/dis.rst:1760 +#: ../../library/dis.rst:1780 msgid "Converts a list to a tuple" msgstr "" -#: ../../library/dis.rst:1762 +#: ../../library/dis.rst:1782 msgid "``INTRINSIC_TYPEVAR``" msgstr "``INTRINSIC_TYPEVAR``" -#: ../../library/dis.rst:1762 +#: ../../library/dis.rst:1782 msgid "Creates a :class:`typing.TypeVar`" msgstr "" -#: ../../library/dis.rst:1764 +#: ../../library/dis.rst:1784 msgid "``INTRINSIC_PARAMSPEC``" msgstr "``INTRINSIC_PARAMSPEC``" -#: ../../library/dis.rst:1764 +#: ../../library/dis.rst:1784 msgid "Creates a :class:`typing.ParamSpec`" msgstr "" -#: ../../library/dis.rst:1767 +#: ../../library/dis.rst:1787 msgid "``INTRINSIC_TYPEVARTUPLE``" msgstr "``INTRINSIC_TYPEVARTUPLE``" -#: ../../library/dis.rst:1767 +#: ../../library/dis.rst:1787 msgid "Creates a :class:`typing.TypeVarTuple`" msgstr "" -#: ../../library/dis.rst:1770 +#: ../../library/dis.rst:1790 msgid "``INTRINSIC_SUBSCRIPT_GENERIC``" msgstr "``INTRINSIC_SUBSCRIPT_GENERIC``" -#: ../../library/dis.rst:1770 +#: ../../library/dis.rst:1790 msgid "Returns :class:`typing.Generic` subscripted with the argument" msgstr "" -#: ../../library/dis.rst:1773 +#: ../../library/dis.rst:1793 msgid "``INTRINSIC_TYPEALIAS``" msgstr "``INTRINSIC_TYPEALIAS``" -#: ../../library/dis.rst:1773 +#: ../../library/dis.rst:1793 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:1785 +#: ../../library/dis.rst:1805 msgid "" "Calls an intrinsic function with two arguments. Used to implement " "functionality that is not performance critical::" msgstr "" -#: ../../library/dis.rst:1788 +#: ../../library/dis.rst:1808 msgid "" "arg2 = STACK.pop()\n" "arg1 = STACK.pop()\n" @@ -2089,61 +2114,61 @@ msgstr "" "result = intrinsic2(arg1, arg2)\n" "STACK.append(result)" -#: ../../library/dis.rst:1798 +#: ../../library/dis.rst:1818 msgid "``INTRINSIC_2_INVALID``" msgstr "``INTRINSIC_2_INVALID``" -#: ../../library/dis.rst:1800 +#: ../../library/dis.rst:1820 msgid "``INTRINSIC_PREP_RERAISE_STAR``" msgstr "``INTRINSIC_PREP_RERAISE_STAR``" -#: ../../library/dis.rst:1800 +#: ../../library/dis.rst:1820 msgid "Calculates the :exc:`ExceptionGroup` to raise from a ``try-except*``." msgstr "" -#: ../../library/dis.rst:1804 +#: ../../library/dis.rst:1824 msgid "``INTRINSIC_TYPEVAR_WITH_BOUND``" msgstr "``INTRINSIC_TYPEVAR_WITH_BOUND``" -#: ../../library/dis.rst:1804 +#: ../../library/dis.rst:1824 msgid "Creates a :class:`typing.TypeVar` with a bound." msgstr "" -#: ../../library/dis.rst:1807 +#: ../../library/dis.rst:1827 msgid "``INTRINSIC_TYPEVAR_WITH_CONSTRAINTS``" msgstr "``INTRINSIC_TYPEVAR_WITH_CONSTRAINTS``" -#: ../../library/dis.rst:1807 +#: ../../library/dis.rst:1827 msgid "Creates a :class:`typing.TypeVar` with constraints." msgstr "" -#: ../../library/dis.rst:1811 +#: ../../library/dis.rst:1831 msgid "``INTRINSIC_SET_FUNCTION_TYPE_PARAMS``" msgstr "``INTRINSIC_SET_FUNCTION_TYPE_PARAMS``" -#: ../../library/dis.rst:1811 +#: ../../library/dis.rst:1831 msgid "Sets the ``__type_params__`` attribute of a function." msgstr "" -#: ../../library/dis.rst:1818 +#: ../../library/dis.rst:1838 msgid "**Pseudo-instructions**" msgstr "" -#: ../../library/dis.rst:1820 +#: ../../library/dis.rst:1840 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:1825 +#: ../../library/dis.rst:1845 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:1832 +#: ../../library/dis.rst:1852 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 " @@ -2152,139 +2177,140 @@ msgid "" "exception handler at ``target``." msgstr "" -#: ../../library/dis.rst:1841 +#: ../../library/dis.rst:1861 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:1845 +#: ../../library/dis.rst:1865 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." msgstr "" -#: ../../library/dis.rst:1852 +#: ../../library/dis.rst:1872 msgid "" "Marks the end of the code block associated with the last ``SETUP_FINALLY``, " "``SETUP_CLEANUP`` or ``SETUP_WITH``." msgstr "" -#: ../../library/dis.rst:1858 +#: ../../library/dis.rst:1878 msgid "" "Undirected relative jump instructions which are replaced by their directed " "(forward/backward) counterparts by the assembler." msgstr "" -#: ../../library/dis.rst:1863 +#: ../../library/dis.rst:1883 msgid "" "Pushes a reference to the cell contained in slot ``i`` of the \"fast " "locals\" storage." msgstr "" -#: ../../library/dis.rst:1866 +#: ../../library/dis.rst:1886 msgid "" "Note that ``LOAD_CLOSURE`` is replaced with ``LOAD_FAST`` in the assembler." msgstr "" -#: ../../library/dis.rst:1868 +#: ../../library/dis.rst:1888 msgid "This opcode is now a pseudo-instruction." msgstr "" -#: ../../library/dis.rst:1874 +#: ../../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:1881 +#: ../../library/dis.rst:1901 msgid "Opcode collections" msgstr "" -#: ../../library/dis.rst:1883 +#: ../../library/dis.rst:1903 msgid "" "These collections are provided for automatic introspection of bytecode " "instructions:" msgstr "" -#: ../../library/dis.rst:1886 +#: ../../library/dis.rst:1906 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:1893 +#: ../../library/dis.rst:1913 msgid "Sequence of operation names, indexable using the bytecode." msgstr "" -#: ../../library/dis.rst:1898 +#: ../../library/dis.rst:1918 msgid "Dictionary mapping operation names to bytecodes." msgstr "" -#: ../../library/dis.rst:1903 +#: ../../library/dis.rst:1923 msgid "Sequence of all compare operation names." msgstr "" -#: ../../library/dis.rst:1908 +#: ../../library/dis.rst:1928 msgid "Sequence of bytecodes that use their argument." msgstr "" -#: ../../library/dis.rst:1915 +#: ../../library/dis.rst:1935 msgid "Sequence of bytecodes that access a constant." msgstr "" -#: ../../library/dis.rst:1920 +#: ../../library/dis.rst:1940 msgid "" -"Sequence of bytecodes that access a free variable. 'free' in this context " -"refers to names in the current scope that are referenced by inner scopes or " -"names in outer scopes that are referenced from this scope. It does *not* " -"include references to global or builtin scopes." +"Sequence of bytecodes that access a :term:`free (closure) variable `. 'free' in this context refers to names in the current scope that " +"are referenced by inner scopes or names in outer scopes that are referenced " +"from this scope. It does *not* include references to global or builtin " +"scopes." msgstr "" -#: ../../library/dis.rst:1928 +#: ../../library/dis.rst:1948 msgid "Sequence of bytecodes that access an attribute by name." msgstr "" -#: ../../library/dis.rst:1933 +#: ../../library/dis.rst:1953 msgid "Sequence of bytecodes that have a jump target. All jumps are relative." msgstr "" -#: ../../library/dis.rst:1940 +#: ../../library/dis.rst:1960 msgid "Sequence of bytecodes that access a local variable." msgstr "" -#: ../../library/dis.rst:1945 +#: ../../library/dis.rst:1965 msgid "Sequence of bytecodes of Boolean operations." msgstr "" -#: ../../library/dis.rst:1949 +#: ../../library/dis.rst:1969 msgid "Sequence of bytecodes that set an exception handler." msgstr "" -#: ../../library/dis.rst:1956 +#: ../../library/dis.rst:1976 msgid "Sequence of bytecodes that have a relative jump target." msgstr "" -#: ../../library/dis.rst:1958 +#: ../../library/dis.rst:1978 msgid "All jumps are now relative. Use :data:`hasjump`." msgstr "" -#: ../../library/dis.rst:1964 +#: ../../library/dis.rst:1984 msgid "Sequence of bytecodes that have an absolute jump target." msgstr "" -#: ../../library/dis.rst:1966 +#: ../../library/dis.rst:1986 msgid "All jumps are now relative. This list is empty." msgstr "" -#: ../../library/dis.rst:1582 +#: ../../library/dis.rst:1602 msgid "built-in function" msgstr "built-in function(內建函式)" -#: ../../library/dis.rst:1582 +#: ../../library/dis.rst:1602 msgid "slice" msgstr "slice(切片)" diff --git a/library/distutils.po b/library/distutils.po new file mode 100644 index 0000000000..e4bdeb715f --- /dev/null +++ b/library/distutils.po @@ -0,0 +1,36 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2001-2024, Python Software Foundation +# This file is distributed under the same license as the Python package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Python 3.13\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-11-20 09:21+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/distutils.rst:2 +msgid ":mod:`!distutils` --- Building and installing Python modules" +msgstr "" + +#: ../../library/distutils.rst:10 +msgid "" +"This module is no longer part of the Python standard library. It was :ref:" +"`removed in Python 3.12 ` after being " +"deprecated in Python 3.10. The removal was decided in :pep:`632`, which has " +"`migration advice `_." +msgstr "" + +#: ../../library/distutils.rst:16 +msgid "" +"The last version of Python that provided the :mod:`!distutils` module was " +"`Python 3.11 `_." +msgstr "" diff --git a/library/doctest.po b/library/doctest.po index fda2f389c6..5881ada535 100644 --- a/library/doctest.po +++ b/library/doctest.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-04-24 05:56+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-" @@ -273,39 +273,27 @@ msgstr "" #: ../../library/doctest.rst:176 msgid "" -"There is also a command line shortcut for running :func:`testmod`. You can " -"instruct the Python interpreter to run the doctest module directly from the " -"standard library and pass the module name(s) on the command line::" +"There is also a command line shortcut for running :func:`testmod`, see " +"section :ref:`doctest-cli`." msgstr "" -#: ../../library/doctest.rst:180 -msgid "python -m doctest -v example.py" -msgstr "python -m doctest -v example.py" - -#: ../../library/doctest.rst:182 -msgid "" -"This will import :file:`example.py` as a standalone module and run :func:" -"`testmod` on it. Note that this may not work correctly if the file is part " -"of a package and imports other submodules from that package." -msgstr "" - -#: ../../library/doctest.rst:186 +#: ../../library/doctest.rst:179 msgid "" "For more information on :func:`testmod`, see section :ref:`doctest-basic-" "api`." msgstr "" -#: ../../library/doctest.rst:192 +#: ../../library/doctest.rst:185 msgid "Simple Usage: Checking Examples in a Text File" msgstr "" -#: ../../library/doctest.rst:194 +#: ../../library/doctest.rst:187 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:197 +#: ../../library/doctest.rst:190 msgid "" "import doctest\n" "doctest.testfile(\"example.txt\")" @@ -313,7 +301,7 @@ msgstr "" "import doctest\n" "doctest.testfile(\"example.txt\")" -#: ../../library/doctest.rst:200 +#: ../../library/doctest.rst:193 msgid "" "That short script executes and verifies any interactive Python examples " "contained in the file :file:`example.txt`. The file content is treated as " @@ -321,7 +309,7 @@ msgid "" "Python program! For example, perhaps :file:`example.txt` contains this:" msgstr "" -#: ../../library/doctest.rst:205 +#: ../../library/doctest.rst:198 msgid "" "The ``example`` module\n" "======================\n" @@ -355,13 +343,13 @@ msgstr "" " >>> factorial(6)\n" " 120" -#: ../../library/doctest.rst:223 +#: ../../library/doctest.rst:216 msgid "" "Running ``doctest.testfile(\"example.txt\")`` then finds the error in this " "documentation::" msgstr "" -#: ../../library/doctest.rst:226 +#: ../../library/doctest.rst:219 msgid "" "File \"./example.txt\", line 14, in example.txt\n" "Failed example:\n" @@ -379,7 +367,7 @@ msgstr "" "Got:\n" " 720" -#: ../../library/doctest.rst:234 +#: ../../library/doctest.rst:227 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 " @@ -387,7 +375,7 @@ msgid "" "func:`testmod`." msgstr "" -#: ../../library/doctest.rst:239 +#: ../../library/doctest.rst:232 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 " @@ -395,40 +383,79 @@ msgid "" "locations." msgstr "" -#: ../../library/doctest.rst:243 +#: ../../library/doctest.rst:236 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:247 +#: ../../library/doctest.rst:240 +msgid "" +"There is also a command line shortcut for running :func:`testfile`, see " +"section :ref:`doctest-cli`." +msgstr "" + +#: ../../library/doctest.rst:243 msgid "" -"There is also a command line shortcut for running :func:`testfile`. You can " -"instruct the Python interpreter to run the doctest module directly from the " -"standard library and pass the file name(s) on the command line::" +"For more information on :func:`testfile`, see section :ref:`doctest-basic-" +"api`." +msgstr "" + +#: ../../library/doctest.rst:249 +msgid "Command-line Usage" msgstr "" #: ../../library/doctest.rst:251 -msgid "python -m doctest -v example.txt" -msgstr "python -m doctest -v example.txt" +msgid "" +"The :mod:`doctest` module can be invoked as a script from the command line:" +msgstr "" #: ../../library/doctest.rst:253 +msgid "python -m doctest [-v] [-o OPTION] [-f] file [file ...]" +msgstr "" + +#: ../../library/doctest.rst:261 msgid "" -"Because the file name does not end with :file:`.py`, :mod:`doctest` infers " -"that it must be run with :func:`testfile`, not :func:`testmod`." +"Detailed report of all examples tried is printed to standard output, along " +"with assorted summaries at the end::" msgstr "" -#: ../../library/doctest.rst:256 +#: ../../library/doctest.rst:264 +msgid "python -m doctest -v example.py" +msgstr "python -m doctest -v example.py" + +#: ../../library/doctest.rst:266 msgid "" -"For more information on :func:`testfile`, see section :ref:`doctest-basic-" -"api`." +"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:262 +#: ../../library/doctest.rst:270 +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 +msgid "python -m doctest -v example.txt" +msgstr "python -m doctest -v example.txt" + +#: ../../library/doctest.rst:277 +msgid "" +"Option flags control various aspects of doctest's behavior, see section :ref:" +"`doctest-options`." +msgstr "" + +#: ../../library/doctest.rst:284 +msgid "This is shorthand for ``-o FAIL_FAST``." +msgstr "" + +#: ../../library/doctest.rst:292 msgid "How It Works" msgstr "" -#: ../../library/doctest.rst:264 +#: ../../library/doctest.rst:294 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 " @@ -438,17 +465,17 @@ msgid "" "see the following sections." msgstr "" -#: ../../library/doctest.rst:275 +#: ../../library/doctest.rst:305 msgid "Which Docstrings Are Examined?" msgstr "" -#: ../../library/doctest.rst:277 +#: ../../library/doctest.rst:307 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:280 +#: ../../library/doctest.rst:310 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 " @@ -461,11 +488,11 @@ msgid "" "__test__.K``." msgstr "" -#: ../../library/doctest.rst:289 +#: ../../library/doctest.rst:319 msgid "For example, place this block of code at the top of :file:`example.py`:" msgstr "" -#: ../../library/doctest.rst:291 +#: ../../library/doctest.rst:321 msgid "" "__test__ = {\n" " 'numbers': \"\"\"\n" @@ -487,7 +514,7 @@ msgstr "" "\"\"\"\n" "}" -#: ../../library/doctest.rst:303 +#: ../../library/doctest.rst:333 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 " @@ -496,24 +523,24 @@ msgid "" "scanned for tests." msgstr "" -#: ../../library/doctest.rst:309 +#: ../../library/doctest.rst:339 msgid "" "Any classes found are recursively searched similarly, to test docstrings in " "their contained methods and nested classes." msgstr "" -#: ../../library/doctest.rst:316 +#: ../../library/doctest.rst:346 msgid "How are Docstring Examples Recognized?" msgstr "" -#: ../../library/doctest.rst:318 +#: ../../library/doctest.rst:348 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:323 +#: ../../library/doctest.rst:353 msgid "" ">>> # comments are ignored\n" ">>> x = 12\n" @@ -547,18 +574,18 @@ msgstr "" "NO!!!\n" ">>>" -#: ../../library/doctest.rst:343 +#: ../../library/doctest.rst:373 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:347 +#: ../../library/doctest.rst:377 msgid "The fine print:" msgstr "" -#: ../../library/doctest.rst:349 +#: ../../library/doctest.rst:379 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 " @@ -566,7 +593,7 @@ msgid "" "line is expected." msgstr "" -#: ../../library/doctest.rst:354 +#: ../../library/doctest.rst:384 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 " @@ -581,20 +608,20 @@ msgid "" "`DocTestParser` class." msgstr "" -#: ../../library/doctest.rst:366 +#: ../../library/doctest.rst:396 msgid "" "Output to stdout is captured, but not output to stderr (exception tracebacks " "are captured via a different means)." msgstr "" -#: ../../library/doctest.rst:369 +#: ../../library/doctest.rst:399 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:373 +#: ../../library/doctest.rst:403 msgid "" ">>> def f(x):\n" "... r'''Backslashes in a raw docstring: m\\n'''\n" @@ -603,7 +630,7 @@ msgid "" "Backslashes in a raw docstring: m\\n" msgstr "" -#: ../../library/doctest.rst:379 +#: ../../library/doctest.rst:409 msgid "" "Otherwise, the backslash will be interpreted as part of the string. For " "example, the ``\\n`` above would be interpreted as a newline character. " @@ -611,7 +638,7 @@ msgid "" "use a raw string)::" msgstr "" -#: ../../library/doctest.rst:383 +#: ../../library/doctest.rst:413 msgid "" ">>> def f(x):\n" "... '''Backslashes in a raw docstring: m\\\\n'''\n" @@ -620,11 +647,11 @@ msgid "" "Backslashes in a raw docstring: m\\n" msgstr "" -#: ../../library/doctest.rst:389 +#: ../../library/doctest.rst:419 msgid "The starting column doesn't matter::" msgstr "" -#: ../../library/doctest.rst:391 +#: ../../library/doctest.rst:421 msgid "" ">>> assert \"Easy!\"\n" " >>> import math\n" @@ -636,17 +663,17 @@ msgstr "" " >>> math.floor(1.9)\n" " 1" -#: ../../library/doctest.rst:396 +#: ../../library/doctest.rst:426 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:403 +#: ../../library/doctest.rst:433 msgid "What's the Execution Context?" msgstr "" -#: ../../library/doctest.rst:405 +#: ../../library/doctest.rst:435 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 " @@ -657,17 +684,17 @@ msgid "" "defined in other docstrings." msgstr "" -#: ../../library/doctest.rst:413 +#: ../../library/doctest.rst:443 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:420 +#: ../../library/doctest.rst:450 msgid "What About Exceptions?" msgstr "" -#: ../../library/doctest.rst:422 +#: ../../library/doctest.rst:452 msgid "" "No problem, provided that the traceback is the only output produced by the " "example: just paste in the traceback. [#]_ Since tracebacks contain details " @@ -676,11 +703,11 @@ msgid "" "it accepts." msgstr "" -#: ../../library/doctest.rst:428 +#: ../../library/doctest.rst:458 msgid "Simple example::" msgstr "簡單範例: ::" -#: ../../library/doctest.rst:430 +#: ../../library/doctest.rst:460 msgid "" ">>> [1, 2, 3].remove(42)\n" "Traceback (most recent call last):\n" @@ -692,20 +719,20 @@ msgstr "" " File \"\", line 1, in \n" "ValueError: list.remove(x): x not in list" -#: ../../library/doctest.rst:435 +#: ../../library/doctest.rst:465 msgid "" "That doctest succeeds if :exc:`ValueError` is raised, with the ``list." "remove(x): x not in list`` detail as shown." msgstr "" -#: ../../library/doctest.rst:438 +#: ../../library/doctest.rst:468 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:442 +#: ../../library/doctest.rst:472 msgid "" "Traceback (most recent call last):\n" "Traceback (innermost last):" @@ -713,14 +740,14 @@ msgstr "" "Traceback (most recent call last):\n" "Traceback (innermost last):" -#: ../../library/doctest.rst:445 +#: ../../library/doctest.rst:475 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:449 +#: ../../library/doctest.rst:479 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 " @@ -728,7 +755,7 @@ msgid "" "multi-line detail::" msgstr "" -#: ../../library/doctest.rst:454 +#: ../../library/doctest.rst:484 msgid "" ">>> raise ValueError('multi\\n line\\ndetail')\n" "Traceback (most recent call last):\n" @@ -738,20 +765,20 @@ msgid "" "detail" msgstr "" -#: ../../library/doctest.rst:461 +#: ../../library/doctest.rst:491 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:464 +#: ../../library/doctest.rst:494 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:467 +#: ../../library/doctest.rst:497 msgid "" ">>> raise ValueError('multi\\n line\\ndetail')\n" "Traceback (most recent call last):\n" @@ -761,7 +788,7 @@ msgid "" "detail" msgstr "" -#: ../../library/doctest.rst:474 +#: ../../library/doctest.rst:504 msgid "" "Note that tracebacks are treated very specially. In particular, in the " "rewritten example, the use of ``...`` is independent of doctest's :const:" @@ -770,11 +797,11 @@ msgid "" "transcript of a Monty Python skit." msgstr "" -#: ../../library/doctest.rst:480 +#: ../../library/doctest.rst:510 msgid "Some details you should read once, but won't need to remember:" msgstr "" -#: ../../library/doctest.rst:482 +#: ../../library/doctest.rst:512 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 " @@ -784,7 +811,7 @@ msgid "" "create real problems." msgstr "" -#: ../../library/doctest.rst:489 +#: ../../library/doctest.rst:519 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. " @@ -793,14 +820,14 @@ msgid "" "course this does the right thing for genuine tracebacks." msgstr "" -#: ../../library/doctest.rst:495 +#: ../../library/doctest.rst:525 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:499 +#: ../../library/doctest.rst:529 msgid "" "The interactive shell omits the traceback header line for some :exc:" "`SyntaxError`\\ s. But doctest uses the traceback header line to " @@ -809,13 +836,13 @@ msgid "" "need to manually add the traceback header line to your test example." msgstr "" -#: ../../library/doctest.rst:507 +#: ../../library/doctest.rst:537 msgid "" "For some exceptions, Python displays the position of the error using ``^`` " "markers and tildes::" msgstr "" -#: ../../library/doctest.rst:510 +#: ../../library/doctest.rst:540 msgid "" ">>> 1 + None\n" " File \"\", line 1\n" @@ -829,7 +856,7 @@ msgstr "" " ~~^~~~~~\n" "TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'" -#: ../../library/doctest.rst:516 +#: ../../library/doctest.rst:546 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 " @@ -837,7 +864,7 @@ msgid "" "location::" msgstr "" -#: ../../library/doctest.rst:520 +#: ../../library/doctest.rst:550 msgid "" ">>> 1 + None\n" " File \"\", line 1\n" @@ -851,11 +878,11 @@ msgstr "" " ^~~~~~~~\n" "TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'" -#: ../../library/doctest.rst:531 +#: ../../library/doctest.rst:561 msgid "Option Flags" msgstr "可選旗標" -#: ../../library/doctest.rst:533 +#: ../../library/doctest.rst:563 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 :" @@ -865,17 +892,13 @@ msgid "" "option." msgstr "" -#: ../../library/doctest.rst:539 -msgid "The ``-o`` command line option." -msgstr "" - -#: ../../library/doctest.rst:542 +#: ../../library/doctest.rst:569 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:548 +#: ../../library/doctest.rst:575 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 " @@ -887,7 +910,7 @@ msgid "" "not for several years." msgstr "" -#: ../../library/doctest.rst:560 +#: ../../library/doctest.rst:587 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 " @@ -896,7 +919,7 @@ msgid "" "`DONT_ACCEPT_BLANKLINE` is specified, this substitution is not allowed." msgstr "" -#: ../../library/doctest.rst:569 +#: ../../library/doctest.rst:596 msgid "" "When specified, all sequences of whitespace (blanks and newlines) are " "treated as equal. Any sequence of whitespace within the expected output " @@ -906,7 +929,7 @@ msgid "" "across multiple lines in your source." msgstr "" -#: ../../library/doctest.rst:580 +#: ../../library/doctest.rst:607 msgid "" "When specified, an ellipsis marker (``...``) in the expected output can " "match any substring in the actual output. This includes substrings that " @@ -915,14 +938,14 @@ msgid "" "matched too much!\" surprises that ``.*`` is prone to in regular expressions." msgstr "" -#: ../../library/doctest.rst:589 +#: ../../library/doctest.rst:616 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:593 +#: ../../library/doctest.rst:620 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:" @@ -932,7 +955,7 @@ msgid "" "these variations will work with the flag specified:" msgstr "" -#: ../../library/doctest.rst:601 +#: ../../library/doctest.rst:628 msgid "" ">>> raise Exception('message')\n" "Traceback (most recent call last):\n" @@ -958,20 +981,20 @@ msgstr "" "Traceback (most recent call last):\n" "__main__.Exception: message" -#: ../../library/doctest.rst:615 +#: ../../library/doctest.rst:642 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:619 +#: ../../library/doctest.rst:646 msgid "" ":const:`IGNORE_EXCEPTION_DETAIL` now also ignores any information relating " "to the module containing the exception under test." msgstr "" -#: ../../library/doctest.rst:626 +#: ../../library/doctest.rst:653 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, " @@ -980,32 +1003,32 @@ msgid "" "might depend on resources which would be unavailable to the test driver." msgstr "" -#: ../../library/doctest.rst:632 +#: ../../library/doctest.rst:659 msgid "" "The SKIP flag can also be used for temporarily \"commenting out\" examples." msgstr "" -#: ../../library/doctest.rst:637 +#: ../../library/doctest.rst:664 msgid "A bitmask or'ing together all the comparison flags above." msgstr "" -#: ../../library/doctest.rst:639 +#: ../../library/doctest.rst:666 msgid "The second group of options controls how test failures are reported:" msgstr "" -#: ../../library/doctest.rst:644 +#: ../../library/doctest.rst:671 msgid "" "When specified, failures that involve multi-line expected and actual outputs " "are displayed using a unified diff." msgstr "" -#: ../../library/doctest.rst:650 +#: ../../library/doctest.rst:677 msgid "" "When specified, failures that involve multi-line expected and actual outputs " "will be displayed using a context diff." msgstr "" -#: ../../library/doctest.rst:656 +#: ../../library/doctest.rst:683 msgid "" "When specified, differences are computed by ``difflib.Differ``, using the " "same algorithm as the popular :file:`ndiff.py` utility. This is the only " @@ -1015,7 +1038,7 @@ msgid "" "mismatching column positions." msgstr "" -#: ../../library/doctest.rst:665 +#: ../../library/doctest.rst:692 msgid "" "When specified, display the first failing example in each doctest, but " "suppress output for all remaining examples. This will prevent doctest from " @@ -1026,7 +1049,7 @@ msgid "" "of failures reported; only the output is suppressed." msgstr "" -#: ../../library/doctest.rst:676 +#: ../../library/doctest.rst:703 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 " @@ -1034,23 +1057,17 @@ msgid "" "first failure won't even produce debugging output." msgstr "" -#: ../../library/doctest.rst:681 -msgid "" -"The doctest command line accepts the option ``-f`` as a shorthand for ``-o " -"FAIL_FAST``." -msgstr "" - -#: ../../library/doctest.rst:689 +#: ../../library/doctest.rst:711 msgid "A bitmask or'ing together all the reporting flags above." msgstr "" -#: ../../library/doctest.rst:692 +#: ../../library/doctest.rst:714 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:698 +#: ../../library/doctest.rst:720 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 :" @@ -1059,39 +1076,39 @@ msgid "" "be called using the following idiom::" msgstr "" -#: ../../library/doctest.rst:704 +#: ../../library/doctest.rst:726 msgid "MY_FLAG = register_optionflag('MY_FLAG')" msgstr "MY_FLAG = register_optionflag('MY_FLAG')" -#: ../../library/doctest.rst:714 +#: ../../library/doctest.rst:736 msgid "Directives" msgstr "" -#: ../../library/doctest.rst:716 +#: ../../library/doctest.rst:738 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:727 +#: ../../library/doctest.rst:749 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:731 +#: ../../library/doctest.rst:753 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:734 +#: ../../library/doctest.rst:756 msgid "For example, this test passes:" msgstr "" -#: ../../library/doctest.rst:736 +#: ../../library/doctest.rst:758 msgid "" ">>> print(list(range(20))) # doctest: +NORMALIZE_WHITESPACE\n" "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9,\n" @@ -1101,7 +1118,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:743 +#: ../../library/doctest.rst:765 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 " @@ -1109,7 +1126,7 @@ msgid "" "a directive to do so:" msgstr "" -#: ../../library/doctest.rst:748 +#: ../../library/doctest.rst:770 msgid "" ">>> print(list(range(20))) # doctest: +ELLIPSIS\n" "[0, 1, ..., 18, 19]" @@ -1117,13 +1134,13 @@ msgstr "" ">>> print(list(range(20))) # doctest: +ELLIPSIS\n" "[0, 1, ..., 18, 19]" -#: ../../library/doctest.rst:754 +#: ../../library/doctest.rst:776 msgid "" "Multiple directives can be used on a single physical line, separated by " "commas:" msgstr "" -#: ../../library/doctest.rst:757 +#: ../../library/doctest.rst:779 msgid "" ">>> print(list(range(20))) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE\n" "[0, 1, ..., 18, 19]" @@ -1131,13 +1148,13 @@ msgstr "" ">>> print(list(range(20))) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE\n" "[0, 1, ..., 18, 19]" -#: ../../library/doctest.rst:763 +#: ../../library/doctest.rst:785 msgid "" "If multiple directive comments are used for a single example, then they are " "combined:" msgstr "" -#: ../../library/doctest.rst:766 +#: ../../library/doctest.rst:788 msgid "" ">>> print(list(range(20))) # doctest: +ELLIPSIS\n" "... # doctest: +NORMALIZE_WHITESPACE\n" @@ -1147,14 +1164,14 @@ msgstr "" "... # doctest: +NORMALIZE_WHITESPACE\n" "[0, 1, ..., 18, 19]" -#: ../../library/doctest.rst:773 +#: ../../library/doctest.rst:795 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:777 +#: ../../library/doctest.rst:799 msgid "" ">>> print(list(range(5)) + list(range(10, 20)) + list(range(30, 40)))\n" "... # doctest: +ELLIPSIS\n" @@ -1164,7 +1181,7 @@ msgstr "" "... # doctest: +ELLIPSIS\n" "[0, ..., 4, 10, ..., 19, 30, ..., 39]" -#: ../../library/doctest.rst:784 +#: ../../library/doctest.rst:806 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 " @@ -1174,11 +1191,11 @@ msgid "" "be useful." msgstr "" -#: ../../library/doctest.rst:794 +#: ../../library/doctest.rst:816 msgid "Warnings" msgstr "警告" -#: ../../library/doctest.rst:796 +#: ../../library/doctest.rst:818 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 " @@ -1188,7 +1205,7 @@ msgid "" "test like ::" msgstr "" -#: ../../library/doctest.rst:802 +#: ../../library/doctest.rst:824 msgid "" ">>> foo()\n" "{\"spam\", \"eggs\"}" @@ -1196,11 +1213,11 @@ msgstr "" ">>> foo()\n" "{\"spam\", \"eggs\"}" -#: ../../library/doctest.rst:805 +#: ../../library/doctest.rst:827 msgid "is vulnerable! One workaround is to do ::" msgstr "" -#: ../../library/doctest.rst:807 +#: ../../library/doctest.rst:829 msgid "" ">>> foo() == {\"spam\", \"eggs\"}\n" "True" @@ -1208,11 +1225,11 @@ msgstr "" ">>> foo() == {\"spam\", \"eggs\"}\n" "True" -#: ../../library/doctest.rst:810 +#: ../../library/doctest.rst:832 msgid "instead. Another is to do ::" msgstr "" -#: ../../library/doctest.rst:812 +#: ../../library/doctest.rst:834 msgid "" ">>> d = sorted(foo())\n" ">>> d\n" @@ -1222,29 +1239,29 @@ msgstr "" ">>> d\n" "['eggs', 'spam']" -#: ../../library/doctest.rst:816 +#: ../../library/doctest.rst:838 msgid "There are others, but you get the idea." msgstr "" -#: ../../library/doctest.rst:818 +#: ../../library/doctest.rst:840 msgid "Another bad idea is to print things that embed an object address, like" msgstr "" -#: ../../library/doctest.rst:820 +#: ../../library/doctest.rst:842 msgid "" -">>> id(1.0) # certain to fail some of the time \n" +">>> id(1.0) # certain to fail some of the time\n" "7948648\n" ">>> class C: pass\n" -">>> C() # the default repr() for instances embeds an address \n" +">>> C() # the default repr() for instances embeds an address\n" "" msgstr "" -#: ../../library/doctest.rst:828 +#: ../../library/doctest.rst:850 msgid "" "The :const:`ELLIPSIS` directive gives a nice approach for the last example:" msgstr "" -#: ../../library/doctest.rst:830 +#: ../../library/doctest.rst:852 msgid "" ">>> C() # doctest: +ELLIPSIS\n" "" @@ -1252,14 +1269,14 @@ msgstr "" ">>> C() # doctest: +ELLIPSIS\n" "" -#: ../../library/doctest.rst:836 +#: ../../library/doctest.rst:858 msgid "" "Floating-point numbers are also subject to small output variations across " "platforms, because Python defers to the platform C library for float " "formatting, and C libraries vary widely in quality here. ::" msgstr "" -#: ../../library/doctest.rst:840 +#: ../../library/doctest.rst:862 msgid "" ">>> 1./7 # risky\n" "0.14285714285714285\n" @@ -1269,29 +1286,29 @@ msgid "" "0.142857" msgstr "" -#: ../../library/doctest.rst:847 +#: ../../library/doctest.rst:869 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:850 +#: ../../library/doctest.rst:872 msgid "" ">>> 3./4 # utterly safe\n" "0.75" msgstr "" -#: ../../library/doctest.rst:853 +#: ../../library/doctest.rst:875 msgid "" "Simple fractions are also easier for people to understand, and that makes " "for better documentation." msgstr "" -#: ../../library/doctest.rst:860 +#: ../../library/doctest.rst:882 msgid "Basic API" msgstr "基礎 API" -#: ../../library/doctest.rst:862 +#: ../../library/doctest.rst:884 msgid "" "The functions :func:`testmod` and :func:`testfile` provide a simple " "interface to doctest that should be sufficient for most basic uses. For a " @@ -1299,25 +1316,25 @@ msgid "" "simple-testmod` and :ref:`doctest-simple-testfile`." msgstr "" -#: ../../library/doctest.rst:870 +#: ../../library/doctest.rst:892 msgid "" "All arguments except *filename* are optional, and should be specified in " "keyword form." msgstr "" -#: ../../library/doctest.rst:873 +#: ../../library/doctest.rst:895 msgid "" "Test examples in the file named *filename*. Return ``(failure_count, " "test_count)``." msgstr "" -#: ../../library/doctest.rst:876 +#: ../../library/doctest.rst:898 msgid "" "Optional argument *module_relative* specifies how the filename should be " "interpreted:" msgstr "" -#: ../../library/doctest.rst:879 +#: ../../library/doctest.rst:901 msgid "" "If *module_relative* is ``True`` (the default), then *filename* specifies an " "OS-independent module-relative path. By default, this path is relative to " @@ -1327,20 +1344,20 @@ msgid "" "absolute path (i.e., it may not begin with ``/``)." msgstr "" -#: ../../library/doctest.rst:886 +#: ../../library/doctest.rst:908 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:890 +#: ../../library/doctest.rst:912 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:893 +#: ../../library/doctest.rst:915 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-" @@ -1349,7 +1366,7 @@ msgid "" "is an error to specify *package* if *module_relative* is ``False``." msgstr "" -#: ../../library/doctest.rst:899 +#: ../../library/doctest.rst:921 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 " @@ -1357,7 +1374,7 @@ msgid "" "``None``, a new empty dict is used." msgstr "" -#: ../../library/doctest.rst:904 +#: ../../library/doctest.rst:926 msgid "" "Optional argument *extraglobs* gives a dict merged into the globals used to " "execute examples. This works like :meth:`dict.update`: if *globs* and " @@ -1370,27 +1387,27 @@ msgid "" "tested." msgstr "" -#: ../../library/doctest.rst:913 +#: ../../library/doctest.rst:935 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 ``sys.argv``." msgstr "" -#: ../../library/doctest.rst:917 +#: ../../library/doctest.rst:939 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:921 +#: ../../library/doctest.rst:943 msgid "" "Optional argument *optionflags* (default value 0) takes the :ref:`bitwise OR " "` of option flags. See section :ref:`doctest-options`." msgstr "" -#: ../../library/doctest.rst:925 +#: ../../library/doctest.rst:947 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. " @@ -1398,33 +1415,33 @@ msgid "" "continue running examples." msgstr "" -#: ../../library/doctest.rst:930 ../../library/doctest.rst:1072 +#: ../../library/doctest.rst:952 ../../library/doctest.rst:1094 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:934 ../../library/doctest.rst:1076 +#: ../../library/doctest.rst:956 ../../library/doctest.rst:1098 msgid "" "Optional argument *encoding* specifies an encoding that should be used to " "convert the file to unicode." msgstr "" -#: ../../library/doctest.rst:940 +#: ../../library/doctest.rst:962 msgid "" "All arguments are optional, and all except for *m* should be specified in " "keyword form." msgstr "" -#: ../../library/doctest.rst:943 +#: ../../library/doctest.rst:965 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:947 +#: ../../library/doctest.rst:969 msgid "" "Also test examples reachable from dict ``m.__test__``, if it exists. ``m." "__test__`` maps names (strings) to functions, classes and strings; function " @@ -1432,22 +1449,22 @@ msgid "" "directly, as if they were docstrings." msgstr "" -#: ../../library/doctest.rst:952 +#: ../../library/doctest.rst:974 msgid "" "Only docstrings attached to objects belonging to module *m* are searched." msgstr "" -#: ../../library/doctest.rst:954 +#: ../../library/doctest.rst:976 msgid "Return ``(failure_count, test_count)``." msgstr "" -#: ../../library/doctest.rst:956 +#: ../../library/doctest.rst:978 msgid "" "Optional argument *name* gives the name of the module; by default, or if " "``None``, ``m.__name__`` is used." msgstr "" -#: ../../library/doctest.rst:959 +#: ../../library/doctest.rst:981 msgid "" "Optional argument *exclude_empty* defaults to false. If true, objects for " "which no doctests are found are excluded from consideration. The default is " @@ -1458,39 +1475,39 @@ msgid "" "defaults to true." msgstr "" -#: ../../library/doctest.rst:967 +#: ../../library/doctest.rst:989 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:974 +#: ../../library/doctest.rst:996 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:977 +#: ../../library/doctest.rst:999 msgid "" "A shallow copy of dictionary argument *globs* is used for the execution " "context." msgstr "" -#: ../../library/doctest.rst:979 +#: ../../library/doctest.rst:1001 msgid "" "Optional argument *name* is used in failure messages, and defaults to " "``\"NoName\"``." msgstr "" -#: ../../library/doctest.rst:982 +#: ../../library/doctest.rst:1004 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:985 +#: ../../library/doctest.rst:1007 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 " @@ -1498,16 +1515,16 @@ msgid "" "found in *globs*." msgstr "" -#: ../../library/doctest.rst:989 +#: ../../library/doctest.rst:1011 msgid "" "Optional argument *optionflags* works as for function :func:`testfile` above." msgstr "" -#: ../../library/doctest.rst:995 +#: ../../library/doctest.rst:1017 msgid "Unittest API" msgstr "" -#: ../../library/doctest.rst:997 +#: ../../library/doctest.rst:1019 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 " @@ -1517,7 +1534,7 @@ msgid "" "your test module::" msgstr "" -#: ../../library/doctest.rst:1003 +#: ../../library/doctest.rst:1025 msgid "" "import unittest\n" "import doctest\n" @@ -1535,19 +1552,19 @@ msgstr "" " tests.addTests(doctest.DocTestSuite(my_module_with_doctests))\n" " return tests" -#: ../../library/doctest.rst:1011 +#: ../../library/doctest.rst:1033 msgid "" "There are two main functions for creating :class:`unittest.TestSuite` " "instances from text files and modules with doctests:" msgstr "" -#: ../../library/doctest.rst:1017 +#: ../../library/doctest.rst:1039 msgid "" "Convert doctest tests from one or more text files to a :class:`unittest." "TestSuite`." msgstr "" -#: ../../library/doctest.rst:1020 +#: ../../library/doctest.rst:1042 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 " @@ -1558,21 +1575,21 @@ msgid "" "marked as skipped." msgstr "" -#: ../../library/doctest.rst:1027 +#: ../../library/doctest.rst:1049 msgid "Pass one or more paths (as strings) to text files to be examined." msgstr "" -#: ../../library/doctest.rst:1029 +#: ../../library/doctest.rst:1051 msgid "Options may be provided as keyword arguments:" msgstr "" -#: ../../library/doctest.rst:1031 +#: ../../library/doctest.rst:1053 msgid "" "Optional argument *module_relative* specifies how the filenames in *paths* " "should be interpreted:" msgstr "" -#: ../../library/doctest.rst:1034 +#: ../../library/doctest.rst:1056 msgid "" "If *module_relative* is ``True`` (the default), then each filename in " "*paths* specifies an OS-independent module-relative path. By default, this " @@ -1583,14 +1600,14 @@ msgid "" "``)." msgstr "" -#: ../../library/doctest.rst:1042 +#: ../../library/doctest.rst:1064 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:1046 +#: ../../library/doctest.rst:1068 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-" @@ -1600,7 +1617,7 @@ msgid "" "``False``." msgstr "" -#: ../../library/doctest.rst:1053 +#: ../../library/doctest.rst:1075 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 " @@ -1608,7 +1625,7 @@ msgid "" "test globals as the *globs* attribute of the test passed." msgstr "" -#: ../../library/doctest.rst:1058 +#: ../../library/doctest.rst:1080 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* " @@ -1616,14 +1633,14 @@ msgid "" "access the test globals as the *globs* attribute of the test passed." msgstr "" -#: ../../library/doctest.rst:1063 ../../library/doctest.rst:1098 +#: ../../library/doctest.rst:1085 ../../library/doctest.rst:1120 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:1067 +#: ../../library/doctest.rst:1089 msgid "" "Optional argument *optionflags* specifies the default doctest options for " "the tests, created by or-ing together individual option flags. See section :" @@ -1631,17 +1648,17 @@ msgid "" "for a better way to set reporting options." msgstr "" -#: ../../library/doctest.rst:1079 +#: ../../library/doctest.rst:1101 msgid "" "The global ``__file__`` is added to the globals provided to doctests loaded " "from a text file using :func:`DocFileSuite`." msgstr "" -#: ../../library/doctest.rst:1085 +#: ../../library/doctest.rst:1107 msgid "Convert doctest tests for a module to a :class:`unittest.TestSuite`." msgstr "" -#: ../../library/doctest.rst:1087 +#: ../../library/doctest.rst:1109 msgid "" "The returned :class:`unittest.TestSuite` is to be run by the unittest " "framework and runs each doctest in the module. If any of the doctests fail, " @@ -1651,42 +1668,42 @@ msgid "" "skipped, then the synthesized unit test is also marked as skipped." msgstr "" -#: ../../library/doctest.rst:1094 +#: ../../library/doctest.rst:1116 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:1102 +#: ../../library/doctest.rst:1124 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:1105 +#: ../../library/doctest.rst:1127 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:1108 +#: ../../library/doctest.rst:1130 msgid "" "Optional arguments *setUp*, *tearDown*, and *optionflags* are the same as " "for function :func:`DocFileSuite` above." msgstr "" -#: ../../library/doctest.rst:1111 +#: ../../library/doctest.rst:1133 msgid "This function uses the same search technique as :func:`testmod`." msgstr "" -#: ../../library/doctest.rst:1113 +#: ../../library/doctest.rst:1135 msgid "" ":func:`DocTestSuite` returns an empty :class:`unittest.TestSuite` if " "*module* contains no docstrings instead of raising :exc:`ValueError`." msgstr "" -#: ../../library/doctest.rst:1119 +#: ../../library/doctest.rst:1141 msgid "" "When doctests which have been converted to unit tests by :func:" "`DocFileSuite` or :func:`DocTestSuite` fail, this exception is raised " @@ -1694,7 +1711,7 @@ msgid "" "approximate) line number." msgstr "" -#: ../../library/doctest.rst:1123 +#: ../../library/doctest.rst:1145 msgid "" "Under the covers, :func:`DocTestSuite` creates a :class:`unittest.TestSuite` " "out of :class:`!doctest.DocTestCase` instances, and :class:`!DocTestCase` is " @@ -1703,14 +1720,14 @@ msgid "" "questions about the exact details of :mod:`unittest` integration." msgstr "" -#: ../../library/doctest.rst:1129 +#: ../../library/doctest.rst:1151 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:1133 +#: ../../library/doctest.rst:1155 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 :" @@ -1723,23 +1740,23 @@ msgid "" "through :mod:`unittest` to :mod:`doctest` test runners." msgstr "" -#: ../../library/doctest.rst:1143 +#: ../../library/doctest.rst:1165 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:1149 +#: ../../library/doctest.rst:1171 msgid "Set the :mod:`doctest` reporting flags to use." msgstr "" -#: ../../library/doctest.rst:1151 +#: ../../library/doctest.rst:1173 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:1154 +#: ../../library/doctest.rst:1176 msgid "" "This is a module-global setting, and affects all future doctests run by " "module :mod:`unittest`: the :meth:`!runTest` method of :class:`!" @@ -1753,17 +1770,17 @@ msgid "" "`!doctest`'s :mod:`unittest` reporting flags are ignored." msgstr "" -#: ../../library/doctest.rst:1165 +#: ../../library/doctest.rst:1187 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:1172 +#: ../../library/doctest.rst:1194 msgid "Advanced API" msgstr "" -#: ../../library/doctest.rst:1174 +#: ../../library/doctest.rst:1196 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 " @@ -1771,62 +1788,62 @@ msgid "" "doctest's capabilities, then you should use the advanced API." msgstr "" -#: ../../library/doctest.rst:1179 +#: ../../library/doctest.rst:1201 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:1182 +#: ../../library/doctest.rst:1204 msgid "" ":class:`Example`: A single Python :term:`statement`, paired with its " "expected output." msgstr "" -#: ../../library/doctest.rst:1185 +#: ../../library/doctest.rst:1207 msgid "" ":class:`DocTest`: A collection of :class:`Example`\\ s, typically extracted " "from a single docstring or text file." msgstr "" -#: ../../library/doctest.rst:1188 +#: ../../library/doctest.rst:1210 msgid "" "Additional processing classes are defined to find, parse, and run, and check " "doctest examples:" msgstr "" -#: ../../library/doctest.rst:1191 +#: ../../library/doctest.rst:1213 msgid "" ":class:`DocTestFinder`: Finds all docstrings in a given module, and uses a :" "class:`DocTestParser` to create a :class:`DocTest` from every docstring that " "contains interactive examples." msgstr "" -#: ../../library/doctest.rst:1195 +#: ../../library/doctest.rst:1217 msgid "" ":class:`DocTestParser`: Creates a :class:`DocTest` object from a string " "(such as an object's docstring)." msgstr "" -#: ../../library/doctest.rst:1198 +#: ../../library/doctest.rst:1220 msgid "" ":class:`DocTestRunner`: Executes the examples in a :class:`DocTest`, and " "uses an :class:`OutputChecker` to verify their output." msgstr "" -#: ../../library/doctest.rst:1201 +#: ../../library/doctest.rst:1223 msgid "" ":class:`OutputChecker`: Compares the actual output from a doctest example " "with the expected output, and decides whether they match." msgstr "" -#: ../../library/doctest.rst:1204 +#: ../../library/doctest.rst:1226 msgid "" "The relationships among these processing classes are summarized in the " "following diagram::" msgstr "" -#: ../../library/doctest.rst:1207 +#: ../../library/doctest.rst:1229 msgid "" " list of:\n" "+------+ +---------+\n" @@ -1846,30 +1863,30 @@ msgstr "" " DocTestParser | Example | OutputChecker\n" " +---------+" -#: ../../library/doctest.rst:1220 +#: ../../library/doctest.rst:1242 msgid "DocTest Objects" msgstr "DocTest 物件" -#: ../../library/doctest.rst:1225 +#: ../../library/doctest.rst:1247 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:1229 +#: ../../library/doctest.rst:1251 msgid "" ":class:`DocTest` defines the following attributes. They are initialized by " "the constructor, and should not be modified directly." msgstr "" -#: ../../library/doctest.rst:1235 +#: ../../library/doctest.rst:1257 msgid "" "A list of :class:`Example` objects encoding the individual interactive " "Python examples that should be run by this test." msgstr "" -#: ../../library/doctest.rst:1241 +#: ../../library/doctest.rst:1263 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 " @@ -1877,57 +1894,57 @@ msgid "" "`globs` after the test is run." msgstr "" -#: ../../library/doctest.rst:1249 +#: ../../library/doctest.rst:1271 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:1255 +#: ../../library/doctest.rst:1277 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:1262 +#: ../../library/doctest.rst:1284 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:1269 +#: ../../library/doctest.rst:1291 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:1276 +#: ../../library/doctest.rst:1298 msgid "Example Objects" msgstr "Example 物件" -#: ../../library/doctest.rst:1281 +#: ../../library/doctest.rst:1303 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:1286 +#: ../../library/doctest.rst:1308 msgid "" ":class:`Example` defines the following attributes. They are initialized by " "the constructor, and should not be modified directly." msgstr "" -#: ../../library/doctest.rst:1292 +#: ../../library/doctest.rst:1314 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:1299 +#: ../../library/doctest.rst:1321 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 " @@ -1935,7 +1952,7 @@ msgid "" "The constructor adds a newline when necessary." msgstr "" -#: ../../library/doctest.rst:1307 +#: ../../library/doctest.rst:1329 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 " @@ -1944,20 +1961,20 @@ msgid "" "unless it's ``None``. The constructor adds a newline if needed." msgstr "" -#: ../../library/doctest.rst:1316 +#: ../../library/doctest.rst:1338 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:1323 +#: ../../library/doctest.rst:1345 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:1329 +#: ../../library/doctest.rst:1351 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 " @@ -1966,11 +1983,11 @@ msgid "" "default, no options are set." msgstr "" -#: ../../library/doctest.rst:1339 +#: ../../library/doctest.rst:1361 msgid "DocTestFinder objects" msgstr "DocTestFinder 物件" -#: ../../library/doctest.rst:1344 +#: ../../library/doctest.rst:1366 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 " @@ -1978,48 +1995,48 @@ msgid "" "classes, functions, methods, staticmethods, classmethods, and properties." msgstr "" -#: ../../library/doctest.rst:1349 +#: ../../library/doctest.rst:1371 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:1352 +#: ../../library/doctest.rst:1374 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:1355 +#: ../../library/doctest.rst:1377 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:1358 +#: ../../library/doctest.rst:1380 msgid "" "If the optional argument *exclude_empty* is false, then :meth:`DocTestFinder." "find` will include tests for objects with empty docstrings." msgstr "" -#: ../../library/doctest.rst:1362 +#: ../../library/doctest.rst:1384 msgid ":class:`DocTestFinder` defines the following method:" msgstr "" -#: ../../library/doctest.rst:1367 +#: ../../library/doctest.rst:1389 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:1370 +#: ../../library/doctest.rst:1392 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:1374 +#: ../../library/doctest.rst:1396 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 " @@ -2027,26 +2044,26 @@ msgid "" "module is used:" msgstr "" -#: ../../library/doctest.rst:1378 +#: ../../library/doctest.rst:1400 msgid "As a default namespace, if *globs* is not specified." msgstr "" -#: ../../library/doctest.rst:1380 +#: ../../library/doctest.rst:1402 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:1384 +#: ../../library/doctest.rst:1406 msgid "To find the name of the file containing the object." msgstr "" -#: ../../library/doctest.rst:1386 +#: ../../library/doctest.rst:1408 msgid "To help find the line number of the object within its file." msgstr "" -#: ../../library/doctest.rst:1388 +#: ../../library/doctest.rst:1410 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 " @@ -2055,7 +2072,7 @@ msgid "" "contained objects will (recursively) be searched for doctests." msgstr "" -#: ../../library/doctest.rst:1394 +#: ../../library/doctest.rst:1416 msgid "" "The globals for each :class:`DocTest` is formed by combining *globs* and " "*extraglobs* (bindings in *extraglobs* override bindings in *globs*). A new " @@ -2065,34 +2082,34 @@ msgid "" "defaults to ``{}``." msgstr "" -#: ../../library/doctest.rst:1405 +#: ../../library/doctest.rst:1427 msgid "DocTestParser objects" msgstr "DocTestParser 物件" -#: ../../library/doctest.rst:1410 +#: ../../library/doctest.rst:1432 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:1414 +#: ../../library/doctest.rst:1436 msgid ":class:`DocTestParser` defines the following methods:" msgstr "" -#: ../../library/doctest.rst:1419 +#: ../../library/doctest.rst:1441 msgid "" "Extract all doctest examples from the given string, and collect them into a :" "class:`DocTest` object." msgstr "" -#: ../../library/doctest.rst:1422 +#: ../../library/doctest.rst:1444 msgid "" "*globs*, *name*, *filename*, and *lineno* are attributes for the new :class:" "`DocTest` object. See the documentation for :class:`DocTest` for more " "information." msgstr "" -#: ../../library/doctest.rst:1429 +#: ../../library/doctest.rst:1451 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 " @@ -2100,7 +2117,7 @@ msgid "" "error messages." msgstr "" -#: ../../library/doctest.rst:1436 +#: ../../library/doctest.rst:1458 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 " @@ -2108,34 +2125,34 @@ msgid "" "name identifying this string, and is only used for error messages." msgstr "" -#: ../../library/doctest.rst:1443 +#: ../../library/doctest.rst:1465 #, fuzzy msgid "TestResults objects" msgstr "DocTestRunner 物件" -#: ../../library/doctest.rst:1450 +#: ../../library/doctest.rst:1472 msgid "Number of failed tests." msgstr "" -#: ../../library/doctest.rst:1454 +#: ../../library/doctest.rst:1476 msgid "Number of attempted tests." msgstr "" -#: ../../library/doctest.rst:1458 +#: ../../library/doctest.rst:1480 msgid "Number of skipped tests." msgstr "" -#: ../../library/doctest.rst:1466 +#: ../../library/doctest.rst:1488 msgid "DocTestRunner objects" msgstr "DocTestRunner 物件" -#: ../../library/doctest.rst:1471 +#: ../../library/doctest.rst:1493 msgid "" "A processing class used to execute and verify the interactive examples in a :" "class:`DocTest`." msgstr "" -#: ../../library/doctest.rst:1474 +#: ../../library/doctest.rst:1496 msgid "" "The comparison between expected outputs and actual outputs is done by an :" "class:`OutputChecker`. This comparison may be customized with a number of " @@ -2145,7 +2162,7 @@ msgid "" "constructor." msgstr "" -#: ../../library/doctest.rst:1480 +#: ../../library/doctest.rst:1502 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 " @@ -2156,14 +2173,14 @@ msgid "" "`report_unexpected_exception`, and :meth:`report_failure`." msgstr "" -#: ../../library/doctest.rst:1488 +#: ../../library/doctest.rst:1510 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:1492 +#: ../../library/doctest.rst:1514 msgid "" "The optional keyword argument *verbose* controls the :class:" "`DocTestRunner`'s verbosity. If *verbose* is ``True``, then information is " @@ -2172,14 +2189,14 @@ msgid "" "verbose output is used iff the command-line switch ``-v`` is used." msgstr "" -#: ../../library/doctest.rst:1498 +#: ../../library/doctest.rst:1520 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:1502 +#: ../../library/doctest.rst:1524 msgid "" "The test runner accumulates statistics. The aggregated number of attempted, " "failed and skipped examples is also available via the :attr:`tries`, :attr:" @@ -2187,53 +2204,53 @@ msgid "" "`summarize` methods return a :class:`TestResults` instance." msgstr "" -#: ../../library/doctest.rst:1507 +#: ../../library/doctest.rst:1529 msgid ":class:`DocTestRunner` defines the following methods:" msgstr "" -#: ../../library/doctest.rst:1512 +#: ../../library/doctest.rst:1534 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:1516 +#: ../../library/doctest.rst:1538 msgid "" "*example* is the example about to be processed. *test* is the test " "*containing example*. *out* is the output function that was passed to :meth:" "`DocTestRunner.run`." msgstr "" -#: ../../library/doctest.rst:1523 +#: ../../library/doctest.rst:1545 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:1527 ../../library/doctest.rst:1538 +#: ../../library/doctest.rst:1549 ../../library/doctest.rst:1560 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:1534 +#: ../../library/doctest.rst:1556 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:1545 +#: ../../library/doctest.rst:1567 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:1549 +#: ../../library/doctest.rst:1571 msgid "" "*example* is the example about to be processed. *exc_info* is a tuple " "containing information about the unexpected exception (as returned by :func:" @@ -2241,14 +2258,14 @@ msgid "" "output function that was passed to :meth:`DocTestRunner.run`." msgstr "" -#: ../../library/doctest.rst:1557 +#: ../../library/doctest.rst:1579 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:1561 +#: ../../library/doctest.rst:1583 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, " @@ -2256,55 +2273,55 @@ msgid "" "after the test completes, then use *clear_globs=False*." msgstr "" -#: ../../library/doctest.rst:1566 +#: ../../library/doctest.rst:1588 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:1570 +#: ../../library/doctest.rst:1592 msgid "" "The output of each example is checked using the :class:`DocTestRunner`'s " "output checker, and the results are formatted by the :meth:`!DocTestRunner." "report_\\*` methods." msgstr "" -#: ../../library/doctest.rst:1577 +#: ../../library/doctest.rst:1599 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:1580 +#: ../../library/doctest.rst:1602 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:1584 +#: ../../library/doctest.rst:1606 #, fuzzy msgid ":class:`DocTestParser` has the following attributes:" msgstr ":exc:`DocTestFailure` 定義了以下屬性:" -#: ../../library/doctest.rst:1588 +#: ../../library/doctest.rst:1610 msgid "Number of attempted examples." msgstr "" -#: ../../library/doctest.rst:1592 +#: ../../library/doctest.rst:1614 msgid "Number of failed examples." msgstr "" -#: ../../library/doctest.rst:1596 +#: ../../library/doctest.rst:1618 msgid "Number of skipped examples." msgstr "" -#: ../../library/doctest.rst:1604 +#: ../../library/doctest.rst:1626 msgid "OutputChecker objects" msgstr "OutputChecker 物件" -#: ../../library/doctest.rst:1609 +#: ../../library/doctest.rst:1631 msgid "" "A class used to check the whether the actual output from a doctest example " "matches the expected output. :class:`OutputChecker` defines two methods: :" @@ -2313,11 +2330,11 @@ msgid "" "string describing the differences between two outputs." msgstr "" -#: ../../library/doctest.rst:1616 +#: ../../library/doctest.rst:1638 msgid ":class:`OutputChecker` defines the following methods:" msgstr "" -#: ../../library/doctest.rst:1620 +#: ../../library/doctest.rst:1642 msgid "" "Return ``True`` iff the actual output from an example (*got*) matches the " "expected output (*want*). These strings are always considered to match if " @@ -2326,28 +2343,28 @@ msgid "" "`doctest-options` for more information about option flags." msgstr "" -#: ../../library/doctest.rst:1629 +#: ../../library/doctest.rst:1651 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:1637 +#: ../../library/doctest.rst:1659 msgid "Debugging" msgstr "" -#: ../../library/doctest.rst:1639 +#: ../../library/doctest.rst:1661 msgid "Doctest provides several mechanisms for debugging doctest examples:" msgstr "" -#: ../../library/doctest.rst:1641 +#: ../../library/doctest.rst:1663 msgid "" "Several functions convert doctests to executable Python programs, which can " "be run under the Python debugger, :mod:`pdb`." msgstr "" -#: ../../library/doctest.rst:1644 +#: ../../library/doctest.rst:1666 msgid "" "The :class:`DebugRunner` class is a subclass of :class:`DocTestRunner` that " "raises an exception for the first failing example, containing information " @@ -2355,13 +2372,13 @@ msgid "" "debugging on the example." msgstr "" -#: ../../library/doctest.rst:1649 +#: ../../library/doctest.rst:1671 msgid "" "The :mod:`unittest` cases generated by :func:`DocTestSuite` support the :" "meth:`debug` method defined by :class:`unittest.TestCase`." msgstr "" -#: ../../library/doctest.rst:1652 +#: ../../library/doctest.rst:1674 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 " @@ -2369,7 +2386,7 @@ msgid "" "`a.py` contains just this module docstring::" msgstr "" -#: ../../library/doctest.rst:1657 +#: ../../library/doctest.rst:1679 msgid "" "\"\"\"\n" ">>> def f(x):\n" @@ -2391,11 +2408,11 @@ msgstr "" "9\n" "\"\"\"" -#: ../../library/doctest.rst:1667 +#: ../../library/doctest.rst:1689 msgid "Then an interactive Python session may look like this::" msgstr "" -#: ../../library/doctest.rst:1669 +#: ../../library/doctest.rst:1691 msgid "" ">>> import a, doctest\n" ">>> doctest.testmod(a)\n" @@ -2457,17 +2474,17 @@ msgstr "" "(0, 3)\n" ">>>" -#: ../../library/doctest.rst:1700 +#: ../../library/doctest.rst:1722 msgid "" "Functions that convert doctests to Python code, and possibly run the " "synthesized code under the debugger:" msgstr "" -#: ../../library/doctest.rst:1706 +#: ../../library/doctest.rst:1728 msgid "Convert text with examples to a script." msgstr "" -#: ../../library/doctest.rst:1708 +#: ../../library/doctest.rst:1730 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 " @@ -2475,7 +2492,7 @@ msgid "" "generated script is returned as a string. For example, ::" msgstr "" -#: ../../library/doctest.rst:1713 +#: ../../library/doctest.rst:1735 msgid "" "import doctest\n" "print(doctest.script_from_examples(r\"\"\"\n" @@ -2488,11 +2505,11 @@ msgid "" "\"\"\"))" msgstr "" -#: ../../library/doctest.rst:1723 +#: ../../library/doctest.rst:1745 msgid "displays::" msgstr "" -#: ../../library/doctest.rst:1725 +#: ../../library/doctest.rst:1747 msgid "" "# Set x and y to 1 and 2.\n" "x, y = 1, 2\n" @@ -2503,18 +2520,18 @@ msgid "" "## 3" msgstr "" -#: ../../library/doctest.rst:1733 +#: ../../library/doctest.rst:1755 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:1740 +#: ../../library/doctest.rst:1762 msgid "Convert the doctest for an object to a script." msgstr "" -#: ../../library/doctest.rst:1742 +#: ../../library/doctest.rst:1764 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 " @@ -2524,7 +2541,7 @@ msgid "" "module :file:`a.py` contains a top-level function :func:`!f`, then ::" msgstr "" -#: ../../library/doctest.rst:1749 +#: ../../library/doctest.rst:1771 msgid "" "import a, doctest\n" "print(doctest.testsource(a, \"a.f\"))" @@ -2532,17 +2549,17 @@ msgstr "" "import a, doctest\n" "print(doctest.testsource(a, \"a.f\"))" -#: ../../library/doctest.rst:1752 +#: ../../library/doctest.rst:1774 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:1758 +#: ../../library/doctest.rst:1780 msgid "Debug the doctests for an object." msgstr "" -#: ../../library/doctest.rst:1760 +#: ../../library/doctest.rst:1782 msgid "" "The *module* and *name* arguments are the same as for function :func:" "`testsource` above. The synthesized Python script for the named object's " @@ -2550,13 +2567,13 @@ msgid "" "the control of the Python debugger, :mod:`pdb`." msgstr "" -#: ../../library/doctest.rst:1765 +#: ../../library/doctest.rst:1787 msgid "" "A shallow copy of ``module.__dict__`` is used for both local and global " "execution context." msgstr "" -#: ../../library/doctest.rst:1768 +#: ../../library/doctest.rst:1790 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 " @@ -2568,30 +2585,30 @@ msgid "" "to :func:`pdb.run`." msgstr "" -#: ../../library/doctest.rst:1779 +#: ../../library/doctest.rst:1801 msgid "Debug the doctests in a string." msgstr "" -#: ../../library/doctest.rst:1781 +#: ../../library/doctest.rst:1803 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:1784 +#: ../../library/doctest.rst:1806 msgid "" "Optional argument *pm* has the same meaning as in function :func:`debug` " "above." msgstr "" -#: ../../library/doctest.rst:1786 +#: ../../library/doctest.rst:1808 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:1791 +#: ../../library/doctest.rst:1813 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 " @@ -2599,7 +2616,7 @@ msgid "" "(which is a doctest!) for more details:" msgstr "" -#: ../../library/doctest.rst:1799 +#: ../../library/doctest.rst:1821 msgid "" "A subclass of :class:`DocTestRunner` that raises an exception as soon as a " "failure is encountered. If an unexpected exception occurs, an :exc:" @@ -2609,89 +2626,89 @@ msgid "" "the actual output." msgstr "" -#: ../../library/doctest.rst:1806 +#: ../../library/doctest.rst:1828 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:1809 +#: ../../library/doctest.rst:1831 msgid "" "There are two exceptions that may be raised by :class:`DebugRunner` " "instances:" msgstr "" -#: ../../library/doctest.rst:1814 +#: ../../library/doctest.rst:1836 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:1818 +#: ../../library/doctest.rst:1840 msgid ":exc:`DocTestFailure` defines the following attributes:" msgstr ":exc:`DocTestFailure` 定義了以下屬性:" -#: ../../library/doctest.rst:1823 ../../library/doctest.rst:1847 +#: ../../library/doctest.rst:1845 ../../library/doctest.rst:1869 msgid "The :class:`DocTest` object that was being run when the example failed." msgstr "" -#: ../../library/doctest.rst:1828 ../../library/doctest.rst:1852 +#: ../../library/doctest.rst:1850 ../../library/doctest.rst:1874 msgid "The :class:`Example` that failed." msgstr "" -#: ../../library/doctest.rst:1833 +#: ../../library/doctest.rst:1855 msgid "The example's actual output." msgstr "" -#: ../../library/doctest.rst:1838 +#: ../../library/doctest.rst:1860 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:1842 +#: ../../library/doctest.rst:1864 msgid ":exc:`UnexpectedException` defines the following attributes:" msgstr "" -#: ../../library/doctest.rst:1857 +#: ../../library/doctest.rst:1879 msgid "" "A tuple containing information about the unexpected exception, as returned " "by :func:`sys.exc_info`." msgstr "" -#: ../../library/doctest.rst:1864 +#: ../../library/doctest.rst:1886 msgid "Soapbox" msgstr "" -#: ../../library/doctest.rst:1866 +#: ../../library/doctest.rst:1888 msgid "" "As mentioned in the introduction, :mod:`doctest` has grown to have three " "primary uses:" msgstr "" -#: ../../library/doctest.rst:1869 +#: ../../library/doctest.rst:1891 msgid "Checking examples in docstrings." msgstr "" -#: ../../library/doctest.rst:1871 +#: ../../library/doctest.rst:1893 msgid "Regression testing." msgstr "" -#: ../../library/doctest.rst:1873 +#: ../../library/doctest.rst:1895 msgid "Executable documentation / literate testing." msgstr "" -#: ../../library/doctest.rst:1875 +#: ../../library/doctest.rst:1897 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:1879 +#: ../../library/doctest.rst:1901 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. " @@ -2703,7 +2720,7 @@ msgid "" "\"harmless\" change." msgstr "" -#: ../../library/doctest.rst:1887 +#: ../../library/doctest.rst:1909 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 " @@ -2724,13 +2741,13 @@ msgid "" "different results, blurring the distinction between testing and explaining." msgstr "" -#: ../../library/doctest.rst:1905 +#: ../../library/doctest.rst:1927 msgid "" "Regression testing is best confined to dedicated objects or files. There " "are several options for organizing tests:" msgstr "" -#: ../../library/doctest.rst:1908 +#: ../../library/doctest.rst:1930 msgid "" "Write text files containing test cases as interactive examples, and test the " "files using :func:`testfile` or :func:`DocFileSuite`. This is recommended, " @@ -2738,7 +2755,7 @@ msgid "" "doctest." msgstr "" -#: ../../library/doctest.rst:1913 +#: ../../library/doctest.rst:1935 msgid "" "Define functions named ``_regrtest_topic`` that consist of single " "docstrings, containing test cases for the named topics. These functions can " @@ -2746,13 +2763,13 @@ msgid "" "test file." msgstr "" -#: ../../library/doctest.rst:1917 +#: ../../library/doctest.rst:1939 msgid "" "Define a ``__test__`` dictionary mapping from regression test topics to " "docstrings containing test cases." msgstr "" -#: ../../library/doctest.rst:1920 +#: ../../library/doctest.rst:1942 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-" @@ -2760,7 +2777,7 @@ msgid "" "example of such a test runner::" msgstr "" -#: ../../library/doctest.rst:1925 +#: ../../library/doctest.rst:1947 #, fuzzy msgid "" "if __name__ == '__main__':\n" @@ -2793,53 +2810,53 @@ msgstr "" " fail, total = doctest.testmod(optionflags=flags)\n" " print(\"{} failures out of {} tests\".format(fail, total))" -#: ../../library/doctest.rst:1942 +#: ../../library/doctest.rst:1964 msgid "Footnotes" msgstr "註解" -#: ../../library/doctest.rst:1943 +#: ../../library/doctest.rst:1965 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:339 +#: ../../library/doctest.rst:369 msgid ">>>" msgstr ">>>" -#: ../../library/doctest.rst:339 +#: ../../library/doctest.rst:369 msgid "interpreter prompt" msgstr "interpreter prompt(直譯器提示)" -#: ../../library/doctest.rst:339 ../../library/doctest.rst:577 +#: ../../library/doctest.rst:369 ../../library/doctest.rst:604 msgid "..." msgstr "..." -#: ../../library/doctest.rst:505 +#: ../../library/doctest.rst:535 msgid "^ (caret)" msgstr "^ (插入符號)" -#: ../../library/doctest.rst:505 +#: ../../library/doctest.rst:535 msgid "marker" msgstr "marker(標記)" -#: ../../library/doctest.rst:557 +#: ../../library/doctest.rst:584 msgid "" msgstr "" -#: ../../library/doctest.rst:577 ../../library/doctest.rst:707 +#: ../../library/doctest.rst:604 ../../library/doctest.rst:729 msgid "in doctests" msgstr "於 doctests 中" -#: ../../library/doctest.rst:707 +#: ../../library/doctest.rst:729 msgid "# (hash)" msgstr "# (井字號)" -#: ../../library/doctest.rst:707 +#: ../../library/doctest.rst:729 msgid "+ (plus)" msgstr "+ (加號)" -#: ../../library/doctest.rst:707 +#: ../../library/doctest.rst:729 msgid "- (minus)" msgstr "- (減號)" diff --git a/library/email.contentmanager.po b/library/email.contentmanager.po index 2c155e66b3..b7f373d04d 100644 --- a/library/email.contentmanager.po +++ b/library/email.contentmanager.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-05-09 00:03+0000\n" +"POT-Creation-Date: 2025-02-07 08:41+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-" @@ -98,46 +98,46 @@ msgid "" msgstr "" #: ../../library/email.contentmanager.rst:61 -msgid "the type's qualname (``typ.__qualname__``)" +msgid "the type's :attr:`qualname ` (``typ.__qualname__``)" msgstr "" #: ../../library/email.contentmanager.rst:62 -msgid "the type's name (``typ.__name__``)." +msgid "the type's :attr:`name ` (``typ.__name__``)." msgstr "" #: ../../library/email.contentmanager.rst:64 msgid "" "If none of the above match, repeat all of the checks above for each of the " -"types in the :term:`MRO` (``typ.__mro__``). Finally, if no other key yields " -"a handler, check for a handler for the key ``None``. If there is no handler " -"for ``None``, raise a :exc:`KeyError` for the fully qualified name of the " -"type." +"types in the :term:`MRO` (:attr:`typ.__mro__ `). Finally, if " +"no other key yields a handler, check for a handler for the key ``None``. If " +"there is no handler for ``None``, raise a :exc:`KeyError` for the fully " +"qualified name of the type." msgstr "" -#: ../../library/email.contentmanager.rst:70 +#: ../../library/email.contentmanager.rst:71 msgid "" "Also add a :mailheader:`MIME-Version` header if one is not present (see " "also :class:`.MIMEPart`)." msgstr "" -#: ../../library/email.contentmanager.rst:76 +#: ../../library/email.contentmanager.rst:77 msgid "" "Record the function *handler* as the handler for *key*. For the possible " "values of *key*, see :meth:`get_content`." msgstr "" -#: ../../library/email.contentmanager.rst:82 +#: ../../library/email.contentmanager.rst:83 msgid "" "Record *handler* as the function to call when an object of a type matching " "*typekey* is passed to :meth:`set_content`. For the possible values of " "*typekey*, see :meth:`set_content`." msgstr "" -#: ../../library/email.contentmanager.rst:88 +#: ../../library/email.contentmanager.rst:89 msgid "Content Manager Instances" msgstr "" -#: ../../library/email.contentmanager.rst:90 +#: ../../library/email.contentmanager.rst:91 msgid "" "Currently the email package provides only one concrete content manager, :" "data:`raw_data_manager`, although more may be added in the future. :data:" @@ -145,7 +145,7 @@ msgid "" "provided by :attr:`~email.policy.EmailPolicy` and its derivatives." msgstr "" -#: ../../library/email.contentmanager.rst:99 +#: ../../library/email.contentmanager.rst:100 msgid "" "This content manager provides only a minimum interface beyond that provided " "by :class:`~email.message.Message` itself: it deals only with text, raw " @@ -158,7 +158,7 @@ msgid "" "simplifying the creation of multipart messages." msgstr "" -#: ../../library/email.contentmanager.rst:111 +#: ../../library/email.contentmanager.rst:112 msgid "" "Return the payload of the part as either a string (for ``text`` parts), an :" "class:`~email.message.EmailMessage` object (for ``message/rfc822`` parts), " @@ -168,28 +168,28 @@ msgid "" "to unicode. The default error handler is ``replace``." msgstr "" -#: ../../library/email.contentmanager.rst:130 +#: ../../library/email.contentmanager.rst:131 msgid "Add headers and payload to *msg*:" msgstr "" -#: ../../library/email.contentmanager.rst:132 +#: ../../library/email.contentmanager.rst:133 msgid "" "Add a :mailheader:`Content-Type` header with a ``maintype/subtype`` value." msgstr "" -#: ../../library/email.contentmanager.rst:135 +#: ../../library/email.contentmanager.rst:136 msgid "" "For ``str``, set the MIME ``maintype`` to ``text``, and set the subtype to " "*subtype* if it is specified, or ``plain`` if it is not." msgstr "" -#: ../../library/email.contentmanager.rst:137 +#: ../../library/email.contentmanager.rst:138 msgid "" "For ``bytes``, use the specified *maintype* and *subtype*, or raise a :exc:" "`TypeError` if they are not specified." msgstr "" -#: ../../library/email.contentmanager.rst:139 +#: ../../library/email.contentmanager.rst:140 msgid "" "For :class:`~email.message.EmailMessage` objects, set the maintype to " "``message``, and set the subtype to *subtype* if it is specified or " @@ -197,7 +197,7 @@ msgid "" "(``bytes`` objects must be used to construct ``message/partial`` parts)." msgstr "" -#: ../../library/email.contentmanager.rst:145 +#: ../../library/email.contentmanager.rst:146 msgid "" "If *charset* is provided (which is valid only for ``str``), encode the " "string to bytes using the specified character set. The default is " @@ -205,7 +205,7 @@ msgid "" "charset name, use the standard charset instead." msgstr "" -#: ../../library/email.contentmanager.rst:150 +#: ../../library/email.contentmanager.rst:151 msgid "" "If *cte* is set, encode the payload using the specified content transfer " "encoding, and set the :mailheader:`Content-Transfer-Encoding` header to that " @@ -215,13 +215,22 @@ msgid "" "that contains non-ASCII values), raise a :exc:`ValueError`." msgstr "" -#: ../../library/email.contentmanager.rst:158 +#: ../../library/email.contentmanager.rst:159 msgid "" "For ``str`` objects, if *cte* is not set use heuristics to determine the " -"most compact encoding." +"most compact encoding. Prior to encoding, :meth:`str.splitlines` is used to " +"normalize all line boundaries, ensuring that each line of the payload is " +"terminated by the current policy's :data:`~email.policy.Policy.linesep` " +"property (even if the original string did not end with one)." msgstr "" -#: ../../library/email.contentmanager.rst:160 +#: ../../library/email.contentmanager.rst:165 +msgid "" +"For ``bytes`` objects, *cte* is taken to be base64 if not set, and the " +"aforementioned newline translation is not performed." +msgstr "" + +#: ../../library/email.contentmanager.rst:167 msgid "" "For :class:`~email.message.EmailMessage`, per :rfc:`2046`, raise an error if " "a *cte* of ``quoted-printable`` or ``base64`` is requested for *subtype* " @@ -230,14 +239,14 @@ msgid "" "For all other values of *subtype*, use ``7bit``." msgstr "" -#: ../../library/email.contentmanager.rst:167 +#: ../../library/email.contentmanager.rst:174 msgid "" "A *cte* of ``binary`` does not actually work correctly yet. The " "``EmailMessage`` object as modified by ``set_content`` is correct, but :" "class:`~email.generator.BytesGenerator` does not serialize it correctly." msgstr "" -#: ../../library/email.contentmanager.rst:172 +#: ../../library/email.contentmanager.rst:179 msgid "" "If *disposition* is set, use it as the value of the :mailheader:`Content-" "Disposition` header. If not specified, and *filename* is specified, add the " @@ -246,37 +255,37 @@ msgid "" "values for *disposition* are ``attachment`` and ``inline``." msgstr "" -#: ../../library/email.contentmanager.rst:179 +#: ../../library/email.contentmanager.rst:186 msgid "" "If *filename* is specified, use it as the value of the ``filename`` " "parameter of the :mailheader:`Content-Disposition` header." msgstr "" -#: ../../library/email.contentmanager.rst:182 +#: ../../library/email.contentmanager.rst:189 msgid "" "If *cid* is specified, add a :mailheader:`Content-ID` header with *cid* as " "its value." msgstr "" -#: ../../library/email.contentmanager.rst:185 +#: ../../library/email.contentmanager.rst:192 msgid "" "If *params* is specified, iterate its ``items`` method and use the resulting " "``(key, value)`` pairs to set additional parameters on the :mailheader:" "`Content-Type` header." msgstr "" -#: ../../library/email.contentmanager.rst:189 +#: ../../library/email.contentmanager.rst:196 msgid "" "If *headers* is specified and is a list of strings of the form ``headername: " "headervalue`` or a list of ``header`` objects (distinguished from strings by " "having a ``name`` attribute), add the headers to *msg*." msgstr "" -#: ../../library/email.contentmanager.rst:196 +#: ../../library/email.contentmanager.rst:203 msgid "Footnotes" msgstr "註解" -#: ../../library/email.contentmanager.rst:197 +#: ../../library/email.contentmanager.rst:204 msgid "" "Originally added in 3.4 as a :term:`provisional module `" msgstr "" diff --git a/library/email.errors.po b/library/email.errors.po index 4e9e91bc1f..efdf5240fd 100644 --- a/library/email.errors.po +++ b/library/email.errors.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-08-07 00:03+0000\n" +"POT-Creation-Date: 2025-03-03 18:39+0000\n" "PO-Revision-Date: 2018-05-23 14:44+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -64,40 +64,31 @@ msgstr "" #: ../../library/email.errors.rst:48 msgid "" -"Raised when a payload is added to a :class:`~email.message.Message` object " -"using :meth:`add_payload`, but the payload is already a scalar and the " -"message's :mailheader:`Content-Type` main type is not either :mimetype:" -"`multipart` or missing. :exc:`MultipartConversionError` multiply inherits " -"from :exc:`MessageError` and the built-in :exc:`TypeError`." +"Raised if the :meth:`~email.message.Message.attach` method is called on an " +"instance of a class derived from :class:`~email.mime.nonmultipart." +"MIMENonMultipart` (e.g. :class:`~email.mime.image.MIMEImage`). :exc:" +"`MultipartConversionError` multiply inherits from :exc:`MessageError` and " +"the built-in :exc:`TypeError`." msgstr "" -#: ../../library/email.errors.rst:54 -msgid "" -"Since :meth:`Message.add_payload` is deprecated, this exception is rarely " -"raised in practice. However the exception may also be raised if the :meth:" -"`~email.message.Message.attach` method is called on an instance of a class " -"derived from :class:`~email.mime.nonmultipart.MIMENonMultipart` (e.g. :class:" -"`~email.mime.image.MIMEImage`)." -msgstr "" - -#: ../../library/email.errors.rst:64 +#: ../../library/email.errors.rst:58 msgid "" "Raised when an error occurs when the :mod:`~email.generator` outputs headers." msgstr "" -#: ../../library/email.errors.rst:70 +#: ../../library/email.errors.rst:64 msgid "" "This is the base class for all defects found when parsing email messages. It " "is derived from :exc:`ValueError`." msgstr "" -#: ../../library/email.errors.rst:75 +#: ../../library/email.errors.rst:69 msgid "" "This is the base class for all defects found when parsing email headers. It " "is derived from :exc:`MessageDefect`." msgstr "" -#: ../../library/email.errors.rst:78 +#: ../../library/email.errors.rst:72 msgid "" "Here is the list of the defects that the :class:`~email.parser.FeedParser` " "can find while parsing messages. Note that the defects are added to the " @@ -107,90 +98,84 @@ msgid "" "not." msgstr "" -#: ../../library/email.errors.rst:84 +#: ../../library/email.errors.rst:78 msgid "" "All defect classes are subclassed from :class:`email.errors.MessageDefect`." msgstr "" -#: ../../library/email.errors.rst:86 +#: ../../library/email.errors.rst:82 msgid "" -":class:`NoBoundaryInMultipartDefect` -- A message claimed to be a multipart, " -"but had no :mimetype:`boundary` parameter." +"A message claimed to be a multipart, but had no :mimetype:`boundary` " +"parameter." msgstr "" -#: ../../library/email.errors.rst:89 +#: ../../library/email.errors.rst:87 msgid "" -":class:`StartBoundaryNotFoundDefect` -- The start boundary claimed in the :" -"mailheader:`Content-Type` header was never found." +"The start boundary claimed in the :mailheader:`Content-Type` header was " +"never found." msgstr "" #: ../../library/email.errors.rst:92 msgid "" -":class:`CloseBoundaryNotFoundDefect` -- A start boundary was found, but no " -"corresponding close boundary was ever found." +"A start boundary was found, but no corresponding close boundary was ever " +"found." msgstr "" -#: ../../library/email.errors.rst:97 -msgid "" -":class:`FirstHeaderLineIsContinuationDefect` -- The message had a " -"continuation line as its first header line." +#: ../../library/email.errors.rst:99 +msgid "The message had a continuation line as its first header line." msgstr "" -#: ../../library/email.errors.rst:100 -msgid "" -":class:`MisplacedEnvelopeHeaderDefect` - A \"Unix From\" header was found in " -"the middle of a header block." +#: ../../library/email.errors.rst:103 +msgid "A \"Unix From\" header was found in the middle of a header block." msgstr "" -#: ../../library/email.errors.rst:103 +#: ../../library/email.errors.rst:107 msgid "" -":class:`MissingHeaderBodySeparatorDefect` - A line was found while parsing " -"headers that had no leading white space but contained no ':'. Parsing " -"continues assuming that the line represents the first line of the body." +"A line was found while parsing headers that had no leading white space but " +"contained no ':'. Parsing continues assuming that the line represents the " +"first line of the body." msgstr "" -#: ../../library/email.errors.rst:109 +#: ../../library/email.errors.rst:115 msgid "" -":class:`MalformedHeaderDefect` -- A header was found that was missing a " -"colon, or was otherwise malformed." +"A header was found that was missing a colon, or was otherwise malformed." msgstr "" -#: ../../library/email.errors.rst:112 +#: ../../library/email.errors.rst:117 msgid "This defect has not been used for several Python versions." msgstr "" -#: ../../library/email.errors.rst:115 +#: ../../library/email.errors.rst:122 msgid "" -":class:`MultipartInvariantViolationDefect` -- A message claimed to be a :" -"mimetype:`multipart`, but no subparts were found. Note that when a message " -"has this defect, its :meth:`~email.message.Message.is_multipart` method may " -"return ``False`` even though its content type claims to be :mimetype:" -"`multipart`." +"A message claimed to be a :mimetype:`multipart`, but no subparts were found. " +"Note that when a message has this defect, its :meth:`~email.message.Message." +"is_multipart` method may return ``False`` even though its content type " +"claims to be :mimetype:`multipart`." msgstr "" -#: ../../library/email.errors.rst:120 +#: ../../library/email.errors.rst:129 msgid "" -":class:`InvalidBase64PaddingDefect` -- When decoding a block of base64 " -"encoded bytes, the padding was not correct. Enough padding is added to " -"perform the decode, but the resulting decoded bytes may be invalid." +"When decoding a block of base64 encoded bytes, the padding was not correct. " +"Enough padding is added to perform the decode, but the resulting decoded " +"bytes may be invalid." msgstr "" -#: ../../library/email.errors.rst:124 +#: ../../library/email.errors.rst:135 msgid "" -":class:`InvalidBase64CharactersDefect` -- When decoding a block of base64 " -"encoded bytes, characters outside the base64 alphabet were encountered. The " -"characters are ignored, but the resulting decoded bytes may be invalid." +"When decoding a block of base64 encoded bytes, characters outside the base64 " +"alphabet were encountered. The characters are ignored, but the resulting " +"decoded bytes may be invalid." msgstr "" -#: ../../library/email.errors.rst:128 +#: ../../library/email.errors.rst:141 msgid "" -":class:`InvalidBase64LengthDefect` -- When decoding a block of base64 " -"encoded bytes, the number of non-padding base64 characters was invalid (1 " -"more than a multiple of 4). The encoded block was kept as-is." +"When decoding a block of base64 encoded bytes, the number of non-padding " +"base64 characters was invalid (1 more than a multiple of 4). The encoded " +"block was kept as-is." msgstr "" -#: ../../library/email.errors.rst:132 +#: ../../library/email.errors.rst:147 msgid "" -":class:`InvalidDateDefect` -- When decoding an invalid or unparsable date " -"field. The original value is kept as-is." +"When decoding an invalid or unparsable date field. The original value is " +"kept as-is." msgstr "" diff --git a/library/email.examples.po b/library/email.examples.po index fe74e43133..8186d940fa 100644 --- a/library/email.examples.po +++ b/library/email.examples.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-04-24 05:56+0000\n" "PO-Revision-Date: 2018-07-15 18:56+0800\n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" @@ -337,7 +337,7 @@ msgid "" " recette\n" " sera sûrement un très bon repas.\n" "

\n" -" \n" +" \n" " \n" "\n" "\"\"\".format(asparagus_cid=asparagus_cid[1:-1]), subtype='html')\n" diff --git a/library/email.headerregistry.po b/library/email.headerregistry.po index a55e5e9a83..43e3bde9e7 100644 --- a/library/email.headerregistry.po +++ b/library/email.headerregistry.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2024-10-04 16:20+0000\n" "PO-Revision-Date: 2018-05-23 14:44+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -390,7 +390,7 @@ msgid "" "class. When *use_default_map* is ``True`` (the default), the standard " "mapping of header names to classes is copied in to the registry during " "initialization. *base_class* is always the last class in the generated " -"class's ``__bases__`` list." +"class's :class:`~type.__bases__` list." msgstr "" #: ../../library/email.headerregistry.rst:322 diff --git a/library/email.parser.po b/library/email.parser.po index 69565e928d..4c1838e5c5 100644 --- a/library/email.parser.po +++ b/library/email.parser.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-03-03 18:39+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-" @@ -328,9 +328,10 @@ msgid "" msgstr "" #: ../../library/email.parser.rst:286 +#, fuzzy msgid "" ">>> import email\n" -">>> msg = email.message_from_bytes(myBytes) " +">>> msg = email.message_from_bytes(myBytes)" msgstr "" ">>> import email\n" ">>> msg = email.message_from_bytes(myBytes) " diff --git a/library/email.policy.po b/library/email.policy.po index 20f6c5e82b..c30e817522 100644 --- a/library/email.policy.po +++ b/library/email.policy.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-02-07 08:41+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-" @@ -355,7 +355,7 @@ msgstr "" #: ../../library/email.policy.rst:268 msgid "" "Handle a *defect* found on *obj*. When the email package calls this method, " -"*defect* will always be a subclass of :class:`~email.errors.Defect`." +"*defect* will always be a subclass of :class:`~email.errors.MessageDefect`." msgstr "" #: ../../library/email.policy.rst:272 @@ -368,7 +368,7 @@ msgstr "" #: ../../library/email.policy.rst:279 msgid "" "Register a *defect* on *obj*. In the email package, *defect* will always be " -"a subclass of :class:`~email.errors.Defect`." +"a subclass of :class:`~email.errors.MessageDefect`." msgstr "" #: ../../library/email.policy.rst:282 diff --git a/library/ensurepip.po b/library/ensurepip.po index 8b2bc4d453..fa7e3b7eb0 100644 --- a/library/ensurepip.po +++ b/library/ensurepip.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-03-03 18:39+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-" @@ -75,39 +75,34 @@ msgstr ":pep:`453`: 在 Python 安裝中的 pip 明確初始建置" msgid "The original rationale and specification for this module." msgstr "此模組的最初設計理念與規範。" -#: ../../includes/wasm-ios-notavail.rst:3 -msgid ":ref:`Availability `: not WASI, not iOS." +#: ../../includes/wasm-mobile-notavail.rst:3 +msgid "Availability" msgstr "" -#: ../../includes/wasm-ios-notavail.rst:5 -#, fuzzy +#: ../../includes/wasm-mobile-notavail.rst:5 msgid "" -"This module does not work or is not available on WebAssembly platforms, or " -"on iOS. See :ref:`wasm-availability` for more information on WASM " -"availability; see :ref:`iOS-availability` for more information on iOS " -"availability." +"This module is not supported on :ref:`mobile platforms ` or :ref:`WebAssembly platforms `." msgstr "" -"此模組在 WebAssembly 平台 ``wasm32-emscripten`` 和 ``wasm32-wasi`` 上無法作用" -"或無法使用。有關更多資訊,請參閱 :ref:`wasm-availability`。" #: ../../library/ensurepip.rst:44 msgid "Command line interface" msgstr "命令列介面" -#: ../../library/ensurepip.rst:46 +#: ../../library/ensurepip.rst:48 msgid "" "The command line interface is invoked using the interpreter's ``-m`` switch." msgstr "使用直譯器 (interpreter) 的 ``-m`` 來調用命令列介面" -#: ../../library/ensurepip.rst:48 +#: ../../library/ensurepip.rst:50 msgid "The simplest possible invocation is::" msgstr "最簡單可行的調用: ::" -#: ../../library/ensurepip.rst:50 +#: ../../library/ensurepip.rst:52 msgid "python -m ensurepip" msgstr "python -m ensurepip" -#: ../../library/ensurepip.rst:52 +#: ../../library/ensurepip.rst:54 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 " @@ -118,11 +113,11 @@ msgstr "" "upgrade`` 參數來確保 ``pip`` 的安裝版本至少為當前 ``ensurepip`` 中最新可用的" "版本: ::" -#: ../../library/ensurepip.rst:57 +#: ../../library/ensurepip.rst:59 msgid "python -m ensurepip --upgrade" msgstr "python -m ensurepip --upgrade" -#: ../../library/ensurepip.rst:59 +#: ../../library/ensurepip.rst:61 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 " @@ -132,25 +127,27 @@ msgstr "" "預設上,``pip`` 會被安裝至當前虛擬環境(若已啟動虛擬環境)或系統端的套件(若" "沒有啟動的虛擬環境)。安裝位置可透過兩個額外的命令列選項來控制:" -#: ../../library/ensurepip.rst:64 +#: ../../library/ensurepip.rst:68 +#, fuzzy msgid "" -":samp:`--root {dir}`: 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 the current Python installation." +"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 " +"the current Python installation." msgstr "" "``--root ``:安裝 ``pip`` 到給定的根目錄 (root directory) 的相對路徑,而" "不是當前虛擬環境(若存在)的根目錄,或當前 Python 安裝版所預設的根目錄。" -#: ../../library/ensurepip.rst:67 +#: ../../library/ensurepip.rst:74 +#, fuzzy msgid "" -"``--user``: Installs ``pip`` into the user site packages directory rather " -"than globally for the current Python installation (this option is not " -"permitted inside an active virtual environment)." +"Installs ``pip`` into the user site packages directory rather than globally " +"for the current Python installation (this option is not permitted inside an " +"active virtual environment)." msgstr "" "``--user`` :安裝 ``pip`` 到使用者端的套件目錄,而不是全域安裝到當前的 " "Python 安裝版(此選項不允許在一啟動的虛擬環境中使用)。" -#: ../../library/ensurepip.rst:71 +#: ../../library/ensurepip.rst:78 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 " @@ -159,45 +156,47 @@ msgstr "" "預設會安裝 ``pipX`` 和 ``pipX.Y`` 腳本(X.Y 代表用來調用 ``ensurepip`` 的 " "Python 之版本)。安裝的腳本可透過兩個額外的命令列選項來控制:" -#: ../../library/ensurepip.rst:76 +#: ../../library/ensurepip.rst:85 +#, fuzzy msgid "" -"``--altinstall``: if an alternate installation is requested, the ``pipX`` " -"script will *not* be installed." +"If an alternate installation is requested, the ``pipX`` script will *not* be " +"installed." msgstr "" "``--altinstall``:若要求一個替代安裝版,則\\ *不會*\\ 安裝 ``pipX`` 腳本。" -#: ../../library/ensurepip.rst:79 +#: ../../library/ensurepip.rst:90 +#, fuzzy msgid "" -"``--default-pip``: if a \"default pip\" installation is requested, the " -"``pip`` script will be installed in addition to the two regular scripts." +"If a \"default pip\" installation is requested, the ``pip`` script will be " +"installed in addition to the two regular scripts." msgstr "" "``--default-pip``: 若要求安裝「預設 pip」,則會安裝 ``pip`` 腳本,及 2 個常" "規腳本。" -#: ../../library/ensurepip.rst:82 +#: ../../library/ensurepip.rst:93 msgid "" "Providing both of the script selection options will trigger an exception." msgstr "提供兩種指令選項將會導致例外 (exception) 。" -#: ../../library/ensurepip.rst:86 +#: ../../library/ensurepip.rst:96 msgid "Module API" msgstr "模組 API" -#: ../../library/ensurepip.rst:88 +#: ../../library/ensurepip.rst:98 msgid ":mod:`ensurepip` exposes two functions for programmatic use:" msgstr ":mod:`ensurepip` 開放了兩個用於編寫程式的函式:" -#: ../../library/ensurepip.rst:92 +#: ../../library/ensurepip.rst:102 msgid "" "Returns a string specifying the available version of pip that will be " "installed when bootstrapping an environment." msgstr "回傳一個字串,用以標明初始建置時,安裝的 pip 的可行版本號。" -#: ../../library/ensurepip.rst:99 +#: ../../library/ensurepip.rst:109 msgid "Bootstraps ``pip`` into the current or designated environment." msgstr "在當前或指定的環境之中建立 ``pip``。" -#: ../../library/ensurepip.rst:101 +#: ../../library/ensurepip.rst:111 msgid "" "*root* specifies an alternative root directory to install relative to. If " "*root* is ``None``, then installation uses the default install location for " @@ -206,47 +205,47 @@ msgstr "" "*root* 指定一個替代的根目錄,作為安裝的相對路徑。若 *root* 為 ``None``,則安" "裝使用當前環境的預設安裝位置。" -#: ../../library/ensurepip.rst:105 +#: ../../library/ensurepip.rst:115 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:108 +#: ../../library/ensurepip.rst:118 msgid "" "*user* indicates whether to use the user scheme rather than installing " "globally." msgstr "*user* 指出是否要使用使用者的安裝方案而不是全域安裝。" -#: ../../library/ensurepip.rst:111 +#: ../../library/ensurepip.rst:121 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:114 +#: ../../library/ensurepip.rst:124 msgid "If *altinstall* is set, then ``pipX`` will *not* be installed." msgstr "如果啟用了 *altinstall*,則不會安裝 ``pipX``。" -#: ../../library/ensurepip.rst:116 +#: ../../library/ensurepip.rst:126 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:119 +#: ../../library/ensurepip.rst:129 msgid "" "Setting both *altinstall* and *default_pip* will trigger :exc:`ValueError`." msgstr "同時啟用 *altinstall* 跟 *default_pip*,將會觸發 :exc:`ValueError`。" -#: ../../library/ensurepip.rst:122 +#: ../../library/ensurepip.rst:132 msgid "" "*verbosity* controls the level of output to :data:`sys.stdout` from the " "bootstrapping operation." msgstr "" "*verbosity* 用來控制初始建置操作內,對於 :data:`sys.stdout` 的輸出等級。" -#: ../../library/ensurepip.rst:125 +#: ../../library/ensurepip.rst:135 msgid "" "Raises an :ref:`auditing event ` ``ensurepip.bootstrap`` with " "argument ``root``." @@ -254,7 +253,7 @@ msgstr "" "引發一個附帶引數 ``root`` 的\\ :ref:`稽核事件 ` ``ensurepip." "bootstrap``。" -#: ../../library/ensurepip.rst:129 +#: ../../library/ensurepip.rst:139 msgid "" "The bootstrapping process has side effects on both ``sys.path`` and ``os." "environ``. Invoking the command line interface in a subprocess instead " @@ -263,7 +262,7 @@ msgstr "" "初始建置的過程對於 ``sys.path`` 及 ``os.environ`` 均有副作用。改為在一子行程 " "(subprocess) 調用命令列介面可避免這些副作用。" -#: ../../library/ensurepip.rst:135 +#: ../../library/ensurepip.rst:145 msgid "" "The bootstrapping process may install additional modules required by " "``pip``, but other software should not assume those dependencies will always " @@ -273,3 +272,13 @@ msgstr "" "初始建置的過程也許會安裝 ``pip`` 所需要的額外的模組,但其他軟體不應該假設這些" "相依 (dependency) 總是預設存在(因為這些相依很可能會在未來版本的 ``pip`` 中被" "移除)。" + +#, fuzzy +#~ msgid "" +#~ "This module does not work or is not available on WebAssembly platforms, " +#~ "or on iOS. See :ref:`wasm-availability` for more information on WASM " +#~ "availability; see :ref:`iOS-availability` for more information on iOS " +#~ "availability." +#~ msgstr "" +#~ "此模組在 WebAssembly 平台 ``wasm32-emscripten`` 和 ``wasm32-wasi`` 上無法" +#~ "作用或無法使用。有關更多資訊,請參閱 :ref:`wasm-availability`。" diff --git a/library/enum.po b/library/enum.po index d67a0bd1b5..f05642bc5b 100644 --- a/library/enum.po +++ b/library/enum.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2024-12-29 16:19+0000\n" "PO-Revision-Date: 2023-09-11 14:08+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -83,7 +83,7 @@ msgid "" "... BLUE = 3\n" "\n" ">>> # functional syntax\n" -">>> Color = Enum('Color', ['RED', 'GREEN', 'BLUE'])" +">>> Color = Enum('Color', [('RED', 1), ('GREEN', 2), ('BLUE', 3)])" msgstr "" #: ../../library/enum.rst:49 @@ -228,10 +228,19 @@ msgstr "" "對如何處理非法值做更細微的控制。" #: ../../library/enum.rst:113 +#, fuzzy +msgid ":class:`EnumDict`" +msgstr ":class:`Enum`" + +#: ../../library/enum.rst:115 +msgid "A subclass of :class:`dict` for use when subclassing :class:`EnumType`." +msgstr "" + +#: ../../library/enum.rst:117 msgid ":class:`auto`" msgstr ":class:`auto`" -#: ../../library/enum.rst:115 +#: ../../library/enum.rst:119 msgid "" "Instances are replaced with an appropriate value for Enum members. :class:" "`StrEnum` defaults to the lower-cased version of the member name, while " @@ -240,11 +249,11 @@ msgstr "" "列舉成員的實例會被取代成合適的值。:class:`StrEnum` 預設是小寫版本的成員名稱," "其它列舉則預設是 1 且往後遞增。" -#: ../../library/enum.rst:119 +#: ../../library/enum.rst:123 msgid ":func:`~enum.property`" msgstr ":func:`~enum.property`" -#: ../../library/enum.rst:121 +#: ../../library/enum.rst:125 msgid "" "Allows :class:`Enum` members to have attributes without conflicting with " "member names. The ``value`` and ``name`` attributes are implemented this " @@ -253,46 +262,46 @@ msgstr "" "允許 :class:`Enum` 成員擁有屬性且不會與成員名稱有衝突。``value`` 及 ``name`` " "屬性是用這個方式來實作。" -#: ../../library/enum.rst:125 +#: ../../library/enum.rst:129 msgid ":func:`unique`" msgstr ":func:`unique`" -#: ../../library/enum.rst:127 +#: ../../library/enum.rst:131 msgid "" "Enum class decorator that ensures only one name is bound to any one value." msgstr "Enum 類別的裝飾器,用來確保任何值只有綁定到一個名稱上。" -#: ../../library/enum.rst:129 +#: ../../library/enum.rst:133 msgid ":func:`verify`" msgstr ":func:`verify`" -#: ../../library/enum.rst:131 +#: ../../library/enum.rst:135 msgid "" "Enum class decorator that checks user-selectable constraints on an " "enumeration." msgstr "Enum 類別的裝飾器,用來檢查列舉上使用者所選的限制。" -#: ../../library/enum.rst:134 +#: ../../library/enum.rst:138 msgid ":func:`member`" msgstr ":func:`member`" -#: ../../library/enum.rst:136 +#: ../../library/enum.rst:140 msgid "Make ``obj`` a member. Can be used as a decorator." msgstr "讓 ``obj`` 變成成員。可以當作裝飾器使用。" -#: ../../library/enum.rst:138 +#: ../../library/enum.rst:142 msgid ":func:`nonmember`" msgstr ":func:`nonmember`" -#: ../../library/enum.rst:140 +#: ../../library/enum.rst:144 msgid "Do not make ``obj`` a member. Can be used as a decorator." msgstr "不讓 ``obj`` 變成成員。可以當作裝飾器使用。" -#: ../../library/enum.rst:142 +#: ../../library/enum.rst:146 msgid ":func:`global_enum`" msgstr ":func:`global_enum`" -#: ../../library/enum.rst:144 +#: ../../library/enum.rst:148 msgid "" "Modify the :class:`str() ` and :func:`repr` of an enum to show its " "members as belonging to the module instead of its class, and export the enum " @@ -301,19 +310,19 @@ msgstr "" "修改列舉上的 :class:`str() ` 及 :func:`repr` ,讓成員顯示為屬於模組而不" "是類別,並將該列舉成員匯出到全域命名空間。" -#: ../../library/enum.rst:148 +#: ../../library/enum.rst:152 msgid ":func:`show_flag_values`" msgstr ":func:`show_flag_values`" -#: ../../library/enum.rst:150 +#: ../../library/enum.rst:154 msgid "Return a list of all power-of-two integers contained in a flag." msgstr "回傳旗標 (flag) 裡包含的所有 2 的次方的整數串列。" -#: ../../library/enum.rst:153 +#: ../../library/enum.rst:157 msgid "``Flag``, ``IntFlag``, ``auto``" msgstr "``Flag``, ``IntFlag``, ``auto``" -#: ../../library/enum.rst:154 +#: ../../library/enum.rst:158 msgid "" "``StrEnum``, ``EnumCheck``, ``ReprEnum``, ``FlagBoundary``, ``property``, " "``member``, ``nonmember``, ``global_enum``, ``show_flag_values``" @@ -322,10 +331,14 @@ msgstr "" "``member``, ``nonmember``, ``global_enum``, ``show_flag_values``" #: ../../library/enum.rst:159 +msgid "``EnumDict``" +msgstr "" + +#: ../../library/enum.rst:164 msgid "Data Types" msgstr "資料型別" -#: ../../library/enum.rst:164 +#: ../../library/enum.rst:169 msgid "" "*EnumType* is the :term:`metaclass` for *enum* enumerations. It is possible " "to subclass *EnumType* -- see :ref:`Subclassing EnumType `。" -#: ../../library/enum.rst:168 +#: ../../library/enum.rst:173 #, fuzzy msgid "" "``EnumType`` is responsible for setting the correct :meth:`!__repr__`, :meth:" @@ -346,11 +359,11 @@ msgstr "" "__str__`、:meth:`!__format__` 及 :meth:`!__reduce__` 方法,以及建立列舉成員," "並正確處理重複,提供列舉類別的疊代等等。" -#: ../../library/enum.rst:175 +#: ../../library/enum.rst:180 msgid "This method is called in two different ways:" msgstr "這個方法可以用兩種不同的方式呼叫:" -#: ../../library/enum.rst:177 +#: ../../library/enum.rst:182 msgid "to look up an existing member:" msgstr "查詢已存在的成員:" @@ -358,7 +371,7 @@ msgstr "查詢已存在的成員:" msgid "cls" msgstr "cls" -#: ../../library/enum.rst:179 ../../library/enum.rst:185 +#: ../../library/enum.rst:184 ../../library/enum.rst:190 msgid "The enum class being called." msgstr "所呼叫的列舉類別。" @@ -366,17 +379,17 @@ msgstr "所呼叫的列舉類別。" msgid "value" msgstr "value" -#: ../../library/enum.rst:180 +#: ../../library/enum.rst:185 msgid "The value to lookup." msgstr "要查詢的值。" -#: ../../library/enum.rst:182 +#: ../../library/enum.rst:187 msgid "" "to use the ``cls`` enum to create a new enum (only if the existing enum does " "not have any members):" msgstr "使用 ``cls`` 列舉來建立新列舉(只有在現有列舉沒有任何成員時)" -#: ../../library/enum.rst:186 +#: ../../library/enum.rst:191 msgid "The name of the new Enum to create." msgstr "要建立的新列舉的名稱。" @@ -384,7 +397,7 @@ msgstr "要建立的新列舉的名稱。" msgid "names" msgstr "names" -#: ../../library/enum.rst:187 +#: ../../library/enum.rst:192 msgid "The names/values of the members for the new Enum." msgstr "新列舉的成員的名稱/值。" @@ -392,7 +405,7 @@ msgstr "新列舉的成員的名稱/值。" msgid "module" msgstr "module" -#: ../../library/enum.rst:188 +#: ../../library/enum.rst:193 msgid "The name of the module the new Enum is created in." msgstr "新列舉要建立在哪個模組名稱下。" @@ -400,7 +413,7 @@ msgstr "新列舉要建立在哪個模組名稱下。" msgid "qualname" msgstr "qualname" -#: ../../library/enum.rst:189 +#: ../../library/enum.rst:194 msgid "The actual location in the module where this Enum can be found." msgstr "這個列舉在模組裡實際上的位置。" @@ -408,7 +421,7 @@ msgstr "這個列舉在模組裡實際上的位置。" msgid "type" msgstr "type" -#: ../../library/enum.rst:190 +#: ../../library/enum.rst:195 msgid "A mix-in type for the new Enum." msgstr "新列舉的混合類型。" @@ -416,7 +429,7 @@ msgstr "新列舉的混合類型。" msgid "start" msgstr "start" -#: ../../library/enum.rst:191 +#: ../../library/enum.rst:196 msgid "The first integer value for the Enum (used by :class:`auto`)." msgstr "列舉的第一個整數值(由 :class:`auto` 所使用)" @@ -424,16 +437,16 @@ msgstr "列舉的第一個整數值(由 :class:`auto` 所使用)" msgid "boundary" msgstr "boundary" -#: ../../library/enum.rst:192 +#: ../../library/enum.rst:197 msgid "" "How to handle out-of-range values from bit operations (:class:`Flag` only)." msgstr "在位元操作時怎麼處理範圍外的值(只有 :class:`Flag` 會用到)" -#: ../../library/enum.rst:196 +#: ../../library/enum.rst:201 msgid "Returns ``True`` if member belongs to the ``cls``::" msgstr "如果 member 屬於 ``cls`` 則回傳 ``True``: ::" -#: ../../library/enum.rst:198 +#: ../../library/enum.rst:203 msgid "" ">>> some_var = Color.RED\n" ">>> some_var in Color\n" @@ -447,7 +460,7 @@ msgstr "" ">>> Color.RED.value in Color\n" "True" -#: ../../library/enum.rst:206 +#: ../../library/enum.rst:211 msgid "" "Before Python 3.12, a ``TypeError`` is raised if a non-Enum-member is used " "in a containment check." @@ -455,7 +468,7 @@ msgstr "" "在 Python 3.12 之前,如果用非列舉成員做屬於檢查 (containment check) 會引發 " "``TypeError``。" -#: ../../library/enum.rst:211 +#: ../../library/enum.rst:216 msgid "" "Returns ``['__class__', '__doc__', '__members__', '__module__']`` and the " "names of the members in *cls*::" @@ -463,7 +476,7 @@ msgstr "" "回傳 ``['__class__', '__doc__', '__members__', '__module__']`` 及 *cls* 的成" "員名稱: ::" -#: ../../library/enum.rst:214 +#: ../../library/enum.rst:219 msgid "" ">>> dir(Color)\n" "['BLUE', 'GREEN', 'RED', '__class__', '__contains__', '__doc__', " @@ -475,13 +488,13 @@ msgstr "" "'__getitem__', '__init_subclass__', '__iter__', '__len__', '__members__', " "'__module__', '__name__', '__qualname__']" -#: ../../library/enum.rst:219 +#: ../../library/enum.rst:224 msgid "" "Returns the Enum member in *cls* matching *name*, or raises a :exc:" "`KeyError`::" msgstr "回傳 *cls* 中符合 *name* 的列舉成員,或引發 :exc:`KeyError`: ::" -#: ../../library/enum.rst:221 +#: ../../library/enum.rst:226 msgid "" ">>> Color['BLUE']\n" "" @@ -489,11 +502,11 @@ msgstr "" ">>> Color['BLUE']\n" "" -#: ../../library/enum.rst:226 +#: ../../library/enum.rst:231 msgid "Returns each member in *cls* in definition order::" msgstr "以定義的順序回傳在 *cls* 中的每個成員: ::" -#: ../../library/enum.rst:228 +#: ../../library/enum.rst:233 msgid "" ">>> list(Color)\n" "[, , ]" @@ -501,11 +514,11 @@ msgstr "" ">>> list(Color)\n" "[, , ]" -#: ../../library/enum.rst:233 +#: ../../library/enum.rst:238 msgid "Returns the number of member in *cls*::" msgstr "回傳 *cls* 的成員數量: ::" -#: ../../library/enum.rst:235 +#: ../../library/enum.rst:240 msgid "" ">>> len(Color)\n" "3" @@ -513,15 +526,15 @@ msgstr "" ">>> len(Color)\n" "3" -#: ../../library/enum.rst:240 +#: ../../library/enum.rst:245 msgid "Returns a mapping of every enum name to its member, including aliases" msgstr "回傳每個列舉名稱到其成員的對映,包括別名" -#: ../../library/enum.rst:244 +#: ../../library/enum.rst:249 msgid "Returns each member in *cls* in reverse definition order::" msgstr "以跟定義相反的順序回傳 *cls* 的每個成員: ::" -#: ../../library/enum.rst:246 +#: ../../library/enum.rst:251 msgid "" ">>> list(reversed(Color))\n" "[, , ]" @@ -529,19 +542,19 @@ msgstr "" ">>> list(reversed(Color))\n" "[, , ]" -#: ../../library/enum.rst:251 +#: ../../library/enum.rst:256 msgid "" "Adds a new name as an alias to an existing member. Raises a :exc:" "`NameError` if the name is already assigned to a different member." msgstr "" -#: ../../library/enum.rst:256 +#: ../../library/enum.rst:261 msgid "" "Adds a new value as an alias to an existing member. Raises a :exc:" "`ValueError` if the value is already linked with a different member." msgstr "" -#: ../../library/enum.rst:261 +#: ../../library/enum.rst:266 #, fuzzy msgid "" "Before 3.11 ``EnumType`` was called ``EnumMeta``, which is still available " @@ -549,15 +562,15 @@ msgid "" msgstr "" "在 3.11 之前,``enum`` 使用 ``EnumMeta`` 類型,目前保留此類型當作別名。" -#: ../../library/enum.rst:266 +#: ../../library/enum.rst:271 msgid "*Enum* is the base class for all *enum* enumerations." msgstr "*Enum* 是所有 *enum* 列舉的基礎類別。" -#: ../../library/enum.rst:270 +#: ../../library/enum.rst:275 msgid "The name used to define the ``Enum`` member::" msgstr "用來定義 ``Enum`` 成員的名稱: ::" -#: ../../library/enum.rst:272 +#: ../../library/enum.rst:277 msgid "" ">>> Color.BLUE.name\n" "'BLUE'" @@ -565,11 +578,11 @@ msgstr "" ">>> Color.BLUE.name\n" "'BLUE'" -#: ../../library/enum.rst:277 +#: ../../library/enum.rst:282 msgid "The value given to the ``Enum`` member::" msgstr "``Enum`` 成員給定的值: ::" -#: ../../library/enum.rst:279 +#: ../../library/enum.rst:284 msgid "" ">>> Color.RED.value\n" "1" @@ -577,15 +590,15 @@ msgstr "" ">>> Color.RED.value\n" "1" -#: ../../library/enum.rst:282 ../../library/enum.rst:302 +#: ../../library/enum.rst:287 ../../library/enum.rst:307 msgid "Value of the member, can be set in :meth:`~Enum.__new__`." msgstr "成員的值,可以在 :meth:`~Enum.__new__` 設定。" -#: ../../library/enum.rst:284 +#: ../../library/enum.rst:289 msgid "Enum member values" msgstr "列舉成員的值" -#: ../../library/enum.rst:286 +#: ../../library/enum.rst:291 msgid "" "Member values can be anything: :class:`int`, :class:`str`, etc. If the " "exact value is unimportant you may use :class:`auto` instances and an " @@ -595,7 +608,7 @@ msgstr "" "重要,你可以使用 :class:`auto` 實例,它會為你選擇合適的值。更多細節請參考 :" "class:`auto`。" -#: ../../library/enum.rst:291 +#: ../../library/enum.rst:296 msgid "" "While mutable/unhashable values, such as :class:`dict`, :class:`list` or a " "mutable :class:`~dataclasses.dataclass`, can be used, they will have a " @@ -603,23 +616,23 @@ msgid "" "mutable/unhashable values in the enum." msgstr "" -#: ../../library/enum.rst:298 +#: ../../library/enum.rst:303 msgid "Name of the member." msgstr "成員名稱。" -#: ../../library/enum.rst:306 +#: ../../library/enum.rst:311 msgid "" "No longer used, kept for backward compatibility. (class attribute, removed " "during class creation)." msgstr "已不再使用,只為了向後相容而保留(類別屬性,在類別建立時移除)" -#: ../../library/enum.rst:311 +#: ../../library/enum.rst:316 msgid "" "``_ignore_`` is only used during creation and is removed from the " "enumeration once creation is complete." msgstr "``_ignore_`` 只有在建立的時候用到,在列舉建立完成後會被移除。" -#: ../../library/enum.rst:314 +#: ../../library/enum.rst:319 msgid "" "``_ignore_`` is a list of names that will not become members, and whose " "names will also be removed from the completed enumeration. See :ref:" @@ -628,7 +641,7 @@ msgstr "" "``_ignore_`` 是一個不會變成成員的名稱串列,在列舉建立完成後其名稱會被移除。範" "例請參考 :ref:`TimePeriod `。" -#: ../../library/enum.rst:320 +#: ../../library/enum.rst:325 msgid "" "Returns ``['__class__', '__doc__', '__module__', 'name', 'value']`` and any " "public methods defined on *self.__class__*::" @@ -636,7 +649,7 @@ msgstr "" "回傳 ``['__class__', '__doc__', '__module__', 'name', 'value']`` 及任何 " "*self.__class__* 上定義的公開方法: ::" -#: ../../library/enum.rst:323 +#: ../../library/enum.rst:328 msgid "" ">>> from datetime import date\n" ">>> class Weekday(Enum):\n" @@ -676,11 +689,11 @@ msgstr "" msgid "name" msgstr "name" -#: ../../library/enum.rst:341 +#: ../../library/enum.rst:346 msgid "The name of the member being defined (e.g. 'RED')." msgstr "定義的成員名稱(例如 'RED')。" -#: ../../library/enum.rst:342 +#: ../../library/enum.rst:347 msgid "The start value for the Enum; the default is 1." msgstr "列舉的開始值,預設為 1。" @@ -688,7 +701,7 @@ msgstr "列舉的開始值,預設為 1。" msgid "count" msgstr "count" -#: ../../library/enum.rst:343 +#: ../../library/enum.rst:348 msgid "The number of members currently defined, not including this one." msgstr "已定義的成員數量,不包含目前這一個。" @@ -696,17 +709,17 @@ msgstr "已定義的成員數量,不包含目前這一個。" msgid "last_values" msgstr "last_values" -#: ../../library/enum.rst:344 +#: ../../library/enum.rst:349 msgid "A list of the previous values." msgstr "一個之前值的串列。" -#: ../../library/enum.rst:346 +#: ../../library/enum.rst:351 msgid "" "A *staticmethod* that is used to determine the next value returned by :class:" "`auto`::" msgstr "一個 *staticmethod*,用來決定 :class:`auto` 下一個要回傳的值的: ::" -#: ../../library/enum.rst:349 +#: ../../library/enum.rst:354 msgid "" ">>> from enum import auto\n" ">>> class PowersOfThree(Enum):\n" @@ -730,7 +743,7 @@ msgstr "" ">>> PowersOfThree.SECOND.value\n" "9" -#: ../../library/enum.rst:362 +#: ../../library/enum.rst:367 msgid "" "By default, does nothing. If multiple values are given in the member " "assignment, those values become separate arguments to ``__init__``; e.g." @@ -738,19 +751,19 @@ msgstr "" "預設情況下,不執行任何操作。如果在成員賦值中給出多個值,這些值將成為與 " "``__init__`` 分別的引數;例如" -#: ../../library/enum.rst:369 +#: ../../library/enum.rst:374 msgid "" "``Weekday.__init__()`` would be called as ``Weekday.__init__(self, 1, " "'Mon')``" msgstr "``Weekday.__init__()`` 將被稱為 ``Weekday.__init__(self, 1, 'Mon')``" -#: ../../library/enum.rst:373 +#: ../../library/enum.rst:378 msgid "" "A *classmethod* that is used to further configure subsequent subclasses. By " "default, does nothing." msgstr "一個 *classmethod*,用來進一步設定後續的子類別,預設不做任何事。" -#: ../../library/enum.rst:378 +#: ../../library/enum.rst:383 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::" @@ -758,7 +771,7 @@ msgstr "" "一個 *classmethod*,用來查詢在 *cls* 裡找不到的值。預設不做任何事,但可以被覆" "寫以實作客製化的搜尋行為: ::" -#: ../../library/enum.rst:381 +#: ../../library/enum.rst:386 msgid "" ">>> from enum import StrEnum\n" ">>> class Build(StrEnum):\n" @@ -794,7 +807,7 @@ msgstr "" ">>> Build('deBUG')\n" "" -#: ../../library/enum.rst:400 +#: ../../library/enum.rst:405 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 " @@ -803,12 +816,12 @@ msgstr "" "預設情況下不存在。如果有指定,無論是在列舉類別定義中還是在 mixin 類別中(例" "如 ``int``\\ ),都將傳遞成員賦值中給出的所有值;例如" -#: ../../library/enum.rst:408 +#: ../../library/enum.rst:413 msgid "" "results in the call ``int('1a', 16)`` and a value of ``26`` for the member." msgstr "" -#: ../../library/enum.rst:412 +#: ../../library/enum.rst:417 msgid "" "When writing a custom ``__new__``, do not use ``super().__new__`` -- call " "the appropriate ``__new__`` instead." @@ -816,7 +829,7 @@ msgstr "" "當寫自訂的 ``__new__`` 時,不要使用 ``super().__new__``,而是要呼叫適當的 " "``__new__``。" -#: ../../library/enum.rst:417 +#: ../../library/enum.rst:422 msgid "" "Returns the string used for *repr()* calls. By default, returns the *Enum* " "name, member name, and value, but can be overridden::" @@ -824,7 +837,7 @@ msgstr "" "回傳呼叫 *repr()* 時使用的字串。預設回傳 *Enum* 名稱、成員名稱及值,但可以被" "覆寫: ::" -#: ../../library/enum.rst:420 +#: ../../library/enum.rst:425 msgid "" ">>> class OtherStyle(Enum):\n" "... ALTERNATE = auto()\n" @@ -850,7 +863,7 @@ msgstr "" "ALTERNATE}\"\n" "(OtherStyle.ALTERNATE, 'OtherStyle.ALTERNATE', 'OtherStyle.ALTERNATE')" -#: ../../library/enum.rst:433 +#: ../../library/enum.rst:438 msgid "" "Returns the string used for *str()* calls. By default, returns the *Enum* " "name and member name, but can be overridden::" @@ -858,7 +871,7 @@ msgstr "" "回傳呼叫 *str()* 時使用的字串。預設回傳 *Enum* 名稱及成員名稱,但可以被覆" "寫: ::" -#: ../../library/enum.rst:436 +#: ../../library/enum.rst:441 msgid "" ">>> class OtherStyle(Enum):\n" "... ALTERNATE = auto()\n" @@ -882,7 +895,7 @@ msgstr "" "ALTERNATE}\"\n" "(, 'ALTERNATE', 'ALTERNATE')" -#: ../../library/enum.rst:448 +#: ../../library/enum.rst:453 msgid "" "Returns the string used for *format()* and *f-string* calls. By default, " "returns :meth:`__str__` return value, but can be overridden::" @@ -890,7 +903,7 @@ msgstr "" "回傳呼叫 *format()* 及 *f-string* 時使用的字串。預設回傳 :meth:`__str__` 的回" "傳值,但可以被覆寫: ::" -#: ../../library/enum.rst:451 +#: ../../library/enum.rst:456 msgid "" ">>> class OtherStyle(Enum):\n" "... ALTERNATE = auto()\n" @@ -914,17 +927,17 @@ msgstr "" "ALTERNATE}\"\n" "(, 'OtherStyle.ALTERNATE', 'ALTERNATE')" -#: ../../library/enum.rst:463 +#: ../../library/enum.rst:468 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:466 +#: ../../library/enum.rst:471 msgid "Added :ref:`enum-dataclass-support`" msgstr "新增 :ref:`enum-dataclass-support`" -#: ../../library/enum.rst:471 +#: ../../library/enum.rst:476 #, fuzzy msgid "" "*IntEnum* is the same as :class:`Enum`, but its members are also integers " @@ -935,13 +948,13 @@ msgstr "" "*IntEnum* 和 *Enum* 一樣,但其成員同時也是整數而可以被用在任何使用整數的地" "方。如果 *IntEnum* 成員經過任何整數運算,其結果會失去列舉狀態。" -#: ../../library/enum.rst:492 +#: ../../library/enum.rst:497 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:495 +#: ../../library/enum.rst:500 msgid "" ":meth:`~object.__str__` is now :meth:`!int.__str__` to better support the " "*replacement of existing constants* use-case. :meth:`~object.__format__` was " @@ -951,7 +964,7 @@ msgstr "" "境,:meth:`~object.__str__` 現在會是 :meth:`!int.__str__`。為了同樣的理由,:" "meth:`~object.__format__` 已經是 :meth:`!int.__format__`。" -#: ../../library/enum.rst:502 +#: ../../library/enum.rst:507 #, fuzzy msgid "" "``StrEnum`` is the same as :class:`Enum`, but its members are also strings " @@ -962,7 +975,7 @@ msgstr "" "*StrEnum* 和 *Enum* 一樣,但其成員同時也是字串而可以被用在幾乎所有使用字串的" "地方。*StrEnum* 成員經過任何字串操作的結果會不再是列舉的一部份。" -#: ../../library/enum.rst:508 +#: ../../library/enum.rst:513 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 " @@ -973,13 +986,13 @@ msgstr "" "是 ``type(unknown) == str`` 而不是 ``isinstance(unknown, str)``),在這些地方" "你需要使用 ``str(StrEnum.member)``。" -#: ../../library/enum.rst:515 +#: ../../library/enum.rst:520 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:520 +#: ../../library/enum.rst:525 msgid "" ":meth:`~object.__str__` is :meth:`!str.__str__` to better support the " "*replacement of existing constants* use-case. :meth:`~object.__format__` is " @@ -989,7 +1002,7 @@ msgstr "" "境,:meth:`~object.__str__` 現在會是 :meth:`!str.__str__`。為了同樣的理由,:" "meth:`~object.__format__` 也會是 :meth:`!str.__format__`。" -#: ../../library/enum.rst:528 +#: ../../library/enum.rst:533 msgid "" "``Flag`` is the same as :class:`Enum`, but its members support the bitwise " "operators ``&`` (*AND*), ``|`` (*OR*), ``^`` (*XOR*), and ``~`` (*INVERT*); " @@ -999,11 +1012,11 @@ msgstr "" "(*OR*)、``^`` (*XOR*) 和 ``~`` (*INVERT*);這些操作的結果是列舉的成員(的別" "名)。" -#: ../../library/enum.rst:534 +#: ../../library/enum.rst:539 msgid "Returns *True* if value is in self::" msgstr "如果 value 在 self 裡則回傳 *True*: ::" -#: ../../library/enum.rst:536 +#: ../../library/enum.rst:541 msgid "" ">>> from enum import Flag, auto\n" ">>> class Color(Flag):\n" @@ -1039,11 +1052,11 @@ msgstr "" ">>> white in purple\n" "False" -#: ../../library/enum.rst:555 +#: ../../library/enum.rst:560 msgid "Returns all contained non-alias members::" msgstr "回傳所有包含的非別名成員: ::" -#: ../../library/enum.rst:557 +#: ../../library/enum.rst:562 msgid "" ">>> list(Color.RED)\n" "[]\n" @@ -1055,11 +1068,11 @@ msgstr "" ">>> list(purple)\n" "[, ]" -#: ../../library/enum.rst:566 +#: ../../library/enum.rst:571 msgid "Returns number of members in flag::" msgstr "回傳旗標裡的成員數量: ::" -#: ../../library/enum.rst:568 +#: ../../library/enum.rst:573 msgid "" ">>> len(Color.GREEN)\n" "1\n" @@ -1071,11 +1084,11 @@ msgstr "" ">>> len(white)\n" "3" -#: ../../library/enum.rst:577 +#: ../../library/enum.rst:582 msgid "Returns *True* if any members in flag, *False* otherwise::" msgstr "如果成員在旗標裡則回傳 *True*,否則回傳 *False*: ::" -#: ../../library/enum.rst:579 +#: ../../library/enum.rst:584 msgid "" ">>> bool(Color.GREEN)\n" "True\n" @@ -1093,11 +1106,11 @@ msgstr "" ">>> bool(black)\n" "False" -#: ../../library/enum.rst:589 +#: ../../library/enum.rst:594 msgid "Returns current flag binary or'ed with other::" msgstr "回傳和 other 做 OR 過後的二進位旗標: ::" -#: ../../library/enum.rst:591 +#: ../../library/enum.rst:596 msgid "" ">>> Color.RED | Color.GREEN\n" "" @@ -1105,11 +1118,11 @@ msgstr "" ">>> Color.RED | Color.GREEN\n" "" -#: ../../library/enum.rst:596 +#: ../../library/enum.rst:601 msgid "Returns current flag binary and'ed with other::" msgstr "回傳和 other 做 AND 過後的二進位旗標: ::" -#: ../../library/enum.rst:598 +#: ../../library/enum.rst:603 msgid "" ">>> purple & white\n" "\n" @@ -1121,11 +1134,11 @@ msgstr "" ">>> purple & Color.GREEN\n" "" -#: ../../library/enum.rst:605 +#: ../../library/enum.rst:610 msgid "Returns current flag binary xor'ed with other::" msgstr "回傳和 other 做 XOR 過後的二進位旗標: ::" -#: ../../library/enum.rst:607 +#: ../../library/enum.rst:612 msgid "" ">>> purple ^ white\n" "\n" @@ -1137,12 +1150,12 @@ msgstr "" ">>> purple ^ Color.GREEN\n" "" -#: ../../library/enum.rst:614 +#: ../../library/enum.rst:619 #, fuzzy msgid "Returns all the flags in *type(self)* that are not in *self*::" msgstr "回傳所有在 *type(self)* 但不在 self 裡的旗標: ::" -#: ../../library/enum.rst:616 +#: ../../library/enum.rst:621 msgid "" ">>> ~white\n" "\n" @@ -1158,7 +1171,7 @@ msgstr "" ">>> ~Color.RED\n" "" -#: ../../library/enum.rst:625 +#: ../../library/enum.rst:630 msgid "" "Function used to format any remaining unnamed numeric values. Default is " "the value's repr; common choices are :func:`hex` and :func:`oct`." @@ -1166,17 +1179,17 @@ msgstr "" "用來格式化任何剩下未命名數值的函式。預設是值的 repr,常見選擇是 :func:`hex` " "和 :func:`oct`。" -#: ../../library/enum.rst:630 +#: ../../library/enum.rst:635 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:633 +#: ../../library/enum.rst:638 msgid "The *repr()* of zero-valued flags has changed. It is now::" msgstr "值為 0 的旗標的 *repr()* 已改變。現在是: ::" -#: ../../library/enum.rst:641 +#: ../../library/enum.rst:646 #, fuzzy msgid "" "``IntFlag`` is the same as :class:`Flag`, but its members are also integers " @@ -1185,13 +1198,13 @@ msgstr "" "*IntFlag* 和 *Flag* 一樣,但其成員同時也是整數而可以被用在任何使用整數的地" "方。" -#: ../../library/enum.rst:655 +#: ../../library/enum.rst:660 msgid "" "If any integer operation is performed with an *IntFlag* member, the result " "is not an *IntFlag*::" msgstr "如果 *IntFlag* 成員經過任何整數運算,其結果不是 *IntFlag*: ::" -#: ../../library/enum.rst:658 +#: ../../library/enum.rst:663 msgid "" ">>> Color.RED + 2\n" "3" @@ -1199,35 +1212,35 @@ msgstr "" ">>> Color.RED + 2\n" "3" -#: ../../library/enum.rst:661 +#: ../../library/enum.rst:666 #, fuzzy msgid "If a :class:`Flag` operation is performed with an *IntFlag* member and:" msgstr "如果 *IntFlag* 成員經過 *Flag* 操作且:" -#: ../../library/enum.rst:663 +#: ../../library/enum.rst:668 msgid "the result is a valid *IntFlag*: an *IntFlag* is returned" msgstr "結果是合法的 *IntFlag*:回傳 *IntFlag*" -#: ../../library/enum.rst:664 +#: ../../library/enum.rst:669 #, fuzzy msgid "" "the result is not a valid *IntFlag*: the result depends on the :class:" "`FlagBoundary` setting" msgstr "結果不是合法的 *IntFlag*:結果會根據 *FlagBoundary* 的設定" -#: ../../library/enum.rst:666 +#: ../../library/enum.rst:671 #, fuzzy msgid "The :func:`repr` of unnamed zero-valued flags has changed. It is now:" msgstr "未命名且值為 0 的旗標的 *repr()* 已改變。現在是: ::" -#: ../../library/enum.rst:673 +#: ../../library/enum.rst:678 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:678 +#: ../../library/enum.rst:683 msgid "" ":meth:`~object.__str__` is now :meth:`!int.__str__` to better support the " "*replacement of existing constants* use-case. :meth:`~object.__format__` " @@ -1237,7 +1250,7 @@ msgstr "" "境,:meth:`~object.__str__` 現在會是 :meth:`!int.__str__`。為了同樣的理由,:" "meth:`~object.__format__` 已經是 :meth:`!int.__format__`。" -#: ../../library/enum.rst:682 +#: ../../library/enum.rst:687 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 " @@ -1246,7 +1259,7 @@ msgstr "" ":class:`!IntFlag` 的反轉 (inversion) 現在會回傳正值,該值是不在給定旗標的所有" "旗標聯集,而不是一個負值。這符合現有 :class:`Flag` 的行為。" -#: ../../library/enum.rst:688 +#: ../../library/enum.rst:693 msgid "" ":class:`!ReprEnum` uses the :meth:`repr() ` of :class:`Enum`, " "but the :class:`str() ` of the mixed-in data type:" @@ -1254,15 +1267,15 @@ msgstr "" ":class:`!ReprEnum` 使用 :class:`Enum` 的 :meth:`repr() `,但使" "用混合資料類型的 :class:`str() `:" -#: ../../library/enum.rst:691 +#: ../../library/enum.rst:696 msgid ":meth:`!int.__str__` for :class:`IntEnum` and :class:`IntFlag`" msgstr "對 :class:`IntEnum` 和 :class:`IntFlag` 是 :meth:`!int.__str__`" -#: ../../library/enum.rst:692 +#: ../../library/enum.rst:697 msgid ":meth:`!str.__str__` for :class:`StrEnum`" msgstr "對 :class:`StrEnum` 是 :meth:`!str.__str__`" -#: ../../library/enum.rst:694 +#: ../../library/enum.rst:699 msgid "" "Inherit from :class:`!ReprEnum` to keep the :class:`str() ` / :func:" "`format` of the mixed-in data type instead of using the :class:`Enum`-" @@ -1271,7 +1284,7 @@ msgstr "" "繼承 :class:`!ReprEnum` 來保留混合資料類型的 :class:`str() ` / :func:" "`format`,而不是使用 :class:`Enum` 預設的 :meth:`str() `。" -#: ../../library/enum.rst:703 +#: ../../library/enum.rst:708 msgid "" "*EnumCheck* contains the options used by the :func:`verify` decorator to " "ensure various constraints; failed constraints result in a :exc:`ValueError`." @@ -1279,11 +1292,11 @@ msgstr "" "*EnumCheck* 包含 :func:`verify` 裝飾器使用的選項,以確保多樣的限制,不符合限" "制會產生 :exc:`ValueError`。" -#: ../../library/enum.rst:708 +#: ../../library/enum.rst:713 msgid "Ensure that each value has only one name::" msgstr "確保每個值只有一個名稱: ::" -#: ../../library/enum.rst:710 +#: ../../library/enum.rst:715 msgid "" ">>> from enum import Enum, verify, UNIQUE\n" ">>> @verify(UNIQUE)\n" @@ -1307,13 +1320,13 @@ msgstr "" "...\n" "ValueError: aliases found in : CRIMSON -> RED" -#: ../../library/enum.rst:724 +#: ../../library/enum.rst:729 msgid "" "Ensure that there are no missing values between the lowest-valued member and " "the highest-valued member::" msgstr "確保在最小值成員跟最大值成員間沒有缺少值: ::" -#: ../../library/enum.rst:727 +#: ../../library/enum.rst:732 msgid "" ">>> from enum import Enum, verify, CONTINUOUS\n" ">>> @verify(CONTINUOUS)\n" @@ -1335,7 +1348,7 @@ msgstr "" "...\n" "ValueError: invalid enum 'Color': missing values 3, 4" -#: ../../library/enum.rst:739 +#: ../../library/enum.rst:744 msgid "" "Ensure that any flag groups/masks contain only named flags -- useful when " "values are specified instead of being generated by :func:`auto`::" @@ -1343,7 +1356,7 @@ msgstr "" "確保任何旗標群組 / 遮罩只包含命名旗標 -- 當值是用指定而不是透過 :func:`auto` " "產生時是很實用的: ::" -#: ../../library/enum.rst:742 +#: ../../library/enum.rst:747 msgid "" ">>> from enum import Flag, verify, NAMED_FLAGS\n" ">>> @verify(NAMED_FLAGS)\n" @@ -1371,25 +1384,25 @@ 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:756 +#: ../../library/enum.rst:761 msgid "" "CONTINUOUS and NAMED_FLAGS are designed to work with integer-valued members." msgstr "CONTINUOUS 和 NAMED_FLAGS 是設計用來運作在整數值的成員上。" -#: ../../library/enum.rst:762 +#: ../../library/enum.rst:767 #, fuzzy msgid "" "``FlagBoundary`` controls how out-of-range values are handled in :class:" "`Flag` and its subclasses." msgstr "*FlagBoundary* 控制在 *Flag* 及其子類別中如何處理範圍外的值。" -#: ../../library/enum.rst:767 +#: ../../library/enum.rst:772 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:770 +#: ../../library/enum.rst:775 msgid "" ">>> from enum import Flag, STRICT, auto\n" ">>> class StrictFlag(Flag, boundary=STRICT):\n" @@ -1417,14 +1430,14 @@ msgstr "" " given 0b0 10100\n" " allowed 0b0 00111" -#: ../../library/enum.rst:785 +#: ../../library/enum.rst:790 #, fuzzy msgid "" "Out-of-range values have invalid values removed, leaving a valid :class:" "`Flag` value::" msgstr "範圍外的值會移除非法值,留下合法的 *Flag* 值: ::" -#: ../../library/enum.rst:788 +#: ../../library/enum.rst:793 msgid "" ">>> from enum import Flag, CONFORM, auto\n" ">>> class ConformFlag(Flag, boundary=CONFORM):\n" @@ -1444,14 +1457,14 @@ msgstr "" ">>> ConformFlag(2**2 + 2**4)\n" "" -#: ../../library/enum.rst:799 +#: ../../library/enum.rst:804 #, fuzzy msgid "" "Out-of-range values lose their :class:`Flag` membership and revert to :class:" "`int`." msgstr "範圍外的值會失去它們的 *Flag* 成員資格且恢復成 :class:`int`。" -#: ../../library/enum.rst:812 +#: ../../library/enum.rst:817 #, fuzzy msgid "" "Out-of-range values are kept, and the :class:`Flag` membership is kept. This " @@ -1460,7 +1473,7 @@ msgstr "" "範圍外的值會被保留,*Flag* 成員資格也會被保留。這是 :class:`IntFlag` 的預設行" "為: ::" -#: ../../library/enum.rst:815 +#: ../../library/enum.rst:820 msgid "" ">>> from enum import Flag, KEEP, auto\n" ">>> class KeepFlag(Flag, boundary=KEEP):\n" @@ -1480,11 +1493,34 @@ msgstr "" ">>> KeepFlag(2**2 + 2**4)\n" "" -#: ../../library/enum.rst:829 +#: ../../library/enum.rst:833 +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 " +"subclasses of :class:`EnumType` with advanced behavior like having multiple " +"values per member. It should be called with the name of the enum class being " +"created, otherwise private names and internal classes will not be handled " +"correctly." +msgstr "" + +#: ../../library/enum.rst:840 +msgid "" +"Note that only the :class:`~collections.abc.MutableMapping` interface (:meth:" +"`~object.__setitem__` and :meth:`~dict.update`) is overridden. It may be " +"possible to bypass the checks using other :class:`!dict` operations like :" +"meth:`|= `." +msgstr "" + +#: ../../library/enum.rst:847 +#, fuzzy +msgid "A list of member names." +msgstr "一個之前值的串列。" + +#: ../../library/enum.rst:854 msgid "Supported ``__dunder__`` names" msgstr "支援 ``__dunder__`` 名稱" -#: ../../library/enum.rst:831 +#: ../../library/enum.rst:856 msgid "" ":attr:`~EnumType.__members__` is a read-only ordered mapping of " "``member_name``:``member`` items. It is only available on the class." @@ -1492,7 +1528,7 @@ msgstr "" ":attr:`~EnumType.__members__` 是一個唯讀有序的\\ ``成員名稱``:``成員``\\ 項" "目的對映。只有在類別上可用。" -#: ../../library/enum.rst:834 +#: ../../library/enum.rst:859 #, fuzzy msgid "" ":meth:`~Enum.__new__`, if specified, must create and return the enum " @@ -1503,38 +1539,38 @@ msgstr "" "的 :attr:`!_value_` 也是一個很好的主意。一旦所有成員都建立之後就不會再被用" "到。" -#: ../../library/enum.rst:840 +#: ../../library/enum.rst:865 msgid "Supported ``_sunder_`` names" msgstr "支援 ``_sunder_`` 名稱" -#: ../../library/enum.rst:842 +#: ../../library/enum.rst:867 msgid "" ":meth:`~EnumType._add_alias_` -- adds a new name as an alias to an existing " "member." msgstr "" -#: ../../library/enum.rst:844 +#: ../../library/enum.rst:869 msgid "" ":meth:`~EnumType._add_value_alias_` -- adds a new value as an alias to an " "existing member." msgstr "" -#: ../../library/enum.rst:846 +#: ../../library/enum.rst:871 msgid ":attr:`~Enum._name_` -- name of the member" msgstr ":attr:`~Enum._name_` -- 成員名稱" -#: ../../library/enum.rst:847 +#: ../../library/enum.rst:872 msgid ":attr:`~Enum._value_` -- value of the member; can be set in ``__new__``" msgstr ":attr:`~Enum._value_` -- 成員的值;可以在 ``__new__`` 設定" -#: ../../library/enum.rst:848 +#: ../../library/enum.rst:873 msgid "" ":meth:`~Enum._missing_` -- a lookup function used when a value is not found; " "may be overridden" msgstr "" ":meth:`~Enum._missing_` -- 當值沒有被找到時會使用的查詢函式;可以被覆寫" -#: ../../library/enum.rst:850 +#: ../../library/enum.rst:875 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 " @@ -1543,7 +1579,7 @@ msgstr "" ":attr:`~Enum._ignore_` -- 一個名稱的串列,可以是 :class:`list` 或 :class:" "`str`,它不會被轉換成成員,且在最後的類別上會被移除" -#: ../../library/enum.rst:853 +#: ../../library/enum.rst:878 msgid "" ":attr:`~Enum._order_` -- no longer used, kept for backward compatibility " "(class attribute, removed during class creation)" @@ -1551,14 +1587,14 @@ msgstr "" ":attr:`~Enum._order_` -- 不再被使用,僅為了向後相容而保留(類別屬性,在類別建" "立時移除)" -#: ../../library/enum.rst:855 +#: ../../library/enum.rst:880 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:860 +#: ../../library/enum.rst:885 #, fuzzy msgid "" "For standard :class:`Enum` classes the next value chosen is the highest " @@ -1566,7 +1602,7 @@ msgid "" msgstr "" "對標準的 :class:`Enum` 類別來說,下一個被選擇的值是最後一個看見的值加一。" -#: ../../library/enum.rst:863 +#: ../../library/enum.rst:888 #, fuzzy msgid "" "For :class:`Flag` classes the next value chosen will be the next highest " @@ -1575,34 +1611,34 @@ msgstr "" "對 :class:`Flag` 類別來說,下一個被選擇的值是下一個最大的 2 的次方,不管最後" "一個看見的值是什麼。" -#: ../../library/enum.rst:866 +#: ../../library/enum.rst:891 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:" msgstr "" -#: ../../library/enum.rst:869 +#: ../../library/enum.rst:894 msgid "" "``_repr_*`` (e.g. ``_repr_html_``), as used in `IPython's rich display`_" msgstr "" -#: ../../library/enum.rst:871 +#: ../../library/enum.rst:896 msgid "``_missing_``, ``_order_``, ``_generate_next_value_``" msgstr "``_missing_``、``_order_``、``_generate_next_value_``" -#: ../../library/enum.rst:872 +#: ../../library/enum.rst:897 msgid "``_ignore_``" msgstr "``_ignore_``" -#: ../../library/enum.rst:873 +#: ../../library/enum.rst:898 msgid "``_add_alias_``, ``_add_value_alias_``, ``_repr_*``" msgstr "" -#: ../../library/enum.rst:879 +#: ../../library/enum.rst:904 msgid "Utilities and Decorators" msgstr "通用項目與裝飾器" -#: ../../library/enum.rst:883 +#: ../../library/enum.rst:908 #, fuzzy msgid "" "*auto* can be used in place of a value. If used, the *Enum* machinery will " @@ -1619,16 +1655,16 @@ msgstr "" "2 的次方的數字;對 *StrEnum* 來說,是成員名稱的小寫版本。如果混用 *auto()* 和" "手動指定值的話要特別注意。" -#: ../../library/enum.rst:891 +#: ../../library/enum.rst:916 msgid "" "*auto* instances are only resolved when at the top level of an assignment:" msgstr "*auto* 實例只有在最上層的賦值時才會被解析:" -#: ../../library/enum.rst:893 +#: ../../library/enum.rst:918 msgid "``FIRST = auto()`` will work (auto() is replaced with ``1``);" msgstr "``FIRST = auto()`` 可以運作(auto() 會被取代成 ``1``)" -#: ../../library/enum.rst:894 +#: ../../library/enum.rst:919 msgid "" "``SECOND = auto(), -2`` will work (auto is replaced with ``2``, so ``2, -2`` " "is used to create the ``SECOND`` enum member;" @@ -1636,7 +1672,7 @@ msgstr "" "``SECOND = auto(), -2`` 可以運作(auto 會被取代成 ``2``, 因此 ``2, -2`` 會被" "用來建立列舉成員 ``SECOND``;" -#: ../../library/enum.rst:896 +#: ../../library/enum.rst:921 msgid "" "``THREE = [auto(), -3]`` will *not* work (``, -3`` is used to " "create the ``THREE`` enum member)" @@ -1644,19 +1680,19 @@ msgstr "" "``THREE = [auto(), -3]`` *無法*\\ 運作(\\ ``, -3`` 會被用來建立列" "舉成員 ``THREE``)" -#: ../../library/enum.rst:901 +#: ../../library/enum.rst:926 msgid "" "In prior versions, ``auto()`` had to be the only thing on the assignment " "line to work properly." msgstr "在之前的版本中,``auto()`` 必須是賦值行裡的唯一內容才能運作正確。" -#: ../../library/enum.rst:904 +#: ../../library/enum.rst:929 msgid "" "``_generate_next_value_`` can be overridden to customize the values used by " "*auto*." msgstr "可以覆寫 ``_generate_next_value_`` 來客製 *auto* 使用的值。" -#: ../../library/enum.rst:907 +#: ../../library/enum.rst:932 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 " @@ -1665,7 +1701,7 @@ msgstr "" "在 3.13 預設 ``_generate_next_value_`` 總是回傳最大的成員值加一,如果任何成員" "是不相容的類型就會失敗。" -#: ../../library/enum.rst:913 +#: ../../library/enum.rst:938 msgid "" "A decorator similar to the built-in *property*, but specifically for " "enumerations. It allows member attributes to have the same names as members " @@ -1674,7 +1710,7 @@ msgstr "" "和內建的 *property* 相似的裝飾器,但只專門針對列舉。它允許成員屬性和成員本身" "有相同名稱。" -#: ../../library/enum.rst:917 +#: ../../library/enum.rst:942 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, " @@ -1684,7 +1720,7 @@ msgstr "" "*屬性*\\ 和成員必須定義在分開的類別裡;例如 *value* 和 *name* 屬性定義在 " "*Enum* 類別而 *Enum* 子類別可以定義成員名稱為 ``value`` 和 ``name``。" -#: ../../library/enum.rst:926 +#: ../../library/enum.rst:951 msgid "" "A :keyword:`class` decorator specifically for enumerations. It searches an " "enumeration's :attr:`~EnumType.__members__`, gathering any aliases it finds; " @@ -1694,7 +1730,7 @@ msgstr "" "__members__`,蒐集任何它找到的別名;如果有找到任何別名則引發 :exc:" "`ValueError` 並附上細節: ::" -#: ../../library/enum.rst:930 +#: ../../library/enum.rst:955 msgid "" ">>> from enum import Enum, unique\n" ">>> @unique\n" @@ -1720,7 +1756,7 @@ msgstr "" "...\n" "ValueError: duplicate values found in : FOUR -> THREE" -#: ../../library/enum.rst:944 +#: ../../library/enum.rst:969 msgid "" "A :keyword:`class` decorator specifically for enumerations. Members from :" "class:`EnumCheck` are used to specify which constraints should be checked on " @@ -1729,15 +1765,15 @@ msgstr "" "專門針對列舉的 :keyword:`class` 裝飾器。使用 :class:`EnumCheck` 裡的成員來指" "定在裝飾的列舉上應該檢查什麼限制。" -#: ../../library/enum.rst:952 +#: ../../library/enum.rst:977 msgid "A decorator for use in enums: its target will become a member." msgstr "列舉所使用的裝飾器:其目標會變成成員。" -#: ../../library/enum.rst:958 +#: ../../library/enum.rst:983 msgid "A decorator for use in enums: its target will not become a member." msgstr "列舉所使用的裝飾器:其目標不會變成成員。" -#: ../../library/enum.rst:964 +#: ../../library/enum.rst:989 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 " @@ -1748,19 +1784,19 @@ msgstr "" "組而不是其類別。應該只有當列舉成員被匯出到模組的全域命名空間才使用(範例請參" "考 :class:`re.RegexFlag`)。" -#: ../../library/enum.rst:974 +#: ../../library/enum.rst:998 msgid "Return a list of all power-of-two integers contained in a flag *value*." msgstr "回傳在旗標\\ *值*\\ 中包含的所有 2 的次方的整數串列。" -#: ../../library/enum.rst:981 +#: ../../library/enum.rst:1006 msgid "Notes" msgstr "備註" -#: ../../library/enum.rst:983 +#: ../../library/enum.rst:1008 msgid ":class:`IntEnum`, :class:`StrEnum`, and :class:`IntFlag`" msgstr ":class:`IntEnum`、:class:`StrEnum` 及 :class:`IntFlag`" -#: ../../library/enum.rst:985 +#: ../../library/enum.rst:1010 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:" @@ -1768,17 +1804,17 @@ msgstr "" "這三種列舉類型是設計來直接取代現有以整數及字串為基底的值;因此它們有額外的限" "制:" -#: ../../library/enum.rst:988 +#: ../../library/enum.rst:1013 msgid "``__str__`` uses the value and not the name of the enum member" msgstr "``__str__`` 使用值而不是列舉成員的名稱" -#: ../../library/enum.rst:990 +#: ../../library/enum.rst:1015 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:993 +#: ../../library/enum.rst:1018 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::" @@ -1786,7 +1822,7 @@ msgstr "" "如果你不需要或不想要這些限制,你可以透過混合 ``int`` 或 ``str`` 類型來建立自" "己的基礎類別: ::" -#: ../../library/enum.rst:996 +#: ../../library/enum.rst:1021 msgid "" ">>> from enum import Enum\n" ">>> class MyIntEnum(int, Enum):\n" @@ -1796,11 +1832,11 @@ msgstr "" ">>> class MyIntEnum(int, Enum):\n" "... pass" -#: ../../library/enum.rst:1000 +#: ../../library/enum.rst:1025 msgid "or you can reassign the appropriate :meth:`str`, etc., in your enum::" msgstr "或者你也可以在你的列舉重新給定合適的 :meth:`str`: ::" -#: ../../library/enum.rst:1002 +#: ../../library/enum.rst:1027 msgid "" ">>> from enum import Enum, IntEnum\n" ">>> class MyIntEnum(IntEnum):\n" diff --git a/library/errno.po b/library/errno.po index 8a2c10f4e4..46eecaa81d 100644 --- a/library/errno.po +++ b/library/errno.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-05-09 00:03+0000\n" +"POT-Creation-Date: 2025-02-07 08:41+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-" @@ -581,24 +581,131 @@ msgstr "" msgid "Interface output queue is full" msgstr "" -#: ../../library/errno.rst:670 +#: ../../library/errno.rst:671 +msgid "No medium found" +msgstr "" + +#: ../../library/errno.rst:676 +msgid "Wrong medium type" +msgstr "" + +#: ../../library/errno.rst:681 +msgid "Required key not available" +msgstr "" + +#: ../../library/errno.rst:686 +msgid "Key has expired" +msgstr "" + +#: ../../library/errno.rst:691 +msgid "Key has been revoked" +msgstr "" + +#: ../../library/errno.rst:696 +msgid "Key was rejected by service" +msgstr "" + +#: ../../library/errno.rst:701 +msgid "Operation not possible due to RF-kill" +msgstr "" + +#: ../../library/errno.rst:706 +msgid "Locked lock was unmapped" +msgstr "" + +#: ../../library/errno.rst:711 +msgid "Facility is not active" +msgstr "" + +#: ../../library/errno.rst:716 +msgid "Authentication error" +msgstr "" + +#: ../../library/errno.rst:723 +msgid "Bad CPU type in executable" +msgstr "" + +#: ../../library/errno.rst:730 +msgid "Bad executable (or shared library)" +msgstr "" + +#: ../../library/errno.rst:737 +msgid "Malformed Mach-o file" +msgstr "" + +#: ../../library/errno.rst:744 +msgid "Device error" +msgstr "" + +#: ../../library/errno.rst:751 +msgid "Inappropriate file type or format" +msgstr "" + +#: ../../library/errno.rst:758 +msgid "Need authenticator" +msgstr "" + +#: ../../library/errno.rst:765 +msgid "Attribute not found" +msgstr "" + +#: ../../library/errno.rst:772 +msgid "Policy not found" +msgstr "" + +#: ../../library/errno.rst:779 +msgid "Too many processes" +msgstr "" + +#: ../../library/errno.rst:786 +msgid "Bad procedure for program" +msgstr "" + +#: ../../library/errno.rst:793 +msgid "Program version wrong" +msgstr "" + +#: ../../library/errno.rst:800 +msgid "RPC prog. not avail" +msgstr "" + +#: ../../library/errno.rst:807 +msgid "Device power is off" +msgstr "" + +#: ../../library/errno.rst:814 +msgid "RPC struct is bad" +msgstr "" + +#: ../../library/errno.rst:821 +msgid "RPC version wrong" +msgstr "" + +#: ../../library/errno.rst:828 +msgid "Shared library version mismatch" +msgstr "" + +#: ../../library/errno.rst:835 msgid "" "Capabilities insufficient. This error is mapped to the exception :exc:" "`PermissionError`." msgstr "" -#: ../../library/errno.rst:673 -msgid ":ref:`Availability `: WASI, FreeBSD" -msgstr ":ref:`適用 `:WASI, FreeBSD" +#: ../../library/errno.rst:838 +msgid "Availability" +msgstr "" -#: ../../library/errno.rst:680 +#: ../../library/errno.rst:845 msgid "Operation canceled" msgstr "" -#: ../../library/errno.rst:687 +#: ../../library/errno.rst:852 msgid "Owner died" msgstr "" -#: ../../library/errno.rst:694 +#: ../../library/errno.rst:859 msgid "State not recoverable" msgstr "" + +#~ msgid ":ref:`Availability `: WASI, FreeBSD" +#~ msgstr ":ref:`適用 `:WASI, FreeBSD" diff --git a/library/exceptions.po b/library/exceptions.po index 836c4bee5c..3b806cf449 100644 --- a/library/exceptions.po +++ b/library/exceptions.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-03-03 18:39+0000\n" "PO-Revision-Date: 2024-09-17 09:18+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -501,24 +501,25 @@ msgstr "" "子或方法保持未定義,或者如果是子類別的話將其設成 :data:`None`。" #: ../../library/exceptions.rst:338 +#, fuzzy msgid "" -"``NotImplementedError`` and :data:`NotImplemented` are not interchangeable, " -"even though they have similar names and purposes. See :data:`!" -"NotImplemented` for details on when to use it." +":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." msgstr "" "``NotImplementedError`` 和 :data:`NotImplemented` 雖然有相似的名稱和目的但並" "不是可互換的。參考 :data:`!NotImplemented` 裡關於何時使用的細節。" -#: ../../library/exceptions.rst:347 +#: ../../library/exceptions.rst:349 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 失敗會引" "發此例外(而非不合法的引數或其他次要的錯誤)。" -#: ../../library/exceptions.rst:351 +#: ../../library/exceptions.rst:353 msgid "" "The second form of the constructor sets the corresponding attributes, " "described below. The attributes default to :const:`None` if not specified. " @@ -530,7 +531,7 @@ msgstr "" "const:`None`。為了向後相容,如果傳入三個引數,:attr:`~BaseException.args` 屬" "性只會是包含建構函式前兩個引數的雙元素元組。" -#: ../../library/exceptions.rst:357 +#: ../../library/exceptions.rst:359 msgid "" "The constructor often actually returns a subclass of :exc:`OSError`, as " "described in `OS exceptions`_ below. The particular subclass depends on the " @@ -543,11 +544,11 @@ msgstr "" "個行為只發生在直接建構 :exc:`OSError` 或透過別名,且產生子類別的時候不會被繼" "承。" -#: ../../library/exceptions.rst:365 +#: ../../library/exceptions.rst:367 msgid "A numeric error code from the C variable :c:data:`errno`." msgstr "從 C 變數 :c:data:`errno` 而來的數值錯誤代碼。" -#: ../../library/exceptions.rst:369 +#: ../../library/exceptions.rst:371 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 " @@ -556,7 +557,7 @@ msgstr "" "在 Windows 下,這會提供你原生的 Windows 錯誤代碼。而 :attr:`.errno` 屬性是一" "個該原生錯誤代碼對於 POSIX 來說的近似翻譯。" -#: ../../library/exceptions.rst:373 +#: ../../library/exceptions.rst:375 msgid "" "Under Windows, if the *winerror* constructor argument is an integer, the :" "attr:`.errno` attribute is determined from the Windows error code, and the " @@ -567,7 +568,7 @@ msgstr "" "據該 Windows 錯誤代碼來決定,且 *errno* 引數會被忽略。在其他平台上," "*winerror* 引數會被忽略,而 :attr:`winerror` 屬性會不存在。" -#: ../../library/exceptions.rst:381 +#: ../../library/exceptions.rst:383 msgid "" "The corresponding error message, as provided by the operating system. It is " "formatted by the C functions :c:func:`perror` under POSIX, and :c:func:" @@ -576,7 +577,7 @@ msgstr "" "作業系統提供的對應錯誤訊息。在 POSIX 下會使用 C 函式 :c:func:`perror` 做格式" "化,而在 Windows 下會使用 :c:func:`FormatMessage`。" -#: ../../library/exceptions.rst:389 +#: ../../library/exceptions.rst:391 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. " @@ -588,7 +589,7 @@ msgstr "" "`filename` 是傳入函式的檔案名稱。對於包含兩個檔案系統路徑的函式(像是 :func:" "`os.rename`),:attr:`filename2` 對應到傳入函式的第二個檔案名稱。" -#: ../../library/exceptions.rst:396 +#: ../../library/exceptions.rst:398 msgid "" ":exc:`EnvironmentError`, :exc:`IOError`, :exc:`WindowsError`, :exc:`socket." "error`, :exc:`select.error` and :exc:`mmap.error` have been merged into :exc:" @@ -598,7 +599,7 @@ msgstr "" "error`、:exc:`select.error` 及 :exc:`mmap.error` 已合併進 :exc:`OSError`,而" "建構函式可能會回傳子類別。" -#: ../../library/exceptions.rst:402 +#: ../../library/exceptions.rst:404 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:" @@ -609,7 +610,7 @@ msgstr "" "和錯誤處理函式 `\\ 編碼或解碼過的名" "稱。並且新增 *filename2* 建構函式引數與屬性。" -#: ../../library/exceptions.rst:411 +#: ../../library/exceptions.rst:413 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:" @@ -623,7 +624,7 @@ msgstr "" "有時候會因為整數在要求範圍之外而引發。因為在 C 裡面缺乏浮點數例外處理的標準" "化,大部分的浮點數運算都沒有被檢查。" -#: ../../library/exceptions.rst:421 +#: ../../library/exceptions.rst:423 #, fuzzy msgid "" "This exception is derived from :exc:`RuntimeError`. It is raised when an " @@ -633,29 +634,29 @@ msgstr "" "此例外衍生自 :exc:`RuntimeError`。當直譯器偵測到超過最大的遞迴深度(參考 :" "func:`sys.getrecursionlimit`)時會引發此例外。" -#: ../../library/exceptions.rst:425 +#: ../../library/exceptions.rst:427 msgid "" "Examples of operations which can be blocked with a :exc:" "`PythonFinalizationError` during the Python finalization:" msgstr "" -#: ../../library/exceptions.rst:428 +#: ../../library/exceptions.rst:430 msgid "Creating a new Python thread." msgstr "" -#: ../../library/exceptions.rst:429 +#: ../../library/exceptions.rst:431 msgid ":func:`os.fork`." msgstr "" -#: ../../library/exceptions.rst:431 +#: ../../library/exceptions.rst:433 msgid "See also the :func:`sys.is_finalizing` function." msgstr "" -#: ../../library/exceptions.rst:433 ../../library/exceptions.rst:443 +#: ../../library/exceptions.rst:435 ../../library/exceptions.rst:445 msgid "Previously, a plain :exc:`RuntimeError` was raised." msgstr "在之前,會引發一般的 :exc:`RuntimeError`。" -#: ../../library/exceptions.rst:439 +#: ../../library/exceptions.rst:441 msgid "" "This exception is derived from :exc:`RuntimeError`. It is raised when the " "interpreter detects that the maximum recursion depth (see :func:`sys." @@ -664,7 +665,7 @@ msgstr "" "此例外衍生自 :exc:`RuntimeError`。當直譯器偵測到超過最大的遞迴深度(參考 :" "func:`sys.getrecursionlimit`)時會引發此例外。" -#: ../../library/exceptions.rst:449 +#: ../../library/exceptions.rst:451 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 " @@ -675,7 +676,7 @@ msgstr "" "用來存取已經被垃圾回收 (garbage collected) 的參照物屬性時會引發此例外。更多關" "於弱參照的資訊參考 :mod:`weakref` 模組。" -#: ../../library/exceptions.rst:457 +#: ../../library/exceptions.rst:459 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 " @@ -684,7 +685,7 @@ msgstr "" "當偵測到一個不屬於任何其他種類的錯誤時會引發此例外。關聯值是一個表示確切什麼" "地方出錯的字串。" -#: ../../library/exceptions.rst:464 +#: ../../library/exceptions.rst:466 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 " @@ -693,7 +694,7 @@ msgstr "" "會被內建函式 :func:`next` 及 :term:`iterator` 的 :meth:`~iterator.__next__` " "方法引發,用來表示疊代器沒有更多項目可以產生。" -#: ../../library/exceptions.rst:470 +#: ../../library/exceptions.rst:472 msgid "" "The exception object has a single attribute :attr:`!value`, which is given " "as an argument when constructing the exception, and defaults to :const:" @@ -702,7 +703,7 @@ msgstr "" "此例外物件有單一屬性 :attr:`!value`,當建構此例外時會以引數給定,預設為 :" "const:`None`。" -#: ../../library/exceptions.rst:474 +#: ../../library/exceptions.rst:476 msgid "" "When a :term:`generator` or :term:`coroutine` function returns, a new :exc:" "`StopIteration` instance is raised, and the value returned by the function " @@ -712,7 +713,7 @@ msgstr "" "`StopIteration` 實例會被引發,而該函式的回傳值會被用來當作此例外建構函式的 :" "attr:`value` 參數。" -#: ../../library/exceptions.rst:479 +#: ../../library/exceptions.rst:481 msgid "" "If a generator code directly or indirectly raises :exc:`StopIteration`, it " "is converted into a :exc:`RuntimeError` (retaining the :exc:`StopIteration` " @@ -721,13 +722,13 @@ msgstr "" "如果產生器程式直接或間接引發 :exc:`StopIteration`,則其會被轉換成 :exc:" "`RuntimeError`\\ (保留 :exc:`StopIteration` 作為新例外的成因)。" -#: ../../library/exceptions.rst:483 +#: ../../library/exceptions.rst:485 msgid "" "Added ``value`` attribute and the ability for generator functions to use it " "to return a value." msgstr "新增 ``value`` 屬性且產生器函式可以用它來回傳值。" -#: ../../library/exceptions.rst:487 +#: ../../library/exceptions.rst:489 msgid "" "Introduced the RuntimeError transformation via ``from __future__ import " "generator_stop``, see :pep:`479`." @@ -735,7 +736,7 @@ msgstr "" "透過 ``from __future__ import generator_stop`` 引入 RuntimeError 的轉換,參" "考 :pep:`479`。" -#: ../../library/exceptions.rst:491 +#: ../../library/exceptions.rst:493 msgid "" "Enable :pep:`479` for all code by default: a :exc:`StopIteration` error " "raised in a generator is transformed into a :exc:`RuntimeError`." @@ -743,7 +744,7 @@ msgstr "" "預設對所有程式啟用 :pep:`479`:在產生器引發的 :exc:`StopIteration` 錯誤會轉換" "成 :exc:`RuntimeError`。" -#: ../../library/exceptions.rst:497 +#: ../../library/exceptions.rst:499 msgid "" "Must be raised by :meth:`~object.__anext__` method of an :term:`asynchronous " "iterator` object to stop the iteration." @@ -751,7 +752,7 @@ msgstr "" "此例外必須被 :term:`asynchronous iterator` 物件的 :meth:`~object.__anext__` " "方法引發來停止疊代。" -#: ../../library/exceptions.rst:504 +#: ../../library/exceptions.rst:506 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:" @@ -762,7 +763,7 @@ msgstr "" "呼叫內建函式 :func:`compile`、:func:`exec` 或 :func:`eval` 的時候,或者在讀取" "初始腳本或標準輸入(也包含互動式)的時候。" -#: ../../library/exceptions.rst:510 +#: ../../library/exceptions.rst:512 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." @@ -770,18 +771,18 @@ msgstr "" "例外實例的 :func:`str` 只回傳錯誤訊息。Details 是個元組,其成員也能夠以分開的" "屬性取得。" -#: ../../library/exceptions.rst:515 +#: ../../library/exceptions.rst:517 msgid "The name of the file the syntax error occurred in." msgstr "發生語法錯誤所在的檔案名稱。" -#: ../../library/exceptions.rst:519 +#: ../../library/exceptions.rst:521 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:524 +#: ../../library/exceptions.rst:526 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." @@ -789,11 +790,11 @@ msgstr "" "發生錯誤所在該列的欄號 (column)。這是以 1 開始的索引:該列第一個字元的 " "``offset`` 是 1。" -#: ../../library/exceptions.rst:529 +#: ../../library/exceptions.rst:531 msgid "The source code text involved in the error." msgstr "涉及該錯誤的原始程式碼文字。" -#: ../../library/exceptions.rst:533 +#: ../../library/exceptions.rst:535 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." @@ -801,7 +802,7 @@ msgstr "" "發生錯誤所在檔案的結束列號。這是以 1 開始的索引:檔案第一列的 ``lineno`` 是 " "1。" -#: ../../library/exceptions.rst:538 +#: ../../library/exceptions.rst:540 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." @@ -809,7 +810,7 @@ msgstr "" "發生錯誤所在該結束列的欄號。這是以 1 開始的索引:該列第一個字元的 ``offset`` " "是 1。" -#: ../../library/exceptions.rst:541 +#: ../../library/exceptions.rst:543 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,18 +821,18 @@ msgstr "" "(offset) 是從替代表達式建構的文字的偏移量。例如編譯 f'Bad {a b} field' 會得到" "這個 args 屬性:('f-string: ...', ('', 1, 2, '(a b)\\n', 1, 5))。" -#: ../../library/exceptions.rst:546 +#: ../../library/exceptions.rst:548 msgid "Added the :attr:`end_lineno` and :attr:`end_offset` attributes." msgstr "新增 :attr:`end_lineno` 與 :attr:`end_offset` 屬性。" -#: ../../library/exceptions.rst:551 +#: ../../library/exceptions.rst:553 msgid "" "Base class for syntax errors related to incorrect indentation. This is a " "subclass of :exc:`SyntaxError`." msgstr "" "與不正確的縮排有關的語法錯誤的基礎類別。這是 :exc:`SyntaxError` 的子類別。" -#: ../../library/exceptions.rst:557 +#: ../../library/exceptions.rst:559 msgid "" "Raised when indentation contains an inconsistent use of tabs and spaces. " "This is a subclass of :exc:`IndentationError`." @@ -839,28 +840,34 @@ msgstr "" "當縮排包含製表符號 (tab) 和空白的不一致用法時會引發此例外。這是 :exc:" "`IndentationError` 的子類別。" -#: ../../library/exceptions.rst:563 +#: ../../library/exceptions.rst:565 +#, fuzzy 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)." +"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 "" "當直譯器找到一個內部錯誤,但該情況看起來沒有嚴重到要讓它放棄所有的希望時會引" "發此例外。關聯值是一個表示什麼地方出錯的字串(以低階的方式表達)。" -#: ../../library/exceptions.rst:567 +#: ../../library/exceptions.rst:571 +#, fuzzy msgid "" -"You should report this to the author or maintainer of your Python " -"interpreter. Be sure to report the version of the Python interpreter (``sys." -"version``; it is also printed at the start of an interactive Python " -"session), the exact error message (the exception's associated value) and if " -"possible the source of the program that triggered the error." +"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 " +"your Python interpreter. Be sure to report the version of the Python " +"interpreter (``sys.version``; it is also printed at the start of an " +"interactive Python session), the exact error message (the exception's " +"associated value) and if possible the source of the program that triggered " +"the error." msgstr "" "你應該向你的 Python 直譯器作者或維護者回報此錯誤。務必要回報該 Python 直譯器" "的版本(``sys.version``;這也會在互動式 Python 會話的開頭被印出)、確切的錯誤" "訊息(該例外的關聯值)及如果可能的話,觸發此錯誤的程式來源。" -#: ../../library/exceptions.rst:576 +#: ../../library/exceptions.rst:582 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 " @@ -881,7 +888,7 @@ msgstr "" "``None``,結束狀態會是 0;如果它是其他類型(例如字串),則物件的值會被印出而" "結束狀態是 1。" -#: ../../library/exceptions.rst:587 +#: ../../library/exceptions.rst:593 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 " @@ -895,13 +902,13 @@ msgstr "" "風險下執行腳本。如果在絕對有必要立即結束的情況(例如在子行程呼叫完 :func:`os." "fork` 之後 )可以使用 :func:`os._exit` 函式。" -#: ../../library/exceptions.rst:596 +#: ../../library/exceptions.rst:602 msgid "" "The exit status or error message that is passed to the constructor. " "(Defaults to ``None``.)" msgstr "傳入建構函式的結束狀態或錯誤訊息。(預設是 ``None``。 )" -#: ../../library/exceptions.rst:602 +#: ../../library/exceptions.rst:608 msgid "" "Raised when an operation or function is applied to an object of " "inappropriate type. The associated value is a string giving details about " @@ -910,7 +917,7 @@ msgstr "" "當一個操作或函式被用在不適合的類型的物件時會引發此例外。關聯值是一個字串,提" "供關於不相符類型的細節。" -#: ../../library/exceptions.rst:605 +#: ../../library/exceptions.rst:611 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 " @@ -921,7 +928,7 @@ msgstr "" "這樣做。如果一個物件有意要支援某個給定的操作但尚未提供實作,該引發的正確例外" "是 :exc:`NotImplementedError`。" -#: ../../library/exceptions.rst:610 +#: ../../library/exceptions.rst:616 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 " @@ -932,7 +939,7 @@ msgstr "" "導致 :exc:`TypeError`,但傳入帶有錯誤值的引數(例如超出預期範圍的數值)應該要" "導致 :exc:`ValueError`。" -#: ../../library/exceptions.rst:617 +#: ../../library/exceptions.rst:623 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:" @@ -941,7 +948,7 @@ msgstr "" "當在函式或方法裡引用某個區域變數,但該變數尚未被繫結到任何值的時候會引發此例" "外。這是 :exc:`NameError` 的子類別。" -#: ../../library/exceptions.rst:624 +#: ../../library/exceptions.rst:630 msgid "" "Raised when a Unicode-related encoding or decoding error occurs. It is a " "subclass of :exc:`ValueError`." @@ -949,7 +956,7 @@ msgstr "" "當 Unicode 相關的編碼或解碼錯誤發生時會引發此例外。這是 :exc:`ValueError` 的" "子類別。" -#: ../../library/exceptions.rst:627 +#: ../../library/exceptions.rst:633 msgid "" ":exc:`UnicodeError` has attributes that describe the encoding or decoding " "error. For example, ``err.object[err.start:err.end]`` gives the particular " @@ -958,27 +965,27 @@ msgstr "" ":exc:`UnicodeError` 有屬性描述編碼或解碼錯誤。例如 ``err.object[err.start:" "err.end]`` 會提供讓編解碼器失敗的具體無效輸入。" -#: ../../library/exceptions.rst:633 +#: ../../library/exceptions.rst:639 msgid "The name of the encoding that raised the error." msgstr "引發錯誤的編碼名稱。" -#: ../../library/exceptions.rst:637 +#: ../../library/exceptions.rst:643 msgid "A string describing the specific codec error." msgstr "描述特定編解碼器錯誤的字串。" -#: ../../library/exceptions.rst:641 +#: ../../library/exceptions.rst:647 msgid "The object the codec was attempting to encode or decode." msgstr "編解碼器嘗試編碼或解碼的物件。" -#: ../../library/exceptions.rst:645 +#: ../../library/exceptions.rst:651 msgid "The first index of invalid data in :attr:`object`." msgstr "在 :attr:`object` 中無效資料的開始索引。" -#: ../../library/exceptions.rst:649 +#: ../../library/exceptions.rst:655 msgid "The index after the last invalid data in :attr:`object`." msgstr "在 :attr:`object` 中最後的無效資料後的索引。" -#: ../../library/exceptions.rst:654 +#: ../../library/exceptions.rst:660 msgid "" "Raised when a Unicode-related error occurs during encoding. It is a " "subclass of :exc:`UnicodeError`." @@ -986,7 +993,7 @@ msgstr "" "在編碼當中發生 Unicode 相關錯誤時會引發此例外。這是 :exc:`UnicodeError` 的子" "類別。" -#: ../../library/exceptions.rst:660 +#: ../../library/exceptions.rst:666 msgid "" "Raised when a Unicode-related error occurs during decoding. It is a " "subclass of :exc:`UnicodeError`." @@ -994,7 +1001,7 @@ msgstr "" "在解碼當中發生 Unicode 相關錯誤時會引發此例外。這是 :exc:`UnicodeError` 的子" "類別。" -#: ../../library/exceptions.rst:666 +#: ../../library/exceptions.rst:672 msgid "" "Raised when a Unicode-related error occurs during translating. It is a " "subclass of :exc:`UnicodeError`." @@ -1002,7 +1009,7 @@ msgstr "" "在轉譯當中發生 Unicode 相關錯誤時會引發此例外。這是 :exc:`UnicodeError` 的子" "類別。" -#: ../../library/exceptions.rst:672 +#: ../../library/exceptions.rst:678 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 " @@ -1011,7 +1018,7 @@ msgstr "" "當一個操作或函式收到引數是正確類型但是不適合的值,且該情況無法被更精確的例外" "例如 :exc:`IndexError` 所描述時會引發此例外。" -#: ../../library/exceptions.rst:679 +#: ../../library/exceptions.rst:685 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 " @@ -1020,7 +1027,7 @@ msgstr "" "當除法或模數運算 (modulo operation) 的第二個引數是 0 的時候會引發此例外。關聯" "值是一個字串,表示運算元及運算的類型。" -#: ../../library/exceptions.rst:684 +#: ../../library/exceptions.rst:690 msgid "" "The following exceptions are kept for compatibility with previous versions; " "starting from Python 3.3, they are aliases of :exc:`OSError`." @@ -1028,21 +1035,21 @@ msgstr "" "以下例外是為了相容於之前版本而保留;從 Python 3.3 開始,它們是 :exc:" "`OSError` 的別名。" -#: ../../library/exceptions.rst:693 +#: ../../library/exceptions.rst:699 msgid "Only available on Windows." msgstr "僅限於在 Windows 中使用。" -#: ../../library/exceptions.rst:697 +#: ../../library/exceptions.rst:703 msgid "OS exceptions" msgstr "作業系統例外" -#: ../../library/exceptions.rst:699 +#: ../../library/exceptions.rst:705 msgid "" "The following exceptions are subclasses of :exc:`OSError`, they get raised " "depending on the system error code." msgstr "以下的例外是 :exc:`OSError` 的子類別,它們根據系統錯誤代碼來引發。" -#: ../../library/exceptions.rst:704 +#: ../../library/exceptions.rst:710 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." @@ -1053,14 +1060,14 @@ msgstr "" "到 :c:data:`errno` :py:const:`~errno.EAGAIN`、:py:const:`~errno.EALREADY`、:" "py:const:`~errno.EWOULDBLOCK` 及 :py:const:`~errno.EINPROGRESS`。" -#: ../../library/exceptions.rst:709 +#: ../../library/exceptions.rst:715 msgid "" "In addition to those of :exc:`OSError`, :exc:`BlockingIOError` can have one " "more attribute:" msgstr "" "除了 :exc:`OSError` 的那些屬性之外,:exc:`BlockingIOError` 有多一個屬性:" -#: ../../library/exceptions.rst:714 +#: ../../library/exceptions.rst:720 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 " @@ -1069,7 +1076,7 @@ msgstr "" "一個整數,內容為在其阻塞之前,已寫進串流的字元數。當使用 :mod:`io` 模組裡的緩" "衝 I/O 類別時這個屬性是可用的。" -#: ../../library/exceptions.rst:720 +#: ../../library/exceptions.rst:726 msgid "" "Raised when an operation on a child process failed. Corresponds to :c:data:" "`errno` :py:const:`~errno.ECHILD`." @@ -1077,11 +1084,11 @@ msgstr "" "當子行程上的操作失敗時會引發此例外。對應到 :c:data:`errno` :py:const:`~errno." "ECHILD`。" -#: ../../library/exceptions.rst:725 +#: ../../library/exceptions.rst:731 msgid "A base class for connection-related issues." msgstr "連線相關問題的基礎類別。" -#: ../../library/exceptions.rst:727 +#: ../../library/exceptions.rst:733 msgid "" "Subclasses are :exc:`BrokenPipeError`, :exc:`ConnectionAbortedError`, :exc:" "`ConnectionRefusedError` and :exc:`ConnectionResetError`." @@ -1089,7 +1096,7 @@ msgstr "" "子類別有 :exc:`BrokenPipeError`、:exc:`ConnectionAbortedError`、:exc:" "`ConnectionRefusedError` 及 :exc:`ConnectionResetError`。" -#: ../../library/exceptions.rst:732 +#: ../../library/exceptions.rst:738 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 " @@ -1100,7 +1107,7 @@ msgstr "" "會引發此例外,或者當嘗試寫入已關閉寫入的 socket 時也會引發。對應到 :c:data:" "`errno` :py:const:`~errno.EPIPE` 及 :py:const:`~errno.ESHUTDOWN`。" -#: ../../library/exceptions.rst:739 +#: ../../library/exceptions.rst:745 msgid "" "A subclass of :exc:`ConnectionError`, raised when a connection attempt is " "aborted by the peer. Corresponds to :c:data:`errno` :py:const:`~errno." @@ -1109,7 +1116,7 @@ msgstr "" ":exc:`ConnectionError` 的子類別。當一個連線的嘗試被對等端點 (peer) 中斷時會引" "發此例外。對應到 :c:data:`errno` :py:const:`~errno.ECONNABORTED`。" -#: ../../library/exceptions.rst:745 +#: ../../library/exceptions.rst:751 msgid "" "A subclass of :exc:`ConnectionError`, raised when a connection attempt is " "refused by the peer. Corresponds to :c:data:`errno` :py:const:`~errno." @@ -1118,7 +1125,7 @@ msgstr "" ":exc:`ConnectionError` 的子類別。當一個連線的嘗試被對等端點拒絕時會引發此例" "外。對應到 :c:data:`errno` :py:const:`~errno.ECONNREFUSED`。" -#: ../../library/exceptions.rst:751 +#: ../../library/exceptions.rst:757 msgid "" "A subclass of :exc:`ConnectionError`, raised when a connection is reset by " "the peer. Corresponds to :c:data:`errno` :py:const:`~errno.ECONNRESET`." @@ -1126,7 +1133,7 @@ msgstr "" ":exc:`ConnectionError` 的子類別。當一個連線被對等端點重置時會引發此例外。對應" "到 :c:data:`errno` :py:const:`~errno.ECONNRESET`。" -#: ../../library/exceptions.rst:757 +#: ../../library/exceptions.rst:763 msgid "" "Raised when trying to create a file or directory which already exists. " "Corresponds to :c:data:`errno` :py:const:`~errno.EEXIST`." @@ -1134,7 +1141,7 @@ msgstr "" "當嘗試建立已存在的檔案或目錄時會引發此例外。對應到 :c:data:`errno` :py:const:" "`~errno.EEXIST`。" -#: ../../library/exceptions.rst:762 +#: ../../library/exceptions.rst:768 msgid "" "Raised when a file or directory is requested but doesn't exist. Corresponds " "to :c:data:`errno` :py:const:`~errno.ENOENT`." @@ -1142,7 +1149,7 @@ msgstr "" "當請求不存在的檔案或目錄時會引發此例外。對應到 :c:data:`errno` :py:const:" "`~errno.ENOENT`。" -#: ../../library/exceptions.rst:767 +#: ../../library/exceptions.rst:773 msgid "" "Raised when a system call is interrupted by an incoming signal. Corresponds " "to :c:data:`errno` :py:const:`~errno.EINTR`." @@ -1150,7 +1157,7 @@ msgstr "" "當系統呼叫被傳入的信號中斷時會引發此例外。對應到 :c:data:`errno` :py:const:" "`~errno.EINTR`。" -#: ../../library/exceptions.rst:770 +#: ../../library/exceptions.rst:776 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 " @@ -1159,7 +1166,7 @@ msgstr "" "現在當 syscall 被信號中斷時 Python 會重試系統呼叫而不會引發 :exc:" "`InterruptedError`,除非信號處理器引發例外(理由可參考 :pep:`475`)。" -#: ../../library/exceptions.rst:777 +#: ../../library/exceptions.rst:783 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`." @@ -1167,7 +1174,7 @@ msgstr "" "當在目錄上請求檔案操作(例如 :func:`os.remove`)時會引發此例外。對應到 :c:" "data:`errno` :py:const:`~errno.EISDIR`。" -#: ../../library/exceptions.rst:783 +#: ../../library/exceptions.rst:789 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 " @@ -1179,7 +1186,7 @@ msgstr "" "外。在大多數的 POSIX 平台上,如果嘗試操作開啟或遍歷一個當作目錄的非目錄檔案也" "會引發此例外。對應到 :c:data:`errno` :py:const:`~errno.ENOTDIR`。" -#: ../../library/exceptions.rst:791 +#: ../../library/exceptions.rst:797 msgid "" "Raised when trying to run an operation without the adequate access rights - " "for example filesystem permissions. Corresponds to :c:data:`errno` :py:const:" @@ -1190,14 +1197,14 @@ msgstr "" "到 :c:data:`errno` :py:const:`~errno.EACCES`、:py:const:`~errno.EPERM` 及 :" "py:const:`~errno.ENOTCAPABLE`。" -#: ../../library/exceptions.rst:796 +#: ../../library/exceptions.rst:802 msgid "" "WASI's :py:const:`~errno.ENOTCAPABLE` is now mapped to :exc:" "`PermissionError`." msgstr "" "WASI 的 :py:const:`~errno.ENOTCAPABLE` 現在對應到 :exc:`PermissionError`。" -#: ../../library/exceptions.rst:802 +#: ../../library/exceptions.rst:808 msgid "" "Raised when a given process doesn't exist. Corresponds to :c:data:`errno` :" "py:const:`~errno.ESRCH`." @@ -1205,7 +1212,7 @@ msgstr "" "當給定的行程不存在時會引發此例外。對應到 :c:data:`errno` :py:const:`~errno." "ESRCH`。" -#: ../../library/exceptions.rst:807 +#: ../../library/exceptions.rst:813 msgid "" "Raised when a system function timed out at the system level. Corresponds to :" "c:data:`errno` :py:const:`~errno.ETIMEDOUT`." @@ -1213,40 +1220,40 @@ msgstr "" "當系統函式在系統層級超時會引發此例外。對應到 :c:data:`errno` :py:const:" "`~errno.ETIMEDOUT`。" -#: ../../library/exceptions.rst:810 +#: ../../library/exceptions.rst:816 msgid "All the above :exc:`OSError` subclasses were added." msgstr "加入以上所有的 :exc:`OSError` 子類別。" -#: ../../library/exceptions.rst:816 +#: ../../library/exceptions.rst:822 msgid ":pep:`3151` - Reworking the OS and IO exception hierarchy" msgstr ":pep:`3151` — 改寫作業系統與 IO 例外階層" -#: ../../library/exceptions.rst:822 +#: ../../library/exceptions.rst:828 msgid "Warnings" msgstr "警告" -#: ../../library/exceptions.rst:824 +#: ../../library/exceptions.rst:830 msgid "" "The following exceptions are used as warning categories; see the :ref:" "`warning-categories` documentation for more details." msgstr "" "以下的例外是當作警告的種類使用;更多細節參考 :ref:`warning-categories` 文件。" -#: ../../library/exceptions.rst:829 +#: ../../library/exceptions.rst:835 msgid "Base class for warning categories." msgstr "警告種類的基礎類別。" -#: ../../library/exceptions.rst:834 +#: ../../library/exceptions.rst:840 msgid "Base class for warnings generated by user code." msgstr "使用者程式碼產生的警告的基礎類別。" -#: ../../library/exceptions.rst:839 +#: ../../library/exceptions.rst:845 msgid "" "Base class for warnings about deprecated features when those warnings are " "intended for other Python developers." msgstr "關於已棄用功能的警告的基礎類別,且當那些警告是針對其他 Python 開發者。" -#: ../../library/exceptions.rst:842 +#: ../../library/exceptions.rst:848 msgid "" "Ignored by the default warning filters, except in the ``__main__`` module (:" "pep:`565`). Enabling the :ref:`Python Development Mode ` shows this " @@ -1255,17 +1262,17 @@ msgstr "" "會被預設的警告過濾器忽略,在 ``__main__`` 模組裡除外 (:pep:`565`)。啟用 :ref:" "`Python 開發模式 `\\ 會顯示此警告。" -#: ../../library/exceptions.rst:846 ../../library/exceptions.rst:862 +#: ../../library/exceptions.rst:852 ../../library/exceptions.rst:868 msgid "The deprecation policy is described in :pep:`387`." msgstr "棄用原則描述在 :pep:`387` 裡。" -#: ../../library/exceptions.rst:851 +#: ../../library/exceptions.rst:857 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:855 +#: ../../library/exceptions.rst:861 msgid "" "This class is rarely used as emitting a warning about a possible upcoming " "deprecation is unusual, and :exc:`DeprecationWarning` is preferred for " @@ -1274,8 +1281,8 @@ msgstr "" "因為發出關於可能即將被棄用的警告是不尋常的,此類別很少被使用,而對已經被棄用" "的情況會優先使用 :exc:`DeprecationWarning`。" -#: ../../library/exceptions.rst:859 ../../library/exceptions.rst:885 -#: ../../library/exceptions.rst:912 +#: ../../library/exceptions.rst:865 ../../library/exceptions.rst:891 +#: ../../library/exceptions.rst:918 msgid "" "Ignored by the default warning filters. Enabling the :ref:`Python " "Development Mode ` shows this warning." @@ -1283,15 +1290,15 @@ msgstr "" "會被預設的警告過濾器忽略。啟用 :ref:`Python 開發模式 `\\ 會顯示此警" "告。" -#: ../../library/exceptions.rst:867 +#: ../../library/exceptions.rst:873 msgid "Base class for warnings about dubious syntax." msgstr "關於可疑語法的警告的基礎類別。" -#: ../../library/exceptions.rst:872 +#: ../../library/exceptions.rst:878 msgid "Base class for warnings about dubious runtime behavior." msgstr "關於可疑執行環境行為的警告的基礎類別。" -#: ../../library/exceptions.rst:877 +#: ../../library/exceptions.rst:883 msgid "" "Base class for warnings about deprecated features when those warnings are " "intended for end users of applications that are written in Python." @@ -1299,36 +1306,36 @@ msgstr "" "關於已棄用功能的警告的基礎類別,且當那些警告是針對以 Python 寫的應用程式的終" "端使用者。" -#: ../../library/exceptions.rst:883 +#: ../../library/exceptions.rst:889 msgid "Base class for warnings about probable mistakes in module imports." msgstr "關於在模組引入的可能錯誤的警告的基礎類別。" -#: ../../library/exceptions.rst:891 +#: ../../library/exceptions.rst:897 msgid "Base class for warnings related to Unicode." msgstr "Unicode 相關警告的基礎類別。" -#: ../../library/exceptions.rst:896 +#: ../../library/exceptions.rst:902 msgid "Base class for warnings related to encodings." msgstr "編碼相關警告的基礎類別。" -#: ../../library/exceptions.rst:898 +#: ../../library/exceptions.rst:904 msgid "See :ref:`io-encoding-warning` for details." msgstr "細節參考\\ :ref:`io-encoding-warning`。" -#: ../../library/exceptions.rst:905 +#: ../../library/exceptions.rst:911 msgid "" "Base class for warnings related to :class:`bytes` and :class:`bytearray`." msgstr ":class:`bytes` 及 :class:`bytearray` 相關警告的基礎類別。" -#: ../../library/exceptions.rst:910 +#: ../../library/exceptions.rst:916 msgid "Base class for warnings related to resource usage." msgstr "資源用法相關警告的基礎類別。" -#: ../../library/exceptions.rst:921 +#: ../../library/exceptions.rst:927 msgid "Exception groups" msgstr "例外群組" -#: ../../library/exceptions.rst:923 +#: ../../library/exceptions.rst:929 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 " @@ -1340,7 +1347,7 @@ msgstr "" "所有其他例外一樣使用 :keyword:`except` 來處理。此外,它們會以包含的例外類型為" "基礎來比對其子群組而被 :keyword:`except*` 辨認出來。" -#: ../../library/exceptions.rst:932 +#: ../../library/exceptions.rst:938 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 " @@ -1356,7 +1363,7 @@ msgstr "" "`Exception` 的子類別。這個設計使得 ``except Exception`` 可以捕捉 :exc:" "`ExceptionGroup` 但不能捕捉 :exc:`BaseExceptionGroup`。" -#: ../../library/exceptions.rst:940 +#: ../../library/exceptions.rst:946 msgid "" "The :exc:`BaseExceptionGroup` constructor returns an :exc:`ExceptionGroup` " "rather than a :exc:`BaseExceptionGroup` if all contained exceptions are :exc:" @@ -1369,17 +1376,17 @@ msgstr "" "使用來讓這樣的選擇自動化。另一方面來說,如果任何包含的例外不是 :exc:" "`Exception` 的子類別,:exc:`ExceptionGroup` 建構函式會引發 :exc:`TypeError`。" -#: ../../library/exceptions.rst:949 +#: ../../library/exceptions.rst:955 msgid "The ``msg`` argument to the constructor. This is a read-only attribute." msgstr "建構函式的 ``msg`` 引數。這是一個唯讀的屬性。" -#: ../../library/exceptions.rst:953 +#: ../../library/exceptions.rst:959 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:958 +#: ../../library/exceptions.rst:964 msgid "" "Returns an exception group that contains only the exceptions from the " "current group that match *condition*, or ``None`` if the result is empty." @@ -1387,7 +1394,7 @@ msgstr "" "回傳只包含從現有群組比對到 *condition* 的例外的例外群組,或者當結果為空時回" "傳 ``None``。" -#: ../../library/exceptions.rst:961 +#: ../../library/exceptions.rst:967 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 " @@ -1396,7 +1403,7 @@ msgid "" "true for the exceptions that should be in the subgroup." msgstr "" -#: ../../library/exceptions.rst:967 +#: ../../library/exceptions.rst:973 msgid "" "The nesting structure of the current exception is preserved in the result, " "as are the values of its :attr:`message`, :attr:`~BaseException." @@ -1409,7 +1416,7 @@ msgstr "" "__context__` 及 :attr:`~BaseException.__notes__` 欄位的值也一樣。空的巢狀群組" "會從結果裡排除。" -#: ../../library/exceptions.rst:974 +#: ../../library/exceptions.rst:980 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 " @@ -1418,11 +1425,11 @@ msgstr "" "條件會對巢狀例外群組裡的所有例外做檢查,包括頂層及任何巢狀的例外群組。如果條" "件對這樣的例外群組為 true,它會被完整包含在結果裡。" -#: ../../library/exceptions.rst:978 +#: ../../library/exceptions.rst:984 msgid "``condition`` can be any callable which is not a type object." msgstr "" -#: ../../library/exceptions.rst:983 +#: ../../library/exceptions.rst:989 msgid "" "Like :meth:`subgroup`, but returns the pair ``(match, rest)`` where " "``match`` is ``subgroup(condition)`` and ``rest`` is the remaining non-" @@ -1431,13 +1438,13 @@ msgstr "" "像 :meth:`subgroup` 一樣,但回傳一對 ``(match, rest)``,其中 ``match`` 是 " "``subgroup(condition)`` 而 ``rest`` 是剩下沒有比對到的部分。" -#: ../../library/exceptions.rst:989 +#: ../../library/exceptions.rst:995 msgid "" "Returns an exception group with the same :attr:`message`, but which wraps " "the exceptions in ``excs``." msgstr "回傳有相同 :attr:`message` 但將例外包裝在 ``excs`` 的例外群組。" -#: ../../library/exceptions.rst:992 +#: ../../library/exceptions.rst:998 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 " @@ -1448,7 +1455,7 @@ msgstr "" "組。子類別需要覆寫它來讓 :meth:`subgroup` 及 :meth:`split` 回傳子類別而不是 :" "exc:`ExceptionGroup` 的實例。" -#: ../../library/exceptions.rst:998 +#: ../../library/exceptions.rst:1004 msgid "" ":meth:`subgroup` and :meth:`split` copy the :attr:`~BaseException." "__traceback__`, :attr:`~BaseException.__cause__`, :attr:`~BaseException." @@ -1461,7 +1468,7 @@ msgstr "" "`~BaseException.__context__` 和 :attr:`~BaseException.__notes__` 欄位到 :" "meth:`derive` 所回傳的例外群組上,因此這些欄位不需要被 :meth:`derive` 更新。" -#: ../../library/exceptions.rst:1005 +#: ../../library/exceptions.rst:1011 msgid "" ">>> class MyGroup(ExceptionGroup):\n" "... def derive(self, excs):\n" @@ -1515,7 +1522,7 @@ msgstr "" ">>> exc.__traceback__ is match.__traceback__ is rest.__traceback__\n" "True" -#: ../../library/exceptions.rst:1031 +#: ../../library/exceptions.rst:1037 msgid "" "Note that :exc:`BaseExceptionGroup` defines :meth:`~object.__new__`, so " "subclasses that need a different constructor signature need to override that " @@ -1527,7 +1534,7 @@ msgstr "" "建構函式簽名的子類別需要覆寫它而不是 :meth:`~object.__init__`。例如下面定義了" "一個例外群組子類別接受 exit_code 並從中建構群組的訊息。: ::" -#: ../../library/exceptions.rst:1037 +#: ../../library/exceptions.rst:1043 msgid "" "class Errors(ExceptionGroup):\n" " def __new__(cls, errors, exit_code):\n" @@ -1547,7 +1554,7 @@ msgstr "" " def derive(self, excs):\n" " return Errors(excs, self.exit_code)" -#: ../../library/exceptions.rst:1046 +#: ../../library/exceptions.rst:1052 msgid "" "Like :exc:`ExceptionGroup`, any subclass of :exc:`BaseExceptionGroup` which " "is also a subclass of :exc:`Exception` can only wrap instances of :exc:" @@ -1556,15 +1563,15 @@ msgstr "" "像 :exc:`ExceptionGroup` 一樣,任何 :exc:`BaseExceptionGroup` 的子類別且也" "是 :exc:`Exception` 的子類別只能包裝 :exc:`Exception` 的實例。" -#: ../../library/exceptions.rst:1054 +#: ../../library/exceptions.rst:1060 msgid "Exception hierarchy" msgstr "例外階層" -#: ../../library/exceptions.rst:1056 +#: ../../library/exceptions.rst:1062 msgid "The class hierarchy for built-in exceptions is:" msgstr "內建例外的類別階層如下:" -#: ../../library/exceptions.rst:1058 +#: ../../library/exceptions.rst:1064 #, fuzzy msgid "" "BaseException\n" @@ -1745,11 +1752,11 @@ msgstr "__suppress_context__(例外屬性)" msgid "assert" msgstr "assert" -#: ../../library/exceptions.rst:345 +#: ../../library/exceptions.rst:347 msgid "module" msgstr "module(模組)" -#: ../../library/exceptions.rst:345 +#: ../../library/exceptions.rst:347 msgid "errno" msgstr "errno" diff --git a/library/fcntl.po b/library/fcntl.po index 4a43c0463f..310659c5a8 100644 --- a/library/fcntl.po +++ b/library/fcntl.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-04-24 05:56+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-" @@ -31,9 +31,8 @@ msgid "" msgstr "" #: ../../library/fcntl.rst:21 -#, fuzzy -msgid ":ref:`Availability `: Unix, not WASI." -msgstr ":ref:`適用 `:Unix、非 Emscripten、非 WASI。" +msgid "Availability" +msgstr "" #: ../../library/fcntl.rst:23 msgid "" @@ -119,24 +118,43 @@ msgid "" "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, or a :class:" -"`bytes` object. With an integer value, the return value of this function is " -"the integer return value of the C :c:func:`fcntl` call. When the argument " -"is bytes it represents a binary structure, e.g. created by :func:`struct." -"pack`. 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. If the information returned in the buffer by " -"the operating system is larger than 1024 bytes, this is most likely to " -"result in a segmentation violation or a more subtle data corruption." -msgstr "" - -#: ../../library/fcntl.rst:104 +"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." +msgstr "" + +#: ../../library/fcntl.rst:96 +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 +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." +msgstr "" + +#: ../../library/fcntl.rst:108 msgid "If the :c:func:`fcntl` call fails, an :exc:`OSError` is raised." msgstr "" -#: ../../library/fcntl.rst:106 +#: ../../library/fcntl.rst:111 +msgid "" +"If the type or the size of *arg* does not match the type or size of the " +"argument of the operation (for example, if an integer is passed when a " +"pointer is expected, or the information returned in the buffer by the " +"operating system is larger than 1024 bytes), this is most likely to result " +"in a segmentation violation or a more subtle data corruption." +msgstr "" + +#: ../../library/fcntl.rst:118 msgid "" "Raises an :ref:`auditing event ` ``fcntl.fcntl`` with arguments " "``fd``, ``cmd``, ``arg``." @@ -144,68 +162,65 @@ msgstr "" "引發一個附帶引數 ``fd``、``cmd``、``arg`` 的\\ :ref:`稽核事件 ` " "``fcntl.fcntl``。" -#: ../../library/fcntl.rst:111 +#: ../../library/fcntl.rst:123 msgid "" "This function is identical to the :func:`~fcntl.fcntl` function, except that " "the argument handling is even more complicated." msgstr "" -#: ../../library/fcntl.rst:114 +#: ../../library/fcntl.rst:126 msgid "" -"The *request* parameter is limited to values that can fit in 32-bits. " -"Additional constants of interest for use as the *request* argument can be " -"found in the :mod:`termios` module, under the same names as used in the " -"relevant C header files." +"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 " +"the *request* argument can be found in the :mod:`termios` module, under the " +"same names as used in the relevant C header files." msgstr "" -#: ../../library/fcntl.rst:119 +#: ../../library/fcntl.rst:132 msgid "" -"The parameter *arg* can be one of an integer, an object supporting the read-" -"only buffer interface (like :class:`bytes`) or an object supporting the read-" -"write buffer interface (like :class:`bytearray`)." +"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:123 +#: ../../library/fcntl.rst:137 msgid "" -"In all but the last case, behaviour is as for the :func:`~fcntl.fcntl` " -"function." +"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:126 +#: ../../library/fcntl.rst:141 msgid "" -"If a mutable buffer is passed, then the behaviour is determined by the value " -"of the *mutate_flag* parameter." +"If *arg* supports the read-write buffer interface (like :class:`bytearray`) " +"and *mutate_flag* is true (the default), then the buffer is (in effect) " +"passed to the underlying :c:func:`!ioctl` system call, the latter's return " +"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." msgstr "" -#: ../../library/fcntl.rst:129 +#: ../../library/fcntl.rst:150 msgid "" -"If it is false, the buffer's mutability is ignored and behaviour is as for a " -"read-only buffer, except that the 1024 byte limit mentioned above is avoided " -"-- so long as the buffer you pass is at least as long as what the operating " -"system wants to put there, things should work." +"If the :c:func:`ioctl` call fails, an :exc:`OSError` exception is raised." msgstr "" -#: ../../library/fcntl.rst:134 +#: ../../library/fcntl.rst:153 msgid "" -"If *mutate_flag* is true (the default), then the buffer is (in effect) " -"passed to the underlying :func:`ioctl` system call, the latter's return code " -"is passed back to the calling Python, and the buffer's new contents reflect " -"the action of the :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." +"If the type or size of *arg* does not match the type or size of the " +"operation's argument (for example, if an integer is passed when a pointer is " +"expected, or the information returned in the buffer by the operating system " +"is larger than 1024 bytes, or the size of the mutable bytes-like object is " +"too small), this is most likely to result in a segmentation violation or a " +"more subtle data corruption." msgstr "" -#: ../../library/fcntl.rst:142 -msgid "" -"If the :c:func:`ioctl` call fails, an :exc:`OSError` exception is raised." -msgstr "" - -#: ../../library/fcntl.rst:144 +#: ../../library/fcntl.rst:161 msgid "An example::" msgstr "範例: ::" -#: ../../library/fcntl.rst:146 +#: ../../library/fcntl.rst:163 msgid "" ">>> import array, fcntl, struct, termios, os\n" ">>> os.getpgrp()\n" @@ -229,7 +244,7 @@ msgstr "" ">>> buf\n" "array('h', [13341])" -#: ../../library/fcntl.rst:157 +#: ../../library/fcntl.rst:174 msgid "" "Raises an :ref:`auditing event ` ``fcntl.ioctl`` with arguments " "``fd``, ``request``, ``arg``." @@ -237,7 +252,7 @@ msgstr "" "引發一個附帶引數 ``fd``、``request``、``arg`` 的\\ :ref:`稽核事件 " "` ``fcntl.ioctl``。" -#: ../../library/fcntl.rst:162 +#: ../../library/fcntl.rst:179 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 " @@ -245,12 +260,12 @@ msgid "" "function is emulated using :c:func:`fcntl`.)" msgstr "" -#: ../../library/fcntl.rst:167 +#: ../../library/fcntl.rst:184 msgid "" "If the :c:func:`flock` call fails, an :exc:`OSError` exception is raised." msgstr "" -#: ../../library/fcntl.rst:169 +#: ../../library/fcntl.rst:186 msgid "" "Raises an :ref:`auditing event ` ``fcntl.flock`` with arguments " "``fd``, ``operation``." @@ -258,7 +273,7 @@ msgstr "" "引發一個附帶引數 ``fd``、``operation`` 的\\ :ref:`稽核事件 ` " "``fcntl.flock``。" -#: ../../library/fcntl.rst:174 +#: ../../library/fcntl.rst:191 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." @@ -266,25 +281,25 @@ msgid "" "*cmd* is one of the following values:" msgstr "" -#: ../../library/fcntl.rst:181 +#: ../../library/fcntl.rst:198 msgid "Release an existing lock." msgstr "" -#: ../../library/fcntl.rst:185 +#: ../../library/fcntl.rst:202 msgid "Acquire a shared lock." msgstr "" -#: ../../library/fcntl.rst:189 +#: ../../library/fcntl.rst:206 msgid "Acquire an exclusive lock." msgstr "" -#: ../../library/fcntl.rst:193 +#: ../../library/fcntl.rst:210 msgid "" "Bitwise OR with any of the other three ``LOCK_*`` constants to make the " "request non-blocking." msgstr "" -#: ../../library/fcntl.rst:196 +#: ../../library/fcntl.rst:213 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 " @@ -294,33 +309,33 @@ msgid "" "a file opened for writing." msgstr "" -#: ../../library/fcntl.rst:203 +#: ../../library/fcntl.rst:220 msgid "" "*len* is the number of bytes to lock, *start* is the byte offset at which " "the lock starts, relative to *whence*, and *whence* is as with :func:`io." "IOBase.seek`, specifically:" msgstr "" -#: ../../library/fcntl.rst:207 +#: ../../library/fcntl.rst:224 msgid "``0`` -- relative to the start of the file (:const:`os.SEEK_SET`)" msgstr "" -#: ../../library/fcntl.rst:208 +#: ../../library/fcntl.rst:225 msgid "``1`` -- relative to the current buffer position (:const:`os.SEEK_CUR`)" msgstr "" -#: ../../library/fcntl.rst:209 +#: ../../library/fcntl.rst:226 msgid "``2`` -- relative to the end of the file (:const:`os.SEEK_END`)" msgstr "" -#: ../../library/fcntl.rst:211 +#: ../../library/fcntl.rst:228 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:215 +#: ../../library/fcntl.rst:232 msgid "" "Raises an :ref:`auditing event ` ``fcntl.lockf`` with arguments " "``fd``, ``cmd``, ``len``, ``start``, ``whence``." @@ -328,11 +343,11 @@ msgstr "" "引發一個附帶引數 ``fd``、``cmd``、``len``、``start``、``whence`` 的\\ :ref:`" "稽核事件 ` ``fcntl.lockf``。" -#: ../../library/fcntl.rst:217 +#: ../../library/fcntl.rst:234 msgid "Examples (all on a SVR4 compliant system)::" msgstr "" -#: ../../library/fcntl.rst:219 +#: ../../library/fcntl.rst:236 msgid "" "import struct, fcntl, os\n" "\n" @@ -350,7 +365,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:227 +#: ../../library/fcntl.rst:244 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. " @@ -358,11 +373,11 @@ msgid "" "therefore using the :func:`flock` call may be better." msgstr "" -#: ../../library/fcntl.rst:235 +#: ../../library/fcntl.rst:252 msgid "Module :mod:`os`" msgstr ":mod:`os` 模組" -#: ../../library/fcntl.rst:236 +#: ../../library/fcntl.rst:253 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 " @@ -381,6 +396,10 @@ msgstr "file control(檔案控制)" msgid "I/O control" msgstr "I/O control(I/O 控制)" +#, fuzzy +#~ msgid ":ref:`Availability `: Unix, not WASI." +#~ msgstr ":ref:`適用 `:Unix、非 Emscripten、非 WASI。" + #~ msgid "" #~ "This module does not work or is not available on WebAssembly platforms " #~ "``wasm32-emscripten`` and ``wasm32-wasi``. See :ref:`wasm-availability` " diff --git a/library/filecmp.po b/library/filecmp.po index ca8839f45d..ec971e6a84 100644 --- a/library/filecmp.po +++ b/library/filecmp.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-03-03 18:39+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-" @@ -242,6 +242,7 @@ msgid "" msgstr "" #: ../../library/filecmp.rst:202 +#, fuzzy msgid "" ">>> from filecmp import dircmp\n" ">>> def print_diff_files(dcmp):\n" @@ -251,8 +252,8 @@ msgid "" "... for sub_dcmp in dcmp.subdirs.values():\n" "... print_diff_files(sub_dcmp)\n" "...\n" -">>> dcmp = dircmp('dir1', 'dir2') \n" -">>> print_diff_files(dcmp) " +">>> dcmp = dircmp('dir1', 'dir2')\n" +">>> print_diff_files(dcmp)" msgstr "" ">>> from filecmp import dircmp\n" ">>> def print_diff_files(dcmp):\n" diff --git a/library/filesys.po b/library/filesys.po index 039d7bf996..7aca43b2ca 100644 --- a/library/filesys.po +++ b/library/filesys.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-04-18 00:04+0000\n" +"POT-Creation-Date: 2024-12-29 16:19+0000\n" "PO-Revision-Date: 2021-11-22 20:13+0800\n" "Last-Translator: Allen Wu \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -36,11 +36,11 @@ msgstr "" "取檔案的屬性、以可攜 (portable) 方式操作路徑以及建立暫存檔。本章中的完整 " "module 清單是:" -#: ../../library/filesys.rst:29 +#: ../../library/filesys.rst:28 msgid "Module :mod:`os`" msgstr "Module :mod:`os`" -#: ../../library/filesys.rst:30 +#: ../../library/filesys.rst:29 msgid "" "Operating system interfaces, including functions to work with files at a " "lower level than Python :term:`file objects `." @@ -48,11 +48,11 @@ msgstr "" "作業系統介面,包括處理比 Python :term:`檔案物件 `\\ 更低階檔案的" "函式。" -#: ../../library/filesys.rst:33 +#: ../../library/filesys.rst:32 msgid "Module :mod:`io`" msgstr "Module :mod:`io`" -#: ../../library/filesys.rst:34 +#: ../../library/filesys.rst:33 msgid "" "Python's built-in I/O library, including both abstract classes and some " "concrete classes such as file I/O." @@ -60,10 +60,10 @@ msgstr "" "Python 的內建 I/O 函式庫,包含抽象類別和一些具體類別 (concrete class),如檔" "案 I/O。" -#: ../../library/filesys.rst:37 +#: ../../library/filesys.rst:36 msgid "Built-in function :func:`open`" msgstr "內建函式 :func:`open`" -#: ../../library/filesys.rst:38 +#: ../../library/filesys.rst:37 msgid "The standard way to open files for reading and writing with Python." msgstr "使用 Python 打開檔案以進行讀寫檔案的標準方法。" diff --git a/library/fnmatch.po b/library/fnmatch.po index 345fd99a0a..09b141490a 100644 --- a/library/fnmatch.po +++ b/library/fnmatch.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-02-07 08:41+0000\n" "PO-Revision-Date: 2018-05-23 16:02+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -90,12 +90,20 @@ msgstr "" #: ../../library/fnmatch.rst:49 msgid "" -"Also note that :func:`functools.lru_cache` with the *maxsize* of 32768 is " -"used to cache the compiled regex patterns in the following functions: :func:" -"`fnmatch`, :func:`fnmatchcase`, :func:`.filter`." +"Unless stated otherwise, \"filename string\" and \"pattern string\" either " +"refer to :class:`str` or ``ISO-8859-1`` encoded :class:`bytes` objects. Note " +"that the functions documented below do not allow to mix a :class:`!bytes` " +"pattern with a :class:`!str` filename, and vice-versa." msgstr "" -#: ../../library/fnmatch.rst:55 +#: ../../library/fnmatch.rst:54 +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`." +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 :" @@ -104,13 +112,13 @@ msgid "" "operating system." msgstr "" -#: ../../library/fnmatch.rst:61 +#: ../../library/fnmatch.rst:67 msgid "" "This example will print all file names in the current directory with the " "extension ``.txt``::" msgstr "" -#: ../../library/fnmatch.rst:64 +#: ../../library/fnmatch.rst:70 msgid "" "import fnmatch\n" "import os\n" @@ -126,35 +134,35 @@ msgstr "" " if fnmatch.fnmatch(file, '*.txt'):\n" " print(file)" -#: ../../library/fnmatch.rst:74 +#: ../../library/fnmatch.rst:80 msgid "" "Test whether the filename string *name* matches the pattern string *pat*, " "returning ``True`` or ``False``; the comparison is case-sensitive and does " "not apply :func:`os.path.normcase`." msgstr "" -#: ../../library/fnmatch.rst:81 +#: ../../library/fnmatch.rst:87 msgid "" -"Construct a list from those elements of the :term:`iterable` *names* that " -"match pattern *pat*. It is the same as ``[n for n in names if fnmatch(n, " -"pat)]``, but implemented more efficiently." +"Construct a list from those elements of the :term:`iterable` of filename " +"strings *names* that match the pattern string *pat*. It is the same as ``[n " +"for n in names if fnmatch(n, pat)]``, but implemented more efficiently." msgstr "" -#: ../../library/fnmatch.rst:89 +#: ../../library/fnmatch.rst:95 msgid "" "Return the shell-style pattern *pat* converted to a regular expression for " -"using with :func:`re.match`." +"using with :func:`re.match`. The pattern is expected to be a :class:`str`." msgstr "" -#: ../../library/fnmatch.rst:92 +#: ../../library/fnmatch.rst:98 msgid "Example:" msgstr "範例:" -#: ../../library/fnmatch.rst:106 +#: ../../library/fnmatch.rst:112 msgid "Module :mod:`glob`" msgstr ":mod:`glob` 模組" -#: ../../library/fnmatch.rst:107 +#: ../../library/fnmatch.rst:113 msgid "Unix shell-style path expansion." msgstr "" diff --git a/library/ftplib.po b/library/ftplib.po index b0dac40c3a..cf88ad9a5b 100644 --- a/library/ftplib.po +++ b/library/ftplib.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2024-10-13 17:13+0000\n" "PO-Revision-Date: 2023-04-26 19:44+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -46,8 +46,8 @@ msgid "The default encoding is UTF-8, following :rfc:`2640`." msgstr "預設編碼是 UTF-8,遵循 :rfc:`2640`。" #: ../../includes/wasm-notavail.rst:3 -msgid ":ref:`Availability `: not WASI." -msgstr ":ref:`Availability `:非 WASI。" +msgid "Availability" +msgstr "" #: ../../includes/wasm-notavail.rst:5 #, fuzzy @@ -747,3 +747,6 @@ msgstr "protocol(協定)" #: ../../library/ftplib.rst:9 msgid "ftplib (standard module)" msgstr "ftplib(標準模組)" + +#~ msgid ":ref:`Availability `: not WASI." +#~ msgstr ":ref:`Availability `:非 WASI。" diff --git a/library/functions.po b/library/functions.po index 1ac9b3f1e4..18be988f8c 100644 --- a/library/functions.po +++ b/library/functions.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-03-03 18:39+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-" @@ -514,8 +514,8 @@ msgid "" "ways." msgstr "如果不一定需要 \"0b\" 前綴,還可以使用如下的方法。" -#: ../../library/functions.rst:141 ../../library/functions.rst:929 -#: ../../library/functions.rst:1308 +#: ../../library/functions.rst:141 ../../library/functions.rst:942 +#: ../../library/functions.rst:1323 msgid "See also :func:`format` for more information." msgstr "可參考 :func:`format` 獲取更多資訊。" @@ -535,7 +535,7 @@ msgstr "" "(參見 :ref:`typesnumeric`),其他 class 不能繼承自它。它只有 ``False`` 和 " "``True`` 兩個實例(參見 :ref:`typebool`)。" -#: ../../library/functions.rst:156 ../../library/functions.rst:794 +#: ../../library/functions.rst:156 ../../library/functions.rst:807 msgid "The parameter is now positional-only." msgstr "現在為僅限位置參數。" @@ -763,16 +763,18 @@ msgstr "" "`property`" #: ../../library/functions.rst:285 +#, fuzzy msgid "" -"Class methods now inherit the method attributes (``__module__``, " -"``__name__``, ``__qualname__``, ``__doc__`` and ``__annotations__``) and " -"have a new ``__wrapped__`` attribute." +"Class methods now inherit the method attributes (:attr:`~function." +"__module__`, :attr:`~function.__name__`, :attr:`~function.__qualname__`, :" +"attr:`~function.__doc__` and :attr:`~function.__annotations__`) and have a " +"new ``__wrapped__`` attribute." msgstr "" "Class method 現在繼承了 method 屬性(``__module__``、``__name__``、" "``__qualname__``、``__doc__`` 和 ``__annotations__``),並擁有一個新的 " "``__wrapped__`` 屬性。" -#: ../../library/functions.rst:290 +#: ../../library/functions.rst:292 msgid "" "Class methods can no longer wrap other :term:`descriptors ` such " "as :func:`property`." @@ -780,7 +782,7 @@ msgstr "" "Class methods 不能再包裝其他的\\ :term:`描述器 `,例如 :func:" "`property`。" -#: ../../library/functions.rst:297 +#: ../../library/functions.rst:299 msgid "" "Compile the *source* into a code or AST object. Code objects can be " "executed by :func:`exec` or :func:`eval`. *source* can either be a normal " @@ -791,7 +793,7 @@ msgstr "" "`eval` 執行。*source* 可以是一般的字串、bytes 字串、或者 AST 物件。參見 :mod:" "`ast` module(模組)的說明文件瞭解如何使用 AST 物件。" -#: ../../library/functions.rst:302 +#: ../../library/functions.rst:304 msgid "" "The *filename* argument should give the file from which the code was read; " "pass some recognizable value if it wasn't read from a file (``''`` " @@ -800,7 +802,7 @@ msgstr "" "*filename* 引數必須是程式碼的檔名;如果程式碼不是從檔案中讀取,可以傳入一些可" "辨識的值(經常會使用 ``''`` 來替代)。" -#: ../../library/functions.rst:306 +#: ../../library/functions.rst:308 msgid "" "The *mode* argument specifies what kind of code must be compiled; it can be " "``'exec'`` if *source* consists of a sequence of statements, ``'eval'`` if " @@ -813,7 +815,7 @@ msgstr "" "式,可以是 ``'single'``\\ (在最後一種情況下,如果運算式執行結果不是 " "``None`` 則會被印出來)。" -#: ../../library/functions.rst:312 +#: ../../library/functions.rst:314 msgid "" "The optional arguments *flags* and *dont_inherit* control which :ref:" "`compiler options ` should be activated and which :ref:" @@ -833,7 +835,7 @@ msgstr "" "引數所指定的編譯器選項和未來陳述式。如果 *dont_inherit* 是一個非零整數,則使" "用 *flags* 引數 -- 周圍程式碼中的旗標(未來功能和編譯器選項)將被忽略。" -#: ../../library/functions.rst:323 +#: ../../library/functions.rst:325 msgid "" "Compiler options and future statements are specified by bits which can be " "bitwise ORed together to specify multiple options. The bitfield required to " @@ -848,7 +850,7 @@ msgstr "" "compiler_flag` 屬性來獲得。:ref:`編譯器旗標 `\\ 可以在 :" "mod:`ast` module 中搜尋有 ``PyCF_`` 前綴的名稱。" -#: ../../library/functions.rst:331 +#: ../../library/functions.rst:333 msgid "" "The argument *optimize* specifies the optimization level of the compiler; " "the default value of ``-1`` selects the optimization level of the " @@ -861,7 +863,7 @@ msgstr "" "``__debug__`` 為真值)、``1``\\ (assert 被刪除,``__debug__`` 為假值)或 " "``2``\\ (說明字串 (docstring) 也被刪除)。" -#: ../../library/functions.rst:337 +#: ../../library/functions.rst:339 msgid "" "This function raises :exc:`SyntaxError` if the compiled source is invalid, " "and :exc:`ValueError` if the source contains null bytes." @@ -869,13 +871,13 @@ msgstr "" "如果編譯的原始碼無效,此函式會引發 :exc:`SyntaxError`,如果原始碼包含 null " "bytes,則會引發 :exc:`ValueError`。" -#: ../../library/functions.rst:340 +#: ../../library/functions.rst:342 msgid "" "If you want to parse Python code into its AST representation, see :func:`ast." "parse`." msgstr "如果你想解析 Python 程式碼為 AST 運算式,請參閱 :func:`ast.parse`。" -#: ../../library/functions.rst:343 ../../library/functions.rst:345 +#: ../../library/functions.rst:345 ../../library/functions.rst:347 msgid "" "Raises an :ref:`auditing event ` ``compile`` with arguments " "``source`` and ``filename``. This event may also be raised by implicit " @@ -884,7 +886,7 @@ msgstr "" "引發一個附帶引數 ``source``、``filename`` 的\\ :ref:`稽核事件 ` " "``compile``。此事件也可能由隱式編譯 (implicit compilation) 所引發。" -#: ../../library/functions.rst:351 +#: ../../library/functions.rst:353 msgid "" "When compiling a string with multi-line code in ``'single'`` or ``'eval'`` " "mode, input must be terminated by at least one newline character. This is " @@ -894,7 +896,7 @@ msgstr "" "在 ``'single'`` 或 ``'eval'`` 模式編譯多行程式碼時,輸入必須以至少一個換行符" "結尾。這使 :mod:`code` module 更容易檢測陳述式的完整性。" -#: ../../library/functions.rst:358 +#: ../../library/functions.rst:360 msgid "" "It is possible to crash the Python interpreter with a sufficiently large/" "complex string when compiling to an AST object due to stack depth " @@ -903,7 +905,7 @@ msgstr "" "如果編譯足夠大或者足夠複雜的字串成 AST 物件時,Python 直譯器會因為 Python " "AST 編譯器的 stack 深度限制而崩潰。" -#: ../../library/functions.rst:362 +#: ../../library/functions.rst:364 msgid "" "Allowed use of Windows and Mac newlines. Also, input in ``'exec'`` mode " "does not have to end in a newline anymore. Added the *optimize* parameter." @@ -911,13 +913,13 @@ msgstr "" "允許使用 Windows 和 Mac 的換行符號。此外,在 ``'exec'`` 模式不需要以換行符號" "結尾。增加了 *optimize* 參數。" -#: ../../library/functions.rst:366 +#: ../../library/functions.rst:368 msgid "" "Previously, :exc:`TypeError` was raised when null bytes were encountered in " "*source*." msgstr "在之前的版本,*source* 中包含 null bytes 會引發 :exc:`TypeError`。" -#: ../../library/functions.rst:370 +#: ../../library/functions.rst:372 msgid "" "``ast.PyCF_ALLOW_TOP_LEVEL_AWAIT`` can now be passed in flags to enable " "support for top-level ``await``, ``async for``, and ``async with``." @@ -925,18 +927,18 @@ msgstr "" "``ast.PyCF_ALLOW_TOP_LEVEL_AWAIT`` 現在可以傳遞旗標以啟用對頂層 ``await``、" "``async for`` 和 ``async with`` 的支援。" -#: ../../library/functions.rst:379 +#: ../../library/functions.rst:381 msgid "" "Convert a single string or number to a complex number, or create a complex " "number from real and imaginary parts." msgstr "" -#: ../../library/functions.rst:382 ../../library/functions.rst:739 -#: ../../library/functions.rst:985 +#: ../../library/functions.rst:384 ../../library/functions.rst:752 +#: ../../library/functions.rst:998 msgid "Examples:" msgstr "例如: ::" -#: ../../library/functions.rst:384 +#: ../../library/functions.rst:386 msgid "" ">>> complex('+1.23')\n" "(1.23+0j)\n" @@ -972,7 +974,7 @@ msgstr "" ">>> complex(-1.23, 4.5)\n" "(-1.23+4.5j)" -#: ../../library/functions.rst:403 +#: ../../library/functions.rst:405 msgid "" "If the argument is a string, it must contain either a real part (in the same " "format as for :func:`float`) or an imaginary part (in the same format but " @@ -987,7 +989,7 @@ msgid "" "parentheses and leading and trailing whitespace characters are removed:" msgstr "" -#: ../../library/functions.rst:422 +#: ../../library/functions.rst:424 #, fuzzy msgid "" "If the argument is a number, the constructor serves as a numeric conversion " @@ -1002,7 +1004,7 @@ msgstr "" "back) 到 :meth:`~object.__float__`。如果 :meth:`!__float__` 未定義,則會再回" "退到 :meth:`~object.__index__`。" -#: ../../library/functions.rst:431 +#: ../../library/functions.rst:433 msgid "" "If two arguments are provided or keyword arguments are used, each argument " "may be any numeric type (including complex). If both arguments are real " @@ -1013,20 +1015,20 @@ msgid "" "number, only its real component is used in the above expressions." msgstr "" -#: ../../library/functions.rst:441 +#: ../../library/functions.rst:443 msgid "If all arguments are omitted, returns ``0j``." msgstr "" -#: ../../library/functions.rst:443 +#: ../../library/functions.rst:445 msgid "The complex type is described in :ref:`typesnumeric`." msgstr "複數型別在 :ref:`typesnumeric` 中有相關描述。" -#: ../../library/functions.rst:445 ../../library/functions.rst:791 -#: ../../library/functions.rst:1034 +#: ../../library/functions.rst:447 ../../library/functions.rst:804 +#: ../../library/functions.rst:1047 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." @@ -1034,7 +1036,7 @@ msgstr "" "如果 :meth:`~object.__complex__` 和 :meth:`~object.__float__` 未定義,則會回" "退到 :meth:`~object.__index__`。" -#: ../../library/functions.rst:455 +#: ../../library/functions.rst:457 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 " @@ -1047,7 +1049,7 @@ msgstr "" "'foobar')`` 等價於 ``del x.foobar``。*name* 不必是個 Python 識別符 " "(identifier)(請見 :func:`setattr`)。" -#: ../../library/functions.rst:468 +#: ../../library/functions.rst:470 msgid "" "Create a new dictionary. The :class:`dict` object is the dictionary class. " "See :class:`dict` and :ref:`typesmapping` for documentation about this class." @@ -1055,7 +1057,7 @@ msgstr "" "建立一個新的 dictionary(字典)。:class:`dict` 物件是一個 dictionary class。" "參見 :class:`dict` 和 :ref:`typesmapping` 來瞭解這個 class。" -#: ../../library/functions.rst:471 +#: ../../library/functions.rst:473 msgid "" "For other containers see the built-in :class:`list`, :class:`set`, and :" "class:`tuple` classes, as well as the :mod:`collections` module." @@ -1063,7 +1065,7 @@ msgstr "" "其他容器型別,請參見內建的 :class:`list`、:class:`set` 和 :class:`tuple` " "class,以及 :mod:`collections` module。" -#: ../../library/functions.rst:478 +#: ../../library/functions.rst:480 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 " @@ -1072,7 +1074,7 @@ msgstr "" "如果沒有引數,則回傳當前區域作用域 (local scope) 中的名稱列表。如果有引數,它" "會嘗試回傳該物件的有效屬性列表。" -#: ../../library/functions.rst:481 +#: ../../library/functions.rst:483 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 " @@ -1085,7 +1087,7 @@ msgstr "" "或 :func:`~object.__getattribute__` 函式的物件能夠自定義 :func:`dir` 來報告它" "們的屬性。" -#: ../../library/functions.rst:488 +#: ../../library/functions.rst:490 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__` " @@ -1097,7 +1099,7 @@ msgstr "" "`~object.__dict__` 屬性和型別物件收集資訊。結果列表並不總是完整的,如果物件有" "自定義 :func:`~object.__getattr__`,那結果可能不準確。" -#: ../../library/functions.rst:494 +#: ../../library/functions.rst:496 msgid "" "The default :func:`dir` mechanism behaves differently with different types " "of objects, as it attempts to produce the most relevant, rather than " @@ -1106,13 +1108,13 @@ msgstr "" "預設的 :func:`dir` 機制對不同型別的物件有不同行為,它會試圖回傳最相關而非最完" "整的資訊:" -#: ../../library/functions.rst:498 +#: ../../library/functions.rst:500 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:503 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." @@ -1120,7 +1122,7 @@ msgstr "" "如果物件是型別或 class 物件,則列表包含它們的屬性名稱,並且遞迴查詢其基礎的所" "有屬性。" -#: ../../library/functions.rst:504 +#: ../../library/functions.rst:506 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 " @@ -1129,11 +1131,11 @@ msgstr "" "否則,包含物件的屬性名稱列表、它的 class 屬性名稱,並且遞迴查詢它的 class 的" "所有基礎 class 的屬性。" -#: ../../library/functions.rst:508 +#: ../../library/functions.rst:510 msgid "The resulting list is sorted alphabetically. For example:" msgstr "回傳的列表按字母表排序,例如:" -#: ../../library/functions.rst:528 +#: ../../library/functions.rst:530 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 " @@ -1146,7 +1148,7 @@ msgstr "" "版本之間改變。例如,當引數是一個 class 時,metaclass 的屬性不包含在結果列表" "中。" -#: ../../library/functions.rst:538 +#: ../../library/functions.rst:540 msgid "" "Take two (non-complex) numbers as arguments and return a pair of numbers " "consisting of their quotient and remainder when using integer division. " @@ -1164,7 +1166,7 @@ msgstr "" "等,如果 ``a % b`` 非零,則它的符號和 *b* 一樣,且 ``0 <= abs(a % b) < " "abs(b)``。" -#: ../../library/functions.rst:550 +#: ../../library/functions.rst:552 msgid "" "Return an enumerate object. *iterable* must be a sequence, an :term:" "`iterator`, or some other object which supports iteration. The :meth:" @@ -1177,11 +1179,11 @@ msgstr "" "__next__` method 回傳一個 tuple(元組),裡面包含一個計數值(從 *start* 開" "始,預設為 0)和透過疊代 *iterable* 獲得的值。" -#: ../../library/functions.rst:562 +#: ../../library/functions.rst:564 msgid "Equivalent to::" msgstr "等價於: ::" -#: ../../library/functions.rst:564 +#: ../../library/functions.rst:566 msgid "" "def enumerate(iterable, start=0):\n" " n = start\n" @@ -1199,15 +1201,15 @@ msgstr "" msgid "Parameters" msgstr "" -#: ../../library/functions.rst:574 +#: ../../library/functions.rst:576 msgid "A Python expression." msgstr "" -#: ../../library/functions.rst:578 +#: ../../library/functions.rst:580 msgid "The global namespace (default: ``None``)." msgstr "" -#: ../../library/functions.rst:582 +#: ../../library/functions.rst:584 msgid "The local namespace (default: ``None``)." msgstr "" @@ -1215,7 +1217,7 @@ msgstr "" msgid "Returns" msgstr "" -#: ../../library/functions.rst:586 +#: ../../library/functions.rst:588 msgid "The result of the evaluated expression." msgstr "" @@ -1223,11 +1225,17 @@ msgstr "" msgid "raises" msgstr "引發" -#: ../../library/functions.rst:587 +#: ../../library/functions.rst:589 msgid "Syntax errors are reported as exceptions." msgstr "" -#: ../../library/functions.rst:589 +#: ../../library/functions.rst:593 ../../library/functions.rst:654 +msgid "" +"This function executes arbitrary code. Calling it with user-supplied input " +"may lead to security vulnerabilities." +msgstr "" + +#: ../../library/functions.rst:596 #, fuzzy msgid "" "The *expression* argument is parsed and evaluated as a Python expression " @@ -1256,11 +1264,11 @@ msgstr "" "func:`eval` 被呼叫的環境中執行運算式。請注意,*eval()* 在封閉 (enclosing) 環" "境中無法存取\\ :term:`巢狀作用域 ` (non-locals)。" -#: ../../library/functions.rst:605 +#: ../../library/functions.rst:612 msgid "Example:" msgstr "範例:" -#: ../../library/functions.rst:611 +#: ../../library/functions.rst:618 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 " @@ -1271,7 +1279,7 @@ msgstr "" "情況下,傳入的引數是程式碼物件而不是字串。如果編譯該物件時的 *mode* 引數是 " "``'exec'``,那麼 :func:`eval` 回傳值為 ``None``。" -#: ../../library/functions.rst:616 +#: ../../library/functions.rst:623 msgid "" "Hints: dynamic execution of statements is supported by the :func:`exec` " "function. The :func:`globals` and :func:`locals` functions return the " @@ -1282,13 +1290,13 @@ msgstr "" "函式分別回傳當前的全域性和局部性 dictionary,它們對於將引數傳遞給 :func:" "`eval` 或 :func:`exec` 可能會方便許多。" -#: ../../library/functions.rst:621 +#: ../../library/functions.rst:628 msgid "" "If the given source is a string, then leading and trailing spaces and tabs " "are stripped." msgstr "如果給定來源是一個字串,那麼其前後的空格和定位字元會被移除。" -#: ../../library/functions.rst:624 +#: ../../library/functions.rst:631 msgid "" "See :func:`ast.literal_eval` for a function that can safely evaluate strings " "with expressions containing only literals." @@ -1296,8 +1304,8 @@ msgstr "" "另外可以參閱 :func:`ast.literal_eval`,該函式可以安全執行僅包含文字的運算式字" "串。" -#: ../../library/functions.rst:627 ../../library/functions.rst:629 -#: ../../library/functions.rst:683 ../../library/functions.rst:685 +#: ../../library/functions.rst:634 ../../library/functions.rst:636 +#: ../../library/functions.rst:696 ../../library/functions.rst:698 msgid "" "Raises an :ref:`auditing event ` ``exec`` with the code object as " "the argument. Code compilation events may also be raised." @@ -1305,17 +1313,17 @@ msgstr "" "引發一個附帶程式碼物件為引數的\\ :ref:`稽核事件 ` ``exec``。也可能" "會引發程式碼編譯事件。" -#: ../../library/functions.rst:634 ../../library/functions.rst:705 +#: ../../library/functions.rst:641 ../../library/functions.rst:718 msgid "The *globals* and *locals* arguments can now be passed as keywords." msgstr "" -#: ../../library/functions.rst:638 ../../library/functions.rst:709 +#: ../../library/functions.rst:645 ../../library/functions.rst:722 msgid "" "The semantics of the default *locals* namespace have been adjusted as " "described for the :func:`locals` builtin." msgstr "" -#: ../../library/functions.rst:645 +#: ../../library/functions.rst:657 #, fuzzy msgid "" "This function supports dynamic execution of Python code. *source* must be " @@ -1336,7 +1344,7 @@ msgstr "" "`nonlocal`、:keyword:`yield` 和 :keyword:`return` 陳述式也不能在函式之外使" "用。該函式回傳值是 ``None``。" -#: ../../library/functions.rst:656 +#: ../../library/functions.rst:668 #, fuzzy msgid "" "In all cases, if the optional parts are omitted, the code is executed in the " @@ -1353,7 +1361,7 @@ msgstr "" "供了 *locals* 引數,則它可以是任何映射物件。請記住在 module 層級中全域性和本" "地變數是相同的 dictionary。" -#: ../../library/functions.rst:666 +#: ../../library/functions.rst:678 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 " @@ -1362,7 +1370,7 @@ msgid "" "are treated as class variables in a class definition)." msgstr "" -#: ../../library/functions.rst:672 +#: ../../library/functions.rst:684 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:" @@ -1375,18 +1383,19 @@ msgstr "" "dictionary 傳入 :func:`exec` 之前,你可以透過將它插入 *globals* 來控制你需要" "哪些內建函式來執行程式碼。" -#: ../../library/functions.rst:678 +#: ../../library/functions.rst:690 +#, fuzzy msgid "" "The *closure* argument specifies a closure--a tuple of cellvars. It's only " -"valid when the *object* is a code object containing free variables. The " -"length of the tuple must exactly match the number of free variables " -"referenced by the code object." +"valid when the *object* is a code object containing :term:`free (closure) " +"variables `. The length of the tuple must exactly match " +"the length of the code object's :attr:`~codeobject.co_freevars` attribute." msgstr "" "*closure* 引數會指定一個閉包 (closure) — 它是一個 cellvar(格變數)的 tuple。" "只有在 *object* 是一個含有自由變數 (free variable) 的程式碼物件時,它才有效。" "Tuple 的長度必須與程式碼物件所引用的自由變數數量完全匹配。" -#: ../../library/functions.rst:690 +#: ../../library/functions.rst:703 #, fuzzy msgid "" "The built-in functions :func:`globals` and :func:`locals` return the current " @@ -1396,7 +1405,7 @@ msgstr "" "內建 :func:`globals` 和 :func:`locals` 函式各自回傳當前的全域性和本地 " "dictionary,因此可以將它們傳遞給 :func:`exec` 的第二個和第三個引數。" -#: ../../library/functions.rst:696 +#: ../../library/functions.rst:709 #, fuzzy msgid "" "The default *locals* act as described for function :func:`locals` below. " @@ -1407,11 +1416,11 @@ msgstr "" "預設的 *locals* dictionary。如果你想在 :func:`exec` 函式回傳時知道程式碼對 " "*locals* 的變動,請明確地傳遞 *locals* dictionary 。" -#: ../../library/functions.rst:700 +#: ../../library/functions.rst:713 msgid "Added the *closure* parameter." msgstr "增加了 *closure* 參數。" -#: ../../library/functions.rst:715 +#: ../../library/functions.rst:728 msgid "" "Construct an iterator from those elements of *iterable* for which *function* " "is true. *iterable* may be either a sequence, a container which supports " @@ -1423,7 +1432,7 @@ msgstr "" "*function* 是 ``None``,則會假設它是一個識別性函式,即 *iterable* 中所有假值" "元素會被移除。" -#: ../../library/functions.rst:721 +#: ../../library/functions.rst:734 msgid "" "Note that ``filter(function, iterable)`` is equivalent to the generator " "expression ``(item for item in iterable if function(item))`` if function is " @@ -1434,7 +1443,7 @@ msgstr "" "是 ``None`` 的時候為 ``(item for item in iterable if function(item))``;" "function 是 ``None`` 的時候為 ``(item for item in iterable if item)``。" -#: ../../library/functions.rst:726 +#: ../../library/functions.rst:739 msgid "" "See :func:`itertools.filterfalse` for the complementary function that " "returns elements of *iterable* for which *function* is false." @@ -1442,11 +1451,11 @@ msgstr "" "請參閱 :func:`itertools.filterfalse`,只有 *function* 為 false 時才選取 " "*iterable* 中元素的互補函式。" -#: ../../library/functions.rst:737 +#: ../../library/functions.rst:750 msgid "Return a floating-point number constructed from a number or a string." msgstr "回傳從數字或字串生成的浮點數。" -#: ../../library/functions.rst:741 +#: ../../library/functions.rst:754 msgid "" ">>> float('+1.23')\n" "1.23\n" @@ -1470,7 +1479,7 @@ msgstr "" ">>> float('-Infinity')\n" "-inf" -#: ../../library/functions.rst:754 +#: ../../library/functions.rst:767 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 " @@ -1485,7 +1494,7 @@ msgstr "" "數也可以是 NaN(非數字)或正負無窮大的字串。確切地說,除去首尾的空格後,輸入" "必須遵循以下語法中 :token:`~float:floatvalue` 的生成規則:" -#: ../../library/functions.rst:775 +#: ../../library/functions.rst:788 msgid "" "Case is not significant, so, for example, \"inf\", \"Inf\", \"INFINITY\", " "and \"iNfINity\" are all acceptable spellings for positive infinity." @@ -1493,7 +1502,7 @@ msgstr "" "字母大小寫不影響,例如,\"inf\"、\"Inf\"、\"INFINITY\"、\"iNfINity\" 都可以表" "示正無窮大。" -#: ../../library/functions.rst:778 +#: ../../library/functions.rst:791 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 " @@ -1503,7 +1512,7 @@ msgstr "" "否則,如果引數是整數或浮點數,則回傳具有相同值(在 Python 浮點精度範圍內)的" "浮點數。如果引數在 Python 浮點精度範圍外,則會引發 :exc:`OverflowError`。" -#: ../../library/functions.rst:783 +#: ../../library/functions.rst:796 msgid "" "For a general Python object ``x``, ``float(x)`` delegates to ``x." "__float__()``. If :meth:`~object.__float__` is not defined then it falls " @@ -1512,22 +1521,22 @@ msgstr "" "對於一般的 Python 物件 ``x``,``float(x)`` 會委派給 ``x.__float__()``。如果未" "定義 :meth:`~object.__float__` 則會回退到 :meth:`~object.__index__`。" -#: ../../library/functions.rst:787 +#: ../../library/functions.rst:800 msgid "If no argument is given, ``0.0`` is returned." msgstr "如果沒有引數,則回傳 ``0.0``。" -#: ../../library/functions.rst:789 +#: ../../library/functions.rst:802 msgid "The float type is described in :ref:`typesnumeric`." msgstr ":ref:`typesnumeric` 描述了浮點數型別。" -#: ../../library/functions.rst:797 +#: ../../library/functions.rst:810 msgid "" "Falls back to :meth:`~object.__index__` if :meth:`~object.__float__` is not " "defined." msgstr "" "如果 :meth:`~object.__float__` 未定義,則會回退到 :meth:`~object.__index__`。" -#: ../../library/functions.rst:807 +#: ../../library/functions.rst:820 msgid "" "Convert a *value* to a \"formatted\" representation, as controlled by " "*format_spec*. The interpretation of *format_spec* will depend on the type " @@ -1538,7 +1547,7 @@ msgstr "" "取決於 *value* 引數的型別,但是大多數內建型別使用標準格式化語法::ref:" "`formatspec`。" -#: ../../library/functions.rst:812 +#: ../../library/functions.rst:825 msgid "" "The default *format_spec* is an empty string which usually gives the same " "effect as calling :func:`str(value) `." @@ -1546,7 +1555,7 @@ msgstr "" "預設的 *format_spec* 是一個空字串,它通常和呼叫 :func:`str(value) ` 的效" "果相同。" -#: ../../library/functions.rst:815 +#: ../../library/functions.rst:828 msgid "" "A call to ``format(value, format_spec)`` is translated to ``type(value)." "__format__(value, format_spec)`` which bypasses the instance dictionary when " @@ -1560,7 +1569,7 @@ msgstr "" "實例中的字典。如果搜尋到 :mod:`object` 這個 method 但 *format_spec* 不為空," "或是 *format_spec* 或回傳值不是字串,則會引發 :exc:`TypeError`。" -#: ../../library/functions.rst:822 +#: ../../library/functions.rst:835 msgid "" "``object().__format__(format_spec)`` raises :exc:`TypeError` if " "*format_spec* is not an empty string." @@ -1568,7 +1577,7 @@ msgstr "" "當 *format_spec* 不是空字串時,``object().__format__(format_spec)`` 會引發 :" "exc:`TypeError`。" -#: ../../library/functions.rst:831 +#: ../../library/functions.rst:844 msgid "" "Return a new :class:`frozenset` object, optionally with elements taken from " "*iterable*. ``frozenset`` is a built-in class. See :class:`frozenset` and :" @@ -1578,7 +1587,7 @@ msgstr "" "``frozenset`` 是一個內建的 class。有關此 class 的文件,請參閱 :class:" "`frozenset` 和 :ref:`types-set`。" -#: ../../library/functions.rst:835 +#: ../../library/functions.rst:848 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." @@ -1586,7 +1595,7 @@ msgstr "" "請參閱內建的 :class:`set`、:class:`list`、:class:`tuple` 和 :class:`dict` " "class,以及 :mod:`collections` module 來了解其它的容器。" -#: ../../library/functions.rst:843 +#: ../../library/functions.rst:856 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 " @@ -1601,7 +1610,7 @@ msgstr "" "`AttributeError`。*name* 不必是個 Python 識別符 (identifier)(請見 :func:" "`setattr`)。" -#: ../../library/functions.rst:852 +#: ../../library/functions.rst:865 msgid "" "Since :ref:`private name mangling ` happens at " "compilation time, one must manually mangle a private attribute's (attributes " @@ -1612,7 +1621,7 @@ msgstr "" "發生在編譯期,因此你必須手動改編私有屬性(有兩個前導底線的屬性)的名稱,才能" "使用 :func:`getattr` 來取得它。" -#: ../../library/functions.rst:860 +#: ../../library/functions.rst:873 msgid "" "Return the dictionary implementing the current module namespace. For code " "within functions, this is set when the function is defined and remains the " @@ -1621,7 +1630,7 @@ msgstr "" "回傳代表當前 module 命名空間的 dictionary。對於在函式中的程式碼來說,這在定義" "函式時設定且不論該函式是在何處呼叫都會保持相同。" -#: ../../library/functions.rst:867 +#: ../../library/functions.rst:880 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. " @@ -1632,7 +1641,7 @@ msgstr "" "則回傳 ``False``。(此功能是透過呼叫 ``getattr(object, name)`` 並檢查是否引" "發 :exc:`AttributeError` 來實作的。)" -#: ../../library/functions.rst:875 +#: ../../library/functions.rst:888 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 " @@ -1643,7 +1652,7 @@ msgstr "" "時用來快速比較 dictionary 的鍵。相同大小的數字數值有相同的雜湊值(即使它們型" "別不同,如 1 和 1.0)。" -#: ../../library/functions.rst:882 +#: ../../library/functions.rst:895 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." @@ -1651,7 +1660,7 @@ msgstr "" "請注意,如果物件帶有自訂的 :meth:`~object.__hash__` 方法,:func:`hash` 將根據" "運行機器的位元長度來截斷回傳值。" -#: ../../library/functions.rst:889 +#: ../../library/functions.rst:902 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 " @@ -1665,7 +1674,7 @@ msgstr "" "關鍵字或說明文件主題中搜索該字串,並在控制台上列印幫助資訊。如果引數是其他任" "意物件,則會生成該物件的幫助頁。" -#: ../../library/functions.rst:896 +#: ../../library/functions.rst:909 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 " @@ -1676,12 +1685,12 @@ msgstr "" "前面的參數是僅限位置 (positional-only) 參數。有關更多資訊,請參閱\\ :ref:`常" "見問答集中的僅限位置參數條目 `。" -#: ../../library/functions.rst:901 +#: ../../library/functions.rst:914 msgid "" "This function is added to the built-in namespace by the :mod:`site` module." msgstr "此函式會被 :mod:`site` module 加入到內建命名空間。" -#: ../../library/functions.rst:903 +#: ../../library/functions.rst:916 msgid "" "Changes to :mod:`pydoc` and :mod:`inspect` mean that the reported signatures " "for callables are now more comprehensive and consistent." @@ -1689,7 +1698,7 @@ msgstr "" "對於 :mod:`pydoc` 和 :mod:`inspect` 的變更,使得可呼叫物件回報的的簽名 " "(signature) 更加全面和一致。" -#: ../../library/functions.rst:910 +#: ../../library/functions.rst:923 msgid "" "Convert an integer number to a lowercase hexadecimal string prefixed with " "\"0x\". If *x* is not a Python :class:`int` object, it has to define an :" @@ -1699,7 +1708,7 @@ msgstr "" "class:`int` 物件,則必須定義一個 :meth:`~object.__index__` method 並且回傳一" "個整數。舉例來說:" -#: ../../library/functions.rst:919 +#: ../../library/functions.rst:932 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 " @@ -1708,20 +1717,20 @@ msgstr "" "如果要將整數轉換為大寫或小寫的十六進位制字串,並可選擇有無 \"0x\" 前綴,則可" "以使用如下方法:" -#: ../../library/functions.rst:931 +#: ../../library/functions.rst:944 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:936 +#: ../../library/functions.rst:949 msgid "" "To obtain a hexadecimal string representation for a float, use the :meth:" "`float.hex` method." msgstr "" "如果要獲取浮點數的十六進位制字串形式,請使用 :meth:`float.hex` method。" -#: ../../library/functions.rst:942 +#: ../../library/functions.rst:955 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. " @@ -1731,18 +1740,18 @@ msgstr "" "回傳物件的 \"識別性\" 。該值是一個整數,在此物件的生命週期中保證是唯一且恆定" "的。兩個生命期不重疊的物件可能具有相同的 :func:`id` 值。" -#: ../../library/functions.rst:947 +#: ../../library/functions.rst:960 msgid "This is the address of the object in memory." msgstr "這是該物件在記憶體中的位址。" -#: ../../library/functions.rst:949 +#: ../../library/functions.rst:962 msgid "" "Raises an :ref:`auditing event ` ``builtins.id`` with argument " "``id``." msgstr "" "引發一個附帶引數 ``id`` 的\\ :ref:`稽核事件 ` ``builtins.id``。" -#: ../../library/functions.rst:955 +#: ../../library/functions.rst:968 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, " @@ -1753,11 +1762,12 @@ msgstr "" "從輸入中讀取一行,將其轉換為字串(去除末尾的換行符)並回傳。當讀取到 EOF 時," "則引發 :exc:`EOFError`。例如: ::" -#: ../../library/functions.rst:960 +#: ../../library/functions.rst:973 +#, fuzzy msgid "" -">>> s = input('--> ') \n" +">>> s = input('--> ')\n" "--> Monty Python's Flying Circus\n" -">>> s \n" +">>> s\n" "\"Monty Python's Flying Circus\"" msgstr "" ">>> s = input('--> ') \n" @@ -1765,7 +1775,7 @@ msgstr "" ">>> s \n" "\"Monty Python's Flying Circus\"" -#: ../../library/functions.rst:965 +#: ../../library/functions.rst:978 msgid "" "If the :mod:`readline` module was loaded, then :func:`input` will use it to " "provide elaborate line editing and history features." @@ -1773,7 +1783,7 @@ msgstr "" "如果載入了 :mod:`readline` module,:func:`input` 將使用它來提供複雜的行編輯和" "歷史記錄功能。" -#: ../../library/functions.rst:968 ../../library/functions.rst:970 +#: ../../library/functions.rst:981 ../../library/functions.rst:983 msgid "" "Raises an :ref:`auditing event ` ``builtins.input`` with argument " "``prompt`` before reading input" @@ -1781,7 +1791,7 @@ msgstr "" "引發一個附帶讀取輸入前的引數 ``prompt`` 的\\ :ref:`稽核事件 ` " "``builtins.input``。" -#: ../../library/functions.rst:973 ../../library/functions.rst:975 +#: ../../library/functions.rst:986 ../../library/functions.rst:988 msgid "" "Raises an :ref:`auditing event ` ``builtins.input/result`` with " "the result after successfully reading input." @@ -1789,13 +1799,13 @@ msgstr "" "引發一個附帶成功讀取結果的\\ :ref:`稽核事件 ` ``builtins.input/" "result``。" -#: ../../library/functions.rst:982 +#: ../../library/functions.rst:995 msgid "" "Return an integer object constructed from a number or a string, or return " "``0`` if no arguments are given." msgstr "" -#: ../../library/functions.rst:987 +#: ../../library/functions.rst:1000 msgid "" ">>> int(123.45)\n" "123\n" @@ -1823,7 +1833,7 @@ msgstr "" ">>> int('01110011', base=2)\n" "115" -#: ../../library/functions.rst:1002 +#: ../../library/functions.rst:1015 msgid "" "If the argument defines :meth:`~object.__int__`, ``int(x)`` returns ``x." "__int__()``. If the argument defines :meth:`~object.__index__`, it returns " @@ -1836,7 +1846,7 @@ msgstr "" "義了 :meth:`~object.__trunc__` 則回傳 ``x.__trunc__()``。對於浮點數,則會向零" "的方向無條件捨去。" -#: ../../library/functions.rst:1008 +#: ../../library/functions.rst:1021 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 " @@ -1849,7 +1859,7 @@ msgstr "" "以有 ``+`` 或 ``-``\\ (中間沒有空格)、可有個前導的零、也可被空格包圍、或在" "數字間有單一底線。" -#: ../../library/functions.rst:1014 +#: ../../library/functions.rst:1027 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 " @@ -1871,11 +1881,11 @@ msgstr "" "進制中的一個,所以 ``int('010', 0)`` 是非法的,但 ``int('010')`` 和 " "``int('010', 8)`` 是有效的。" -#: ../../library/functions.rst:1025 +#: ../../library/functions.rst:1038 msgid "The integer type is described in :ref:`typesnumeric`." msgstr "整數型別定義請參閱\\ :ref:`typesnumeric`。" -#: ../../library/functions.rst:1027 +#: ../../library/functions.rst:1040 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 " @@ -1887,22 +1897,22 @@ msgstr "" "的版本使用 :meth:`base.__int__ ` 而不是 :meth:`base." "__index__ `。" -#: ../../library/functions.rst:1037 +#: ../../library/functions.rst:1050 msgid "The first parameter is now positional-only." msgstr "第一個參數為僅限位置參數。" -#: ../../library/functions.rst:1040 +#: ../../library/functions.rst:1053 msgid "" "Falls back to :meth:`~object.__index__` if :meth:`~object.__int__` is not " "defined." msgstr "" "如果未定義 :meth:`~object.__int__` 則會回退到 :meth:`~object.__index__`。" -#: ../../library/functions.rst:1043 +#: ../../library/functions.rst:1056 msgid "The delegation to :meth:`~object.__trunc__` is deprecated." msgstr "對 :meth:`~object.__trunc__` 的委派已棄用。" -#: ../../library/functions.rst:1046 +#: ../../library/functions.rst:1059 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 " @@ -1916,7 +1926,7 @@ msgstr "" "`int` 轉換為字串時將會超出限制時,會引發 :exc:`ValueError`。請參閱\\ :ref:`整" "數字串轉換的長度限制 `\\ 說明文件。" -#: ../../library/functions.rst:1056 +#: ../../library/functions.rst:1069 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 " @@ -1956,7 +1966,7 @@ msgstr "" "是 *classinfo* 中任一元素的 subclass 時則回傳 ``True``。其他情況,會引發 :" "exc:`TypeError`。" -#: ../../library/functions.rst:1088 +#: ../../library/functions.rst:1101 msgid "" "Return an :term:`iterator` object. The first argument is interpreted very " "differently depending on the presence of the second argument. Without a " @@ -1980,11 +1990,11 @@ msgstr "" "__next__` 時會不帶引數地呼叫 *object*;如果回傳的結果是 *sentinel* 則引發 :" "exc:`StopIteration`,否則回傳呼叫結果。" -#: ../../library/functions.rst:1102 +#: ../../library/functions.rst:1115 msgid "See also :ref:`typeiter`." msgstr "另請參閱 :ref:`typeiter`。" -#: ../../library/functions.rst:1104 +#: ../../library/functions.rst:1117 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 " @@ -1993,7 +2003,7 @@ msgstr "" ":func:`iter` 的第二種形式有一個好用的應用,是能夠建立一個區塊閱讀器 (block-" "reader)。例如,從二進位資料庫檔案中讀取固定寬度的區塊,直到檔案的結尾: ::" -#: ../../library/functions.rst:1108 +#: ../../library/functions.rst:1121 msgid "" "from functools import partial\n" "with open('mydata.db', 'rb') as f:\n" @@ -2005,7 +2015,7 @@ msgstr "" " for block in iter(partial(f.read, 64), b''):\n" " process_block(block)" -#: ../../library/functions.rst:1116 +#: ../../library/functions.rst:1129 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 " @@ -2014,7 +2024,7 @@ msgstr "" "回傳物件的長度(元素個數)。引數可以是序列(如 string、bytes、tuple、list 或 " "range)或集合(如 dictionary、set 或 frozen set)。" -#: ../../library/functions.rst:1122 +#: ../../library/functions.rst:1135 msgid "" "``len`` raises :exc:`OverflowError` on lengths larger than :data:`sys." "maxsize`, such as :class:`range(2 ** 100) `." @@ -2022,7 +2032,7 @@ msgstr "" "如果物件長度大於 :data:`sys.maxsize`,像是 :class:`range(2 ** 100) `," "則 ``len`` 會引發 :exc:`OverflowError`。" -#: ../../library/functions.rst:1131 +#: ../../library/functions.rst:1144 msgid "" "Rather than being a function, :class:`list` is actually a mutable sequence " "type, as documented in :ref:`typesseq-list` and :ref:`typesseq`." @@ -2030,33 +2040,33 @@ msgstr "" "除了是函式,:class:`list` 也是可變序列型別,詳情請參閱 :ref:`typesseq-list` " "和 :ref:`typesseq`。" -#: ../../library/functions.rst:1137 +#: ../../library/functions.rst:1150 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:1141 +#: ../../library/functions.rst:1154 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:1145 +#: ../../library/functions.rst:1158 msgid "" "At class scope, it returns the namespace that will be passed to the " "metaclass constructor." msgstr "" -#: ../../library/functions.rst:1148 +#: ../../library/functions.rst:1161 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:1151 +#: ../../library/functions.rst:1164 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 " @@ -2066,7 +2076,7 @@ msgid "" "returned mapping object." msgstr "" -#: ../../library/functions.rst:1158 +#: ../../library/functions.rst:1171 msgid "" "In an :term:`optimized scope` (including functions, generators, and " "coroutines), each call to ``locals()`` instead returns a fresh dictionary " @@ -2078,7 +2088,7 @@ msgid "" "previously returned dictionaries." msgstr "" -#: ../../library/functions.rst:1167 +#: ../../library/functions.rst:1180 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 " @@ -2087,19 +2097,19 @@ msgid "" "function." msgstr "" -#: ../../library/functions.rst:1173 +#: ../../library/functions.rst:1186 msgid "" "Calling ``locals()`` as part of a generator expression is equivalent to " "calling it in a nested generator function." msgstr "" -#: ../../library/functions.rst:1176 +#: ../../library/functions.rst:1189 msgid "" "The behaviour of ``locals()`` in a comprehension has been updated as " "described in :pep:`709`." msgstr "" -#: ../../library/functions.rst:1180 +#: ../../library/functions.rst:1193 msgid "" "As part of :pep:`667`, the semantics of mutating the mapping objects " "returned from this function are now defined. The behavior in :term:" @@ -2108,7 +2118,7 @@ msgid "" "versions." msgstr "" -#: ../../library/functions.rst:1190 +#: ../../library/functions.rst:1203 msgid "" "Return an iterator that applies *function* to every item of *iterable*, " "yielding the results. If additional *iterables* arguments are passed, " @@ -2123,13 +2133,13 @@ msgstr "" "iteratable 耗盡時 iterator 也會結束。如果函式的輸入已經被編排為引數的 tuple," "請參閱 :func:`itertools.starmap`。" -#: ../../library/functions.rst:1202 +#: ../../library/functions.rst:1215 msgid "" "Return the largest item in an iterable or the largest of two or more " "arguments." msgstr "回傳 iterable 中最大的元素,或者回傳兩個以上的引數中最大的。" -#: ../../library/functions.rst:1205 +#: ../../library/functions.rst:1218 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 " @@ -2138,7 +2148,7 @@ msgstr "" "如果只提供了一個位置引數,它必須是個 :term:`iterable`,iterable 中最大的元素" "會被回傳。如果提供了兩個或以上的位置引數,則回傳最大的位置引數。" -#: ../../library/functions.rst:1210 ../../library/functions.rst:1248 +#: ../../library/functions.rst:1223 ../../library/functions.rst:1261 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 " @@ -2151,7 +2161,7 @@ msgstr "" "的物件。如果 iterable 為空,並且沒有提供 *default*,則會引發 :exc:" "`ValueError`。" -#: ../../library/functions.rst:1216 +#: ../../library/functions.rst:1229 msgid "" "If multiple items are maximal, the function returns the first one " "encountered. This is consistent with other sort-stability preserving tools " @@ -2162,15 +2172,15 @@ msgstr "" "``sorted(iterable, key=keyfunc, reverse=True)[0]`` 和 ``heapq.nlargest(1, " "iterable, key=keyfunc)`` 一致。" -#: ../../library/functions.rst:1221 ../../library/functions.rst:1259 +#: ../../library/functions.rst:1234 ../../library/functions.rst:1272 msgid "Added the *default* keyword-only parameter." msgstr "新增 *default* 僅限關鍵字參數。" -#: ../../library/functions.rst:1224 ../../library/functions.rst:1262 +#: ../../library/functions.rst:1237 ../../library/functions.rst:1275 msgid "The *key* can be ``None``." msgstr "*key* 可以為 ``None``。" -#: ../../library/functions.rst:1232 +#: ../../library/functions.rst:1245 msgid "" "Return a \"memory view\" object created from the given argument. See :ref:" "`typememoryview` for more information." @@ -2178,13 +2188,13 @@ msgstr "" "回傳由給定的引數所建立之「memory view(記憶體檢視)」物件。有關詳細資訊,請參" "閱\\ :ref:`typememoryview`。" -#: ../../library/functions.rst:1240 +#: ../../library/functions.rst:1253 msgid "" "Return the smallest item in an iterable or the smallest of two or more " "arguments." msgstr "回傳 iterable 中最小的元素,或者回傳兩個以上的引數中最小的。" -#: ../../library/functions.rst:1243 +#: ../../library/functions.rst:1256 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 " @@ -2193,7 +2203,7 @@ msgstr "" "如果只提供了一個位置引數,它必須是 :term:`iterable`,iterable 中最小的元素會" "被回傳。如果提供了兩個以上的位置引數,則回傳最小的位置引數。" -#: ../../library/functions.rst:1254 +#: ../../library/functions.rst:1267 msgid "" "If multiple items are minimal, the function returns the first one " "encountered. This is consistent with other sort-stability preserving tools " @@ -2204,7 +2214,7 @@ msgstr "" "``sorted(iterable, key=keyfunc)[0]`` 和 ``heapq.nsmallest(1, iterable, " "key=keyfunc)`` 一致。" -#: ../../library/functions.rst:1269 +#: ../../library/functions.rst:1282 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 " @@ -2214,24 +2224,27 @@ msgstr "" "素。如果 iterator 耗盡,則回傳給定的預設值 *default*,如果沒有預設值則引發 :" "exc:`StopIteration`。" -#: ../../library/functions.rst:1276 +#: ../../library/functions.rst:1289 +#, fuzzy msgid "" -"Return a new featureless object. :class:`object` is a base for all classes. " -"It has methods that are common to all instances of Python classes. This " -"function does not accept any arguments." +"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 " +"called, it returns a new featureless object. The constructor does not accept " +"any arguments." msgstr "" "回傳一個沒有特徵的新物件。:class:`object` 是所有 class 的基礎,它具有所有 " "Python class 實例的通用 method。這個函式不接受任何引數。" -#: ../../library/functions.rst:1282 +#: ../../library/functions.rst:1296 +#, fuzzy msgid "" -":class:`object` does *not* have a :attr:`~object.__dict__`, so you can't " -"assign arbitrary attributes to an instance of the :class:`object` class." +":class:`object` instances do *not* have :attr:`~object.__dict__` attributes, " +"so you can't assign arbitrary attributes to an instance of :class:`object`." msgstr "" "由於 :class:`object` *沒有* :attr:`~object.__dict__`,因此無法將任意屬性賦" "給 :class:`object` class 的實例。" -#: ../../library/functions.rst:1288 +#: ../../library/functions.rst:1303 msgid "" "Convert an integer number to an octal string prefixed with \"0o\". The " "result is a valid Python expression. If *x* is not a Python :class:`int` " @@ -2242,7 +2255,7 @@ msgstr "" "Python 運算式。如果 *x* 不是 Python 的 :class:`int` 物件,那它需要定義 :meth:" "`~object.__index__` method 回傳一個整數。舉例來說:" -#: ../../library/functions.rst:1298 +#: ../../library/functions.rst:1313 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." @@ -2250,7 +2263,7 @@ msgstr "" "如果要將整數轉換為八進位制字串,不論是否具備 \"0o\" 前綴,都可以使用下面的方" "法。" -#: ../../library/functions.rst:1315 +#: ../../library/functions.rst:1330 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 " @@ -2260,7 +2273,7 @@ msgstr "" "啟,則引發 :exc:`OSError`。關於使用此函式的更多方法,請參閱\\ :ref:`tut-" "files`。" -#: ../../library/functions.rst:1319 +#: ../../library/functions.rst:1334 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 " @@ -2273,7 +2286,7 @@ msgstr "" "器 (file descriptor)。(如果有給定檔案描述器,它會隨著回傳的 I/O 物件關閉而關" "閉,除非 *closefd* 被設為 ``False``。)" -#: ../../library/functions.rst:1325 +#: ../../library/functions.rst:1340 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. " @@ -2294,71 +2307,71 @@ msgstr "" "getencoding` 來獲取當前的本地編碼。(要讀取和寫入原始 bytes,請使用二進位制模" "式且不要指定 *encoding*。)可用的模式有:" -#: ../../library/functions.rst:1342 +#: ../../library/functions.rst:1357 msgid "Character" msgstr "字元" -#: ../../library/functions.rst:1342 +#: ../../library/functions.rst:1357 msgid "Meaning" msgstr "意義" -#: ../../library/functions.rst:1344 +#: ../../library/functions.rst:1359 msgid "``'r'``" msgstr "``'r'``" -#: ../../library/functions.rst:1344 +#: ../../library/functions.rst:1359 msgid "open for reading (default)" msgstr "讀取(預設)" -#: ../../library/functions.rst:1345 +#: ../../library/functions.rst:1360 msgid "``'w'``" msgstr "``'w'``" -#: ../../library/functions.rst:1345 +#: ../../library/functions.rst:1360 msgid "open for writing, truncating the file first" msgstr "寫入,會先清除檔案內容" -#: ../../library/functions.rst:1346 +#: ../../library/functions.rst:1361 msgid "``'x'``" msgstr "``'x'``" -#: ../../library/functions.rst:1346 +#: ../../library/functions.rst:1361 msgid "open for exclusive creation, failing if the file already exists" msgstr "唯一性建立,如果文件已存在則會失敗" -#: ../../library/functions.rst:1347 +#: ../../library/functions.rst:1362 msgid "``'a'``" msgstr "``'a'``" -#: ../../library/functions.rst:1347 +#: ../../library/functions.rst:1362 msgid "open for writing, appending to the end of file if it exists" msgstr "寫入,如果檔案存在則在其末端附加內容" -#: ../../library/functions.rst:1348 +#: ../../library/functions.rst:1363 msgid "``'b'``" msgstr "``'b'``" -#: ../../library/functions.rst:1348 ../../library/functions.rst:1492 +#: ../../library/functions.rst:1363 ../../library/functions.rst:1507 msgid "binary mode" msgstr "二進制模式" -#: ../../library/functions.rst:1349 +#: ../../library/functions.rst:1364 msgid "``'t'``" msgstr "``'t'``" -#: ../../library/functions.rst:1349 +#: ../../library/functions.rst:1364 msgid "text mode (default)" msgstr "文字模式(預設)" -#: ../../library/functions.rst:1350 +#: ../../library/functions.rst:1365 msgid "``'+'``" msgstr "``'+'``" -#: ../../library/functions.rst:1350 +#: ../../library/functions.rst:1365 msgid "open for updating (reading and writing)" msgstr "更新(讀取並寫入)" -#: ../../library/functions.rst:1353 +#: ../../library/functions.rst:1368 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 " @@ -2368,7 +2381,7 @@ msgstr "" "``'w+b'`` 模式會開啟並清除檔案。``'r+'`` 和 ``'r+b'`` 模式會開啟且保留檔案內" "容。" -#: ../../library/functions.rst:1357 +#: ../../library/functions.rst:1372 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* " @@ -2384,7 +2397,7 @@ msgstr "" "``'t'``),檔案的內容會以 :class:`str` 回傳,其位元組已經先被解碼,使用的是取" "決於平台的編碼系統或是給定的 *encoding*。" -#: ../../library/functions.rst:1367 +#: ../../library/functions.rst:1382 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 " @@ -2393,7 +2406,7 @@ msgstr "" "Python 不會使用底層作業系統對於文字檔案的操作概念;所有的處理都是由 Python 獨" "自完成的,因此能獨立於不同平台。" -#: ../../library/functions.rst:1371 +#: ../../library/functions.rst:1386 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 " @@ -2414,7 +2427,7 @@ msgstr "" "``write_through`` 旗標。若未給定 *buffering* 引數,則預設的緩衝策略會運作如" "下:" -#: ../../library/functions.rst:1381 +#: ../../library/functions.rst:1396 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 " @@ -2426,7 +2439,7 @@ msgstr "" "DEFAULT_BUFFER_SIZE`。在許多系統上,緩衝區的長度通常為 4096 或 8192 個位元" "組。" -#: ../../library/functions.rst:1386 +#: ../../library/functions.rst:1401 msgid "" "\"Interactive\" text files (files for which :meth:`~io.IOBase.isatty` " "returns ``True``) use line buffering. Other text files use the policy " @@ -2435,7 +2448,7 @@ msgstr "" "「互動式」文字檔(:meth:`~io.IOBase.isatty` 回傳 ``True`` 的檔案)會使用列緩" "衝。其他文字檔則使用上述的二進制檔案緩衝策略。" -#: ../../library/functions.rst:1390 +#: ../../library/functions.rst:1405 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 " @@ -2448,7 +2461,7 @@ msgstr "" "Python 支援的任何 :term:`text encoding`\\ (文字編碼)都是可以使用的。關於支" "援的編碼系統清單,請參閱 :mod:`codecs` module。" -#: ../../library/functions.rst:1396 +#: ../../library/functions.rst:1411 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 " @@ -2461,7 +2474,7 @@ msgstr "" "handlers`\\ 有列出清單),不過任何已註冊到 :func:`codecs.register_error` 的錯" "誤處理程式名稱也都是有效的。標準的名稱包括:" -#: ../../library/functions.rst:1404 +#: ../../library/functions.rst:1419 msgid "" "``'strict'`` to raise a :exc:`ValueError` exception if there is an encoding " "error. The default value of ``None`` has the same effect." @@ -2469,20 +2482,20 @@ msgstr "" "``'strict'`` 如果發生編碼錯誤,則引發 :exc:`ValueError` 例外。預設值 " "``None`` 也有相同的效果。" -#: ../../library/functions.rst:1408 +#: ../../library/functions.rst:1423 msgid "" "``'ignore'`` ignores errors. Note that ignoring encoding errors can lead to " "data loss." msgstr "``'ignore'`` 忽略錯誤。請注意,忽略編碼錯誤可能導致資料遺失。" -#: ../../library/functions.rst:1411 +#: ../../library/functions.rst:1426 msgid "" "``'replace'`` causes a replacement marker (such as ``'?'``) to be inserted " "where there is malformed data." msgstr "" "``'replace'`` 會在格式不正確的資料位置插入一個替換標誌(像是 ``'?'``)。" -#: ../../library/functions.rst:1414 +#: ../../library/functions.rst:1429 msgid "" "``'surrogateescape'`` will represent any incorrect bytes as low surrogate " "code units ranging from U+DC80 to U+DCFF. These surrogate code units will " @@ -2495,7 +2508,7 @@ msgstr "" "被還原回 ``surrogateescape`` 錯誤處理程式當時所處理的那些相同位元組。這對於處" "理未知編碼方式的檔案會很好用。" -#: ../../library/functions.rst:1421 +#: ../../library/functions.rst:1436 msgid "" "``'xmlcharrefreplace'`` is only supported when writing to a file. Characters " "not supported by the encoding are replaced with the appropriate XML " @@ -2504,7 +2517,7 @@ msgstr "" "``'xmlcharrefreplace'`` 僅在寫入檔案時可支援。編碼系統不支援的字元會被替換為" "適當的 XML 字元參考 (character reference) ``&#nnn;``。" -#: ../../library/functions.rst:1425 +#: ../../library/functions.rst:1440 msgid "" "``'backslashreplace'`` replaces malformed data by Python's backslashed " "escape sequences." @@ -2512,7 +2525,7 @@ msgstr "" "``'backslashreplace'`` 會用 Python 的反斜線跳脫序列 (backslashed escape " "sequence) 替換格式不正確的資料。" -#: ../../library/functions.rst:1428 +#: ../../library/functions.rst:1443 msgid "" "``'namereplace'`` (also only supported when writing) replaces unsupported " "characters with ``\\N{...}`` escape sequences." @@ -2520,7 +2533,7 @@ msgstr "" "``'namereplace'``\\ (也僅在寫入時支援)會將不支援的字元替換為 ``\\N{...}`` " "跳脫序列。" -#: ../../library/functions.rst:1436 +#: ../../library/functions.rst:1451 msgid "" "*newline* determines how to parse newline characters from the stream. It can " "be ``None``, ``''``, ``'\\n'``, ``'\\r'``, and ``'\\r\\n'``. It works as " @@ -2529,7 +2542,7 @@ msgstr "" "*newline* 會決定如何剖析資料串流 (stream) 中的換行字元。它可以是 ``None``、" "``''``、``'\\n'``、``'\\r'`` 或 ``'\\r\\n'``。它的運作規則如下:" -#: ../../library/functions.rst:1440 +#: ../../library/functions.rst:1455 msgid "" "When reading input from the stream, if *newline* is ``None``, universal " "newlines mode is enabled. Lines in the input can end in ``'\\n'``, " @@ -2545,7 +2558,7 @@ msgstr "" "傳給呼叫方時,行尾符號不會被轉換。如果它是任何其他有效的值,則輸入資料的行只" "會由給定的字串做結尾,且在回傳給呼叫方時,行尾符號不會被轉換。" -#: ../../library/functions.rst:1448 +#: ../../library/functions.rst:1463 msgid "" "When writing output to the stream, if *newline* is ``None``, any ``'\\n'`` " "characters written are translated to the system default line separator, :" @@ -2558,7 +2571,7 @@ msgstr "" "``''`` 或 ``'\\n'``,則不做任何轉換。如果 *newline* 是任何其他有效的值,則寫" "入的任何 ``'\\n'`` 字元都將轉換為給定的字串。" -#: ../../library/functions.rst:1454 +#: ../../library/functions.rst:1469 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 " @@ -2569,7 +2582,7 @@ msgstr "" "則當檔案關閉時,底層的檔案描述器會保持開啟狀態。如果有給定一個檔名,則 " "*closefd* 必須是 ``True``\\ (預設值);否則將引發錯誤。" -#: ../../library/functions.rst:1459 +#: ../../library/functions.rst:1474 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 " @@ -2582,11 +2595,11 @@ msgstr "" "必須回傳一個開啟的檔案描述器(將 :mod:`os.open` 作為 *opener* 傳入,在功能上" "的結果會相當於傳入 ``None``)。" -#: ../../library/functions.rst:1465 +#: ../../library/functions.rst:1480 msgid "The newly created file is :ref:`non-inheritable `." msgstr "新建立的檔案是\\ :ref:`不可繼承的 `。" -#: ../../library/functions.rst:1467 +#: ../../library/functions.rst:1482 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::" @@ -2594,7 +2607,7 @@ msgstr "" "下面的範例使用 :func:`os.open` 函式回傳值當作 :ref:`dir_fd ` 的參數," "從給定的目錄中用相對路徑開啟檔案: ::" -#: ../../library/functions.rst:1470 +#: ../../library/functions.rst:1485 msgid "" ">>> import os\n" ">>> dir_fd = os.open('somedir', os.O_RDONLY)\n" @@ -2607,7 +2620,7 @@ msgid "" ">>> os.close(dir_fd) # don't leak a file descriptor" msgstr "" -#: ../../library/functions.rst:1480 +#: ../../library/functions.rst:1495 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 " @@ -2631,7 +2644,7 @@ msgstr "" "BufferedRandom`。當緩衝被停用時,會回傳原始資料串流 :class:`io.FileIO`,它" "是 :class:`io.RawIOBase` 的一個 subclass。" -#: ../../library/functions.rst:1501 +#: ../../library/functions.rst:1516 msgid "" "See also the file handling modules, such as :mod:`fileinput`, :mod:`io` " "(where :func:`open` is declared), :mod:`os`, :mod:`os.path`, :mod:" @@ -2641,7 +2654,7 @@ msgstr "" "`open` 的 module )、:mod:`os`、:mod:`os.path`、:mod:`tempfile` 以及 :mod:" "`shutil`。" -#: ../../library/functions.rst:1505 +#: ../../library/functions.rst:1520 msgid "" "Raises an :ref:`auditing event ` ``open`` with arguments ``path``, " "``mode``, ``flags``." @@ -2649,25 +2662,25 @@ msgstr "" "引發一個附帶引數 ``path``、``mode``、``flags`` 的\\ :ref:`稽核事件 " "` ``open``。" -#: ../../library/functions.rst:1507 +#: ../../library/functions.rst:1522 msgid "" "The ``mode`` and ``flags`` arguments may have been modified or inferred from " "the original call." msgstr "``mode`` 和 ``flags`` 引數可能會被原始的呼叫所修改或推論 (infer)。" -#: ../../library/functions.rst:1512 +#: ../../library/functions.rst:1527 msgid "The *opener* parameter was added." msgstr "增加了 *opener* 參數。" -#: ../../library/functions.rst:1513 +#: ../../library/functions.rst:1528 msgid "The ``'x'`` mode was added." msgstr "增加了 ``'x'`` 模式。" -#: ../../library/functions.rst:1514 +#: ../../library/functions.rst:1529 msgid ":exc:`IOError` used to be raised, it is now an alias of :exc:`OSError`." msgstr "過去引發的 :exc:`IOError`,現在是 :exc:`OSError` 的別名。" -#: ../../library/functions.rst:1515 +#: ../../library/functions.rst:1530 msgid "" ":exc:`FileExistsError` is now raised if the file opened in exclusive " "creation mode (``'x'``) already exists." @@ -2675,11 +2688,11 @@ msgstr "" "如果檔案已存在但使用了唯一性建立模式 (``'x'``),現在會引發 :exc:" "`FileExistsError`。" -#: ../../library/functions.rst:1520 +#: ../../library/functions.rst:1535 msgid "The file is now non-inheritable." msgstr "檔案在此版本開始是不可繼承的。" -#: ../../library/functions.rst:1524 +#: ../../library/functions.rst:1539 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 :" @@ -2688,15 +2701,15 @@ msgstr "" "如果系統呼叫被中斷,但訊號處理程式沒有引發例外,此函式現在會重試系統呼叫,而" "不是引發 :exc:`InterruptedError` 例外(原因詳見 :pep:`475`)。" -#: ../../library/functions.rst:1527 +#: ../../library/functions.rst:1542 msgid "The ``'namereplace'`` error handler was added." msgstr "增加了 ``'namereplace'`` 錯誤處理程式。" -#: ../../library/functions.rst:1531 +#: ../../library/functions.rst:1546 msgid "Support added to accept objects implementing :class:`os.PathLike`." msgstr "增加對於實作 :class:`os.PathLike` 物件的支援。" -#: ../../library/functions.rst:1532 +#: ../../library/functions.rst:1547 msgid "" "On Windows, opening a console buffer may return a subclass of :class:`io." "RawIOBase` other than :class:`io.FileIO`." @@ -2704,11 +2717,11 @@ msgstr "" "在 Windows 上,開啟一個控制臺緩衝區可能會回傳 :class:`io.RawIOBase` 的 " "subclass,而不是 :class:`io.FileIO`。" -#: ../../library/functions.rst:1535 +#: ../../library/functions.rst:1550 msgid "The ``'U'`` mode has been removed." msgstr "``'U'`` 模式被移除。" -#: ../../library/functions.rst:1540 +#: ../../library/functions.rst:1555 msgid "" "Given a string representing one Unicode character, return an integer " "representing the Unicode code point of that character. For example, " @@ -2719,7 +2732,7 @@ msgstr "" "``ord('a')`` 回傳整數 ``97``、``ord('€')``\\ (歐元符號)回傳 ``8364``。這" "是 :func:`chr` 的逆函式。" -#: ../../library/functions.rst:1548 +#: ../../library/functions.rst:1563 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) % " @@ -2730,7 +2743,7 @@ msgstr "" "*mod* 取餘數(比直接呼叫 ``pow(base, exp) % mod`` 計算更高效)。兩個引數形式" "的 ``pow(exp, exp)`` 等價於次方運算子:``base**exp``。" -#: ../../library/functions.rst:1553 +#: ../../library/functions.rst:1568 #, fuzzy msgid "" "The arguments must have numeric types. With mixed operand types, the " @@ -2753,7 +2766,7 @@ msgstr "" "數,且指數 (exponent) 不是整數,則會得到一個複數的結果。例如,``pow(-9, " "0.5)`` 會回傳一個接近 ``3j`` 的值。" -#: ../../library/functions.rst:1565 +#: ../../library/functions.rst:1580 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 " @@ -2766,11 +2779,11 @@ msgstr "" "與 *mod* 互質。在這種情況下,會回傳 ``pow(inv_base, -exp, mod)``,其中 " "*inv_base* 是 *base* 對 *mod* 的模倒數 (inverse modulo)。" -#: ../../library/functions.rst:1571 +#: ../../library/functions.rst:1586 msgid "Here's an example of computing an inverse for ``38`` modulo ``97``::" msgstr "以下是一個計算 ``38`` 對 ``97`` 取模倒數的範例: ::" -#: ../../library/functions.rst:1573 +#: ../../library/functions.rst:1588 msgid "" ">>> pow(38, -1, mod=97)\n" "23\n" @@ -2782,7 +2795,7 @@ msgstr "" ">>> 23 * 38 % 97 == 1\n" "True" -#: ../../library/functions.rst:1578 +#: ../../library/functions.rst:1593 msgid "" "For :class:`int` operands, the three-argument form of ``pow`` now allows the " "second argument to be negative, permitting computation of modular inverses." @@ -2790,12 +2803,12 @@ msgstr "" "對於 :class:`int` 運算元,現在 ``pow`` 的三引數形式允許第二個引數為負數,也容" "許模倒數的計算。" -#: ../../library/functions.rst:1583 +#: ../../library/functions.rst:1598 msgid "" "Allow keyword arguments. Formerly, only positional arguments were supported." msgstr "允許關鍵字引數。在此之前只支援位置引數。" -#: ../../library/functions.rst:1590 +#: ../../library/functions.rst:1605 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 " @@ -2804,7 +2817,7 @@ msgstr "" "將 *objects* 列印到文字資料串流 *file*,用 *sep* 分隔並以 *end* 結尾。如果有" "給定 *sep*、*end*、*file* 和 *flush*,那麼它們必須是關鍵字引數的形式。" -#: ../../library/functions.rst:1594 +#: ../../library/functions.rst:1609 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* " @@ -2817,7 +2830,7 @@ msgstr "" "以是 ``None``,這表示使用預設值。如果沒有給定 *objects*,:func:`print` 就只會" "寫入 *end*。" -#: ../../library/functions.rst:1600 +#: ../../library/functions.rst:1615 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 " @@ -2829,7 +2842,7 @@ msgstr "" "串,所以 :func:`print` 不能用於二進位模式的檔案物件。對於此類物件,請改用 " "``file.write(...)``。" -#: ../../library/functions.rst:1605 +#: ../../library/functions.rst:1620 msgid "" "Output buffering is usually determined by *file*. However, if *flush* is " "true, the stream is forcibly flushed." @@ -2837,15 +2850,15 @@ msgstr "" "輸出緩衝通常會由 *file* 決定。但是如果 *flush* 為 true,則資料串流會被強制清" "除。" -#: ../../library/functions.rst:1609 +#: ../../library/functions.rst:1624 msgid "Added the *flush* keyword argument." msgstr "增加了 *flush* 關鍵字引數。" -#: ../../library/functions.rst:1615 +#: ../../library/functions.rst:1630 msgid "Return a property attribute." msgstr "回傳 property 屬性。" -#: ../../library/functions.rst:1617 +#: ../../library/functions.rst:1632 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 " @@ -2854,11 +2867,11 @@ msgstr "" "*fget* 是一個用於取得屬性值的函式,*fset* 是一個用於設定屬性值的函式,*fdel* " "是一個用於刪除屬性值的函式,而 *doc* 會為該屬性建立一個說明字串。" -#: ../../library/functions.rst:1621 +#: ../../library/functions.rst:1636 msgid "A typical use is to define a managed attribute ``x``::" msgstr "一個典型的用途是定義一個受管理的屬性 ``x``: ::" -#: ../../library/functions.rst:1623 +#: ../../library/functions.rst:1638 msgid "" "class C:\n" " def __init__(self):\n" @@ -2890,7 +2903,7 @@ msgstr "" "\n" " x = property(getx, setx, delx, \"I'm the 'x' property.\")" -#: ../../library/functions.rst:1638 +#: ../../library/functions.rst:1653 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." @@ -2898,7 +2911,7 @@ msgstr "" "如果 *c* 是 *C* 的一個實例,則 ``c.x`` 將會呼叫取得器 (getter),``c.x = " "value`` 會呼叫設定器 (setter),而 ``del c.x`` 會呼叫刪除器 (deleter)。" -#: ../../library/functions.rst:1641 +#: ../../library/functions.rst:1656 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 " @@ -2909,7 +2922,7 @@ msgstr "" "*fget* 的說明字串(如果它存在的話)。這樣一來,就能夠輕鬆地使用 :func:" "`property` 作為\\ :term:`裝飾器 `\\ 來建立唯讀屬性: ::" -#: ../../library/functions.rst:1645 +#: ../../library/functions.rst:1660 msgid "" "class Parrot:\n" " def __init__(self):\n" @@ -2921,14 +2934,14 @@ msgid "" " return self._voltage" msgstr "" -#: ../../library/functions.rst:1654 +#: ../../library/functions.rst:1669 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:1662 +#: ../../library/functions.rst:1677 msgid "" "A property object has ``getter``, ``setter``, and ``deleter`` methods usable " "as decorators that create a copy of the property with the corresponding " @@ -2936,7 +2949,7 @@ msgid "" "with an example:" msgstr "" -#: ../../library/functions.rst:1667 +#: ../../library/functions.rst:1682 msgid "" "class C:\n" " def __init__(self):\n" @@ -2972,36 +2985,36 @@ msgstr "" " def x(self):\n" " del self._x" -#: ../../library/functions.rst:1686 +#: ../../library/functions.rst:1701 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:1690 +#: ../../library/functions.rst:1705 msgid "" "The returned property object also has the attributes ``fget``, ``fset``, and " "``fdel`` corresponding to the constructor arguments." msgstr "" -#: ../../library/functions.rst:1693 +#: ../../library/functions.rst:1708 msgid "The docstrings of property objects are now writeable." msgstr "" -#: ../../library/functions.rst:1698 +#: ../../library/functions.rst:1713 msgid "" "Attribute holding the name of the property. The name of the property can be " "changed at runtime." msgstr "" -#: ../../library/functions.rst:1709 +#: ../../library/functions.rst:1724 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:1715 +#: ../../library/functions.rst:1730 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 " @@ -3014,11 +3027,11 @@ msgid "" "raise :exc:`RuntimeError`." msgstr "" -#: ../../library/functions.rst:1726 +#: ../../library/functions.rst:1741 msgid "This class has a custom representation that can be evaluated::" msgstr "" -#: ../../library/functions.rst:1728 +#: ../../library/functions.rst:1743 msgid "" "class Person:\n" " def __init__(self, name, age):\n" @@ -3036,7 +3049,7 @@ msgstr "" " def __repr__(self):\n" " return f\"Person('{self.name}', {self.age})\"" -#: ../../library/functions.rst:1739 +#: ../../library/functions.rst:1754 msgid "" "Return a reverse :term:`iterator`. *seq* must be an object which has a :" "meth:`~object.__reversed__` method or supports the sequence protocol (the :" @@ -3044,14 +3057,14 @@ msgid "" "with integer arguments starting at ``0``)." msgstr "" -#: ../../library/functions.rst:1747 +#: ../../library/functions.rst:1762 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:1751 +#: ../../library/functions.rst:1766 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 " @@ -3062,13 +3075,13 @@ msgid "" "``None``. Otherwise, the return value has the same type as *number*." msgstr "" -#: ../../library/functions.rst:1760 +#: ../../library/functions.rst:1775 msgid "" "For a general Python object ``number``, ``round`` delegates to ``number." "__round__``." msgstr "" -#: ../../library/functions.rst:1765 +#: ../../library/functions.rst:1780 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 " @@ -3077,21 +3090,21 @@ msgid "" "information." msgstr "" -#: ../../library/functions.rst:1777 +#: ../../library/functions.rst:1792 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:1781 +#: ../../library/functions.rst:1796 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:1788 +#: ../../library/functions.rst:1803 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 " @@ -3100,7 +3113,7 @@ msgid "" "is equivalent to ``x.foobar = 123``." msgstr "" -#: ../../library/functions.rst:1794 +#: ../../library/functions.rst:1809 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:" @@ -3109,21 +3122,21 @@ msgid "" "notation, but is accessible through :func:`getattr` etc.." msgstr "" -#: ../../library/functions.rst:1802 +#: ../../library/functions.rst:1817 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:1811 +#: ../../library/functions.rst:1826 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:1819 +#: ../../library/functions.rst:1834 msgid "" "Slice objects have read-only data attributes :attr:`!start`, :attr:`!stop`, " "and :attr:`!step` which merely return the argument values (or their " @@ -3131,48 +3144,48 @@ msgid "" "by NumPy and other third-party packages." msgstr "" -#: ../../library/functions.rst:1824 +#: ../../library/functions.rst:1839 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:1829 +#: ../../library/functions.rst:1844 msgid "" "Slice objects are now :term:`hashable` (provided :attr:`~slice.start`, :attr:" "`~slice.stop`, and :attr:`~slice.step` are hashable)." msgstr "" -#: ../../library/functions.rst:1835 +#: ../../library/functions.rst:1850 msgid "Return a new sorted list from the items in *iterable*." msgstr "" -#: ../../library/functions.rst:1837 +#: ../../library/functions.rst:1852 msgid "" "Has two optional arguments which must be specified as keyword arguments." msgstr "有兩個選擇性引數,只能使用關鍵字引數來指定。" -#: ../../library/functions.rst:1839 +#: ../../library/functions.rst:1854 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:1843 +#: ../../library/functions.rst:1858 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:1846 +#: ../../library/functions.rst:1861 msgid "" "Use :func:`functools.cmp_to_key` to convert an old-style *cmp* function to a " "*key* function." msgstr "" -#: ../../library/functions.rst:1849 +#: ../../library/functions.rst:1864 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 " @@ -3180,7 +3193,7 @@ msgid "" "example, sort by department, then by salary grade)." msgstr "" -#: ../../library/functions.rst:1854 +#: ../../library/functions.rst:1869 msgid "" "The sort algorithm uses only ``<`` comparisons between items. While " "defining an :meth:`~object.__lt__` method will suffice for sorting, :PEP:`8` " @@ -3192,22 +3205,22 @@ msgid "" "method." msgstr "" -#: ../../library/functions.rst:1863 +#: ../../library/functions.rst:1878 msgid "" "For sorting examples and a brief sorting tutorial, see :ref:`sortinghowto`." msgstr "" -#: ../../library/functions.rst:1867 +#: ../../library/functions.rst:1882 msgid "Transform a method into a static method." msgstr "" -#: ../../library/functions.rst:1869 +#: ../../library/functions.rst:1884 msgid "" "A static method does not receive an implicit first argument. To declare a " "static method, use this idiom::" msgstr "" -#: ../../library/functions.rst:1872 +#: ../../library/functions.rst:1887 msgid "" "class C:\n" " @staticmethod\n" @@ -3217,7 +3230,7 @@ msgstr "" " @staticmethod\n" " def f(arg1, arg2, argN): ..." -#: ../../library/functions.rst:1876 +#: ../../library/functions.rst:1891 msgid "" "The ``@staticmethod`` form is a function :term:`decorator` -- see :ref:" "`function` for details." @@ -3225,7 +3238,7 @@ msgstr "" "``@staticmethod`` 語法是一個函式 :term:`decorator` - 參見 :ref:`function` 中" "的詳細介紹。" -#: ../../library/functions.rst:1879 +#: ../../library/functions.rst:1894 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:" @@ -3233,14 +3246,14 @@ msgid "" "(such as ``f()``)." msgstr "" -#: ../../library/functions.rst:1884 +#: ../../library/functions.rst:1899 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:1888 +#: ../../library/functions.rst:1903 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 " @@ -3249,7 +3262,7 @@ msgid "" "cases, use this idiom::" msgstr "" -#: ../../library/functions.rst:1894 +#: ../../library/functions.rst:1909 msgid "" "def regular_function():\n" " ...\n" @@ -3263,36 +3276,41 @@ msgstr "" "class C:\n" " method = staticmethod(regular_function)" -#: ../../library/functions.rst:1900 +#: ../../library/functions.rst:1915 msgid "For more information on static methods, see :ref:`types`." msgstr "關於 static method 的更多資訊,請參考 :ref:`types`。" -#: ../../library/functions.rst:1902 +#: ../../library/functions.rst:1917 +#, fuzzy msgid "" -"Static methods now inherit the method attributes (``__module__``, " -"``__name__``, ``__qualname__``, ``__doc__`` and ``__annotations__``), have a " -"new ``__wrapped__`` attribute, and are now callable as regular functions." +"Static methods now inherit the method attributes (:attr:`~function." +"__module__`, :attr:`~function.__name__`, :attr:`~function.__qualname__`, :" +"attr:`~function.__doc__` and :attr:`~function.__annotations__`), have a new " +"``__wrapped__`` attribute, and are now callable as regular functions." msgstr "" +"Class method 現在繼承了 method 屬性(``__module__``、``__name__``、" +"``__qualname__``、``__doc__`` 和 ``__annotations__``),並擁有一個新的 " +"``__wrapped__`` 屬性。" -#: ../../library/functions.rst:1917 +#: ../../library/functions.rst:1933 msgid "" "Return a :class:`str` version of *object*. See :func:`str` for details." msgstr "" -#: ../../library/functions.rst:1919 +#: ../../library/functions.rst:1935 msgid "" "``str`` is the built-in string :term:`class`. For general information about " "strings, see :ref:`textseq`." msgstr "" -#: ../../library/functions.rst:1925 +#: ../../library/functions.rst:1941 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:1929 +#: ../../library/functions.rst:1945 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 ``''." @@ -3301,45 +3319,45 @@ msgid "" "using :func:`itertools.chain`." msgstr "" -#: ../../library/functions.rst:1935 +#: ../../library/functions.rst:1951 msgid "The *start* parameter can be specified as a keyword argument." msgstr "*start* 參數可被指定為關鍵字引數。" -#: ../../library/functions.rst:1938 +#: ../../library/functions.rst:1954 msgid "" "Summation of floats switched to an algorithm that gives higher accuracy and " "better commutativity on most builds." msgstr "" -#: ../../library/functions.rst:1945 +#: ../../library/functions.rst:1961 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:1949 +#: ../../library/functions.rst:1965 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:1953 +#: ../../library/functions.rst:1969 msgid "" -"For example, if :attr:`~class.__mro__` of *object_or_type* is ``D -> B -> C -" +"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:1957 +#: ../../library/functions.rst:1973 msgid "" -"The :attr:`~class.__mro__` attribute of the class corresponding to " +"The :attr:`~type.__mro__` attribute of the class corresponding to " "*object_or_type* lists the method resolution search order used by both :func:" "`getattr` and :func:`super`. The attribute is dynamic and can change " "whenever the inheritance hierarchy is updated." msgstr "" -#: ../../library/functions.rst:1962 +#: ../../library/functions.rst:1978 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. " @@ -3347,7 +3365,7 @@ msgid "" "(this is useful for classmethods)." msgstr "" -#: ../../library/functions.rst:1967 +#: ../../library/functions.rst:1983 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 " @@ -3357,7 +3375,7 @@ msgid "" "including generator expressions, which implicitly create nested functions.)" msgstr "" -#: ../../library/functions.rst:1974 +#: ../../library/functions.rst:1990 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 " @@ -3365,7 +3383,7 @@ msgid "" "closely parallels the use of *super* in other programming languages." msgstr "" -#: ../../library/functions.rst:1979 +#: ../../library/functions.rst:1995 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 " @@ -3378,11 +3396,11 @@ msgid "" "classes that are unknown prior to runtime)." msgstr "" -#: ../../library/functions.rst:1989 +#: ../../library/functions.rst:2005 msgid "For both use cases, a typical superclass call looks like this::" msgstr "" -#: ../../library/functions.rst:1991 +#: ../../library/functions.rst:2007 msgid "" "class C(B):\n" " def method(self, arg):\n" @@ -3390,14 +3408,14 @@ msgid "" " # super(C, self).method(arg)" msgstr "" -#: ../../library/functions.rst:1996 +#: ../../library/functions.rst:2012 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:2000 +#: ../../library/functions.rst:2016 msgid "" "Note that :func:`super` is implemented as part of the binding process for " "explicit dotted attribute lookups such as ``super().__getitem__(name)``. It " @@ -3407,7 +3425,7 @@ msgid "" "using statements or operators such as ``super()[name]``." msgstr "" -#: ../../library/functions.rst:2008 +#: ../../library/functions.rst:2024 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 " @@ -3417,50 +3435,61 @@ msgid "" "accessing the current instance for ordinary methods." msgstr "" -#: ../../library/functions.rst:2015 +#: ../../library/functions.rst:2031 msgid "" "For practical suggestions on how to design cooperative classes using :func:" "`super`, see `guide to using super() `_." msgstr "" -#: ../../library/functions.rst:2025 +#: ../../library/functions.rst:2041 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:2034 +#: ../../library/functions.rst:2050 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__ `." +"__class__`." msgstr "" -#: ../../library/functions.rst:2038 +#: ../../library/functions.rst:2054 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:2042 +#: ../../library/functions.rst:2057 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 " -"class name and becomes the :attr:`~definition.__name__` attribute. The " -"*bases* tuple contains the base classes and becomes the :attr:`~class." -"__bases__` attribute; if empty, :class:`object`, the ultimate base of all " -"classes, is added. The *dict* dictionary contains attribute and method " -"definitions for the class body; it may be copied or wrapped before becoming " -"the :attr:`~object.__dict__` attribute. The following two statements create " -"identical :class:`type` objects:" +"class name and becomes the :attr:`~type.__name__` attribute. The *bases* " +"tuple contains the base classes and becomes the :attr:`~type.__bases__` " +"attribute; if empty, :class:`object`, the ultimate base of all classes, is " +"added. The *dict* dictionary contains attribute and method definitions for " +"the class body; it may be copied or wrapped before becoming the :attr:`~type." +"__dict__` attribute. The following two statements create identical :class:`!" +"type` objects:" msgstr "" -#: ../../library/functions.rst:2057 -msgid "See also :ref:`bltin-type-objects`." +#: ../../library/functions.rst:2072 +msgid "See also:" +msgstr "" + +#: ../../library/functions.rst:2074 +msgid "" +":ref:`Documentation on attributes and methods on classes `." +msgstr "" + +#: ../../library/functions.rst:2075 +#, fuzzy +msgid ":ref:`bltin-type-objects`" msgstr "另請參閱 :ref:`bltin-type-objects`。" -#: ../../library/functions.rst:2059 +#: ../../library/functions.rst:2077 msgid "" "Keyword arguments provided to the three argument form are passed to the " "appropriate metaclass machinery (usually :meth:`~object.__init_subclass__`) " @@ -3468,58 +3497,58 @@ msgid "" "would." msgstr "" -#: ../../library/functions.rst:2064 +#: ../../library/functions.rst:2082 msgid "See also :ref:`class-customization`." msgstr "另請參閱 :ref:`class-customization`。" -#: ../../library/functions.rst:2066 +#: ../../library/functions.rst:2084 msgid "" -"Subclasses of :class:`type` which don't override ``type.__new__`` may no " +"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:2073 +#: ../../library/functions.rst:2091 msgid "" "Return the :attr:`~object.__dict__` attribute for a module, class, instance, " -"or any other object with a :attr:`~object.__dict__` attribute." +"or any other object with a :attr:`!__dict__` attribute." msgstr "" -#: ../../library/functions.rst:2076 +#: ../../library/functions.rst:2094 msgid "" "Objects such as modules and instances have an updateable :attr:`~object." "__dict__` attribute; however, other objects may have write restrictions on " -"their :attr:`~object.__dict__` attributes (for example, classes use a :class:" -"`types.MappingProxyType` to prevent direct dictionary updates)." +"their :attr:`!__dict__` attributes (for example, classes use a :class:`types." +"MappingProxyType` to prevent direct dictionary updates)." msgstr "" -#: ../../library/functions.rst:2081 +#: ../../library/functions.rst:2099 msgid "Without an argument, :func:`vars` acts like :func:`locals`." msgstr "" -#: ../../library/functions.rst:2083 +#: ../../library/functions.rst:2101 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:2089 +#: ../../library/functions.rst:2107 msgid "" "The result of calling this function without an argument has been updated as " "described for the :func:`locals` builtin." msgstr "" -#: ../../library/functions.rst:2095 +#: ../../library/functions.rst:2113 msgid "" "Iterate over several iterables in parallel, producing tuples with an item " "from each one." msgstr "" -#: ../../library/functions.rst:2098 +#: ../../library/functions.rst:2116 msgid "Example::" msgstr "例如: ::" -#: ../../library/functions.rst:2100 +#: ../../library/functions.rst:2118 msgid "" ">>> for item in zip([1, 2, 3], ['sugar', 'spice', 'everything nice']):\n" "... print(item)\n" @@ -3535,27 +3564,27 @@ msgstr "" "(2, 'spice')\n" "(3, 'everything nice')" -#: ../../library/functions.rst:2107 +#: ../../library/functions.rst:2125 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:2110 +#: ../../library/functions.rst:2128 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:2114 +#: ../../library/functions.rst:2132 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:2118 +#: ../../library/functions.rst:2136 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 " @@ -3563,14 +3592,14 @@ msgid "" "approaches to dealing with this issue:" msgstr "" -#: ../../library/functions.rst:2123 +#: ../../library/functions.rst:2141 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:2127 +#: ../../library/functions.rst:2145 msgid "" ">>> list(zip(range(3), ['fee', 'fi', 'fo', 'fum']))\n" "[(0, 'fee'), (1, 'fi'), (2, 'fo')]" @@ -3578,14 +3607,14 @@ msgstr "" ">>> list(zip(range(3), ['fee', 'fi', 'fo', 'fum']))\n" "[(0, 'fee'), (1, 'fi'), (2, 'fo')]" -#: ../../library/functions.rst:2130 +#: ../../library/functions.rst:2148 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:2134 +#: ../../library/functions.rst:2152 msgid "" ">>> list(zip(('a', 'b', 'c'), (1, 2, 3), strict=True))\n" "[('a', 1), ('b', 2), ('c', 3)]" @@ -3593,37 +3622,37 @@ msgstr "" ">>> list(zip(('a', 'b', 'c'), (1, 2, 3), strict=True))\n" "[('a', 1), ('b', 2), ('c', 3)]" -#: ../../library/functions.rst:2137 +#: ../../library/functions.rst:2155 msgid "" "Unlike the default behavior, it raises a :exc:`ValueError` if one iterable " "is exhausted before the others:" msgstr "" -#: ../../library/functions.rst:2155 +#: ../../library/functions.rst:2173 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:2159 +#: ../../library/functions.rst:2177 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:2163 +#: ../../library/functions.rst:2181 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:2166 +#: ../../library/functions.rst:2184 msgid "Tips and tricks:" msgstr "" -#: ../../library/functions.rst:2168 +#: ../../library/functions.rst:2186 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 " @@ -3632,13 +3661,13 @@ msgid "" "iterator. This has the effect of dividing the input into n-length chunks." msgstr "" -#: ../../library/functions.rst:2174 +#: ../../library/functions.rst:2192 msgid "" ":func:`zip` in conjunction with the ``*`` operator can be used to unzip a " "list::" msgstr "" -#: ../../library/functions.rst:2177 +#: ../../library/functions.rst:2195 msgid "" ">>> x = [1, 2, 3]\n" ">>> y = [4, 5, 6]\n" @@ -3656,17 +3685,17 @@ msgstr "" ">>> x == list(x2) and y == list(y2)\n" "True" -#: ../../library/functions.rst:2185 +#: ../../library/functions.rst:2203 msgid "Added the ``strict`` argument." msgstr "增加了 ``strict`` 引數。" -#: ../../library/functions.rst:2197 +#: ../../library/functions.rst:2215 msgid "" "This is an advanced function that is not needed in everyday Python " "programming, unlike :func:`importlib.import_module`." msgstr "" -#: ../../library/functions.rst:2200 +#: ../../library/functions.rst:2218 msgid "" "This function is invoked by the :keyword:`import` statement. It can be " "replaced (by importing the :mod:`builtins` module and assigning to " @@ -3678,7 +3707,7 @@ msgid "" "discouraged in favor of :func:`importlib.import_module`." msgstr "" -#: ../../library/functions.rst:2209 +#: ../../library/functions.rst:2227 msgid "" "The function imports the module *name*, potentially using the given " "*globals* and *locals* to determine how to interpret the name in a package " @@ -3688,7 +3717,7 @@ msgid "" "determine the package context of the :keyword:`import` statement." msgstr "" -#: ../../library/functions.rst:2216 +#: ../../library/functions.rst:2234 msgid "" "*level* specifies whether to use absolute or relative imports. ``0`` (the " "default) means only perform absolute imports. Positive values for *level* " @@ -3697,7 +3726,7 @@ msgid "" "details)." msgstr "" -#: ../../library/functions.rst:2222 +#: ../../library/functions.rst:2240 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 " @@ -3705,37 +3734,37 @@ msgid "" "given, the module named by *name* is returned." msgstr "" -#: ../../library/functions.rst:2227 +#: ../../library/functions.rst:2245 msgid "" "For example, the statement ``import spam`` results in bytecode resembling " "the following code::" msgstr "" -#: ../../library/functions.rst:2230 +#: ../../library/functions.rst:2248 msgid "spam = __import__('spam', globals(), locals(), [], 0)" msgstr "spam = __import__('spam', globals(), locals(), [], 0)" -#: ../../library/functions.rst:2232 +#: ../../library/functions.rst:2250 msgid "The statement ``import spam.ham`` results in this call::" msgstr "" -#: ../../library/functions.rst:2234 +#: ../../library/functions.rst:2252 msgid "spam = __import__('spam.ham', globals(), locals(), [], 0)" msgstr "spam = __import__('spam.ham', globals(), locals(), [], 0)" -#: ../../library/functions.rst:2236 +#: ../../library/functions.rst:2254 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:2239 +#: ../../library/functions.rst:2257 msgid "" "On the other hand, the statement ``from spam.ham import eggs, sausage as " "saus`` results in ::" msgstr "" -#: ../../library/functions.rst:2242 +#: ../../library/functions.rst:2260 msgid "" "_temp = __import__('spam.ham', globals(), locals(), ['eggs', 'sausage'], 0)\n" "eggs = _temp.eggs\n" @@ -3745,36 +3774,36 @@ msgstr "" "eggs = _temp.eggs\n" "saus = _temp.sausage" -#: ../../library/functions.rst:2246 +#: ../../library/functions.rst:2264 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:2250 +#: ../../library/functions.rst:2268 msgid "" "If you simply want to import a module (potentially within a package) by " "name, use :func:`importlib.import_module`." msgstr "" -#: ../../library/functions.rst:2253 +#: ../../library/functions.rst:2271 msgid "" "Negative values for *level* are no longer supported (which also changes the " "default value to 0)." msgstr "" -#: ../../library/functions.rst:2257 +#: ../../library/functions.rst:2275 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:2262 +#: ../../library/functions.rst:2280 msgid "Footnotes" msgstr "註解" -#: ../../library/functions.rst:2263 +#: ../../library/functions.rst:2281 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 " @@ -3787,107 +3816,107 @@ msgstr "" msgid "Boolean" msgstr "Boolean(布林值)" -#: ../../library/functions.rst:154 ../../library/functions.rst:2032 +#: ../../library/functions.rst:154 ../../library/functions.rst:2048 msgid "type" msgstr "type(型別)" -#: ../../library/functions.rst:641 +#: ../../library/functions.rst:648 msgid "built-in function" msgstr "built-in function(內建函式)" -#: ../../library/functions.rst:641 +#: ../../library/functions.rst:648 msgid "exec" msgstr "exec" -#: ../../library/functions.rst:733 +#: ../../library/functions.rst:746 msgid "NaN" msgstr "NaN" -#: ../../library/functions.rst:733 +#: ../../library/functions.rst:746 msgid "Infinity" msgstr "Infinity(無窮)" -#: ../../library/functions.rst:801 +#: ../../library/functions.rst:814 msgid "__format__" msgstr "__format__" -#: ../../library/functions.rst:801 ../../library/functions.rst:1909 +#: ../../library/functions.rst:814 ../../library/functions.rst:1925 msgid "string" msgstr "string(字串)" -#: ../../library/functions.rst:801 +#: ../../library/functions.rst:814 msgid "format() (built-in function)" msgstr "format()(內建函式)" -#: ../../library/functions.rst:1310 +#: ../../library/functions.rst:1325 msgid "file object" msgstr "file object(檔案物件)" -#: ../../library/functions.rst:1310 ../../library/functions.rst:1431 +#: ../../library/functions.rst:1325 ../../library/functions.rst:1446 msgid "open() built-in function" msgstr "open() 內建函式" -#: ../../library/functions.rst:1338 +#: ../../library/functions.rst:1353 msgid "file" msgstr "file(檔案)" -#: ../../library/functions.rst:1338 +#: ../../library/functions.rst:1353 msgid "modes" msgstr "modes(模式)" -#: ../../library/functions.rst:1431 +#: ../../library/functions.rst:1446 msgid "universal newlines" msgstr "universal newlines" -#: ../../library/functions.rst:1492 +#: ../../library/functions.rst:1507 msgid "line-buffered I/O" msgstr "line-buffered I/O(行緩衝 I/O)" -#: ../../library/functions.rst:1492 +#: ../../library/functions.rst:1507 msgid "unbuffered I/O" msgstr "unbuffered I/O(非緩衝 I/O)" -#: ../../library/functions.rst:1492 +#: ../../library/functions.rst:1507 msgid "buffer size, I/O" msgstr "buffer size, I/O(緩衝區大小、I/O)" -#: ../../library/functions.rst:1492 +#: ../../library/functions.rst:1507 msgid "I/O control" msgstr "I/O control(I/O 控制)" -#: ../../library/functions.rst:1492 +#: ../../library/functions.rst:1507 msgid "buffering" msgstr "buffering(緩衝)" -#: ../../library/functions.rst:1492 +#: ../../library/functions.rst:1507 msgid "text mode" msgstr "text mode(文字模式)" -#: ../../library/functions.rst:1492 ../../library/functions.rst:2191 +#: ../../library/functions.rst:1507 ../../library/functions.rst:2209 msgid "module" msgstr "module(模組)" -#: ../../library/functions.rst:1492 +#: ../../library/functions.rst:1507 msgid "sys" msgstr "sys" -#: ../../library/functions.rst:1909 +#: ../../library/functions.rst:1925 msgid "str() (built-in function)" msgstr "str() (內建函式)" -#: ../../library/functions.rst:2032 +#: ../../library/functions.rst:2048 msgid "object" msgstr "object(物件)" -#: ../../library/functions.rst:2191 +#: ../../library/functions.rst:2209 msgid "statement" msgstr "statement(陳述式)" -#: ../../library/functions.rst:2191 +#: ../../library/functions.rst:2209 msgid "import" msgstr "import(引入)" -#: ../../library/functions.rst:2191 +#: ../../library/functions.rst:2209 msgid "builtins" msgstr "builtins(內建)" diff --git a/library/functools.po b/library/functools.po index 280a86fb33..c5113ff4be 100644 --- a/library/functools.po +++ b/library/functools.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2024-10-04 16:20+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-" @@ -397,7 +397,7 @@ msgstr "" #, fuzzy msgid "" "An `LRU (least recently used) cache `_ works best when the " +"Cache_replacement_policies#Least_Recently_Used_(LRU)>`_ works best when the " "most recent calls are the best predictors of upcoming calls (for example, " "the most popular articles on a news server tend to change each day). The " "cache's size limit assures that the cache does not grow without bound on " @@ -878,7 +878,46 @@ msgstr "" "... print(arg.real, arg.imag)\n" "..." -#: ../../library/functools.rst:496 +#: ../../library/functools.rst:495 +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 " +"type should be passed explicitly to the decorator itself with the typehint " +"going into the function definition::" +msgstr "" + +#: ../../library/functools.rst:500 +#, fuzzy +msgid "" +">>> @fun.register(list)\n" +"... def _(arg: list[int], verbose=False):\n" +"... if verbose:\n" +"... print(\"Enumerate this:\")\n" +"... for i, elem in enumerate(arg):\n" +"... print(i, elem)" +msgstr "" +">>> @fun.register\n" +"... def _(arg: int, verbose=False):\n" +"... if verbose:\n" +"... print(\"Strength in numbers, eh?\", end=\" \")\n" +"... print(arg)\n" +"...\n" +">>> @fun.register\n" +"... def _(arg: list, verbose=False):\n" +"... if verbose:\n" +"... print(\"Enumerate this:\")\n" +"... for i, elem in enumerate(arg):\n" +"... print(i, elem)" + +#: ../../library/functools.rst:509 +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 " +"same as ``[\"foo\", \"bar\", \"baz\"]``. The annotation provided in this " +"example is for static type checkers only and has no runtime impact." +msgstr "" + +#: ../../library/functools.rst:515 msgid "" "To enable registering :term:`lambdas` and pre-existing functions, " "the :func:`register` attribute can also be used in a functional form::" @@ -886,7 +925,7 @@ msgstr "" "若要啟用註冊 :term:`lambdas` 和預先存在的函式,:func:`register` 屬性" "也能以函式形式使用: ::" -#: ../../library/functools.rst:499 +#: ../../library/functools.rst:518 msgid "" ">>> def nothing(arg, verbose=False):\n" "... print(\"Nothing.\")\n" @@ -898,7 +937,7 @@ msgstr "" "...\n" ">>> fun.register(type(None), nothing)" -#: ../../library/functools.rst:504 +#: ../../library/functools.rst:523 msgid "" "The :func:`register` attribute returns the undecorated function. This " "enables decorator stacking, :mod:`pickling`, and the creation of " @@ -907,7 +946,7 @@ msgstr "" ":func:`register` 屬性回傳未加裝飾器的函式。這讓使得裝飾器堆疊 (decorator " "stacking)、:mod:`pickling` 以及為每個變體獨立建立單元測試成為可能:" -#: ../../library/functools.rst:508 +#: ../../library/functools.rst:527 msgid "" ">>> @fun.register(float)\n" "... @fun.register(Decimal)\n" @@ -929,13 +968,13 @@ msgstr "" ">>> fun_num is fun\n" "False" -#: ../../library/functools.rst:518 +#: ../../library/functools.rst:537 msgid "" "When called, the generic function dispatches on the type of the first " "argument::" msgstr "呼叫時,泛型函式會分派第一個引數的型別: ::" -#: ../../library/functools.rst:521 +#: ../../library/functools.rst:540 msgid "" ">>> fun(\"Hello, world.\")\n" "Hello, world.\n" @@ -971,7 +1010,7 @@ msgstr "" ">>> fun(1.23)\n" "0.615" -#: ../../library/functools.rst:538 +#: ../../library/functools.rst:557 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 " @@ -983,7 +1022,7 @@ msgstr "" "尋找更通用的實作。用 ``@singledispatch`` 裝飾的原始函式是為基底 :class:" "`object` 型別註冊的,這意味著如果沒有找到更好的實作就會使用它。" -#: ../../library/functools.rst:544 +#: ../../library/functools.rst:563 msgid "" "If an implementation is registered to an :term:`abstract base class`, " "virtual subclasses of the base class will be dispatched to that " @@ -992,7 +1031,7 @@ msgstr "" "如果一個實作有被註冊到一個\\ :term:`抽象基底類別 `,則基" "底類別的虛擬子類別將被分派到該實作: ::" -#: ../../library/functools.rst:548 +#: ../../library/functools.rst:567 msgid "" ">>> from collections.abc import Mapping\n" ">>> @fun.register\n" @@ -1016,14 +1055,14 @@ msgstr "" ">>> fun({\"a\": \"b\"})\n" "a => b" -#: ../../library/functools.rst:559 +#: ../../library/functools.rst:578 msgid "" "To check which implementation the generic function will choose for a given " "type, use the ``dispatch()`` attribute::" msgstr "" "若要檢查泛型函式將為給定型別選擇哪種實作,請使用 ``dispatch()`` 屬性: ::" -#: ../../library/functools.rst:562 +#: ../../library/functools.rst:581 msgid "" ">>> fun.dispatch(float)\n" "\n" @@ -1031,13 +1070,13 @@ msgid "" "" msgstr "" -#: ../../library/functools.rst:567 +#: ../../library/functools.rst:586 msgid "" "To access all registered implementations, use the read-only ``registry`` " "attribute::" msgstr "若要存取所有已註冊的實作,請使用唯讀 ``registry`` 屬性: ::" -#: ../../library/functools.rst:570 +#: ../../library/functools.rst:589 msgid "" ">>> fun.registry.keys()\n" "dict_keys([, , ,\n" @@ -1057,11 +1096,11 @@ msgstr "" ">>> fun.registry[object]\n" "" -#: ../../library/functools.rst:581 +#: ../../library/functools.rst:600 msgid "The :func:`register` attribute now supports using type annotations." msgstr ":func:`register` 屬性現在支援使用型別註釋。" -#: ../../library/functools.rst:584 +#: ../../library/functools.rst:603 msgid "" "The :func:`register` attribute now supports :data:`types.UnionType` and :" "data:`typing.Union` as type annotations." @@ -1069,7 +1108,7 @@ msgstr "" ":func:`register` 屬性現在支援以 :data:`types.UnionType` 和 :data:`typing." "Union` 作為型別註釋。" -#: ../../library/functools.rst:591 +#: ../../library/functools.rst:610 msgid "" "Transform a method into a :term:`single-dispatch ` :term:" "`generic function`." @@ -1077,7 +1116,7 @@ msgstr "" "將方法轉換為\\ :term:`單一調度 `\\ :term:`泛型函式 `。" -#: ../../library/functools.rst:594 +#: ../../library/functools.rst:613 msgid "" "To define a generic method, decorate it with the ``@singledispatchmethod`` " "decorator. When defining a function using ``@singledispatchmethod``, note " @@ -1088,7 +1127,7 @@ msgstr "" "用 ``@singledispatchmethod`` 定義函式時,分派調度是發生在第一個非 *self* 或" "非 *cls* 引數的型別上: ::" -#: ../../library/functools.rst:599 +#: ../../library/functools.rst:618 msgid "" "class Negator:\n" " @singledispatchmethod\n" @@ -1116,7 +1155,7 @@ msgstr "" " def _(self, arg: bool):\n" " return not arg" -#: ../../library/functools.rst:612 +#: ../../library/functools.rst:631 msgid "" "``@singledispatchmethod`` supports nesting with other decorators such as :" "func:`@classmethod`. Note that to allow for ``dispatcher." @@ -1129,7 +1168,7 @@ msgstr "" "``singledispatchmethod`` 必須是\\ *最外面的*\\ 裝飾器。以下範例是 " "``Negator`` 類別,其 ``neg`` 方法繫結到該類別,而不是該類別的實例: ::" -#: ../../library/functools.rst:618 +#: ../../library/functools.rst:637 msgid "" "class Negator:\n" " @singledispatchmethod\n" @@ -1163,7 +1202,7 @@ msgstr "" " def _(cls, arg: bool):\n" " return not arg" -#: ../../library/functools.rst:634 +#: ../../library/functools.rst:653 msgid "" "The same pattern can be used for other similar decorators: :func:" "`@staticmethod`, :func:`@abstractmethod`, " @@ -1172,7 +1211,8 @@ msgstr "" "相同的模式可用於其他類似的裝飾器::func:`@staticmethod`、:func:" "`@abstractmethod` 等。" -#: ../../library/functools.rst:643 +#: ../../library/functools.rst:662 +#, fuzzy msgid "" "Update a *wrapper* function to look like the *wrapped* function. The " "optional arguments are tuples to specify which attributes of the original " @@ -1180,10 +1220,12 @@ msgid "" "function and which attributes of the wrapper function are updated with the " "corresponding attributes from the original function. The default values for " "these arguments are the module level constants ``WRAPPER_ASSIGNMENTS`` " -"(which assigns to the wrapper function's ``__module__``, ``__name__``, " -"``__qualname__``, ``__annotations__``, ``__type_params__``, and ``__doc__``, " -"the documentation string) and ``WRAPPER_UPDATES`` (which updates the wrapper " -"function's ``__dict__``, i.e. the instance dictionary)." +"(which assigns to the wrapper function's :attr:`~function.__module__`, :attr:" +"`~function.__name__`, :attr:`~function.__qualname__`, :attr:`~function." +"__annotations__`, :attr:`~function.__type_params__`, and :attr:`~function." +"__doc__`, the documentation string) and ``WRAPPER_UPDATES`` (which updates " +"the wrapper function's :attr:`~function.__dict__`, i.e. the instance " +"dictionary)." msgstr "" "更新 *wrapper* 函式,使其看起來像 *wrapped* 函式。可選引數是元組,用於指定原" "始函式的哪些屬性直接賦值給包裝函式上的匹配屬性,以及包裝函式的哪些屬性使用原" @@ -1192,7 +1234,7 @@ msgstr "" "``__qualname__``、``__annotations__`` 和 ``__doc__`` 文件字串 (docstring)和 " "``WRAPPER_UPDATES``\\ (更新包裝器函式的 ``__dict__``,即實例字典)。" -#: ../../library/functools.rst:654 +#: ../../library/functools.rst:674 msgid "" "To allow access to the original function for introspection and other " "purposes (e.g. bypassing a caching decorator such as :func:`lru_cache`), " @@ -1203,7 +1245,7 @@ msgstr "" "飾器,如 :func:`lru_cache`),此函式會自動向包裝器新增 ``__wrapped__`` 屬性," "該包裝器參照被包裝的函式。" -#: ../../library/functools.rst:659 +#: ../../library/functools.rst:679 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 " @@ -1215,7 +1257,7 @@ msgstr "" "裝器函式未更新,則回傳函式的元資料 (metadata) 將反映包裝器定義而非原始函式定" "義,這通常不太會有幫助。" -#: ../../library/functools.rst:665 +#: ../../library/functools.rst:685 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 " @@ -1228,16 +1270,17 @@ msgstr "" "器函式上設定它們)。如果包裝函式本身缺少 *updated* 中指定的任何屬性,仍然會引" "發 :exc:`AttributeError`。" -#: ../../library/functools.rst:671 +#: ../../library/functools.rst:691 +#, fuzzy msgid "" -"The ``__wrapped__`` attribute is now automatically added. The " -"``__annotations__`` attribute is now copied by default. Missing attributes " -"no longer trigger an :exc:`AttributeError`." +"The ``__wrapped__`` attribute is now automatically added. The :attr:" +"`~function.__annotations__` attribute is now copied by default. Missing " +"attributes no longer trigger an :exc:`AttributeError`." msgstr "" "現在會自動新增 ``__wrapped__`` 屬性。現在預設會複製 ``__annotations__`` 屬" "性。缺少的屬性不再觸發 :exc:`AttributeError`。" -#: ../../library/functools.rst:676 +#: ../../library/functools.rst:696 msgid "" "The ``__wrapped__`` attribute now always refers to the wrapped function, " "even if that function defined a ``__wrapped__`` attribute. (see :issue:" @@ -1246,11 +1289,13 @@ msgstr "" "``__wrapped__`` 屬性現在都會參照包裝函式,即便函式有定義 ``__wrapped__`` 屬" "性。(參見 :issue:`17482`)" -#: ../../library/functools.rst:681 -msgid "The ``__type_params__`` attribute is now copied by default." +#: ../../library/functools.rst:701 +#, fuzzy +msgid "" +"The :attr:`~function.__type_params__` attribute is now copied by default." msgstr "現在預設會複製 ``__type_params__`` 屬性。" -#: ../../library/functools.rst:687 +#: ../../library/functools.rst:707 msgid "" "This is a convenience function for invoking :func:`update_wrapper` as a " "function decorator when defining a wrapper function. It is equivalent to " @@ -1261,7 +1306,7 @@ msgstr "" "式裝飾器。它相當於 ``partial(update_wrapper, wrapped=wrapped, " "assigned=assigned, updated=updated)``。例如: ::" -#: ../../library/functools.rst:692 +#: ../../library/functools.rst:712 msgid "" ">>> from functools import wraps\n" ">>> def my_decorator(f):\n" @@ -1285,7 +1330,7 @@ msgid "" "'Docstring'" msgstr "" -#: ../../library/functools.rst:713 +#: ../../library/functools.rst:733 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:" @@ -1294,11 +1339,11 @@ msgstr "" "如果不使用這個裝飾器工廠 (decorator factory),範例函式的名稱將會是 " "``'wrapper'``,並且原始 :func:`example` 的文件字串將會遺失。" -#: ../../library/functools.rst:721 +#: ../../library/functools.rst:741 msgid ":class:`partial` Objects" msgstr ":class:`partial` 物件" -#: ../../library/functools.rst:723 +#: ../../library/functools.rst:743 msgid "" ":class:`partial` objects are callable objects created by :func:`partial`. " "They have three read-only attributes:" @@ -1306,7 +1351,7 @@ msgstr "" ":class:`partial` 物件是由 :func:`partial` 所建立的可呼叫物件。它們有三個唯讀" "屬性:" -#: ../../library/functools.rst:729 +#: ../../library/functools.rst:749 msgid "" "A callable object or function. Calls to the :class:`partial` object will be " "forwarded to :attr:`func` with new arguments and keywords." @@ -1314,7 +1359,7 @@ msgstr "" "一個可呼叫的物件或函式。對 :class:`partial` 物件的呼叫將被轉送到帶有新引數和" "關鍵字的 :attr:`func`。" -#: ../../library/functools.rst:735 +#: ../../library/functools.rst:755 msgid "" "The leftmost positional arguments that will be prepended to the positional " "arguments provided to a :class:`partial` object call." @@ -1322,20 +1367,22 @@ msgstr "" "最左邊的位置引數將會被加入到提供給 :class:`partial` 物件呼叫的位置引數的前" "面。" -#: ../../library/functools.rst:741 +#: ../../library/functools.rst:761 msgid "" "The keyword arguments that will be supplied when the :class:`partial` object " "is called." msgstr "呼叫 :class:`partial` 物件時將提供的關鍵字引數。" -#: ../../library/functools.rst:744 +#: ../../library/functools.rst:764 +#, fuzzy msgid "" -":class:`partial` objects are like :class:`function` objects in that they are " -"callable, weak referenceable, and can have attributes. There are some " -"important differences. For instance, the :attr:`~definition.__name__` and :" -"attr:`__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." +":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." msgstr "" ":class:`partial` 物件與 :class:`function` 物件類似,因為它們是可呼叫的、可弱" "參照的 (weak referencable) 且可以具有屬性。有一些重要的區別,例如,:attr:" diff --git a/library/gc.po b/library/gc.po index 9e8bf39153..9d218d0f89 100644 --- a/library/gc.po +++ b/library/gc.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2024-10-04 16:20+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-" @@ -66,10 +66,10 @@ msgstr "如果啟用了自動回收則回傳 ``True``。" #: ../../library/gc.rst:43 #, fuzzy msgid "" -"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." +"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." msgstr "" "若被呼叫時沒有引數,則啟動完整垃圾回收。可選的引數 *generation* 可以是一個指" "明需要回收哪一代垃圾的整數(從 0 到 2)。當引數 *generation* 無效時,會引發 :" @@ -77,23 +77,6 @@ msgstr "" #: ../../library/gc.rst:48 msgid "" -"Calling ``gc.collect(0)`` will perform a GC collection on the young " -"generation." -msgstr "" - -#: ../../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 "" - -#: ../../library/gc.rst:53 -msgid "" -"Calling ``gc.collect(2)`` or ``gc.collect()`` performs a full collection" -msgstr "" - -#: ../../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 " @@ -103,17 +86,13 @@ msgstr "" "為了特定型別的實現,特別是 :class:`float`,在某些空閒列表中並非所有項目都會被" "釋放。" -#: ../../library/gc.rst:60 +#: ../../library/gc.rst:53 msgid "" "The effect of calling ``gc.collect()`` while the interpreter is already " "performing a collection is undefined." msgstr "" -#: ../../library/gc.rst:63 -msgid "``generation=1`` performs an increment of collection." -msgstr "" - -#: ../../library/gc.rst:69 +#: ../../library/gc.rst:59 msgid "" "Set the garbage collection debugging flags. Debugging information will be " "written to ``sys.stderr``. See below for a list of debugging flags which " @@ -122,43 +101,25 @@ msgstr "" "設定垃圾回收器的除錯旗標。除錯資訊會被寫入 ``sys.stderr``。請見下方的除錯旗標" "列表,可以使用位元操作 (bit operation) 進行設定以控制除錯程式。" -#: ../../library/gc.rst:76 +#: ../../library/gc.rst:66 msgid "Return the debugging flags currently set." msgstr "回傳當前設置的除錯旗標。" -#: ../../library/gc.rst:82 +#: ../../library/gc.rst:71 #, fuzzy msgid "" "Returns a list of all objects tracked by the collector, excluding the list " -"returned. If *generation* is not ``None``, return only the objects as " -"follows:" +"returned. If *generation* is not ``None``, return only the objects tracked " +"by the collector that are in that generation." msgstr "" "回傳一個包含回收器正在追蹤的所有物件的 list,除去所回傳的 list。如果 " "*generation* 不為 None,只回傳回收器正在追蹤且屬於該代的物件。" -#: ../../library/gc.rst:85 -#, fuzzy -msgid "0: All objects in the young generation" -msgstr "回傳永久代中的物件數量。" - -#: ../../library/gc.rst:86 -msgid "1: No objects, as there is no generation 1 (as of Python 3.13)" -msgstr "" - -#: ../../library/gc.rst:87 -#, fuzzy -msgid "2: All objects in the old generation" -msgstr "回傳永久代中的物件數量。" - -#: ../../library/gc.rst:89 +#: ../../library/gc.rst:75 msgid "New *generation* parameter." msgstr "新增 *generation* 參數。" -#: ../../library/gc.rst:92 -msgid "Generation 1 is removed" -msgstr "" - -#: ../../library/gc.rst:95 +#: ../../library/gc.rst:78 msgid "" "Raises an :ref:`auditing event ` ``gc.get_objects`` with argument " "``generation``." @@ -166,7 +127,7 @@ msgstr "" "引發一個附帶引數 ``generation`` 的\\ :ref:`稽核事件 (auditing event) " "` ``gc.get_objects``。" -#: ../../library/gc.rst:99 +#: ../../library/gc.rst:82 msgid "" "Return a list of three per-generation dictionaries containing collection " "statistics since interpreter start. The number of keys may change in the " @@ -176,17 +137,17 @@ msgstr "" "的垃圾回收統計資料。字典的鍵的數目在將來可能會改變,但目前每個字典包含以下項" "目:" -#: ../../library/gc.rst:104 +#: ../../library/gc.rst:87 msgid "``collections`` is the number of times this generation was collected;" msgstr "``collections`` 是該代被回收的次數;" -#: ../../library/gc.rst:106 +#: ../../library/gc.rst:89 msgid "" "``collected`` is the total number of objects collected inside this " "generation;" msgstr "``collected`` 是該代中被回收的物件總數;" -#: ../../library/gc.rst:109 +#: ../../library/gc.rst:92 msgid "" "``uncollectable`` is the total number of objects which were found to be " "uncollectable (and were therefore moved to the :data:`garbage` list) inside " @@ -195,64 +156,54 @@ msgstr "" "``uncollectable`` 是在這一代中被發現無法回收的物件總數(因此被移到 :data:" "`garbage` list 中)。" -#: ../../library/gc.rst:118 +#: ../../library/gc.rst:101 msgid "" "Set the garbage collection thresholds (the collection frequency). Setting " "*threshold0* to zero disables collection." msgstr "設定垃圾回收閾值(回收頻率)。 將 *threshold0* 設為零會停止回收。" -#: ../../library/gc.rst:121 -msgid "" -"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 "" - -#: ../../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 "" - -#: ../../library/gc.rst:131 -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 "" - -#: ../../library/gc.rst:136 -msgid "*threshold2* is ignored." -msgstr "" - -#: ../../library/gc.rst:138 +#: ../../library/gc.rst:104 msgid "" -"See `Garbage collector design `_ for more information." -msgstr "" - -#: ../../library/gc.rst:140 -msgid "*threshold2* is ignored" -msgstr "" +"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 `_ 來了解詳情。" -#: ../../library/gc.rst:146 +#: ../../library/gc.rst:121 msgid "" "Return the current collection counts as a tuple of ``(count0, count1, " "count2)``." msgstr "將當前回收計數以 ``(count0, count1, count2)`` 形式的 tuple 回傳。" -#: ../../library/gc.rst:152 +#: ../../library/gc.rst:127 msgid "" "Return the current collection thresholds as a tuple of ``(threshold0, " "threshold1, threshold2)``." msgstr "" "將當前回收閾值以 ``(threshold0, threshold1, threshold2)`` 形式的 tuple 回傳。" -#: ../../library/gc.rst:158 +#: ../../library/gc.rst:133 msgid "" "Return the list of objects that directly refer to any of objs. This function " "will only locate those containers which support garbage collection; " @@ -262,7 +213,7 @@ msgstr "" "回傳包含直接參照 objs 中任一個物件的物件 list。這個函式只定位支援垃圾回收的容" "器;參照了其它物件但不支援垃圾回收的擴充套件型別無法被找到。" -#: ../../library/gc.rst:163 +#: ../../library/gc.rst:138 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 " @@ -273,7 +224,7 @@ msgstr "" "會被作為參照者出現在回傳的 list 中。若只要獲取當前正在參照的物件,需要在呼" "叫 :func:`get_referrers` 之前呼叫 :func:`collect`。" -#: ../../library/gc.rst:169 +#: ../../library/gc.rst:144 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 " @@ -284,7 +235,7 @@ msgstr "" "在建構中而處於暫時無效的狀態。不要把 :func:`get_referrers` 用於除錯以外的其它" "目的。" -#: ../../library/gc.rst:174 +#: ../../library/gc.rst:149 msgid "" "Raises an :ref:`auditing event ` ``gc.get_referrers`` with " "argument ``objs``." @@ -292,7 +243,7 @@ msgstr "" "引發一個附帶引數 ``objs`` 的\\ :ref:`稽核事件 ` ``gc." "get_referrers``。" -#: ../../library/gc.rst:179 +#: ../../library/gc.rst:154 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:" @@ -310,7 +261,7 @@ msgstr "" "此,可以有以下例子:一個整數對於一個引數是直接可達的,這個整數物件有可能出現" "或不出現在結果的 list 當中。" -#: ../../library/gc.rst:187 +#: ../../library/gc.rst:162 msgid "" "Raises an :ref:`auditing event ` ``gc.get_referents`` with " "argument ``objs``." @@ -318,7 +269,7 @@ msgstr "" "引發一個附帶引數 ``objs`` 的\\ :ref:`稽核事件 ` ``gc." "get_referents``。" -#: ../../library/gc.rst:191 +#: ../../library/gc.rst:166 msgid "" "Returns ``True`` if the object is currently tracked by the garbage " "collector, ``False`` otherwise. As a general rule, instances of atomic " @@ -332,7 +283,7 @@ msgstr "" "件)會被追蹤。然而,有一些特定型別最佳化會被用來減少垃圾回收器在簡單實例(如" "只含有原子性的鍵和值的字典)上的足跡: ::" -#: ../../library/gc.rst:198 +#: ../../library/gc.rst:173 msgid "" ">>> gc.is_tracked(0)\n" "False\n" @@ -360,14 +311,14 @@ msgstr "" ">>> gc.is_tracked({\"a\": []})\n" "True" -#: ../../library/gc.rst:216 +#: ../../library/gc.rst:191 msgid "" "Returns ``True`` if the given object has been finalized by the garbage " "collector, ``False`` otherwise. ::" msgstr "" "如果給定物件已被垃圾回收器終結則回傳 ``True``,否則回傳 ``False``。: ::" -#: ../../library/gc.rst:219 +#: ../../library/gc.rst:194 msgid "" ">>> x = None\n" ">>> class Lazarus:\n" @@ -395,7 +346,7 @@ msgstr "" ">>> gc.is_finalized(x)\n" "True" -#: ../../library/gc.rst:237 +#: ../../library/gc.rst:212 msgid "" "Freeze all the objects tracked by the garbage collector; move them to a " "permanent generation and ignore them in all the future collections." @@ -403,7 +354,7 @@ msgstr "" "凍結 (freeze) 垃圾回收器所追蹤的所有物件;將它們移至永久代並忽略所有未來的收" "集動作。" -#: ../../library/gc.rst:240 +#: ../../library/gc.rst:215 msgid "" "If a process will ``fork()`` without ``exec()``, avoiding unnecessary copy-" "on-write in child processes will maximize memory sharing and reduce overall " @@ -421,23 +372,23 @@ msgstr "" "disable()``,在 ``fork()`` 之前呼叫 ``gc.freeze()``,並儘早在子行程中呼叫 " "``gc.enable()``。" -#: ../../library/gc.rst:254 +#: ../../library/gc.rst:229 msgid "" "Unfreeze the objects in the permanent generation, put them back into the " "oldest generation." msgstr "解凍 (unfreeze) 永久代中的物件,並將它們放回到最年老代中。" -#: ../../library/gc.rst:262 +#: ../../library/gc.rst:237 msgid "Return the number of objects in the permanent generation." msgstr "回傳永久代中的物件數量。" -#: ../../library/gc.rst:267 +#: ../../library/gc.rst:242 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:272 +#: ../../library/gc.rst:247 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 " @@ -448,7 +399,7 @@ msgstr "" "開始,該 list 在大多數時候都應該是空的,除非使用了有非 ``NULL`` ``tp_del`` 槽" "位的 C 擴充套件型別的實例。" -#: ../../library/gc.rst:277 +#: ../../library/gc.rst:252 msgid "" "If :const:`DEBUG_SAVEALL` is set, then all unreachable objects will be added " "to this list rather than freed." @@ -456,7 +407,7 @@ msgstr "" "如果設定了 :const:`DEBUG_SAVEALL`,則所有不可達物件將被加進該 list 而不會被釋" "放。" -#: ../../library/gc.rst:280 +#: ../../library/gc.rst:255 msgid "" "If this list is non-empty at :term:`interpreter shutdown`, a :exc:" "`ResourceWarning` is emitted, which is silent by default. If :const:" @@ -467,7 +418,7 @@ msgstr "" "`ResourceWarning`,在預設情況下此警告不會被提醒。如果設定了 :const:" "`DEBUG_UNCOLLECTABLE`,所有無法被回收的物件會被印出。" -#: ../../library/gc.rst:286 +#: ../../library/gc.rst:261 msgid "" "Following :pep:`442`, objects with a :meth:`~object.__del__` method don't " "end up in :data:`gc.garbage` anymore." @@ -475,7 +426,7 @@ msgstr "" "根據 :pep:`442`,帶有 :meth:`~object.__del__` method 的物件最終不會在 :data:" "`gc.garbage` 內。" -#: ../../library/gc.rst:292 +#: ../../library/gc.rst:267 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* " @@ -484,29 +435,29 @@ msgstr "" "會被垃圾回收器在回收開始前和完成後呼叫的一系列回呼函式 (callback) 。這些回呼" "函式在被呼叫時附帶兩個引數:*phase* 和 *info*。" -#: ../../library/gc.rst:296 +#: ../../library/gc.rst:271 msgid "*phase* can be one of two values:" msgstr "*phase* 可為以下兩者之一:" -#: ../../library/gc.rst:298 +#: ../../library/gc.rst:273 msgid "\"start\": The garbage collection is about to start." msgstr "\"start\":垃圾回收即將開始。" -#: ../../library/gc.rst:300 +#: ../../library/gc.rst:275 msgid "\"stop\": The garbage collection has finished." msgstr "\"stop\":垃圾回收已結束。" -#: ../../library/gc.rst:302 +#: ../../library/gc.rst:277 msgid "" "*info* is a dict providing more information for the callback. The following " "keys are currently defined:" msgstr "*info* 是一個字典,提供回呼函式更多資訊。已有定義的鍵有:" -#: ../../library/gc.rst:305 +#: ../../library/gc.rst:280 msgid "\"generation\": The oldest generation being collected." msgstr "\"generation\"(代):正在被回收的最年老的一代。" -#: ../../library/gc.rst:307 +#: ../../library/gc.rst:282 msgid "" "\"collected\": When *phase* is \"stop\", the number of objects successfully " "collected." @@ -514,7 +465,7 @@ msgstr "" "\"collected\"(已回收的):當 *phase* 為 \"stop\" 時,被成功回收的物件的數" "目。" -#: ../../library/gc.rst:310 +#: ../../library/gc.rst:285 msgid "" "\"uncollectable\": When *phase* is \"stop\", the number of objects that " "could not be collected and were put in :data:`garbage`." @@ -522,40 +473,40 @@ msgstr "" "\"uncollectable\"(不可回收的):當 *phase* 為 \"stop\" 時,不能被回收並被放" "入 :data:`garbage` 的物件的數目。" -#: ../../library/gc.rst:313 +#: ../../library/gc.rst:288 msgid "" "Applications can add their own callbacks to this list. The primary use " "cases are:" msgstr "應用程式可以把他們自己的回呼函式加入此 list。主要的使用場景有:" -#: ../../library/gc.rst:316 +#: ../../library/gc.rst:291 msgid "" "Gathering statistics about garbage collection, such as how often various " "generations are collected, and how long the collection takes." msgstr "收集垃圾回收的統計資料,如:不同代的回收頻率、回收任務所花費的時間。" -#: ../../library/gc.rst:320 +#: ../../library/gc.rst:295 msgid "" "Allowing applications to identify and clear their own uncollectable types " "when they appear in :data:`garbage`." msgstr "" "讓應用程式可以識別和清理他們自己在 :data:`garbage` 中的不可回收型別物件。" -#: ../../library/gc.rst:326 +#: ../../library/gc.rst:301 msgid "The following constants are provided for use with :func:`set_debug`:" msgstr "以下常數是為了和 :func:`set_debug` 一起使用所提供:" -#: ../../library/gc.rst:331 +#: ../../library/gc.rst:306 msgid "" "Print statistics during collection. This information can be useful when " "tuning the collection frequency." msgstr "在回收完成後印出統計資訊。當調校回收頻率設定時,這些資訊會很有用。" -#: ../../library/gc.rst:337 +#: ../../library/gc.rst:312 msgid "Print information on collectable objects found." msgstr "當發現可回收物件時印出資訊。" -#: ../../library/gc.rst:342 +#: ../../library/gc.rst:317 msgid "" "Print information of uncollectable objects found (objects which are not " "reachable but cannot be freed by the collector). These objects will be " @@ -564,7 +515,7 @@ msgstr "" "印出找到的不可回收物件的資訊(指不能被回收器回收的不可達物件)。這些物件會被" "新增到 ``garbage`` list 中。" -#: ../../library/gc.rst:346 +#: ../../library/gc.rst:321 msgid "" "Also print the contents of the :data:`garbage` list at :term:`interpreter " "shutdown`, if it isn't empty." @@ -572,7 +523,7 @@ msgstr "" "當 :term:`interpreter shutdown`\\ (直譯器關閉)時,若 :data:`garbage` list " "不是空的,那這些內容也會被印出。" -#: ../../library/gc.rst:352 +#: ../../library/gc.rst:327 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." @@ -580,7 +531,7 @@ msgstr "" "設定後,所有回收器找到的不可達物件會被加進 *garbage* 而不是直接被釋放。這在為" "一個記憶體流失的程式除錯時會很有用。" -#: ../../library/gc.rst:358 +#: ../../library/gc.rst:333 msgid "" "The debugging flags necessary for the collector to print information about a " "leaking program (equal to ``DEBUG_COLLECTABLE | DEBUG_UNCOLLECTABLE | " @@ -589,30 +540,10 @@ 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 `_ 來了解詳情。" +#, fuzzy +#~ msgid "0: All objects in the young generation" +#~ msgstr "回傳永久代中的物件數量。" + +#, fuzzy +#~ msgid "2: All objects in the old generation" +#~ msgstr "回傳永久代中的物件數量。" diff --git a/library/getopt.po b/library/getopt.po index f4467adec5..e8956c58a6 100644 --- a/library/getopt.po +++ b/library/getopt.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2024-12-29 16:19+0000\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-" @@ -26,22 +26,16 @@ msgstr ":mod:`!getopt` --- 用於命令列選項的 C 風格剖析器" msgid "**Source code:** :source:`Lib/getopt.py`" msgstr "**原始碼:**\\ :source:`Lib/getopt.py`" -#: ../../library/getopt.rst:10 +#: ../../library/getopt.rst:12 msgid "" -"The :mod:`getopt` module is :term:`soft deprecated` and will not be " -"developed further; development will continue with the :mod:`argparse` module." +"This module is considered feature complete. A more declarative and " +"extensible alternative to this API is provided in the :mod:`optparse` " +"module. Further functional enhancements for command line parameter " +"processing are provided either as third party modules on PyPI, or else as " +"features in the :mod:`argparse` module." msgstr "" -#: ../../library/getopt.rst:17 -msgid "" -"The :mod:`getopt` module is a parser for command line options whose API is " -"designed to be familiar to users of the C :c:func:`!getopt` function. Users " -"who are unfamiliar with the C :c:func:`!getopt` function or who would like " -"to write less code and get better help and error messages should consider " -"using the :mod:`argparse` module instead." -msgstr "" - -#: ../../library/getopt.rst:25 +#: ../../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` " @@ -50,11 +44,21 @@ msgid "" "be used as well via an optional third argument." msgstr "" -#: ../../library/getopt.rst:31 +#: ../../library/getopt.rst:26 +msgid "" +"Users who are unfamiliar with the Unix :c:func:`!getopt` function should " +"consider using the :mod:`argparse` module instead. Users who are familiar " +"with the Unix :c:func:`!getopt` function, but would like to get equivalent " +"behavior while writing less code and getting better help and error messages " +"should consider using the :mod:`optparse` module. See :ref:`choosing-an-" +"argument-parser` for additional details." +msgstr "" + +#: ../../library/getopt.rst:33 msgid "This module provides two functions and an exception:" msgstr "" -#: ../../library/getopt.rst:37 +#: ../../library/getopt.rst:39 msgid "" "Parses command line options and parameter list. *args* is the argument list " "to be parsed, without the leading reference to the running program. " @@ -64,14 +68,14 @@ msgid "" "func:`!getopt` uses)." msgstr "" -#: ../../library/getopt.rst:45 +#: ../../library/getopt.rst:47 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:49 +#: ../../library/getopt.rst:51 msgid "" "*longopts*, if specified, must be a list of strings with the names of the " "long options which should be supported. The leading ``'--'`` characters " @@ -85,7 +89,7 @@ msgid "" "uniquely, so :exc:`GetoptError` will be raised." msgstr "" -#: ../../library/getopt.rst:60 +#: ../../library/getopt.rst:62 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 " @@ -98,7 +102,7 @@ msgid "" "occurrences. Long and short options may be mixed." msgstr "" -#: ../../library/getopt.rst:73 +#: ../../library/getopt.rst:75 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 " @@ -106,14 +110,14 @@ msgid "" "a non-option argument is encountered." msgstr "" -#: ../../library/getopt.rst:78 +#: ../../library/getopt.rst:80 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:85 +#: ../../library/getopt.rst:87 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 " @@ -124,23 +128,52 @@ msgid "" "which the exception relates, :attr:`!opt` is an empty string." msgstr "" -#: ../../library/getopt.rst:96 +#: ../../library/getopt.rst:98 msgid "Alias for :exc:`GetoptError`; for backward compatibility." msgstr "" -#: ../../library/getopt.rst:98 +#: ../../library/getopt.rst:100 msgid "An example using only Unix style options:" msgstr "" -#: ../../library/getopt.rst:110 +#: ../../library/getopt.rst:102 +msgid "" +">>> import getopt\n" +">>> args = '-a -b -cfoo -d bar a1 a2'.split()\n" +">>> args\n" +"['-a', '-b', '-cfoo', '-d', 'bar', 'a1', 'a2']\n" +">>> optlist, args = getopt.getopt(args, 'abc:d:')\n" +">>> optlist\n" +"[('-a', ''), ('-b', ''), ('-c', 'foo'), ('-d', 'bar')]\n" +">>> args\n" +"['a1', 'a2']" +msgstr "" + +#: ../../library/getopt.rst:114 msgid "Using long option names is equally easy:" msgstr "" -#: ../../library/getopt.rst:123 -msgid "In a script, typical usage is something like this::" +#: ../../library/getopt.rst:116 +msgid "" +">>> s = '--condition=foo --testing --output-file abc.def -x a1 a2'\n" +">>> args = s.split()\n" +">>> args\n" +"['--condition=foo', '--testing', '--output-file', 'abc.def', '-x', 'a1', " +"'a2']\n" +">>> optlist, args = getopt.getopt(args, 'x', [\n" +"... 'condition=', 'output-file=', 'testing'])\n" +">>> optlist\n" +"[('--condition', 'foo'), ('--testing', ''), ('--output-file', 'abc.def'), ('-" +"x', '')]\n" +">>> args\n" +"['a1', 'a2']" msgstr "" -#: ../../library/getopt.rst:125 +#: ../../library/getopt.rst:129 +msgid "In a script, typical usage is something like this:" +msgstr "" + +#: ../../library/getopt.rst:131 msgid "" "import getopt, sys\n" "\n" @@ -166,20 +199,38 @@ msgid "" " output = a\n" " else:\n" " assert False, \"unhandled option\"\n" -" # ...\n" +" process(args, output=output, verbose=verbose)\n" "\n" "if __name__ == \"__main__\":\n" " main()" msgstr "" -#: ../../library/getopt.rst:152 +#: ../../library/getopt.rst:160 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:" -"`argparse` module::" +"`optparse` module:" msgstr "" -#: ../../library/getopt.rst:155 +#: ../../library/getopt.rst:163 +msgid "" +"import optparse\n" +"\n" +"if __name__ == '__main__':\n" +" parser = optparse.OptionParser()\n" +" parser.add_option('-o', '--output')\n" +" parser.add_option('-v', dest='verbose', action='store_true')\n" +" opts, args = parser.parse_args()\n" +" process(args, output=opts.output, verbose=opts.verbose)" +msgstr "" + +#: ../../library/getopt.rst:174 +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 msgid "" "import argparse\n" "\n" @@ -187,15 +238,31 @@ msgid "" " parser = argparse.ArgumentParser()\n" " parser.add_argument('-o', '--output')\n" " parser.add_argument('-v', dest='verbose', action='store_true')\n" +" parser.add_argument('rest', nargs='*')\n" " args = parser.parse_args()\n" -" # ... do something with args.output ...\n" -" # ... do something with args.verbose .." +" process(args.rest, output=args.output, verbose=args.verbose)" +msgstr "" + +#: ../../library/getopt.rst:189 +msgid "" +"See :ref:`choosing-an-argument-parser` for details on how the ``argparse`` " +"version of this code differs in behaviour from the ``optparse`` (and " +"``getopt``) version." +msgstr "" + +#: ../../library/getopt.rst:195 +#, fuzzy +msgid "Module :mod:`optparse`" +msgstr ":mod:`argparse` 模組" + +#: ../../library/getopt.rst:196 +msgid "Declarative command line option parsing." msgstr "" -#: ../../library/getopt.rst:167 +#: ../../library/getopt.rst:198 msgid "Module :mod:`argparse`" msgstr ":mod:`argparse` 模組" -#: ../../library/getopt.rst:168 -msgid "Alternative command line option and argument parsing library." +#: ../../library/getopt.rst:199 +msgid "More opinionated command line option and argument parsing library." msgstr "" diff --git a/library/getpass.po b/library/getpass.po index 19177262cd..d36a12a06e 100644 --- a/library/getpass.po +++ b/library/getpass.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2024-10-13 17:13+0000\n" "PO-Revision-Date: 2022-02-11 12:04+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -28,7 +28,7 @@ msgid "**Source code:** :source:`Lib/getpass.py`" msgstr "**原始碼:**\\ :source:`Lib/getpass.py`" #: ../../includes/wasm-notavail.rst:3 -msgid ":ref:`Availability `: not WASI." +msgid "Availability" msgstr "" #: ../../includes/wasm-notavail.rst:5 diff --git a/library/grp.po b/library/grp.po index 00ca37fb41..fc6efba553 100644 --- a/library/grp.po +++ b/library/grp.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2024-10-13 17:13+0000\n" "PO-Revision-Date: 2018-05-23 16:02+0000\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -29,9 +29,8 @@ msgid "" msgstr "" #: ../../library/grp.rst:13 -#, fuzzy -msgid ":ref:`Availability `: Unix, not WASI, not iOS." -msgstr ":ref:`適用 `:Unix、非 Emscripten、非 WASI。" +msgid "Availability" +msgstr "" #: ../../library/grp.rst:15 msgid "" @@ -144,6 +143,11 @@ msgstr ":mod:`pwd` 模組" msgid "An interface to the user database, similar to this." msgstr "" +#, fuzzy +#~ msgid "" +#~ ":ref:`Availability `: Unix, not WASI, not Android, not iOS." +#~ msgstr ":ref:`適用 `:Unix、非 Emscripten、非 WASI。" + #~ msgid "Module :mod:`spwd`" #~ msgstr ":mod:`spwd` 模組" diff --git a/library/gzip.po b/library/gzip.po index d2643f46da..37ebc1b6f2 100644 --- a/library/gzip.po +++ b/library/gzip.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-05-04 20:08+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-" @@ -105,7 +105,7 @@ msgstr "" msgid "Added support for the ``'x'``, ``'xb'`` and ``'xt'`` modes." msgstr "新增 ``'x'``、``'xb'`` 和 ``'xt'`` 模式的支援。" -#: ../../library/gzip.rst:59 ../../library/gzip.rst:175 +#: ../../library/gzip.rst:59 ../../library/gzip.rst:173 msgid "Accepts a :term:`path-like object`." msgstr "接受\\ :term:`類路徑物件 `。" @@ -201,27 +201,26 @@ msgstr ":class:`GzipFile` 也提供了以下的方法和屬性:" #: ../../library/gzip.rst:124 msgid "" -"Read *n* uncompressed bytes without advancing the file position. At most one " -"single read on the compressed stream is done to satisfy the call. The " -"number of bytes returned may be more or less than requested." +"Read *n* uncompressed bytes without advancing the file position. The number " +"of bytes returned may be more or less than requested." msgstr "" -#: ../../library/gzip.rst:129 +#: ../../library/gzip.rst:127 msgid "" "While calling :meth:`peek` does not change the file position of the :class:" "`GzipFile`, it may change the position of the underlying file object (e.g. " "if the :class:`GzipFile` was constructed with the *fileobj* parameter)." msgstr "" -#: ../../library/gzip.rst:138 +#: ../../library/gzip.rst:136 msgid "``'rb'`` for reading and ``'wb'`` for writing." msgstr "" -#: ../../library/gzip.rst:140 +#: ../../library/gzip.rst:138 msgid "In previous versions it was an integer ``1`` or ``2``." msgstr "" -#: ../../library/gzip.rst:145 +#: ../../library/gzip.rst:143 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 " @@ -229,62 +228,62 @@ msgid "" "reading any headers is ``None``." msgstr "" -#: ../../library/gzip.rst:152 +#: ../../library/gzip.rst:150 msgid "" "The path to the gzip file on disk, as a :class:`str` or :class:`bytes`. " "Equivalent to the output of :func:`os.fspath` on the original input path, " "with no other normalization, resolution or expansion." msgstr "" -#: ../../library/gzip.rst:156 +#: ../../library/gzip.rst:154 msgid "" "Support for the :keyword:`with` statement was added, along with the *mtime* " "constructor argument and :attr:`mtime` attribute." msgstr "" -#: ../../library/gzip.rst:160 +#: ../../library/gzip.rst:158 msgid "Support for zero-padded and unseekable files was added." msgstr "" -#: ../../library/gzip.rst:163 +#: ../../library/gzip.rst:161 msgid "The :meth:`io.BufferedIOBase.read1` method is now implemented." msgstr ":meth:`io.BufferedIOBase.read1` 方法現在已有實作。" -#: ../../library/gzip.rst:166 +#: ../../library/gzip.rst:164 msgid "Added support for the ``'x'`` and ``'xb'`` modes." msgstr "新增 ``'x'`` 和 ``'xb'`` 模式的支援。" -#: ../../library/gzip.rst:169 +#: ../../library/gzip.rst:167 msgid "" "Added support for writing arbitrary :term:`bytes-like objects `. The :meth:`~io.BufferedIOBase.read` method now accepts an argument " "of ``None``." msgstr "" -#: ../../library/gzip.rst:178 +#: ../../library/gzip.rst:176 msgid "" "Opening :class:`GzipFile` for writing without specifying the *mode* argument " "is deprecated." msgstr "" -#: ../../library/gzip.rst:182 +#: ../../library/gzip.rst:180 msgid "" "Remove the ``filename`` attribute, use the :attr:`~GzipFile.name` attribute " "instead." msgstr "" -#: ../../library/gzip.rst:189 +#: ../../library/gzip.rst:187 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." msgstr "" -#: ../../library/gzip.rst:194 +#: ../../library/gzip.rst:192 msgid "Added the *mtime* parameter for reproducible output." msgstr "" -#: ../../library/gzip.rst:196 +#: ../../library/gzip.rst:194 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." @@ -293,13 +292,13 @@ msgid "" "underlying zlib implementation." msgstr "" -#: ../../library/gzip.rst:203 +#: ../../library/gzip.rst:201 msgid "" "The gzip header OS byte is guaranteed to be set to 255 when this function is " "used as was the case in 3.10 and earlier." msgstr "" -#: ../../library/gzip.rst:209 +#: ../../library/gzip.rst:207 msgid "" "Decompress the *data*, returning a :class:`bytes` object containing the " "uncompressed data. This function is capable of decompressing multi-member " @@ -308,21 +307,21 @@ msgid "" "*wbits* set to 31 is faster." msgstr "" -#: ../../library/gzip.rst:216 +#: ../../library/gzip.rst:214 msgid "" "Speed is improved by decompressing members at once in memory instead of in a " "streamed fashion." msgstr "" -#: ../../library/gzip.rst:223 +#: ../../library/gzip.rst:221 msgid "Examples of usage" msgstr "用法範例" -#: ../../library/gzip.rst:225 +#: ../../library/gzip.rst:223 msgid "Example of how to read a compressed file::" msgstr "如何讀取壓縮檔案的範例: ::" -#: ../../library/gzip.rst:227 +#: ../../library/gzip.rst:225 msgid "" "import gzip\n" "with gzip.open('/home/joe/file.txt.gz', 'rb') as f:\n" @@ -332,11 +331,11 @@ msgstr "" "with gzip.open('/home/joe/file.txt.gz', 'rb') as f:\n" " file_content = f.read()" -#: ../../library/gzip.rst:231 +#: ../../library/gzip.rst:229 msgid "Example of how to create a compressed GZIP file::" msgstr "如何建立一個壓縮的 GZIP 檔案的範例: ::" -#: ../../library/gzip.rst:233 +#: ../../library/gzip.rst:231 msgid "" "import gzip\n" "content = b\"Lots of content here\"\n" @@ -348,11 +347,11 @@ msgstr "" "with gzip.open('/home/joe/file.txt.gz', 'wb') as f:\n" " f.write(content)" -#: ../../library/gzip.rst:238 +#: ../../library/gzip.rst:236 msgid "Example of how to GZIP compress an existing file::" msgstr "如何壓縮一個已存在的檔案的範例: ::" -#: ../../library/gzip.rst:240 +#: ../../library/gzip.rst:238 msgid "" "import gzip\n" "import shutil\n" @@ -366,11 +365,11 @@ msgstr "" " with gzip.open('/home/joe/file.txt.gz', 'wb') as f_out:\n" " shutil.copyfileobj(f_in, f_out)" -#: ../../library/gzip.rst:246 +#: ../../library/gzip.rst:244 msgid "Example of how to GZIP compress a binary string::" msgstr "如何壓縮一個二進位字串的範例: ::" -#: ../../library/gzip.rst:248 +#: ../../library/gzip.rst:246 msgid "" "import gzip\n" "s_in = b\"Lots of content here\"\n" @@ -380,56 +379,62 @@ msgstr "" "s_in = b\"Lots of content here\"\n" "s_out = gzip.compress(s_in)" -#: ../../library/gzip.rst:254 +#: ../../library/gzip.rst:252 msgid "Module :mod:`zlib`" msgstr ":mod:`zlib` 模組" -#: ../../library/gzip.rst:255 +#: ../../library/gzip.rst:253 msgid "" "The basic data compression module needed to support the :program:`gzip` file " "format." msgstr "" -#: ../../library/gzip.rst:264 +#: ../../library/gzip.rst:256 +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" msgstr "命令列介面" -#: ../../library/gzip.rst:266 +#: ../../library/gzip.rst:268 msgid "" "The :mod:`gzip` module provides a simple command line interface to compress " "or decompress files." msgstr "" -#: ../../library/gzip.rst:269 +#: ../../library/gzip.rst:271 msgid "Once executed the :mod:`gzip` module keeps the input file(s)." msgstr "" -#: ../../library/gzip.rst:273 +#: ../../library/gzip.rst:275 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:277 +#: ../../library/gzip.rst:279 msgid "Command line options" msgstr "命令列選項" -#: ../../library/gzip.rst:281 +#: ../../library/gzip.rst:283 msgid "If *file* is not specified, read from :data:`sys.stdin`." msgstr "如果未指定 *file*,則從 :data:`sys.stdin` 讀取。" -#: ../../library/gzip.rst:285 +#: ../../library/gzip.rst:287 msgid "Indicates the fastest compression method (less compression)." msgstr "" -#: ../../library/gzip.rst:289 +#: ../../library/gzip.rst:291 msgid "Indicates the slowest compression method (best compression)." msgstr "" -#: ../../library/gzip.rst:293 +#: ../../library/gzip.rst:295 msgid "Decompress the given file." msgstr "解壓縮指定的檔案。" -#: ../../library/gzip.rst:297 +#: ../../library/gzip.rst:299 msgid "Show the help message." msgstr "顯示幫助訊息。" diff --git a/library/hashlib.po b/library/hashlib.po index c3eba1ece2..09978ad558 100644 --- a/library/hashlib.po +++ b/library/hashlib.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-23 07:52+0800\n" +"POT-Creation-Date: 2025-04-24 05:56+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-" @@ -28,14 +28,13 @@ msgid "**Source code:** :source:`Lib/hashlib.py`" msgstr "**原始碼:**\\ :source:`Lib/hashlib.py`" #: ../../library/hashlib.rst:23 +#, fuzzy msgid "" -"This module implements a common interface to many different secure hash and " -"message digest algorithms. Included are the FIPS secure hash algorithms " -"SHA1, SHA224, SHA256, SHA384, SHA512, (defined in `the FIPS 180-4 " -"standard`_), the SHA-3 series (defined in `the FIPS 202 standard`_) as well " -"as RSA's MD5 algorithm (defined in internet :rfc:`1321`). The terms " -"\"secure hash\" and \"message digest\" are interchangeable. Older " -"algorithms were called message digests. The modern term is secure hash." +"This module implements a common interface to many different hash algorithms. " +"Included are the FIPS secure hash algorithms SHA224, SHA256, SHA384, SHA512, " +"(defined in `the FIPS 180-4 standard`_), the SHA-3 series (defined in `the " +"FIPS 202 standard`_) as well as the legacy algorithms SHA1 (`formerly part " +"of FIPS`_) and the MD5 algorithm (defined in internet :rfc:`1321`)." msgstr "" "該模組實作了許多不同安全雜湊和訊息摘要演算法的通用介面,其中包括 FIPS 安全雜" "湊演算法 SHA1、SHA224、SHA256、SHA384、SHA512(定義於 `FIPS 180-4 標準 ` 方法來要求它提供迄今為止傳遞給它的資料串聯的\\ :dfn:`摘要 " "(digest)`。" -#: ../../library/hashlib.rst:50 +#: ../../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 :" @@ -84,7 +83,7 @@ msgstr "" "式或 :meth:`.update` 方法中計算一次提供超過 2047 位元組資料的雜" "湊值。" -#: ../../library/hashlib.rst:57 +#: ../../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:" @@ -101,7 +100,7 @@ msgstr "" "果你使用罕見的「符合 FIPS (FIPS compliant)」的 Python 建置版本,它可能不存在" "或者不被允許使用。以上會對應到 :data:`algorithms_guaranteed`。" -#: ../../library/hashlib.rst:65 +#: ../../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. " @@ -112,7 +111,7 @@ msgstr "" "也可能有其他演算法可用。其他則\\ *不保證可用*\\ 於在所有安裝上,並且只能以名" "稱來透過 :func:`new` 存取。請參閱 :data:`algorithms_available`。" -#: ../../library/hashlib.rst:72 +#: ../../library/hashlib.rst:70 msgid "" "Some algorithms have known hash collision weaknesses (including MD5 and " "SHA1). Refer to `Attacks on cryptographic hash algorithms`_ and the `hashlib-" @@ -122,7 +121,7 @@ msgstr "" "閱 `Attacks on cryptographic hash algorithms`_ 和本文件後面的\\ `也參考 " "`_\\ 部分。" -#: ../../library/hashlib.rst:76 +#: ../../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 " @@ -132,7 +131,7 @@ msgstr "" "func:`sha3_384`、:func:`sha3_512`、:func:`shake_128`、:func:`shake_256`。也新" "增了 :func:`blake2b` 和 :func:`blake2s`。" -#: ../../library/hashlib.rst:84 +#: ../../library/hashlib.rst:82 msgid "" "All hashlib constructors take a keyword-only argument *usedforsecurity* with " "default value ``True``. A false value allows the use of insecure and blocked " @@ -145,11 +144,11 @@ msgstr "" "全 (insecure) 和阻塞的 (blocked) 雜湊演算法。``False`` 表示雜湊演算法未在安全" "情境中使用,例如作為一種非加密用途的單向壓縮函式。" -#: ../../library/hashlib.rst:91 +#: ../../library/hashlib.rst:89 msgid "Hashlib now uses SHA3 and SHAKE from OpenSSL if it provides it." msgstr "Hashlib 現在使用 OpenSSL 中的 SHA3 和 SHAKE(如果有提供的話)。" -#: ../../library/hashlib.rst:94 +#: ../../library/hashlib.rst:92 msgid "" "For any of the MD5, SHA1, SHA2, or SHA3 algorithms that the linked OpenSSL " "does not provide we fall back to a verified implementation from the `HACL\\* " @@ -158,18 +157,18 @@ msgstr "" "對於鏈結之 OpenSSL 未提供的任何 MD5、SHA1、SHA2 或 SHA3 演算法,我們會回退使" "用 `HACL\\* 專案 `_\\ 中經過驗證的實作。" -#: ../../library/hashlib.rst:100 +#: ../../library/hashlib.rst:98 msgid "Usage" msgstr "用法" -#: ../../library/hashlib.rst:102 +#: ../../library/hashlib.rst:100 msgid "" "To obtain the digest of the byte string ``b\"Nobody inspects the spammish " "repetition\"``::" msgstr "" "獲取位元組字串 ``b\"Nobody inspects the spammish repetition\"`` 的摘要: ::" -#: ../../library/hashlib.rst:105 +#: ../../library/hashlib.rst:103 msgid "" ">>> import hashlib\n" ">>> m = hashlib.sha256()\n" @@ -193,15 +192,15 @@ msgstr "" ">>> m.hexdigest()\n" "'031edd7d41651593c5fe5c006fa5752b37fddff7bc4e843aa6af0c950f4b9406'" -#: ../../library/hashlib.rst:114 +#: ../../library/hashlib.rst:112 msgid "More condensed:" msgstr "更濃縮:" -#: ../../library/hashlib.rst:120 +#: ../../library/hashlib.rst:118 msgid "Constructors" msgstr "建構函式" -#: ../../library/hashlib.rst:124 +#: ../../library/hashlib.rst:122 msgid "" "Is a generic constructor that takes the string *name* of the desired " "algorithm as its first parameter. It also exists to allow access to the " @@ -211,25 +210,25 @@ msgstr "" "是一個通用建構函式,它將目標演算法的字串 *name* 作為其第一個參數。它還允許使" "用者取得上面列出的雜湊值以及 OpenSSL 函式庫可能提供的任何其他演算法。" -#: ../../library/hashlib.rst:129 +#: ../../library/hashlib.rst:127 msgid "Using :func:`new` with an algorithm name:" msgstr "使用 :func:`new` 和演算法名稱:" -#: ../../library/hashlib.rst:148 +#: ../../library/hashlib.rst:146 msgid "" "Named constructors such as these are faster than passing an algorithm name " "to :func:`new`." msgstr "諸如此類的附名建構函式比將演算法名稱傳遞給 :func:`new` 更快。" -#: ../../library/hashlib.rst:152 +#: ../../library/hashlib.rst:150 msgid "Attributes" msgstr "屬性" -#: ../../library/hashlib.rst:154 +#: ../../library/hashlib.rst:152 msgid "Hashlib provides the following constant module attributes:" msgstr "Hashlib 提供以下常數模組屬性:" -#: ../../library/hashlib.rst:158 +#: ../../library/hashlib.rst:156 msgid "" "A set containing the names of the hash algorithms guaranteed to be supported " "by this module on all platforms. Note that 'md5' is in this list despite " @@ -240,7 +239,7 @@ msgstr "" "列表中,儘管有一些上游供應商提供了奇怪的「符合 FIPS (FIPS compliant)」的 " "Python 建置,並將其排除在外。" -#: ../../library/hashlib.rst:167 +#: ../../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 :" @@ -252,29 +251,29 @@ msgstr "" "func:`new` 時將被識別。:attr:`algorithms_guaranteed` 都會是它的一個子集。相同" "的演算法可能會以不同的名稱多次出現在該集合中(多虧了 OpenSSL)。" -#: ../../library/hashlib.rst:176 +#: ../../library/hashlib.rst:174 msgid "Hash Objects" msgstr "雜湊物件" -#: ../../library/hashlib.rst:178 +#: ../../library/hashlib.rst:176 msgid "" "The following values are provided as constant attributes of the hash objects " "returned by the constructors:" msgstr "以下的值皆為建構函式回傳之雜湊物件的常數屬性:" -#: ../../library/hashlib.rst:183 +#: ../../library/hashlib.rst:181 msgid "The size of the resulting hash in bytes." msgstr "生成雜湊的大小(以位元組為單位)。" -#: ../../library/hashlib.rst:187 +#: ../../library/hashlib.rst:185 msgid "The internal block size of the hash algorithm in bytes." msgstr "雜湊演算法的內部區塊大小(以位元組為單位)。" -#: ../../library/hashlib.rst:189 +#: ../../library/hashlib.rst:187 msgid "A hash object has the following attributes:" msgstr "雜湊物件具有以下屬性:" -#: ../../library/hashlib.rst:193 +#: ../../library/hashlib.rst:191 msgid "" "The canonical name of this hash, always lowercase and always suitable as a " "parameter to :func:`new` to create another hash of this type." @@ -282,7 +281,7 @@ msgstr "" "該雜湊的規範名稱,都會是小寫,且都會適合作為 :func:`new` 的參數以建立此型別的" "另一個雜湊。" -#: ../../library/hashlib.rst:196 +#: ../../library/hashlib.rst:194 msgid "" "The name attribute has been present in CPython since its inception, but " "until Python 3.4 was not formally specified, so may not exist on some " @@ -291,11 +290,11 @@ msgstr "" "name 屬性自 CPython 誕生以來就存在於其中,但直到 Python 3.4 才正式確立,因此" "在某些平台上可能不存在。" -#: ../../library/hashlib.rst:201 +#: ../../library/hashlib.rst:199 msgid "A hash object has the following methods:" msgstr "雜湊物件具有以下方法:" -#: ../../library/hashlib.rst:206 +#: ../../library/hashlib.rst:204 msgid "" "Update the hash object with the :term:`bytes-like object`. Repeated calls " "are equivalent to a single call with the concatenation of all the arguments: " @@ -305,7 +304,7 @@ msgstr "" "當於連接所有引數的單一呼叫:``m.update(a); m.update(b)`` 等價於 ``m." "update(a+b)``。" -#: ../../library/hashlib.rst:214 +#: ../../library/hashlib.rst:212 msgid "" "Return the digest of the data passed to the :meth:`update` method so far. " "This is a bytes object of size :attr:`digest_size` which may contain bytes " @@ -314,7 +313,7 @@ msgstr "" "回傳目前有傳遞給 :meth:`update` 方法的資料之摘要。這是一個大小為 :attr:" "`digest_size` 的位元組物件,它可能包含從 0 到 255 的整個範圍內的位元組。" -#: ../../library/hashlib.rst:221 +#: ../../library/hashlib.rst:219 msgid "" "Like :meth:`digest` except the digest is returned as a string object of " "double length, containing only hexadecimal digits. This may be used to " @@ -323,7 +322,7 @@ msgstr "" "與 :meth:`digest` 類似,只不過摘要會是作為雙倍長度的字串物件回傳,僅包含十六" "進位數字。這可用於在電子郵件或其他非二進位環境中安全地交換值。" -#: ../../library/hashlib.rst:228 +#: ../../library/hashlib.rst:226 msgid "" "Return a copy (\"clone\") of the hash object. This can be used to " "efficiently compute the digests of data sharing a common initial substring." @@ -331,11 +330,11 @@ msgstr "" "回傳雜湊物件的副本(「複製 (clone)」),這可用於高效率地計算出共享同一初始子" "字串的資料之摘要。" -#: ../../library/hashlib.rst:233 +#: ../../library/hashlib.rst:231 msgid "SHAKE variable length digests" msgstr "SHAKE 可變長度摘要" -#: ../../library/hashlib.rst:238 +#: ../../library/hashlib.rst:236 msgid "" "The :func:`shake_128` and :func:`shake_256` algorithms provide variable " "length digests with length_in_bits//2 up to 128 or 256 bits of security. As " @@ -346,7 +345,7 @@ msgstr "" "length_in_bits//2 最高為 128 或 256 位元安全性。因此,他們的摘要方法會需要長" "度。最大長度不受 SHAKE 演算法限制。" -#: ../../library/hashlib.rst:245 +#: ../../library/hashlib.rst:243 msgid "" "Return the digest of the data passed to the :meth:`~hash.update` method so " "far. This is a bytes object of size *length* which may contain bytes in the " @@ -355,7 +354,7 @@ msgstr "" "回傳目前有傳遞給 :meth:`~hash.update` 方法的資料之摘要。這是一個大小為 " "*length* 的位元組物件,可能包含從 0 到 255 的整個範圍內的位元組。" -#: ../../library/hashlib.rst:252 +#: ../../library/hashlib.rst:250 msgid "" "Like :meth:`digest` except the digest is returned as a string object of " "double length, containing only hexadecimal digits. This may be used to " @@ -364,15 +363,15 @@ msgstr "" "與 :meth:`digest` 類似,只不過摘要作為雙倍長度的字串物件回傳,僅包含十六進位" "數字。這可用於交換電子郵件或其他非二進位環境中的值。" -#: ../../library/hashlib.rst:256 +#: ../../library/hashlib.rst:254 msgid "Example use:" msgstr "範例:" -#: ../../library/hashlib.rst:263 +#: ../../library/hashlib.rst:261 msgid "File hashing" msgstr "檔案雜湊" -#: ../../library/hashlib.rst:265 +#: ../../library/hashlib.rst:263 msgid "" "The hashlib module provides a helper function for efficient hashing of a " "file or file-like object." @@ -380,20 +379,33 @@ msgstr "" "hashlib 模組提供了一個輔助函式,用於對檔案或類檔案物件 (file-like object) 進" "行有效率的雜湊。" -#: ../../library/hashlib.rst:270 +#: ../../library/hashlib.rst:268 msgid "" "Return a digest object that has been updated with contents of file object." msgstr "回傳已用檔案物件內容更新的摘要物件。" -#: ../../library/hashlib.rst:272 +#: ../../library/hashlib.rst:270 +#, fuzzy 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. 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*." +"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 物件等。該函式可以繞過 Python 的 I/O 並直接使用 :meth:`~io.IOBase." +"fileno` 中的檔案描述器 (file descriptor)。在此函式回傳或引發後,必須假定 " +"*fileobj* 處於未知狀態 (unknown state)。由呼叫者決定是否關閉 *fileobj*。" + +#: ../../library/hashlib.rst:276 +#, fuzzy +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*." msgstr "" "*fileobj* 必須是以二進位模式讀取的類檔案物件。它接受來自內建 :func:`open` 的" "檔案物件、:class:`~io.BytesIO` 實例、來自 :meth:`socket.socket.makefile` 的 " @@ -401,7 +413,7 @@ msgstr "" "fileno` 中的檔案描述器 (file descriptor)。在此函式回傳或引發後,必須假定 " "*fileobj* 處於未知狀態 (unknown state)。由呼叫者決定是否關閉 *fileobj*。" -#: ../../library/hashlib.rst:280 +#: ../../library/hashlib.rst:281 msgid "" "*digest* must either be a hash algorithm name as a *str*, a hash " "constructor, or a callable that returns a hash object." @@ -409,15 +421,21 @@ msgstr "" "*digest* 必須是名稱作為 *str* 的雜湊演算法、雜湊建構函式或會回傳雜湊物件的可" "呼叫函式。" -#: ../../library/hashlib.rst:283 +#: ../../library/hashlib.rst:284 msgid "Example:" msgstr "範例:" -#: ../../library/hashlib.rst:306 +#: ../../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." +msgstr "" + +#: ../../library/hashlib.rst:311 msgid "Key derivation" msgstr "密鑰的生成" -#: ../../library/hashlib.rst:308 +#: ../../library/hashlib.rst:313 msgid "" "Key derivation and key stretching algorithms are designed for secure " "password hashing. Naive algorithms such as ``sha1(password)`` are not " @@ -430,7 +448,7 @@ msgstr "" "的密碼雜湊函式必須是可調校的 (tunable)、緩慢的,並且有包含 `salt(鹽) " "`_。" -#: ../../library/hashlib.rst:316 +#: ../../library/hashlib.rst:321 msgid "" "The function provides PKCS#5 password-based key derivation function 2. It " "uses HMAC as pseudorandom function." @@ -438,7 +456,7 @@ msgstr "" "該函式提供基於密碼的 PKCS#5 密鑰生成函式 2。它使用 HMAC 作為偽隨機函式 " "(pseudorandom function)。" -#: ../../library/hashlib.rst:319 +#: ../../library/hashlib.rst:324 msgid "" "The string *hash_name* is the desired name of the hash digest algorithm for " "HMAC, e.g. 'sha1' or 'sha256'. *password* and *salt* are interpreted as " @@ -451,7 +469,7 @@ msgstr "" "*password* 設下合理的長度限制(例如 1024)。*salt* 應該是來自適當來源(例如 :" "func:`os.urandom`)且大約 16 或更多位元組。" -#: ../../library/hashlib.rst:325 +#: ../../library/hashlib.rst:330 msgid "" "The number of *iterations* should be chosen based on the hash algorithm and " "computing power. As of 2022, hundreds of thousands of iterations of SHA-256 " @@ -464,7 +482,7 @@ msgstr "" "讀 NIST-SP-800-132_ 的 *Appendix A.2.2*。`stackexchange pbkdf2 疊代問題`_\\ " "上的答案有詳細解釋。" -#: ../../library/hashlib.rst:331 +#: ../../library/hashlib.rst:336 msgid "" "*dklen* is the length of the derived key in bytes. If *dklen* is ``None`` " "then the digest size of the hash algorithm *hash_name* is used, e.g. 64 for " @@ -473,11 +491,11 @@ msgstr "" "*dklen* 是生成的密鑰長度。如果 *dklen* 為 ``None``,則會使用雜湊演算法 " "*hash_name* 的摘要大小,例如 SHA-512 為 64。" -#: ../../library/hashlib.rst:340 +#: ../../library/hashlib.rst:345 msgid "Function only available when Python is compiled with OpenSSL." msgstr "僅當有使用 OpenSSL 編譯 Python 時該函式才可用。" -#: ../../library/hashlib.rst:344 +#: ../../library/hashlib.rst:349 msgid "" "Function now only available when Python is built with OpenSSL. The slow pure " "Python implementation has been removed." @@ -485,13 +503,13 @@ msgstr "" "該函式現在僅在有使用 OpenSSL 建置 Python 時可用。緩慢的純 Python 實作已被刪" "除。" -#: ../../library/hashlib.rst:350 +#: ../../library/hashlib.rst:355 msgid "" "The function provides scrypt password-based key derivation function as " "defined in :rfc:`7914`." msgstr "該函式提供(如 :rfc:`7914` 中所定義的)scrypt 基於密碼的密鑰衍生函式。" -#: ../../library/hashlib.rst:353 +#: ../../library/hashlib.rst:358 msgid "" "*password* and *salt* must be :term:`bytes-like objects `. Applications and libraries should limit *password* to a sensible " @@ -502,7 +520,7 @@ msgstr "" "程式和函式庫應為 *password* 設下合理的長度限制(例如 1024)。*salt* 應該是來" "自適當來源(例如 :func:`os.urandom`)且大約 16 或更多位元組。" -#: ../../library/hashlib.rst:358 +#: ../../library/hashlib.rst:363 msgid "" "*n* is the CPU/Memory cost factor, *r* the block size, *p* parallelization " "factor and *maxmem* limits memory (OpenSSL 1.1.0 defaults to 32 MiB). " @@ -511,17 +529,17 @@ msgstr "" "*n* 是 CPU/記憶體開銷係數、*r* 是區塊大小、*p* 為平行化係數、*maxmem* 為記憶" "體限制(OpenSSL 1.1.0 預設為 32 MiB)。*dklen* 是生成密鑰的長度。" -#: ../../library/hashlib.rst:368 +#: ../../library/hashlib.rst:373 msgid "BLAKE2" msgstr "BLAKE2" -#: ../../library/hashlib.rst:375 +#: ../../library/hashlib.rst:380 msgid "" "BLAKE2_ is a cryptographic hash function defined in :rfc:`7693` that comes " "in two flavors:" msgstr "BLAKE2_ 是在 :rfc:`7693` 中定義的加密雜湊函式,有兩種類型:" -#: ../../library/hashlib.rst:378 +#: ../../library/hashlib.rst:383 msgid "" "**BLAKE2b**, optimized for 64-bit platforms and produces digests of any size " "between 1 and 64 bytes," @@ -529,7 +547,7 @@ msgstr "" "**BLAKE2b**,針對 64 位元平台進行了最佳化,可生成 1 到 64 位元組之間任意大小" "的摘要," -#: ../../library/hashlib.rst:381 +#: ../../library/hashlib.rst:386 msgid "" "**BLAKE2s**, optimized for 8- to 32-bit platforms and produces digests of " "any size between 1 and 32 bytes." @@ -537,7 +555,7 @@ msgstr "" "**BLAKE2s**,針對 8 至 32 位元平台進行了最佳化,可生成 1 至 32 位元組之間任意" "大小的摘要。" -#: ../../library/hashlib.rst:384 +#: ../../library/hashlib.rst:389 msgid "" "BLAKE2 supports **keyed mode** (a faster and simpler replacement for HMAC_), " "**salted hashing**, **personalization**, and **tree hashing**." @@ -545,21 +563,21 @@ msgstr "" "BLAKE2 支援\\ **密鑰模式 (keyed mode)** (更快、更簡單的 HMAC_ 替代品)、**加" "鹽雜湊 (salted hashing)**、**個人化**\\ 和\\ **樹狀雜湊**。" -#: ../../library/hashlib.rst:387 +#: ../../library/hashlib.rst:392 msgid "" "Hash objects from this module follow the API of standard library's :mod:" "`hashlib` objects." msgstr "該模組中的雜湊物件遵循標準函式庫的 :mod:`hashlib` 物件 API。" -#: ../../library/hashlib.rst:392 +#: ../../library/hashlib.rst:397 msgid "Creating hash objects" msgstr "建立雜湊物件" -#: ../../library/hashlib.rst:394 +#: ../../library/hashlib.rst:399 msgid "New hash objects are created by calling constructor functions:" msgstr "新的雜湊物件是透過呼叫建構函式建立的:" -#: ../../library/hashlib.rst:408 +#: ../../library/hashlib.rst:413 msgid "" "These functions return the corresponding hash objects for calculating " "BLAKE2b or BLAKE2s. They optionally take these general parameters:" @@ -567,7 +585,7 @@ msgstr "" "這些函式回傳相應的雜湊物件以計算 BLAKE2b 或 BLAKE2s。他們可以選擇採用這些通用" "參數:" -#: ../../library/hashlib.rst:411 +#: ../../library/hashlib.rst:416 msgid "" "*data*: initial chunk of data to hash, which must be :term:`bytes-like " "object`. It can be passed only as positional argument." @@ -575,18 +593,18 @@ msgstr "" "*data*:要雜湊的初始資料塊 (data chunk),它必須是\\ :term:`類位元組物件 " "`。它只能作為位置引數傳遞。" -#: ../../library/hashlib.rst:414 +#: ../../library/hashlib.rst:419 msgid "*digest_size*: size of output digest in bytes." msgstr "*digest_size*:輸出摘要的大小(以位元組為單位)。" -#: ../../library/hashlib.rst:416 +#: ../../library/hashlib.rst:421 msgid "" "*key*: key for keyed hashing (up to 64 bytes for BLAKE2b, up to 32 bytes for " "BLAKE2s)." msgstr "" "*key*:用於密鑰雜湊的密鑰(BLAKE2b 最多 64 位元組、BLAKE2s 最多 32 位元組)。" -#: ../../library/hashlib.rst:419 +#: ../../library/hashlib.rst:424 msgid "" "*salt*: salt for randomized hashing (up to 16 bytes for BLAKE2b, up to 8 " "bytes for BLAKE2s)." @@ -594,62 +612,62 @@ msgstr "" "*salt*:用於隨機雜湊的鹽(BLAKE2b 最多 16 個位元組、BLAKE2s 最多 8 個位元" "組)。" -#: ../../library/hashlib.rst:422 +#: ../../library/hashlib.rst:427 msgid "" "*person*: personalization string (up to 16 bytes for BLAKE2b, up to 8 bytes " "for BLAKE2s)." msgstr "" "*person*:個人化字串(BLAKE2b 最多 16 個位元組、BLAKE2s 最多 8 個位元組)。" -#: ../../library/hashlib.rst:425 +#: ../../library/hashlib.rst:430 msgid "The following table shows limits for general parameters (in bytes):" msgstr "下表顯示了一般參數的限制(以位元組為單位):" -#: ../../library/hashlib.rst:428 +#: ../../library/hashlib.rst:433 msgid "Hash" msgstr "雜湊" -#: ../../library/hashlib.rst:428 +#: ../../library/hashlib.rst:433 msgid "digest_size" msgstr "digest_size" -#: ../../library/hashlib.rst:428 +#: ../../library/hashlib.rst:433 msgid "len(key)" msgstr "len(key)" -#: ../../library/hashlib.rst:428 +#: ../../library/hashlib.rst:433 msgid "len(salt)" msgstr "len(salt)" -#: ../../library/hashlib.rst:428 +#: ../../library/hashlib.rst:433 msgid "len(person)" msgstr "len(person)" -#: ../../library/hashlib.rst:430 +#: ../../library/hashlib.rst:435 msgid "BLAKE2b" msgstr "BLAKE2b" -#: ../../library/hashlib.rst:430 +#: ../../library/hashlib.rst:435 msgid "64" msgstr "64" -#: ../../library/hashlib.rst:430 +#: ../../library/hashlib.rst:435 msgid "16" msgstr "16" -#: ../../library/hashlib.rst:431 +#: ../../library/hashlib.rst:436 msgid "BLAKE2s" msgstr "BLAKE2s" -#: ../../library/hashlib.rst:431 +#: ../../library/hashlib.rst:436 msgid "32" msgstr "32" -#: ../../library/hashlib.rst:431 +#: ../../library/hashlib.rst:436 msgid "8" msgstr "8" -#: ../../library/hashlib.rst:436 +#: ../../library/hashlib.rst:441 msgid "" "BLAKE2 specification defines constant lengths for salt and personalization " "parameters, however, for convenience, this implementation accepts byte " @@ -663,26 +681,26 @@ msgstr "" "以像是 ``b'salt`` 和 ``b'salt\\x00`` 是相同的值。(但 *key* 的情況並非如" "此。)" -#: ../../library/hashlib.rst:443 +#: ../../library/hashlib.rst:448 msgid "These sizes are available as module `constants`_ described below." msgstr "這些大小可作為模組\\ `常數 `_\\ 使用,如下所述。" -#: ../../library/hashlib.rst:445 +#: ../../library/hashlib.rst:450 msgid "" "Constructor functions also accept the following tree hashing parameters:" msgstr "建構函式還接受以下樹狀雜湊參數:" -#: ../../library/hashlib.rst:447 +#: ../../library/hashlib.rst:452 msgid "*fanout*: fanout (0 to 255, 0 if unlimited, 1 in sequential mode)." msgstr "*fanout*:扇出(0 到 255,如果無限制則為 0、順序模式為 1)。" -#: ../../library/hashlib.rst:449 +#: ../../library/hashlib.rst:454 msgid "" "*depth*: maximal depth of tree (1 to 255, 255 if unlimited, 1 in sequential " "mode)." msgstr "*depth*:樹的最大深度(1 到 255,如果無限制則為 255、順序模式為 1)。" -#: ../../library/hashlib.rst:452 +#: ../../library/hashlib.rst:457 msgid "" "*leaf_size*: maximal byte length of leaf (0 to ``2**32-1``, 0 if unlimited " "or in sequential mode)." @@ -690,7 +708,7 @@ msgstr "" "*leaf_size*:葉的最大位元組長度(0 到 ``2**32-1``,如果無限制或處於順序模式則" "為 0)。" -#: ../../library/hashlib.rst:455 +#: ../../library/hashlib.rst:460 msgid "" "*node_offset*: node offset (0 to ``2**64-1`` for BLAKE2b, 0 to ``2**48-1`` " "for BLAKE2s, 0 for the first, leftmost, leaf, or in sequential mode)." @@ -698,12 +716,12 @@ msgstr "" "*node_offset*:節點偏移量(BLAKE2b 為 0 到 ``2**64-1``,BLAKE2s 為 0 到 " "``2**48-1``,0 表示第一個、最左邊、葉子或在順序模式下)。" -#: ../../library/hashlib.rst:458 +#: ../../library/hashlib.rst:463 msgid "" "*node_depth*: node depth (0 to 255, 0 for leaves, or in sequential mode)." msgstr "*node_depth*:節點深度(0 到 255,葉為 0,或在順序模式下)。" -#: ../../library/hashlib.rst:460 +#: ../../library/hashlib.rst:465 msgid "" "*inner_size*: inner digest size (0 to 64 for BLAKE2b, 0 to 32 for BLAKE2s, 0 " "in sequential mode)." @@ -711,18 +729,18 @@ msgstr "" "*inner_size*:內部摘要大小(BLAKE2b 為 0 到 64,BLAKE2s 為 0 到 32,順序模式" "為 0)。" -#: ../../library/hashlib.rst:463 +#: ../../library/hashlib.rst:468 msgid "" "*last_node*: boolean indicating whether the processed node is the last one " "(``False`` for sequential mode)." msgstr "" "*last_node*:布林值,代表處理的節點是否為最後一個(``False`` 代表順序模式)。" -#: ../../library/hashlib.rst:466 +#: ../../library/hashlib.rst:471 msgid "Explanation of tree mode parameters." msgstr "樹狀模式參數說明。" -#: ../../library/hashlib.rst:470 +#: ../../library/hashlib.rst:475 msgid "" "See section 2.10 in `BLAKE2 specification `_ for comprehensive review of tree hashing." @@ -730,36 +748,36 @@ msgstr "" "關於樹狀雜湊的綜合回顧,請參閱 `BLAKE2 規範 `_\\ 中的第 2.10 節。" -#: ../../library/hashlib.rst:476 +#: ../../library/hashlib.rst:481 msgid "Constants" msgstr "常數" -#: ../../library/hashlib.rst:481 +#: ../../library/hashlib.rst:486 msgid "Salt length (maximum length accepted by constructors)." msgstr "鹽長度(建構函式接受的最大長度)。" -#: ../../library/hashlib.rst:487 +#: ../../library/hashlib.rst:492 msgid "" "Personalization string length (maximum length accepted by constructors)." msgstr "個人化字串長度(建構函式接受的最大長度)。" -#: ../../library/hashlib.rst:493 +#: ../../library/hashlib.rst:498 msgid "Maximum key size." msgstr "最大密鑰大小。" -#: ../../library/hashlib.rst:499 +#: ../../library/hashlib.rst:504 msgid "Maximum digest size that the hash function can output." msgstr "雜湊函式可以輸出的最大摘要大小。" -#: ../../library/hashlib.rst:503 +#: ../../library/hashlib.rst:508 msgid "Examples" msgstr "範例" -#: ../../library/hashlib.rst:506 +#: ../../library/hashlib.rst:511 msgid "Simple hashing" msgstr "簡單雜湊" -#: ../../library/hashlib.rst:508 +#: ../../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:" @@ -772,7 +790,7 @@ msgstr "" "update` 來以資料對它更新,最後透過呼叫 :meth:`~hash.digest`\\ (或對於十六進" "位編碼字串則為 :meth:`~hash.hexdigest`)從物件中獲得摘要。" -#: ../../library/hashlib.rst:521 +#: ../../library/hashlib.rst:526 msgid "" "As a shortcut, you can pass the first chunk of data to update directly to " "the constructor as the positional argument:" @@ -780,17 +798,17 @@ msgstr "" "作為一個快捷方式,你可以將要更新的第一個資料塊作為位置引數直接傳遞給建構函" "式:" -#: ../../library/hashlib.rst:528 +#: ../../library/hashlib.rst:533 msgid "" "You can call :meth:`hash.update` as many times as you need to iteratively " "update the hash:" msgstr "你可以根據需求來多次呼叫 :meth:`hash.update` 以疊代更新雜湊:" -#: ../../library/hashlib.rst:542 +#: ../../library/hashlib.rst:547 msgid "Using different digest sizes" msgstr "使用不同的摘要大小" -#: ../../library/hashlib.rst:544 +#: ../../library/hashlib.rst:549 msgid "" "BLAKE2 has configurable size of digests up to 64 bytes for BLAKE2b and up to " "32 bytes for BLAKE2s. For example, to replace SHA-1 with BLAKE2b without " @@ -800,7 +818,7 @@ msgstr "" "組。例如,要在不改變輸出大小的情況下用 BLAKE2b 替換 SHA-1,我們可以指定 " "BLAKE2b 生成 20 位元組的摘要:" -#: ../../library/hashlib.rst:558 +#: ../../library/hashlib.rst:563 msgid "" "Hash objects with different digest sizes have completely different outputs " "(shorter hashes are *not* prefixes of longer hashes); BLAKE2b and BLAKE2s " @@ -809,11 +827,11 @@ msgstr "" "具有不同摘要大小的雜湊物件具有完全不同的輸出(較短的雜湊值\\ *不是*\\ 較長雜" "湊值的前綴);即使輸出長度相同,BLAKE2b 和 BLAKE2s 也會產生不同的輸出:" -#: ../../library/hashlib.rst:574 +#: ../../library/hashlib.rst:579 msgid "Keyed hashing" msgstr "密鑰雜湊 (Keyed hashing)" -#: ../../library/hashlib.rst:576 +#: ../../library/hashlib.rst:581 msgid "" "Keyed hashing can be used for authentication as a faster and simpler " "replacement for `Hash-based message authentication code >> from hashlib import blake2b\n" ">>> h = blake2b(key=b'pseudorandom key', digest_size=16)\n" @@ -847,7 +865,7 @@ msgstr "" ">>> h.hexdigest()\n" "'3d363ff7401e02026f4a4687d4863ced'" -#: ../../library/hashlib.rst:592 +#: ../../library/hashlib.rst:597 msgid "" "As a practical example, a web application can symmetrically sign cookies " "sent to users and later verify them to make sure they weren't tampered with::" @@ -855,7 +873,7 @@ msgstr "" "舉一個實際的例子,網頁應用程式可以對發送給使用者的 cookie 進行對稱簽名 " "(symmetrically sign),然後驗證它們以確保它們沒有被篡改: ::" -#: ../../library/hashlib.rst:595 +#: ../../library/hashlib.rst:600 msgid "" ">>> from hashlib import blake2b\n" ">>> from hmac import compare_digest\n" @@ -909,7 +927,7 @@ msgstr "" ">>> verify(cookie, b'0102030405060708090a0b0c0d0e0f00')\n" "False" -#: ../../library/hashlib.rst:621 +#: ../../library/hashlib.rst:626 msgid "" "Even though there's a native keyed hashing mode, BLAKE2 can, of course, be " "used in HMAC construction with :mod:`hmac` module::" @@ -917,7 +935,7 @@ msgstr "" "儘管有原生密鑰雜湊模式,BLAKE2 還是可以透過 :mod:`hmac` 模組用於建構 " "HMAC: ::" -#: ../../library/hashlib.rst:624 +#: ../../library/hashlib.rst:629 msgid "" ">>> import hmac, hashlib\n" ">>> m = hmac.new(b'secret key', digestmod=hashlib.blake2s)\n" @@ -931,11 +949,11 @@ msgstr "" ">>> m.hexdigest()\n" "'e3c8102868d28b5ff85fc35dda07329970d1a01e273c37481326fe0c861c8142'" -#: ../../library/hashlib.rst:632 +#: ../../library/hashlib.rst:637 msgid "Randomized hashing" msgstr "隨機雜湊 (Randomized hashing)" -#: ../../library/hashlib.rst:634 +#: ../../library/hashlib.rst:639 msgid "" "By setting *salt* parameter users can introduce randomization to the hash " "function. Randomized hashing is useful for protecting against collision " @@ -944,7 +962,7 @@ msgstr "" "透過設定 *salt* 參數,使用者可以向雜湊函式引入隨機化。隨機雜湊在防止針對數位" "簽章中雜湊函式的碰撞攻擊 (collision attacks) 非常有用。" -#: ../../library/hashlib.rst:638 +#: ../../library/hashlib.rst:643 msgid "" "Randomized hashing is designed for situations where one party, the message " "preparer, generates all or part of a message to be signed by a second party, " @@ -975,16 +993,16 @@ msgstr "" "的所有部分都是由簽名者所準備好的,使用隨機雜湊可能會降低數位簽章提供的安全" "性。" -#: ../../library/hashlib.rst:657 +#: ../../library/hashlib.rst:662 #, fuzzy msgid "" "(`NIST SP-800-106 \"Randomized Hashing for Digital Signatures\" `_)" +"csrc.nist.gov/pubs/sp/800/106/final>`_)" msgstr "" "(`NIST SP-800-106 「數位簽章的隨機雜湊 (Randomized Hashing for Digital " "Signatures)」 `_)" -#: ../../library/hashlib.rst:660 +#: ../../library/hashlib.rst:665 msgid "" "In BLAKE2 the salt is processed as a one-time input to the hash function " "during initialization, rather than as an input to each compression function." @@ -992,7 +1010,7 @@ msgstr "" "在 BLAKE2 中,鹽在初始化期間作為雜湊函式的一次性輸入被處理,而不是作為每個壓" "縮函式的輸入。" -#: ../../library/hashlib.rst:665 +#: ../../library/hashlib.rst:670 msgid "" "*Salted hashing* (or just hashing) with BLAKE2 or any other general-purpose " "cryptographic hash function, such as SHA-256, is not suitable for hashing " @@ -1003,11 +1021,11 @@ msgstr "" "純雜湊)不適合對密碼進行雜湊處理。有關更多資訊,請參閱 `BLAKE2 FAQ `_ 。" -#: ../../library/hashlib.rst:688 +#: ../../library/hashlib.rst:693 msgid "Personalization" msgstr "個人化" -#: ../../library/hashlib.rst:690 +#: ../../library/hashlib.rst:695 msgid "" "Sometimes it is useful to force hash function to produce different digests " "for the same input for different purposes. Quoting the authors of the Skein " @@ -1016,7 +1034,7 @@ msgstr "" "有時候強制雜湊函式為不同目的的相同輸入生成不同的摘要是很有用的。引用 Skein 雜" "湊函式的作者的話:" -#: ../../library/hashlib.rst:694 +#: ../../library/hashlib.rst:699 msgid "" "We recommend that all application designers seriously consider doing this; " "we have seen many protocols where a hash that is computed in one part of the " @@ -1030,7 +1048,7 @@ msgstr "" "關的資料上完成的,並且攻擊者可以強制應用程式將雜湊輸入設為相同的。對協議中使" "用的每個雜湊函式進行個人化可以立即阻止此類攻擊。" -#: ../../library/hashlib.rst:701 +#: ../../library/hashlib.rst:706 msgid "" "(`The Skein Hash Function Family `_, p. 21)" @@ -1038,11 +1056,11 @@ msgstr "" "(`Skein 雜湊函式系列 `_,第 21 頁)" -#: ../../library/hashlib.rst:705 +#: ../../library/hashlib.rst:710 msgid "BLAKE2 can be personalized by passing bytes to the *person* argument::" msgstr "BLAKE2 可以透過將位元組傳遞給 *person* 引數來做個人化: ::" -#: ../../library/hashlib.rst:707 +#: ../../library/hashlib.rst:712 msgid "" ">>> from hashlib import blake2b\n" ">>> FILES_HASH_PERSON = b'MyApp Files Hash'\n" @@ -1068,21 +1086,21 @@ msgstr "" ">>> h.hexdigest()\n" "'cf68fb5761b9c44e7878bfb2c4c9aea52264a80b75005e65619778de59f383a3'" -#: ../../library/hashlib.rst:719 +#: ../../library/hashlib.rst:724 msgid "" "Personalization together with the keyed mode can also be used to derive " "different keys from a single one." msgstr "個人化與密鑰模式還可以一起用於從單個密鑰得出不同的密鑰。" -#: ../../library/hashlib.rst:733 +#: ../../library/hashlib.rst:738 msgid "Tree mode" msgstr "樹狀模式" -#: ../../library/hashlib.rst:735 +#: ../../library/hashlib.rst:740 msgid "Here's an example of hashing a minimal tree with two leaf nodes::" msgstr "下面是對具有兩個葉節點的最小樹進行雜湊處理的範例: ::" -#: ../../library/hashlib.rst:737 +#: ../../library/hashlib.rst:742 msgid "" " 10\n" " / \\\n" @@ -1092,13 +1110,13 @@ msgstr "" " / \\\n" "00 01" -#: ../../library/hashlib.rst:741 +#: ../../library/hashlib.rst:746 msgid "" "This example uses 64-byte internal digests, and returns the 32-byte final " "digest::" msgstr "此範例使用 64-byte 內部摘要,並回傳 32-byte 最終摘要: ::" -#: ../../library/hashlib.rst:744 +#: ../../library/hashlib.rst:749 msgid "" ">>> from hashlib import blake2b\n" ">>>\n" @@ -1152,11 +1170,11 @@ msgstr "" ">>> h10.hexdigest()\n" "'3ad2a9b37c6070e374c7a8c508fe20ca86b6ed54e286e93a0318e95e881db5aa'" -#: ../../library/hashlib.rst:771 +#: ../../library/hashlib.rst:776 msgid "Credits" msgstr "製作人員" -#: ../../library/hashlib.rst:773 +#: ../../library/hashlib.rst:778 msgid "" "BLAKE2_ was designed by *Jean-Philippe Aumasson*, *Samuel Neves*, *Zooko " "Wilcox-O'Hearn*, and *Christian Winnerlein* based on SHA-3_ finalist BLAKE_ " @@ -1168,13 +1186,13 @@ msgstr "" "Henzen*、*Willi Meier* 和 *Raphael C.-W. Phan* 所建立的 SHA-3_ 最終版本 " "BLAKE_。" -#: ../../library/hashlib.rst:778 +#: ../../library/hashlib.rst:783 msgid "" "It uses core algorithm from ChaCha_ cipher designed by *Daniel J. " "Bernstein*." msgstr "它使用 *Daniel J. Bernstein* 設計的 ChaCha_ 密碼的核心演算法。" -#: ../../library/hashlib.rst:780 +#: ../../library/hashlib.rst:785 msgid "" "The stdlib implementation is based on pyblake2_ module. It was written by " "*Dmitry Chestnykh* based on C implementation written by *Samuel Neves*. The " @@ -1184,17 +1202,17 @@ msgstr "" "Neves* 的 C 版本實作為基礎所編寫的。該文件是由 *Dmitry Chestnykh* 編寫並從 " "pyblake2_ 複製過來的。" -#: ../../library/hashlib.rst:784 +#: ../../library/hashlib.rst:789 msgid "The C code was partly rewritten for Python by *Christian Heimes*." msgstr "*Christian Heimes* 為 Python 重寫了部分 C 程式碼。" -#: ../../library/hashlib.rst:786 +#: ../../library/hashlib.rst:791 msgid "" "The following public domain dedication applies for both C hash function " "implementation, extension code, and this documentation:" msgstr "以下公開領域貢獻適用於 C 雜湊函式實作、擴充程式碼和此文件:" -#: ../../library/hashlib.rst:789 +#: ../../library/hashlib.rst:794 msgid "" "To the extent possible under law, the author(s) have dedicated all copyright " "and related and neighboring rights to this software to the public domain " @@ -1203,7 +1221,7 @@ msgstr "" "在法律允許的範圍內,作者已將該軟體的所有版權以及相關和鄰接權利奉獻給全球的公" "開領域。該軟體的發布沒有任何授權 (warranty)。" -#: ../../library/hashlib.rst:793 +#: ../../library/hashlib.rst:798 msgid "" "You should have received a copy of the CC0 Public Domain Dedication along " "with this software. If not, see https://creativecommons.org/publicdomain/" @@ -1213,7 +1231,7 @@ msgstr "" "Dedication) 的副本。如果沒有,請參閱 https://creativecommons.org/" "publicdomain/zero/1.0/ 。" -#: ../../library/hashlib.rst:797 +#: ../../library/hashlib.rst:802 msgid "" "The following people have helped with development or contributed their " "changes to the project and the public domain according to the Creative " @@ -1222,56 +1240,56 @@ msgstr "" "以下人員根據創用 CC 通用公眾領域貢獻宣告 1.0 (Creative Commons Public Domain " "Dedication 1.0 Universal) 於專案和公開領域做出了開發或貢獻:" -#: ../../library/hashlib.rst:801 +#: ../../library/hashlib.rst:806 msgid "*Alexandr Sokolovskiy*" msgstr "*Alexandr Sokolovskiy*" -#: ../../library/hashlib.rst:821 +#: ../../library/hashlib.rst:827 msgid "Module :mod:`hmac`" msgstr ":mod:`hmac` 模組" -#: ../../library/hashlib.rst:822 +#: ../../library/hashlib.rst:828 msgid "A module to generate message authentication codes using hashes." msgstr "使用雜湊生成訊息驗證程式碼的模組。" -#: ../../library/hashlib.rst:824 +#: ../../library/hashlib.rst:830 msgid "Module :mod:`base64`" msgstr ":mod:`base64` 模組" -#: ../../library/hashlib.rst:825 +#: ../../library/hashlib.rst:831 msgid "Another way to encode binary hashes for non-binary environments." msgstr "另一種在非二進位環境中編碼二進位雜湊的方法。" -#: ../../library/hashlib.rst:827 +#: ../../library/hashlib.rst:833 msgid "https://nvlpubs.nist.gov/nistpubs/fips/nist.fips.180-4.pdf" msgstr "https://nvlpubs.nist.gov/nistpubs/fips/nist.fips.180-4.pdf" -#: ../../library/hashlib.rst:828 +#: ../../library/hashlib.rst:834 msgid "The FIPS 180-4 publication on Secure Hash Algorithms." msgstr "有關安全雜湊演算法的 FIPS 180-4 出版物。" -#: ../../library/hashlib.rst:830 +#: ../../library/hashlib.rst:836 #, fuzzy -msgid "https://csrc.nist.gov/publications/detail/fips/202/final" +msgid "https://csrc.nist.gov/pubs/fips/202/final" msgstr "https://csrc.nist.gov/pubs/fips/202/final" -#: ../../library/hashlib.rst:831 +#: ../../library/hashlib.rst:837 msgid "The FIPS 202 publication on the SHA-3 Standard." msgstr "有關 SHA-3 標準的 FIPS 202 出版物。" -#: ../../library/hashlib.rst:833 +#: ../../library/hashlib.rst:839 msgid "https://www.blake2.net/" msgstr "https://www.blake2.net/" -#: ../../library/hashlib.rst:834 +#: ../../library/hashlib.rst:840 msgid "Official BLAKE2 website." msgstr "BLAKE2 官方網站。" -#: ../../library/hashlib.rst:836 +#: ../../library/hashlib.rst:842 msgid "https://en.wikipedia.org/wiki/Cryptographic_hash_function" msgstr "https://en.wikipedia.org/wiki/Cryptographic_hash_function" -#: ../../library/hashlib.rst:837 +#: ../../library/hashlib.rst:843 msgid "" "Wikipedia article with information on which algorithms have known issues and " "what that means regarding their use." @@ -1279,21 +1297,21 @@ msgstr "" "包含有關哪些演算法存在已知問題以及這些問題對其使用意味著什麼資訊的維基百科文" "章。" -#: ../../library/hashlib.rst:840 +#: ../../library/hashlib.rst:846 msgid "https://www.ietf.org/rfc/rfc8018.txt" msgstr "https://www.ietf.org/rfc/rfc8018.txt" -#: ../../library/hashlib.rst:841 +#: ../../library/hashlib.rst:847 msgid "PKCS #5: Password-Based Cryptography Specification Version 2.1" msgstr "PKCS #5:基於密碼的加密規範版本 2.1" -#: ../../library/hashlib.rst:843 +#: ../../library/hashlib.rst:849 msgid "" "https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf" msgstr "" "https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf" -#: ../../library/hashlib.rst:844 +#: ../../library/hashlib.rst:850 msgid "NIST Recommendation for Password-Based Key Derivation." msgstr "NIST(美國國家標準技術研究院)針對基於密碼的密鑰衍生的建議。" @@ -1309,14 +1327,14 @@ msgstr "" "安全雜湊演算法、SHA1、SHA2、SHA224、SHA256、SHA384、SHA512、SHA3、Shake、" "Blake2" -#: ../../library/hashlib.rst:55 +#: ../../library/hashlib.rst:53 msgid "OpenSSL" msgstr "OpenSSL" -#: ../../library/hashlib.rst:55 +#: ../../library/hashlib.rst:53 msgid "(use in module hashlib)" msgstr "(使用於 hashlib 模組中)" -#: ../../library/hashlib.rst:372 +#: ../../library/hashlib.rst:377 msgid "blake2b, blake2s" msgstr "blake2b, blake2s" diff --git a/library/html.parser.po b/library/html.parser.po index f8c640799e..7ba2b573df 100644 --- a/library/html.parser.po +++ b/library/html.parser.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-09-03 11:11+0800\n" +"POT-Creation-Date: 2025-05-11 14:27+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-" @@ -82,10 +82,11 @@ msgid "Example HTML Parser Application" msgstr "HTML 剖析器應用程式範例" #: ../../library/html.parser.rst:44 +#, fuzzy 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::" +"encountered:" msgstr "" "以下的基礎範例是一個簡單的 HTML 剖析器,它使用 :class:`HTMLParser` 類別,當遇" "到開始標籤、結束標籤和資料時將它們印出: ::" @@ -124,11 +125,11 @@ msgstr "" "parser.feed('Test'\n" " '

Parse me!

')" -#: ../../library/html.parser.rst:64 +#: ../../library/html.parser.rst:66 msgid "The output will then be:" msgstr "輸出將是:" -#: ../../library/html.parser.rst:66 +#: ../../library/html.parser.rst:68 msgid "" "Encountered a start tag: html\n" "Encountered a start tag: head\n" @@ -156,15 +157,15 @@ msgstr "" "Encountered an end tag : body\n" "Encountered an end tag : html" -#: ../../library/html.parser.rst:83 +#: ../../library/html.parser.rst:85 msgid ":class:`.HTMLParser` Methods" msgstr ":class:`.HTMLParser` 方法" -#: ../../library/html.parser.rst:85 +#: ../../library/html.parser.rst:87 msgid ":class:`HTMLParser` instances have the following methods:" msgstr ":class:`HTMLParser` 實例具有以下方法:" -#: ../../library/html.parser.rst:90 +#: ../../library/html.parser.rst:92 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 :" @@ -173,7 +174,7 @@ msgstr "" "向剖析器提供一些文本。只要它由完整的元素組成,它就會被處理;不完整的資料會被" "緩衝,直到輸入更多資料或呼叫 :meth:`close`。 *data* 必須是 :class:`str`。" -#: ../../library/html.parser.rst:97 +#: ../../library/html.parser.rst:99 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 " @@ -184,17 +185,17 @@ msgstr "" "重新定義,以在輸入末尾定義額外的處理,但重新定義的版本仍應要呼叫 :class:" "`HTMLParser` 基底類別方法 :meth:`close`。" -#: ../../library/html.parser.rst:105 +#: ../../library/html.parser.rst:107 msgid "" "Reset the instance. Loses all unprocessed data. This is called implicitly " "at instantiation time." msgstr "重置實例。丟棄所有未處理的資料。這在實例化時被會隱晦地呼叫。" -#: ../../library/html.parser.rst:111 +#: ../../library/html.parser.rst:113 msgid "Return current line number and offset." msgstr "回傳當前列號 (line number) 和偏移量 (offset)。" -#: ../../library/html.parser.rst:116 +#: ../../library/html.parser.rst:118 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,7 +206,7 @@ msgstr "" "「已部署」的 HTML 或以最少的更改重新生成輸入(可以保留屬性之間的空白等)時可" "能很有用。" -#: ../../library/html.parser.rst:122 +#: ../../library/html.parser.rst:124 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 " @@ -215,13 +216,13 @@ msgstr "" "當遇到資料或標記元素時將呼叫以下方法,並且它們應在子類別中被覆蓋。基底類別實" "作什麼都不做(除了 :meth:`~HTMLParser.handle_startendtag`):" -#: ../../library/html.parser.rst:129 +#: ../../library/html.parser.rst:131 msgid "" "This method is called to handle the start tag of an element (e.g. ``
``)." msgstr "呼叫此方法來處理元素的開始標籤(例如 ``
``)。" -#: ../../library/html.parser.rst:131 +#: ../../library/html.parser.rst:133 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,7 +234,7 @@ msgstr "" "列表,包含在標籤的 ``<>`` 括號內找到的屬性。 *name* 將被轉成小寫,*value* 中" "的引號會被刪除,字元和實體參照也會被替換。" -#: ../../library/html.parser.rst:137 +#: ../../library/html.parser.rst:139 msgid "" "For instance, for the tag ````, this method " "would be called as ``handle_starttag('a', [('href', 'https://www.cwi." @@ -242,22 +243,22 @@ msgstr "" "例如,對於標籤 ````,這個方法會以 " "``handle_starttag('a', [('href', 'https://www.cwi.nl/')])`` 的形式被呼叫。" -#: ../../library/html.parser.rst:140 +#: ../../library/html.parser.rst:142 msgid "" "All entity references from :mod:`html.entities` are replaced in the " "attribute values." msgstr "在屬性值中來自 :mod:`html.entities` 的所有實體參照都會被替換。" -#: ../../library/html.parser.rst:146 +#: ../../library/html.parser.rst:148 msgid "" "This method is called to handle the end tag of an element (e.g. ``
``)." msgstr "呼叫此方法來處理元素的結束標籤(例如 ``
``)。" -#: ../../library/html.parser.rst:148 +#: ../../library/html.parser.rst:150 msgid "The *tag* argument is the name of the tag converted to lower case." msgstr "*tag* 引數是轉換為小寫的標籤名稱。" -#: ../../library/html.parser.rst:153 +#: ../../library/html.parser.rst:155 msgid "" "Similar to :meth:`handle_starttag`, but called when the parser encounters an " "XHTML-style empty tag (````). This method may be overridden by " @@ -270,7 +271,7 @@ msgstr "" "information) 的子類別覆蓋;預設實作只是呼叫 :meth:`handle_starttag` 和 :meth:" "`handle_endtag`。" -#: ../../library/html.parser.rst:161 +#: ../../library/html.parser.rst:163 msgid "" "This method is called to process arbitrary data (e.g. text nodes and the " "content of ```` and ````)." @@ -278,7 +279,7 @@ msgstr "" "呼叫此方法來處理任意資料(例如文本節點與 ```` 和 " "```` 的內容)。" -#: ../../library/html.parser.rst:167 +#: ../../library/html.parser.rst:169 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. " @@ -288,7 +289,7 @@ msgstr "" "*name* 是一般實體參照(例如 ``'gt'``)。如果 *convert_charrefs* 為 ``True``," "則永遠不會呼叫此方法。" -#: ../../library/html.parser.rst:175 +#: ../../library/html.parser.rst:177 msgid "" "This method is called to process decimal and hexadecimal numeric character " "references of the form :samp:`&#{NNN};` and :samp:`&#x{NNN};`. For example, " @@ -301,13 +302,13 @@ msgstr "" "``;在這種情況下,該方法將收到 ``'62'`` 或 ``'x3E'``。如果 " "*convert_charrefs* 為 ``True``,則永遠不會呼叫此方法。" -#: ../../library/html.parser.rst:184 +#: ../../library/html.parser.rst:186 msgid "" "This method is called when a comment is encountered (e.g. ````)。" -#: ../../library/html.parser.rst:186 +#: ../../library/html.parser.rst:188 msgid "" "For example, the comment ```` will cause this method to be " "called with the argument ``' comment '``." @@ -315,7 +316,7 @@ msgstr "" "舉例來說,註解 ```` 會使得此方法被以引數 ``' comment '`` 來呼" "叫。" -#: ../../library/html.parser.rst:189 +#: ../../library/html.parser.rst:191 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 +335,7 @@ msgstr "" "呼叫此方法來處理 HTML 文件類型聲明 (doctype declaration)(例如 ````)。" -#: ../../library/html.parser.rst:199 +#: ../../library/html.parser.rst:201 msgid "" "The *decl* parameter will be the entire contents of the declaration inside " "the ```` markup (e.g. ``'DOCTYPE html'``)." @@ -342,7 +343,7 @@ msgstr "" "*decl* 參數將是 ```` 標記內聲明部分的全部內容(例如 ``'DOCTYPE " "html'``)。" -#: ../../library/html.parser.rst:205 +#: ../../library/html.parser.rst:207 msgid "" "Method called when a processing instruction is encountered. The *data* " "parameter will contain the entire processing instruction. For example, for " @@ -355,7 +356,7 @@ msgstr "" "``handle_pi(\"proc color='red'\")`` 形式被呼叫。它旨在被衍生類別覆蓋;基底類" "別實作中什麼都不做。" -#: ../../library/html.parser.rst:213 +#: ../../library/html.parser.rst:215 msgid "" "The :class:`HTMLParser` class uses the SGML syntactic rules for processing " "instructions. An XHTML processing instruction using the trailing ``'?'`` " @@ -364,12 +365,12 @@ msgstr "" ":class:`HTMLParser` 類別使用 SGML 語法規則來處理指示。使用有 ``?`` 跟隨在後面" "的 XHTML 處理指示將導致 ``?`` 被包含在 *data* 中。" -#: ../../library/html.parser.rst:220 +#: ../../library/html.parser.rst:222 msgid "" "This method is called when an unrecognized declaration is read by the parser." msgstr "當剖析器讀取無法識別的聲明時會呼叫此方法。" -#: ../../library/html.parser.rst:222 +#: ../../library/html.parser.rst:224 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 +379,18 @@ msgstr "" "*data* 參數將是 ```` 標記內聲明的全部內容。有時被衍生類別被覆蓋會是好" "用的。在基底類別實作中什麼都不做。" -#: ../../library/html.parser.rst:230 +#: ../../library/html.parser.rst:232 msgid "Examples" msgstr "範例" -#: ../../library/html.parser.rst:232 +#: ../../library/html.parser.rst:234 +#, fuzzy msgid "" "The following class implements a parser that will be used to illustrate more " -"examples::" +"examples:" msgstr "以下類別實作了一個剖析器,將用於解說更多範例: ::" -#: ../../library/html.parser.rst:235 +#: ../../library/html.parser.rst:237 msgid "" "from html.parser import HTMLParser\n" "from html.entities import name2codepoint\n" @@ -458,11 +460,12 @@ msgstr "" "\n" "parser = MyHTMLParser()" -#: ../../library/html.parser.rst:269 -msgid "Parsing a doctype::" +#: ../../library/html.parser.rst:273 +#, fuzzy +msgid "Parsing a doctype:" msgstr "剖析文件類型: ::" -#: ../../library/html.parser.rst:271 +#: ../../library/html.parser.rst:275 msgid "" ">>> parser.feed('')\n" @@ -474,11 +477,12 @@ msgstr "" "Decl : DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3." "org/TR/html4/strict.dtd\"" -#: ../../library/html.parser.rst:275 -msgid "Parsing an element with a few attributes and a title::" +#: ../../library/html.parser.rst:281 +#, fuzzy +msgid "Parsing an element with a few attributes and a title:" msgstr "剖析一個具有一些屬性和標題的元素: ::" -#: ../../library/html.parser.rst:277 +#: ../../library/html.parser.rst:283 msgid "" ">>> parser.feed('\"The')\n" "Start tag: img\n" @@ -500,13 +504,14 @@ msgstr "" "Data : Python\n" "End tag : h1" -#: ../../library/html.parser.rst:287 +#: ../../library/html.parser.rst:295 +#, fuzzy msgid "" "The content of ``script`` and ``style`` elements is returned as is, without " -"further parsing::" +"further parsing:" msgstr "``script`` 和 ``style`` 元素的內容按原樣回傳,無需進一步剖析: ::" -#: ../../library/html.parser.rst:290 +#: ../../library/html.parser.rst:298 msgid "" ">>> parser.feed('